feat(agentcompany-rust): scaffold native shell and runtime bridge

This commit is contained in:
ZacharyZhang-NY committed 2026-04-19 01:02:20 -04:00
1 parent 34814b4dfd
commit 2cddf89717
40 files changed
+11300 -3

No files matched your search

@@ -0,0 +1,139 @@
#[derive(Clone, Copy, Debug)]
pub struct ConnectorSeed {
pub id: &'static str,
pub label: &'static str,
pub description: &'static str,
}
pub const CONNECTOR_SEEDS: &[ConnectorSeed] = &[
ConnectorSeed {
id: "claude-pro",
label: "Claude Pro",
description: "Anthropic OAuth session for Claude Pro.",
},
ConnectorSeed {
id: "openai-codex",
label: "OpenAI Codex",
description: "OpenAI OAuth session for Codex desktop flows.",
},
ConnectorSeed {
id: "github-copilot",
label: "GitHub Copilot",
description: "GitHub Copilot OAuth session.",
},
ConnectorSeed {
id: "gemini-cli",
label: "Gemini CLI",
description: "Google Gemini CLI OAuth session.",
},
ConnectorSeed {
id: "antigravity",
label: "Antigravity",
description: "Google Antigravity OAuth session.",
},
ConnectorSeed {
id: "anthropic",
label: "Anthropic",
description: "Anthropic API key connector.",
},
ConnectorSeed {
id: "openai",
label: "OpenAI",
description: "OpenAI API key connector.",
},
ConnectorSeed {
id: "google",
label: "Google",
description: "Google AI Studio API key connector.",
},
ConnectorSeed {
id: "mistral",
label: "Mistral",
description: "Mistral API key connector.",
},
ConnectorSeed {
id: "groq",
label: "Groq",
description: "Groq API key connector.",
},
ConnectorSeed {
id: "cerebras",
label: "Cerebras",
description: "Cerebras API key connector.",
},
ConnectorSeed {
id: "xai",
label: "xAI",
description: "xAI API key connector.",
},
ConnectorSeed {
id: "openrouter",
label: "OpenRouter",
description: "OpenRouter API key connector.",
},
ConnectorSeed {
id: "vercel-ai-gateway",
label: "Vercel AI Gateway",
description: "Vercel AI Gateway API key connector.",
},
ConnectorSeed {
id: "zai",
label: "Z AI",
description: "Z AI API key connector.",
},
ConnectorSeed {
id: "opencode",
label: "OpenCode",
description: "OpenCode API key connector.",
},
ConnectorSeed {
id: "opencode-go",
label: "OpenCode Go",
description: "OpenCode Go API key connector.",
},
ConnectorSeed {
id: "huggingface",
label: "Hugging Face",
description: "Hugging Face API key connector.",
},
ConnectorSeed {
id: "kimi-coding",
label: "Kimi Coding",
description: "Kimi Coding API key connector.",
},
ConnectorSeed {
id: "minimax",
label: "MiniMax",
description: "MiniMax global API connector.",
},
ConnectorSeed {
id: "minimax-cn",
label: "MiniMax CN",
description: "MiniMax China API connector.",
},
ConnectorSeed {
id: "fireworks",
label: "Fireworks",
description: "Fireworks API key connector.",
},
ConnectorSeed {
id: "fireworks-firepass",
label: "Fireworks Firepass",
description: "Fireworks Firepass API key connector.",
},
ConnectorSeed {
id: "amazon-bedrock",
label: "Amazon Bedrock",
description: "AWS Bedrock cloud connector.",
},
ConnectorSeed {
id: "azure-openai",
label: "Azure OpenAI",
description: "Azure OpenAI cloud connector.",
},
ConnectorSeed {
id: "google-vertex",
label: "Google Vertex",
description: "Google Vertex AI cloud connector.",
},
];
@@ -0,0 +1,130 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SectionId {
#[default]
Overview,
Runs,
Inbox,
Messages,
Approvals,
Documents,
Workspaces,
Settings,
}
impl SectionId {
pub fn label(self) -> &'static str {
match self {
Self::Overview => "Dashboard",
Self::Runs => "Runs",
Self::Inbox => "Inbox",
Self::Messages => "Messages",
Self::Approvals => "Approvals",
Self::Documents => "Documents",
Self::Workspaces => "Workspaces",
Self::Settings => "Settings",
}
}
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum CompanyStatus {
#[default]
Active,
Paused,
Archived,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ExecutionMode {
#[default]
AiCeo,
AiCofounder,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WorkspaceState {
Ready,
Busy,
Blocked,
Missing,
Error,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AgentStatus {
Idle,
Active,
Running,
Paused,
Error,
PendingApproval,
Terminated,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TaskStatus {
Backlog,
Todo,
InProgress,
InReview,
Done,
Blocked,
Cancelled,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ApprovalState {
Pending,
Approved,
Rejected,
RevisionRequested,
}
impl ApprovalState {
pub fn as_str(self) -> &'static str {
match self {
Self::Pending => "pending",
Self::Approved => "approved",
Self::Rejected => "rejected",
Self::RevisionRequested => "revision_requested",
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum MessageChannel {
Direct,
Company,
Department,
Project,
Incident,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DocumentStatus {
Draft,
InReview,
Approved,
Archived,
Superseded,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ThreadWaitingFor {
HumanApproval,
HumanReply,
ToolResult,
ExternalEvent,
}
@@ -0,0 +1,9 @@
pub mod catalog;
pub mod enums;
pub mod models;
pub mod snapshot;
pub use catalog::{CONNECTOR_SEEDS, ConnectorSeed};
pub use enums::*;
pub use models::*;
pub use snapshot::ProfileSnapshot;
@@ -0,0 +1,213 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Company {
pub id: String,
pub name: String,
pub description: String,
pub status: String,
pub auto_approve_hires: bool,
pub review_deliverables: bool,
pub execution_mode: String,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Connector {
pub id: String,
pub label: String,
pub description: String,
pub status: String,
pub version: Option<String>,
pub auth_state: String,
pub last_checked_at: Option<String>,
pub last_error: Option<String>,
pub model: Option<String>,
pub env_binding_text: String,
pub notes: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Workspace {
pub id: String,
pub company_id: String,
pub name: String,
pub local_path: String,
pub repo_url: String,
pub repo_ref: String,
pub project_id: Option<String>,
pub state: String,
pub is_primary: bool,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Agent {
pub id: String,
pub company_id: String,
pub name: String,
pub role: String,
pub title: String,
pub department: Option<String>,
pub status: String,
pub reports_to: Option<String>,
pub connector_id: String,
pub workspace_id: Option<String>,
pub model: Option<String>,
pub capabilities: String,
pub budget_monthly_usd: f64,
pub spent_monthly_usd: f64,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Goal {
pub id: String,
pub company_id: String,
pub title: String,
pub description: String,
pub parent_id: Option<String>,
pub owner_agent_id: Option<String>,
pub status: String,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Project {
pub id: String,
pub company_id: String,
pub goal_id: Option<String>,
pub name: String,
pub description: String,
pub lead_agent_id: Option<String>,
pub status: String,
pub target_date: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Task {
pub id: String,
pub company_id: String,
pub project_id: Option<String>,
pub goal_id: Option<String>,
pub parent_id: Option<String>,
pub title: String,
pub description: String,
pub assignee_agent_id: Option<String>,
pub workspace_id: Option<String>,
pub status: String,
pub priority: String,
pub active_run_id: Option<String>,
pub cost_usd: f64,
pub task_type: Option<String>,
pub requires_user_review: bool,
pub started_at: Option<String>,
pub completed_at: Option<String>,
pub cancelled_at: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Approval {
pub id: String,
pub company_id: String,
pub related_task_id: Option<String>,
pub related_agent_id: Option<String>,
pub requested_by_agent_id: Option<String>,
pub approval_type: String,
pub payload_summary: String,
pub impact_summary: String,
pub payload_json: Option<String>,
pub decision_note: String,
pub state: String,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Run {
pub id: String,
pub company_id: String,
pub task_id: Option<String>,
pub agent_id: String,
pub workspace_id: Option<String>,
pub connector_id: String,
pub status: String,
pub summary: String,
pub error_message: Option<String>,
pub model: Option<String>,
pub cost_usd: Option<f64>,
pub started_at: Option<String>,
pub finished_at: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Activity {
pub id: String,
pub company_id: String,
pub actor: String,
pub action: String,
pub entity_type: String,
pub entity_id: String,
pub detail: String,
pub created_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct AgentMessage {
pub id: String,
pub company_id: String,
pub from_agent_id: String,
pub to_agent_id: Option<String>,
pub sender_kind: String,
pub channel: String,
pub channel_target_id: Option<String>,
pub subject: String,
pub body: String,
pub priority: String,
pub read_at: Option<String>,
pub parent_message_id: Option<String>,
pub attachments_json: String,
pub created_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Document {
pub id: String,
pub company_id: String,
pub document_type: String,
pub title: String,
pub content: String,
pub author_agent_id: Option<String>,
pub reviewer_agent_id: Option<String>,
pub project_id: Option<String>,
pub goal_id: Option<String>,
pub parent_doc_id: Option<String>,
pub version: i64,
pub status: String,
pub tags_json: String,
pub latest_revision_id: Option<String>,
pub created_at: String,
pub updated_at: String,
}
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ThreadWaitState {
pub id: String,
pub thread_id: String,
pub company_id: String,
pub waiting_for: String,
pub related_approval_id: Option<String>,
pub reason: String,
pub created_at: String,
pub resolved_at: Option<String>,
}
@@ -0,0 +1,71 @@
use crate::{
Activity, Agent, AgentMessage, Approval, Company, Connector, Document, Goal, Project, Run,
Task, Workspace,
};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ProfileSnapshot {
pub current_company_id: Option<String>,
pub profile_path: String,
pub theme: String,
pub locale: String,
pub companies: Vec<Company>,
pub connectors: Vec<Connector>,
pub workspaces: Vec<Workspace>,
pub agents: Vec<Agent>,
pub goals: Vec<Goal>,
pub projects: Vec<Project>,
pub tasks: Vec<Task>,
pub approvals: Vec<Approval>,
pub runs: Vec<Run>,
pub activity: Vec<Activity>,
pub agent_messages: Vec<AgentMessage>,
pub documents: Vec<Document>,
}
impl ProfileSnapshot {
pub fn current_company(&self) -> Option<&Company> {
self.current_company_id
.as_ref()
.and_then(|company_id| {
self.companies
.iter()
.find(|company| &company.id == company_id)
})
.or_else(|| self.companies.first())
}
pub fn unread_messages(&self) -> usize {
self.agent_messages
.iter()
.filter(|message| message.read_at.is_none())
.count()
}
pub fn pending_approvals(&self) -> usize {
self.approvals
.iter()
.filter(|approval| approval.state == "pending")
.count()
}
pub fn active_tasks(&self) -> usize {
self.tasks
.iter()
.filter(|task| matches!(task.status.as_str(), "todo" | "in_progress" | "in_review"))
.count()
}
pub fn active_runs(&self) -> usize {
self.runs
.iter()
.filter(|run| {
matches!(
run.status.as_str(),
"queued" | "running" | "waiting_approval" | "paused"
)
})
.count()
}
}