@jini-ai/agent-runtime 0.6.23 → 0.7.1

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/agent-protocol/acp/models.js +1 -1
  3. package/dist/agent-protocol/acp/session.js +1 -1
  4. package/dist/agent-protocol/core/json-line-stream.d.ts +10 -20
  5. package/dist/agent-protocol/core/json-line-stream.js +39 -27
  6. package/dist/agent-protocol/pi-rpc/session.js +1 -1
  7. package/dist/auth.js +1 -1
  8. package/dist/claude-stream.js +8 -19
  9. package/dist/core/bounded-line-stream.d.ts +17 -0
  10. package/dist/core/bounded-line-stream.js +49 -0
  11. package/dist/core/model-discovery-shared.d.ts +25 -1
  12. package/dist/core/model-discovery-shared.js +47 -0
  13. package/dist/defs/aider.d.ts +1 -0
  14. package/dist/defs/aider.js +1 -0
  15. package/dist/defs/claude.d.ts +1 -0
  16. package/dist/defs/claude.js +1 -0
  17. package/dist/defs/codex.js +6 -4
  18. package/dist/defs/pi.d.ts +1 -0
  19. package/dist/defs/pi.js +1 -0
  20. package/dist/defs/shared.d.ts +2 -3
  21. package/dist/defs/shared.js +2 -23
  22. package/dist/detection.d.ts +11 -2
  23. package/dist/detection.js +35 -5
  24. package/dist/json-event-stream.js +8 -14
  25. package/dist/model-discovery-native.d.ts +1 -0
  26. package/dist/model-discovery.d.ts +6 -3
  27. package/dist/model-discovery.js +8 -3
  28. package/dist/models.js +2 -27
  29. package/dist/native-tool-policy.d.ts +59 -3
  30. package/dist/native-tool-policy.js +46 -10
  31. package/dist/providers/google-messages.d.ts +2 -1
  32. package/dist/providers/google-messages.js +10 -5
  33. package/dist/providers/google-schema.js +18 -0
  34. package/dist/providers/model-catalog.js +8 -4
  35. package/dist/qoder-stream.js +8 -15
  36. package/dist/types.d.ts +7 -1
  37. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## 0.7.1
2
+
3
+ ### Patch Changes
4
+
5
+ - Updated dependencies [873f10c]
6
+ - @jini-ai/core@0.7.1
7
+ - @jini-ai/integrations@0.7.1
8
+ - @jini-ai/oauth@0.7.1
9
+ - @jini-ai/platform@0.7.1
10
+ - @jini-ai/protocol@0.7.1
11
+
12
+ ## 0.7.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [ed7901c]
17
+ - Updated dependencies [8fe045b]
18
+ - Updated dependencies [c393010]
19
+ - Updated dependencies [46039c5]
20
+ - Updated dependencies [ce9e9dc]
21
+ - Updated dependencies [1838089]
22
+ - Updated dependencies [b2017d9]
23
+ - Updated dependencies [41ff2ff]
24
+ - Updated dependencies [63e11c5]
25
+ - Updated dependencies [a266ba8]
26
+ - Updated dependencies [27063ef]
27
+ - Updated dependencies [27063ef]
28
+ - Updated dependencies [6ab1d81]
29
+ - Updated dependencies [f1e5364]
30
+ - Updated dependencies [6ab1d81]
31
+ - Updated dependencies [50f6e4c]
32
+ - Updated dependencies [699b478]
33
+ - Updated dependencies [39cf677]
34
+ - @jini-ai/integrations@0.7.0
35
+ - @jini-ai/core@0.7.0
36
+ - @jini-ai/platform@0.7.0
37
+ - @jini-ai/oauth@0.7.0
38
+ - @jini-ai/protocol@0.7.0
39
+
1
40
  ## 0.6.23
2
41
 
3
42
  - Security hardening.
@@ -277,7 +277,7 @@ export async function detectAcpModels(requiredArgs, optionalArgs = {}) {
277
277
  const models = normalizeModels({ models: result.models, defaultModelOption: defaultModelOption }, { configOptions: result.configOptions });
278
278
  finish(resolve, models);
279
279
  };
