agent-contracts-runtime 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -48
- package/cli-contract.yaml +88 -0
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/cursor-sdk.d.ts +1 -1
- package/dist/adapters/mock.d.ts +1 -1
- package/dist/chunk-24SRKCWQ.js +595 -0
- package/dist/chunk-24SRKCWQ.js.map +1 -0
- package/dist/chunk-DNTCPVJN.js +433 -0
- package/dist/chunk-DNTCPVJN.js.map +1 -0
- package/dist/cli/index.js +99 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/generator/index.d.ts +153 -0
- package/dist/generator/index.js +15 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/index.d.ts +29 -3
- package/dist/index.js +14 -451
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-CuYWldNc.d.ts → task-runner-MQO5VR1Y.d.ts} +14 -3
- package/package.json +6 -1
- package/templates/agents.ts.hbs +54 -0
- package/templates/contracts-index.ts.hbs +4 -0
- package/templates/guardrails.ts.hbs +132 -0
- package/templates/handoffs.ts.hbs +19 -0
- package/templates/hooks-index.ts.hbs +31 -0
- package/templates/tasks.ts.hbs +38 -0
- package/templates/workflows.ts.hbs +60 -0
package/dist/cli/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildTaskPrompt,
|
|
4
|
+
pluginRegistry
|
|
5
|
+
} from "../chunk-24SRKCWQ.js";
|
|
6
|
+
import {
|
|
7
|
+
generate,
|
|
8
|
+
loadConfig
|
|
9
|
+
} from "../chunk-DNTCPVJN.js";
|
|
2
10
|
|
|
3
11
|
// src/generated/cli/program.ts
|
|
4
12
|
import { Command } from "commander";
|
|
@@ -11,7 +19,7 @@ function createProgram(handlers2, version) {
|
|
|
11
19
|
program2.command("init").description("Initialize runtime scaffolding for a project.").option("-a, --adapter <value>", "Default SDK adapter to configure.", "mock").option("-o, --output <value>", "Output directory for generated scaffolding.", ".").option("-f, --force", "Overwrite existing files without prompting.", false).action(async (opts, cmd) => {
|
|
12
20
|
await handlers2.init(opts, cmd.optsWithGlobals());
|
|
13
21
|
});
|
|
14
|
-
program2.command("generate").description("Generate runtime contracts and hooks from DSL.").option("--clean", "Delete generated_dir before regenerating.\nRemoves stale files that may remain from previous generations.\n", false).option("--check", "Dry-run mode for CI. Does not write files.\nCompares current generated output with what would be regenerated.\nExits with code 1 if any differences are found.\n", false).action(async (opts, cmd) => {
|
|
22
|
+
program2.command("generate").description("Generate runtime contracts and hooks from DSL.").option("--clean", "Delete generated_dir before regenerating.\nRemoves stale files that may remain from previous generations.\n", false).option("--check", "Dry-run mode for CI. Does not write files.\nCompares current generated output with what would be regenerated.\nExits with code 1 if any differences are found.\n", false).option("-t, --templates <value>", "Custom templates directory. Overrides built-in templates.").action(async (opts, cmd) => {
|
|
15
23
|
await handlers2.generate(opts, cmd.optsWithGlobals());
|
|
16
24
|
});
|
|
17
25
|
program2.command("run").description("Execute a workflow.").argument("<workflow-id>", "ID of the workflow to execute (e.g. feature-implement, issue-fix).").argument("<user-request>", "Natural language description of what to do.").option("-a, --adapter <value>", "SDK adapter to use. Overrides config.").option("-r, --max-retries <value>", "Override default max retries per step.").option("-n, --dry-run", "Simulate execution without calling the SDK adapter.", false).option("--auto-approve-gates", "Automatically approve all gate steps.", false).action(async (workflowId, userRequest, opts, cmd) => {
|
|
@@ -20,6 +28,9 @@ function createProgram(handlers2, version) {
|
|
|
20
28
|
program2.command("list").description("List available workflows, tasks, or agents.").argument("<resource>", "Type of resource to list.").option("--format <value>", "Output format.", "table").action(async (resource, opts, cmd) => {
|
|
21
29
|
await handlers2.list(resource, opts, cmd.optsWithGlobals());
|
|
22
30
|
});
|
|
31
|
+
program2.command("show-prompt").description("Display the generated prompt for a task.").argument("<task-id>", "ID of the task to show the prompt for (e.g. plan-and-implement, audit-tests).").option("-u, --user-request <value>", "User request text to include in the prompt preview.", "(preview)").option("--format <value>", "Output format.", "markdown").option("--with-plugins", "Apply registered plugin prompt enhancers to the output.", false).action(async (taskId, opts, cmd) => {
|
|
32
|
+
await handlers2.showPrompt(taskId, opts, cmd.optsWithGlobals());
|
|
33
|
+
});
|
|
23
34
|
program2.command("doctor").description("Verify configuration, generated files, and SDK connectivity.").action(async (opts, cmd) => {
|
|
24
35
|
await handlers2.doctor({}, cmd.optsWithGlobals());
|
|
25
36
|
});
|
|
@@ -30,31 +41,109 @@ function createProgram(handlers2, version) {
|
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
// src/cli/index.ts
|
|
33
|
-
var VERSION = "0.
|
|
44
|
+
var VERSION = "0.3.0";
|
|
45
|
+
async function loadGeneratedContracts(configPath) {
|
|
46
|
+
const config = await loadConfig(configPath);
|
|
47
|
+
const indexPath = new URL(`file://${config.generatedDir}/index.js`).href;
|
|
48
|
+
const mod = await import(indexPath);
|
|
49
|
+
return {
|
|
50
|
+
agentRegistry: mod.agentRegistry ?? {},
|
|
51
|
+
taskRegistry: mod.taskRegistry ?? {},
|
|
52
|
+
handoffSchemas: mod.handoffSchemas ?? {}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
34
55
|
var handlers = {
|
|
35
56
|
async init(options, _globalOpts) {
|
|
36
|
-
console.log("agent-runtime init \u2014 not yet implemented
|
|
57
|
+
console.log("agent-runtime init \u2014 not yet implemented");
|
|
37
58
|
console.log("Options:", JSON.stringify(options));
|
|
38
59
|
},
|
|
39
|
-
async generate(options,
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
async generate(options, globalOpts) {
|
|
61
|
+
try {
|
|
62
|
+
const configPath = globalOpts.config ?? "./agent-runtime.config.yaml";
|
|
63
|
+
const result = await generate({
|
|
64
|
+
clean: options.clean,
|
|
65
|
+
check: options.check,
|
|
66
|
+
templates: options.templates,
|
|
67
|
+
configPath
|
|
68
|
+
});
|
|
69
|
+
if (result.checkMode) {
|
|
70
|
+
if (result.hasDifferences) {
|
|
71
|
+
console.error("Generated files are out of date. Run `agent-runtime generate` to update.");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
console.log(JSON.stringify({ ...result, status: "up-to-date" }, null, 2));
|
|
75
|
+
} else {
|
|
76
|
+
console.log(JSON.stringify(result, null, 2));
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error("Generate failed:", err.message);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
42
82
|
},
|
|
43
83
|
async run(workflowId, userRequest, options, _globalOpts) {
|
|
44
|
-
console.log("agent-runtime run \u2014 not yet implemented
|
|
84
|
+
console.log("agent-runtime run \u2014 not yet implemented");
|
|
45
85
|
console.log(`Workflow: ${workflowId}, Request: ${userRequest}`);
|
|
46
86
|
console.log("Options:", JSON.stringify(options));
|
|
47
87
|
},
|
|
48
88
|
async list(resource, options, _globalOpts) {
|
|
49
|
-
console.log("agent-runtime list \u2014 not yet implemented
|
|
89
|
+
console.log("agent-runtime list \u2014 not yet implemented");
|
|
50
90
|
console.log(`Resource: ${resource}`);
|
|
51
91
|
console.log("Options:", JSON.stringify(options));
|
|
52
92
|
},
|
|
93
|
+
async showPrompt(taskId, options, globalOpts) {
|
|
94
|
+
if (!taskId) {
|
|
95
|
+
console.error("Error: task-id is required");
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
const configPath = globalOpts.config ?? "./agent-runtime.config.yaml";
|
|
99
|
+
let contracts;
|
|
100
|
+
try {
|
|
101
|
+
contracts = await loadGeneratedContracts(configPath);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.error(`Failed to load generated contracts: ${err.message}`);
|
|
104
|
+
console.error("Run `agent-runtime generate` first.");
|
|
105
|
+
process.exit(1);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const task = contracts.taskRegistry[taskId];
|
|
109
|
+
if (!task) {
|
|
110
|
+
console.error(`Unknown task: ${taskId}`);
|
|
111
|
+
console.error(`Available tasks: ${Object.keys(contracts.taskRegistry).join(", ")}`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const agent = contracts.agentRegistry[task.target_agent];
|
|
116
|
+
if (!agent) {
|
|
117
|
+
console.error(`Unknown agent: ${task.target_agent} (referenced by task ${taskId})`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const userRequest = options.userRequest ?? "(preview)";
|
|
122
|
+
let prompt = buildTaskPrompt(agent, task, { user_request: userRequest }, {
|
|
123
|
+
handoffSchemas: contracts.handoffSchemas
|
|
124
|
+
});
|
|
125
|
+
const pluginsApplied = options.withPlugins ?? false;
|
|
126
|
+
if (pluginsApplied) {
|
|
127
|
+
prompt = pluginRegistry.applyPromptEnhancers(taskId, prompt, { user_request: userRequest });
|
|
128
|
+
}
|
|
129
|
+
const format = options.format ?? "markdown";
|
|
130
|
+
if (format === "json") {
|
|
131
|
+
console.log(JSON.stringify({
|
|
132
|
+
task_id: taskId,
|
|
133
|
+
agent_id: task.target_agent,
|
|
134
|
+
prompt,
|
|
135
|
+
handoff_schema: task.result_handoff,
|
|
136
|
+
plugins_applied: pluginsApplied
|
|
137
|
+
}, null, 2));
|
|
138
|
+
} else {
|
|
139
|
+
console.log(prompt);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
53
142
|
async doctor(_globalOpts) {
|
|
54
|
-
console.log("agent-runtime doctor \u2014 not yet implemented
|
|
143
|
+
console.log("agent-runtime doctor \u2014 not yet implemented");
|
|
55
144
|
},
|
|
56
145
|
async replay(runDir, options, _globalOpts) {
|
|
57
|
-
console.log("agent-runtime replay \u2014 not yet implemented
|
|
146
|
+
console.log("agent-runtime replay \u2014 not yet implemented");
|
|
58
147
|
console.log(`Run dir: ${runDir}`);
|
|
59
148
|
console.log("Options:", JSON.stringify(options));
|
|
60
149
|
}
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generated/cli/program.ts","../../src/cli/index.ts"],"sourcesContent":["// Auto-generated by cli-contracts. Do not edit.\nimport { Command } from \"commander\";\n\nexport interface CommandHandlers {\n init: (options: { adapter?: string; output?: string; force?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n generate: (options: { clean?: boolean; check?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n run: (workflowId: string | undefined, userRequest: string | undefined, options: { adapter?: string; maxRetries?: string; dryRun?: boolean; autoApproveGates?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n list: (resource: string | undefined, options: { format?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n doctor: (parentOpts: Record<string, unknown>) => Promise<void>;\n replay: (runDir: string | undefined, options: { validateOnly?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n}\n\nexport function createProgram(\n handlers: CommandHandlers,\n version: string,\n): Command {\n const program = new Command();\n program\n .name(\"agent-runtime\")\n .version(version, \"-V, --version\")\n .description(\"CLI for agent-contracts-runtime — generate, run, and manage agent workflows.\");\n\n program.option(\"-c, --config <value>\", \"Path to agent-runtime.config.yaml.\", \"./agent-runtime.config.yaml\");\n program.option(\"-v, --verbose\", \"Enable verbose output.\", false);\n program.option(\"-q, --quiet\", \"Suppress non-error output.\", false);\n\n program\n .command(\"init\")\n .description(\"Initialize runtime scaffolding for a project.\")\n .option(\"-a, --adapter <value>\", \"Default SDK adapter to configure.\", \"mock\")\n .option(\"-o, --output <value>\", \"Output directory for generated scaffolding.\", \".\")\n .option(\"-f, --force\", \"Overwrite existing files without prompting.\", false)\n .action(async (opts, cmd) => {\n await handlers.init(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"generate\")\n .description(\"Generate runtime contracts and hooks from DSL.\")\n .option(\"--clean\", \"Delete generated_dir before regenerating.\\nRemoves stale files that may remain from previous generations.\\n\", false)\n .option(\"--check\", \"Dry-run mode for CI. Does not write files.\\nCompares current generated output with what would be regenerated.\\nExits with code 1 if any differences are found.\\n\", false)\n .action(async (opts, cmd) => {\n await handlers.generate(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"run\")\n .description(\"Execute a workflow.\")\n .argument(\"<workflow-id>\", \"ID of the workflow to execute (e.g. feature-implement, issue-fix).\")\n .argument(\"<user-request>\", \"Natural language description of what to do.\")\n .option(\"-a, --adapter <value>\", \"SDK adapter to use. Overrides config.\")\n .option(\"-r, --max-retries <value>\", \"Override default max retries per step.\")\n .option(\"-n, --dry-run\", \"Simulate execution without calling the SDK adapter.\", false)\n .option(\"--auto-approve-gates\", \"Automatically approve all gate steps.\", false)\n .action(async (workflowId, userRequest, opts, cmd) => {\n await handlers.run(workflowId, userRequest, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"list\")\n .description(\"List available workflows, tasks, or agents.\")\n .argument(\"<resource>\", \"Type of resource to list.\")\n .option(\"--format <value>\", \"Output format.\", \"table\")\n .action(async (resource, opts, cmd) => {\n await handlers.list(resource, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"doctor\")\n .description(\"Verify configuration, generated files, and SDK connectivity.\")\n .action(async (opts, cmd) => {\n await handlers.doctor({}, cmd.optsWithGlobals());\n });\n\n program\n .command(\"replay\")\n .description(\"Replay a past workflow execution from logs.\")\n .argument(\"<run-dir>\", \"Path to the .agent-runs/<run-id> directory.\")\n .option(\"--validate-only\", \"Only validate the run log without re-execution.\", false)\n .action(async (runDir, opts, cmd) => {\n await handlers.replay(runDir, opts, cmd.optsWithGlobals());\n });\n\n return program;\n}\n","#!/usr/bin/env node\n\n/**\n * agent-runtime CLI entry point\n *\n * Uses auto-generated program from cli-contract.yaml.\n * Handler implementations are stubs for v0.0.x — full logic in Phase 2.\n */\n\nimport { createProgram, type CommandHandlers } from \"../generated/cli/program.js\";\n\nconst VERSION = \"0.1.0\";\n\nconst handlers: CommandHandlers = {\n async init(options, _globalOpts) {\n console.log(\"agent-runtime init — not yet implemented (Phase 2)\");\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async generate(options, _globalOpts) {\n console.log(\"agent-runtime generate — not yet implemented (Phase 2)\");\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async run(workflowId, userRequest, options, _globalOpts) {\n console.log(\"agent-runtime run — not yet implemented (Phase 2)\");\n console.log(`Workflow: ${workflowId}, Request: ${userRequest}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async list(resource, options, _globalOpts) {\n console.log(\"agent-runtime list — not yet implemented (Phase 2)\");\n console.log(`Resource: ${resource}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async doctor(_globalOpts) {\n console.log(\"agent-runtime doctor — not yet implemented (Phase 2)\");\n },\n\n async replay(runDir, options, _globalOpts) {\n console.log(\"agent-runtime replay — not yet implemented (Phase 3)\");\n console.log(`Run dir: ${runDir}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n};\n\nconst program = createProgram(handlers, VERSION);\nprogram.parse();\n"],"mappings":";;;AACA,SAAS,eAAe;AAWjB,SAAS,cACdA,WACA,SACS;AACT,QAAMC,WAAU,IAAI,QAAQ;AAC5B,EAAAA,SACG,KAAK,eAAe,EACpB,QAAQ,SAAS,eAAe,EAChC,YAAY,mFAA8E;AAE7F,EAAAA,SAAQ,OAAO,wBAAwB,sCAAsC,6BAA6B;AAC1G,EAAAA,SAAQ,OAAO,iBAAiB,0BAA0B,KAAK;AAC/D,EAAAA,SAAQ,OAAO,eAAe,8BAA8B,KAAK;AAEjE,EAAAA,SACG,QAAQ,MAAM,EACd,YAAY,+CAA+C,EAC3D,OAAO,yBAAyB,qCAAqC,MAAM,EAC3E,OAAO,wBAAwB,+CAA+C,GAAG,EACjF,OAAO,eAAe,+CAA+C,KAAK,EAC1E,OAAO,OAAO,MAAM,QAAQ;AAC3B,UAAMD,UAAS,KAAK,MAAM,IAAI,gBAAgB,CAAC;AAAA,EACjD,CAAC;AAEH,EAAAC,SACG,QAAQ,UAAU,EAClB,YAAY,gDAAgD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,KAAK,SAAS,aAAa;AAC/B,YAAQ,IAAI,yDAAoD;AAChE,YAAQ,IAAI,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA,EACjD;AAAA,EAEA,MAAM,SAAS,SAAS,aAAa;AACnC,YAAQ,IAAI,6DAAwD;AACpE,YAAQ,IAAI,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA,EACjD;AAAA,EAEA,MAAM,IAAI,YAAY,aAAa,SAAS,aAAa;AACvD,YAAQ,IAAI,wDAAmD;AAC/D,YAAQ,IAAI,aAAa,UAAU,cAAc,WAAW,EAAE;AAC9D,YAAQ,IAAI,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA,EACjD;AAAA,EAEA,MAAM,KAAK,UAAU,SAAS,aAAa;AACzC,YAAQ,IAAI,yDAAoD;AAChE,YAAQ,IAAI,aAAa,QAAQ,EAAE;AACnC,YAAQ,IAAI,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA,EACjD;AAAA,EAEA,MAAM,OAAO,aAAa;AACxB,YAAQ,IAAI,2DAAsD;AAAA,EACpE;AAAA,EAEA,MAAM,OAAO,QAAQ,SAAS,aAAa;AACzC,YAAQ,IAAI,2DAAsD;AAClE,YAAQ,IAAI,YAAY,MAAM,EAAE;AAChC,YAAQ,IAAI,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA,EACjD;AACF;AAEA,IAAM,UAAU,cAAc,UAAU,OAAO;AAC/C,QAAQ,MAAM;","names":["handlers","program"]}
|
|
1
|
+
{"version":3,"sources":["../../src/generated/cli/program.ts","../../src/cli/index.ts"],"sourcesContent":["// Auto-generated by cli-contracts. Do not edit.\nimport { Command } from \"commander\";\n\nexport interface CommandHandlers {\n init: (options: { adapter?: string; output?: string; force?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n generate: (options: { clean?: boolean; check?: boolean; templates?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n run: (workflowId: string | undefined, userRequest: string | undefined, options: { adapter?: string; maxRetries?: string; dryRun?: boolean; autoApproveGates?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n list: (resource: string | undefined, options: { format?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n showPrompt: (taskId: string | undefined, options: { userRequest?: string; format?: string; withPlugins?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n doctor: (parentOpts: Record<string, unknown>) => Promise<void>;\n replay: (runDir: string | undefined, options: { validateOnly?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n}\n\nexport function createProgram(\n handlers: CommandHandlers,\n version: string,\n): Command {\n const program = new Command();\n program\n .name(\"agent-runtime\")\n .version(version, \"-V, --version\")\n .description(\"CLI for agent-contracts-runtime — generate, run, and manage agent workflows.\");\n\n program.option(\"-c, --config <value>\", \"Path to agent-runtime.config.yaml.\", \"./agent-runtime.config.yaml\");\n program.option(\"-v, --verbose\", \"Enable verbose output.\", false);\n program.option(\"-q, --quiet\", \"Suppress non-error output.\", false);\n\n program\n .command(\"init\")\n .description(\"Initialize runtime scaffolding for a project.\")\n .option(\"-a, --adapter <value>\", \"Default SDK adapter to configure.\", \"mock\")\n .option(\"-o, --output <value>\", \"Output directory for generated scaffolding.\", \".\")\n .option(\"-f, --force\", \"Overwrite existing files without prompting.\", false)\n .action(async (opts, cmd) => {\n await handlers.init(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"generate\")\n .description(\"Generate runtime contracts and hooks from DSL.\")\n .option(\"--clean\", \"Delete generated_dir before regenerating.\\nRemoves stale files that may remain from previous generations.\\n\", false)\n .option(\"--check\", \"Dry-run mode for CI. Does not write files.\\nCompares current generated output with what would be regenerated.\\nExits with code 1 if any differences are found.\\n\", false)\n .option(\"-t, --templates <value>\", \"Custom templates directory. Overrides built-in templates.\")\n .action(async (opts, cmd) => {\n await handlers.generate(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"run\")\n .description(\"Execute a workflow.\")\n .argument(\"<workflow-id>\", \"ID of the workflow to execute (e.g. feature-implement, issue-fix).\")\n .argument(\"<user-request>\", \"Natural language description of what to do.\")\n .option(\"-a, --adapter <value>\", \"SDK adapter to use. Overrides config.\")\n .option(\"-r, --max-retries <value>\", \"Override default max retries per step.\")\n .option(\"-n, --dry-run\", \"Simulate execution without calling the SDK adapter.\", false)\n .option(\"--auto-approve-gates\", \"Automatically approve all gate steps.\", false)\n .action(async (workflowId, userRequest, opts, cmd) => {\n await handlers.run(workflowId, userRequest, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"list\")\n .description(\"List available workflows, tasks, or agents.\")\n .argument(\"<resource>\", \"Type of resource to list.\")\n .option(\"--format <value>\", \"Output format.\", \"table\")\n .action(async (resource, opts, cmd) => {\n await handlers.list(resource, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"show-prompt\")\n .description(\"Display the generated prompt for a task.\")\n .argument(\"<task-id>\", \"ID of the task to show the prompt for (e.g. plan-and-implement, audit-tests).\")\n .option(\"-u, --user-request <value>\", \"User request text to include in the prompt preview.\", \"(preview)\")\n .option(\"--format <value>\", \"Output format.\", \"markdown\")\n .option(\"--with-plugins\", \"Apply registered plugin prompt enhancers to the output.\", false)\n .action(async (taskId, opts, cmd) => {\n await handlers.showPrompt(taskId, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"doctor\")\n .description(\"Verify configuration, generated files, and SDK connectivity.\")\n .action(async (opts, cmd) => {\n await handlers.doctor({}, cmd.optsWithGlobals());\n });\n\n program\n .command(\"replay\")\n .description(\"Replay a past workflow execution from logs.\")\n .argument(\"<run-dir>\", \"Path to the .agent-runs/<run-id> directory.\")\n .option(\"--validate-only\", \"Only validate the run log without re-execution.\", false)\n .action(async (runDir, opts, cmd) => {\n await handlers.replay(runDir, opts, cmd.optsWithGlobals());\n });\n\n return program;\n}\n","#!/usr/bin/env node\n\n/**\n * agent-runtime CLI entry point\n *\n * Uses auto-generated program from cli-contract.yaml.\n */\n\nimport { createProgram, type CommandHandlers } from \"../generated/cli/program.js\";\nimport { generate, loadConfig } from \"../generator/index.js\";\nimport { buildTaskPrompt, pluginRegistry, type AgentContractLike, type TaskContractLike } from \"../index.js\";\nimport type { z } from \"zod\";\n\nconst VERSION = \"0.3.0\";\n\n/**\n * Dynamically import the generated contracts from the configured generated_dir.\n */\nasync function loadGeneratedContracts(configPath: string): Promise<{\n agentRegistry: Record<string, AgentContractLike>;\n taskRegistry: Record<string, TaskContractLike>;\n handoffSchemas: Record<string, z.ZodTypeAny>;\n}> {\n const config = await loadConfig(configPath);\n const indexPath = new URL(`file://${config.generatedDir}/index.js`).href;\n const mod = await import(indexPath);\n return {\n agentRegistry: mod.agentRegistry ?? {},\n taskRegistry: mod.taskRegistry ?? {},\n handoffSchemas: mod.handoffSchemas ?? {},\n };\n}\n\nconst handlers: CommandHandlers = {\n async init(options, _globalOpts) {\n console.log(\"agent-runtime init — not yet implemented\");\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async generate(options, globalOpts) {\n try {\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n const result = await generate({\n clean: options.clean,\n check: options.check,\n templates: options.templates,\n configPath,\n });\n\n if (result.checkMode) {\n if (result.hasDifferences) {\n console.error(\"Generated files are out of date. Run `agent-runtime generate` to update.\");\n process.exit(1);\n }\n console.log(JSON.stringify({ ...result, status: \"up-to-date\" }, null, 2));\n } else {\n console.log(JSON.stringify(result, null, 2));\n }\n } catch (err) {\n console.error(\"Generate failed:\", (err as Error).message);\n process.exit(1);\n }\n },\n\n async run(workflowId, userRequest, options, _globalOpts) {\n console.log(\"agent-runtime run — not yet implemented\");\n console.log(`Workflow: ${workflowId}, Request: ${userRequest}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async list(resource, options, _globalOpts) {\n console.log(\"agent-runtime list — not yet implemented\");\n console.log(`Resource: ${resource}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async showPrompt(taskId, options, globalOpts) {\n if (!taskId) {\n console.error(\"Error: task-id is required\");\n process.exit(1);\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n console.error(\"Run `agent-runtime generate` first.\");\n process.exit(1);\n return;\n }\n\n const task = contracts.taskRegistry[taskId];\n if (!task) {\n console.error(`Unknown task: ${taskId}`);\n console.error(`Available tasks: ${Object.keys(contracts.taskRegistry).join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const agent = contracts.agentRegistry[task.target_agent];\n if (!agent) {\n console.error(`Unknown agent: ${task.target_agent} (referenced by task ${taskId})`);\n process.exit(1);\n return;\n }\n\n const userRequest = options.userRequest ?? \"(preview)\";\n let prompt = buildTaskPrompt(agent, task, { user_request: userRequest }, {\n handoffSchemas: contracts.handoffSchemas,\n });\n\n const pluginsApplied = options.withPlugins ?? false;\n if (pluginsApplied) {\n prompt = pluginRegistry.applyPromptEnhancers(taskId, prompt, { user_request: userRequest });\n }\n\n const format = options.format ?? \"markdown\";\n if (format === \"json\") {\n console.log(JSON.stringify({\n task_id: taskId,\n agent_id: task.target_agent,\n prompt,\n handoff_schema: task.result_handoff,\n plugins_applied: pluginsApplied,\n }, null, 2));\n } else {\n console.log(prompt);\n }\n },\n\n async doctor(_globalOpts) {\n console.log(\"agent-runtime doctor — not yet implemented\");\n },\n\n async replay(runDir, options, _globalOpts) {\n console.log(\"agent-runtime replay — not yet implemented\");\n console.log(`Run dir: ${runDir}`);\n console.log(\"Options:\", JSON.stringify(options));\n },\n};\n\nconst program = createProgram(handlers, VERSION);\nprogram.parse();\n"],"mappings":";;;;;;;;;;;AACA,SAAS,eAAe;AAYjB,SAAS,cACdA,WACA,SACS;AACT,QAAMC,WAAU,IAAI,QAAQ;AAC5B,EAAAA,SACG,KAAK,eAAe,EACpB,QAAQ,SAAS,eAAe,EAChC,YAAY,mFAA8E;AAE7F,EAAAA,SAAQ,OAAO,wBAAwB,s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A,IAAM,UAAU,cAAc,UAAU,OAAO;AAC/C,QAAQ,MAAM;","names":["handlers","program"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generator configuration — loads and validates agent-runtime.config.yaml
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare const RuntimeConfigSchema: z.ZodObject<{
|
|
8
|
+
dsl: z.ZodDefault<z.ZodString>;
|
|
9
|
+
generated_dir: z.ZodDefault<z.ZodString>;
|
|
10
|
+
bindings: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
active_guardrail_policy: z.ZodOptional<z.ZodString>;
|
|
12
|
+
templates_dir: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
dsl: string;
|
|
15
|
+
generated_dir: string;
|
|
16
|
+
bindings: string[];
|
|
17
|
+
active_guardrail_policy?: string | undefined;
|
|
18
|
+
templates_dir?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
dsl?: string | undefined;
|
|
21
|
+
generated_dir?: string | undefined;
|
|
22
|
+
bindings?: string[] | undefined;
|
|
23
|
+
active_guardrail_policy?: string | undefined;
|
|
24
|
+
templates_dir?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
|
|
27
|
+
interface ResolvedConfig extends RuntimeConfig {
|
|
28
|
+
configDir: string;
|
|
29
|
+
dslPath: string;
|
|
30
|
+
generatedDir: string;
|
|
31
|
+
bindingPaths: string[];
|
|
32
|
+
templatesDir: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
declare function loadConfig(configPath: string): Promise<ResolvedConfig>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Build template contexts from resolved DSL data
|
|
38
|
+
*/
|
|
39
|
+
interface AgentEntry {
|
|
40
|
+
id: string;
|
|
41
|
+
varName: string;
|
|
42
|
+
role_name: string;
|
|
43
|
+
purpose: string;
|
|
44
|
+
mode: string;
|
|
45
|
+
dispatch_only: boolean;
|
|
46
|
+
can_read_artifacts: string[];
|
|
47
|
+
can_write_artifacts: string[];
|
|
48
|
+
can_execute_tools: string[];
|
|
49
|
+
can_invoke_agents: string[];
|
|
50
|
+
can_return_handoffs: string[];
|
|
51
|
+
responsibilities: string[];
|
|
52
|
+
constraints: string[];
|
|
53
|
+
rules: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
description: string;
|
|
56
|
+
severity: string;
|
|
57
|
+
}>;
|
|
58
|
+
escalation_criteria: Array<{
|
|
59
|
+
condition: string;
|
|
60
|
+
action: string;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
interface TaskEntry {
|
|
64
|
+
id: string;
|
|
65
|
+
varName: string;
|
|
66
|
+
description: string;
|
|
67
|
+
target_agent: string;
|
|
68
|
+
allowed_from_agents: string[];
|
|
69
|
+
workflow: string;
|
|
70
|
+
invocation_handoff: string;
|
|
71
|
+
result_handoff: string;
|
|
72
|
+
input_artifacts: string[];
|
|
73
|
+
responsibilities: string[];
|
|
74
|
+
completion_criteria: string[];
|
|
75
|
+
optional: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface WorkflowStepEntry {
|
|
78
|
+
type: string;
|
|
79
|
+
task?: string;
|
|
80
|
+
from_agent?: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
optional?: boolean;
|
|
83
|
+
max_retries?: number;
|
|
84
|
+
gate_kind?: string;
|
|
85
|
+
}
|
|
86
|
+
interface WorkflowEntry {
|
|
87
|
+
id: string;
|
|
88
|
+
varName: string;
|
|
89
|
+
description: string;
|
|
90
|
+
trigger: string;
|
|
91
|
+
entry_conditions: string[];
|
|
92
|
+
steps: WorkflowStepEntry[];
|
|
93
|
+
}
|
|
94
|
+
interface HandoffEntry {
|
|
95
|
+
id: string;
|
|
96
|
+
varName: string;
|
|
97
|
+
pascalName: string;
|
|
98
|
+
schemaName: string;
|
|
99
|
+
description: string;
|
|
100
|
+
schema: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
interface ContractContext {
|
|
103
|
+
agentEntries: AgentEntry[];
|
|
104
|
+
taskEntries: TaskEntry[];
|
|
105
|
+
workflowEntries: WorkflowEntry[];
|
|
106
|
+
handoffEntries: HandoffEntry[];
|
|
107
|
+
}
|
|
108
|
+
declare function buildContractContext(dsl: any): ContractContext;
|
|
109
|
+
interface GuardrailCheckEntry {
|
|
110
|
+
guardrail_id: string;
|
|
111
|
+
description: string;
|
|
112
|
+
severity: string;
|
|
113
|
+
action: string;
|
|
114
|
+
matcher_type: string;
|
|
115
|
+
pattern: string;
|
|
116
|
+
message: string;
|
|
117
|
+
file_glob?: string;
|
|
118
|
+
exclude_glob?: string;
|
|
119
|
+
}
|
|
120
|
+
interface GuardrailContext {
|
|
121
|
+
commandChecks: GuardrailCheckEntry[];
|
|
122
|
+
fileChecks: GuardrailCheckEntry[];
|
|
123
|
+
contentChecks: GuardrailCheckEntry[];
|
|
124
|
+
allChecks: GuardrailCheckEntry[];
|
|
125
|
+
hasGuardrails: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Build guardrail context from DSL guardrails, binding guardrail_impl, and active policy.
|
|
129
|
+
* Mirrors the agent-contracts resolveChecks pattern.
|
|
130
|
+
*/
|
|
131
|
+
declare function buildGuardrailContext(dsl: any, binding: any, policyName?: string): GuardrailContext;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Generator — orchestrates DSL-to-TypeScript code generation
|
|
135
|
+
*/
|
|
136
|
+
interface GenerateOptions {
|
|
137
|
+
clean?: boolean;
|
|
138
|
+
check?: boolean;
|
|
139
|
+
templates?: string;
|
|
140
|
+
configPath?: string;
|
|
141
|
+
}
|
|
142
|
+
interface GenerateResult {
|
|
143
|
+
filesGenerated: string[];
|
|
144
|
+
dslHash: string;
|
|
145
|
+
generationInputHash: string;
|
|
146
|
+
cleaned: boolean;
|
|
147
|
+
checkMode: boolean;
|
|
148
|
+
hasDifferences: boolean;
|
|
149
|
+
}
|
|
150
|
+
declare function generate(options?: GenerateOptions): Promise<GenerateResult>;
|
|
151
|
+
declare function checkFreshness(configPath?: string): Promise<boolean>;
|
|
152
|
+
|
|
153
|
+
export { type GenerateOptions, type GenerateResult, type ResolvedConfig, buildContractContext, buildGuardrailContext, checkFreshness, generate, loadConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildContractContext,
|
|
3
|
+
buildGuardrailContext,
|
|
4
|
+
checkFreshness,
|
|
5
|
+
generate,
|
|
6
|
+
loadConfig
|
|
7
|
+
} from "../chunk-DNTCPVJN.js";
|
|
8
|
+
export {
|
|
9
|
+
buildContractContext,
|
|
10
|
+
buildGuardrailContext,
|
|
11
|
+
checkFreshness,
|
|
12
|
+
generate,
|
|
13
|
+
loadConfig
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TaskOutcome, a as TaskContext, S as SdkAdapter, b as TaskContractLike, A as AgentContractLike } from './task-runner-
|
|
2
|
-
export { R as RetryDecision, c as TaskRunOptions, d as TaskRunResult, e as buildRetryFollowUp, f as buildTaskPrompt, g as extractStructuredResult, r as runTask } from './task-runner-
|
|
1
|
+
import { T as TaskOutcome, a as TaskContext, S as SdkAdapter, b as TaskContractLike, A as AgentContractLike, P as PromptBuilderOptions } from './task-runner-MQO5VR1Y.js';
|
|
2
|
+
export { R as RetryDecision, c as TaskRunOptions, d as TaskRunResult, e as buildRetryFollowUp, f as buildTaskPrompt, g as extractStructuredResult, r as runTask, z as zodSchemaToPromptDescription, h as zodSchemaToYamlExample } from './task-runner-MQO5VR1Y.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -38,6 +38,10 @@ interface WorkflowContractLike {
|
|
|
38
38
|
}
|
|
39
39
|
interface WorkflowRunOptions {
|
|
40
40
|
user_request: string;
|
|
41
|
+
/** Override max follow-up attempts per step (lightweight output-format correction). Default: 2 */
|
|
42
|
+
maxFollowUps?: number;
|
|
43
|
+
/** Override max full retry attempts per step. Default: from DSL step.max_retries */
|
|
44
|
+
maxRetries?: number;
|
|
41
45
|
onGate?: (gateKind: string, description: string, stepResults: StepResult[]) => Promise<boolean>;
|
|
42
46
|
onStepComplete?: (event: StepCompleteEvent) => void;
|
|
43
47
|
onOptionalStep?: (step: DelegateStep, context: TaskContext) => Promise<boolean>;
|
|
@@ -94,11 +98,28 @@ interface GuardrailResult {
|
|
|
94
98
|
action: "block" | "warn" | "shadow" | "info";
|
|
95
99
|
message: string;
|
|
96
100
|
}
|
|
101
|
+
interface PromptBuilderArgs {
|
|
102
|
+
agent: AgentContractLike;
|
|
103
|
+
task: TaskContractLike;
|
|
104
|
+
context: TaskContext;
|
|
105
|
+
options?: PromptBuilderOptions;
|
|
106
|
+
}
|
|
97
107
|
interface AgentPlugin {
|
|
98
108
|
readonly id: string;
|
|
99
109
|
beforeTask?(taskId: string, context: TaskContext): Promise<TaskContext | null>;
|
|
100
110
|
afterTask?(taskId: string, outcome: TaskOutcome): Promise<TaskOutcome>;
|
|
111
|
+
/**
|
|
112
|
+
* Lightweight prompt post-processor. Applied after the prompt is built.
|
|
113
|
+
* Use for appending instructions or modifying sections.
|
|
114
|
+
*/
|
|
101
115
|
promptEnhancer?(taskId: string, prompt: string, context: TaskContext): string;
|
|
116
|
+
/**
|
|
117
|
+
* Full prompt builder override. If provided and returns a non-null string,
|
|
118
|
+
* replaces the default buildTaskPrompt output entirely.
|
|
119
|
+
* Receives the agent/task contracts and context so the plugin can build
|
|
120
|
+
* a completely custom prompt.
|
|
121
|
+
*/
|
|
122
|
+
promptBuilder?(args: PromptBuilderArgs): string | null;
|
|
102
123
|
customGuardrails?: {
|
|
103
124
|
evaluateCommand?(command: string): GuardrailResult[];
|
|
104
125
|
evaluateFilePath?(filePath: string): GuardrailResult[];
|
|
@@ -113,6 +134,11 @@ declare class PluginRegistry {
|
|
|
113
134
|
getAll(): readonly AgentPlugin[];
|
|
114
135
|
runBeforeTask(taskId: string, context: TaskContext): Promise<TaskContext | null>;
|
|
115
136
|
runAfterTask(taskId: string, outcome: TaskOutcome): Promise<TaskOutcome>;
|
|
137
|
+
/**
|
|
138
|
+
* Try plugin promptBuilder hooks. Returns custom prompt if any plugin provides one,
|
|
139
|
+
* or null to use the default buildTaskPrompt.
|
|
140
|
+
*/
|
|
141
|
+
applyPromptBuilder(args: PromptBuilderArgs): string | null;
|
|
116
142
|
applyPromptEnhancers(taskId: string, prompt: string, context: TaskContext): string;
|
|
117
143
|
evaluateCommandGuardrails(command: string): GuardrailResult[];
|
|
118
144
|
evaluateFilePathGuardrails(filePath: string): GuardrailResult[];
|
|
@@ -122,4 +148,4 @@ declare class PluginRegistry {
|
|
|
122
148
|
}
|
|
123
149
|
declare const pluginRegistry: PluginRegistry;
|
|
124
150
|
|
|
125
|
-
export { AgentContractLike, type AgentPlugin, type DelegateStep, type GateStep, type GuardrailResult, PluginRegistry, SdkAdapter, type StepCompleteEvent, type StepResult, TaskContext, TaskContractLike, TaskOutcome, type WorkflowContractLike, type WorkflowResult, type WorkflowRunOptions, type WorkflowStep, pluginRegistry, runWorkflow };
|
|
151
|
+
export { AgentContractLike, type AgentPlugin, type DelegateStep, type GateStep, type GuardrailResult, PluginRegistry, type PromptBuilderArgs, PromptBuilderOptions, SdkAdapter, type StepCompleteEvent, type StepResult, TaskContext, TaskContractLike, TaskOutcome, type WorkflowContractLike, type WorkflowResult, type WorkflowRunOptions, type WorkflowStep, pluginRegistry, runWorkflow };
|