Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev": "node scripts/dev-server.mjs",
"postinstall": "node scripts/fix-node-pty-permissions.mjs",
"start": "node dist/cli.js serve",
"test": "tsx src/config.test.ts && tsx src/ui/card-types.test.ts && tsx src/ui/patch-display.test.ts && tsx src/ui/tool-display.test.ts && tsx src/apply-patch.test.ts && tsx src/process-platform.test.ts && tsx src/process-sessions.test.ts && tsx src/mcp-sessions.test.ts && tsx src/server-shutdown.test.ts && tsx src/local-agent-runtime.test.ts && tsx src/local-agent-adapters.test.ts && tsx src/local-agent-availability.test.ts && tsx src/local-agent-profiles.test.ts && tsx src/local-agent-targets.test.ts && tsx src/local-agent-store.test.ts && tsx src/roots.test.ts && tsx src/skills.test.ts && tsx src/workspaces.test.ts && tsx src/review-checkpoints.test.ts && tsx src/oauth-store.test.ts && tsx src/cli.test.ts && tsx src/workflow-types.test.ts && tsx src/workflow-store.test.ts && tsx src/workflow-script.test.ts && tsx src/workflow-sandbox.test.ts && tsx src/workflow-engine.test.ts",
"test": "tsx src/config.test.ts && tsx src/ui/card-types.test.ts && tsx src/ui/patch-display.test.ts && tsx src/ui/tool-display.test.ts && tsx src/apply-patch.test.ts && tsx src/process-platform.test.ts && tsx src/process-sessions.test.ts && tsx src/mcp-sessions.test.ts && tsx src/server-shutdown.test.ts && tsx src/local-agent-runtime.test.ts && tsx src/local-agent-adapters.test.ts && tsx src/local-agent-availability.test.ts && tsx src/local-agent-profiles.test.ts && tsx src/local-agent-targets.test.ts && tsx src/local-agent-store.test.ts && tsx src/roots.test.ts && tsx src/skills.test.ts && tsx src/workspaces.test.ts && tsx src/review-checkpoints.test.ts && tsx src/oauth-store.test.ts && tsx src/cli.test.ts && tsx src/workflow-types.test.ts && tsx src/workflow-store.test.ts && tsx src/workflow-script.test.ts && tsx src/workflow-sandbox.test.ts && tsx src/workflow-engine.test.ts && tsx src/workflow-files.test.ts && tsx src/workflow-replay.test.ts && tsx src/workflow-schema.test.ts",
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"keywords": [],
Expand All @@ -44,6 +44,7 @@
"@openai/codex-sdk": "^0.142.5",
"@opencode-ai/sdk": "^1.17.13",
"@pierre/diffs": "^1.2.5",
"ajv": "^8.20.0",
"better-sqlite3": "^12.10.0",
"diff": "^8.0.3",
"drizzle-orm": "^0.45.2",
Expand Down
18 changes: 16 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import {
import { expandHomePath } from "./roots.js";
import { shutdownHttpServer } from "./server-shutdown.js";

type Command = "serve" | "init" | "doctor" | "config" | "agents" | "help" | "version";
import { runWorkflowCommand } from "./workflow-cli.js";

type Command = "serve" | "init" | "doctor" | "config" | "agents" | "workflow" | "help" | "version";
const require = createRequire(import.meta.url);
const SUPPORTED_NODE_RANGE = ">=20.12 <27";

Expand All @@ -67,6 +69,9 @@ async function main(argv: string[]): Promise<void> {
case "agents":
await runAgentsCommand(args);
return;
case "workflow":
await runWorkflowCommand(args, loadConfig());
return;
case "help":
printHelp();
return;
Expand All @@ -78,7 +83,15 @@ async function main(argv: string[]): Promise<void> {

function normalizeCommand(command: string | undefined): Command {
if (!command || command === "serve" || command === "start") return "serve";
if (command === "init" || command === "doctor" || command === "config" || command === "agents") return command;
if (
command === "init" ||
command === "doctor" ||
command === "config" ||
command === "agents" ||
command === "workflow"
) {
return command;
}
if (command === "help" || command === "--help" || command === "-h") return "help";
if (command === "version" || command === "--version" || command === "-v") return "version";
throw new Error(`Unknown command: ${command}`);
Expand Down Expand Up @@ -312,6 +325,7 @@ function printHelp(): void {
" devspace agents ls List subagent sessions",
" devspace agents run <profile-or-provider-or-id> [--model <model>] <prompt>",
" devspace agents show <id>",
" devspace workflow run|status|cancel|ls",
" devspace -v, --version Print the installed version",
"",
"For temporary tunnels:",
Expand Down
47 changes: 32 additions & 15 deletions src/workflow-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export function createWorkflowApi(deps: WorkflowApiDeps): WorkflowApi {
});

const cwd = worktreePath ?? deps.workspaceRoot;
const result = await deps.runProvider({
const providerBase = {
provider,
prompt,
model: agentOpts.model,
Expand All @@ -334,25 +334,42 @@ export function createWorkflowApi(deps: WorkflowApiDeps): WorkflowApi {
signal: deps.signal,
label: agentOpts.label,
phase,
});

throwIfCancelled(deps);
};

let returnValue: unknown = result.finalResponse;
let returnValue: unknown;
let structuredJson: string | undefined;
let result: WorkflowProviderRunResult;

if (agentOpts.schema) {
// Full Ajv enforcement lands in M6; for now extract JSON object when schema set.
const extracted = tryExtractJson(result.finalResponse);
if (extracted === undefined) {
throw new WorkflowEngineError(
"schema",
"agent() schema set but response was not valid JSON",
);
}
returnValue = extracted;
structuredJson = JSON.stringify(extracted);
// Lazy import keeps non-schema paths free of ajv load cost.
const { enforceAgentSchema } = await import("./workflow-schema.js");
const enforced = await enforceAgentSchema({
schema: agentOpts.schema,
prompt,
run: (p) => deps.runProvider({ ...providerBase, prompt: p }),
onRetry: ({ attempt, errors }) => {
deps.journal.appendEvent({
runId: deps.runId,
type: "schema_retry",
phase,
label: agentOpts.label,
data: { callIndex: index, attempt, errors },
});
},
});
returnValue = enforced.value;
structuredJson = JSON.stringify(enforced.value);
result = {
finalResponse: enforced.finalResponse,
providerSessionId: enforced.providerSessionId,
};
} else {
result = await deps.runProvider(providerBase);
returnValue = result.finalResponse;
}

throwIfCancelled(deps);

let dirty: boolean | undefined;
if (worktree) {
const finalized = await worktree.finalize("success");
Expand Down
Loading
Loading