2b587612d5
Removes maxRounds as a hard stop limit from the entire stack. The supervisor (already configured via workflow.yaml supervisorInterval) is now the sole termination authority. Changes across 27 files in 11 packages: - workflow-protocol: StartStep.meta is now empty, StartNodePayload drops maxRounds - workflow-cas: isStartPayload no longer checks maxRounds - workflow-execute: engine, worker, fork-thread all stripped of maxRounds plumbing - cli-workflow: --max-rounds flag removed from CLI and HTTP API - workflow-runtime: build-context and create-workflow no longer reference maxRounds - workflow-dashboard: UI no longer sends maxRounds - workflow-template-develop/solve-issue: moderator no longer checks rounds remaining - All tests updated Fixes #185
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { join } from "node:path";
|
|
|
|
import { err, ok, type Result } from "@uncaged/workflow-protocol";
|
|
import { getRegisteredWorkflow, readWorkflowRegistry } from "@uncaged/workflow-register";
|
|
import { generateUlid } from "@uncaged/workflow-util";
|
|
import { ensureWorkerForHash, sendWorkerTcpCommand } from "../../worker-spawn.js";
|
|
import { validateCliWorkflowName } from "../../workflow-name.js";
|
|
|
|
export async function cmdRun(
|
|
storageRoot: string,
|
|
name: string,
|
|
prompt: string,
|
|
): Promise<Result<{ threadId: string }, string>> {
|
|
const nameOk = validateCliWorkflowName(name);
|
|
if (!nameOk.ok) {
|
|
return nameOk;
|
|
}
|
|
|
|
const reg = await readWorkflowRegistry(storageRoot);
|
|
if (!reg.ok) {
|
|
return err(reg.error.message);
|
|
}
|
|
|
|
const entry = getRegisteredWorkflow(reg.value, name);
|
|
if (entry === null) {
|
|
return err(`workflow not registered: ${name}`);
|
|
}
|
|
|
|
const bundlePath = join(storageRoot, "bundles", `${entry.hash}.esm.js`);
|
|
const worker = await ensureWorkerForHash(storageRoot, entry.hash, bundlePath);
|
|
if (!worker.ok) {
|
|
return worker;
|
|
}
|
|
|
|
const threadId = generateUlid(Date.now());
|
|
const sent = await sendWorkerTcpCommand(
|
|
worker.value.port,
|
|
{
|
|
type: "run",
|
|
threadId,
|
|
workflowName: name,
|
|
prompt,
|
|
options: { depth: 0 },
|
|
},
|
|
{ awaitResponseLine: false },
|
|
);
|
|
if (!sent.ok) {
|
|
return sent;
|
|
}
|
|
|
|
return ok({ threadId });
|
|
}
|