Track workflow executions
const executionId = await db.execution.start( "Feature Implementation", // name "scripts/feature.tsx", // file path { timeout: 3600000 } // optional config );
await db.execution.complete(executionId, { summary: "Feature implemented successfully", output: result, });
await db.execution.fail(executionId, new Error("Tests failed"));
await db.execution.cancel(executionId);
const current = await db.execution.current(); if (current) { console.log(`Running: ${current.name}`); }
const execution = await db.execution.get(executionId);
const recent = await db.execution.list(10);
const incomplete = await db.execution.findIncomplete(); if (incomplete) { console.log("Resuming:", incomplete.id); }
async function main() { const db = await createSmithersDB({ path: ".smithers/data" }); // Check for interrupted execution let executionId: string; const incomplete = await db.execution.findIncomplete(); if (incomplete) { executionId = incomplete.id; console.log(`Resuming execution: ${executionId}`); } else { executionId = await db.execution.start("New Task", "task.tsx"); } // ... run workflow ... await db.execution.complete(executionId); await db.close(); }
// List recent executions const executions = await db.execution.list(10); for (const exec of executions) { console.log(`${exec.name}: ${exec.status}`); console.log(` Started: ${exec.startedAt}`); if (exec.completedAt) { console.log(` Completed: ${exec.completedAt}`); } }
interface Execution { id: string; name: string; filePath: string; status: "pending" | "running" | "complete" | "failed" | "cancelled"; config?: Record<string, any>; result?: Record<string, any>; error?: string; startedAt: Date; completedAt?: Date; }