@warble/claude-agent-sdk 0.11.0 → 0.13.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 +5 -2
- package/dist/{chunk-3ON7TSGW.js → chunk-2VDMVARW.js} +1814 -122
- package/dist/chunk-2VDMVARW.js.map +1 -0
- package/dist/cli.js +85 -23
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +743 -209
- package/dist/index.js +53 -3
- package/package.json +4 -4
- package/dist/chunk-3ON7TSGW.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
buildManifest,
|
|
8
8
|
createChatSession,
|
|
9
9
|
discoverClaudeModels,
|
|
10
|
+
dispatch,
|
|
10
11
|
emitAgentModule,
|
|
12
|
+
parseIr,
|
|
11
13
|
parseRenderFlavor,
|
|
14
|
+
parseSlotFlags,
|
|
15
|
+
preflightDispatchAssets,
|
|
12
16
|
prepareDispatch,
|
|
13
|
-
prepareDisplayManifest
|
|
14
|
-
|
|
15
|
-
} from "./chunk-3ON7TSGW.js";
|
|
17
|
+
prepareDisplayManifest
|
|
18
|
+
} from "./chunk-2VDMVARW.js";
|
|
16
19
|
|
|
17
20
|
// src/cli.ts
|
|
18
21
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -21,6 +24,13 @@ import { dirname, join, resolve } from "path";
|
|
|
21
24
|
import { createInterface } from "readline";
|
|
22
25
|
import { parseArgs } from "util";
|
|
23
26
|
import { fileURLToPath } from "url";
|
|
27
|
+
function parseSlotFlagsOrFail(flags) {
|
|
28
|
+
try {
|
|
29
|
+
return parseSlotFlags(flags);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
fail(e instanceof Error ? e.message : String(e));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
function fail(message) {
|
|
25
35
|
process.stderr.write(`error: ${message}
|
|
26
36
|
`);
|
|
@@ -90,7 +100,8 @@ async function main() {
|
|
|
90
100
|
"stream-json": { type: "boolean" },
|
|
91
101
|
resume: { type: "string" },
|
|
92
102
|
timeout: { type: "string" },
|
|
93
|
-
"include-unavailable": { type: "boolean" }
|
|
103
|
+
"include-unavailable": { type: "boolean" },
|
|
104
|
+
slot: { type: "string", multiple: true }
|
|
94
105
|
}
|
|
95
106
|
});
|
|
96
107
|
const [subcommand, irArg, question] = positionals;
|
|
@@ -116,7 +127,15 @@ async function main() {
|
|
|
116
127
|
const flavor = parseRenderFlavor(values["render-flavor"] ?? "programmatic");
|
|
117
128
|
const models = buildModels(values);
|
|
118
129
|
const raw = readFileSync(resolve(irArg), "utf8");
|
|
119
|
-
const common = {
|
|
130
|
+
const common = {
|
|
131
|
+
target,
|
|
132
|
+
flavor,
|
|
133
|
+
models,
|
|
134
|
+
raw,
|
|
135
|
+
irPath: irArg,
|
|
136
|
+
project: values.project,
|
|
137
|
+
slots: parseSlotFlagsOrFail(values.slot ?? [])
|
|
138
|
+
};
|
|
120
139
|
if (subcommand === "emit") {
|
|
121
140
|
return runEmit(common, values.out, Boolean(values.standalone));
|
|
122
141
|
}
|
|
@@ -129,14 +148,17 @@ async function main() {
|
|
|
129
148
|
return runDispatchCmd(common, values, question);
|
|
130
149
|
}
|
|
131
150
|
function runEmit(common, outArg, standalone) {
|
|
132
|
-
const
|
|
151
|
+
const input = {
|
|
152
|
+
slots: common.slots,
|
|
133
153
|
ir: common.raw,
|
|
134
154
|
target: common.target,
|
|
135
155
|
flavor: common.flavor,
|
|
136
156
|
models: common.models,
|
|
137
157
|
irPath: common.irPath,
|
|
138
158
|
...common.project !== void 0 ? { project: common.project } : {}
|
|
139
|
-
}
|
|
159
|
+
};
|
|
160
|
+
const prepared = prepareDispatch(input);
|
|
161
|
+
preflightDispatchAssets(input, prepared);
|
|
140
162
|
for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);
|
|
141
163
|
const outPath = resolve(outArg ?? "agent.ts");
|
|
142
164
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
@@ -155,7 +177,7 @@ function runManifest(common, outArg, includeUnavailable) {
|
|
|
155
177
|
irPath: common.irPath,
|
|
156
178
|
...common.project !== void 0 ? { project: common.project } : {}
|
|
157
179
|
};
|
|
158
|
-
const prepared = includeUnavailable ? prepareDisplayManifest(input) : prepareDispatch(input);
|
|
180
|
+
const prepared = includeUnavailable ? prepareDisplayManifest({ ...input, slots: common.slots }) : prepareDispatch({ ...input, slots: common.slots });
|
|
159
181
|
for (const c of prepared.components) {
|
|
160
182
|
if ("report" in c) printResolutionSummary(common.target, c.id, c.report);
|
|
161
183
|
}
|
|
@@ -183,7 +205,8 @@ async function runDispatchCmd(common, values, question) {
|
|
|
183
205
|
const outDir = resolve(values.out ?? "./run");
|
|
184
206
|
const warbleBin = values["warble-bin"] ?? defaultWarbleBin();
|
|
185
207
|
const title = values.title;
|
|
186
|
-
const
|
|
208
|
+
const input = {
|
|
209
|
+
slots: common.slots,
|
|
187
210
|
ir: common.raw,
|
|
188
211
|
question: question ?? "",
|
|
189
212
|
target: common.target,
|
|
@@ -192,33 +215,60 @@ async function runDispatchCmd(common, values, question) {
|
|
|
192
215
|
irPath: common.irPath,
|
|
193
216
|
...common.project !== void 0 ? { project: common.project } : {},
|
|
194
217
|
...maxTurns !== void 0 ? { maxTurns } : {}
|
|
195
|
-
}
|
|
196
|
-
|
|
218
|
+
};
|
|
219
|
+
const prepared = prepareDispatch(input);
|
|
220
|
+
preflightDispatchAssets(input, prepared);
|
|
197
221
|
for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);
|
|
198
|
-
|
|
199
|
-
|
|
222
|
+
if (dryRun) {
|
|
223
|
+
mkdirSync(outDir, { recursive: true });
|
|
224
|
+
for (const c of prepared.components) {
|
|
200
225
|
const planPath = join(outDir, `${c.node.verb}.plan.json`);
|
|
201
226
|
writeFileSync(
|
|
202
227
|
planPath,
|
|
203
|
-
JSON.stringify({
|
|
228
|
+
JSON.stringify({
|
|
229
|
+
prompt: c.plan.prompt,
|
|
230
|
+
options: c.plan.options,
|
|
231
|
+
meta: c.plan.meta,
|
|
232
|
+
composition: {
|
|
233
|
+
entry: prepared.entries.find((entry) => entry.root === c.id) ?? null,
|
|
234
|
+
dependencies: prepared.dependencies,
|
|
235
|
+
prepared_callees: prepared.preparedCallees.map((callee) => callee.id)
|
|
236
|
+
}
|
|
237
|
+
}, null, 2) + "\n",
|
|
204
238
|
"utf8"
|
|
205
239
|
);
|
|
206
240
|
process.stderr.write(
|
|
207
241
|
`warble-agent-sdk: dry-run \u2014 wrote plan ${planPath} (model=${c.plan.meta.model}, split=${c.plan.meta.split}, render=${c.plan.meta.render.kind}); query() not called.
|
|
208
242
|
`
|
|
209
243
|
);
|
|
210
|
-
continue;
|
|
211
244
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
245
|
+
} else {
|
|
246
|
+
const outcome = await dispatch(input, {
|
|
247
|
+
outDir,
|
|
248
|
+
warbleBin,
|
|
249
|
+
...title ? { title } : {}
|
|
250
|
+
});
|
|
251
|
+
for (const component of outcome.components) {
|
|
252
|
+
process.stderr.write(
|
|
253
|
+
`warble-agent-sdk: ran '${component.id}' \u2192 ${component.result.htmlPath ?? "(no html)"}; ${component.result.denials.length} guardrail denial(s); trace at ${join(outDir, "trace.json")}
|
|
215
254
|
`
|
|
216
|
-
|
|
255
|
+
);
|
|
256
|
+
}
|
|
217
257
|
}
|
|
218
258
|
writeFileSync(
|
|
219
259
|
join(outDir, "capability-report.json"),
|
|
220
260
|
JSON.stringify(
|
|
221
|
-
{
|
|
261
|
+
{
|
|
262
|
+
target: common.target,
|
|
263
|
+
profile: prepared.profile,
|
|
264
|
+
entries: prepared.entries,
|
|
265
|
+
dependencies: prepared.dependencies,
|
|
266
|
+
components: [...prepared.components, ...prepared.preparedCallees].map((c) => ({
|
|
267
|
+
id: c.id,
|
|
268
|
+
role: c.role,
|
|
269
|
+
capabilities: c.report
|
|
270
|
+
}))
|
|
271
|
+
},
|
|
222
272
|
null,
|
|
223
273
|
2
|
|
224
274
|
) + "\n",
|
|
@@ -229,7 +279,8 @@ async function runChatCmd(common, values) {
|
|
|
229
279
|
const outDir = resolve(values.out ?? "./run");
|
|
230
280
|
const warbleBin = values["warble-bin"] ?? defaultWarbleBin();
|
|
231
281
|
const componentId = values.component ?? "answer_query";
|
|
232
|
-
const
|
|
282
|
+
const input = {
|
|
283
|
+
slots: common.slots,
|
|
233
284
|
ir: common.raw,
|
|
234
285
|
target: common.target,
|
|
235
286
|
flavor: common.flavor,
|
|
@@ -237,13 +288,24 @@ async function runChatCmd(common, values) {
|
|
|
237
288
|
irPath: common.irPath,
|
|
238
289
|
componentId,
|
|
239
290
|
...common.project !== void 0 ? { project: common.project } : {}
|
|
240
|
-
}
|
|
291
|
+
};
|
|
292
|
+
const prepared = prepareDispatch(input);
|
|
293
|
+
preflightDispatchAssets(input, prepared);
|
|
241
294
|
const component = prepared.components[0];
|
|
242
295
|
if (!component) fail(`internal error: no component prepared for '${componentId}'`);
|
|
243
296
|
for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);
|
|
244
297
|
mkdirSync(outDir, { recursive: true });
|
|
245
298
|
const resumeSessionId = values.resume;
|
|
246
|
-
const
|
|
299
|
+
const ir = parseIr(common.raw);
|
|
300
|
+
const session = createChatSession(
|
|
301
|
+
component.plan,
|
|
302
|
+
{
|
|
303
|
+
outDir,
|
|
304
|
+
warbleBin,
|
|
305
|
+
assets: { ir: { ...ir, components: [component.node] }, irPath: common.irPath }
|
|
306
|
+
},
|
|
307
|
+
resumeSessionId
|
|
308
|
+
);
|
|
247
309
|
process.stderr.write(
|
|
248
310
|
`warble-agent-sdk: chat \u2014 component '${componentId}'; type a question per line (Ctrl-D to end).
|
|
249
311
|
`
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `warble-agent-sdk` — the Claude Agent SDK back-end CLI.\n *\n * warble-agent-sdk dispatch <ir.json> \"<question>\" [--target …] [--models-config m.yml]\n * [--render-flavor programmatic|prompt] [--out ./run] [--project <dir>]\n * [--strong opus] [--cheap haiku] [--orchestrator sonnet]\n * [--warble-bin <path>] [--max-turns N] [--title <t>] [--dry-run]\n *\n * warble-agent-sdk emit <ir.json> [--out agent.ts] [--standalone] [--target …] [--models-config …]\n * [--render-flavor …] [--project <dir>] [--strong/--cheap/--orchestrator …]\n *\n * warble-agent-sdk manifest <ir.json> [--include-unavailable] [--out manifest.json] [--target …] [--models-config …]\n * [--render-flavor …] [--project <dir>] [--strong/--cheap/--orchestrator …]\n *\n * warble-agent-sdk chat <ir.json> [--project <dir>] [--component answer_query] [--out ./run]\n * [--target …] [--models-config m.yml] [--render-flavor programmatic|prompt] [--warble-bin <path>]\n * [--stream-json] [--resume <session-id>]\n *\n * `chat --stream-json` emits per-step/per-tool NDJSON events (one `WarbleChatEvent`, events.ts, per\n * line) to stdout as each turn runs, ending with a terminal `{\"t\":\"answer\",\"text\":…}` line, instead of\n * the default plain final-answer-text-per-turn output — for a consumer that wants to build a live,\n * expandable work log rather than just the finished text. Every turn also emits a\n * `{\"t\":\"session\",\"id\":…}` line (on success AND on a failed turn) carrying that turn's SDK session id.\n *\n * `--resume <session-id>` seeds a brand-new `chat` process's FIRST turn with a session id captured by\n * an earlier `chat` process (from its `{\"t\":\"session\",…}` line) — lets a caller resume a conversation\n * that a previous process started (e.g. one that ran out of turns), continuing the real SDK\n * conversation instead of re-dispatching a fresh prompt from scratch. Ignored after the first turn:\n * subsequent turns resume from this process's own prior turn, as usual.\n *\n * `dispatch` consumes the SAME `ir.json` a Rust `warble compile` emits and drives the SDK loop\n * in-process (`--dry-run` writes the assembled plan without calling `query()`). `emit` freezes the\n * resolved plan into an importable TS agent module (thin, or `--standalone`). `manifest` runs the\n * same preparation as `emit` (no `question`, no `query()` call) and instead serializes a display\n * manifest — the resolved agents/steps/tiers/capabilities/guardrails for THIS target, structurally\n * identical to the vercel back-end's bundle — so a consumer can source a display from whichever\n * back-end actually runs, instead of always reading the vercel bundle target's output. `chat` opens a\n * multi-turn session (session.ts, G1 — single profile, many turns) over one component, reading\n * questions from stdin line-by-line and resuming the SDK session turn over turn.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport { parseArgs } from \"node:util\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { emitAgentModule } from \"./codegen.js\";\nimport { prepareDisplayManifest, prepareDispatch, type PreparedDispatch } from \"./dispatch.js\";\nimport { DispatchError } from \"./error.js\";\nimport type { WarbleChatEvent } from \"./events.js\";\nimport { buildManifest } from \"./manifest.js\";\nimport { ModelConfig } from \"./models.js\";\nimport { discoverClaudeModels } from \"./model_catalog.js\";\nimport { parseRenderFlavor, type RenderFlavor } from \"./options.js\";\nimport { DispatchSessionError, runDispatch } from \"./run.js\";\nimport { createChatSession } from \"./session.js\";\nimport { type ResolutionReport } from \"./resolve.js\";\nimport { DEFAULT_TARGET } from \"./targets.js\";\n\nfunction fail(message: string): never {\n process.stderr.write(`error: ${message}\\n`);\n process.exit(1);\n}\n\nconst USAGE =\n 'usage: warble-agent-sdk <dispatch|emit|manifest|chat> <ir.json> [\"<question>\"] [options]\\n' +\n \" warble-agent-sdk list-models [--project <dir>] [--timeout <ms>]\";\n\n// `require(\"../package.json\")` resolves relative to *this* file's own location, one directory up —\n// which is the package root in both the dev tree (src/cli.ts → ../package.json) and the published\n// layout (dist/cli.js → ../package.json; package.json ships in every npm package regardless of the\n// \"files\" allowlist). That keeps the reported version tied to the package's real `version` field\n// instead of a literal that could drift from it.\nconst requireFromHere = createRequire(import.meta.url);\n\nfunction packageVersion(): string {\n return (requireFromHere(\"../package.json\") as { version: string }).version;\n}\n\n/** Locate the reference `warble` binary: --warble-bin, else PATH, else this repo's release build. */\nfunction defaultWarbleBin(): string {\n const here = dirname(fileURLToPath(import.meta.url));\n const repoBuilt = resolve(here, \"../../../target/release/warble\");\n return existsSync(repoBuilt) ? repoBuilt : \"warble\";\n}\n\nfunction printResolutionSummary(target: string, id: string, report: ResolutionReport): void {\n process.stderr.write(`warble-agent-sdk: capability resolution for '${target}' (component '${id}'):\\n`);\n for (const e of report) {\n const note = e.note ? ` — ${e.note}` : \"\";\n process.stderr.write(\n ` ${e.capability.padEnd(28)} ${e.outcome.padEnd(12)} (${e.provided_by}, ${e.criticality})${note}\\n`,\n );\n }\n}\n\ninterface CommonArgs {\n target: string;\n flavor: RenderFlavor;\n models: ModelConfig;\n raw: string;\n irPath: string;\n project: string | undefined;\n}\n\nfunction buildModels(values: Record<string, string | boolean | undefined>): ModelConfig {\n const cfgPath = values[\"models-config\"];\n if (typeof cfgPath === \"string\") {\n return ModelConfig.fromYaml(readFileSync(resolve(cfgPath), \"utf8\"));\n }\n return ModelConfig.fromFlags(\n (values.strong as string) ?? \"opus\",\n (values.cheap as string) ?? \"haiku\",\n (values.orchestrator as string) ?? \"sonnet\",\n );\n}\n\nasync function main(): Promise<void> {\n // Handle `--version`/`-V` and `--help`/`-h` up front, before the strict `parseArgs` below —\n // neither is a declared option there, so leaving them for `parseArgs` to see would throw\n // `ERR_PARSE_ARGS_UNKNOWN_OPTION` instead of doing what every other CLI does with them.\n const firstArg = process.argv[2];\n if (firstArg === \"--version\" || firstArg === \"-V\") {\n process.stdout.write(`${packageVersion()}\\n`);\n return;\n }\n if (firstArg === \"--help\" || firstArg === \"-h\") {\n process.stdout.write(`${USAGE}\\n`);\n return;\n }\n\n const { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n target: { type: \"string\" },\n out: { type: \"string\" },\n \"models-config\": { type: \"string\" },\n \"render-flavor\": { type: \"string\" },\n strong: { type: \"string\" },\n cheap: { type: \"string\" },\n orchestrator: { type: \"string\" },\n project: { type: \"string\" },\n \"warble-bin\": { type: \"string\" },\n \"max-turns\": { type: \"string\" },\n title: { type: \"string\" },\n \"dry-run\": { type: \"boolean\" },\n standalone: { type: \"boolean\" },\n component: { type: \"string\" },\n \"stream-json\": { type: \"boolean\" },\n resume: { type: \"string\" },\n timeout: { type: \"string\" },\n \"include-unavailable\": { type: \"boolean\" },\n },\n });\n\n const [subcommand, irArg, question] = positionals;\n if (\n subcommand !== \"dispatch\" &&\n subcommand !== \"emit\" &&\n subcommand !== \"manifest\" &&\n subcommand !== \"chat\" &&\n subcommand !== \"list-models\"\n ) {\n fail(USAGE);\n }\n if (subcommand === \"list-models\") {\n if (irArg !== undefined || question !== undefined) fail(\"list-models does not take an <ir.json> or question\");\n const timeout = values.timeout === undefined ? undefined : Number(values.timeout);\n if (timeout !== undefined && (!Number.isFinite(timeout) || timeout <= 0)) fail(\"--timeout must be a positive number\");\n const catalog = await discoverClaudeModels({\n ...(values.project ? { cwd: values.project } : {}),\n ...(timeout !== undefined ? { timeoutMs: timeout } : {}),\n });\n process.stdout.write(`${JSON.stringify(catalog)}\\n`);\n return;\n }\n if (values.timeout !== undefined) fail(\"--timeout is only supported by list-models\");\n if (values[\"include-unavailable\"] && subcommand !== \"manifest\") fail(\"--include-unavailable is only supported by manifest\");\n if (!irArg) fail(\"missing <ir.json> argument\");\n\n const target = values.target ?? DEFAULT_TARGET;\n const flavor = parseRenderFlavor(values[\"render-flavor\"] ?? \"programmatic\");\n const models = buildModels(values);\n const raw = readFileSync(resolve(irArg), \"utf8\");\n\n const common: CommonArgs = { target, flavor, models, raw, irPath: irArg, project: values.project };\n\n if (subcommand === \"emit\") {\n return runEmit(common, values.out, Boolean(values.standalone));\n }\n if (subcommand === \"manifest\") {\n return runManifest(common, values.out, Boolean(values[\"include-unavailable\"]));\n }\n if (subcommand === \"chat\") {\n return runChatCmd(common, values);\n }\n return runDispatchCmd(common, values, question);\n}\n\nfunction runEmit(common: CommonArgs, outArg: string | undefined, standalone: boolean): void {\n const prepared: PreparedDispatch = prepareDispatch({\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n });\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n const outPath = resolve(outArg ?? \"agent.ts\");\n mkdirSync(dirname(outPath), { recursive: true });\n writeFileSync(outPath, emitAgentModule(prepared, { standalone }), \"utf8\");\n process.stderr.write(\n `warble-agent-sdk: emit — wrote ${outPath} (${prepared.components.length} component(s), ${standalone ? \"standalone\" : \"thin\"}).\\n`,\n );\n}\n\n/**\n * `manifest` — same preparation as `emit` (no `question`, `query()` never called), but instead of\n * freezing an importable agent module, serializes the display manifest (see `manifest.ts`) to stdout\n * or `--out`. Capability resolution summaries still go to stderr so stdout stays pure JSON.\n */\nfunction runManifest(common: CommonArgs, outArg: string | undefined, includeUnavailable: boolean): void {\n const input = {\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n } as const;\n const prepared = includeUnavailable ? prepareDisplayManifest(input) : prepareDispatch(input);\n for (const c of prepared.components) {\n if (\"report\" in c) printResolutionSummary(common.target, c.id, c.report);\n }\n\n const manifest = buildManifest(prepared, common.raw);\n const json = `${JSON.stringify(manifest, null, 2)}\\n`;\n\n if (outArg) {\n const outPath = resolve(outArg);\n mkdirSync(dirname(outPath), { recursive: true });\n writeFileSync(outPath, json, \"utf8\");\n process.stderr.write(\n `warble-agent-sdk: manifest — wrote ${outPath} (${prepared.components.length} agent(s)).\\n`,\n );\n } else {\n process.stdout.write(json);\n }\n}\n\nasync function runDispatchCmd(\n common: CommonArgs,\n values: Record<string, string | boolean | undefined>,\n question: string | undefined,\n): Promise<void> {\n const dryRun = Boolean(values[\"dry-run\"]);\n if (!question && !dryRun) fail('missing \"<question>\" argument (or pass --dry-run)');\n\n const maxTurnsRaw = values[\"max-turns\"];\n const maxTurns = typeof maxTurnsRaw === \"string\" ? Number(maxTurnsRaw) : undefined;\n if (maxTurns !== undefined && !Number.isFinite(maxTurns)) fail(\"--max-turns must be a number\");\n\n const outDir = resolve((values.out as string) ?? \"./run\");\n const warbleBin = (values[\"warble-bin\"] as string) ?? defaultWarbleBin();\n const title = values.title as string | undefined;\n\n const prepared = prepareDispatch({\n ir: common.raw,\n question: question ?? \"\",\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n ...(maxTurns !== undefined ? { maxTurns } : {}),\n });\n\n mkdirSync(outDir, { recursive: true });\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n for (const c of prepared.components) {\n if (dryRun) {\n const planPath = join(outDir, `${c.node.verb}.plan.json`);\n writeFileSync(\n planPath,\n JSON.stringify({ prompt: c.plan.prompt, options: c.plan.options, meta: c.plan.meta }, null, 2) + \"\\n\",\n \"utf8\",\n );\n process.stderr.write(\n `warble-agent-sdk: dry-run — wrote plan ${planPath} (model=${c.plan.meta.model}, split=${c.plan.meta.split}, render=${c.plan.meta.render.kind}); query() not called.\\n`,\n );\n continue;\n }\n const result = await runDispatch(c.plan, { outDir, warbleBin, ...(title ? { title } : {}) });\n process.stderr.write(\n `warble-agent-sdk: ran '${c.node.verb}' → ${result.htmlPath ?? \"(no html)\"}; ` +\n `${result.denials.length} guardrail denial(s); trace at ${join(outDir, \"trace.json\")}\\n`,\n );\n }\n\n writeFileSync(\n join(outDir, \"capability-report.json\"),\n JSON.stringify(\n { target: common.target, components: prepared.components.map((c) => ({ id: c.id, capabilities: c.report })) },\n null,\n 2,\n ) + \"\\n\",\n \"utf8\",\n );\n}\n\n/**\n * `chat` — a multi-turn session (session.ts, G1) over ONE prepared component, reading questions from\n * stdin line-by-line. Each turn's answer is printed to stdout; the SDK session is resumed turn over\n * turn (`ChatSession` handles the `resume: session_id` plumbing). Manual/live use only — not exercised\n * by the offline test suite.\n *\n * `--stream-json` (opt-in): instead of printing the turn's plain final-answer text, stream one\n * `WarbleChatEvent` NDJSON line per event as the turn runs (via `session.ask`'s `onEvent`), followed\n * by a terminal `{\"t\":\"answer\",\"text\":…}` line. Without the flag, behavior is byte-for-byte unchanged\n * from before this option existed.\n */\nasync function runChatCmd(\n common: CommonArgs,\n values: Record<string, string | boolean | undefined>,\n): Promise<void> {\n const outDir = resolve((values.out as string) ?? \"./run\");\n const warbleBin = (values[\"warble-bin\"] as string) ?? defaultWarbleBin();\n const componentId = (values.component as string) ?? \"answer_query\";\n\n // Scoped to `componentId`: only its own required capabilities are resolved, so a *different*\n // component's unmet requirements (e.g. a sibling gated-tool with no approval channel wired on\n // this target) can never block dispatching this one. See `DispatchInput.componentId`.\n const prepared = prepareDispatch({\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n componentId,\n ...(common.project !== undefined ? { project: common.project } : {}),\n });\n\n // `prepareDispatch` with `componentId` set either returns exactly this one component or throws\n // (caught by `main().catch()` below) — this is a defensive invariant check, not a reachable\n // \"not found\" path; that path's error text now comes from `prepareDispatch` itself.\n const component = prepared.components[0];\n if (!component) fail(`internal error: no component prepared for '${componentId}'`);\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n mkdirSync(outDir, { recursive: true });\n const resumeSessionId = values.resume as string | undefined;\n const session = createChatSession(component.plan, { outDir, warbleBin }, resumeSessionId);\n\n process.stderr.write(\n `warble-agent-sdk: chat — component '${componentId}'; type a question per line (Ctrl-D to end).\\n`,\n );\n\n const streamJson = Boolean(values[\"stream-json\"]);\n const onEvent = streamJson\n ? (event: WarbleChatEvent): void => {\n process.stdout.write(`${JSON.stringify(event)}\\n`);\n }\n : undefined;\n\n const emitSession = (id: string | null): void => {\n if (!streamJson) return;\n const sessionEvent: WarbleChatEvent = { t: \"session\", id };\n process.stdout.write(`${JSON.stringify(sessionEvent)}\\n`);\n };\n\n const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });\n for await (const line of rl) {\n const question = line.trim();\n if (!question) continue;\n let turn;\n try {\n turn = await session.ask(question, onEvent ? { onEvent } : {});\n } catch (err) {\n // A failed turn (e.g. error_max_turns) still surfaces its session id, when the SDK's result\n // message carried one, so a caller can resume this same conversation instead of starting over.\n emitSession(err instanceof DispatchSessionError ? err.sessionId : null);\n throw err;\n }\n emitSession(turn.sessionId);\n if (streamJson) {\n const answerEvent: WarbleChatEvent = { t: \"answer\", text: turn.finalText };\n process.stdout.write(`${JSON.stringify(answerEvent)}\\n`);\n } else {\n process.stdout.write(`${turn.finalText}\\n`);\n }\n }\n}\n\nmain().catch((e: unknown) => {\n if (e instanceof DispatchError) fail(e.message);\n fail(e instanceof Error ? (e.stack ?? e.message) : String(e));\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,SAAS,MAAM,eAAe;AACvC,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAe9B,SAAS,KAAK,SAAwB;AACpC,UAAQ,OAAO,MAAM,UAAU,OAAO;AAAA,CAAI;AAC1C,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,QACJ;AAQF,IAAM,kBAAkB,cAAc,YAAY,GAAG;AAErD,SAAS,iBAAyB;AAChC,SAAQ,gBAAgB,iBAAiB,EAA0B;AACrE;AAGA,SAAS,mBAA2B;AAClC,QAAM,OAAO,QAAQ,cAAc,YAAY,GAAG,CAAC;AACnD,QAAM,YAAY,QAAQ,MAAM,gCAAgC;AAChE,SAAO,WAAW,SAAS,IAAI,YAAY;AAC7C;AAEA,SAAS,uBAAuB,QAAgB,IAAY,QAAgC;AAC1F,UAAQ,OAAO,MAAM,gDAAgD,MAAM,iBAAiB,EAAE;AAAA,CAAO;AACrG,aAAW,KAAK,QAAQ;AACtB,UAAM,OAAO,EAAE,OAAO,WAAM,EAAE,IAAI,KAAK;AACvC,YAAQ,OAAO;AAAA,MACb,KAAK,EAAE,WAAW,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,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AC,CAAC;AAAA,IAC/D,SAAS,KAAK;AAGZ,kBAAY,eAAe,uBAAuB,IAAI,YAAY,IAAI;AACtE,YAAM;AAAA,IACR;AACA,gBAAY,KAAK,SAAS;AAC1B,QAAI,YAAY;AACd,YAAM,cAA+B,EAAE,GAAG,UAAU,MAAM,KAAK,UAAU;AACzE,cAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,WAAW,CAAC;AAAA,CAAI;AAAA,IACzD,OAAO;AACL,cAAQ,OAAO,MAAM,GAAG,KAAK,SAAS;AAAA,CAAI;AAAA,IAC5C;AAAA,EACF;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,MAAe;AAC3B,MAAI,aAAa,cAAe,MAAK,EAAE,OAAO;AAC9C,OAAK,aAAa,QAAS,EAAE,SAAS,EAAE,UAAW,OAAO,CAAC,CAAC;AAC9D,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `warble-agent-sdk` — the Claude Agent SDK back-end CLI.\n *\n * warble-agent-sdk dispatch <ir.json> \"<question>\" [--target …] [--models-config m.yml]\n * [--render-flavor programmatic|prompt] [--out ./run] [--project <dir>]\n * [--strong opus] [--cheap haiku] [--orchestrator sonnet]\n * [--warble-bin <path>] [--max-turns N] [--title <t>] [--dry-run]\n *\n * warble-agent-sdk emit <ir.json> [--out agent.ts] [--standalone] [--target …] [--models-config …]\n * [--render-flavor …] [--project <dir>] [--strong/--cheap/--orchestrator …]\n *\n * warble-agent-sdk manifest <ir.json> [--include-unavailable] [--out manifest.json] [--target …] [--models-config …]\n * [--render-flavor …] [--project <dir>] [--strong/--cheap/--orchestrator …]\n *\n * warble-agent-sdk chat <ir.json> [--project <dir>] [--component answer_query] [--out ./run]\n * [--target …] [--models-config m.yml] [--render-flavor programmatic|prompt] [--warble-bin <path>]\n * [--stream-json] [--resume <session-id>]\n *\n * `--slot NAME=VARIANT` fills a named prompt slot with that variant; `--slot NAME=` removes a slot\n * whose condition does not hold. Repeatable, accepted by every subcommand, and mirroring the `warble`\n * CLI's flag of the same name. A slot nobody names takes its declared default — except one carrying\n * a `present_when` condition, which is refused when unanswered on any path whose text reaches a\n * model, because shipping wording for something that may have been withheld is worse than shipping\n * none. `manifest` is a display and renders such a default instead of refusing.\n *\n * `chat --stream-json` emits per-step/per-tool NDJSON events (one `WarbleChatEvent`, events.ts, per\n * line) to stdout as each turn runs, ending with a terminal `{\"t\":\"answer\",\"text\":…}` line, instead of\n * the default plain final-answer-text-per-turn output — for a consumer that wants to build a live,\n * expandable work log rather than just the finished text. Every turn also emits a\n * `{\"t\":\"session\",\"id\":…}` line (on success AND on a failed turn) carrying that turn's SDK session id.\n *\n * `--resume <session-id>` seeds a brand-new `chat` process's FIRST turn with a session id captured by\n * an earlier `chat` process (from its `{\"t\":\"session\",…}` line) — lets a caller resume a conversation\n * that a previous process started (e.g. one that ran out of turns), continuing the real SDK\n * conversation instead of re-dispatching a fresh prompt from scratch. Ignored after the first turn:\n * subsequent turns resume from this process's own prior turn, as usual.\n *\n * `dispatch` consumes the SAME `ir.json` a Rust `warble compile` emits and drives the SDK loop\n * in-process (`--dry-run` writes the assembled plan without calling `query()`). `emit` freezes the\n * resolved plan into an importable TS agent module (thin, or `--standalone`). `manifest` runs the\n * same preparation as `emit` (no `question`, no `query()` call) and instead serializes a display\n * manifest — the resolved agents/steps/tiers/capabilities/guardrails for THIS target, structurally\n * identical to the vercel back-end's bundle — so a consumer can source a display from whichever\n * back-end actually runs, instead of always reading the vercel bundle target's output. `chat` opens a\n * multi-turn session (session.ts, G1 — single profile, many turns) over one component, reading\n * questions from stdin line-by-line and resuming the SDK session turn over turn.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport { parseArgs } from \"node:util\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { emitAgentModule } from \"./codegen.js\";\nimport {\n dispatch,\n preflightDispatchAssets,\n prepareDisplayManifest,\n prepareDispatch,\n type DispatchInput,\n type PreparedDispatch,\n} from \"./dispatch.js\";\nimport { parseSlotFlags } from \"./slots.js\";\nimport type { SlotSupply } from \"./slots.js\";\nimport { DispatchError } from \"./error.js\";\nimport type { WarbleChatEvent } from \"./events.js\";\nimport { buildManifest } from \"./manifest.js\";\nimport { parseIr } from \"./ir.js\";\nimport { ModelConfig } from \"./models.js\";\nimport { discoverClaudeModels } from \"./model_catalog.js\";\nimport { parseRenderFlavor, type RenderFlavor } from \"./options.js\";\nimport { DispatchSessionError } from \"./run.js\";\nimport { createChatSession } from \"./session.js\";\nimport { type ResolutionReport } from \"./resolve.js\";\nimport { DEFAULT_TARGET } from \"./targets.js\";\n\n/** `parseSlotFlags` throws; this CLI reports a bad flag as a usage failure instead. */\nfunction parseSlotFlagsOrFail(flags: readonly string[]): SlotSupply {\n try {\n return parseSlotFlags(flags);\n } catch (e) {\n fail(e instanceof Error ? e.message : String(e));\n }\n}\n\nfunction fail(message: string): never {\n process.stderr.write(`error: ${message}\\n`);\n process.exit(1);\n}\n\nconst USAGE =\n 'usage: warble-agent-sdk <dispatch|emit|manifest|chat> <ir.json> [\"<question>\"] [options]\\n' +\n \" warble-agent-sdk list-models [--project <dir>] [--timeout <ms>]\";\n\n// `require(\"../package.json\")` resolves relative to *this* file's own location, one directory up —\n// which is the package root in both the dev tree (src/cli.ts → ../package.json) and the published\n// layout (dist/cli.js → ../package.json; package.json ships in every npm package regardless of the\n// \"files\" allowlist). That keeps the reported version tied to the package's real `version` field\n// instead of a literal that could drift from it.\nconst requireFromHere = createRequire(import.meta.url);\n\nfunction packageVersion(): string {\n return (requireFromHere(\"../package.json\") as { version: string }).version;\n}\n\n/** Locate the reference `warble` binary: --warble-bin, else PATH, else this repo's release build. */\nfunction defaultWarbleBin(): string {\n const here = dirname(fileURLToPath(import.meta.url));\n const repoBuilt = resolve(here, \"../../../target/release/warble\");\n return existsSync(repoBuilt) ? repoBuilt : \"warble\";\n}\n\nfunction printResolutionSummary(target: string, id: string, report: ResolutionReport): void {\n process.stderr.write(`warble-agent-sdk: capability resolution for '${target}' (component '${id}'):\\n`);\n for (const e of report) {\n const note = e.note ? ` — ${e.note}` : \"\";\n process.stderr.write(\n ` ${e.capability.padEnd(28)} ${e.outcome.padEnd(12)} (${e.provided_by}, ${e.criticality})${note}\\n`,\n );\n }\n}\n\ninterface CommonArgs {\n target: string;\n flavor: RenderFlavor;\n models: ModelConfig;\n raw: string;\n irPath: string;\n project: string | undefined;\n /** The host's slot table, from `--slot`. Empty when none was given. */\n slots: SlotSupply;\n}\n\nfunction buildModels(values: Record<string, string | string[] | boolean | undefined>): ModelConfig {\n const cfgPath = values[\"models-config\"];\n if (typeof cfgPath === \"string\") {\n return ModelConfig.fromYaml(readFileSync(resolve(cfgPath), \"utf8\"));\n }\n return ModelConfig.fromFlags(\n (values.strong as string) ?? \"opus\",\n (values.cheap as string) ?? \"haiku\",\n (values.orchestrator as string) ?? \"sonnet\",\n );\n}\n\nasync function main(): Promise<void> {\n // Handle `--version`/`-V` and `--help`/`-h` up front, before the strict `parseArgs` below —\n // neither is a declared option there, so leaving them for `parseArgs` to see would throw\n // `ERR_PARSE_ARGS_UNKNOWN_OPTION` instead of doing what every other CLI does with them.\n const firstArg = process.argv[2];\n if (firstArg === \"--version\" || firstArg === \"-V\") {\n process.stdout.write(`${packageVersion()}\\n`);\n return;\n }\n if (firstArg === \"--help\" || firstArg === \"-h\") {\n process.stdout.write(`${USAGE}\\n`);\n return;\n }\n\n const { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n target: { type: \"string\" },\n out: { type: \"string\" },\n \"models-config\": { type: \"string\" },\n \"render-flavor\": { type: \"string\" },\n strong: { type: \"string\" },\n cheap: { type: \"string\" },\n orchestrator: { type: \"string\" },\n project: { type: \"string\" },\n \"warble-bin\": { type: \"string\" },\n \"max-turns\": { type: \"string\" },\n title: { type: \"string\" },\n \"dry-run\": { type: \"boolean\" },\n standalone: { type: \"boolean\" },\n component: { type: \"string\" },\n \"stream-json\": { type: \"boolean\" },\n resume: { type: \"string\" },\n timeout: { type: \"string\" },\n \"include-unavailable\": { type: \"boolean\" },\n slot: { type: \"string\", multiple: true },\n },\n });\n\n\n\n const [subcommand, irArg, question] = positionals;\n if (\n subcommand !== \"dispatch\" &&\n subcommand !== \"emit\" &&\n subcommand !== \"manifest\" &&\n subcommand !== \"chat\" &&\n subcommand !== \"list-models\"\n ) {\n fail(USAGE);\n }\n if (subcommand === \"list-models\") {\n if (irArg !== undefined || question !== undefined) fail(\"list-models does not take an <ir.json> or question\");\n const timeout = values.timeout === undefined ? undefined : Number(values.timeout);\n if (timeout !== undefined && (!Number.isFinite(timeout) || timeout <= 0)) fail(\"--timeout must be a positive number\");\n const catalog = await discoverClaudeModels({\n ...(values.project ? { cwd: values.project } : {}),\n ...(timeout !== undefined ? { timeoutMs: timeout } : {}),\n });\n process.stdout.write(`${JSON.stringify(catalog)}\\n`);\n return;\n }\n if (values.timeout !== undefined) fail(\"--timeout is only supported by list-models\");\n if (values[\"include-unavailable\"] && subcommand !== \"manifest\") fail(\"--include-unavailable is only supported by manifest\");\n if (!irArg) fail(\"missing <ir.json> argument\");\n\n const target = values.target ?? DEFAULT_TARGET;\n const flavor = parseRenderFlavor(values[\"render-flavor\"] ?? \"programmatic\");\n const models = buildModels(values);\n const raw = readFileSync(resolve(irArg), \"utf8\");\n\n // Parsed once and carried on CommonArgs, so every subcommand that builds prompts gets the same\n // table. Without this the seam would be reachable only by importing the library, and a profile\n // with a conditional slot could not be run through this CLI at all — it would always refuse for\n // want of an answer.\n const common: CommonArgs = {\n target,\n flavor,\n models,\n raw,\n irPath: irArg,\n project: values.project,\n slots: parseSlotFlagsOrFail(values.slot ?? []),\n };\n\n if (subcommand === \"emit\") {\n return runEmit(common, values.out, Boolean(values.standalone));\n }\n if (subcommand === \"manifest\") {\n return runManifest(common, values.out, Boolean(values[\"include-unavailable\"]));\n }\n if (subcommand === \"chat\") {\n return runChatCmd(common, values);\n }\n return runDispatchCmd(common, values, question);\n}\n\nfunction runEmit(common: CommonArgs, outArg: string | undefined, standalone: boolean): void {\n const input: DispatchInput = {\n slots: common.slots,\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n };\n const prepared: PreparedDispatch = prepareDispatch(input);\n preflightDispatchAssets(input, prepared);\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n const outPath = resolve(outArg ?? \"agent.ts\");\n mkdirSync(dirname(outPath), { recursive: true });\n writeFileSync(outPath, emitAgentModule(prepared, { standalone }), \"utf8\");\n process.stderr.write(\n `warble-agent-sdk: emit — wrote ${outPath} (${prepared.components.length} component(s), ${standalone ? \"standalone\" : \"thin\"}).\\n`,\n );\n}\n\n/**\n * `manifest` — same preparation as `emit` (no `question`, `query()` never called), but instead of\n * freezing an importable agent module, serializes the display manifest (see `manifest.ts`) to stdout\n * or `--out`. Capability resolution summaries still go to stderr so stdout stays pure JSON.\n */\nfunction runManifest(common: CommonArgs, outArg: string | undefined, includeUnavailable: boolean): void {\n const input = {\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n } as const;\n const prepared = includeUnavailable ? prepareDisplayManifest({ ...input, slots: common.slots }) : prepareDispatch({ ...input, slots: common.slots });\n for (const c of prepared.components) {\n if (\"report\" in c) printResolutionSummary(common.target, c.id, c.report);\n }\n\n const manifest = buildManifest(prepared, common.raw);\n const json = `${JSON.stringify(manifest, null, 2)}\\n`;\n\n if (outArg) {\n const outPath = resolve(outArg);\n mkdirSync(dirname(outPath), { recursive: true });\n writeFileSync(outPath, json, \"utf8\");\n process.stderr.write(\n `warble-agent-sdk: manifest — wrote ${outPath} (${prepared.components.length} agent(s)).\\n`,\n );\n } else {\n process.stdout.write(json);\n }\n}\n\nasync function runDispatchCmd(\n common: CommonArgs,\n values: Record<string, string | string[] | boolean | undefined>,\n question: string | undefined,\n): Promise<void> {\n const dryRun = Boolean(values[\"dry-run\"]);\n if (!question && !dryRun) fail('missing \"<question>\" argument (or pass --dry-run)');\n\n const maxTurnsRaw = values[\"max-turns\"];\n const maxTurns = typeof maxTurnsRaw === \"string\" ? Number(maxTurnsRaw) : undefined;\n if (maxTurns !== undefined && !Number.isFinite(maxTurns)) fail(\"--max-turns must be a number\");\n\n const outDir = resolve((values.out as string) ?? \"./run\");\n const warbleBin = (values[\"warble-bin\"] as string) ?? defaultWarbleBin();\n const title = values.title as string | undefined;\n\n const input: DispatchInput = {\n slots: common.slots,\n ir: common.raw,\n question: question ?? \"\",\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n ...(common.project !== undefined ? { project: common.project } : {}),\n ...(maxTurns !== undefined ? { maxTurns } : {}),\n };\n const prepared = prepareDispatch(input);\n preflightDispatchAssets(input, prepared);\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n if (dryRun) {\n mkdirSync(outDir, { recursive: true });\n for (const c of prepared.components) {\n const planPath = join(outDir, `${c.node.verb}.plan.json`);\n writeFileSync(\n planPath,\n JSON.stringify({\n prompt: c.plan.prompt,\n options: c.plan.options,\n meta: c.plan.meta,\n composition: {\n entry: prepared.entries.find((entry) => entry.root === c.id) ?? null,\n dependencies: prepared.dependencies,\n prepared_callees: prepared.preparedCallees.map((callee) => callee.id),\n },\n }, null, 2) + \"\\n\",\n \"utf8\",\n );\n process.stderr.write(\n `warble-agent-sdk: dry-run — wrote plan ${planPath} (model=${c.plan.meta.model}, split=${c.plan.meta.split}, render=${c.plan.meta.render.kind}); query() not called.\\n`,\n );\n }\n } else {\n const outcome = await dispatch(input, {\n outDir,\n warbleBin,\n ...(title ? { title } : {}),\n });\n for (const component of outcome.components) {\n process.stderr.write(\n `warble-agent-sdk: ran '${component.id}' → ${component.result.htmlPath ?? \"(no html)\"}; ` +\n `${component.result.denials.length} guardrail denial(s); trace at ${join(outDir, \"trace.json\")}\\n`,\n );\n }\n }\n\n writeFileSync(\n join(outDir, \"capability-report.json\"),\n JSON.stringify(\n {\n target: common.target,\n profile: prepared.profile,\n entries: prepared.entries,\n dependencies: prepared.dependencies,\n components: [...prepared.components, ...prepared.preparedCallees].map((c) => ({\n id: c.id,\n role: c.role,\n capabilities: c.report,\n })),\n },\n null,\n 2,\n ) + \"\\n\",\n \"utf8\",\n );\n}\n\n/**\n * `chat` — a multi-turn session (session.ts, G1) over ONE prepared component, reading questions from\n * stdin line-by-line. Each turn's answer is printed to stdout; the SDK session is resumed turn over\n * turn (`ChatSession` handles the `resume: session_id` plumbing). Manual/live use only — not exercised\n * by the offline test suite.\n *\n * `--stream-json` (opt-in): instead of printing the turn's plain final-answer text, stream one\n * `WarbleChatEvent` NDJSON line per event as the turn runs (via `session.ask`'s `onEvent`), followed\n * by a terminal `{\"t\":\"answer\",\"text\":…}` line. Without the flag, behavior is byte-for-byte unchanged\n * from before this option existed.\n */\nasync function runChatCmd(\n common: CommonArgs,\n values: Record<string, string | string[] | boolean | undefined>,\n): Promise<void> {\n const outDir = resolve((values.out as string) ?? \"./run\");\n const warbleBin = (values[\"warble-bin\"] as string) ?? defaultWarbleBin();\n const componentId = (values.component as string) ?? \"answer_query\";\n\n // Scoped to `componentId`: only its own required capabilities are resolved, so a *different*\n // component's unmet requirements (e.g. a sibling gated-tool with no approval channel wired on\n // this target) can never block dispatching this one. See `DispatchInput.componentId`.\n const input: DispatchInput = {\n slots: common.slots,\n ir: common.raw,\n target: common.target,\n flavor: common.flavor,\n models: common.models,\n irPath: common.irPath,\n componentId,\n ...(common.project !== undefined ? { project: common.project } : {}),\n };\n const prepared = prepareDispatch(input);\n preflightDispatchAssets(input, prepared);\n\n // `prepareDispatch` with `componentId` set either returns exactly this one component or throws\n // (caught by `main().catch()` below) — this is a defensive invariant check, not a reachable\n // \"not found\" path; that path's error text now comes from `prepareDispatch` itself.\n const component = prepared.components[0];\n if (!component) fail(`internal error: no component prepared for '${componentId}'`);\n for (const c of prepared.components) printResolutionSummary(common.target, c.id, c.report);\n\n mkdirSync(outDir, { recursive: true });\n const resumeSessionId = values.resume as string | undefined;\n const ir = parseIr(common.raw);\n const session = createChatSession(\n component.plan,\n {\n outDir,\n warbleBin,\n assets: { ir: { ...ir, components: [component.node] }, irPath: common.irPath },\n },\n resumeSessionId,\n );\n\n process.stderr.write(\n `warble-agent-sdk: chat — component '${componentId}'; type a question per line (Ctrl-D to end).\\n`,\n );\n\n const streamJson = Boolean(values[\"stream-json\"]);\n const onEvent = streamJson\n ? (event: WarbleChatEvent): void => {\n process.stdout.write(`${JSON.stringify(event)}\\n`);\n }\n : undefined;\n\n const emitSession = (id: string | null): void => {\n if (!streamJson) return;\n const sessionEvent: WarbleChatEvent = { t: \"session\", id };\n process.stdout.write(`${JSON.stringify(sessionEvent)}\\n`);\n };\n\n const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });\n for await (const line of rl) {\n const question = line.trim();\n if (!question) continue;\n let turn;\n try {\n turn = await session.ask(question, onEvent ? { onEvent } : {});\n } catch (err) {\n // A failed turn (e.g. error_max_turns) still surfaces its session id, when the SDK's result\n // message carried one, so a caller can resume this same conversation instead of starting over.\n emitSession(err instanceof DispatchSessionError ? err.sessionId : null);\n throw err;\n }\n emitSession(turn.sessionId);\n if (streamJson) {\n const answerEvent: WarbleChatEvent = { t: \"answer\", text: turn.finalText };\n process.stdout.write(`${JSON.stringify(answerEvent)}\\n`);\n } else {\n process.stdout.write(`${turn.finalText}\\n`);\n }\n }\n}\n\nmain().catch((e: unknown) => {\n if (e instanceof DispatchError) fail(e.message);\n fail(e instanceof Error ? (e.stack ?? e.message) : String(e));\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,qBAAqB;AAC9B,SAAS,SAAS,MAAM,eAAe;AACvC,SAAS,uBAAu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