This commit is contained in:
ZacharyZhang-NY committed 2026-03-18 16:13:17 -04:00
1 parent 0cd65521b8
commit 48daca9ba0
18 files changed
+192 -91

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "agent-company", "name": "agent-company",
"version": "0.4.29", "version": "0.4.36",
"private": true, "private": true,
"type": "module", "type": "module",
"description": "Cross-platform Electron desktop control plane for local-first AI agent companies.", "description": "Cross-platform Electron desktop control plane for local-first AI agent companies.",
@@ -41,8 +41,8 @@ function parseModelProvider(model: string | null): string | null {
return trimmed.slice(0, trimmed.indexOf("/")).trim() || null; return trimmed.slice(0, trimmed.indexOf("/")).trim() || null;
} }
function claudeSkillsHome(): string { function openCodeSkillsHome(): string {
return path.join(os.homedir(), ".claude", "skills"); return path.join(os.homedir(), ".opencode", "skills");
} }
async function resolveAgentCompanySkillsDir(): Promise<string | null> { async function resolveAgentCompanySkillsDir(): Promise<string | null> {
@@ -57,7 +57,7 @@ async function ensureOpenCodeSkillsInjected(onLog: AdapterExecutionContext["onLo
const skillsDir = await resolveAgentCompanySkillsDir(); const skillsDir = await resolveAgentCompanySkillsDir();
if (!skillsDir) return; if (!skillsDir) return;
const skillsHome = claudeSkillsHome(); const skillsHome = openCodeSkillsHome();
await fs.mkdir(skillsHome, { recursive: true }); await fs.mkdir(skillsHome, { recursive: true });
const entries = await fs.readdir(skillsDir, { withFileTypes: true }); const entries = await fs.readdir(skillsDir, { withFileTypes: true });
for (const entry of entries) { for (const entry of entries) {
+8 -8
View File
@@ -781,16 +781,18 @@ export function createAutomationService({
const isSuccess = event.status === "succeeded"; const isSuccess = event.status === "succeeded";
const isFailed = event.status === "failed" || event.status === "timed_out"; const isFailed = event.status === "failed" || event.status === "timed_out";
if (isSuccess && task.status === "in_progress") { let effectiveStatus = task.status;
if (isSuccess && effectiveStatus === "in_progress") {
db.advanceTaskStatus(task.id, "in_review", "Run completed successfully. Awaiting review."); db.advanceTaskStatus(task.id, "in_review", "Run completed successfully. Awaiting review.");
handleTaskStatusChange(task.id, run.companyId, "in_progress", "in_review"); handleTaskStatusChange(task.id, run.companyId, "in_progress", "in_review");
effectiveStatus = "in_review";
publishDomainChanged(); publishDomainChanged();
} }
if (isSuccess && task.title.startsWith("[Heartbeat]") && task.status !== "done") { if (isSuccess && task.title.startsWith("[Heartbeat]") && effectiveStatus !== "done") {
const previousStatus = task.status;
db.advanceTaskStatus(task.id, "done", "Heartbeat check completed."); db.advanceTaskStatus(task.id, "done", "Heartbeat check completed.");
handleTaskStatusChange(task.id, run.companyId, previousStatus, "done"); handleTaskStatusChange(task.id, run.companyId, effectiveStatus, "done");
} }
const automationContext: AutomationEventContext = { const automationContext: AutomationEventContext = {
@@ -811,8 +813,7 @@ export function createAutomationService({
dispatchAutomation("run_completed", automationContext); dispatchAutomation("run_completed", automationContext);
if (task.parentId) { if (task.parentId) {
try { try {
const freshSnapshot = db.listSnapshot(); const siblings = db.listChildTasks(task.parentId, run.companyId);
const siblings = freshSnapshot.tasks.filter((entry) => entry.parentId === task!.parentId && entry.companyId === run.companyId);
const allSiblingsDoneOrReview = siblings.every((entry) => entry.status === "done" || entry.status === "in_review"); const allSiblingsDoneOrReview = siblings.every((entry) => entry.status === "done" || entry.status === "in_review");
if (allSiblingsDoneOrReview) { if (allSiblingsDoneOrReview) {
const parent = db.getTask(task.parentId); const parent = db.getTask(task.parentId);
@@ -1017,8 +1018,7 @@ export function createAutomationService({
if (newStatus === "done" && task.parentId) { if (newStatus === "done" && task.parentId) {
try { try {
const snapshot = db.listSnapshot(); const siblings = db.listChildTasks(task.parentId, companyId);
const siblings = snapshot.tasks.filter((entry) => entry.parentId === task!.parentId && entry.companyId === companyId);
const allDone = siblings.every((entry) => entry.id === taskId ? true : entry.status === "done"); const allDone = siblings.every((entry) => entry.id === taskId ? true : entry.status === "done");
if (allDone) { if (allDone) {
const parent = db.getTask(task.parentId); const parent = db.getTask(task.parentId);
+12 -1
View File
@@ -76,7 +76,18 @@ export async function openConnectorAuthTerminal(connectorId: ConnectorId, comman
} }
if (process.platform === "win32") { if (process.platform === "win32") {
const child = spawn("cmd.exe", ["/c", "start", "", "cmd.exe", "/k", script], { const spec = connectorAuthSpec(connectorId, command);
const winScript = [
`@echo off`,
`echo ${spec.intro}`,
`echo.`,
`cd /d "${targetCwd}"`,
spec.shellCommand,
`echo.`,
`echo You can close this terminal after the login flow completes.`,
`pause`,
].join(" & ");
const child = spawn("cmd.exe", ["/c", "start", "", "cmd.exe", "/k", winScript], {
detached: true, detached: true,
stdio: "ignore", stdio: "ignore",
shell: false, shell: false,
+1 -1
View File
@@ -37,7 +37,7 @@ export function createConnectorHealthService({
return new Promise((resolve) => { return new Promise((resolve) => {
let resolved = false; let resolved = false;
const child = spawn(command, ["--version"], { const child = spawn(command, ["--version"], {
env: process.env, env: buildSanitizedRuntimeEnv(process.env, {}),
shell: false, shell: false,
stdio: ["ignore", "pipe", "pipe"], stdio: ["ignore", "pipe", "pipe"],
}); });
+1 -1
View File
@@ -125,7 +125,7 @@ const CONNECTORS: ConnectorDefinition[] = [
gracefulCancel: true, gracefulCancel: true,
modelDiscovery: true, modelDiscovery: true,
structuredTranscript: true, structuredTranscript: true,
costAttribution: false, costAttribution: true,
}, },
configurationDoc: opencodeDoc, configurationDoc: opencodeDoc,
module: { module: {
+63
View File
@@ -1986,6 +1986,69 @@ export class AppDatabase {
}); });
} }
getCompanyStatus(companyId: string): string | null {
const row = this.db.prepare("select status from companies where id = ?").get(companyId) as { status: string } | undefined;
return row?.status ?? null;
}
getCompanyBasic(companyId: string): { name: string; description: string } | null {
const row = this.db.prepare("select name, description from companies where id = ?").get(companyId) as { name: string; description: string } | undefined;
return row ?? null;
}
listActiveCompanyIds(): Array<{ id: string; name: string }> {
return this.readAll<{ id: string; name: string }>(
"select id, name from companies where status = 'active'",
);
}
countActiveTasksForCompany(companyId: string): number {
const row = this.db.prepare(
"select count(*) as cnt from tasks where company_id = ? and status not in ('done', 'cancelled') and title not like '[Heartbeat]%'",
).get(companyId) as { cnt: number };
return row.cnt;
}
countActiveGoalsForCompany(companyId: string): number {
const row = this.db.prepare(
"select count(*) as cnt from goals where company_id = ? and status in ('active', 'planned')",
).get(companyId) as { cnt: number };
return row.cnt;
}
getCeoForCompany(companyId: string): { id: string; name: string; lastHeartbeatAt: string | null } | null {
const row = this.db.prepare(
"select id, name, last_heartbeat_at as lastHeartbeatAt from agents where company_id = ? and reports_to is null and status != 'terminated' limit 1",
).get(companyId) as { id: string; name: string; lastHeartbeatAt: string | null } | undefined;
return row ?? null;
}
listActiveAgentsForCompany(companyId: string): Array<{ id: string; name: string; department: string | null; lastHeartbeatAt: string | null }> {
return this.readAll<{ id: string; name: string; department: string | null; lastHeartbeatAt: string | null }>(
"select id, name, department, last_heartbeat_at as lastHeartbeatAt from agents where company_id = ? and status not in ('terminated', 'paused', 'pending_approval')",
companyId,
);
}
hasAgentAssignedTasks(agentId: string, companyId: string): boolean {
const row = this.db.prepare(
"select 1 from tasks where assignee_agent_id = ? and company_id = ? and status in ('todo', 'in_progress', 'blocked') limit 1",
).get(agentId, companyId);
return !!row;
}
listChildTasks(parentId: string, companyId: string): Array<{ id: string; status: string; assigneeAgentId: string | null }> {
return this.readAll<{ id: string; status: string; assigneeAgentId: string | null }>(
`select id, status, assignee_agent_id as assigneeAgentId from tasks where parent_id = ? and company_id = ?`,
parentId, companyId,
);
}
updateAgentStatus(agentId: string, status: string) {
const ts = new Date().toISOString();
this.db.prepare("update agents set status = ?, updated_at = ? where id = ?").run(status, ts, agentId);
}
private getSetting(key: string): string | null { private getSetting(key: string): string | null {
const row = this.db.prepare("select value from settings where key = ?").get(key) as { value: string } | undefined; const row = this.db.prepare("select value from settings where key = ?").get(key) as { value: string } | undefined;
return row?.value ?? null; return row?.value ?? null;
+10 -2
View File
@@ -24,10 +24,10 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
}, },
{ {
name: "Escalate completed work to manager", name: "Escalate completed work to manager",
description: "When a run completes successfully, escalate to the assignee's manager so they review the work.", description: "When a run completes successfully, escalate to the assignee's manager so they can review the completed work.",
trigger: "run_completed", trigger: "run_completed",
action: "escalate_to_manager", action: "escalate_to_manager",
actionConfigJson: JSON.stringify({ body: "A task run has completed successfully. Please review the work and approve or send back for changes." }), actionConfigJson: JSON.stringify({ body: "A task run has completed successfully. The task has moved to review status. Please review and either approve (mark as done) or send back with feedback." }),
priority: 80, priority: 80,
}, },
{ {
@@ -126,6 +126,14 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
actionConfigJson: JSON.stringify({}), actionConfigJson: JSON.stringify({}),
priority: 78, priority: 78,
}, },
{
name: "Wake approvers on new approval",
description: "When a new approval request is created and not auto-approved, escalate to the requesting agent's manager for review.",
trigger: "approval_created",
action: "escalate_to_manager",
actionConfigJson: JSON.stringify({ body: "A new approval request needs your review. Please check the Approvals section." }),
priority: 88,
},
]; ];
export function seedDefaultAutomationRules( export function seedDefaultAutomationRules(
+6
View File
@@ -75,6 +75,12 @@ export function registerCoreOperationHandlers({
publishDomainChanged(); publishDomainChanged();
return ok(id); return ok(id);
} }
// Approval was NOT auto-approved — wake decision-makers to review it
dispatchAutomation("approval_created", {
companyId: parsed.companyId,
agentId: parsed.requestedByAgentId ?? undefined,
taskId: parsed.relatedTaskId ?? undefined,
});
publishDomainChanged(); publishDomainChanged();
return ok(id); return ok(id);
}); });
+13 -3
View File
@@ -286,11 +286,15 @@ export function registerCoreWorkGraphHandlers({
} }
const isNew = !parsed.id; const isNew = !parsed.id;
let previousStatus: string | null = null; let previousStatus: string | null = null;
let previousAssigneeAgentId: string | null = null;
if (!isNew) { if (!isNew) {
try { try {
previousStatus = db.getTask(parsed.id!).status; const existingTask = db.getTask(parsed.id!);
previousStatus = existingTask.status;
previousAssigneeAgentId = existingTask.assigneeAgentId;
} catch { } catch {
previousStatus = null; previousStatus = null;
previousAssigneeAgentId = null;
} }
} }
let id: string; let id: string;
@@ -309,8 +313,14 @@ export function registerCoreWorkGraphHandlers({
}); });
if (isNew) { if (isNew) {
handleTaskCreated(id, parsed.companyId); handleTaskCreated(id, parsed.companyId);
} else if (previousStatus && previousStatus !== parsed.status) { } else {
handleTaskStatusChange(id, parsed.companyId, previousStatus, parsed.status); if (previousStatus && previousStatus !== parsed.status) {
handleTaskStatusChange(id, parsed.companyId, previousStatus, parsed.status);
}
// Wake new assignee when task is reassigned (matches api-server.ts behavior)
if (parsed.assigneeAgentId && parsed.assigneeAgentId !== previousAssigneeAgentId) {
wakeAgentIfPossible(parsed.assigneeAgentId, parsed.companyId, "assignment");
}
} }
publishDomainChanged(); publishDomainChanged();
return ok(id); return ok(id);
+26 -28
View File
@@ -117,6 +117,7 @@ export function createOrchestrationService({
if (!(agent.budgetMonthlyUsd > 0) || agent.spentMonthlyUsd < agent.budgetMonthlyUsd) { if (!(agent.budgetMonthlyUsd > 0) || agent.spentMonthlyUsd < agent.budgetMonthlyUsd) {
return false; return false;
} }
db.updateAgentStatus(agent.id, "paused");
db.addActivity({ db.addActivity({
companyId: agent.companyId, companyId: agent.companyId,
actor: "system", actor: "system",
@@ -294,9 +295,8 @@ export function createOrchestrationService({
function startAgentHeartbeatRun(agentId: string, companyId: string, trigger: string): string | null { function startAgentHeartbeatRun(agentId: string, companyId: string, trigger: string): string | null {
if (!hasWorkerReady()) return null; if (!hasWorkerReady()) return null;
const snapshot = db.listSnapshot(); const companyStatus = db.getCompanyStatus(companyId);
const company = snapshot.companies.find((entry) => entry.id === companyId) ?? null; if (companyStatus !== "active") {
if (!company || company.status !== "active") {
logger.info(`[heartbeat] Skipping ${agentId} because company ${companyId} is not active.`); logger.info(`[heartbeat] Skipping ${agentId} because company ${companyId} is not active.`);
return null; return null;
} }
@@ -335,10 +335,10 @@ export function createOrchestrationService({
} }
const isCeo = !agent.reportsTo; const isCeo = !agent.reportsTo;
const isManager = snapshot.agents.some((entry) => entry.reportsTo === agent.id && entry.companyId === companyId); const isManager = db.getDirectReports(agent.id, companyId).length > 0;
const activeGoals = snapshot.goals.filter((goal) => goal.companyId === companyId && (goal.status === "active" || goal.status === "planned")); const goalCount = db.countActiveGoalsForCompany(companyId);
const companyTasks = snapshot.tasks.filter((entry) => entry.companyId === companyId && entry.status !== "done" && entry.status !== "cancelled"); const taskCount = db.countActiveTasksForCompany(companyId);
const companyNeedsBootstrap = activeGoals.length > 0 && companyTasks.length < activeGoals.length; const companyNeedsBootstrap = goalCount > 0 && taskCount < goalCount;
if (isTimer && !isCeo && !isManager && !companyNeedsBootstrap) { if (isTimer && !isCeo && !isManager && !companyNeedsBootstrap) {
logger.info(`[heartbeat] Skipping ${agent.name} — no actionable tasks and trigger is timer.`); logger.info(`[heartbeat] Skipping ${agent.name} — no actionable tasks and trigger is timer.`);
@@ -388,6 +388,7 @@ export function createOrchestrationService({
connectorId: connector.id, connectorId: connector.id,
}); });
const companyBasic = db.getCompanyBasic(companyId);
dispatchRunToWorker({ dispatchRunToWorker({
runId: run.id, runId: run.id,
companyId, companyId,
@@ -396,9 +397,9 @@ export function createOrchestrationService({
connector, connector,
workspace, workspace,
workspaceMode: workspaceResolution.lockMode, workspaceMode: workspaceResolution.lockMode,
companyName: company.name, companyName: companyBasic?.name ?? "Unknown",
companyDescription: company.description ?? "", companyDescription: companyBasic?.description ?? "",
snapshot, snapshot: db.listSnapshot(),
trigger, trigger,
}); });
@@ -446,9 +447,8 @@ export function createOrchestrationService({
return fail("WORKER_UNAVAILABLE", "Orchestration worker is not ready."); return fail("WORKER_UNAVAILABLE", "Orchestration worker is not ready.");
} }
const task = db.getTask(taskId); const task = db.getTask(taskId);
const snapshot = db.listSnapshot(); const companyStatus = db.getCompanyStatus(task.companyId);
const company = snapshot.companies.find((entry) => entry.id === task.companyId) ?? null; if (companyStatus !== "active") {
if (!company || company.status !== "active") {
return fail("COMPANY_NOT_ACTIVE", "Runs can only start while the company is active."); return fail("COMPANY_NOT_ACTIVE", "Runs can only start while the company is active.");
} }
if (task.activeRunId || hasActiveRun({ taskId: task.id, companyId: task.companyId })) { if (task.activeRunId || hasActiveRun({ taskId: task.id, companyId: task.companyId })) {
@@ -498,6 +498,7 @@ export function createOrchestrationService({
connectorId: connector.id, connectorId: connector.id,
}); });
const companyBasic = db.getCompanyBasic(task.companyId);
dispatchRunToWorker({ dispatchRunToWorker({
runId: run.id, runId: run.id,
companyId: task.companyId, companyId: task.companyId,
@@ -506,9 +507,9 @@ export function createOrchestrationService({
connector, connector,
workspace, workspace,
workspaceMode: workspaceResolution.lockMode, workspaceMode: workspaceResolution.lockMode,
companyName: company.name, companyName: companyBasic?.name ?? "Unknown",
companyDescription: company.description, companyDescription: companyBasic?.description ?? "",
snapshot, snapshot: db.listSnapshot(),
trigger, trigger,
}); });
db.addActivity({ db.addActivity({
@@ -579,10 +580,10 @@ export function createOrchestrationService({
heartbeatTimer = setInterval(() => { heartbeatTimer = setInterval(() => {
try { try {
if (!hasWorkerReady()) return; if (!hasWorkerReady()) return;
const snapshot = db.listSnapshot(); const activeCompanies = db.listActiveCompanyIds();
const now = Date.now(); const now = Date.now();
for (const company of snapshot.companies.filter((entry) => entry.status === "active")) { for (const company of activeCompanies) {
try { try {
const eligibleAgents = db.listHeartbeatEligibleAgents(company.id); const eligibleAgents = db.listHeartbeatEligibleAgents(company.id);
for (const agent of eligibleAgents) { for (const agent of eligibleAgents) {
@@ -596,14 +597,14 @@ export function createOrchestrationService({
startAgentHeartbeatRun(agent.id, company.id, "timer"); startAgentHeartbeatRun(agent.id, company.id, "timer");
} }
const companyGoals = snapshot.goals.filter((goal) => goal.companyId === company.id && (goal.status === "active" || goal.status === "planned")); const goalCount = db.countActiveGoalsForCompany(company.id);
const companyActiveTasks = snapshot.tasks.filter((task) => task.companyId === company.id && !["done", "cancelled"].includes(task.status) && !task.title.startsWith("[Heartbeat]")); const taskCount = db.countActiveTasksForCompany(company.id);
if (companyGoals.length > 0 && companyActiveTasks.length === 0) { if (goalCount > 0 && taskCount === 0) {
const ceo = snapshot.agents.find((agent) => agent.companyId === company.id && !agent.reportsTo && agent.status !== "terminated"); const ceo = db.getCeoForCompany(company.id);
const ceoLastWake = ceo?.lastHeartbeatAt ? new Date(ceo.lastHeartbeatAt).getTime() : 0; const ceoLastWake = ceo?.lastHeartbeatAt ? new Date(ceo.lastHeartbeatAt).getTime() : 0;
const bootstrapCooldown = 120_000; const bootstrapCooldown = 120_000;
if (ceo && !hasActiveRun({ agentId: ceo.id, companyId: company.id }) && (now - ceoLastWake > bootstrapCooldown)) { if (ceo && !hasActiveRun({ agentId: ceo.id, companyId: company.id }) && (now - ceoLastWake > bootstrapCooldown)) {
logger.info(`[heartbeat] Company ${company.name} has ${companyGoals.length} goals but no tasks — bootstrapping CEO ${ceo.name}`); logger.info(`[heartbeat] Company ${company.name} has ${goalCount} goals but no tasks — bootstrapping CEO ${ceo.name}`);
startAgentHeartbeatRun(ceo.id, company.id, "bootstrap"); startAgentHeartbeatRun(ceo.id, company.id, "bootstrap");
} }
} }
@@ -615,12 +616,9 @@ export function createOrchestrationService({
scheduleLastFiredMap.set(scheduleKey, now); scheduleLastFiredMap.set(scheduleKey, now);
} }
const companyAgents = snapshot.agents.filter((agent) => agent.companyId === company.id && agent.status !== "terminated" && agent.status !== "paused" && agent.status !== "pending_approval"); const companyAgents = db.listActiveAgentsForCompany(company.id);
for (const agent of companyAgents) { for (const agent of companyAgents) {
const hasAssigned = snapshot.tasks.some( if (!db.hasAgentAssignedTasks(agent.id, company.id)) {
(task) => task.assigneeAgentId === agent.id && task.companyId === company.id && ["todo", "in_progress", "blocked"].includes(task.status),
);
if (!hasAssigned) {
const lastActive = agent.lastHeartbeatAt ? new Date(agent.lastHeartbeatAt).getTime() : 0; const lastActive = agent.lastHeartbeatAt ? new Date(agent.lastHeartbeatAt).getTime() : 0;
const idleThreshold = 20 * 60 * 1000; const idleThreshold = 20 * 60 * 1000;
if (now - lastActive > idleThreshold) { if (now - lastActive > idleThreshold) {
+12
View File
@@ -321,6 +321,18 @@ export function createWorkerService({
} }
processRunCompletion(run, event as z.infer<typeof workerMessageSchema> & { type: "run-finished" }); processRunCompletion(run, event as z.infer<typeof workerMessageSchema> & { type: "run-finished" });
// Self-wake: pick up next assigned task immediately instead of waiting for heartbeat timer
if (pendingWakes.length === 0) {
try {
const actionableTasks = db.listAgentTasks(run.agentId, run.companyId, ["todo", "in_progress"]);
if (actionableTasks.length > 0) {
wakeAgentIfPossible(run.agentId, run.companyId, "task_continuation");
}
} catch {
// Best-effort self-wake; agent will pick up work on the next heartbeat cycle.
}
}
}); });
} }
+6 -22
View File
@@ -314,22 +314,6 @@ export function App() {
const companyId = snapshot.currentCompanyId; const companyId = snapshot.currentCompanyId;
let cancelled = false; let cancelled = false;
if (section === "inbox") {
setInboxItems([]);
}
if (section === "performance") {
setCompanyMetrics(null);
}
if (section === "standup") {
setStandupReport(null);
}
if (section === "social") {
setSocialAccounts([]);
}
if (section === "inbox") { if (section === "inbox") {
void window.agentCompany.getInbox(companyId).then((result) => { void window.agentCompany.getInbox(companyId).then((result) => {
if (!cancelled && result.ok) setInboxItems(result.data); if (!cancelled && result.ok) setInboxItems(result.data);
@@ -1266,7 +1250,7 @@ export function App() {
<SprintManager companyId={currentCompany.id} sprints={companySprints} onRefresh={refresh} /> <SprintManager companyId={currentCompany.id} sprints={companySprints} onRefresh={refresh} />
) : null} ) : null}
{section === "workspaces" ? ( {section === "workspaces" && currentCompany ? (
<EntityWorkspace <EntityWorkspace
title="Workspaces" title="Workspaces"
eyebrow={undefined} eyebrow={undefined}
@@ -1304,7 +1288,7 @@ export function App() {
/> />
) : null} ) : null}
{section === "settings" ? ( {section === "settings" && currentCompany ? (
<div className="space-y-10"> <div className="space-y-10">
<Panel title="Profile and release"> <Panel title="Profile and release">
<SettingsPane snapshot={snapshot} secrets={companySecrets} companyId={currentCompany!.id} onSaved={refresh} /> <SettingsPane snapshot={snapshot} secrets={companySecrets} companyId={currentCompany!.id} onSaved={refresh} />
@@ -1340,10 +1324,10 @@ export function App() {
compact compact
value={selectedRun?.id ?? ""} value={selectedRun?.id ?? ""}
onChange={setSelectedRunId} onChange={setSelectedRunId}
options={(runs.length > 0 ? runs : [{ id: "", summary: "No runs" } as RunRecord]).map((run) => ({ options={runs.length > 0
value: run.id, ? runs.map((run) => ({ value: run.id, label: run.summary || `Run ${run.id.slice(0, 8)}` }))
label: run.summary || `Run ${run.id.slice(0, 8)}`, : [{ value: "", label: "No runs" }]
}))} }
/> />
<button <button
type="button" type="button"
+2
View File
@@ -37,8 +37,10 @@ const triggerConfig: Record<AutomationTrigger, { label: string; description: str
task_status_changed: { label: "Task Status Changed", description: "When a task transitions to a new status", icon: ArrowsClockwise }, task_status_changed: { label: "Task Status Changed", description: "When a task transitions to a new status", icon: ArrowsClockwise },
task_created: { label: "Task Created", description: "When a new task is added to the system", icon: Plus }, task_created: { label: "Task Created", description: "When a new task is added to the system", icon: Plus },
task_blocked: { label: "Task Blocked", description: "When a task becomes blocked by a dependency", icon: Pause }, task_blocked: { label: "Task Blocked", description: "When a task becomes blocked by a dependency", icon: Pause },
task_reassigned: { label: "Task Reassigned", description: "When a task is reassigned to a different agent", icon: ArrowsClockwise },
run_completed: { label: "Run Completed", description: "When an agent run finishes successfully", icon: Play }, run_completed: { label: "Run Completed", description: "When an agent run finishes successfully", icon: Play },
run_failed: { label: "Run Failed", description: "When an agent run encounters an error", icon: Trash }, run_failed: { label: "Run Failed", description: "When an agent run encounters an error", icon: Trash },
approval_created: { label: "Approval Created", description: "When a new approval request needs review", icon: Eye },
approval_resolved: { label: "Approval Resolved", description: "When a pending approval is decided", icon: Eye }, approval_resolved: { label: "Approval Resolved", description: "When a pending approval is decided", icon: Eye },
budget_threshold: { label: "Budget Threshold", description: "When spending exceeds a configured limit", icon: Funnel }, budget_threshold: { label: "Budget Threshold", description: "When spending exceeds a configured limit", icon: Funnel },
agent_idle: { label: "Agent Idle", description: "When an agent has no tasks and becomes idle", icon: Robot }, agent_idle: { label: "Agent Idle", description: "When an agent has no tasks and becomes idle", icon: Robot },
+12 -8
View File
@@ -501,10 +501,11 @@ export function DocumentCenter({
title="Delete document" title="Delete document"
message="This removes the document from the company knowledge surface." message="This removes the document from the company knowledge surface."
onCancel={() => setDeleteId(null)} onCancel={() => setDeleteId(null)}
onConfirm={() => { onConfirm={async () => {
if (!deleteId) return; if (!deleteId) return;
void window.agentCompany.deleteDocument({ id: deleteId, companyId }).then(() => onRefresh()); const result = await window.agentCompany.deleteDocument({ id: deleteId, companyId });
setDeleteId(null); setDeleteId(null);
if (result.ok) await onRefresh();
}} }}
/> />
</div> </div>
@@ -568,10 +569,11 @@ export function KnowledgeBaseManager({
title="Delete knowledge entry" title="Delete knowledge entry"
message="This removes the entry from the shared company knowledge base." message="This removes the entry from the shared company knowledge base."
onCancel={() => setDeleteId(null)} onCancel={() => setDeleteId(null)}
onConfirm={() => { onConfirm={async () => {
if (!deleteId) return; if (!deleteId) return;
void window.agentCompany.deleteKnowledgeEntry({ id: deleteId, companyId }).then(() => onRefresh()); const result = await window.agentCompany.deleteKnowledgeEntry({ id: deleteId, companyId });
setDeleteId(null); setDeleteId(null);
if (result.ok) await onRefresh();
}} }}
/> />
</div> </div>
@@ -638,10 +640,11 @@ export function MeetingsManager({
title="Delete meeting" title="Delete meeting"
message="This removes the meeting and its operational context from the company timeline." message="This removes the meeting and its operational context from the company timeline."
onCancel={() => setDeleteId(null)} onCancel={() => setDeleteId(null)}
onConfirm={() => { onConfirm={async () => {
if (!deleteId) return; if (!deleteId) return;
void window.agentCompany.deleteMeeting({ id: deleteId, companyId }).then(() => onRefresh()); const result = await window.agentCompany.deleteMeeting({ id: deleteId, companyId });
setDeleteId(null); setDeleteId(null);
if (result.ok) await onRefresh();
}} }}
/> />
</div> </div>
@@ -705,10 +708,11 @@ export function SprintManager({
title="Delete sprint" title="Delete sprint"
message="This removes the sprint board entry. Historical run and task records remain." message="This removes the sprint board entry. Historical run and task records remain."
onCancel={() => setDeleteId(null)} onCancel={() => setDeleteId(null)}
onConfirm={() => { onConfirm={async () => {
if (!deleteId) return; if (!deleteId) return;
void window.agentCompany.deleteSprint({ id: deleteId, companyId }).then(() => onRefresh()); const result = await window.agentCompany.deleteSprint({ id: deleteId, companyId });
setDeleteId(null); setDeleteId(null);
if (result.ok) await onRefresh();
}} }}
/> />
</div> </div>
+5 -4
View File
@@ -7,6 +7,7 @@ import {
} from "@phosphor-icons/react"; } from "@phosphor-icons/react";
import type { AgentRecord, ApprovalRecord } from "@shared/types"; import type { AgentRecord, ApprovalRecord } from "@shared/types";
import { getAgentInitials } from "../lib/formatters"; import { getAgentInitials } from "../lib/formatters";
import { unwrap } from "../lib/desktop";
import { ActionButton, EmptyState, Panel, StatusPill } from "./ui"; import { ActionButton, EmptyState, Panel, StatusPill } from "./ui";
interface HiringPipelineProps { interface HiringPipelineProps {
@@ -189,12 +190,12 @@ export function HiringPipeline({ agents, approvals, onRefresh, onNavigateToAgent
icon={Check} icon={Check}
tone="accent" tone="accent"
onClick={async () => { onClick={async () => {
await window.agentCompany.decideApproval({ unwrap(await window.agentCompany.decideApproval({
companyId: a.companyId, companyId: a.companyId,
approvalId: a.id, approvalId: a.id,
state: "approved", state: "approved",
decisionNote: "Hire approved via hiring pipeline", decisionNote: "Hire approved via hiring pipeline",
}); }));
await onRefresh(); await onRefresh();
}} }}
/> />
@@ -203,12 +204,12 @@ export function HiringPipeline({ agents, approvals, onRefresh, onNavigateToAgent
icon={X} icon={X}
tone="danger" tone="danger"
onClick={async () => { onClick={async () => {
await window.agentCompany.decideApproval({ unwrap(await window.agentCompany.decideApproval({
companyId: a.companyId, companyId: a.companyId,
approvalId: a.id, approvalId: a.id,
state: "rejected", state: "rejected",
decisionNote: "Hire rejected via hiring pipeline", decisionNote: "Hire rejected via hiring pipeline",
}); }));
await onRefresh(); await onRefresh();
}} }}
/> />
+9 -9
View File
@@ -271,7 +271,7 @@ export const heartbeatSettingsSchema = z.object({
export const triggerHeartbeatSchema = z.object({ export const triggerHeartbeatSchema = z.object({
agentId: z.string().uuid(), agentId: z.string().uuid(),
companyId: 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"]).default("manual"), 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({ export const metricsQuerySchema = z.object({
@@ -393,10 +393,10 @@ export const automationRuleInputSchema = z.object({
name: z.string().min(2).max(120), name: z.string().min(2).max(120),
description: z.string().max(500).default(""), description: z.string().max(500).default(""),
trigger: z.enum([ trigger: z.enum([
"task_status_changed", "task_created", "task_blocked", "run_completed", "task_status_changed", "task_created", "task_blocked", "task_reassigned",
"run_failed", "approval_resolved", "budget_threshold", "agent_idle", "run_completed", "run_failed", "approval_created", "approval_resolved",
"comment_posted", "document_created", "schedule", "hire_approved", "budget_threshold", "agent_idle", "comment_posted", "document_created",
"sprint_started", "sprint_ended", "schedule", "hire_approved", "sprint_started", "sprint_ended",
]), ]),
conditionsJson: z.string().default("{}"), conditionsJson: z.string().default("{}"),
action: z.enum([ action: z.enum([
@@ -471,10 +471,10 @@ export const workflowInputSchema = z.object({
description: z.string().max(500).default(""), description: z.string().max(500).default(""),
stepsJson: z.string().default("[]"), stepsJson: z.string().default("[]"),
triggerType: z.enum([ triggerType: z.enum([
"task_status_changed", "task_created", "task_blocked", "run_completed", "task_status_changed", "task_created", "task_blocked", "task_reassigned",
"run_failed", "approval_resolved", "budget_threshold", "agent_idle", "run_completed", "run_failed", "approval_created", "approval_resolved",
"comment_posted", "document_created", "schedule", "hire_approved", "budget_threshold", "agent_idle", "comment_posted", "document_created",
"sprint_started", "sprint_ended", "schedule", "hire_approved", "sprint_started", "sprint_ended",
]), ]),
triggerConfigJson: z.string().default("{}"), triggerConfigJson: z.string().default("{}"),
status: z.enum(["draft", "active", "paused", "completed", "failed"]).default("draft"), status: z.enum(["draft", "active", "paused", "completed", "failed"]).default("draft"),
+2
View File
@@ -639,8 +639,10 @@ export type AutomationTrigger =
| "task_status_changed" | "task_status_changed"
| "task_created" | "task_created"
| "task_blocked" | "task_blocked"
| "task_reassigned"
| "run_completed" | "run_completed"
| "run_failed" | "run_failed"
| "approval_created"
| "approval_resolved" | "approval_resolved"
| "budget_threshold" | "budget_threshold"
| "agent_idle" | "agent_idle"