update
This commit is contained in:
1 parent
66158e222e
commit
67c757f481
314 files changed
+37945
-22962
No files matched your search
@@ -0,0 +1,54 @@
|
||||
export interface ApprovalDocumentReference {
|
||||
id: string
|
||||
title?: string
|
||||
type?: string
|
||||
}
|
||||
|
||||
function parsePayload(payloadJson: string | null): Record<string, unknown> | null {
|
||||
if (!payloadJson) return null
|
||||
try {
|
||||
const parsed = JSON.parse(payloadJson)
|
||||
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
||||
? parsed as Record<string, unknown>
|
||||
: null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function extractApprovalDocumentReferences(payloadJson: string | null): ApprovalDocumentReference[] {
|
||||
const payload = parsePayload(payloadJson)
|
||||
if (!payload) return []
|
||||
|
||||
const refs = new Map<string, ApprovalDocumentReference>()
|
||||
const addRef = (id: unknown, title?: unknown, type?: unknown) => {
|
||||
if (typeof id !== "string" || id.length === 0) return
|
||||
refs.set(id, {
|
||||
id,
|
||||
title: typeof title === "string" && title.length > 0 ? title : undefined,
|
||||
type: typeof type === "string" && type.length > 0 ? type : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
addRef(payload.documentId, payload.documentTitle, payload.documentType)
|
||||
|
||||
const documentIds = payload.documentIds
|
||||
if (Array.isArray(documentIds)) {
|
||||
for (const entry of documentIds) addRef(entry)
|
||||
}
|
||||
|
||||
const documents = payload.documents
|
||||
if (Array.isArray(documents)) {
|
||||
for (const entry of documents) {
|
||||
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue
|
||||
const record = entry as Record<string, unknown>
|
||||
addRef(record.id, record.title, record.type)
|
||||
}
|
||||
}
|
||||
|
||||
return [...refs.values()]
|
||||
}
|
||||
|
||||
export function extractApprovalDocumentIds(payloadJson: string | null): string[] {
|
||||
return extractApprovalDocumentReferences(payloadJson).map((entry) => entry.id)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
export interface ConnectorModelEntry {
|
||||
id: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
function dedupeById(entries: Array<{ id: string; label: string; enabled: boolean }>) {
|
||||
const seen = new Map<string, ConnectorModelEntry>();
|
||||
for (const entry of entries) {
|
||||
if (!entry.id.trim()) continue;
|
||||
const existing = seen.get(entry.id);
|
||||
if (!existing) {
|
||||
seen.set(entry.id, { ...entry, id: entry.id.trim() });
|
||||
continue;
|
||||
}
|
||||
seen.set(entry.id, {
|
||||
...existing,
|
||||
label: existing.label || entry.label,
|
||||
enabled: existing.enabled || entry.enabled,
|
||||
});
|
||||
}
|
||||
return Array.from(seen.values());
|
||||
}
|
||||
|
||||
export function mergeConnectorModelEntries(
|
||||
enabledModels: Array<{ id: string; label: string }>,
|
||||
disabledModels: Array<{ id: string; label: string }>,
|
||||
): ConnectorModelEntry[] {
|
||||
return dedupeById([
|
||||
...enabledModels.map((entry) => ({ ...entry, enabled: true })),
|
||||
...disabledModels.map((entry) => ({ ...entry, enabled: false })),
|
||||
]).sort((a, b) => {
|
||||
if (a.enabled !== b.enabled) return a.enabled ? -1 : 1;
|
||||
return a.label.localeCompare(b.label);
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveSelectedConnectorModel(
|
||||
entries: ConnectorModelEntry[],
|
||||
currentModel: string,
|
||||
): string {
|
||||
if (currentModel && entries.some((entry) => entry.enabled && entry.id === currentModel)) {
|
||||
return currentModel;
|
||||
}
|
||||
return entries.find((entry) => entry.enabled)?.id ?? "";
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CapabilityMatrix, ConnectorRecord } from "./types";
|
||||
import type { ConnectorRecord } from "./types";
|
||||
|
||||
type ConnectorExecutionCandidate = Pick<ConnectorRecord, "status" | "capabilityMatrix"> & Partial<Pick<ConnectorRecord, "label">>;
|
||||
|
||||
|
||||
+10
-861
@@ -1,861 +1,10 @@
|
||||
import { z } from "zod";
|
||||
import type { AgentMessageRecord, AgentMetrics, AgentRecord, ApprovalRecord, BrowserActionRecord, BudgetIncidentRecord, BudgetPolicyRecord, BudgetStatusSummary, CommentRecord, CompanyMetrics, DesktopEvent, InboxItem, OnboardingBootstrapResult, ProfileSnapshot, RunLogChunk, RunRecord, SkillImportResult, SkillRecord, SkillUpdateStatus, StandupReport, TaskRecord } from "./types";
|
||||
|
||||
export const IPC_CHANNELS = {
|
||||
loadSnapshot: "agent-company:load-snapshot",
|
||||
pickDirectory: "agent-company:pick-directory",
|
||||
openPath: "agent-company:open-path",
|
||||
saveCompany: "agent-company:save-company",
|
||||
setCurrentCompany: "agent-company:set-current-company",
|
||||
saveConnector: "agent-company:save-connector",
|
||||
testConnector: "agent-company:test-connector",
|
||||
saveWorkspace: "agent-company:save-workspace",
|
||||
saveAgent: "agent-company:save-agent",
|
||||
requestHire: "agent-company:request-hire",
|
||||
saveGoal: "agent-company:save-goal",
|
||||
saveProject: "agent-company:save-project",
|
||||
saveTask: "agent-company:save-task",
|
||||
requestApproval: "agent-company:request-approval",
|
||||
decideApproval: "agent-company:decide-approval",
|
||||
saveSecret: "agent-company:save-secret",
|
||||
startTaskRun: "agent-company:start-task-run",
|
||||
cancelRun: "agent-company:cancel-run",
|
||||
getRunLog: "agent-company:get-run-log",
|
||||
getRunLogChunk: "agent-company:get-run-log-chunk",
|
||||
backupProfile: "agent-company:backup-profile",
|
||||
restoreProfile: "agent-company:restore-profile",
|
||||
updateSettings: "agent-company:update-settings",
|
||||
checkForUpdates: "agent-company:check-for-updates",
|
||||
deleteCompany: "agent-company:delete-company",
|
||||
deleteAgent: "agent-company:delete-agent",
|
||||
deleteTask: "agent-company:delete-task",
|
||||
deleteGoal: "agent-company:delete-goal",
|
||||
deleteProject: "agent-company:delete-project",
|
||||
deleteWorkspace: "agent-company:delete-workspace",
|
||||
deleteApproval: "agent-company:delete-approval",
|
||||
deleteSecret: "agent-company:delete-secret",
|
||||
getSidebarBadges: "agent-company:get-sidebar-badges",
|
||||
listConnectorModels: "agent-company:list-connector-models",
|
||||
openConnectorAuthTerminal: "agent-company:open-connector-auth-terminal",
|
||||
addComment: "agent-company:add-comment",
|
||||
listComments: "agent-company:list-comments",
|
||||
setHeartbeat: "agent-company:set-heartbeat",
|
||||
triggerHeartbeat: "agent-company:trigger-heartbeat",
|
||||
getApiPort: "agent-company:get-api-port",
|
||||
rendererEvent: "agent-company:event",
|
||||
getInbox: "agent-company:get-inbox",
|
||||
getCompanyMetrics: "agent-company:get-company-metrics",
|
||||
getAgentMetrics: "agent-company:get-agent-metrics",
|
||||
getStandupReport: "agent-company:get-standup-report",
|
||||
bootstrapOnboarding: "agent-company:bootstrap-onboarding",
|
||||
checkNodeInstalled: "agent-company:check-node-installed",
|
||||
openTerminalCommand: "agent-company:open-terminal-command",
|
||||
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",
|
||||
saveMeeting: "agent-company:save-meeting",
|
||||
deleteMeeting: "agent-company:delete-meeting",
|
||||
saveDocument: "agent-company:save-document",
|
||||
deleteDocument: "agent-company:delete-document",
|
||||
saveKnowledgeEntry: "agent-company:save-knowledge-entry",
|
||||
deleteKnowledgeEntry: "agent-company:delete-knowledge-entry",
|
||||
saveSprint: "agent-company:save-sprint",
|
||||
deleteSprint: "agent-company:delete-sprint",
|
||||
saveAutomationRule: "agent-company:save-automation-rule",
|
||||
deleteAutomationRule: "agent-company:delete-automation-rule",
|
||||
toggleAutomationRule: "agent-company:toggle-automation-rule",
|
||||
getAutomationLog: "agent-company:get-automation-log",
|
||||
sendAgentMessage: "agent-company:send-agent-message",
|
||||
listAgentMessages: "agent-company:list-agent-messages",
|
||||
markMessageRead: "agent-company:mark-message-read",
|
||||
saveWorkflow: "agent-company:save-workflow",
|
||||
deleteWorkflow: "agent-company:delete-workflow",
|
||||
runWorkflow: "agent-company:run-workflow",
|
||||
autoAssignTask: "agent-company:auto-assign-task",
|
||||
searchMessages: "agent-company:search-messages",
|
||||
importSkill: "agent-company:import-skill",
|
||||
listSkills: "agent-company:list-skills",
|
||||
getSkillDetail: "agent-company:get-skill-detail",
|
||||
deleteSkill: "agent-company:delete-skill",
|
||||
assignSkillToAgent: "agent-company:assign-skill-to-agent",
|
||||
removeSkillFromAgent: "agent-company:remove-skill-from-agent",
|
||||
checkSkillUpdate: "agent-company:check-skill-update",
|
||||
listSkillAgents: "agent-company:list-skill-agents",
|
||||
listAgentSkills: "agent-company:list-agent-skills",
|
||||
listWakeupRequests: "agent-company:list-wakeup-requests",
|
||||
saveBudgetPolicy: "agent-company:save-budget-policy",
|
||||
deleteBudgetPolicy: "agent-company:delete-budget-policy",
|
||||
listBudgetPolicies: "agent-company:list-budget-policies",
|
||||
listBudgetIncidents: "agent-company:list-budget-incidents",
|
||||
resolveBudgetIncident: "agent-company:resolve-budget-incident",
|
||||
getBudgetStatus: "agent-company:get-budget-status",
|
||||
getTask: "agent-company:get-task",
|
||||
getAgent: "agent-company:get-agent",
|
||||
getRun: "agent-company:get-run",
|
||||
getApproval: "agent-company:get-approval",
|
||||
getConnectorDisabledModels: "agent-company:get-connector-disabled-models",
|
||||
setConnectorDisabledModels: "agent-company:set-connector-disabled-models",
|
||||
// Agent config revisions
|
||||
listConfigRevisions: "agent-company:list-config-revisions",
|
||||
getConfigRevision: "agent-company:get-config-revision",
|
||||
rollbackConfigRevision: "agent-company:rollback-config-revision",
|
||||
// Run events
|
||||
listRunEvents: "agent-company:list-run-events",
|
||||
// Agent permissions
|
||||
getAgentPermissions: "agent-company:get-agent-permissions",
|
||||
setAgentPermission: "agent-company:set-agent-permission",
|
||||
// Heartbeat policy
|
||||
getHeartbeatPolicy: "agent-company:get-heartbeat-policy",
|
||||
setHeartbeatPolicy: "agent-company:set-heartbeat-policy",
|
||||
// Runtime state
|
||||
getRuntimeState: "agent-company:get-runtime-state",
|
||||
setRuntimeState: "agent-company:set-runtime-state",
|
||||
} as const;
|
||||
|
||||
const optionalId = z.preprocess(
|
||||
(value) => (value === "" ? null : value),
|
||||
z.string().uuid().nullable().optional(),
|
||||
);
|
||||
|
||||
export const companyInputSchema = z.object({
|
||||
id: optionalId,
|
||||
name: z.string().min(2).max(80),
|
||||
description: z.string().max(500).default(""),
|
||||
status: z.enum(["active", "paused", "archived"]).default("active"),
|
||||
autoApproveHires: z.boolean().default(false),
|
||||
reviewDeliverables: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const connectorInputSchema = z.object({
|
||||
id: z.enum(["codex_local", "claude_local", "claude_compatible", "claude_compat_2", "claude_compat_3", "claude_compat_4", "claude_compat_5", "claude_compat_6", "claude_compat_7", "claude_compat_8", "claude_compat_9", "claude_compat_10", "gemini_local"]),
|
||||
command: z.string().min(1),
|
||||
model: z.string().nullable().optional(),
|
||||
envBindingText: z.string().default(""),
|
||||
notes: z.string().default(""),
|
||||
});
|
||||
|
||||
export const connectorDisabledModelsSchema = z.object({
|
||||
connectorId: connectorInputSchema.shape.id,
|
||||
disabledModels: z.array(z.object({ id: z.string(), label: z.string() })),
|
||||
});
|
||||
|
||||
export const workspaceInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(80),
|
||||
localPath: z.string().min(1),
|
||||
repoUrl: z.string().default(""),
|
||||
repoRef: z.string().default(""),
|
||||
projectId: optionalId,
|
||||
isPrimary: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const agentInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
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,
|
||||
model: z.string().nullable().optional(),
|
||||
metadataJson: z.string().default("{}").optional(),
|
||||
capabilities: z.string().default(""),
|
||||
budgetMonthlyUsd: z.number().min(0).default(0),
|
||||
status: z.enum(["idle", "active", "running", "paused", "error", "pending_approval", "terminated"]).default("idle"),
|
||||
});
|
||||
|
||||
export const hireRequestSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
requestedByAgentId: optionalId,
|
||||
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,
|
||||
model: z.string().nullable().optional(),
|
||||
metadataJson: z.string().default("{}").optional(),
|
||||
capabilities: z.string().default(""),
|
||||
budgetMonthlyUsd: z.number().min(0).default(0),
|
||||
});
|
||||
|
||||
export const goalInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
title: z.string().min(2).max(120),
|
||||
description: z.string().default(""),
|
||||
parentId: optionalId,
|
||||
ownerAgentId: optionalId,
|
||||
status: z.enum(["planned", "active", "achieved", "cancelled"]).default("planned"),
|
||||
});
|
||||
|
||||
export const projectInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
goalId: optionalId,
|
||||
name: z.string().min(2).max(120),
|
||||
description: z.string().default(""),
|
||||
leadAgentId: optionalId,
|
||||
targetDate: z.string().nullable().optional(),
|
||||
status: z.enum(["backlog", "planned", "in_progress", "completed", "cancelled"]).default("planned"),
|
||||
});
|
||||
|
||||
export const taskInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
projectId: optionalId,
|
||||
goalId: optionalId,
|
||||
parentId: optionalId,
|
||||
title: z.string().min(2).max(160),
|
||||
description: z.string().default(""),
|
||||
assigneeAgentId: optionalId,
|
||||
workspaceId: optionalId,
|
||||
priority: z.enum(["critical", "high", "medium", "low"]).default("medium"),
|
||||
status: z.enum(["backlog", "todo", "in_progress", "in_review", "done", "blocked", "cancelled"]).default("todo"),
|
||||
});
|
||||
|
||||
export const approvalInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
relatedTaskId: optionalId,
|
||||
requestedByAgentId: optionalId,
|
||||
relatedAgentId: optionalId,
|
||||
type: z.enum(["hire_agent", "approve_ceo_strategy", "dangerous_command", "secret_access", "budget_request", "promotion", "termination", "vendor_approval", "document_review", "production_deploy", "incident_escalation", "social_post", "deliverable_review"]),
|
||||
payloadSummary: z.string().min(2).max(280),
|
||||
impactSummary: z.string().min(2).max(400),
|
||||
payloadJson: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const approvalDecisionSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
approvalId: z.string().uuid(),
|
||||
state: z.enum(["approved", "rejected", "revision_requested"]),
|
||||
decisionNote: z.string().max(400).default(""),
|
||||
});
|
||||
|
||||
export const secretInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(80),
|
||||
description: z.string().default(""),
|
||||
value: z.string().min(1).max(2000),
|
||||
});
|
||||
|
||||
export const startRunSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const cancelRunSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const runLogSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const runLogChunkSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1024).max(262_144).default(65_536),
|
||||
});
|
||||
|
||||
export const triggerBrowserLoginSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
socialAccountId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const deleteEntitySchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const sidebarBadgesSchema = z.object({
|
||||
pendingApprovals: z.number(),
|
||||
activeRuns: z.number(),
|
||||
failedRuns: z.number(),
|
||||
todoTasks: z.number(),
|
||||
budgetWarnings: z.number(),
|
||||
unreadMessages: z.number(),
|
||||
});
|
||||
export type SidebarBadges = z.infer<typeof sidebarBadgesSchema>;
|
||||
|
||||
export const settingsSchema = z.object({
|
||||
theme: z.enum(["system", "light", "dark"]).optional(),
|
||||
locale: z.enum(["en", "zh"]).optional(),
|
||||
updatesEnabled: z.boolean().optional(),
|
||||
logRetentionDays: z.number().int().min(1).max(365).optional(),
|
||||
});
|
||||
|
||||
export const commentInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
authorAgentId: optionalId,
|
||||
authorName: z.string().min(1).max(80),
|
||||
body: z.string().min(1).max(4000),
|
||||
});
|
||||
|
||||
export const listCommentsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const heartbeatSettingsSchema = z.object({
|
||||
agentId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
enabled: z.boolean(),
|
||||
intervalSec: z.number().int().min(30).max(86400).default(120),
|
||||
});
|
||||
|
||||
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", "message", "peer_request", "task_continuation"]).default("manual"),
|
||||
});
|
||||
|
||||
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 bootstrapOnboardingSchema = z.object({
|
||||
companyName: z.string().min(2).max(80),
|
||||
companyDescription: z.string().max(500).default(""),
|
||||
workspacePath: z.string().default(""),
|
||||
autoApproveHires: z.boolean().default(true),
|
||||
reviewDeliverables: z.boolean().default(false),
|
||||
goalTitle: z.string().default(""),
|
||||
goalDescription: z.string().default(""),
|
||||
connectorId: z.enum(["codex_local", "claude_local", "claude_compatible", "claude_compat_2", "claude_compat_3", "claude_compat_4", "claude_compat_5", "claude_compat_6", "claude_compat_7", "claude_compat_8", "claude_compat_9", "claude_compat_10", "gemini_local"]).optional(),
|
||||
connectorModel: z.string().default(""),
|
||||
});
|
||||
|
||||
export const openTerminalCommandSchema = z.object({
|
||||
title: z.string().min(1).max(200),
|
||||
command: z.string().min(1),
|
||||
});
|
||||
|
||||
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.enum([
|
||||
"agents",
|
||||
"goals",
|
||||
"projects",
|
||||
"tasks",
|
||||
"approvals",
|
||||
"runs",
|
||||
"secrets",
|
||||
"meetings",
|
||||
"documents",
|
||||
"knowledge_base",
|
||||
"sprints",
|
||||
"automation_rules",
|
||||
"workflow_pipelines",
|
||||
]).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),
|
||||
});
|
||||
|
||||
export const cancelBrowserActionSchema = z.object({
|
||||
actionId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
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", "task_reassigned",
|
||||
"run_completed", "run_failed", "approval_created", "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.preprocess((v) => (v === "" ? "(no subject)" : v), 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("[]"),
|
||||
}).superRefine((value, ctx) => {
|
||||
if (value.channel === "direct" && !value.toAgentId) {
|
||||
ctx.addIssue({
|
||||
path: ["toAgentId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Direct messages require toAgentId.",
|
||||
});
|
||||
}
|
||||
|
||||
if ((value.channel === "department" || value.channel === "project") && !value.channelTargetId) {
|
||||
ctx.addIssue({
|
||||
path: ["channelTargetId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: `${value.channel} messages require channelTargetId.`,
|
||||
});
|
||||
}
|
||||
|
||||
if (value.channel !== "direct" && value.toAgentId) {
|
||||
ctx.addIssue({
|
||||
path: ["toAgentId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Only direct messages may set toAgentId.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const messageQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).optional(),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
unreadOnly: z.boolean().optional(),
|
||||
limit: z.number().int().min(1).max(500).default(200),
|
||||
});
|
||||
|
||||
export const searchMessagesSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
query: z.string().min(1).max(200),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).optional(),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
limit: z.number().int().min(1).max(100).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", "task_reassigned",
|
||||
"run_completed", "run_failed", "approval_created", "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 toggleAutomationRuleSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["active", "paused"]),
|
||||
});
|
||||
|
||||
export const markMessageReadSchema = z.object({
|
||||
messageId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
readerAgentId: optionalId,
|
||||
});
|
||||
|
||||
export const runWorkflowSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const autoAssignSchema = z.object({
|
||||
taskId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const importSkillSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
source: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listSkillsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const getSkillDetailSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const deleteSkillSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const assignSkillToAgentSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const removeSkillFromAgentSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const checkSkillUpdateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listSkillAgentsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listAgentSkillsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const budgetPolicyInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
scopeType: z.enum(["company", "agent", "project"]),
|
||||
scopeId: z.string().uuid(),
|
||||
metric: z.literal("billed_cents").default("billed_cents"),
|
||||
windowKind: z.literal("calendar_month_utc").default("calendar_month_utc"),
|
||||
amount: z.number().int().min(1),
|
||||
warnPercent: z.number().int().min(1).max(100).default(80),
|
||||
hardStopEnabled: z.boolean().default(true),
|
||||
notifyEnabled: z.boolean().default(true),
|
||||
isActive: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const listBudgetPoliciesSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const deleteBudgetPolicySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
policyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listBudgetIncidentsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["open", "resolved", "auto_resolved_limit_increase", "auto_closed", "all"]).default("all"),
|
||||
});
|
||||
|
||||
export const resolveBudgetIncidentSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
incidentId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const getBudgetStatusSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const wakeupQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["queued", "claimed", "coalesced", "deferred", "completed"]).optional(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
});
|
||||
|
||||
export interface WakeupRequestRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
agentId: string;
|
||||
source: string;
|
||||
triggerDetail: string | null;
|
||||
status: string;
|
||||
coalescedCount: number;
|
||||
runId: string | null;
|
||||
requestedAt: string;
|
||||
claimedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export const entityGetterSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
id: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listConfigRevisionsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const getConfigRevisionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
revisionId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const rollbackConfigRevisionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
revisionId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listRunEventsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
runId: z.string().min(1),
|
||||
offset: z.number().optional(),
|
||||
limit: z.number().optional(),
|
||||
});
|
||||
|
||||
export const getAgentPermissionsSchema = z.object({
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setAgentPermissionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
permissionKey: z.string().min(1),
|
||||
enabled: z.boolean(),
|
||||
});
|
||||
|
||||
export const heartbeatPolicySchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setHeartbeatPolicySchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
enabled: z.boolean().optional(),
|
||||
intervalSec: z.number().optional(),
|
||||
cooldownSec: z.number().optional(),
|
||||
maxConcurrentRuns: z.number().optional(),
|
||||
wakeOnDemand: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const runtimeStateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setRuntimeStateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
state: z.record(z.string(), z.unknown()),
|
||||
});
|
||||
|
||||
export type DesktopResult<T> =
|
||||
| { ok: true; data: T }
|
||||
| { ok: false; error: { code: string; message: string } };
|
||||
|
||||
export interface SaveTaskResult {
|
||||
id: string;
|
||||
capabilityWarning?: string;
|
||||
}
|
||||
|
||||
export type DesktopApi = {
|
||||
loadSnapshot: () => Promise<DesktopResult<ProfileSnapshot>>;
|
||||
pickDirectory: () => Promise<DesktopResult<string | null>>;
|
||||
openPath: (targetPath: string) => Promise<DesktopResult<boolean>>;
|
||||
saveCompany: (input: z.infer<typeof companyInputSchema>) => Promise<DesktopResult<string>>;
|
||||
setCurrentCompany: (companyId: string) => Promise<DesktopResult<boolean>>;
|
||||
saveConnector: (input: z.infer<typeof connectorInputSchema>) => Promise<DesktopResult<boolean>>;
|
||||
testConnector: (id: z.infer<typeof connectorInputSchema.shape.id>) => Promise<DesktopResult<boolean>>;
|
||||
saveWorkspace: (input: z.infer<typeof workspaceInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveAgent: (input: z.infer<typeof agentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
requestHire: (input: z.infer<typeof hireRequestSchema>) => Promise<DesktopResult<{ agentId: string; approvalId: string; autoApproved: boolean }>>;
|
||||
saveGoal: (input: z.infer<typeof goalInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveProject: (input: z.infer<typeof projectInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveTask: (input: z.infer<typeof taskInputSchema>) => Promise<DesktopResult<SaveTaskResult>>;
|
||||
requestApproval: (input: z.infer<typeof approvalInputSchema>) => Promise<DesktopResult<string>>;
|
||||
decideApproval: (input: z.infer<typeof approvalDecisionSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveSecret: (input: z.infer<typeof secretInputSchema>) => Promise<DesktopResult<string>>;
|
||||
startTaskRun: (input: z.infer<typeof startRunSchema>) => Promise<DesktopResult<string>>;
|
||||
cancelRun: (input: z.infer<typeof cancelRunSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getRunLog: (input: z.infer<typeof runLogSchema>) => Promise<DesktopResult<string>>;
|
||||
getRunLogChunk: (input: z.infer<typeof runLogChunkSchema>) => Promise<DesktopResult<RunLogChunk>>;
|
||||
backupProfile: () => Promise<DesktopResult<string | null>>;
|
||||
restoreProfile: () => Promise<DesktopResult<boolean>>;
|
||||
updateSettings: (input: z.infer<typeof settingsSchema>) => Promise<DesktopResult<boolean>>;
|
||||
checkForUpdates: () => Promise<DesktopResult<boolean>>;
|
||||
deleteCompany: (companyId: string) => Promise<DesktopResult<boolean>>;
|
||||
deleteAgent: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteTask: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteGoal: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteProject: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteWorkspace: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteApproval: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteSecret: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
getSidebarBadges: (companyId: string) => Promise<DesktopResult<SidebarBadges>>;
|
||||
listConnectorModels: (connectorId: string) => Promise<DesktopResult<Array<{ id: string; label: string }>>>;
|
||||
getConnectorDisabledModels: (connectorId: string) => Promise<DesktopResult<Array<{ id: string; label: string }>>>;
|
||||
setConnectorDisabledModels: (input: z.infer<typeof connectorDisabledModelsSchema>) => Promise<DesktopResult<boolean>>;
|
||||
openConnectorAuthTerminal: (connectorId: z.infer<typeof connectorInputSchema.shape.id>) => Promise<DesktopResult<boolean>>;
|
||||
addComment: (input: z.infer<typeof commentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
listComments: (input: z.infer<typeof listCommentsSchema>) => Promise<DesktopResult<CommentRecord[]>>;
|
||||
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[]>>;
|
||||
getCompanyMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<CompanyMetrics>>;
|
||||
getAgentMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<AgentMetrics>>;
|
||||
getStandupReport: (companyId: string) => Promise<DesktopResult<StandupReport>>;
|
||||
bootstrapOnboarding: (input: z.infer<typeof bootstrapOnboardingSchema>) => Promise<DesktopResult<OnboardingBootstrapResult>>;
|
||||
checkNodeInstalled: () => Promise<DesktopResult<{ installed: boolean; version: string | null }>>;
|
||||
openTerminalCommand: (input: z.infer<typeof openTerminalCommandSchema>) => Promise<DesktopResult<boolean>>;
|
||||
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 cancelBrowserActionSchema>) => Promise<DesktopResult<boolean>>;
|
||||
triggerBrowserLogin: (input: z.infer<typeof triggerBrowserLoginSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveMeeting: (input: z.infer<typeof meetingInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteMeeting: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveDocument: (input: z.infer<typeof documentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteDocument: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveKnowledgeEntry: (input: z.infer<typeof knowledgeEntryInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteKnowledgeEntry: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveSprint: (input: z.infer<typeof sprintInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteSprint: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveAutomationRule: (input: z.infer<typeof automationRuleInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteAutomationRule: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
toggleAutomationRule: (input: z.infer<typeof toggleAutomationRuleSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getAutomationLog: (companyId: string) => Promise<DesktopResult<Array<{ ruleId: string; ruleName: string; trigger: string; action: string; executedAt: string }>>>;
|
||||
sendAgentMessage: (input: z.infer<typeof agentMessageInputSchema>) => Promise<DesktopResult<string>>;
|
||||
listAgentMessages: (input: z.infer<typeof messageQuerySchema>) => Promise<DesktopResult<AgentMessageRecord[]>>;
|
||||
markMessageRead: (input: z.infer<typeof markMessageReadSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveWorkflow: (input: z.infer<typeof workflowInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteWorkflow: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
runWorkflow: (input: z.infer<typeof runWorkflowSchema>) => Promise<DesktopResult<boolean>>;
|
||||
autoAssignTask: (input: z.infer<typeof autoAssignSchema>) => Promise<DesktopResult<string>>;
|
||||
searchMessages: (input: z.infer<typeof searchMessagesSchema>) => Promise<DesktopResult<AgentMessageRecord[]>>;
|
||||
importSkill: (companyId: string, source: string) => Promise<DesktopResult<SkillImportResult[]>>;
|
||||
listSkills: (companyId: string) => Promise<DesktopResult<SkillRecord[]>>;
|
||||
getSkillDetail: (companyId: string, skillId: string) => Promise<DesktopResult<SkillRecord>>;
|
||||
deleteSkill: (companyId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
assignSkillToAgent: (companyId: string, agentId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
removeSkillFromAgent: (companyId: string, agentId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
checkSkillUpdate: (companyId: string, skillId: string) => Promise<DesktopResult<SkillUpdateStatus>>;
|
||||
listSkillAgents: (companyId: string, skillId: string) => Promise<DesktopResult<string[]>>;
|
||||
listAgentSkills: (companyId: string, agentId: string) => Promise<DesktopResult<string[]>>;
|
||||
listWakeupRequests: (input: z.infer<typeof wakeupQuerySchema>) => Promise<DesktopResult<WakeupRequestRecord[]>>;
|
||||
saveBudgetPolicy: (input: z.infer<typeof budgetPolicyInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteBudgetPolicy: (input: z.infer<typeof deleteBudgetPolicySchema>) => Promise<DesktopResult<boolean>>;
|
||||
listBudgetPolicies: (companyId: string) => Promise<DesktopResult<BudgetPolicyRecord[]>>;
|
||||
listBudgetIncidents: (input: z.infer<typeof listBudgetIncidentsSchema>) => Promise<DesktopResult<BudgetIncidentRecord[]>>;
|
||||
resolveBudgetIncident: (input: z.infer<typeof resolveBudgetIncidentSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getBudgetStatus: (companyId: string) => Promise<DesktopResult<BudgetStatusSummary>>;
|
||||
recoveryRetry: (taskId: string, agentId: string, companyId: string) => Promise<DesktopResult<null>>;
|
||||
recoveryDismiss: (taskId: string) => Promise<DesktopResult<null>>;
|
||||
recoveryFail: (taskId: string) => Promise<DesktopResult<null>>;
|
||||
getTask: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<TaskRecord>>;
|
||||
getAgent: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<AgentRecord>>;
|
||||
getRun: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<RunRecord>>;
|
||||
getApproval: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<ApprovalRecord>>;
|
||||
listConfigRevisions: (companyId: string, agentId: string) => Promise<DesktopResult<unknown[]>>;
|
||||
getConfigRevision: (companyId: string, revisionId: string) => Promise<DesktopResult<unknown>>;
|
||||
rollbackConfigRevision: (companyId: string, agentId: string, revisionId: string) => Promise<DesktopResult<boolean>>;
|
||||
listRunEvents: (companyId: string, runId: string, opts?: { offset?: number; limit?: number }) => Promise<DesktopResult<unknown[]>>;
|
||||
getAgentPermissions: (agentId: string) => Promise<DesktopResult<unknown>>;
|
||||
setAgentPermission: (companyId: string, agentId: string, permissionKey: string, enabled: boolean) => Promise<DesktopResult<boolean>>;
|
||||
getHeartbeatPolicy: (agentId: string, companyId: string) => Promise<DesktopResult<unknown>>;
|
||||
setHeartbeatPolicy: (companyId: string, agentId: string, policy: Record<string, unknown>) => Promise<DesktopResult<boolean>>;
|
||||
getRuntimeState: (agentId: string, companyId: string) => Promise<DesktopResult<unknown>>;
|
||||
setRuntimeState: (companyId: string, agentId: string, state: Record<string, unknown>) => Promise<DesktopResult<boolean>>;
|
||||
subscribe: (callback: (event: DesktopEvent) => void) => () => void;
|
||||
platform: "win32" | "darwin" | "linux";
|
||||
windowMinimize: () => Promise<void>;
|
||||
windowMaximize: () => Promise<void>;
|
||||
windowClose: () => Promise<void>;
|
||||
windowIsMaximized: () => Promise<boolean>;
|
||||
};
|
||||
export * from "./contracts/channels";
|
||||
export * from "./contracts/helpers";
|
||||
export * from "./contracts/schemas-company";
|
||||
export * from "./contracts/schemas-agents";
|
||||
export * from "./contracts/schemas-tasks";
|
||||
export * from "./contracts/schemas-approvals";
|
||||
export * from "./contracts/schemas-messages";
|
||||
export * from "./contracts/schemas-execution";
|
||||
export * from "./contracts/schemas-misc";
|
||||
export * from "./contracts/desktop-api";
|
||||
@@ -0,0 +1,136 @@
|
||||
export const IPC_CHANNELS = {
|
||||
loadSnapshot: "agent-company:load-snapshot",
|
||||
pickDirectory: "agent-company:pick-directory",
|
||||
openPath: "agent-company:open-path",
|
||||
saveCompany: "agent-company:save-company",
|
||||
setCurrentCompany: "agent-company:set-current-company",
|
||||
saveConnector: "agent-company:save-connector",
|
||||
testConnector: "agent-company:test-connector",
|
||||
saveWorkspace: "agent-company:save-workspace",
|
||||
saveAgent: "agent-company:save-agent",
|
||||
requestHire: "agent-company:request-hire",
|
||||
saveGoal: "agent-company:save-goal",
|
||||
saveProject: "agent-company:save-project",
|
||||
saveTask: "agent-company:save-task",
|
||||
requestApproval: "agent-company:request-approval",
|
||||
decideApproval: "agent-company:decide-approval",
|
||||
saveSecret: "agent-company:save-secret",
|
||||
startTaskRun: "agent-company:start-task-run",
|
||||
cancelRun: "agent-company:cancel-run",
|
||||
getRunLog: "agent-company:get-run-log",
|
||||
getRunLogChunk: "agent-company:get-run-log-chunk",
|
||||
backupProfile: "agent-company:backup-profile",
|
||||
restoreProfile: "agent-company:restore-profile",
|
||||
updateSettings: "agent-company:update-settings",
|
||||
checkForUpdates: "agent-company:check-for-updates",
|
||||
deleteCompany: "agent-company:delete-company",
|
||||
deleteAgent: "agent-company:delete-agent",
|
||||
deleteTask: "agent-company:delete-task",
|
||||
deleteGoal: "agent-company:delete-goal",
|
||||
deleteProject: "agent-company:delete-project",
|
||||
deleteWorkspace: "agent-company:delete-workspace",
|
||||
deleteApproval: "agent-company:delete-approval",
|
||||
deleteSecret: "agent-company:delete-secret",
|
||||
getSidebarBadges: "agent-company:get-sidebar-badges",
|
||||
listConnectorModels: "agent-company:list-connector-models",
|
||||
openConnectorAuthTerminal: "agent-company:open-connector-auth-terminal",
|
||||
addComment: "agent-company:add-comment",
|
||||
listComments: "agent-company:list-comments",
|
||||
setHeartbeat: "agent-company:set-heartbeat",
|
||||
triggerHeartbeat: "agent-company:trigger-heartbeat",
|
||||
getApiPort: "agent-company:get-api-port",
|
||||
rendererEvent: "agent-company:event",
|
||||
getInbox: "agent-company:get-inbox",
|
||||
getCompanyMetrics: "agent-company:get-company-metrics",
|
||||
getAgentMetrics: "agent-company:get-agent-metrics",
|
||||
getStandupReport: "agent-company:get-standup-report",
|
||||
bootstrapOnboarding: "agent-company:bootstrap-onboarding",
|
||||
checkNodeInstalled: "agent-company:check-node-installed",
|
||||
openTerminalCommand: "agent-company:open-terminal-command",
|
||||
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",
|
||||
saveMeeting: "agent-company:save-meeting",
|
||||
deleteMeeting: "agent-company:delete-meeting",
|
||||
saveDocument: "agent-company:save-document",
|
||||
deleteDocument: "agent-company:delete-document",
|
||||
saveKnowledgeEntry: "agent-company:save-knowledge-entry",
|
||||
deleteKnowledgeEntry: "agent-company:delete-knowledge-entry",
|
||||
saveSprint: "agent-company:save-sprint",
|
||||
deleteSprint: "agent-company:delete-sprint",
|
||||
saveAutomationRule: "agent-company:save-automation-rule",
|
||||
deleteAutomationRule: "agent-company:delete-automation-rule",
|
||||
toggleAutomationRule: "agent-company:toggle-automation-rule",
|
||||
getAutomationLog: "agent-company:get-automation-log",
|
||||
sendAgentMessage: "agent-company:send-agent-message",
|
||||
listAgentMessages: "agent-company:list-agent-messages",
|
||||
markMessageRead: "agent-company:mark-message-read",
|
||||
saveWorkflow: "agent-company:save-workflow",
|
||||
deleteWorkflow: "agent-company:delete-workflow",
|
||||
runWorkflow: "agent-company:run-workflow",
|
||||
autoAssignTask: "agent-company:auto-assign-task",
|
||||
searchMessages: "agent-company:search-messages",
|
||||
importSkill: "agent-company:import-skill",
|
||||
listSkills: "agent-company:list-skills",
|
||||
getSkillDetail: "agent-company:get-skill-detail",
|
||||
deleteSkill: "agent-company:delete-skill",
|
||||
assignSkillToAgent: "agent-company:assign-skill-to-agent",
|
||||
removeSkillFromAgent: "agent-company:remove-skill-from-agent",
|
||||
checkSkillUpdate: "agent-company:check-skill-update",
|
||||
listSkillAgents: "agent-company:list-skill-agents",
|
||||
listAgentSkills: "agent-company:list-agent-skills",
|
||||
listWakeupRequests: "agent-company:list-wakeup-requests",
|
||||
saveBudgetPolicy: "agent-company:save-budget-policy",
|
||||
deleteBudgetPolicy: "agent-company:delete-budget-policy",
|
||||
listBudgetPolicies: "agent-company:list-budget-policies",
|
||||
listBudgetIncidents: "agent-company:list-budget-incidents",
|
||||
resolveBudgetIncident: "agent-company:resolve-budget-incident",
|
||||
getBudgetStatus: "agent-company:get-budget-status",
|
||||
getTask: "agent-company:get-task",
|
||||
getAgent: "agent-company:get-agent",
|
||||
getRun: "agent-company:get-run",
|
||||
getApproval: "agent-company:get-approval",
|
||||
getConnectorDisabledModels: "agent-company:get-connector-disabled-models",
|
||||
setConnectorDisabledModels: "agent-company:set-connector-disabled-models",
|
||||
// Recovery
|
||||
recoveryRetry: "recovery:retry",
|
||||
recoveryDismiss: "recovery:dismiss",
|
||||
recoveryFail: "recovery:fail",
|
||||
// Agent config revisions
|
||||
listConfigRevisions: "agent-company:list-config-revisions",
|
||||
getConfigRevision: "agent-company:get-config-revision",
|
||||
rollbackConfigRevision: "agent-company:rollback-config-revision",
|
||||
// Run events
|
||||
listRunEvents: "agent-company:list-run-events",
|
||||
// Agent permissions
|
||||
getAgentPermissions: "agent-company:get-agent-permissions",
|
||||
setAgentPermission: "agent-company:set-agent-permission",
|
||||
// Heartbeat policy
|
||||
getHeartbeatPolicy: "agent-company:get-heartbeat-policy",
|
||||
setHeartbeatPolicy: "agent-company:set-heartbeat-policy",
|
||||
// Runtime state
|
||||
getRuntimeState: "agent-company:get-runtime-state",
|
||||
setRuntimeState: "agent-company:set-runtime-state",
|
||||
// Thread runtime
|
||||
createThread: "agent-company:create-thread",
|
||||
listThreads: "agent-company:list-threads",
|
||||
getThread: "agent-company:get-thread",
|
||||
addThreadEvent: "agent-company:add-thread-event",
|
||||
listThreadEvents: "agent-company:list-thread-events",
|
||||
setThreadWaitState: "agent-company:set-thread-wait-state",
|
||||
resolveThreadWaitState: "agent-company:resolve-thread-wait-state",
|
||||
listThreadWaitStates: "agent-company:list-thread-wait-states",
|
||||
listParticipants: "agent-company:list-participants",
|
||||
addParticipant: "agent-company:add-participant",
|
||||
removeParticipant: "agent-company:remove-participant",
|
||||
subscribeThread: "agent-company:subscribe-thread",
|
||||
unsubscribeThread: "agent-company:unsubscribe-thread",
|
||||
listSubscriptions: "agent-company:list-subscriptions",
|
||||
listSubscribedThreads: "agent-company:list-subscribed-threads",
|
||||
windowMinimize: "window:minimize",
|
||||
windowMaximize: "window:maximize",
|
||||
windowClose: "window:close",
|
||||
windowIsMaximized: "window:isMaximized",
|
||||
} as const;
|
||||
@@ -0,0 +1,249 @@
|
||||
import { z } from "zod";
|
||||
import type {
|
||||
AgentMessageRecord,
|
||||
AgentMetrics,
|
||||
AgentRecord,
|
||||
ApprovalRecord,
|
||||
BrowserActionRecord,
|
||||
BudgetIncidentRecord,
|
||||
BudgetPolicyRecord,
|
||||
BudgetStatusSummary,
|
||||
CommentRecord,
|
||||
CompanyMetrics,
|
||||
ConversationEventRecord,
|
||||
ConversationParticipantRecord,
|
||||
ConversationThreadRecord,
|
||||
DesktopEvent,
|
||||
InboxItem,
|
||||
OnboardingBootstrapResult,
|
||||
ProfileSnapshot,
|
||||
RunLogChunk,
|
||||
RunRecord,
|
||||
SkillImportResult,
|
||||
SkillRecord,
|
||||
SkillUpdateStatus,
|
||||
StandupReport,
|
||||
TaskRecord,
|
||||
ThreadSubscriptionRecord,
|
||||
ThreadWaitStateRecord,
|
||||
} from "../types";
|
||||
import type { SidebarBadges } from "./schemas-misc";
|
||||
import type { WakeupRequestRecord } from "./schemas-misc";
|
||||
import {
|
||||
agentInputSchema,
|
||||
heartbeatSettingsSchema,
|
||||
hireRequestSchema,
|
||||
triggerHeartbeatSchema,
|
||||
} from "./schemas-agents";
|
||||
import {
|
||||
approvalDecisionSchema,
|
||||
approvalInputSchema,
|
||||
} from "./schemas-approvals";
|
||||
import {
|
||||
browserActionQuerySchema,
|
||||
cancelBrowserActionSchema,
|
||||
cancelRunSchema,
|
||||
openTerminalCommandSchema,
|
||||
runLogChunkSchema,
|
||||
runLogSchema,
|
||||
runWorkflowSchema,
|
||||
startRunSchema,
|
||||
triggerBrowserLoginSchema,
|
||||
workflowInputSchema,
|
||||
} from "./schemas-execution";
|
||||
import {
|
||||
commentInputSchema,
|
||||
documentInputSchema,
|
||||
knowledgeEntryInputSchema,
|
||||
listCommentsSchema,
|
||||
markMessageReadSchema,
|
||||
meetingInputSchema,
|
||||
messageQuerySchema,
|
||||
searchMessagesSchema,
|
||||
agentMessageInputSchema,
|
||||
} from "./schemas-messages";
|
||||
import {
|
||||
automationRuleInputSchema,
|
||||
budgetPolicyInputSchema,
|
||||
createThreadSchema,
|
||||
addThreadEventSchema,
|
||||
deleteBudgetPolicySchema,
|
||||
deleteEntitySchema,
|
||||
entityGetterSchema,
|
||||
listBudgetIncidentsSchema,
|
||||
listThreadEventsSchema,
|
||||
listThreadsSchema,
|
||||
listThreadWaitStatesSchema,
|
||||
metricsQuerySchema,
|
||||
resolveThreadWaitStateSchema,
|
||||
resolveBudgetIncidentSchema,
|
||||
setThreadWaitStateSchema,
|
||||
threadGetterSchema,
|
||||
toggleAutomationRuleSchema,
|
||||
wakeupQuerySchema,
|
||||
listParticipantsSchema,
|
||||
addParticipantSchema,
|
||||
removeParticipantSchema,
|
||||
subscribeThreadSchema,
|
||||
unsubscribeThreadSchema,
|
||||
listSubscriptionsSchema,
|
||||
listSubscribedThreadsSchema,
|
||||
} from "./schemas-misc";
|
||||
import {
|
||||
autoAssignSchema,
|
||||
goalInputSchema,
|
||||
projectInputSchema,
|
||||
sprintInputSchema,
|
||||
taskInputSchema,
|
||||
} from "./schemas-tasks";
|
||||
import {
|
||||
bootstrapOnboardingSchema,
|
||||
companyInputSchema,
|
||||
connectorDisabledModelsSchema,
|
||||
connectorInputSchema,
|
||||
secretInputSchema,
|
||||
settingsSchema,
|
||||
socialAccountInputSchema,
|
||||
workspaceInputSchema,
|
||||
} from "./schemas-company";
|
||||
|
||||
export type DesktopResult<T> =
|
||||
| { ok: true; data: T }
|
||||
| { ok: false; error: { code: string; message: string } };
|
||||
|
||||
export interface SaveTaskResult {
|
||||
id: string;
|
||||
capabilityWarning?: string;
|
||||
}
|
||||
|
||||
export type DesktopApi = {
|
||||
loadSnapshot: () => Promise<DesktopResult<ProfileSnapshot>>;
|
||||
pickDirectory: () => Promise<DesktopResult<string | null>>;
|
||||
openPath: (targetPath: string) => Promise<DesktopResult<boolean>>;
|
||||
saveCompany: (input: z.infer<typeof companyInputSchema>) => Promise<DesktopResult<string>>;
|
||||
setCurrentCompany: (companyId: string) => Promise<DesktopResult<boolean>>;
|
||||
saveConnector: (input: z.infer<typeof connectorInputSchema>) => Promise<DesktopResult<boolean>>;
|
||||
testConnector: (id: z.infer<typeof connectorInputSchema.shape.id>) => Promise<DesktopResult<boolean>>;
|
||||
saveWorkspace: (input: z.infer<typeof workspaceInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveAgent: (input: z.infer<typeof agentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
requestHire: (input: z.infer<typeof hireRequestSchema>) => Promise<DesktopResult<{ agentId: string; approvalId: string; autoApproved: boolean }>>;
|
||||
saveGoal: (input: z.infer<typeof goalInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveProject: (input: z.infer<typeof projectInputSchema>) => Promise<DesktopResult<string>>;
|
||||
saveTask: (input: z.infer<typeof taskInputSchema>) => Promise<DesktopResult<SaveTaskResult>>;
|
||||
requestApproval: (input: z.infer<typeof approvalInputSchema>) => Promise<DesktopResult<string>>;
|
||||
decideApproval: (input: z.infer<typeof approvalDecisionSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveSecret: (input: z.infer<typeof secretInputSchema>) => Promise<DesktopResult<string>>;
|
||||
startTaskRun: (input: z.infer<typeof startRunSchema>) => Promise<DesktopResult<string>>;
|
||||
cancelRun: (input: z.infer<typeof cancelRunSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getRunLog: (input: z.infer<typeof runLogSchema>) => Promise<DesktopResult<string>>;
|
||||
getRunLogChunk: (input: z.infer<typeof runLogChunkSchema>) => Promise<DesktopResult<RunLogChunk>>;
|
||||
backupProfile: () => Promise<DesktopResult<string | null>>;
|
||||
restoreProfile: () => Promise<DesktopResult<boolean>>;
|
||||
updateSettings: (input: z.infer<typeof settingsSchema>) => Promise<DesktopResult<boolean>>;
|
||||
checkForUpdates: () => Promise<DesktopResult<boolean>>;
|
||||
deleteCompany: (companyId: string) => Promise<DesktopResult<boolean>>;
|
||||
deleteAgent: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteTask: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteGoal: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteProject: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteWorkspace: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteApproval: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
deleteSecret: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
getSidebarBadges: (companyId: string) => Promise<DesktopResult<SidebarBadges>>;
|
||||
listConnectorModels: (connectorId: string) => Promise<DesktopResult<Array<{ id: string; label: string }>>>;
|
||||
getConnectorDisabledModels: (connectorId: string) => Promise<DesktopResult<Array<{ id: string; label: string }>>>;
|
||||
setConnectorDisabledModels: (input: z.infer<typeof connectorDisabledModelsSchema>) => Promise<DesktopResult<boolean>>;
|
||||
openConnectorAuthTerminal: (connectorId: z.infer<typeof connectorInputSchema.shape.id>) => Promise<DesktopResult<boolean>>;
|
||||
addComment: (input: z.infer<typeof commentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
listComments: (input: z.infer<typeof listCommentsSchema>) => Promise<DesktopResult<CommentRecord[]>>;
|
||||
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[]>>;
|
||||
getCompanyMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<CompanyMetrics>>;
|
||||
getAgentMetrics: (input: z.infer<typeof metricsQuerySchema>) => Promise<DesktopResult<AgentMetrics>>;
|
||||
getStandupReport: (companyId: string) => Promise<DesktopResult<StandupReport>>;
|
||||
bootstrapOnboarding: (input: z.infer<typeof bootstrapOnboardingSchema>) => Promise<DesktopResult<OnboardingBootstrapResult>>;
|
||||
checkNodeInstalled: () => Promise<DesktopResult<{ installed: boolean; version: string | null }>>;
|
||||
openTerminalCommand: (input: z.infer<typeof openTerminalCommandSchema>) => Promise<DesktopResult<boolean>>;
|
||||
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 cancelBrowserActionSchema>) => Promise<DesktopResult<boolean>>;
|
||||
triggerBrowserLogin: (input: z.infer<typeof triggerBrowserLoginSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveMeeting: (input: z.infer<typeof meetingInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteMeeting: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveDocument: (input: z.infer<typeof documentInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteDocument: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveKnowledgeEntry: (input: z.infer<typeof knowledgeEntryInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteKnowledgeEntry: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveSprint: (input: z.infer<typeof sprintInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteSprint: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveAutomationRule: (input: z.infer<typeof automationRuleInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteAutomationRule: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
toggleAutomationRule: (input: z.infer<typeof toggleAutomationRuleSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getAutomationLog: (companyId: string) => Promise<DesktopResult<Array<{ ruleId: string; ruleName: string; trigger: string; action: string; executedAt: string }>>>;
|
||||
sendAgentMessage: (input: z.infer<typeof agentMessageInputSchema>) => Promise<DesktopResult<import("@shared/types").SendMessageResult>>;
|
||||
listAgentMessages: (input: z.infer<typeof messageQuerySchema>) => Promise<DesktopResult<AgentMessageRecord[]>>;
|
||||
markMessageRead: (input: z.infer<typeof markMessageReadSchema>) => Promise<DesktopResult<boolean>>;
|
||||
saveWorkflow: (input: z.infer<typeof workflowInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteWorkflow: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||
runWorkflow: (input: z.infer<typeof runWorkflowSchema>) => Promise<DesktopResult<boolean>>;
|
||||
autoAssignTask: (input: z.infer<typeof autoAssignSchema>) => Promise<DesktopResult<string>>;
|
||||
searchMessages: (input: z.infer<typeof searchMessagesSchema>) => Promise<DesktopResult<AgentMessageRecord[]>>;
|
||||
importSkill: (companyId: string, source: string) => Promise<DesktopResult<SkillImportResult[]>>;
|
||||
listSkills: (companyId: string) => Promise<DesktopResult<SkillRecord[]>>;
|
||||
getSkillDetail: (companyId: string, skillId: string) => Promise<DesktopResult<SkillRecord>>;
|
||||
deleteSkill: (companyId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
assignSkillToAgent: (companyId: string, agentId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
removeSkillFromAgent: (companyId: string, agentId: string, skillId: string) => Promise<DesktopResult<void>>;
|
||||
checkSkillUpdate: (companyId: string, skillId: string) => Promise<DesktopResult<SkillUpdateStatus>>;
|
||||
listSkillAgents: (companyId: string, skillId: string) => Promise<DesktopResult<string[]>>;
|
||||
listAgentSkills: (companyId: string, agentId: string) => Promise<DesktopResult<string[]>>;
|
||||
listWakeupRequests: (input: z.infer<typeof wakeupQuerySchema>) => Promise<DesktopResult<WakeupRequestRecord[]>>;
|
||||
saveBudgetPolicy: (input: z.infer<typeof budgetPolicyInputSchema>) => Promise<DesktopResult<string>>;
|
||||
deleteBudgetPolicy: (input: z.infer<typeof deleteBudgetPolicySchema>) => Promise<DesktopResult<boolean>>;
|
||||
listBudgetPolicies: (companyId: string) => Promise<DesktopResult<BudgetPolicyRecord[]>>;
|
||||
listBudgetIncidents: (input: z.infer<typeof listBudgetIncidentsSchema>) => Promise<DesktopResult<BudgetIncidentRecord[]>>;
|
||||
resolveBudgetIncident: (input: z.infer<typeof resolveBudgetIncidentSchema>) => Promise<DesktopResult<boolean>>;
|
||||
getBudgetStatus: (companyId: string) => Promise<DesktopResult<BudgetStatusSummary>>;
|
||||
recoveryRetry: (taskId: string, agentId: string, companyId: string) => Promise<DesktopResult<null>>;
|
||||
recoveryDismiss: (taskId: string) => Promise<DesktopResult<null>>;
|
||||
recoveryFail: (taskId: string) => Promise<DesktopResult<null>>;
|
||||
getTask: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<TaskRecord>>;
|
||||
getAgent: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<AgentRecord>>;
|
||||
getRun: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<RunRecord>>;
|
||||
getApproval: (input: z.infer<typeof entityGetterSchema>) => Promise<DesktopResult<ApprovalRecord>>;
|
||||
listConfigRevisions: (companyId: string, agentId: string) => Promise<DesktopResult<unknown[]>>;
|
||||
getConfigRevision: (companyId: string, revisionId: string) => Promise<DesktopResult<unknown>>;
|
||||
rollbackConfigRevision: (companyId: string, agentId: string, revisionId: string) => Promise<DesktopResult<boolean>>;
|
||||
listRunEvents: (companyId: string, runId: string, opts?: { offset?: number; limit?: number }) => Promise<DesktopResult<unknown[]>>;
|
||||
getAgentPermissions: (agentId: string) => Promise<DesktopResult<unknown>>;
|
||||
setAgentPermission: (companyId: string, agentId: string, permissionKey: string, enabled: boolean) => Promise<DesktopResult<boolean>>;
|
||||
getHeartbeatPolicy: (agentId: string, companyId: string) => Promise<DesktopResult<unknown>>;
|
||||
setHeartbeatPolicy: (companyId: string, agentId: string, policy: Record<string, unknown>) => Promise<DesktopResult<boolean>>;
|
||||
getRuntimeState: (agentId: string, companyId: string) => Promise<DesktopResult<unknown>>;
|
||||
setRuntimeState: (companyId: string, agentId: string, state: Record<string, unknown>) => Promise<DesktopResult<boolean>>;
|
||||
// Thread runtime
|
||||
createThread: (input: z.infer<typeof createThreadSchema>) => Promise<DesktopResult<ConversationThreadRecord>>;
|
||||
listThreads: (input: z.infer<typeof listThreadsSchema>) => Promise<DesktopResult<ConversationThreadRecord[]>>;
|
||||
getThread: (input: z.infer<typeof threadGetterSchema>) => Promise<DesktopResult<ConversationThreadRecord>>;
|
||||
addThreadEvent: (input: z.infer<typeof addThreadEventSchema>) => Promise<DesktopResult<ConversationEventRecord>>;
|
||||
listThreadEvents: (input: z.infer<typeof listThreadEventsSchema>) => Promise<DesktopResult<ConversationEventRecord[]>>;
|
||||
setThreadWaitState: (input: z.infer<typeof setThreadWaitStateSchema>) => Promise<DesktopResult<ThreadWaitStateRecord>>;
|
||||
resolveThreadWaitState: (input: z.infer<typeof resolveThreadWaitStateSchema>) => Promise<DesktopResult<boolean>>;
|
||||
listThreadWaitStates: (input: z.infer<typeof listThreadWaitStatesSchema>) => Promise<DesktopResult<ThreadWaitStateRecord[]>>;
|
||||
listParticipants: (input: z.infer<typeof listParticipantsSchema>) => Promise<DesktopResult<ConversationParticipantRecord[]>>;
|
||||
addParticipant: (input: z.infer<typeof addParticipantSchema>) => Promise<DesktopResult<ConversationParticipantRecord>>;
|
||||
removeParticipant: (input: z.infer<typeof removeParticipantSchema>) => Promise<DesktopResult<boolean>>;
|
||||
subscribeThread: (input: z.infer<typeof subscribeThreadSchema>) => Promise<DesktopResult<ThreadSubscriptionRecord>>;
|
||||
unsubscribeThread: (input: z.infer<typeof unsubscribeThreadSchema>) => Promise<DesktopResult<boolean>>;
|
||||
listSubscriptions: (input: z.infer<typeof listSubscriptionsSchema>) => Promise<DesktopResult<ThreadSubscriptionRecord[]>>;
|
||||
listSubscribedThreads: (input: z.infer<typeof listSubscribedThreadsSchema>) => Promise<DesktopResult<ConversationThreadRecord[]>>;
|
||||
subscribe: (callback: (event: DesktopEvent) => void) => () => void;
|
||||
platform: "win32" | "darwin" | "linux";
|
||||
windowMinimize: () => Promise<void>;
|
||||
windowMaximize: () => Promise<void>;
|
||||
windowClose: () => Promise<void>;
|
||||
windowIsMaximized: () => Promise<boolean>;
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const optionalId = z.preprocess(
|
||||
(value) => (value === "" ? null : value),
|
||||
z.string().uuid().nullable().optional(),
|
||||
);
|
||||
@@ -0,0 +1,49 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
import { connectorInputSchema } from "./schemas-company";
|
||||
|
||||
export const agentInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
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,
|
||||
model: z.string().nullable().optional(),
|
||||
metadataJson: z.string().default("{}").optional(),
|
||||
capabilities: z.string().default(""),
|
||||
budgetMonthlyUsd: z.number().min(0).default(0),
|
||||
status: z.enum(["idle", "active", "running", "paused", "error", "pending_approval", "terminated"]).default("idle"),
|
||||
});
|
||||
|
||||
export const hireRequestSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
requestedByAgentId: optionalId,
|
||||
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,
|
||||
model: z.string().nullable().optional(),
|
||||
metadataJson: z.string().default("{}").optional(),
|
||||
capabilities: z.string().default(""),
|
||||
budgetMonthlyUsd: z.number().min(0).default(0),
|
||||
});
|
||||
|
||||
export const heartbeatSettingsSchema = z.object({
|
||||
agentId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
enabled: z.boolean(),
|
||||
intervalSec: z.number().int().min(30).max(86400).default(120),
|
||||
});
|
||||
|
||||
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", "message", "peer_request", "task_continuation"]).default("manual"),
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
|
||||
export const approvalInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
relatedTaskId: optionalId,
|
||||
requestedByAgentId: optionalId,
|
||||
relatedAgentId: optionalId,
|
||||
type: z.enum(["hire_agent", "approve_ceo_strategy", "dangerous_command", "secret_access", "budget_request", "promotion", "termination", "vendor_approval", "document_review", "production_deploy", "incident_escalation", "social_post", "deliverable_review"]),
|
||||
payloadSummary: z.string().min(2).max(280),
|
||||
impactSummary: z.string().min(2).max(400),
|
||||
payloadJson: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const approvalDecisionSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
approvalId: z.string().uuid(),
|
||||
state: z.enum(["approved", "rejected", "revision_requested"]),
|
||||
decisionNote: z.string().max(400).default(""),
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
|
||||
export const companyInputSchema = z.object({
|
||||
id: optionalId,
|
||||
name: z.string().min(2).max(80),
|
||||
description: z.string().max(500).default(""),
|
||||
status: z.enum(["active", "paused", "archived"]).default("active"),
|
||||
autoApproveHires: z.boolean().default(false),
|
||||
reviewDeliverables: z.boolean().default(false),
|
||||
executionMode: z.enum(["ai_ceo", "ai_cofounder"]).default("ai_ceo"),
|
||||
});
|
||||
|
||||
export const connectorInputSchema = z.object({
|
||||
id: z.enum(["codex_local", "claude_local", "claude_compatible", "claude_compat_2", "claude_compat_3", "claude_compat_4", "claude_compat_5", "claude_compat_6", "claude_compat_7", "claude_compat_8", "claude_compat_9", "claude_compat_10", "gemini_local"]),
|
||||
command: z.string().min(1),
|
||||
model: z.string().nullable().optional(),
|
||||
envBindingText: z.string().default(""),
|
||||
notes: z.string().default(""),
|
||||
});
|
||||
|
||||
export const connectorDisabledModelsSchema = z.object({
|
||||
connectorId: connectorInputSchema.shape.id,
|
||||
disabledModels: z.array(z.object({ id: z.string(), label: z.string() })),
|
||||
});
|
||||
|
||||
export const workspaceInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(80),
|
||||
localPath: z.string().min(1),
|
||||
repoUrl: z.string().default(""),
|
||||
repoRef: z.string().default(""),
|
||||
projectId: optionalId,
|
||||
isPrimary: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const settingsSchema = z.object({
|
||||
theme: z.enum(["system", "light", "dark"]).optional(),
|
||||
locale: z.enum(["en", "zh"]).optional(),
|
||||
updatesEnabled: z.boolean().optional(),
|
||||
logRetentionDays: z.number().int().min(1).max(365).optional(),
|
||||
});
|
||||
|
||||
export const bootstrapOnboardingSchema = z.object({
|
||||
companyName: z.string().min(2).max(80),
|
||||
companyDescription: z.string().max(500).default(""),
|
||||
workspacePath: z.string().default(""),
|
||||
autoApproveHires: z.boolean().default(true),
|
||||
reviewDeliverables: z.boolean().default(false),
|
||||
executionMode: z.enum(["ai_ceo", "ai_cofounder"]).default("ai_ceo"),
|
||||
goalTitle: z.string().default(""),
|
||||
goalDescription: z.string().default(""),
|
||||
connectorId: z.enum(["codex_local", "claude_local", "claude_compatible", "claude_compat_2", "claude_compat_3", "claude_compat_4", "claude_compat_5", "claude_compat_6", "claude_compat_7", "claude_compat_8", "claude_compat_9", "claude_compat_10", "gemini_local"]).optional(),
|
||||
connectorModel: z.string().default(""),
|
||||
});
|
||||
|
||||
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 secretInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
name: z.string().min(2).max(80),
|
||||
description: z.string().default(""),
|
||||
value: z.string().min(1).max(2000),
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const startRunSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const cancelRunSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const runLogSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const runLogChunkSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
runId: z.string().uuid(),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1024).max(262_144).default(65_536),
|
||||
});
|
||||
|
||||
export const triggerBrowserLoginSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
socialAccountId: z.string().uuid(),
|
||||
});
|
||||
|
||||
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),
|
||||
});
|
||||
|
||||
export const cancelBrowserActionSchema = z.object({
|
||||
actionId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
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", "task_reassigned",
|
||||
"run_completed", "run_failed", "approval_created", "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 runWorkflowSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const importSkillSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
source: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listSkillsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const getSkillDetailSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const deleteSkillSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const assignSkillToAgentSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const removeSkillFromAgentSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const checkSkillUpdateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listSkillAgentsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
skillId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listAgentSkillsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const openTerminalCommandSchema = z.object({
|
||||
title: z.string().min(1).max(200),
|
||||
command: z.string().min(1),
|
||||
});
|
||||
@@ -0,0 +1,139 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
|
||||
export const agentMessageInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
fromAgentId: z.union([z.string().uuid(), z.literal("__board__")]),
|
||||
toAgentId: z.preprocess(
|
||||
(v) => (v === "" ? null : v),
|
||||
z.union([z.string().uuid(), z.literal("__board__")]).nullable().optional(),
|
||||
),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).default("direct"),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
subject: z.preprocess((v) => (v === "" ? "(no subject)" : v), 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("[]"),
|
||||
threadId: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
waitStateId: z.preprocess((v) => (v === "" ? null : v), z.string().uuid().nullable().optional()),
|
||||
}).superRefine((value, ctx) => {
|
||||
if (value.channel === "direct" && !value.toAgentId) {
|
||||
ctx.addIssue({
|
||||
path: ["toAgentId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Direct messages require toAgentId.",
|
||||
});
|
||||
}
|
||||
|
||||
if ((value.channel === "department" || value.channel === "project") && !value.channelTargetId) {
|
||||
ctx.addIssue({
|
||||
path: ["channelTargetId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: `${value.channel} messages require channelTargetId.`,
|
||||
});
|
||||
}
|
||||
|
||||
if (value.channel !== "direct" && value.toAgentId) {
|
||||
ctx.addIssue({
|
||||
path: ["toAgentId"],
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Only direct messages may set toAgentId.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const messageQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).optional(),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
unreadOnly: z.boolean().optional(),
|
||||
limit: z.number().int().min(1).max(500).default(200),
|
||||
});
|
||||
|
||||
export const searchMessagesSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
query: z.string().min(1).max(200),
|
||||
channel: z.enum(["direct", "department", "company", "project", "incident"]).optional(),
|
||||
channelTargetId: z.string().nullable().optional(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
});
|
||||
|
||||
export const commentInputSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
authorAgentId: optionalId,
|
||||
authorName: z.string().min(1).max(80),
|
||||
body: z.string().min(1).max(4000),
|
||||
});
|
||||
|
||||
export const listCommentsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
taskId: z.string().uuid(),
|
||||
});
|
||||
|
||||
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.enum([
|
||||
"agents",
|
||||
"goals",
|
||||
"projects",
|
||||
"tasks",
|
||||
"approvals",
|
||||
"runs",
|
||||
"secrets",
|
||||
"meetings",
|
||||
"documents",
|
||||
"knowledge_base",
|
||||
"sprints",
|
||||
"automation_rules",
|
||||
"workflow_pipelines",
|
||||
]).nullable().optional(),
|
||||
referencedEntityId: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
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 markMessageReadSchema = z.object({
|
||||
messageId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
readerAgentId: optionalId,
|
||||
});
|
||||
@@ -0,0 +1,287 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
|
||||
export const deleteEntitySchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const sidebarBadgesSchema = z.object({
|
||||
pendingApprovals: z.number(),
|
||||
activeRuns: z.number(),
|
||||
failedRuns: z.number(),
|
||||
todoTasks: z.number(),
|
||||
budgetWarnings: z.number(),
|
||||
unreadMessages: z.number(),
|
||||
});
|
||||
export type SidebarBadges = z.infer<typeof sidebarBadgesSchema>;
|
||||
|
||||
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", "task_reassigned",
|
||||
"run_completed", "run_failed", "approval_created", "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 toggleAutomationRuleSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["active", "paused"]),
|
||||
});
|
||||
|
||||
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 budgetPolicyInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
scopeType: z.enum(["company", "agent", "project"]),
|
||||
scopeId: z.string().uuid(),
|
||||
metric: z.literal("billed_cents").default("billed_cents"),
|
||||
windowKind: z.literal("calendar_month_utc").default("calendar_month_utc"),
|
||||
amount: z.number().int().min(1),
|
||||
warnPercent: z.number().int().min(1).max(100).default(80),
|
||||
hardStopEnabled: z.boolean().default(true),
|
||||
notifyEnabled: z.boolean().default(true),
|
||||
isActive: z.boolean().default(true),
|
||||
});
|
||||
|
||||
export const listBudgetPoliciesSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const deleteBudgetPolicySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
policyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listBudgetIncidentsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["open", "resolved", "auto_resolved_limit_increase", "auto_closed", "all"]).default("all"),
|
||||
});
|
||||
|
||||
export const resolveBudgetIncidentSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
incidentId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const getBudgetStatusSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const wakeupQuerySchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
status: z.enum(["queued", "claimed", "coalesced", "deferred", "completed"]).optional(),
|
||||
agentId: z.string().uuid().optional(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
});
|
||||
|
||||
export interface WakeupRequestRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
agentId: string;
|
||||
source: string;
|
||||
triggerDetail: string | null;
|
||||
status: string;
|
||||
coalescedCount: number;
|
||||
runId: string | null;
|
||||
requestedAt: string;
|
||||
claimedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export const entityGetterSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
id: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listConfigRevisionsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const getConfigRevisionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
revisionId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const rollbackConfigRevisionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
revisionId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const listRunEventsSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
runId: z.string().min(1),
|
||||
offset: z.number().optional(),
|
||||
limit: z.number().optional(),
|
||||
});
|
||||
|
||||
export const getAgentPermissionsSchema = z.object({
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setAgentPermissionSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
permissionKey: z.string().min(1),
|
||||
enabled: z.boolean(),
|
||||
});
|
||||
|
||||
export const heartbeatPolicySchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setHeartbeatPolicySchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
enabled: z.boolean().optional(),
|
||||
intervalSec: z.number().optional(),
|
||||
cooldownSec: z.number().optional(),
|
||||
maxConcurrentRuns: z.number().optional(),
|
||||
wakeOnDemand: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const runtimeStateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const setRuntimeStateSchema = z.object({
|
||||
companyId: z.string().min(1),
|
||||
agentId: z.string().min(1),
|
||||
state: z.record(z.string(), z.unknown()),
|
||||
});
|
||||
|
||||
// ─── Thread Runtime Schemas ───────────────────────────────────────────────────
|
||||
|
||||
export const createThreadSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
title: z.string().min(1).max(200),
|
||||
type: z.enum(["task", "approval", "general", "announcement"]),
|
||||
relatedEntityType: z.string().nullable().optional(),
|
||||
relatedEntityId: z.string().nullable().optional(),
|
||||
});
|
||||
|
||||
export const listThreadsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
type: z.enum(["task", "approval", "general", "announcement"]).optional(),
|
||||
relatedEntityType: z.string().optional(),
|
||||
relatedEntityId: z.string().optional(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
});
|
||||
|
||||
export const threadGetterSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
threadId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const addThreadEventSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
threadId: z.string().uuid(),
|
||||
actorId: z.string().min(1),
|
||||
actorType: z.enum(["agent", "user", "system"]),
|
||||
eventType: z.enum(["message", "status_change", "approval_request", "approval_decision", "file_attachment", "system_note"]),
|
||||
body: z.string().default(""),
|
||||
metadataJson: z.string().default("{}"),
|
||||
});
|
||||
|
||||
export const listThreadEventsSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
threadId: z.string().uuid(),
|
||||
limit: z.number().int().min(1).max(100).default(50),
|
||||
offset: z.number().int().min(0).default(0),
|
||||
});
|
||||
|
||||
export const setThreadWaitStateSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
threadId: z.string().uuid(),
|
||||
waitingFor: z.enum(["user_review", "user_approval", "user_reply"]),
|
||||
relatedApprovalId: z.string().nullable().optional(),
|
||||
reason: z.string().min(1).max(500),
|
||||
});
|
||||
|
||||
export const resolveThreadWaitStateSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
waitStateId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listThreadWaitStatesSchema = z.object({
|
||||
companyId: z.string().uuid(),
|
||||
resolvedOnly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const listParticipantsSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const addParticipantSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
participantId: z.string(),
|
||||
participantType: z.enum(["agent", "user", "system"]),
|
||||
role: z.enum(["owner", "member", "observer"]).default("member"),
|
||||
});
|
||||
|
||||
export const removeParticipantSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
participantId: z.string(),
|
||||
});
|
||||
|
||||
export const subscribeThreadSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
subscriberId: z.string(),
|
||||
subscriberType: z.enum(["agent", "user", "system"]),
|
||||
notifyOn: z.enum(["all", "mentions", "none"]).default("all"),
|
||||
});
|
||||
|
||||
export const unsubscribeThreadSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
subscriberId: z.string(),
|
||||
});
|
||||
|
||||
export const listSubscriptionsSchema = z.object({
|
||||
threadId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const listSubscribedThreadsSchema = z.object({
|
||||
subscriberId: z.string(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import { z } from "zod";
|
||||
import { optionalId } from "./helpers";
|
||||
|
||||
export const goalInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
title: z.string().min(2).max(120),
|
||||
description: z.string().default(""),
|
||||
parentId: optionalId,
|
||||
ownerAgentId: optionalId,
|
||||
status: z.enum(["planned", "active", "achieved", "cancelled"]).default("planned"),
|
||||
});
|
||||
|
||||
export const projectInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
goalId: optionalId,
|
||||
name: z.string().min(2).max(120),
|
||||
description: z.string().default(""),
|
||||
leadAgentId: optionalId,
|
||||
targetDate: z.string().nullable().optional(),
|
||||
status: z.enum(["backlog", "planned", "in_progress", "completed", "cancelled"]).default("planned"),
|
||||
});
|
||||
|
||||
export const taskInputSchema = z.object({
|
||||
id: optionalId,
|
||||
companyId: z.string().uuid(),
|
||||
projectId: optionalId,
|
||||
goalId: optionalId,
|
||||
parentId: optionalId,
|
||||
title: z.string().min(2).max(160),
|
||||
description: z.string().default(""),
|
||||
assigneeAgentId: optionalId,
|
||||
workspaceId: optionalId,
|
||||
priority: z.enum(["critical", "high", "medium", "low"]).default("medium"),
|
||||
status: z.enum(["backlog", "todo", "in_progress", "in_review", "done", "blocked", "cancelled"]).default("todo"),
|
||||
});
|
||||
|
||||
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 autoAssignSchema = z.object({
|
||||
taskId: z.string().uuid(),
|
||||
companyId: z.string().uuid(),
|
||||
});
|
||||
+4
-969
@@ -1,969 +1,4 @@
|
||||
export type SectionId =
|
||||
| "overview"
|
||||
| "inbox"
|
||||
| "standup"
|
||||
| "performance"
|
||||
| "runs"
|
||||
| "connectors"
|
||||
| "agents"
|
||||
| "orgchart"
|
||||
| "hiring"
|
||||
| "goals"
|
||||
| "projects"
|
||||
| "tasks"
|
||||
| "approvals"
|
||||
| "costs"
|
||||
| "activity"
|
||||
| "workspaces"
|
||||
| "social"
|
||||
| "skills"
|
||||
| "automation"
|
||||
| "communication"
|
||||
| "documents"
|
||||
| "knowledge"
|
||||
| "meetings"
|
||||
| "sprints"
|
||||
| "settings";
|
||||
|
||||
export type ConnectorId =
|
||||
| "codex_local"
|
||||
| "claude_local"
|
||||
| "claude_compatible"
|
||||
| "claude_compat_2"
|
||||
| "claude_compat_3"
|
||||
| "claude_compat_4"
|
||||
| "claude_compat_5"
|
||||
| "claude_compat_6"
|
||||
| "claude_compat_7"
|
||||
| "claude_compat_8"
|
||||
| "claude_compat_9"
|
||||
| "claude_compat_10"
|
||||
| "gemini_local";
|
||||
|
||||
export type ConnectorStatus =
|
||||
| "not_installed"
|
||||
| "detected"
|
||||
| "auth_required"
|
||||
| "ready"
|
||||
| "degraded"
|
||||
| "error";
|
||||
|
||||
export type TaskType = "code" | "research" | "content" | "management" | "general";
|
||||
|
||||
export type WorkspaceState = "ready" | "busy" | "blocked" | "missing" | "error";
|
||||
export type CompanyStatus = "active" | "paused" | "archived";
|
||||
export type AgentStatus =
|
||||
| "idle"
|
||||
| "active"
|
||||
| "running"
|
||||
| "paused"
|
||||
| "error"
|
||||
| "pending_approval"
|
||||
| "terminated";
|
||||
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"
|
||||
| "social_post"
|
||||
| "deliverable_review"
|
||||
| "budget_override";
|
||||
export type RunStatus =
|
||||
| "queued"
|
||||
| "running"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out"
|
||||
| "interrupted";
|
||||
|
||||
export interface CapabilityMatrix {
|
||||
sessionResume: boolean;
|
||||
gracefulCancel: boolean;
|
||||
modelDiscovery: boolean;
|
||||
structuredTranscript: boolean;
|
||||
costAttribution: boolean;
|
||||
}
|
||||
|
||||
export interface CompanyRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
status: CompanyStatus;
|
||||
autoApproveHires: boolean;
|
||||
reviewDeliverables: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ConnectorRecord {
|
||||
id: ConnectorId;
|
||||
label: string;
|
||||
description: string;
|
||||
status: ConnectorStatus;
|
||||
command: string;
|
||||
version: string | null;
|
||||
authState: "unknown" | "ok" | "required" | "error";
|
||||
lastCheckedAt: string | null;
|
||||
lastError: string | null;
|
||||
model: string | null;
|
||||
envBindingText: string;
|
||||
notes: string;
|
||||
configurationDoc: string;
|
||||
capabilityMatrix: CapabilityMatrix;
|
||||
}
|
||||
|
||||
export interface WorkspaceRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
localPath: string;
|
||||
repoUrl: string;
|
||||
repoRef: string;
|
||||
projectId: string | null;
|
||||
state: WorkspaceState;
|
||||
isPrimary: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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;
|
||||
workspaceId: string | null;
|
||||
model: string | null;
|
||||
capabilities: string;
|
||||
budgetMonthlyUsd: number;
|
||||
spentMonthlyUsd: number;
|
||||
metadataJson: string;
|
||||
heartbeatEnabled: boolean;
|
||||
heartbeatIntervalSec: number;
|
||||
lastHeartbeatAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface GoalRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
title: string;
|
||||
description: string;
|
||||
parentId: string | null;
|
||||
ownerAgentId: string | null;
|
||||
status: GoalStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ProjectRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
goalId: string | null;
|
||||
name: string;
|
||||
description: string;
|
||||
leadAgentId: string | null;
|
||||
status: ProjectStatus;
|
||||
targetDate: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TaskRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string | null;
|
||||
goalId: string | null;
|
||||
parentId: string | null;
|
||||
title: string;
|
||||
description: string;
|
||||
assigneeAgentId: string | null;
|
||||
workspaceId: string | null;
|
||||
status: TaskStatus;
|
||||
priority: "critical" | "high" | "medium" | "low";
|
||||
activeRunId: string | null;
|
||||
sessionJson: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
costUsd: number;
|
||||
requiresUserReview: boolean;
|
||||
startedAt: string | null;
|
||||
completedAt: string | null;
|
||||
cancelledAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ApprovalRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
relatedTaskId: string | null;
|
||||
relatedAgentId: string | null;
|
||||
requestedByAgentId: string | null;
|
||||
type: ApprovalType;
|
||||
payloadSummary: string;
|
||||
impactSummary: string;
|
||||
payloadJson: string | null;
|
||||
decisionNote: string;
|
||||
state: ApprovalState;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RunRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
agentId: string;
|
||||
workspaceId: string | null;
|
||||
connectorId: ConnectorId;
|
||||
status: RunStatus;
|
||||
summary: string;
|
||||
errorMessage: string | null;
|
||||
exitCode: number | null;
|
||||
signal: string | null;
|
||||
model: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
costUsd: number | null;
|
||||
unattributedCost: boolean;
|
||||
startedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
logPath: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RunLogChunk {
|
||||
content: string;
|
||||
offset: number;
|
||||
nextOffset: number;
|
||||
totalBytes: number;
|
||||
eof: boolean;
|
||||
}
|
||||
|
||||
export interface CostRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
runId: string;
|
||||
taskId: string | null;
|
||||
agentId: string | null;
|
||||
connectorId: ConnectorId;
|
||||
amountUsd: number | null;
|
||||
unattributed: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetPolicyRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
scopeType: "company" | "agent" | "project";
|
||||
scopeId: string;
|
||||
metric: string;
|
||||
windowKind: string;
|
||||
amount: number; // INTEGER cents
|
||||
warnPercent: number;
|
||||
hardStopEnabled: boolean;
|
||||
notifyEnabled: boolean;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetIncidentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
policyId: string;
|
||||
scopeType: string;
|
||||
scopeId: string;
|
||||
metric: string;
|
||||
windowKind: string;
|
||||
windowStart: string;
|
||||
windowEnd: string;
|
||||
thresholdType: "warn_threshold" | "hard_stop";
|
||||
amountLimit: number;
|
||||
amountObserved: number;
|
||||
status: "open" | "resolved" | "auto_resolved_limit_increase" | "auto_closed";
|
||||
resolvedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetStatusSummary {
|
||||
policies: Array<{
|
||||
policyId: string;
|
||||
scopeType: string;
|
||||
scopeId: string;
|
||||
amount: number;
|
||||
spent: number;
|
||||
warnPercent: number;
|
||||
hardStopEnabled: boolean;
|
||||
hasOpenIncident: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface TaskSessionRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
agentId: string;
|
||||
adapterType: string;
|
||||
sessionParamsJson: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
lastRunId: string | null;
|
||||
lastError: string | null;
|
||||
runCount: number;
|
||||
totalInputTokens: number;
|
||||
totalOutputTokens: number;
|
||||
rotatedAt: string | null;
|
||||
rotationReason: string | null;
|
||||
handoffMarkdown: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ActivityRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
actor: string;
|
||||
action: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
detail: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface SecretRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
backend: "safe_storage" | "vault";
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ProfileSnapshot {
|
||||
currentCompanyId: string | null;
|
||||
profilePath: string;
|
||||
updatesEnabled: boolean;
|
||||
theme: "system" | "light" | "dark";
|
||||
locale: "en" | "zh";
|
||||
backend: {
|
||||
secretBackend: string;
|
||||
};
|
||||
companies: CompanyRecord[];
|
||||
connectors: ConnectorRecord[];
|
||||
workspaces: WorkspaceRecord[];
|
||||
agents: AgentRecord[];
|
||||
goals: GoalRecord[];
|
||||
projects: ProjectRecord[];
|
||||
tasks: TaskRecord[];
|
||||
approvals: ApprovalRecord[];
|
||||
runs: RunRecord[];
|
||||
costs: CostRecord[];
|
||||
activity: ActivityRecord[];
|
||||
secrets: SecretRecord[];
|
||||
comments: CommentRecord[];
|
||||
socialAccounts: SocialAccountRecord[];
|
||||
meetings: MeetingRecord[];
|
||||
documents: DocumentRecord[];
|
||||
knowledgeBase: KnowledgeEntryRecord[];
|
||||
sprints: SprintRecord[];
|
||||
automationRules: AutomationRuleRecord[];
|
||||
agentMessages: AgentMessageRecord[];
|
||||
workflows: WorkflowPipelineRecord[];
|
||||
}
|
||||
|
||||
export interface LogChunkEvent {
|
||||
type: "run-log";
|
||||
runId: string;
|
||||
stream: "stdout" | "stderr";
|
||||
chunk: string;
|
||||
}
|
||||
|
||||
export interface DomainChangedEvent {
|
||||
type: "domain-changed";
|
||||
}
|
||||
|
||||
export interface ShortcutEvent {
|
||||
type: "shortcut";
|
||||
action: "toggle-command-palette" | "toggle-console" | "refresh";
|
||||
}
|
||||
|
||||
export interface RunStatusEvent {
|
||||
type: "run-status";
|
||||
runId: string;
|
||||
status: RunStatus;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface CommentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
authorAgentId: string | null;
|
||||
authorName: string;
|
||||
body: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface HeartbeatStatusEvent {
|
||||
type: "heartbeat-status";
|
||||
agentId: string;
|
||||
enabled: boolean;
|
||||
nextWakeAt: string | null;
|
||||
}
|
||||
|
||||
export interface AgentMessageEvent {
|
||||
type: "agent-message";
|
||||
taskId: string;
|
||||
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 interface NotificationClickEvent {
|
||||
type: "notification-click";
|
||||
section: SectionId;
|
||||
entityId?: string;
|
||||
}
|
||||
|
||||
export interface TaskUpdatedEvent {
|
||||
type: "task-updated";
|
||||
taskId: string;
|
||||
action: "created" | "updated" | "deleted";
|
||||
}
|
||||
|
||||
export interface RunUpdatedEvent {
|
||||
type: "run-updated";
|
||||
runId: string;
|
||||
action: "created" | "status_changed" | "completed";
|
||||
}
|
||||
|
||||
export interface ApprovalUpdatedEvent {
|
||||
type: "approval-updated";
|
||||
approvalId: string;
|
||||
action: "created" | "decided" | "deleted";
|
||||
}
|
||||
|
||||
export interface AgentUpdatedEvent {
|
||||
type: "agent-updated";
|
||||
agentId: string;
|
||||
action: "updated" | "paused";
|
||||
}
|
||||
|
||||
export interface BudgetChangedEvent {
|
||||
type: "budget-changed";
|
||||
companyId: string;
|
||||
}
|
||||
|
||||
export type DesktopEvent =
|
||||
| LogChunkEvent
|
||||
| DomainChangedEvent
|
||||
| ShortcutEvent
|
||||
| RunStatusEvent
|
||||
| HeartbeatStatusEvent
|
||||
| AgentMessageEvent
|
||||
| AutomationFiredEvent
|
||||
| NewMessageEvent
|
||||
| NotificationClickEvent
|
||||
| TaskUpdatedEvent
|
||||
| RunUpdatedEvent
|
||||
| ApprovalUpdatedEvent
|
||||
| AgentUpdatedEvent
|
||||
| BudgetChangedEvent;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface AgentMetrics {
|
||||
agentId: string;
|
||||
agentName: string;
|
||||
tasksCompleted: number;
|
||||
tasksAssigned: number;
|
||||
tasksFailed: number;
|
||||
successRate: number;
|
||||
avgRunDurationSec: number;
|
||||
totalCostUsd: number;
|
||||
runsTotal: number;
|
||||
runsSucceeded: number;
|
||||
runsFailed: number;
|
||||
reviewCycles: number;
|
||||
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[];
|
||||
}
|
||||
|
||||
export interface OnboardingBootstrapResult {
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
workspaceId: string | null;
|
||||
leadAgentId: string | null;
|
||||
projectId: string | null;
|
||||
taskId: string | null;
|
||||
runId: string | null;
|
||||
}
|
||||
|
||||
export type SkillSourceType = "github" | "local_path" | "url" | "skills_sh" | "managed";
|
||||
export type TrustLevel = "markdown_only" | "assets" | "scripts_executables";
|
||||
|
||||
export interface FileInventoryEntry {
|
||||
path: string;
|
||||
kind: "skill" | "reference" | "script" | "asset" | "markdown" | "other";
|
||||
}
|
||||
|
||||
export interface SkillRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
key: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
markdown: string;
|
||||
sourceType: SkillSourceType;
|
||||
sourceLocator: string | null;
|
||||
sourceRef: string | null;
|
||||
trustLevel: TrustLevel;
|
||||
compatibility: string;
|
||||
fileInventory: FileInventoryEntry[];
|
||||
metadata: Record<string, unknown> | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface SkillImportResult {
|
||||
skillId: string;
|
||||
key: string;
|
||||
name: string;
|
||||
isUpdate: boolean;
|
||||
}
|
||||
|
||||
export interface SkillUpdateStatus {
|
||||
skillId: string;
|
||||
key: string;
|
||||
currentRef: string | null;
|
||||
latestRef: string | null;
|
||||
hasUpdate: boolean;
|
||||
}
|
||||
|
||||
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";
|
||||
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;
|
||||
credentialSecretId: string | null;
|
||||
status: SocialAccountStatus;
|
||||
requireApproval: boolean;
|
||||
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;
|
||||
payloadJson: string;
|
||||
status: BrowserActionStatus;
|
||||
resultSummary: string;
|
||||
screenshotPath: string | null;
|
||||
approvalId: string | null;
|
||||
errorMessage: string | null;
|
||||
startedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
latestRevisionId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface DocumentRevisionRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
documentId: string;
|
||||
revisionNumber: number;
|
||||
body: string;
|
||||
changeSummary: string | null;
|
||||
createdByAgentId: string | null;
|
||||
createdByUserId: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ApprovalCommentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
approvalId: string;
|
||||
authorAgentId: string | null;
|
||||
authorUserId: string | null;
|
||||
body: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type WorkProductType = "preview_url" | "pull_request" | "branch" | "commit" | "artifact" | "document" | "runtime_service";
|
||||
export type WorkProductStatus = "active" | "ready_for_review" | "approved" | "changes_requested" | "merged" | "closed" | "failed" | "archived" | "draft";
|
||||
export type WorkProductReviewState = "none" | "needs_board_review" | "approved" | "changes_requested";
|
||||
|
||||
export interface WorkProductRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string | null;
|
||||
taskId: string;
|
||||
type: WorkProductType;
|
||||
provider: string;
|
||||
externalId: string | null;
|
||||
title: string;
|
||||
url: string | null;
|
||||
status: WorkProductStatus;
|
||||
reviewState: WorkProductReviewState;
|
||||
isPrimary: boolean;
|
||||
summary: string | null;
|
||||
metadataJson: string | null;
|
||||
createdByRunId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TaskDocumentLink {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
documentId: string;
|
||||
key: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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:
|
||||
| "agents"
|
||||
| "goals"
|
||||
| "projects"
|
||||
| "tasks"
|
||||
| "approvals"
|
||||
| "runs"
|
||||
| "secrets"
|
||||
| "meetings"
|
||||
| "documents"
|
||||
| "knowledge_base"
|
||||
| "sprints"
|
||||
| "automation_rules"
|
||||
| "workflow_pipelines"
|
||||
| null;
|
||||
referencedEntityId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export type AutomationTrigger =
|
||||
| "task_status_changed"
|
||||
| "task_created"
|
||||
| "task_blocked"
|
||||
| "task_reassigned"
|
||||
| "run_completed"
|
||||
| "run_failed"
|
||||
| "approval_created"
|
||||
| "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;
|
||||
conditionsJson: string;
|
||||
action: AutomationAction;
|
||||
actionConfigJson: string;
|
||||
sourceDepartment: DepartmentId | null;
|
||||
targetDepartment: DepartmentId | null;
|
||||
priority: number;
|
||||
status: AutomationStatus;
|
||||
executionCount: number;
|
||||
lastExecutedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type MessageChannel = "direct" | "department" | "company" | "project" | "incident";
|
||||
export type MessagePriority = "urgent" | "normal" | "low";
|
||||
|
||||
export interface AgentMessageRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
fromAgentId: string;
|
||||
toAgentId: string | null;
|
||||
channel: MessageChannel;
|
||||
channelTargetId: string | null;
|
||||
subject: string;
|
||||
body: string;
|
||||
priority: MessagePriority;
|
||||
readAt: string | null;
|
||||
parentMessageId: string | null;
|
||||
attachmentsJson: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export type WorkflowStatus = "draft" | "active" | "paused" | "completed" | "failed";
|
||||
|
||||
export interface WorkflowPipelineRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
stepsJson: string;
|
||||
triggerType: AutomationTrigger;
|
||||
triggerConfigJson: string;
|
||||
status: WorkflowStatus;
|
||||
currentStepIndex: number;
|
||||
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;
|
||||
requiresApproval: boolean;
|
||||
timeoutSec: number;
|
||||
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
||||
}
|
||||
export * from "./types/enums";
|
||||
export * from "./types/records";
|
||||
export * from "./types/events";
|
||||
export * from "./types/snapshot";
|
||||
@@ -0,0 +1,232 @@
|
||||
export type SectionId =
|
||||
| "overview"
|
||||
| "inbox"
|
||||
| "standup"
|
||||
| "performance"
|
||||
| "runs"
|
||||
| "connectors"
|
||||
| "agents"
|
||||
| "orgchart"
|
||||
| "hiring"
|
||||
| "goals"
|
||||
| "projects"
|
||||
| "tasks"
|
||||
| "approvals"
|
||||
| "costs"
|
||||
| "activity"
|
||||
| "workspaces"
|
||||
| "social"
|
||||
| "skills"
|
||||
| "automation"
|
||||
| "communication"
|
||||
| "documents"
|
||||
| "knowledge"
|
||||
| "meetings"
|
||||
| "sprints"
|
||||
| "settings";
|
||||
|
||||
export type ConnectorId =
|
||||
| "codex_local"
|
||||
| "claude_local"
|
||||
| "claude_compatible"
|
||||
| "claude_compat_2"
|
||||
| "claude_compat_3"
|
||||
| "claude_compat_4"
|
||||
| "claude_compat_5"
|
||||
| "claude_compat_6"
|
||||
| "claude_compat_7"
|
||||
| "claude_compat_8"
|
||||
| "claude_compat_9"
|
||||
| "claude_compat_10"
|
||||
| "gemini_local";
|
||||
|
||||
export type ConnectorStatus =
|
||||
| "not_installed"
|
||||
| "detected"
|
||||
| "auth_required"
|
||||
| "ready"
|
||||
| "degraded"
|
||||
| "error";
|
||||
|
||||
export type SenderKind = "agent" | "human" | "system";
|
||||
|
||||
export type TaskType = "code" | "research" | "content" | "management" | "general";
|
||||
|
||||
export type WorkspaceState = "ready" | "busy" | "blocked" | "missing" | "error";
|
||||
export type CompanyStatus = "active" | "paused" | "archived";
|
||||
export type ExecutionMode = "ai_ceo" | "ai_cofounder";
|
||||
export type AgentStatus =
|
||||
| "idle"
|
||||
| "active"
|
||||
| "running"
|
||||
| "paused"
|
||||
| "error"
|
||||
| "pending_approval"
|
||||
| "terminated";
|
||||
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"
|
||||
| "social_post"
|
||||
| "deliverable_review"
|
||||
| "budget_override"
|
||||
| "plan_review"
|
||||
| "scope_review"
|
||||
| "draft_review"
|
||||
| "strategy_review"
|
||||
| "exception_review";
|
||||
export type RunStatus =
|
||||
| "queued"
|
||||
| "running"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "cancelled"
|
||||
| "timed_out"
|
||||
| "interrupted";
|
||||
|
||||
export type DepartmentId =
|
||||
| "executive"
|
||||
| "engineering"
|
||||
| "product"
|
||||
| "marketing"
|
||||
| "sales"
|
||||
| "hr"
|
||||
| "finance"
|
||||
| "legal"
|
||||
| "operations"
|
||||
| "customer_support"
|
||||
| "research"
|
||||
| "design";
|
||||
|
||||
export type BudgetAlertLevel = "warn" | "hard_stop";
|
||||
|
||||
export type SkillSourceType = "github" | "local_path" | "url" | "skills_sh" | "managed";
|
||||
export type TrustLevel = "markdown_only" | "assets" | "scripts_executables";
|
||||
|
||||
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";
|
||||
export type BrowserActionStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled" | "approval_required";
|
||||
|
||||
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 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 type KnowledgeCategory =
|
||||
| "lesson_learned"
|
||||
| "best_practice"
|
||||
| "decision"
|
||||
| "process"
|
||||
| "technical"
|
||||
| "business"
|
||||
| "onboarding"
|
||||
| "incident";
|
||||
|
||||
export type SprintStatus = "planning" | "active" | "review" | "completed" | "cancelled";
|
||||
|
||||
export type AutomationTrigger =
|
||||
| "task_status_changed"
|
||||
| "task_created"
|
||||
| "task_blocked"
|
||||
| "task_reassigned"
|
||||
| "run_completed"
|
||||
| "run_failed"
|
||||
| "approval_created"
|
||||
| "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 type MessageChannel = "direct" | "department" | "company" | "project" | "incident";
|
||||
export type MessagePriority = "urgent" | "normal" | "low";
|
||||
|
||||
export type WorkflowStatus = "draft" | "active" | "paused" | "completed" | "failed";
|
||||
|
||||
export type WorkProductType = "preview_url" | "pull_request" | "branch" | "commit" | "artifact" | "document" | "runtime_service";
|
||||
export type WorkProductStatus = "active" | "ready_for_review" | "approved" | "changes_requested" | "merged" | "closed" | "failed" | "archived" | "draft";
|
||||
export type WorkProductReviewState = "none" | "needs_board_review" | "approved" | "changes_requested";
|
||||
|
||||
export type InboxItemType = "pending_approval" | "failed_run" | "budget_warning" | "blocked_task" | "review_needed" | "agent_message";
|
||||
|
||||
export type ThreadType = "task" | "approval" | "general" | "announcement";
|
||||
export type ThreadEventType =
|
||||
| "message"
|
||||
| "status_change"
|
||||
| "approval_request"
|
||||
| "approval_decision"
|
||||
| "file_attachment"
|
||||
| "system_note";
|
||||
export type ThreadActorType = "agent" | "user" | "system";
|
||||
export type ThreadParticipantRole = "owner" | "member" | "observer";
|
||||
export type ThreadWaitingFor = "user_review" | "user_approval" | "user_reply";
|
||||
export type ThreadNotifyOn = "all" | "mentions" | "none";
|
||||
@@ -0,0 +1,112 @@
|
||||
import type { RunStatus, SectionId, AutomationTrigger, AutomationAction } from "./enums";
|
||||
import type { CommentRecord } from "./records-core";
|
||||
import type { AgentMessageRecord } from "./records-extended";
|
||||
|
||||
export interface LogChunkEvent {
|
||||
type: "run-log";
|
||||
runId: string;
|
||||
stream: "stdout" | "stderr";
|
||||
chunk: string;
|
||||
}
|
||||
|
||||
export interface DomainChangedEvent {
|
||||
type: "domain-changed";
|
||||
}
|
||||
|
||||
export interface ShortcutEvent {
|
||||
type: "shortcut";
|
||||
action: "toggle-command-palette" | "toggle-console" | "refresh";
|
||||
}
|
||||
|
||||
export interface RunStatusEvent {
|
||||
type: "run-status";
|
||||
runId: string;
|
||||
status: RunStatus;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface HeartbeatStatusEvent {
|
||||
type: "heartbeat-status";
|
||||
agentId: string;
|
||||
enabled: boolean;
|
||||
nextWakeAt: string | null;
|
||||
}
|
||||
|
||||
export interface AgentMessageEvent {
|
||||
type: "agent-message";
|
||||
taskId: string;
|
||||
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 interface NotificationClickEvent {
|
||||
type: "notification-click";
|
||||
section: SectionId;
|
||||
entityId?: string;
|
||||
}
|
||||
|
||||
export interface TaskUpdatedEvent {
|
||||
type: "task-updated";
|
||||
taskId: string;
|
||||
action: "created" | "updated" | "deleted";
|
||||
}
|
||||
|
||||
export interface RunUpdatedEvent {
|
||||
type: "run-updated";
|
||||
runId: string;
|
||||
action: "created" | "status_changed" | "completed";
|
||||
}
|
||||
|
||||
export interface ApprovalUpdatedEvent {
|
||||
type: "approval-updated";
|
||||
approvalId: string;
|
||||
action: "created" | "decided" | "deleted";
|
||||
}
|
||||
|
||||
export interface AgentUpdatedEvent {
|
||||
type: "agent-updated";
|
||||
agentId: string;
|
||||
action: "updated" | "paused";
|
||||
}
|
||||
|
||||
export interface BudgetChangedEvent {
|
||||
type: "budget-changed";
|
||||
companyId: string;
|
||||
}
|
||||
|
||||
export interface ThreadWaitStateUpdatedEvent {
|
||||
type: "thread-wait-state-updated";
|
||||
threadId: string;
|
||||
companyId: string;
|
||||
waitStateId: string;
|
||||
action: "created" | "resolved";
|
||||
}
|
||||
|
||||
export type DesktopEvent =
|
||||
| LogChunkEvent
|
||||
| DomainChangedEvent
|
||||
| ShortcutEvent
|
||||
| RunStatusEvent
|
||||
| HeartbeatStatusEvent
|
||||
| AgentMessageEvent
|
||||
| AutomationFiredEvent
|
||||
| NewMessageEvent
|
||||
| NotificationClickEvent
|
||||
| TaskUpdatedEvent
|
||||
| RunUpdatedEvent
|
||||
| ApprovalUpdatedEvent
|
||||
| AgentUpdatedEvent
|
||||
| BudgetChangedEvent
|
||||
| ThreadWaitStateUpdatedEvent;
|
||||
@@ -0,0 +1,350 @@
|
||||
import type {
|
||||
ConnectorId,
|
||||
ConnectorStatus,
|
||||
CompanyStatus,
|
||||
ExecutionMode,
|
||||
WorkspaceState,
|
||||
DepartmentId,
|
||||
AgentStatus,
|
||||
GoalStatus,
|
||||
ProjectStatus,
|
||||
TaskStatus,
|
||||
ApprovalState,
|
||||
ApprovalType,
|
||||
RunStatus,
|
||||
SkillSourceType,
|
||||
TrustLevel,
|
||||
} from "./enums";
|
||||
|
||||
export interface CapabilityMatrix {
|
||||
sessionResume: boolean;
|
||||
gracefulCancel: boolean;
|
||||
modelDiscovery: boolean;
|
||||
structuredTranscript: boolean;
|
||||
costAttribution: boolean;
|
||||
}
|
||||
|
||||
export interface CompanyRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
status: CompanyStatus;
|
||||
autoApproveHires: boolean;
|
||||
reviewDeliverables: boolean;
|
||||
executionMode: ExecutionMode;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ConnectorRecord {
|
||||
id: ConnectorId;
|
||||
label: string;
|
||||
description: string;
|
||||
status: ConnectorStatus;
|
||||
command: string;
|
||||
version: string | null;
|
||||
authState: "unknown" | "ok" | "required" | "error";
|
||||
lastCheckedAt: string | null;
|
||||
lastError: string | null;
|
||||
model: string | null;
|
||||
envBindingText: string;
|
||||
notes: string;
|
||||
configurationDoc: string;
|
||||
capabilityMatrix: CapabilityMatrix;
|
||||
}
|
||||
|
||||
export interface WorkspaceRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
localPath: string;
|
||||
repoUrl: string;
|
||||
repoRef: string;
|
||||
projectId: string | null;
|
||||
state: WorkspaceState;
|
||||
isPrimary: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface AgentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
role: string;
|
||||
title: string;
|
||||
department: DepartmentId | null;
|
||||
status: AgentStatus;
|
||||
reportsTo: string | null;
|
||||
connectorId: ConnectorId;
|
||||
workspaceId: string | null;
|
||||
model: string | null;
|
||||
capabilities: string;
|
||||
budgetMonthlyUsd: number;
|
||||
spentMonthlyUsd: number;
|
||||
metadataJson: string;
|
||||
heartbeatEnabled: boolean;
|
||||
heartbeatIntervalSec: number;
|
||||
lastHeartbeatAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface GoalRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
title: string;
|
||||
description: string;
|
||||
parentId: string | null;
|
||||
ownerAgentId: string | null;
|
||||
status: GoalStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ProjectRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
goalId: string | null;
|
||||
name: string;
|
||||
description: string;
|
||||
leadAgentId: string | null;
|
||||
status: ProjectStatus;
|
||||
targetDate: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TaskRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string | null;
|
||||
goalId: string | null;
|
||||
parentId: string | null;
|
||||
title: string;
|
||||
description: string;
|
||||
assigneeAgentId: string | null;
|
||||
workspaceId: string | null;
|
||||
status: TaskStatus;
|
||||
priority: "critical" | "high" | "medium" | "low";
|
||||
activeRunId: string | null;
|
||||
sessionJson: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
costUsd: number;
|
||||
requiresUserReview: boolean;
|
||||
startedAt: string | null;
|
||||
completedAt: string | null;
|
||||
cancelledAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ApprovalRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
relatedTaskId: string | null;
|
||||
relatedAgentId: string | null;
|
||||
requestedByAgentId: string | null;
|
||||
type: ApprovalType;
|
||||
payloadSummary: string;
|
||||
impactSummary: string;
|
||||
payloadJson: string | null;
|
||||
decisionNote: string;
|
||||
state: ApprovalState;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RunRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
agentId: string;
|
||||
workspaceId: string | null;
|
||||
connectorId: ConnectorId;
|
||||
status: RunStatus;
|
||||
summary: string;
|
||||
errorMessage: string | null;
|
||||
exitCode: number | null;
|
||||
signal: string | null;
|
||||
model: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
costUsd: number | null;
|
||||
unattributedCost: boolean;
|
||||
startedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
logPath: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RunLogChunk {
|
||||
content: string;
|
||||
offset: number;
|
||||
nextOffset: number;
|
||||
totalBytes: number;
|
||||
eof: boolean;
|
||||
}
|
||||
|
||||
export interface CostRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
runId: string;
|
||||
taskId: string | null;
|
||||
agentId: string | null;
|
||||
connectorId: ConnectorId;
|
||||
amountUsd: number | null;
|
||||
unattributed: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetPolicyRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
scopeType: "company" | "agent" | "project";
|
||||
scopeId: string;
|
||||
metric: string;
|
||||
windowKind: string;
|
||||
amount: number; // INTEGER cents
|
||||
warnPercent: number;
|
||||
hardStopEnabled: boolean;
|
||||
notifyEnabled: boolean;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetIncidentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
policyId: string;
|
||||
scopeType: string;
|
||||
scopeId: string;
|
||||
metric: string;
|
||||
windowKind: string;
|
||||
windowStart: string;
|
||||
windowEnd: string;
|
||||
thresholdType: "warn_threshold" | "hard_stop";
|
||||
amountLimit: number;
|
||||
amountObserved: number;
|
||||
status: "open" | "resolved" | "auto_resolved_limit_increase" | "auto_closed";
|
||||
resolvedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BudgetStatusSummary {
|
||||
policies: Array<{
|
||||
policyId: string;
|
||||
scopeType: string;
|
||||
scopeId: string;
|
||||
amount: number;
|
||||
spent: number;
|
||||
warnPercent: number;
|
||||
hardStopEnabled: boolean;
|
||||
hasOpenIncident: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface TaskSessionRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
agentId: string;
|
||||
adapterType: string;
|
||||
sessionParamsJson: string | null;
|
||||
sessionDisplayId: string | null;
|
||||
lastRunId: string | null;
|
||||
lastError: string | null;
|
||||
runCount: number;
|
||||
totalInputTokens: number;
|
||||
totalOutputTokens: number;
|
||||
rotatedAt: string | null;
|
||||
rotationReason: string | null;
|
||||
handoffMarkdown: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ActivityRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
actor: string;
|
||||
action: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
detail: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface SecretRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
backend: "safe_storage" | "vault";
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CommentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
authorAgentId: string | null;
|
||||
authorName: string;
|
||||
body: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface FileInventoryEntry {
|
||||
path: string;
|
||||
kind: "skill" | "reference" | "script" | "asset" | "markdown" | "other";
|
||||
}
|
||||
|
||||
export interface SkillRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
key: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
markdown: string;
|
||||
sourceType: SkillSourceType;
|
||||
sourceLocator: string | null;
|
||||
sourceRef: string | null;
|
||||
trustLevel: TrustLevel;
|
||||
compatibility: string;
|
||||
fileInventory: FileInventoryEntry[];
|
||||
metadata: Record<string, unknown> | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface SkillImportResult {
|
||||
skillId: string;
|
||||
key: string;
|
||||
name: string;
|
||||
isUpdate: boolean;
|
||||
}
|
||||
|
||||
export interface SkillUpdateStatus {
|
||||
skillId: string;
|
||||
key: string;
|
||||
currentRef: string | null;
|
||||
latestRef: string | null;
|
||||
hasUpdate: boolean;
|
||||
}
|
||||
|
||||
export type MentionOutcome = "woken" | "queued" | "busy" | "not_found";
|
||||
|
||||
export interface MentionResult {
|
||||
agentId: string;
|
||||
agentName: string;
|
||||
outcome: MentionOutcome;
|
||||
}
|
||||
|
||||
export interface SendMessageResult {
|
||||
id: string;
|
||||
mentionResults: MentionResult[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
import type { AgentStatus, RunStatus, InboxItemType } from "./enums";
|
||||
import type {
|
||||
SocialPlatform,
|
||||
SocialAccountStatus,
|
||||
BrowserActionType,
|
||||
BrowserActionStatus,
|
||||
MeetingType,
|
||||
MeetingStatus,
|
||||
DocumentType,
|
||||
DocumentStatus,
|
||||
KnowledgeCategory,
|
||||
SprintStatus,
|
||||
AutomationTrigger,
|
||||
AutomationAction,
|
||||
AutomationStatus,
|
||||
MessageChannel,
|
||||
MessagePriority,
|
||||
WorkflowStatus,
|
||||
WorkProductType,
|
||||
WorkProductStatus,
|
||||
WorkProductReviewState,
|
||||
ThreadType,
|
||||
ThreadActorType,
|
||||
ThreadEventType,
|
||||
ThreadParticipantRole,
|
||||
ThreadWaitingFor,
|
||||
ThreadNotifyOn,
|
||||
DepartmentId,
|
||||
} from "./enums";
|
||||
|
||||
export interface SocialAccountRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
platform: SocialPlatform;
|
||||
accountName: string;
|
||||
displayName: string;
|
||||
profileUrl: string;
|
||||
credentialSecretId: string | null;
|
||||
status: SocialAccountStatus;
|
||||
requireApproval: boolean;
|
||||
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;
|
||||
payloadJson: string;
|
||||
status: BrowserActionStatus;
|
||||
resultSummary: string;
|
||||
screenshotPath: string | null;
|
||||
approvalId: string | null;
|
||||
errorMessage: string | null;
|
||||
startedAt: string | null;
|
||||
finishedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
latestRevisionId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface DocumentRevisionRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
documentId: string;
|
||||
revisionNumber: number;
|
||||
body: string;
|
||||
changeSummary: string | null;
|
||||
createdByAgentId: string | null;
|
||||
createdByUserId: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ApprovalCommentRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
approvalId: string;
|
||||
authorAgentId: string | null;
|
||||
authorUserId: string | null;
|
||||
body: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface WorkProductRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string | null;
|
||||
taskId: string;
|
||||
type: WorkProductType;
|
||||
provider: string;
|
||||
externalId: string | null;
|
||||
title: string;
|
||||
url: string | null;
|
||||
status: WorkProductStatus;
|
||||
reviewState: WorkProductReviewState;
|
||||
isPrimary: boolean;
|
||||
summary: string | null;
|
||||
metadataJson: string | null;
|
||||
createdByRunId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TaskDocumentLink {
|
||||
id: string;
|
||||
companyId: string;
|
||||
taskId: string;
|
||||
documentId: string;
|
||||
key: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface KnowledgeEntryRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
category: KnowledgeCategory;
|
||||
topic: string;
|
||||
content: string;
|
||||
authorAgentId: string | null;
|
||||
importance: "critical" | "high" | "medium" | "low";
|
||||
tagsJson: string;
|
||||
referencedEntityType:
|
||||
| "agents"
|
||||
| "goals"
|
||||
| "projects"
|
||||
| "tasks"
|
||||
| "approvals"
|
||||
| "runs"
|
||||
| "secrets"
|
||||
| "meetings"
|
||||
| "documents"
|
||||
| "knowledge_base"
|
||||
| "sprints"
|
||||
| "automation_rules"
|
||||
| "workflow_pipelines"
|
||||
| null;
|
||||
referencedEntityId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface AutomationRuleRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
trigger: AutomationTrigger;
|
||||
conditionsJson: string;
|
||||
action: AutomationAction;
|
||||
actionConfigJson: string;
|
||||
sourceDepartment: DepartmentId | null;
|
||||
targetDepartment: DepartmentId | null;
|
||||
priority: number;
|
||||
status: AutomationStatus;
|
||||
executionCount: number;
|
||||
lastExecutedAt: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface AgentMessageRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
fromAgentId: string;
|
||||
toAgentId: string | null;
|
||||
senderKind: "agent" | "human" | "system";
|
||||
channel: MessageChannel;
|
||||
channelTargetId: string | null;
|
||||
subject: string;
|
||||
body: string;
|
||||
priority: MessagePriority;
|
||||
readAt: string | null;
|
||||
parentMessageId: string | null;
|
||||
attachmentsJson: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface WorkflowPipelineRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
stepsJson: string;
|
||||
triggerType: AutomationTrigger;
|
||||
triggerConfigJson: string;
|
||||
status: WorkflowStatus;
|
||||
currentStepIndex: number;
|
||||
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;
|
||||
requiresApproval: boolean;
|
||||
timeoutSec: number;
|
||||
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
||||
}
|
||||
|
||||
export interface ConversationThreadRecord {
|
||||
id: string;
|
||||
companyId: string;
|
||||
title: string;
|
||||
type: ThreadType;
|
||||
relatedEntityType: string | null;
|
||||
relatedEntityId: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface ConversationEventRecord {
|
||||
id: string;
|
||||
threadId: string;
|
||||
actorId: string;
|
||||
actorType: ThreadActorType;
|
||||
eventType: ThreadEventType;
|
||||
body: string;
|
||||
metadataJson: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ConversationParticipantRecord {
|
||||
threadId: string;
|
||||
participantId: string;
|
||||
participantType: ThreadActorType;
|
||||
role: ThreadParticipantRole;
|
||||
joinedAt: string;
|
||||
}
|
||||
|
||||
export interface ThreadSubscriptionRecord {
|
||||
threadId: string;
|
||||
subscriberId: string;
|
||||
subscriberType: ThreadActorType;
|
||||
notifyOn: ThreadNotifyOn;
|
||||
subscribedAt: string;
|
||||
}
|
||||
|
||||
export interface ThreadWaitStateRecord {
|
||||
id: string;
|
||||
threadId: string;
|
||||
companyId: string;
|
||||
waitingFor: ThreadWaitingFor;
|
||||
relatedApprovalId: string | null;
|
||||
reason: string;
|
||||
createdAt: string;
|
||||
resolvedAt: string | null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface AgentMetrics {
|
||||
agentId: string;
|
||||
agentName: string;
|
||||
tasksCompleted: number;
|
||||
tasksAssigned: number;
|
||||
tasksFailed: number;
|
||||
successRate: number;
|
||||
avgRunDurationSec: number;
|
||||
totalCostUsd: number;
|
||||
runsTotal: number;
|
||||
runsSucceeded: number;
|
||||
runsFailed: number;
|
||||
reviewCycles: number;
|
||||
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[];
|
||||
}
|
||||
|
||||
export interface OnboardingBootstrapResult {
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
workspaceId: string | null;
|
||||
leadAgentId: string | null;
|
||||
projectId: string | null;
|
||||
taskId: string | null;
|
||||
runId: string | null;
|
||||
}
|
||||
|
||||
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,0 +1,2 @@
|
||||
export * from "./records-core";
|
||||
export * from "./records-extended";
|
||||
@@ -0,0 +1,58 @@
|
||||
import type {
|
||||
CompanyRecord,
|
||||
ConnectorRecord,
|
||||
WorkspaceRecord,
|
||||
AgentRecord,
|
||||
GoalRecord,
|
||||
ProjectRecord,
|
||||
TaskRecord,
|
||||
ApprovalRecord,
|
||||
RunRecord,
|
||||
CostRecord,
|
||||
ActivityRecord,
|
||||
SecretRecord,
|
||||
CommentRecord,
|
||||
} from "./records-core";
|
||||
import type {
|
||||
SocialAccountRecord,
|
||||
MeetingRecord,
|
||||
DocumentRecord,
|
||||
KnowledgeEntryRecord,
|
||||
SprintRecord,
|
||||
AutomationRuleRecord,
|
||||
AgentMessageRecord,
|
||||
WorkflowPipelineRecord,
|
||||
} from "./records-extended";
|
||||
|
||||
export interface ProfileSnapshot {
|
||||
currentCompanyId: string | null;
|
||||
profilePath: string;
|
||||
updatesEnabled: boolean;
|
||||
theme: "system" | "light" | "dark";
|
||||
locale: "en" | "zh";
|
||||
backend: {
|
||||
secretBackend: string;
|
||||
};
|
||||
companies: CompanyRecord[];
|
||||
connectors: ConnectorRecord[];
|
||||
workspaces: WorkspaceRecord[];
|
||||
agents: AgentRecord[];
|
||||
goals: GoalRecord[];
|
||||
projects: ProjectRecord[];
|
||||
tasks: TaskRecord[];
|
||||
approvals: ApprovalRecord[];
|
||||
runs: RunRecord[];
|
||||
costs: CostRecord[];
|
||||
activity: ActivityRecord[];
|
||||
secrets: SecretRecord[];
|
||||
comments: CommentRecord[];
|
||||
socialAccounts: SocialAccountRecord[];
|
||||
meetings: MeetingRecord[];
|
||||
documents: DocumentRecord[];
|
||||
knowledgeBase: KnowledgeEntryRecord[];
|
||||
sprints: SprintRecord[];
|
||||
automationRules: AutomationRuleRecord[];
|
||||
agentMessages: AgentMessageRecord[];
|
||||
workflows: WorkflowPipelineRecord[];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user