function main() {
const db = createSmithersDB({ path: ".smithers/data" });
// Check for interrupted execution
let executionId: string;
const incomplete = db.execution.findIncomplete();
if (incomplete) {
executionId = incomplete.id;
console.log(`Resuming execution: ${executionId}`);
} else {
executionId = db.execution.start("New Task", "task.tsx");
}
try {
// ... run workflow ...
db.execution.complete(executionId);
} catch (err) {
const error = err instanceof Error ? err : new Error(String(err));
db.execution.fail(executionId, error.message);
throw error;
} finally {
db.close();
}
}