@gobing-ai/ts-ai-runner 0.8.4 → 0.8.6

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 CHANGED
@@ -333,7 +333,7 @@ const { args } = getAgentShim('omp').getPromptCommand({
333
333
  // args: ['-p', '', '--session-dir', '.spur/run/r1/...', '-r', 'abc123', '--mode', 'text']
334
334
  ```
335
335
 
336
- **Shim / capability matrix** (probed 2026-09-18; `verifiedAgainst` per row in `getAgentSessionCapability`):
336
+ **Shim / capability matrix** (probed 2026-09-18; `deepseek` re-probed 2026-11-26 on dsh 0.2.2-rc.1; `verifiedAgainst` per row in `getAgentSessionCapability`):
337
337
 
338
338
  | Agent | resumeById | sessionDir | sessionId resume flag | persistentStdin | structuredOutput |
339
339
  | ----- | ---------- | ---------- | --------------------- | --------------- | ---------------- |
@@ -347,7 +347,7 @@ const { args } = getAgentShim('omp').getPromptCommand({
347
347
  | opencode | ✗ (CLI `-s <id>` unwired) | ✗ | degrade → fresh `run` | ✗ | ✓ (`--format json`) |
348
348
  | openclaw | ✗ (CLI `--session-id` unwired) | ✗ | degrade → fresh `agent` | ✗ | ✓ (CLI `--json`; unwired) |
349
349
  | hermes | ✗ (unverified) | ✗ | degrade → fresh `chat` | ✗ | ✗ (unverified) |
350
- | deepseek | ✗ | ✗ | degrade → fresh headless one-shot | ✗ | ✗ |
350
+ | deepseek | ✓ (0.2.2-rc.1) | ✗ (ignored; the store is `$DSH_HOME`) | `--session-id <id>` | ✗ | ✓ (`--json`) |
351
351
  | fm | ✓ | ✓ | `--resume <file>` + `--save-transcript <file>` (file = `<sessionDir>/<sessionId>.json`) | ✗ (`fm chat` is interactive only) | ✗ (`--schema` needs a file; ts-decision-fm surface) |
352
352
 
353
353
  **Claude session discovery:** claude has no session-dir flag and does not accept a caller-chosen
@@ -506,7 +506,7 @@ Agent-specific behavior:
506
506
  | `openclaw` | `openclaw` | 2 | `openclaw health` | `agent --local -m` |
507
507
  | `hermes` | `hermes` | 1 | `hermes doctor` | `chat -q`, `--continue`, `-m` |
508
508
  | `grok` | `grok` | 1 | env/file (`XAI_API_KEY` or `~/.grok/auth.json`) | `-p`, `-c` (resume), `-m`, `--output-format plain\|json` (maps ai-runner `text` → `plain`) |
509
- | `deepseek` | `dsh` | 1 | env-only / `~/.dsh` (no status verb) | `--profile headless <task>`; session/model options degrade to a fresh one-shot (no flags at 0.1.5-rc.1) |
509
+ | `deepseek` | `dsh` | 1 | env-only / `~/.dsh` (no status verb) | `--profile headless`, `--json`, `--session-id <id>`, `--permission-mode workspace-write`, `--approval-policy never`, `--` then the task (0.2.2-rc.1); `continue`/`sessionDir`/`model` degrade to a fresh one-shot |
510
510
  | `fm` | `fm` | 1 | `fm available --model system` | `respond --no-stream`, `-m`, transcript session flags; **text-only** (no file/shell tools — excluded from `TIER1_PRIORITY` auto-selection) |
511
511
 
512
512
  This is the right layer for UI previews, audit logging, and custom launchers.
@@ -1 +1 @@
1
- {"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/agents/shims.ts"],"names":[],"mappings":"AAIA,gEAAgE;AAChE,MAAM,MAAM,SAAS,GACf,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,IAAI,GACJ,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,QAAQ,GACR,KAAK,GACL,MAAM,GACN,UAAU,GACV,IAAI,CAAC;AAEX,0CAA0C;AAC1C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,mEAAmE;AACnE,MAAM,WAAW,WAAW;IACxB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC1B,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IAC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AAC;AAU1E;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAQrE;AAED;mEACmE;AACnE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAMxD"}
@@ -310,10 +310,12 @@ const grokShim = {
310
310
  /**
311
311
  * DeepSeek coding agent (`dsh`, @deepseek-ai/dsh) — tier-1. Boot model is
312
312
  * `dsh --profile <name>`; the headless one-shot surface is the `headless`
313
- * profile: `dsh --profile headless "<task>"` streams reasoning to stderr and
314
- * prints the final assistant message to stdout. At 0.1.5-rc.1 the headless
315
- * app accepts only the positional task and `-h` — no resume/model/mode flags.
316
- * No auth subcommand; credentials resolve via env references / `~/.dsh`.
313
+ * profile. At 0.2.x headless the app accepts `--json` (NDJSON run events),
314
+ * `--session-id` resume, `--permission-mode`, `--approval-policy` and
315
+ * `--add-dir` (`dsh --profile headless --help`, verified on 0.2.2-rc.1).
316
+ * A run exits 0 only when it ends with a completed final `turn/end`, so the
317
+ * exit status alone carries the outcome and the shim parses no events.
318
+ * No auth subcommand; credentials resolve via env references / `$DSH_HOME`.
317
319
  */
318
320
  const dshShim = {
319
321
  name: 'deepseek',
@@ -322,11 +324,22 @@ const dshShim = {
322
324
  getHelpCommand: () => ({ command: 'dsh', args: ['--help'] }),
323
325
  getVersionCommand: () => ({ command: 'dsh', args: ['--version'] }),
324
326
  getPromptCommand: (options) => {
325
- // Always a fresh one-shot headless dispatch: sessionId/sessionDir/
326
- // continue/model degrade silently — the HEADLESS app takes only the
327
- // task + `-h`; no resume/model flags exist at dsh 0.1.5-rc.1.
328
- // mode/workspace/timeoutMs have no dsh flag — best-effort ignored.
329
- return { command: 'dsh', args: ['--profile', 'headless', options.input ?? ''] };
327
+ const args = ['--profile', 'headless'];
328
+ if ((options.mode ?? 'text') === 'json')
329
+ args.push('--json');
330
+ // ADR-047 R5: sessionId is the only session input that emits a flag. `continue`
331
+ // is never mapped — dsh has no last-session flag and guessing an id would break
332
+ // pinned-session precedence; `sessionDir` is ignored (the store is `$DSH_HOME`,
333
+ // an env var an argv-only shim cannot carry).
334
+ if (options.sessionId !== undefined)
335
+ args.push('--session-id', options.sessionId);
336
+ // Non-interactive fixed grant: dsh requires the permission preset (and the
337
+ // approval policy) on every dispatch, resume included. model/workspace/
338
+ // timeoutMs have no dsh flag — best-effort ignored.
339
+ args.push('--permission-mode', 'workspace-write', '--approval-policy', 'never');
340
+ // `--` pins the task as the positional, so a dash-leading prompt is never a flag.
341
+ args.push('--', options.input ?? '');
342
+ return { command: 'dsh', args };
330
343
  },
331
344
  getAuthCommand: () => null,
332
345
  };
@@ -507,14 +520,16 @@ const AGENT_SESSION_CAPABILITY = {
507
520
  verifiedAgainst: 'unverified (CLI not installed)',
508
521
  note: 'CLI absent at verification (2026-09-18) — conservative defaults; `chat --continue` resumes the last session only, no session-dir/stdin/structured-output flags documented',
509
522
  },
510
- // dsh headless has no resume/session flags — fresh-dispatch degrade.
523
+ // dsh 0.2.x headless: `--json` NDJSON events and `--session-id` resume exist; the
524
+ // session store is `$DSH_HOME` (no directory flag) and each run is one task per
525
+ // process (no persistent stdin). Resume needs the same cwd + repeated permission flags.
511
526
  deepseek: {
512
- supportsResumeById: false,
527
+ supportsResumeById: true,
513
528
  supportsSessionDir: false,
514
529
  supportsPersistentStdin: false,
515
- supportsStructuredOutput: false,
516
- verifiedAgainst: '0.1.5-rc.1',
517
- note: 'headless app takes only the task positional and -h at 0.1.5-rc.1 — no resume/session/mode flags; fresh-dispatch degrade',
530
+ supportsStructuredOutput: true,
531
+ verifiedAgainst: '0.2.2-rc.1',
532
+ note: 'sessionDir false: the session store is $DSH_HOME, an env var an argv-only shim cannot set; persistent stdin false: headless runs one task per process; resume requires the same cwd and repeats the permission flags',
518
533
  },
519
534
  fm: {
520
535
  supportsResumeById: true,
@@ -9,6 +9,19 @@ export interface DecisionMaker {
9
9
  questions: Q;
10
10
  model?: string;
11
11
  }): Promise<AnswersFor<Q>>;
12
+ /**
13
+ * `ask` plus the model the backend actually served (P12 R1/R2), or no `servedModel` when the
14
+ * driver cannot report one. Optional: a maker object registered directly need not implement it,
15
+ * and `createDecisionMaker` always does. Validation is identical on both paths.
16
+ */
17
+ askWithMeta?<const Q extends Record<string, Question>>(req: {
18
+ state: DecisionState;
19
+ questions: Q;
20
+ model?: string;
21
+ }): Promise<{
22
+ answers: AnswersFor<Q>;
23
+ servedModel?: string;
24
+ }>;
12
25
  /** Pick one label. Sugar over `ask` with exactly one choice question. */
13
26
  choice<const L extends string>(state: DecisionState, prompt: Desc, labels: Record<L, Desc>): Promise<ChoiceAnswer<L>>;
14
27
  /** Score against a rubric. Sugar over `ask` with exactly one score question. */
@@ -75,9 +88,17 @@ export declare function resolveLayaDriver(options: DecisionMakerOptions, importM
75
88
  export declare function resolveTypesafeDriver(options: DecisionMakerOptions, importModule?: (specifier: string) => Promise<unknown>): Promise<DecisionDriver>;
76
89
  /** @internal Exported for task 0086 R9 branch tests; see {@link resolveLayaDriver}. */
77
90
  export declare function resolveFmDriver(options: DecisionMakerOptions, importModule?: (specifier: string) => Promise<unknown>): Promise<DecisionDriver>;
91
+ /**
92
+ * A maker built by {@link createDecisionMaker}: the optional meta seam is always implemented, so a
93
+ * caller that wants the served model calls it without a presence check. A maker object registered
94
+ * directly (a test double, a foreign implementation) keeps the optional shape.
95
+ */
96
+ export type DecisionMakerWithMeta = DecisionMaker & {
97
+ askWithMeta: NonNullable<DecisionMaker['askWithMeta']>;
98
+ };
78
99
  /**
79
100
  * Build a DecisionMaker. `options.driver` wins when supplied; otherwise `options.backend`
80
101
  * resolves the driver (default `'typesafe'`). The driver is constructed lazily on first use.
81
102
  */
82
- export declare function createDecisionMaker(options?: DecisionMakerOptions): DecisionMaker;
103
+ export declare function createDecisionMaker(options?: DecisionMakerOptions): DecisionMakerWithMeta;
83
104
  //# sourceMappingURL=decision-maker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decision-maker.d.ts","sourceRoot":"","sources":["../../src/decision/decision-maker.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,WAAW,EACd,MAAM,SAAS,CAAC;AAIjB,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE;QAC/C,KAAK,EAAE,aAAa,CAAC;QACrB,SAAS,EAAE,CAAC,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,yEAAyE;IACzE,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACzB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,GACxB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,gFAAgF;IAChF,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1G,wEAAwE;IACxE,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO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AG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAUnE;AAID;;;;GAIG;AACH,wBAAsB,iBAAiB,CACnC,OAAO,EAAE,oBAAoB,EAC7B,YAAY,GAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAoC,GACzF,OAAO,CAAC,cAAc,CAAC,CAuBzB;AAID;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,oBAAoB,EAC7B,YAAY,GAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAoC,GACzF,OAAO,CAAC,cAAc,CAAC,CA4BzB;AAID,uFAAuF;AACvF,wBAAsB,eAAe,CACjC,OAAO,EAAE,oBAAoB,EAC7B,YAAY,GAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAoC,GACzF,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAChD,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,qBAAqB,CAyE7F"}
@@ -124,6 +124,18 @@ export function createDecisionMaker(options = {}) {
124
124
  // Runtime validation above establishes each question/answer correspondence.
125
125
  return answers;
126
126
  };
127
+ const askWithMeta = async (req) => {
128
+ const driver = await getDriver();
129
+ validateQuestions(req.questions);
130
+ // R2: prefer the driver's meta seam and fall back to plain `ask` — the answer validation
131
+ // below is shared, so a driver that cannot report a model behaves exactly as it does today.
132
+ const meta = driver.askWithMeta ? await driver.askWithMeta(req) : { answers: await driver.ask(req) };
133
+ validateAnswers(req.questions, meta.answers);
134
+ // Runtime validation above establishes each question/answer correspondence.
135
+ const answers = meta.answers;
136
+ // Absent, never an explicit undefined: consumers distinguish "no model reported" by absense.
137
+ return meta.servedModel === undefined ? { answers } : { answers, servedModel: meta.servedModel };
138
+ };
127
139
  return {
128
140
  driver: options.driver?.name ?? options.backend ?? 'typesafe',
129
141
  // Only an injected or already-resolved driver is a candidate: running the lazy factory
@@ -133,6 +145,7 @@ export function createDecisionMaker(options = {}) {
133
145
  await (options.driver ?? resolvedDriver)?.dispose?.();
134
146
  },
135
147
  ask,
148
+ askWithMeta,
136
149
  // R4/R5: each sugar method is one `ask` with exactly one `q.*` question,
137
150
  // unwrapping the single answer — no second driver call, no duplicated
138
151
  // request assembly.
@@ -89,6 +89,15 @@ export declare const q: {
89
89
  no?: Desc;
90
90
  }) => NoulQuestion;
91
91
  };
92
+ /**
93
+ * Answers plus the model that actually served them (P12 R3): `servedModel` is what the backend
94
+ * reports it used, which can differ from the requested model under routing. Absent whenever the
95
+ * driver reports none — a fallback, a local process, or an agent CLI with no model identity.
96
+ */
97
+ export interface DecisionAnswersMeta {
98
+ answers: Record<string, Answer>;
99
+ servedModel?: string;
100
+ }
92
101
  /**
93
102
  * The one-method internal seam every backend driver implements. The loose
94
103
  * `Record<string, Answer>` return is narrowed to `AnswersFor<Q>` by a single
@@ -101,6 +110,15 @@ export interface DecisionDriver {
101
110
  questions: Record<string, Question>;
102
111
  model?: string;
103
112
  }): Promise<Record<string, Answer>>;
113
+ /**
114
+ * `ask` plus the served model (P12 R1). Optional and additive: a driver that cannot report a
115
+ * model omits it, and every caller keeps working through `ask` alone.
116
+ */
117
+ askWithMeta?(req: {
118
+ state: DecisionState;
119
+ questions: Record<string, Question>;
120
+ model?: string;
121
+ }): Promise<DecisionAnswersMeta>;
104
122
  /**
105
123
  * Release whatever the driver owns outside the JS heap — a warm worker process, a socket, a
106
124
  * pool. Optional: a driver that owns no such resource omits it. Must be safe to call more than
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/decision/types.ts"],"names":[],"mappings":"AAAA;;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AG,CAAC,GAAG,EAAE;QACL,KAAK,EAAE,aAAa,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,CAAC,GAAG,EAAE;QACd,KAAK,EAAE,aAAa,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACjC;;;;OAIG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/ts-ai-runner",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "@gobing-ai/ts-ai-runner — Coding-agent shims, detection, doctor checks, and prompt execution.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -51,12 +51,12 @@
51
51
  "release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-ai-runner-v<version> && git push --tags' && exit 1"
52
52
  },
53
53
  "dependencies": {
54
- "@gobing-ai/ts-infra": "^0.8.4",
55
- "@gobing-ai/ts-runtime": "^0.8.4"
54
+ "@gobing-ai/ts-infra": "^0.8.6",
55
+ "@gobing-ai/ts-runtime": "^0.8.6"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/bun": "1.4.3",
59
- "@gobing-ai/ts-db": "^0.8.4"
59
+ "@gobing-ai/ts-db": "^0.8.6"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"
@@ -416,10 +416,12 @@ const grokShim: AgentShim = {
416
416
  /**
417
417
  * DeepSeek coding agent (`dsh`, @deepseek-ai/dsh) — tier-1. Boot model is
418
418
  * `dsh --profile <name>`; the headless one-shot surface is the `headless`
419
- * profile: `dsh --profile headless "<task>"` streams reasoning to stderr and
420
- * prints the final assistant message to stdout. At 0.1.5-rc.1 the headless
421
- * app accepts only the positional task and `-h` — no resume/model/mode flags.
422
- * No auth subcommand; credentials resolve via env references / `~/.dsh`.
419
+ * profile. At 0.2.x headless the app accepts `--json` (NDJSON run events),
420
+ * `--session-id` resume, `--permission-mode`, `--approval-policy` and
421
+ * `--add-dir` (`dsh --profile headless --help`, verified on 0.2.2-rc.1).
422
+ * A run exits 0 only when it ends with a completed final `turn/end`, so the
423
+ * exit status alone carries the outcome and the shim parses no events.
424
+ * No auth subcommand; credentials resolve via env references / `$DSH_HOME`.
423
425
  */
424
426
  const dshShim: AgentShim = {
425
427
  name: 'deepseek',
@@ -428,11 +430,20 @@ const dshShim: AgentShim = {
428
430
  getHelpCommand: () => ({ command: 'dsh', args: ['--help'] }),
429
431
  getVersionCommand: () => ({ command: 'dsh', args: ['--version'] }),
430
432
  getPromptCommand: (options) => {
431
- // Always a fresh one-shot headless dispatch: sessionId/sessionDir/
432
- // continue/model degrade silently — the HEADLESS app takes only the
433
- // task + `-h`; no resume/model flags exist at dsh 0.1.5-rc.1.
434
- // mode/workspace/timeoutMs have no dsh flag — best-effort ignored.
435
- return { command: 'dsh', args: ['--profile', 'headless', options.input ?? ''] };
433
+ const args = ['--profile', 'headless'];
434
+ if ((options.mode ?? 'text') === 'json') args.push('--json');
435
+ // ADR-047 R5: sessionId is the only session input that emits a flag. `continue`
436
+ // is never mapped — dsh has no last-session flag and guessing an id would break
437
+ // pinned-session precedence; `sessionDir` is ignored (the store is `$DSH_HOME`,
438
+ // an env var an argv-only shim cannot carry).
439
+ if (options.sessionId !== undefined) args.push('--session-id', options.sessionId);
440
+ // Non-interactive fixed grant: dsh requires the permission preset (and the
441
+ // approval policy) on every dispatch, resume included. model/workspace/
442
+ // timeoutMs have no dsh flag — best-effort ignored.
443
+ args.push('--permission-mode', 'workspace-write', '--approval-policy', 'never');
444
+ // `--` pins the task as the positional, so a dash-leading prompt is never a flag.
445
+ args.push('--', options.input ?? '');
446
+ return { command: 'dsh', args };
436
447
  },
437
448
  getAuthCommand: () => null,
438
449
  };
@@ -630,14 +641,16 @@ const AGENT_SESSION_CAPABILITY: Readonly<Record<AgentName, AgentSessionCapabilit
630
641
  verifiedAgainst: 'unverified (CLI not installed)',
631
642
  note: 'CLI absent at verification (2026-09-18) — conservative defaults; `chat --continue` resumes the last session only, no session-dir/stdin/structured-output flags documented',
632
643
  },
633
- // dsh headless has no resume/session flags — fresh-dispatch degrade.
644
+ // dsh 0.2.x headless: `--json` NDJSON events and `--session-id` resume exist; the
645
+ // session store is `$DSH_HOME` (no directory flag) and each run is one task per
646
+ // process (no persistent stdin). Resume needs the same cwd + repeated permission flags.
634
647
  deepseek: {
635
- supportsResumeById: false,
648
+ supportsResumeById: true,
636
649
  supportsSessionDir: false,
637
650
  supportsPersistentStdin: false,
638
- supportsStructuredOutput: false,
639
- verifiedAgainst: '0.1.5-rc.1',
640
- note: 'headless app takes only the task positional and -h at 0.1.5-rc.1 — no resume/session/mode flags; fresh-dispatch degrade',
651
+ supportsStructuredOutput: true,
652
+ verifiedAgainst: '0.2.2-rc.1',
653
+ note: 'sessionDir false: the session store is $DSH_HOME, an env var an argv-only shim cannot set; persistent stdin false: headless runs one task per process; resume requires the same cwd and repeats the permission flags',
641
654
  },
642
655
  fm: {
643
656
  supportsResumeById: true,
@@ -29,6 +29,16 @@ export interface DecisionMaker {
29
29
  questions: Q;
30
30
  model?: string;
31
31
  }): Promise<AnswersFor<Q>>;
32
+ /**
33
+ * `ask` plus the model the backend actually served (P12 R1/R2), or no `servedModel` when the
34
+ * driver cannot report one. Optional: a maker object registered directly need not implement it,
35
+ * and `createDecisionMaker` always does. Validation is identical on both paths.
36
+ */
37
+ askWithMeta?<const Q extends Record<string, Question>>(req: {
38
+ state: DecisionState;
39
+ questions: Q;
40
+ model?: string;
41
+ }): Promise<{ answers: AnswersFor<Q>; servedModel?: string }>;
32
42
  /** Pick one label. Sugar over `ask` with exactly one choice question. */
33
43
  choice<const L extends string>(
34
44
  state: DecisionState,
@@ -197,11 +207,20 @@ export async function resolveFmDriver(
197
207
  return mod.createFmDriver(options);
198
208
  }
199
209
 
210
+ /**
211
+ * A maker built by {@link createDecisionMaker}: the optional meta seam is always implemented, so a
212
+ * caller that wants the served model calls it without a presence check. A maker object registered
213
+ * directly (a test double, a foreign implementation) keeps the optional shape.
214
+ */
215
+ export type DecisionMakerWithMeta = DecisionMaker & {
216
+ askWithMeta: NonNullable<DecisionMaker['askWithMeta']>;
217
+ };
218
+
200
219
  /**
201
220
  * Build a DecisionMaker. `options.driver` wins when supplied; otherwise `options.backend`
202
221
  * resolves the driver (default `'typesafe'`). The driver is constructed lazily on first use.
203
222
  */
204
- export function createDecisionMaker(options: DecisionMakerOptions = {}): DecisionMaker {
223
+ export function createDecisionMaker(options: DecisionMakerOptions = {}): DecisionMakerWithMeta {
205
224
  let resolvedDriver: DecisionDriver | undefined;
206
225
  const getDriver = async (): Promise<DecisionDriver> => {
207
226
  if (options.driver) return options.driver;
@@ -237,6 +256,23 @@ export function createDecisionMaker(options: DecisionMakerOptions = {}): Decisio
237
256
  return answers as AnswersFor<Q>;
238
257
  };
239
258
 
259
+ const askWithMeta = async <const Q extends Record<string, Question>>(req: {
260
+ state: DecisionState;
261
+ questions: Q;
262
+ model?: string;
263
+ }): Promise<{ answers: AnswersFor<Q>; servedModel?: string }> => {
264
+ const driver = await getDriver();
265
+ validateQuestions(req.questions);
266
+ // R2: prefer the driver's meta seam and fall back to plain `ask` — the answer validation
267
+ // below is shared, so a driver that cannot report a model behaves exactly as it does today.
268
+ const meta = driver.askWithMeta ? await driver.askWithMeta(req) : { answers: await driver.ask(req) };
269
+ validateAnswers(req.questions, meta.answers);
270
+ // Runtime validation above establishes each question/answer correspondence.
271
+ const answers = meta.answers as AnswersFor<Q>;
272
+ // Absent, never an explicit undefined: consumers distinguish "no model reported" by absense.
273
+ return meta.servedModel === undefined ? { answers } : { answers, servedModel: meta.servedModel };
274
+ };
275
+
240
276
  return {
241
277
  driver: options.driver?.name ?? options.backend ?? 'typesafe',
242
278
  // Only an injected or already-resolved driver is a candidate: running the lazy factory
@@ -246,6 +282,7 @@ export function createDecisionMaker(options: DecisionMakerOptions = {}): Decisio
246
282
  await (options.driver ?? resolvedDriver)?.dispose?.();
247
283
  },
248
284
  ask,
285
+ askWithMeta,
249
286
  // R4/R5: each sugar method is one `ask` with exactly one `q.*` question,
250
287
  // unwrapping the single answer — no second driver call, no duplicated
251
288
  // request assembly.
@@ -96,6 +96,16 @@ export const q = {
96
96
  }),
97
97
  };
98
98
 
99
+ /**
100
+ * Answers plus the model that actually served them (P12 R3): `servedModel` is what the backend
101
+ * reports it used, which can differ from the requested model under routing. Absent whenever the
102
+ * driver reports none — a fallback, a local process, or an agent CLI with no model identity.
103
+ */
104
+ export interface DecisionAnswersMeta {
105
+ answers: Record<string, Answer>;
106
+ servedModel?: string;
107
+ }
108
+
99
109
  /**
100
110
  * The one-method internal seam every backend driver implements. The loose
101
111
  * `Record<string, Answer>` return is narrowed to `AnswersFor<Q>` by a single
@@ -108,6 +118,15 @@ export interface DecisionDriver {
108
118
  questions: Record<string, Question>;
109
119
  model?: string;
110
120
  }): Promise<Record<string, Answer>>;
121
+ /**
122
+ * `ask` plus the served model (P12 R1). Optional and additive: a driver that cannot report a
123
+ * model omits it, and every caller keeps working through `ask` alone.
124
+ */
125
+ askWithMeta?(req: {
126
+ state: DecisionState;
127
+ questions: Record<string, Question>;
128
+ model?: string;
129
+ }): Promise<DecisionAnswersMeta>;
111
130
  /**
112
131
  * Release whatever the driver owns outside the JS heap — a warm worker process, a socket, a
113
132
  * pool. Optional: a driver that owns no such resource omits it. Must be safe to call more than