280
- const parser = createJsonLineStream({ onMessage: ({ message: raw }) => {
280
+ const parser = createJsonLineStream({ onError: error => fail(error.message), onMessage: ({ message: raw }) => {
281
281
  const obj = asObject(raw);
282
282
  const rpcErr = rpcErrorMessage(raw);
283
283
  if (rpcErr) {
@@ -970,7 +970,7 @@ export function attachAcpSession(requiredArgs, optionalArgs = {}) {
970
970
  mcpServers,
971
971
  envFormat,
972
972
  };
973
- const parser = createJsonLineStream({ onMessage: ({ message: raw, rawLine }) => {
973
+ const parser = createJsonLineStream({ onError: error => fail(error.message), onMessage: ({ message: raw, rawLine }) => {
974
974
  if (aborted || finished)
975
975
  return;
976
976
  resetStageTimer('response');
@@ -1,17 +1,3 @@
1
- /** @module agent-protocol/core/json-line-stream
2
- * Streaming JSON-line parser that reassembles pretty-printed and multiline
3
- * JSON-RPC messages across chunk boundaries. Shared transport used by both the
4
- * acp/ and pi-rpc/ protocol adapters; this file has no dependencies on any
5
- * other agent-protocol sibling.
6
- *
7
- * Module layout: `createJsonLineStream` owns exactly one piece of state that
8
- * doesn't need to be exported — the raw `buffer` a chunk gets split into
9
- * lines from, which is plain string-splitting with no decision logic worth
10
- * testing in isolation. Everything it delegates to (line handling, the
11
- * multiline-JSON accumulator, and `classifyJsonCandidate`'s scan) is real
12
- * decision logic, so it is hoisted to module level and exported, taking its
13
- * state as an explicit first argument rather than reading it off a closure.
14
- */
15
1
  export interface JsonLineAccumulatorState {
16
2
  pendingJson: string;
17
3
  pendingJsonLineCount: number;
@@ -23,32 +9,36 @@ export declare function emitJsonLine(candidate: string, onMessage: (requiredArgs
23
9
  export declare function continuePendingJsonLine(state: JsonLineAccumulatorState, trimmed: string, onMessage: (requiredArgs: {
24
10
  message: unknown;
25
11
  rawLine: string;
26
- }) => void): void;
27
- export declare function tryStartPendingJsonLine(state: JsonLineAccumulatorState, trimmed: string): void;
12
+ }) => void, onError?: (error: RangeError) => void): void;
13
+ export declare function tryStartPendingJsonLine(state: JsonLineAccumulatorState, trimmed: string, onError?: (error: RangeError) => void): void;
28
14
  export declare function handleJsonLine(state: JsonLineAccumulatorState, line: string, onMessage: (requiredArgs: {
29
15
  message: unknown;
30
16
  rawLine: string;
31
- }) => void): void;
17
+ }) => void, onError?: (error: RangeError) => void): void;
32
18
  /**
33
19
  * Creates a streaming JSON-line parser over a raw byte/string stream.
34
20
  * Buffers incoming chunks, splits on newline boundaries, and attempts
35
21
  * `JSON.parse` on each line. Accumulates pretty-printed (multiline) JSON across
36
- * up to 256 lines and 128 kB before abandoning and re-trying the current line
37
- * as a fresh candidate.
22
+ * up to 256 lines and 128000 characters. An over-budget candidate is discarded;
23
+ * its continuation is retried as a fresh frame. A physical line
24
+ * may contain up to 8 Mi UTF-16 code units, independently of the multiline budget.
38
25
  *
39
26
  * Used as the shared ACP transport: both the acp/ and pi-rpc/ adapters call
40
27
  * this to decode JSON-RPC frames from a subprocess's stdout.
41
28
  *
42
29
  * @param requiredArgs.onMessage - Called with `{ message, rawLine }` for each
43
30
  * successfully parsed JSON value and its raw reassembled line string.
31
+ * @param requiredArgs.onError - Reports a physical-line or multiline overflow to the host's failure path.
32
+ * When omitted, feed throws RangeError. Oversized content is never delivered.
44
33
  * @returns An object with `feed({ chunk })` for incremental input and `flush()` to
45
34
  * drain any residual buffered content at stream end.
46
35
  */
47
- export declare function createJsonLineStream({ onMessage }: {
36
+ export declare function createJsonLineStream({ onMessage, onError }: {
48
37
  onMessage: (requiredArgs: {
49
38
  message: unknown;
50
39
  rawLine: string;
51
40
  }) => void;
41
+ onError?: (error: RangeError) => void;
52
42
  }): {
53
43
  feed({ chunk }: {
54
44
  chunk: string;
@@ -1,3 +1,4 @@
1
+ import { createBoundedLineStream } from '../../core/bounded-line-stream.js';
1
2
  /** @module agent-protocol/core/json-line-stream
2
3
  * Streaming JSON-line parser that reassembles pretty-printed and multiline
3
4
  * JSON-RPC messages across chunk boundaries. Shared transport used by both the
@@ -12,6 +13,10 @@
12
13
  * decision logic, so it is hoisted to module level and exported, taking its
13
14
  * state as an explicit first argument rather than reading it off a closure.
14
15
  */
16
+ // Mutable state for the line-accumulation state machine below: the
17
+ // in-progress multiline JSON candidate (empty when not accumulating) and
18
+ // how many lines have been folded into it.
19
+ const MULTILINE_LIMIT_MESSAGE = 'Agent output multiline JSON exceeded 128000 characters or 256 lines.';
15
20
  function startPendingJson(state, line) {
16
21
  state.pendingJson = line;
17
22
  state.pendingJsonLineCount = 1;
@@ -32,7 +37,15 @@ export function emitJsonLine(candidate, onMessage) {
32
37
  // Continues an in-progress multiline candidate with the next trimmed line.
33
38
  // Either resolves it (parses, or gives up and re-processes `trimmed` fresh)
34
39
  // or keeps accumulating.
35
- export function continuePendingJsonLine(state, trimmed, onMessage) {
40
+ export function continuePendingJsonLine(state, trimmed, onMessage, onError) {
41
+ // Enforce aggregate limits before JSON.parse; a complete closing line earns no exemption.
42
+ if (state.pendingJson.length + 1 + trimmed.length > 128_000 || state.pendingJsonLineCount >= 256) {
43
+ resetPendingJson(state);
44
+ onError?.(new RangeError(MULTILINE_LIMIT_MESSAGE));
45
+ // A complete physical frame may follow a stray opening line; its own line budget still applies.
46
+ handleJsonLine(state, trimmed, onMessage, onError);
47
+ return;
48
+ }
36
49
  const nextCandidate = `${state.pendingJson}\n${trimmed}`;
37
50
  if (emitJsonLine(nextCandidate, onMessage)) {
38
51
  resetPendingJson(state);
@@ -40,70 +53,69 @@ export function continuePendingJsonLine(state, trimmed, onMessage) {
40
53
  }
41
54
  state.pendingJsonLineCount += 1;
42
55
  const classification = classifyJsonCandidate(nextCandidate);
43
- if (classification === 'incomplete' &&
44
- nextCandidate.length <= 128_000 &&
45
- state.pendingJsonLineCount <= 256) {
56
+ if (classification === 'incomplete') {
46
57
  state.pendingJson = nextCandidate;
47
58
  return;
48
59
  }
49
60
  resetPendingJson(state);
50
- handleJsonLine(state, trimmed, onMessage);
61
+ handleJsonLine(state, trimmed, onMessage, onError);
51
62
  }
52
63
  // ACP is line-delimited JSON-RPC, but a few bridges have emitted
53
64
  // pretty-printed JSON during startup. Keep a bounded aggregate so an
54
65
  // otherwise valid multiline initialize response does not get discarded
55
66
  // line-by-line and leave the session stuck in spawn pending.
56
- export function tryStartPendingJsonLine(state, trimmed) {
57
- if ((trimmed.startsWith('{') || trimmed.startsWith('[')) &&
58
- classifyJsonCandidate(trimmed) === 'incomplete') {
59
- startPendingJson(state, trimmed);
67
+ export function tryStartPendingJsonLine(state, trimmed, onError) {
68
+ if (!trimmed.startsWith('{') && !trimmed.startsWith('['))
69
+ return;
70
+ if (trimmed.length > 128_000) {
71
+ onError?.(new RangeError(MULTILINE_LIMIT_MESSAGE));
72
+ return;
60
73
  }
74
+ if (classifyJsonCandidate(trimmed) === 'incomplete')
75
+ startPendingJson(state, trimmed);
61
76
  }
62
- export function handleJsonLine(state, line, onMessage) {
77
+ export function handleJsonLine(state, line, onMessage, onError) {
63
78
  const trimmed = line.trim();
64
79
  if (!trimmed)
65
80
  return;
66
81
  if (state.pendingJson) {
67
- continuePendingJsonLine(state, trimmed, onMessage);
82
+ continuePendingJsonLine(state, trimmed, onMessage, onError);
68
83
  return;
69
84
  }
70
85
  if (emitJsonLine(trimmed, onMessage))
71
86
  return;
72
- tryStartPendingJsonLine(state, trimmed);
87
+ tryStartPendingJsonLine(state, trimmed, onError);
73
88
  }
74
89
  /**
75
90
  * Creates a streaming JSON-line parser over a raw byte/string stream.
76
91
  * Buffers incoming chunks, splits on newline boundaries, and attempts
77
92
  * `JSON.parse` on each line. Accumulates pretty-printed (multiline) JSON across
78
- * up to 256 lines and 128 kB before abandoning and re-trying the current line
79
- * as a fresh candidate.
93
+ * up to 256 lines and 128000 characters. An over-budget candidate is discarded;
94
+ * its continuation is retried as a fresh frame. A physical line
95
+ * may contain up to 8 Mi UTF-16 code units, independently of the multiline budget.
80
96
  *
81
97
  * Used as the shared ACP transport: both the acp/ and pi-rpc/ adapters call
82
98
  * this to decode JSON-RPC frames from a subprocess's stdout.
83
99
  *
84
100
  * @param requiredArgs.onMessage - Called with `{ message, rawLine }` for each
85
101
  * successfully parsed JSON value and its raw reassembled line string.
102
+ * @param requiredArgs.onError - Reports a physical-line or multiline overflow to the host's failure path.
103
+ * When omitted, feed throws RangeError. Oversized content is never delivered.
86
104
  * @returns An object with `feed({ chunk })` for incremental input and `flush()` to
87
105
  * drain any residual buffered content at stream end.
88
106
  */
89
- export function createJsonLineStream({ onMessage }) {
90
- let buffer = '';
107
+ export function createJsonLineStream({ onMessage, onError = error => { throw error; } }) {
91
108
  const state = { pendingJson: '', pendingJsonLineCount: 0 };
109
+ const lines = createBoundedLineStream({
110
+ onLine: line => handleJsonLine(state, line, onMessage, onError),
111
+ onOverflow: error => { resetPendingJson(state); onError(error); },
112
+ });
92
113
  return {
93
114
  feed({ chunk }) {
94
- buffer += chunk;
95
- const lines = buffer.split('\n');
96
- buffer = lines.pop() || '';
97
- for (const line of lines) {
98
- handleJsonLine(state, line, onMessage);
99
- }
115
+ lines.feed({ chunk });
100
116
  },
101
117
  flush() {
102
- const trimmed = buffer.trim();
103
- buffer = '';
104
- if (trimmed) {
105
- handleJsonLine(state, trimmed, onMessage);
106
- }
118
+ lines.flush();
107
119
  // Any `pendingJson` still set at this point was, by construction, the
108
120
  // most recent candidate `classifyJsonCandidate` judged structurally
109
121
  // incomplete (an unclosed string/object/array) — the exact same
@@ -353,7 +353,7 @@ export function attachPiRpcSession(requiredArgs, optionalArgs = {}) {
353
353
  }, gracefulShutdownMs);
354
354
  };
355
355
  // ---- Inbound: parse stdout events ----
356
- const parser = createJsonLineStream({ onMessage: ({ message: raw }) => {
356
+ const parser = createJsonLineStream({ onError: error => fail(`parser: ${error.message}`), onMessage: ({ message: raw }) => {
357
357
  if (!isRecord(raw))
358
358
  return;
359
359
  // Once finished (agent_end or abort), stop processing — the run is
package/dist/auth.js CHANGED
@@ -92,7 +92,7 @@ export function isDeepSeekAuthFailureText({ text }) {
92
92
  return false;
93
93
  const placeholderKey = /KEY=<your-key>/i.test(value) || /api_key\s*=\s*["']<your-key>["']/i.test(value);
94
94
  const configMentionsKey = /~\/\.deepseek\/config\.toml/i.test(value) && /api[_ -]?key|KEY=/i.test(value);
95
- const envKeyProblem = /DEEPSEEK_API_KEY/i.test(value) && /auth|api[_ -]?key|missing|not set|required|unauthorized/i.test(value);
95
+ const envKeyProblem = /DEEPSEEK_API_KEY/i.test(value) && /auth|missing|not set|required|unauthorized|empty|invalid/i.test(value);
96
96
  return placeholderKey || configMentionsKey || envKeyProblem;
97
97
  }
98
98
  export function isReasonixAuthFailureText({ text }) {
@@ -36,6 +36,7 @@
36
36
  * a larger, riskier change than this pass makes. They stay as closures,
37
37
  * exercised only through `feed`/`flush` in the test suite.
38
38
  */
39
+ import { createBoundedLineStream } from './core/bounded-line-stream.js';
39
40
  import { readDelegatedResult } from '@jini-ai/protocol';
40
41
  import { createRoleMarkerGuard } from './role-marker-guard.js';
41
42
  import { createClaudeSegmentUsage } from './claude-segment-usage.js';
@@ -359,7 +360,11 @@ export function emitAssistantErrorIfPresent(obj, content, onEvent) {
359
360
  });
360
361
  }
361
362
  export function createClaudeStreamHandler({ onEvent }, options = {}) {
362
- let buffer = '';
363
+ const lines = createBoundedLineStream({
364
+ onLine: line => { const trimmed = line.trim(); if (trimmed)
365
+ feedLine(trimmed); },
366
+ onOverflow: error => onEvent({ type: 'error', message: error.message, code: 'STREAM_LINE_TOO_LARGE' }),
367
+ });
363
368
  const segmentUsage = createClaudeSegmentUsage({}, {
364
369
  ...(options.nowMs === undefined ? {} : { nowMs: options.nowMs }),
365
370
  ...(options.costBasis === undefined ? {} : { costBasis: options.costBasis }),
@@ -567,14 +572,7 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
567
572
  return startDuplicateArtifactCandidate(current, openIndex);
568
573
  }
569
574
  function feed({ chunk }) {
570
- buffer += chunk;
571
- let nl;
572
- while ((nl = buffer.indexOf('\n')) !== -1) {
573
- const line = buffer.slice(0, nl).trim();
574
- buffer = buffer.slice(nl + 1);
575
- if (line)
576
- feedLine(line);
577
- }
575
+ lines.feed({ chunk: chunk });
578
576
  }
579
577
  /** One complete, non-blank line: a JSON object is handled, anything else passes through raw. */
580
578
  function feedLine(line) {
@@ -589,16 +587,7 @@ export function createClaudeStreamHandler({ onEvent }, options = {}) {
589
587
  handleObject(obj);
590
588
  }
591
589
  function flush() {
592
- const rem = buffer.trim();
593
- buffer = '';
594
- if (rem) {
595
- try {
596
- handleObject(JSON.parse(rem));
597
- }
598
- catch {
599
- onEvent({ type: 'raw', line: rem });
600
- }
601
- }
590
+ lines.flush();
602
591
  flushPendingArtifactText();
603
592
  // A hard cancel has no result frame. Flush only counters actually observed, once.
604
593
  if (segmentUsage.hasObserved())
@@ -0,0 +1,17 @@
1
+ /** Maximum retained physical stdout line, measured in JavaScript UTF-16 code units. */
2
+ export declare const MAX_STREAM_LINE_CHARS: number;
3
+ export declare const STREAM_LINE_LIMIT_MESSAGE = "Agent output is too large to read: one line exceeds 8,388,608 characters. Try a smaller attachment or a new chat.";
4
+ /** Frame bounded physical lines without ever parsing an oversized line's suffix.
5
+ * Overflow is reported once, immediately, then discarded through newline. Flush clears a final tail.
6
+ * @complexity O(incoming characters) time; O(MAX_STREAM_LINE_CHARS) retained text plus chunk references.
7
+ */
8
+ export declare function createBoundedLineStream({ onLine, onOverflow }: {
9
+ onLine: (line: string) => void;
10
+ onOverflow: (error: RangeError) => void;
11
+ }, _optional?: Record<string, never>): {
12
+ feed({ chunk }: {
13
+ chunk: string;
14
+ }): void;
15
+ flush(): void;
16
+ };
17
+ //# sourceMappingURL=bounded-line-stream.d.ts.map
@@ -0,0 +1,49 @@
1
+ /** Maximum retained physical stdout line, measured in JavaScript UTF-16 code units. */
2
+ export const MAX_STREAM_LINE_CHARS = 8 * 1024 * 1024;
3
+ export const STREAM_LINE_LIMIT_MESSAGE = 'Agent output is too large to read: one line exceeds 8,388,608 characters. Try a smaller attachment or a new chat.';
4
+ /** Frame bounded physical lines without ever parsing an oversized line's suffix.
5
+ * Overflow is reported once, immediately, then discarded through newline. Flush clears a final tail.
6
+ * @complexity O(incoming characters) time; O(MAX_STREAM_LINE_CHARS) retained text plus chunk references.
7
+ */
8
+ export function createBoundedLineStream({ onLine, onOverflow }, _optional = {}) {
9
+ let parts = [];
10
+ let length = 0;
11
+ let dropping = false;
12
+ function append(chunk, start, end) {
13
+ if (dropping || start === end)
14
+ return;
15
+ const nextLength = length + end - start;
16
+ if (nextLength > MAX_STREAM_LINE_CHARS) {
17
+ parts = [];
18
+ length = 0;
19
+ dropping = true;
20
+ onOverflow(new RangeError(STREAM_LINE_LIMIT_MESSAGE));
21
+ return;
22
+ }
23
+ parts.push(chunk.slice(start, end));
24
+ length = nextLength;
25
+ }
26
+ function finishLine() {
27
+ const line = dropping ? null : parts.join('');
28
+ parts = [];
29
+ length = 0;
30
+ dropping = false;
31
+ if (line !== null)
32
+ onLine(line);
33
+ }
34
+ return {
35
+ feed({ chunk }) {
36
+ let start = 0;
37
+ let newline = chunk.indexOf('\n', start);
38
+ while (newline !== -1) {
39
+ append(chunk, start, newline);
40
+ finishLine();
41
+ start = newline + 1;
42
+ newline = chunk.indexOf('\n', start);
43
+ }
44
+ append(chunk, start, chunk.length);
45
+ },
46
+ flush() { finishLine(); },
47
+ };
48
+ }
49
+ //# sourceMappingURL=bounded-line-stream.js.map
@@ -1,5 +1,5 @@
1
1
  /** Shared discovery normalization and timeout/error contracts; no native adapters. */
2
- import type { RuntimeModelOption } from '../types.js';
2
+ import type { DetectedAgent, RuntimeModelOption, RuntimeReasoningOption } from '../types.js';
3
3
  import type { DiscoveredModel, ModelCatalogSnapshot } from '../model-discovery-types.js';
4
4
  export declare function modelIdentityKind(id: string): DiscoveredModel['identityKind'];
5
5
  export declare function normalizeDiscoveredModels(models: readonly RuntimeModelOption[]): DiscoveredModel[];
@@ -16,6 +16,20 @@ export declare function concreteModelOptions({ models, supportsConcreteModelSele
16
16
  supportsConcreteModelSelection?: boolean;
17
17
  defaultModelResolution?: DefaultResolutionLike;
18
18
  }, _options?: {}): RuntimeModelOption[];
19
+ /** Effort choices for one model, shared by launch validation and browser pickers.
20
+ * The runtime's advertised Default survives model narrowing; an explicit empty list stays empty
21
+ * apart from that Default. Suffix-based runtimes carry effort in the model ID instead.
22
+ * Pure; O(n) time and space in the offered levels, preserving first labels and ordering.
23
+ */
24
+ export declare function modelReasoningOptions({ agent, model }: {
25
+ agent: {
26
+ reasoningOptions?: readonly RuntimeReasoningOption[];
27
+ reasoningInModelId?: {
28
+ levels: readonly RuntimeReasoningOption[];
29
+ };
30
+ };
31
+ model?: Pick<RuntimeModelOption, 'reasoning'> | undefined;
32
+ }, _options?: {}): RuntimeReasoningOption[];
19
33
  export declare class ProbeTimeout extends Error {
20
34
  }
21
35
  /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
@@ -24,5 +38,15 @@ export declare class ModelProbeError extends Error {
24
38
  readonly code: ModelCatalogSnapshot['diagnostics'][number]['code'];
25
39
  constructor(code: ModelCatalogSnapshot['diagnostics'][number]['code']);
26
40
  }
41
+ /** Refusal for an unknown model, or an effort the selected model does not offer. */
42
+ export declare function validateRuntimeModelSelection({ agent, agentId, modelId, effort }: {
43
+ agent: Pick<DetectedAgent, 'models' | 'reasoningOptions' | 'reasoningInModelId' | 'defaultModelResolution'>;
44
+ agentId: string;
45
+ modelId?: string | undefined;
46
+ effort?: string | undefined;
47
+ }, _options?: {}): string | null;
48
+ /** A refusal assembled by the shared selection validator, safe to show instead of provider errors. */
49
+ export declare class RuntimeSelectionError extends Error {
50
+ }
27
51
  export {};
28
52
  //# sourceMappingURL=model-discovery-shared.d.ts.map
@@ -59,6 +59,25 @@ export function concreteModelOptions({ models = [], supportsConcreteModelSelecti
59
59
  options.unshift({ id: hiddenDefaultId, label: hiddenDefaultId, identityKind: 'concrete' });
60
60
  return options;
61
61
  }
62
+ /** Effort choices for one model, shared by launch validation and browser pickers.
63
+ * The runtime's advertised Default survives model narrowing; an explicit empty list stays empty
64
+ * apart from that Default. Suffix-based runtimes carry effort in the model ID instead.
65
+ * Pure; O(n) time and space in the offered levels, preserving first labels and ordering.
66
+ */
67
+ export function modelReasoningOptions({ agent, model }, _options = {}) {
68
+ if (agent.reasoningInModelId)
69
+ return [];
70
+ const advertised = agent.reasoningOptions ?? [];
71
+ const defaultOption = advertised.find(option => option.id === 'default');
72
+ const levels = model?.reasoning ?? advertised;
73
+ const choices = new Map();
74
+ if (defaultOption)
75
+ choices.set(defaultOption.id, defaultOption);
76
+ for (const level of levels)
77
+ if (!choices.has(level.id))
78
+ choices.set(level.id, level);
79
+ return [...choices.values()];
80
+ }
62
81
  export class ProbeTimeout extends Error {
63
82
  }
64
83
  /** Cancellation always reaches the effect port. A broken port cannot hold callers indefinitely. */
@@ -87,4 +106,32 @@ export class ModelProbeError extends Error {
87
106
  this.code = code;
88
107
  }
89
108
  }
109
+ /** The concrete id a pick launches: the explicit model, else the resolved default (if any). */
110
+ function selectedModelId({ agent, modelId }) {
111
+ if (modelId && modelId !== 'default')
112
+ return modelId;
113
+ const resolution = agent.defaultModelResolution;
114
+ return resolution?.status === 'resolved' ? resolution.id : undefined;
115
+ }
116
+ /** Refusal for an unknown model, or an effort the selected model does not offer. */
117
+ export function validateRuntimeModelSelection({ agent, agentId, modelId, effort }, _options = {}) {
118
+ const choices = concreteModelOptions(agent);
119
+ const resolvedId = selectedModelId({ agent, modelId });
120
+ const model = choices.find(candidate => candidate.id === resolvedId);
121
+ if (modelId && modelId !== 'default' && !model)
122
+ return `Unknown model '${modelId}' for '${agentId}'. Available models: ${choices.map(candidate => candidate.id).join(', ')}.`;
123
+ if (!effort)
124
+ return null;
125
+ // Default must resolve before checking model-specific effort; agent-wide levels can differ.
126
+ if (!model)
127
+ return `Default model for '${agentId}' is unresolved. Pick a concrete model before choosing effort.`;
128
+ // Suffix-based runtimes own effort in the model id; a second effort setting would disagree.
129
+ const levels = modelReasoningOptions({ agent, model });
130
+ if (!levels.some(candidate => candidate.id === effort))
131
+ return `Unknown effort '${effort}' for '${agentId}'. Available effort levels: ${levels.map(candidate => candidate.id).join(', ')} (empty means Default).`;
132
+ return null;
133
+ }
134
+ /** A refusal assembled by the shared selection validator, safe to show instead of provider errors. */
135
+ export class RuntimeSelectionError extends Error {
136
+ }
90
137
  //# sourceMappingURL=model-discovery-shared.js.map
@@ -1,4 +1,5 @@
1
1
  export declare const aiderAgentDef: {
2
+ mcpIsolation: "no-client";
2
3
  id: string;
3
4
  name: string;
4
5
  bin: string;
@@ -3,6 +3,7 @@ import { DEFAULT_MODEL_OPTION } from './shared.js';
3
3
  export const aiderAgentDef = {
4
4
  // UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
5
5
  ...createAgentModelDiscovery('aider', { fallbackModels: () => aiderAgentDef.fallbackModels }),
6
+ mcpIsolation: 'no-client',
6
7
  id: 'aider',
7
8
  name: 'Aider',
8
9
  bin: 'aider',
@@ -1,6 +1,7 @@
1
1
  import type { RuntimeBuildOptions, RuntimeContext } from '../types.js';
2
2
  export declare const claudeAgentDef: {
3
3
  id: string;
4
+ subagentStartHook: true;
4
5
  supportsNativeToolAccess: true;
5
6
  supportsSubagents: true;
6
7
  supportsChromeIntegration: true;
@@ -139,6 +139,7 @@ function claudeLaunchPolicy({ options, caps, extraAllowedDirs, imagePaths, runti
139
139
  export const claudeAgentDef = {
140
140
  ...createAgentModelDiscovery('claude', { fallbackModels: () => claudeAgentDef.fallbackModels }),
141
141
  id: 'claude',
142
+ subagentStartHook: true,
142
143
  supportsNativeToolAccess: true,
143
144
  // Native Task/Agent subagent tool (see `native-tool-policy.ts`'s `subagents` dimension).
144
145
  supportsSubagents: true,
@@ -1,7 +1,7 @@
1
1
  import { createAgentModelDiscovery } from '../model-discovery-native.js';
2
2
  /** CODEX_SANDBOX_MODE remains an adapter-scoped operator override; plugin policy is supplied
3
3
  * explicitly by the host, whose native composition resolves CODEX_DISABLE_PLUGINS. */
4
- import { DEFAULT_MODEL_OPTION, clampCodexReasoning } from './shared.js';
4
+ import { DEFAULT_MODEL_OPTION } from './shared.js';
5
5
  /**
6
6
  * The `visibility` values that mean "reachable by id, but do not render in a picker".
7
7
  *
@@ -278,7 +278,9 @@ function codexCreateOnlyArgs({ extraAllowedDirs, runtimeContext }) {
278
278
  function codexModelArgs(options) {
279
279
  const args = options.model && options.model !== 'default' ? ['--model', options.model] : [];
280
280
  if (options.reasoning && options.reasoning !== 'default') {
281
- const effort = clampCodexReasoning(options.model, options.reasoning);
281
+ // The shared selection validator checks advertised effort before launch. Keep the explicit
282
+ // choice exact here; model-name heuristics must never substitute another effort.
283
+ const effort = options.reasoning;
282
284
  // Codex accepts `-c key=value` config overrides; reasoning effort
283
285
  // is exposed as `model_reasoning_effort`.
284
286
  args.push('-c', `model_reasoning_effort="${effort}"`);
@@ -343,8 +345,8 @@ export const codexAgentDef = {
343
345
  // derived from that catalog instead (see `deriveReasoningOptions` below), which is what makes
344
346
  // `max` and `ultra` reachable. This list is deliberately NOT widened to match: it is what a build
345
347
  // too old to have a catalog gets, and `none`/`minimal` — which no model in the current catalog
346
- // supports — are exactly the levels such a build did accept. `clampCodexReasoning` still maps
347
- // `minimal` to `low` for the late GPT-5 families.
348
+ // supports — are exactly the levels such a build did accept. Launch validation uses the
349
+ // selected model's advertised levels; argv never silently substitutes another effort.
348
350
  reasoningOptions: [
349
351
  { id: 'default', label: 'Default' },
350
352
  { id: 'none', label: 'None' },
package/dist/defs/pi.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { RuntimeBuildOptions, RuntimeModelOption } from '../types.js';
2
2
  export declare const piAgentDef: {
3
+ mcpIsolation: "no-client";
3
4
  id: string;
4
5
  name: string;
5
6
  bin: string;
package/dist/defs/pi.js CHANGED
@@ -23,6 +23,7 @@ function dirHintArgs({ extraAllowedDirs }) {
23
23
  }
24
24
  export const piAgentDef = {
25
25
  ...createAgentModelDiscovery('pi', { fallbackModels: () => piAgentDef.fallbackModels }),
26
+ mcpIsolation: 'no-client',
26
27
  id: 'pi',
27
28
  name: 'Pi',
28
29
  bin: 'pi',
@@ -4,8 +4,8 @@
4
4
  * Small helpers shared across the per-CLI def literals: re-exports of
5
5
  * `execAgentFile`/`DEFAULT_MODEL_OPTION` for convenience, the injected
6
6
  * `detectAcpModels`/`parsePiModels` (see `../acp-model-probe.ts` /
7
- * `../pi-models.ts` for why these are ports, not direct lifts), and two
8
- * small generic parsers (`clampCodexReasoning`, `parseLineSeparatedModels`).
7
+ * `../pi-models.ts` for why these are ports, not direct lifts), and the
8
+ * small generic parser `parseLineSeparatedModels`.
9
9
  *
10
10
  */
11
11
  import { detectAcpModels } from '../acp-model-probe.js';
@@ -56,7 +56,6 @@ type ClaudeMcpOptions = {
56
56
  * @overallScore 100/100
57
57
  */
58
58
  export declare function buildClaudeMcpConfigArgs(runtimeContext: RuntimeContext, options?: ClaudeMcpOptions): string[];
59
- export declare function clampCodexReasoning(modelId: string | null | undefined, effort: string | null | undefined): string | null | undefined;
60
59
  export declare function parseLineSeparatedModels({ stdout }: {
61
60
  stdout: string;
62
61
  }): RuntimeModelOption[];
@@ -4,8 +4,8 @@
4
4
  * Small helpers shared across the per-CLI def literals: re-exports of
5
5
  * `execAgentFile`/`DEFAULT_MODEL_OPTION` for convenience, the injected
6
6
  * `detectAcpModels`/`parsePiModels` (see `../acp-model-probe.ts` /
7
- * `../pi-models.ts` for why these are ports, not direct lifts), and two
8
- * small generic parsers (`clampCodexReasoning`, `parseLineSeparatedModels`).
7
+ * `../pi-models.ts` for why these are ports, not direct lifts), and the
8
+ * small generic parser `parseLineSeparatedModels`.
9
9
  *
10
10
  */
11
11
  import { detectAcpModels } from '../acp-model-probe.js';
@@ -63,27 +63,6 @@ function claudeUserMcpLocked({ options }, _optional = {}) {
63
63
  return options.nativeToolAccess === false || options.nativeCapabilities?.userMcp === false ||
64
64
  (options.filesystemRoot !== undefined && options.nativeCapabilities?.userMcp !== true);
65
65
  }
66
- /** Model-id prefixes of the late gpt-5.x family, which rejects `minimal` effort. */
67
- const GPT5_LATE_FAMILY_PREFIXES = ['gpt-5.2', 'gpt-5.3', 'gpt-5.4', 'gpt-5.5'];
68
- /** True for the empty/`default` id (the CLI's own default model) or a late gpt-5.x id. */
69
- function isGpt5LateFamily(id) {
70
- return id === '' || id === 'default' || GPT5_LATE_FAMILY_PREFIXES.some((prefix) => id.startsWith(prefix));
71
- }
72
- export function clampCodexReasoning(modelId, effort) {
73
- if (!effort)
74
- return effort;
75
- const raw = String(modelId ?? '').trim();
76
- // Strip any provider prefix ("openai/gpt-5.2" -> "gpt-5.2"); a trailing "/" leaves "".
77
- const id = raw.slice(raw.lastIndexOf('/') + 1);
78
- if (isGpt5LateFamily(id) && effort === 'minimal')
79
- return 'low';
80
- if (id === 'gpt-5.1' && effort === 'xhigh')
81
- return 'high';
82
- if (id === 'gpt-5.1-codex-mini') {
83
- return effort === 'high' || effort === 'xhigh' ? 'high' : 'medium';
84
- }
85
- return effort;
86
- }
87
66
  // Parse one-id-per-line stdout from `<cli> models` and prepend the synthetic
88
67
  // default option. Used by opencode / cursor-agent.
89
68
  export function parseLineSeparatedModels({ stdout }) {