update
This commit is contained in:
1 parent
41eafc7c44
commit
54bcc77ef7
19 files changed
+11420
-64
No files matched your search
+253
-3
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { CommentRecord, DesktopEvent, ProfileSnapshot } from "./types";
|
||||
import type { AgentMessageRecord, AgentMetrics, AutomationRuleRecord, BrowserActionRecord, CommentRecord, CompanyMetrics, CompanyTemplate, DesktopEvent, DocumentRecord, InboxItem, KnowledgeEntryRecord, MeetingRecord, ProfileSnapshot, SocialAccountRecord, SprintRecord, StandupReport, WorkflowPipelineRecord } from "./types";
|
||||
|
||||
export const IPC_CHANNELS = {
|
||||
loadSnapshot: "agent-company:load-snapshot",
|
||||
@@ -40,6 +40,45 @@ export const IPC_CHANNELS = {
|
||||
triggerHeartbeat: "agent-company:trigger-heartbeat",
|
||||
getApiPort: "agent-company:get-api-port",
|
||||
rendererEvent: "agent-company:event",
|
||||
getInbox: "agent-company:get-inbox",
|
||||
dismissInboxItem: "agent-company:dismiss-inbox-item",
|
||||
getCompanyMetrics: "agent-company:get-company-metrics",
|
||||
getAgentMetrics: "agent-company:get-agent-metrics",
|
||||
getStandupReport: "agent-company:get-standup-report",
|
||||
applyCompanyTemplate: "agent-company:apply-company-template",
|
||||
listCompanyTemplates: "agent-company:list-company-templates",
|
||||
saveSocialAccount: "agent-company:save-social-account",
|
||||
deleteSocialAccount: "agent-company:delete-social-account",
|
||||
listBrowserActions: "agent-company:list-browser-actions",
|
||||
cancelBrowserAction: "agent-company:cancel-browser-action",
|
||||
triggerBrowserLogin: "agent-company:trigger-browser-login",
|
||||
// Meetings
|
||||
saveMeeting: "agent-company:save-meeting",
|
||||
deleteMeeting: "agent-company:delete-meeting",
|
||||
// Documents
|
||||
saveDocument: "agent-company:save-document",
|
||||
deleteDocument: "agent-company:delete-document",
|
||||
// Knowledge Base
|
||||
saveKnowledgeEntry: "agent-company:save-knowledge-entry",
|
||||
deleteKnowledgeEntry: "agent-company:delete-knowledge-entry",
|
||||
// Sprints
|
||||
saveSprint: "agent-company:save-sprint",
|
||||
deleteSprint: "agent-company:delete-sprint",
|
||||
// Automation
|
||||
saveAutomationRule: "agent-company:save-automation-rule",
|
||||
deleteAutomationRule: "agent-company:delete-automation-rule",
|
||||
toggleAutomationRule: "agent-company:toggle-automation-rule",
|
||||
getAutomationLog: "agent-company:get-automation-log",
|
||||
// Agent Messages
|
||||
sendAgentMessage: "agent-company:send-agent-message",
|
||||
listAgentMessages: "agent-company:list-agent-messages",
|
||||
markMessageRead: "agent-company:mark-message-read",
|
||||
// Workflows
|
||||
saveWorkflow: "agent-company:save-workflow",
|
||||
deleteWorkflow: "agent-company:delete-workflow",
|
||||
runWorkflow: "agent-company:run-workflow",
|
||||
// Auto-assign
|
||||
autoAssignTask: "agent-company:auto-assign-task",
|
||||
} as const;
|
||||
|
||||
const optionalId = z.preprocess(
|
||||
@@ -80,6 +119,7 @@ export const agentInputSchema = z.object({
|
||||
name: z.string().min(2).max(80),
|
||||
role: z.string().min(2).max(80),
|
||||
title: z.string().default(""),
|
||||
department: z.enum(["executive", "engineering", "product", "marketing", "sales", "hr", "finance", "legal", "operations", "customer_support", "research", "design"]).nullable().optional(),
|
||||
reportsTo: optionalId,
|
||||
connectorId: connectorInputSchema.shape.id,
|
||||
workspaceId: optionalId,
|
||||
@@ -129,7 +169,7 @@ export const approvalInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
relatedTaskId: optionalId,
|
||||
requestedByAgentId: optionalId,
|
||||
type: z.enum(["hire_agent", "approve_ceo_strategy", "dangerous_command", "secret_access"]),
|
||||
type: z.enum(["hire_agent", "approve_ceo_strategy", "dangerous_command", "secret_access", "budget_request", "promotion", "termination", "vendor_approval", "document_review", "production_deploy", "incident_escalation"]),
|
||||
payloadSummary: z.string().min(2).max(280),
|
||||
impactSummary: z.string().min(2).max(400),
|
||||
});
|
||||
@@ -202,7 +242,178 @@ export const heartbeatSettingsSchema = z.object({
|
||||
export const triggerHeartbeatSchema = z.object({
|
||||
agentId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
trigger: z.enum(["manual", "timer", "assignment", "goal_activated", "approval_resolved", "subtask_completed", "comment", "report_blocked", "report_failed", "recovery"]).default("manual"),
|
||||
trigger: z.enum(["manual", "timer", "assignment", "goal_activated", "approval_resolved", "subtask_completed", "comment", "report_blocked", "report_failed", "recovery", "message", "peer_request"]).default("manual"),
|
||||
});
|
||||
|
||||
export const inboxDismissSchema = z.object({
|
||||
itemId: z.string(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const metricsQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
days: z.number().int().min(1).max(90).default(30),
|
||||
});
|
||||
|
||||
export const templateApplySchema = z.object({
|
||||
templateId: z.string(),
|
||||
companyName: z.string().min(2).max(80),
|
||||
companyDescription: z.string().max(500).default(""),
|
||||
workspaceId: z.string().uuid().optional(),
|
||||
connectorId: z.enum(["codex_local", "claude_local", "gemini_local", "opencode_local", "kimi_local"]).optional(),
|
||||
});
|
||||
|
||||
export const socialAccountInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
platform: z.enum(["twitter", "linkedin", "instagram", "facebook", "reddit", "youtube", "tiktok", "bluesky", "other"]),
|
||||
accountName: z.string().min(1).max(120),
|
||||
displayName: z.string().max(120).default(""),
|
||||
profileUrl: z.string().max(500).default(""),
|
||||
credentialSecretId: optionalId,
|
||||
status: z.enum(["active", "logged_in", "login_required", "suspended", "paused"]).default("login_required"),
|
||||
requireApproval: z.boolean().default(true),
|
||||
metadataJson: z.string().default("{}"),
|
||||
});
|
||||
|
||||
export const meetingInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
type: z.enum(["standup", "sprint_planning", "sprint_review", "retrospective", "one_on_one", "all_hands", "department_sync", "incident_review", "hiring_committee", "budget_review", "design_review", "architecture_review"]),
|
||||
title: z.string().min(2).max(160),
|
||||
organizerAgentId: optionalId,
|
||||
participantAgentIds: z.string().default("[]"),
|
||||
scheduledAt: z.string(),
|
||||
durationMinutes: z.number().int().min(5).max(480).default(30),
|
||||
agendaJson: z.string().default("[]"),
|
||||
notesJson: z.string().default("[]"),
|
||||
decisionsJson: z.string().default("[]"),
|
||||
actionItemsJson: z.string().default("[]"),
|
||||
status: z.enum(["scheduled", "in_progress", "completed", "cancelled"]).default("scheduled"),
|
||||
});
|
||||
|
||||
export const documentInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
type: z.enum(["prd", "technical_spec", "design_doc", "test_plan", "post_mortem", "meeting_notes", "budget_proposal", "hiring_requisition", "performance_review_doc", "sop", "knowledge_article", "project_brief", "sprint_report", "incident_report", "onboarding_guide", "architecture_decision", "status_report", "contract", "proposal"]),
|
||||
title: z.string().min(2).max(200),
|
||||
content: z.string().default(""),
|
||||
authorAgentId: optionalId,
|
||||
reviewerAgentId: optionalId,
|
||||
projectId: optionalId,
|
||||
goalId: optionalId,
|
||||
parentDocId: optionalId,
|
||||
version: z.number().int().min(1).default(1),
|
||||
status: z.enum(["draft", "in_review", "approved", "archived", "superseded"]).default("draft"),
|
||||
tagsJson: z.string().default("[]"),
|
||||
});
|
||||
|
||||
export const knowledgeEntryInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
category: z.enum(["lesson_learned", "best_practice", "decision", "process", "technical", "business", "onboarding", "incident"]),
|
||||
topic: z.string().min(2).max(200),
|
||||
content: z.string().min(1),
|
||||
authorAgentId: optionalId,
|
||||
importance: z.enum(["critical", "high", "medium", "low"]).default("medium"),
|
||||
tagsJson: z.string().default("[]"),
|
||||
referencedEntityType: z.string().nullable().optional(),
|
||||
referencedEntityId: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const sprintInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(120),
|
||||
goal: z.string().default(""),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
status: z.enum(["planning", "active", "review", "completed", "cancelled"]).default("planning"),
|
||||
retrospectiveNotes: z.string().default(""),
|
||||
velocityPoints: z.number().int().min(0).default(0),
|
||||
completedPoints: z.number().int().min(0).default(0),
|
||||
});
|
||||
|
||||
export const browserActionQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
socialAccountId: z.string().uuid().optional(),
|
||||
status: z.string().optional(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
});
|
||||
|
||||
// ── Automation Schemas ──────────────────────────────────────────────────
|
||||
export const automationRuleInputSchema = z.object({
|
||||
id: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(120),
|
||||
description: z.string().max(500).default(""),
|
||||
trigger: z.enum([
|
||||
"task_status_changed", "task_created", "task_blocked", "run_completed",
|
||||
"run_failed", "approval_resolved", "budget_threshold", "agent_idle",
|
||||
"comment_posted", "document_created", "schedule", "hire_approved",
|
||||
"sprint_started", "sprint_ended",
|
||||
]),
|
||||
conditionsJson: z.string().default("{}"),
|
||||
action: z.enum([
|
||||
"assign_task", "create_task", "notify_agent", "send_message",
|
||||
"trigger_heartbeat", "create_approval", "update_task_status",
|
||||
"escalate_to_manager", "cross_department_notify", "schedule_meeting",
|
||||
"create_document", "auto_approve", "reassign_task", "run_task",
|
||||
]),
|
||||
actionConfigJson: z.string().default("{}"),
|
||||
sourceDepartment: z.enum([
|
||||
"executive", "engineering", "product", "marketing", "sales",
|
||||
"hr", "finance", "legal", "operations", "customer_support", "research", "design",
|
||||
]).nullable().optional(),
|
||||
targetDepartment: z.enum([
|
||||
"executive", "engineering", "product", "marketing", "sales",
|
||||
"hr", "finance", "legal", "operations", "customer_support", "research", "design",
|
||||
]).nullable().optional(),
|
||||
priority: z.number().int().min(0).max(100).default(50),
|
||||
status: z.enum(["active", "paused", "disabled", "error"]).default("active"),
|
||||
});
|
||||
|
||||
export const agentMessageInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
fromAgentId: z.string().uuid(),
|
||||
toAgentId: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).default("direct"),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
subject: z.string().min(1).max(200),
|
||||
body: z.string().min(1).max(8000),
|
||||
priority: z.enum(["urgent", "normal", "low"]).default("normal"),
|
||||
parentMessageId: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
attachmentsJson: z.string().default("[]"),
|
||||
});
|
||||
|
||||
export const messageQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).optional(),
|
||||
unreadOnly: z.boolean().optional(),
|
||||
limit: z.number().int().min(1).max(200).default(50),
|
||||
});
|
||||
|
||||
export const workflowInputSchema = z.object({
|
||||
id: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(120),
|
||||
description: z.string().max(500).default(""),
|
||||
stepsJson: z.string().default("[]"),
|
||||
triggerType: z.enum([
|
||||
"task_status_changed", "task_created", "task_blocked", "run_completed",
|
||||
"run_failed", "approval_resolved", "budget_threshold", "agent_idle",
|
||||
"comment_posted", "document_created", "schedule", "hire_approved",
|
||||
"sprint_started", "sprint_ended",
|
||||
]),
|
||||
triggerConfigJson: z.string().default("{}"),
|
||||
status: z.enum(["draft", "active", "paused", "completed", "failed"]).default("draft"),
|
||||
});
|
||||
|
||||
export const autoAssignSchema = z.object({
|
||||
taskId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export type DesktopResult<T> =
|
||||
@@ -247,5 +458,44 @@ export type DesktopApi = {
|
||||
setHeartbeat: (input: z.infer<typeof heartbeatSettingsSchema>) => Promise<DesktopResult<boolean>>;
|
||||
triggerHeartbeat: (input: z.infer<typeof triggerHeartbeatSchema>) => Promise<DesktopResult<string>>;
|
||||
getApiPort: () => Promise<DesktopResult<number>>;
|
||||
getInbox: (companyId: string) => Promise<DesktopResult<InboxItem[]>>;
|
||||
dismissInboxItem: (input: z.infer<typeof inboxDismissSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getCompanyMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<CompanyMetrics>>;
|
||||
getAgentMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<AgentMetrics>>;
|
||||
getStandupReport: (companyId: string) => Promise<DesktopResult<StandupReport>>;
|
||||
applyCompanyTemplate: (input: z.infer<typeof templateApplySchema>) => Promise<DesktopResult<string>>;
|
||||
listCompanyTemplates: () => Promise<DesktopResult<CompanyTemplate[]>>;
|
||||
saveSocialAccount: (input: z.infer<typeof socialAccountInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteSocialAccount: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
listBrowserActions: (input: z.infer<typeof browserActionQuerySchema>) => Promise<DesktopResult<BrowserActionRecord[]>>;
|
||||
cancelBrowserAction: (input: z.infer<typeof cancelRunSchema>) => Promise<DesktopResult<boolean>>;
|
||||
triggerBrowserLogin: (socialAccountId: string) => Promise<DesktopResult<boolean>>;
|
||||
// Meetings
|
||||
saveMeeting: (input: z.infer<typeof meetingInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteMeeting: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
// Documents
|
||||
saveDocument: (input: z.infer<typeof documentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteDocument: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
// Knowledge Base
|
||||
saveKnowledgeEntry: (input: z.infer<typeof knowledgeEntryInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteKnowledgeEntry: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
// Sprints
|
||||
saveSprint: (input: z.infer<typeof sprintInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteSprint: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
// Automation
|
||||
saveAutomationRule: (input: z.infer<typeof automationRuleInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteAutomationRule: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
toggleAutomationRule: (input: { id: string; companyId: string; status: "active" | "paused" }) => Promise<DesktopResult<boolean>>;
|
||||
getAutomationLog: (companyId: string) => Promise<DesktopResult<Array<{ ruleId: string; ruleName: string; trigger: string; action: string; executedAt: string }>>>;
|
||||
// Agent Messages
|
||||
sendAgentMessage: (input: z.infer<typeof agentMessageInputSchema>) => Promise<DesktopResult<string>>;
|
||||
listAgentMessages: (input: z.infer<typeof messageQuerySchema>) => Promise<DesktopResult<AgentMessageRecord[]>>;
|
||||
markMessageRead: (input: { messageId: string; companyId: string }) => Promise<DesktopResult<boolean>>;
|
||||
// Workflows
|
||||
saveWorkflow: (input: z.infer<typeof workflowInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteWorkflow: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
runWorkflow: (input: { id: string; companyId: string }) => Promise<DesktopResult<boolean>>;
|
||||
// Auto-assign
|
||||
autoAssignTask: (input: z.infer<typeof autoAssignSchema>) => Promise<DesktopResult<string>>;
|
||||
subscribe: (callback: (event: DesktopEvent) => void) => () => void;
|
||||
};
|
||||
+483
-3
@@ -1,8 +1,12 @@
|
||||
export type SectionId =
|
||||
| "overview"
|
||||
| "inbox"
|
||||
| "standup"
|
||||
| "performance"
|
||||
| "connectors"
|
||||
| "agents"
|
||||
| "orgchart"
|
||||
| "hiring"
|
||||
| "goals"
|
||||
| "projects"
|
||||
| "tasks"
|
||||
@@ -10,6 +14,13 @@ export type SectionId =
|
||||
| "costs"
|
||||
| "activity"
|
||||
| "workspaces"
|
||||
| "social"
|
||||
| "automation"
|
||||
| "communication"
|
||||
| "documents"
|
||||
| "knowledge"
|
||||
| "meetings"
|
||||
| "sprints"
|
||||
| "settings";
|
||||
|
||||
export type ConnectorId =
|
||||
@@ -41,6 +52,18 @@ export type GoalStatus = "planned" | "active" | "achieved" | "cancelled";
|
||||
export type ProjectStatus = "backlog" | "planned" | "in_progress" | "completed" | "cancelled";
|
||||
export type TaskStatus = "backlog" | "todo" | "in_progress" | "in_review" | "done" | "blocked" | "cancelled";
|
||||
export type ApprovalState = "pending" | "approved" | "rejected" | "revision_requested";
|
||||
export type ApprovalType =
|
||||
| "hire_agent"
|
||||
| "approve_ceo_strategy"
|
||||
| "dangerous_command"
|
||||
| "secret_access"
|
||||
| "budget_request"
|
||||
| "promotion"
|
||||
| "termination"
|
||||
| "vendor_approval"
|
||||
| "document_review"
|
||||
| "production_deploy"
|
||||
| "incident_escalation";
|
||||
export type RunStatus =
|
||||
| "queued"
|
||||
| "running"
|
||||
@@ -99,12 +122,28 @@ export interface WorkspaceRecord {
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Departments ────────────────────────────────────────────────────────
|
||||
export type DepartmentId =
|
||||
| "executive"
|
||||
| "engineering"
|
||||
| "product"
|
||||
| "marketing"
|
||||
| "sales"
|
||||
| "hr"
|
||||
| "finance"
|
||||
| "legal"
|
||||
| "operations"
|
||||
| "customer_support"
|
||||
| "research"
|
||||
| "design";
|
||||
|
||||
export interface AgentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
role: string;
|
||||
title: string;
|
||||
department: DepartmentId | null;
|
||||
status: AgentStatus;
|
||||
reportsTo: string | null;
|
||||
connectorId: ConnectorId;
|
||||
@@ -172,7 +211,7 @@ export interface ApprovalRecord {
|
||||
relatedTaskId: string | null;
|
||||
relatedAgentId: string | null;
|
||||
requestedByAgentId: string | null;
|
||||
type: "hire_agent" | "approve_ceo_strategy" | "dangerous_command" | "secret_access";
|
||||
type: ApprovalType;
|
||||
payloadSummary: string;
|
||||
impactSummary: string;
|
||||
payloadJson: string | null;
|
||||
@@ -258,6 +297,15 @@ export interface ProfileSnapshot {
|
||||
activity: ActivityRecord[];
|
||||
secrets: SecretRecord[];
|
||||
comments: CommentRecord[];
|
||||
socialAccounts: SocialAccountRecord[];
|
||||
browserActions: BrowserActionRecord[];
|
||||
meetings: MeetingRecord[];
|
||||
documents: DocumentRecord[];
|
||||
knowledgeBase: KnowledgeEntryRecord[];
|
||||
sprints: SprintRecord[];
|
||||
automationRules: AutomationRuleRecord[];
|
||||
agentMessages: AgentMessageRecord[];
|
||||
workflows: WorkflowPipelineRecord[];
|
||||
}
|
||||
|
||||
export interface LogChunkEvent {
|
||||
@@ -283,7 +331,7 @@ export interface RunStatusEvent {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type HeartbeatTrigger = "manual" | "timer" | "assignment" | "goal_activated" | "approval_resolved" | "subtask_completed" | "comment" | "report_blocked" | "report_failed" | "recovery";
|
||||
export type HeartbeatTrigger = "manual" | "timer" | "assignment" | "goal_activated" | "approval_resolved" | "subtask_completed" | "comment" | "report_blocked" | "report_failed" | "recovery" | "message" | "peer_request";
|
||||
|
||||
export interface CommentRecord {
|
||||
id: string;
|
||||
@@ -313,10 +361,442 @@ export interface AgentMessageEvent {
|
||||
comment: CommentRecord;
|
||||
}
|
||||
|
||||
export interface AutomationFiredEvent {
|
||||
type: "automation-fired";
|
||||
ruleId: string;
|
||||
ruleName: string;
|
||||
trigger: AutomationTrigger;
|
||||
action: AutomationAction;
|
||||
}
|
||||
|
||||
export interface NewMessageEvent {
|
||||
type: "new-message";
|
||||
message: AgentMessageRecord;
|
||||
}
|
||||
|
||||
export type DesktopEvent =
|
||||
| LogChunkEvent
|
||||
| DomainChangedEvent
|
||||
| ShortcutEvent
|
||||
| RunStatusEvent
|
||||
| HeartbeatStatusEvent
|
||||
| AgentMessageEvent;
|
||||
| AgentMessageEvent
|
||||
| AutomationFiredEvent
|
||||
| NewMessageEvent;
|
||||
|
||||
// ── Inbox ──────────────────────────────────────────────────────────────
|
||||
export type InboxItemType = "pending_approval" | "failed_run" | "budget_warning" | "blocked_task" | "review_needed" | "agent_message";
|
||||
|
||||
export interface InboxItem {
|
||||
id: string;
|
||||
type: InboxItemType;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
severity: "critical" | "high" | "medium" | "low";
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
agentId: string | null;
|
||||
agentName: string | null;
|
||||
createdAt: string;
|
||||
dismissed: boolean;
|
||||
}
|
||||
|
||||
// ── Performance Metrics ────────────────────────────────────────────────
|
||||
export interface AgentMetrics {
|
||||
agentId: string;
|
||||
agentName: string;
|
||||
tasksCompleted: number;
|
||||
tasksAssigned: number;
|
||||
tasksFailed: number;
|
||||
successRate: number; // 0-100
|
||||
avgRunDurationSec: number;
|
||||
totalCostUsd: number;
|
||||
runsTotal: number;
|
||||
runsSucceeded: number;
|
||||
runsFailed: number;
|
||||
reviewCycles: number; // how many times work was sent back for revision
|
||||
lastActiveAt: string | null;
|
||||
}
|
||||
|
||||
export interface CompanyMetrics {
|
||||
totalAgents: number;
|
||||
activeAgents: number;
|
||||
totalTasks: number;
|
||||
completedTasks: number;
|
||||
blockedTasks: number;
|
||||
totalRuns: number;
|
||||
successfulRuns: number;
|
||||
failedRuns: number;
|
||||
overallSuccessRate: number;
|
||||
totalCostUsd: number;
|
||||
avgCostPerTask: number;
|
||||
throughputTasksPerDay: number;
|
||||
agentMetrics: AgentMetrics[];
|
||||
}
|
||||
|
||||
// ── Company Template ───────────────────────────────────────────────────
|
||||
export interface CompanyTemplate {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
agents: Array<{
|
||||
name: string;
|
||||
role: string;
|
||||
title: string;
|
||||
department: DepartmentId;
|
||||
capabilities: string;
|
||||
reportsToIndex: number | null; // index in this array, null = CEO
|
||||
connectorPreference: ConnectorId;
|
||||
budgetMonthlyUsd: number;
|
||||
}>;
|
||||
goals: Array<{
|
||||
title: string;
|
||||
description: string;
|
||||
}>;
|
||||
departments?: Array<{
|
||||
id: DepartmentId;
|
||||
name: string;
|
||||
description: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
// ── Social Media / Browser Automation ──────────────────────────────
|
||||
export type SocialPlatform = "twitter" | "linkedin" | "instagram" | "facebook" | "reddit" | "youtube" | "tiktok" | "bluesky" | "other";
|
||||
export type SocialAccountStatus = "active" | "logged_in" | "login_required" | "suspended" | "paused";
|
||||
export type BrowserActionType = "post" | "reply" | "like" | "follow" | "browse_feed" | "screenshot" | "navigate" | "search" | "dm" | "custom_script";
|
||||
export type BrowserActionStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled" | "approval_required";
|
||||
|
||||
export interface SocialAccountRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
platform: SocialPlatform;
|
||||
accountName: string;
|
||||
displayName: string;
|
||||
profileUrl: string;
|
||||
/** Secret ID for stored credentials (username/password/cookies) */
|
||||
credentialSecretId: string | null;
|
||||
status: SocialAccountStatus;
|
||||
/** Whether posts require Board approval before publishing */
|
||||
requireApproval: boolean;
|
||||
/** JSON metadata: bio, follower count, etc. */
|
||||
metadataJson: string;
|
||||
lastUsedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BrowserActionRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
socialAccountId: string;
|
||||
agentId: string;
|
||||
taskId: string | null;
|
||||
actionType: BrowserActionType;
|
||||
/** JSON payload: content, targetUrl, selector, script, etc. */
|
||||
payloadJson: string;
|
||||
status: BrowserActionStatus;
|
||||
/** Result summary after execution */
|
||||
resultSummary: string;
|
||||
/** Screenshot path after execution */
|
||||
screenshotPath: string | null;
|
||||
/** Approval ID if approval was required */
|
||||
approvalId: string | null;
|
||||
errorMessage: string | null;
|
||||
startedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Meetings ──────────────────────────────────────────────────────────
|
||||
export type MeetingType =
|
||||
| "standup"
|
||||
| "sprint_planning"
|
||||
| "sprint_review"
|
||||
| "retrospective"
|
||||
| "one_on_one"
|
||||
| "all_hands"
|
||||
| "department_sync"
|
||||
| "incident_review"
|
||||
| "hiring_committee"
|
||||
| "budget_review"
|
||||
| "design_review"
|
||||
| "architecture_review";
|
||||
|
||||
export type MeetingStatus = "scheduled" | "in_progress" | "completed" | "cancelled";
|
||||
|
||||
export interface MeetingRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
type: MeetingType;
|
||||
title: string;
|
||||
organizerAgentId: string | null;
|
||||
participantAgentIds: string; // JSON array of agent IDs
|
||||
scheduledAt: string;
|
||||
durationMinutes: number;
|
||||
agendaJson: string;
|
||||
notesJson: string;
|
||||
decisionsJson: string;
|
||||
actionItemsJson: string;
|
||||
status: MeetingStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Documents ─────────────────────────────────────────────────────────
|
||||
export type DocumentType =
|
||||
| "prd"
|
||||
| "technical_spec"
|
||||
| "design_doc"
|
||||
| "test_plan"
|
||||
| "post_mortem"
|
||||
| "meeting_notes"
|
||||
| "budget_proposal"
|
||||
| "hiring_requisition"
|
||||
| "performance_review_doc"
|
||||
| "sop"
|
||||
| "knowledge_article"
|
||||
| "project_brief"
|
||||
| "sprint_report"
|
||||
| "incident_report"
|
||||
| "onboarding_guide"
|
||||
| "architecture_decision"
|
||||
| "status_report"
|
||||
| "contract"
|
||||
| "proposal";
|
||||
|
||||
export type DocumentStatus = "draft" | "in_review" | "approved" | "archived" | "superseded";
|
||||
|
||||
export interface DocumentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
type: DocumentType;
|
||||
title: string;
|
||||
content: string;
|
||||
authorAgentId: string | null;
|
||||
reviewerAgentId: string | null;
|
||||
projectId: string | null;
|
||||
goalId: string | null;
|
||||
parentDocId: string | null;
|
||||
version: number;
|
||||
status: DocumentStatus;
|
||||
tagsJson: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Knowledge Base ────────────────────────────────────────────────────
|
||||
export type KnowledgeCategory =
|
||||
| "lesson_learned"
|
||||
| "best_practice"
|
||||
| "decision"
|
||||
| "process"
|
||||
| "technical"
|
||||
| "business"
|
||||
| "onboarding"
|
||||
| "incident";
|
||||
|
||||
export interface KnowledgeEntryRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
category: KnowledgeCategory;
|
||||
topic: string;
|
||||
content: string;
|
||||
authorAgentId: string | null;
|
||||
importance: "critical" | "high" | "medium" | "low";
|
||||
tagsJson: string;
|
||||
referencedEntityType: string | null;
|
||||
referencedEntityId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Sprints ───────────────────────────────────────────────────────────
|
||||
export type SprintStatus = "planning" | "active" | "review" | "completed" | "cancelled";
|
||||
|
||||
export interface SprintRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
goal: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
status: SprintStatus;
|
||||
retrospectiveNotes: string;
|
||||
velocityPoints: number;
|
||||
completedPoints: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Performance Reviews ───────────────────────────────────────────────
|
||||
export type ReviewStatus = "draft" | "submitted" | "acknowledged";
|
||||
|
||||
export interface PerformanceReviewRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
agentId: string;
|
||||
reviewerAgentId: string;
|
||||
period: string; // e.g., "2026-Q1"
|
||||
rating: number; // 1-5
|
||||
strengths: string;
|
||||
areasForImprovement: string;
|
||||
goals: string;
|
||||
status: ReviewStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Standup Report ─────────────────────────────────────────────────────
|
||||
export interface StandupReport {
|
||||
companyId: string;
|
||||
generatedAt: string;
|
||||
summary: string;
|
||||
agentReports: Array<{
|
||||
agentId: string;
|
||||
agentName: string;
|
||||
role: string;
|
||||
status: AgentStatus;
|
||||
tasksInProgress: number;
|
||||
tasksCompleted24h: number;
|
||||
tasksBlocked: number;
|
||||
lastRunStatus: RunStatus | null;
|
||||
lastRunAt: string | null;
|
||||
costLast24h: number;
|
||||
highlights: string[];
|
||||
}>;
|
||||
companyHighlights: string[];
|
||||
blockers: string[];
|
||||
pendingApprovals: number;
|
||||
budgetUtilization: number; // 0-100
|
||||
}
|
||||
|
||||
// ── Automation Engine ─────────────────────────────────────────────────
|
||||
export type AutomationTrigger =
|
||||
| "task_status_changed"
|
||||
| "task_created"
|
||||
| "task_blocked"
|
||||
| "run_completed"
|
||||
| "run_failed"
|
||||
| "approval_resolved"
|
||||
| "budget_threshold"
|
||||
| "agent_idle"
|
||||
| "comment_posted"
|
||||
| "document_created"
|
||||
| "schedule"
|
||||
| "hire_approved"
|
||||
| "sprint_started"
|
||||
| "sprint_ended";
|
||||
|
||||
export type AutomationAction =
|
||||
| "assign_task"
|
||||
| "create_task"
|
||||
| "notify_agent"
|
||||
| "send_message"
|
||||
| "trigger_heartbeat"
|
||||
| "create_approval"
|
||||
| "update_task_status"
|
||||
| "escalate_to_manager"
|
||||
| "cross_department_notify"
|
||||
| "schedule_meeting"
|
||||
| "create_document"
|
||||
| "auto_approve"
|
||||
| "reassign_task"
|
||||
| "run_task";
|
||||
|
||||
export type AutomationStatus = "active" | "paused" | "disabled" | "error";
|
||||
|
||||
export interface AutomationRuleRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
trigger: AutomationTrigger;
|
||||
/** JSON conditions: e.g., {"status": "blocked", "department": "engineering"} */
|
||||
conditionsJson: string;
|
||||
action: AutomationAction;
|
||||
/** JSON action config: e.g., {"targetAgentId": "...", "message": "..."} */
|
||||
actionConfigJson: string;
|
||||
/** Source department that triggers (null = any) */
|
||||
sourceDepartment: DepartmentId | null;
|
||||
/** Target department for cross-department rules (null = same) */
|
||||
targetDepartment: DepartmentId | null;
|
||||
priority: number;
|
||||
status: AutomationStatus;
|
||||
/** How many times this rule has fired */
|
||||
executionCount: number;
|
||||
lastExecutedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// ── Agent Messages (Direct Communication) ─────────────────────────────
|
||||
export type MessageChannel = "direct" | "department" | "company" | "project" | "incident";
|
||||
export type MessagePriority = "urgent" | "normal" | "low";
|
||||
|
||||
export interface AgentMessageRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
fromAgentId: string;
|
||||
/** null = broadcast to channel */
|
||||
toAgentId: string | null;
|
||||
channel: MessageChannel;
|
||||
/** Department/project/incident ID for channel messages */
|
||||
channelTargetId: string | null;
|
||||
subject: string;
|
||||
body: string;
|
||||
priority: MessagePriority;
|
||||
/** Whether the recipient has read this message */
|
||||
readAt: string | null;
|
||||
/** Parent message ID for threads */
|
||||
parentMessageId: string | null;
|
||||
/** JSON: attached entity references [{type, id, title}] */
|
||||
attachmentsJson: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// ── Workflow Pipeline ──────────────────────────────────────────────────
|
||||
export type WorkflowStatus = "draft" | "active" | "paused" | "completed" | "failed";
|
||||
|
||||
export interface WorkflowPipelineRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
/** JSON array of pipeline steps */
|
||||
stepsJson: string;
|
||||
triggerType: AutomationTrigger;
|
||||
triggerConfigJson: string;
|
||||
status: WorkflowStatus;
|
||||
currentStepIndex: number;
|
||||
/** How many times this pipeline has run */
|
||||
runCount: number;
|
||||
lastRunAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface WorkflowStep {
|
||||
id: string;
|
||||
name: string;
|
||||
action: AutomationAction;
|
||||
configJson: string;
|
||||
assigneeDepartment: DepartmentId | null;
|
||||
assigneeAgentId: string | null;
|
||||
/** Wait for approval before proceeding */
|
||||
requiresApproval: boolean;
|
||||
/** Timeout in seconds (0 = no timeout) */
|
||||
timeoutSec: number;
|
||||
/** Status of this step */
|
||||
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
||||
}
|
||||
|
||||
// ── Cross-Department Trigger Table ────────────────────────────────────
|
||||
export interface CrossDeptTrigger {
|
||||
sourceEvent: string;
|
||||
sourceDepartment: DepartmentId;
|
||||
targetDepartment: DepartmentId;
|
||||
targetAction: string;
|
||||
description: string;
|
||||
}
|
||||
Reference in new issue
Block a user