Files
united-workforce/packages/cli-workflow/src/cmd-threads.ts
T
xiaoju 7582a88d6b feat: Phase 2 — Thread lifecycle, execution engine, worker, CLI
- types.ts: START/END, RoleMeta, ThreadContext, Role, Moderator, WorkflowDefinition
- engine.ts: executeThread with JSONL persistence + AbortSignal
- worker.ts: per-bundle process, TCP IPC, kill individual threads
- CLI: run/ps/kill/threads/thread/thread rm commands
- 32 tests pass, biome clean

小橘 <xiaoju@shazhou.work>
2026-05-06 04:59:54 +00:00

32 lines
918 B
TypeScript

import { err, ok, type Result } from "@uncaged/workflow";
import { listHistoricalThreads } from "./thread-scan.js";
import { validateCliWorkflowName } from "./workflow-name.js";
export async function cmdThreads(
storageRoot: string,
argv: string[],
): Promise<Result<string[], string>> {
const nameFilter = argv[0];
if (argv.length > 1) {
return err("threads expects at most one workflow name argument");
}
let workflowNameFilter: string | null = null;
if (nameFilter !== undefined) {
const nameOk = validateCliWorkflowName(nameFilter);
if (!nameOk.ok) {
return nameOk;
}
workflowNameFilter = nameFilter;
}
const rows = await listHistoricalThreads(storageRoot, workflowNameFilter);
if (rows.length === 0) {
return ok(["(no threads found)"]);
}
const lines = rows.map((r) => `${r.threadId}\t${r.hash}\t${r.workflowName ?? "(unknown)"}`);
return ok(lines);
}