@jini-ai/agent-runtime 0.4.11 → 0.6.10

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 (111) hide show
  1. package/CHANGELOG.md +83 -1
  2. package/dist/acp-model-probe.d.ts +2 -20
  3. package/dist/agent-protocol/acp/json.js +46 -37
  4. package/dist/agent-protocol/acp/models.js +91 -73
  5. package/dist/agent-protocol/acp/rpc.d.ts +3 -2
  6. package/dist/agent-protocol/acp/rpc.js +3 -2
  7. package/dist/agent-protocol/acp/session-params.d.ts +1 -1
  8. package/dist/agent-protocol/acp/session-params.js +33 -30
  9. package/dist/agent-protocol/acp/session.d.ts +3 -1
  10. package/dist/agent-protocol/acp/session.js +62 -24
  11. package/dist/agent-protocol/acp/updates.js +49 -35
  12. package/dist/agent-protocol/pi-rpc/session.js +3 -1
  13. package/dist/anthropic-live-models.d.ts +12 -4
  14. package/dist/anthropic-live-models.js +0 -0
  15. package/dist/auth.js +84 -91
  16. package/dist/claude-code-models.d.ts +6 -5
  17. package/dist/claude-code-models.js +19 -12
  18. package/dist/claude-segment-usage.d.ts +3 -3
  19. package/dist/claude-segment-usage.js +63 -29
  20. package/dist/claude-stream.d.ts +2 -0
  21. package/dist/claude-stream.js +16 -5
  22. package/dist/copilot-stream.js +42 -50
  23. package/dist/defs/aider.js +3 -4
  24. package/dist/defs/amr.js +52 -61
  25. package/dist/defs/antigravity.d.ts +6 -5
  26. package/dist/defs/antigravity.js +48 -34
  27. package/dist/defs/auggie.d.ts +1 -1
  28. package/dist/defs/claude-compatible-args.d.ts +19 -0
  29. package/dist/defs/claude-compatible-args.js +42 -0
  30. package/dist/defs/claude.d.ts +7 -2
  31. package/dist/defs/claude.js +96 -85
  32. package/dist/defs/cline.d.ts +1 -1
  33. package/dist/defs/codebuddy.d.ts +1 -1
  34. package/dist/defs/codebuddy.js +29 -46
  35. package/dist/defs/codex.d.ts +15 -3
  36. package/dist/defs/codex.js +143 -108
  37. package/dist/defs/cursor-agent.d.ts +9 -7
  38. package/dist/defs/cursor-agent.js +53 -51
  39. package/dist/defs/devin.d.ts +1 -1
  40. package/dist/defs/goose.d.ts +1 -1
  41. package/dist/defs/hermes.d.ts +1 -1
  42. package/dist/defs/kilo.d.ts +1 -1
  43. package/dist/defs/kimi.d.ts +1 -1
  44. package/dist/defs/kiro.d.ts +1 -1
  45. package/dist/defs/opencode.d.ts +5 -4
  46. package/dist/defs/opencode.js +26 -32
  47. package/dist/defs/pi.d.ts +6 -5
  48. package/dist/defs/pi.js +24 -26
  49. package/dist/defs/qoder.d.ts +4 -3
  50. package/dist/defs/qoder.js +25 -25
  51. package/dist/defs/reasonix.d.ts +1 -1
  52. package/dist/defs/shared.d.ts +12 -3
  53. package/dist/defs/shared.js +19 -13
  54. package/dist/defs/trae-cli.d.ts +1 -1
  55. package/dist/defs/vibe.d.ts +1 -1
  56. package/dist/detection.d.ts +13 -20
  57. package/dist/detection.js +129 -111
  58. package/dist/env.js +56 -41
  59. package/dist/executables.js +103 -114
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.js +1 -0
  62. package/dist/json-event-stream.js +611 -527
  63. package/dist/launch.js +44 -37
  64. package/dist/model-discovery-adapters.d.ts +17 -0
  65. package/dist/model-discovery-adapters.js +223 -164
  66. package/dist/model-discovery-config.js +107 -87
  67. package/dist/model-discovery-sdk.d.ts +16 -2
  68. package/dist/model-discovery-sdk.js +4 -3
  69. package/dist/model-discovery-shared.d.ts +14 -0
  70. package/dist/model-discovery-shared.js +50 -15
  71. package/dist/model-discovery-types.d.ts +2 -0
  72. package/dist/model-discovery.js +219 -117
  73. package/dist/models.d.ts +14 -1
  74. package/dist/models.js +75 -19
  75. package/dist/native-tool-policy.d.ts +29 -0
  76. package/dist/native-tool-policy.js +36 -0
  77. package/dist/opencode-log.js +46 -30
  78. package/dist/paths.d.ts +2 -0
  79. package/dist/paths.js +3 -3
  80. package/dist/providers/aihubmix.js +13 -18
  81. package/dist/providers/anthropic-messages.d.ts +7 -0
  82. package/dist/providers/anthropic-messages.js +45 -21
  83. package/dist/providers/azure-chat.d.ts +5 -0
  84. package/dist/providers/azure-chat.js +13 -5
  85. package/dist/providers/connection-guard.d.ts +2 -45
  86. package/dist/providers/connection-guard.js +11 -10
  87. package/dist/providers/connection-test.d.ts +4 -0
  88. package/dist/providers/connection-test.js +127 -110
  89. package/dist/providers/elevenlabs.js +4 -1
  90. package/dist/providers/google-messages.d.ts +4 -0
  91. package/dist/providers/google-messages.js +48 -23
  92. package/dist/providers/google-schema.js +17 -23
  93. package/dist/providers/model-catalog.js +160 -145
  94. package/dist/providers/oauth-callback-server.js +37 -34
  95. package/dist/providers/oauth-credentials.js +23 -23
  96. package/dist/providers/oauth-tokens.js +16 -24
  97. package/dist/providers/openai-chat.d.ts +42 -0
  98. package/dist/providers/openai-chat.js +80 -10
  99. package/dist/providers/operation-schema.d.ts +25 -0
  100. package/dist/providers/operation-schema.js +226 -0
  101. package/dist/providers/response-text.d.ts +10 -0
  102. package/dist/providers/response-text.js +23 -0
  103. package/dist/providers/tool-turn-types.d.ts +56 -9
  104. package/dist/providers/tool-turn.d.ts +7 -0
  105. package/dist/providers/tool-turn.js +120 -32
  106. package/dist/qoder-stream.js +93 -80
  107. package/dist/registry.d.ts +45 -0
  108. package/dist/registry.js +39 -0
  109. package/dist/runtime-state.d.ts +1 -1
  110. package/dist/types.d.ts +43 -1
  111. package/package.json +19 -14
@@ -111,33 +111,69 @@ export function parseAgyModels({ stdout }) {
111
111
  const tabIndex = line.indexOf('\t');
112
112
  if (tabIndex === -1)
113
113
  continue;
114
+ // `line` is already trimmed, so a tab inside it always has a non-blank character on each
115
+ // side: neither the id nor the label can come out empty here.
114
116
  const id = line.slice(0, tabIndex).trim();
115
- if (!id || seen.has(id))
117
+ if (seen.has(id))
116
118
  continue;
117
119
  seen.add(id);
118
- const label = line.slice(tabIndex + 1).trim();
119
- out.push({ id, label: label || id });
120
+ out.push({ id, label: line.slice(tabIndex + 1).trim() });
120
121
  }
121
122
  return out.length > 1 ? out : null;
122
123
  }
124
+ // `agy models` does a real network fetch (its own stdout says "Fetching
125
+ // available models..."), so this gets a longer budget than codex's 5s
126
+ // local-cache read — 10s to absorb ordinary network latency without
127
+ // making every detection pass wait needlessly long on a slow/offline run
128
+ // (`detection.ts#fetchModels` falls back to `fallbackModels` on timeout).
129
+ // It runs within the outer 10s discovery budget: Antigravity has no disk
130
+ // fallback, so `probeAgentCatalog` reserves no recovery time for it.
131
+ const AGY_MODELS_TIMEOUT_MS = 10_000;
132
+ // Match the owner's existing Full CLI grant; never infer approval from headless mode.
133
+ function skipPermissionsArgs({ options }) {
134
+ return options.cliParity === true && options.permissionMode === 'bypass' && options.nativeToolAccess !== false
135
+ ? ['--dangerously-skip-permissions']
136
+ : [];
137
+ }
138
+ // `--model` is the same kind of Go flag as `--log-file`/`-p`: its value is
139
+ // whatever argv token immediately follows it, so it too must be pushed
140
+ // before `-p` (always last — see `buildArgs`). Verified live against agy
141
+ // v1.1.24: `agy --model <slug> -p '<prompt>'` runs that one print-mode
142
+ // turn on the named model, and combining it with `--log-file` works the
143
+ // same way — relative order between `--model` and `--log-file` doesn't
144
+ // matter (each independently consumes exactly the one token after it),
145
+ // only that both precede `-p`.
146
+ function modelArgs({ options }) {
147
+ return options.model && options.model !== DEFAULT_MODEL_OPTION.id ? ['--model', options.model] : [];
148
+ }
149
+ // Always opt into `--log-file` when the daemon supplied a path so
150
+ // it can post-exit grep for the actual upstream failure shape
151
+ // (auth missing vs quota reached vs upstream error) — without it
152
+ // the chat surfaces a generic "empty response" because print mode
153
+ // never echoes those errors on stdout. See server.ts empty-output
154
+ // guard for the consumer.
155
+ function logFileArgs({ runtimeContext }) {
156
+ return runtimeContext.agentLogFilePath ? ['--log-file', runtimeContext.agentLogFilePath] : [];
157
+ }
123
158
  export const antigravityAgentDef = {
124
- ...createAgentModelDiscovery('antigravity', { fallbackModels: () => antigravityAgentDef.fallbackModels, args: ['models'], parse: (input) => antigravityAgentDef.listModels.parse(input) }),
159
+ ...createAgentModelDiscovery('antigravity', { fallbackModels: () => antigravityAgentDef.fallbackModels, args: ['models'], parse: parseAgyModels, timeoutMs: AGY_MODELS_TIMEOUT_MS }),
125
160
  id: 'antigravity',
126
161
  name: 'Antigravity',
127
162
  bin: 'agy',
128
163
  versionArgs: ['--version'],
129
- // `agy models` does a real network fetch (its own stdout says "Fetching
130
- // available models..."), so this gets a longer budget than codex's 5s
131
- // local-cache read — 10s to absorb ordinary network latency without
132
- // making every detection pass wait needlessly long on a slow/offline run
133
- // (`detection.ts#fetchModels` falls back to `fallbackModels` on timeout).
164
+ // Budget rationale: see `AGY_MODELS_TIMEOUT_MS`.
134
165
  listModels: {
135
166
  args: ['models'],
136
167
  parse: parseAgyModels,
137
- timeoutMs: 10_000,
168
+ timeoutMs: AGY_MODELS_TIMEOUT_MS,
138
169
  },
170
+ // Checked against agy 1.4.2 and https://antigravity.google/docs/cli/headless/.
171
+ fallbackModelsAssertedAt: '2026-10-18',
139
172
  fallbackModels: [
140
173
  DEFAULT_MODEL_OPTION,
174
+ { id: 'gemini-4-argon-high', label: 'Gemini 4 Argon High' },
175
+ { id: 'gemini-4-argon-medium', label: 'Gemini 4 Argon Medium' },
176
+ { id: 'gemini-4-argon-low', label: 'Gemini 4 Argon Low' },
141
177
  { id: 'gemini-3.8-flash-high', label: 'Gemini 3.8 Flash (High)' },
142
178
  { id: 'gemini-3.8-flash-medium', label: 'Gemini 3.8 Flash (Medium)' },
143
179
  { id: 'gemini-3.8-flash-low', label: 'Gemini 3.8 Flash (Low)' },
@@ -186,7 +222,7 @@ export const antigravityAgentDef = {
186
222
  // apps/web/src/providers/daemon.ts). The stronger OVERRIDE block
187
223
  // composed in server.ts gives a second line of defense for weak
188
224
  // plain-stream models like Gemini 3.5 Flash.
189
- buildArgs: ({ prompt, imagePaths: _imagePaths }, { extraAllowedDirs: _extra = [], options = {}, runtimeContext = {} } = {}) => {
225
+ buildArgs: ({ prompt }, { options = {}, runtimeContext = {} } = {}) => {
190
226
  // `-p` is a Go `flag`-package flag that TAKES THE PROMPT AS ITS VALUE,
191
227
  // not a boolean switch followed by a positional prompt, and agy has no
192
228
  // stdin sentinel under the default `--input-format text`. Verified
@@ -199,29 +235,7 @@ export const antigravityAgentDef = {
199
235
  // - `agy -p '<prompt>'` -> the prompt actually lands.
200
236
  // So the prompt rides argv as `-p`'s value. That is also why this def is
201
237
  // argv-budgeted (`maxPromptArgBytes` below) rather than `promptViaStdin`.
202
- const args = [];
203
- // `--model` is the same kind of Go flag as `--log-file`/`-p`: its value is
204
- // whatever argv token immediately follows it, so it too must be pushed
205
- // before `-p` (always last — see below). Verified live against agy
206
- // v1.1.24: `agy --model <slug> -p '<prompt>'` runs that one print-mode
207
- // turn on the named model, and combining it with `--log-file` works the
208
- // same way — relative order between `--model` and `--log-file` doesn't
209
- // matter (each independently consumes exactly the one token after it),
210
- // only that both precede `-p`.
211
- if (options.model && options.model !== DEFAULT_MODEL_OPTION.id) {
212
- args.push('--model', options.model);
213
- }
214
- // Always opt into `--log-file` when the daemon supplied a path so
215
- // it can post-exit grep for the actual upstream failure shape
216
- // (auth missing vs quota reached vs upstream error) — without it
217
- // the chat surfaces a generic "empty response" because print mode
218
- // never echoes those errors on stdout. See server.ts empty-output
219
- // guard for the consumer.
220
- if (runtimeContext.agentLogFilePath) {
221
- args.push('--log-file', runtimeContext.agentLogFilePath);
222
- }
223
- args.push('-p', prompt);
224
- return args;
238
+ return [...skipPermissionsArgs({ options }), ...modelArgs({ options }), ...logFileArgs({ runtimeContext }), '-p', prompt];
225
239
  },
226
240
  // agy takes its prompt on argv (see `buildArgs`), so this def is
227
241
  // argv-budgeted like the other plain-stream argv adapters (aider,
@@ -7,7 +7,7 @@ export declare const auggieAgentDef: {
7
7
  resolvedBin: string;
8
8
  env: import("../types.js").RuntimeEnv;
9
9
  }, { acpModelProbe }?: {
10
- acpModelProbe?: import("../acp-model-probe.js").AcpModelProbe;
10
+ acpModelProbe?: import("../types.js").AcpModelProbe;
11
11
  } | undefined) => Promise<import("../types.js").RuntimeModelOption[]>;
12
12
  fallbackModels: import("../types.js").RuntimeModelOption[];
13
13
  buildArgs: () => string[];
@@ -0,0 +1,19 @@
1
+ import type { RuntimeBuildOptions, RuntimeCapabilityMap, RuntimeContext } from '../types.js';
2
+ /** Host-scoped capabilities when supplied, else the published `--help` probe cache for `agentId`. */
3
+ export declare function resolveCapabilities({ agentId, options }: {
4
+ agentId: string;
5
+ options: RuntimeBuildOptions;
6
+ }): RuntimeCapabilityMap;
7
+ /** `--add-dir <dir...>` for every non-empty string dir, unless the probe recorded `addDir: false`. */
8
+ export declare function addDirArgs({ extraAllowedDirs, caps }: {
9
+ extraAllowedDirs: readonly string[] | null | undefined;
10
+ caps: RuntimeCapabilityMap;
11
+ }): string[];
12
+ export declare function sessionArgs(runtimeContext: RuntimeContext): string[];
13
+ export declare function permissionModeArgs(options: RuntimeBuildOptions): string[];
14
+ /** `<flag> <value>` unless the value is empty or the CLI-owned `default` sentinel. */
15
+ export declare function nonDefaultFlag({ flag, value }: {
16
+ flag: string;
17
+ value: string | null | undefined;
18
+ }): string[];
19
+ //# sourceMappingURL=claude-compatible-args.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @module defs/claude-compatible-args
3
+ *
4
+ * Argv fragments shared by the defs that speak Claude Code's `-p` flag surface (`claude`,
5
+ * `codebuddy`). Codebuddy documents `--add-dir`, `--resume`, `--session-id` and
6
+ * `--permission-mode` as working identically to Claude Code, so each fragment is one
7
+ * implementation rather than a copy per def.
8
+ */
9
+ import { agentCapabilities } from '../capabilities.js';
10
+ /** Host-scoped capabilities when supplied, else the published `--help` probe cache for `agentId`. */
11
+ export function resolveCapabilities({ agentId, options }) {
12
+ return (options.capabilities ?? agentCapabilities.get(agentId)) || {};
13
+ }
14
+ /** `--add-dir <dir...>` for every non-empty string dir, unless the probe recorded `addDir: false`. */
15
+ export function addDirArgs({ extraAllowedDirs, caps }) {
16
+ const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
17
+ return dirs.length > 0 && caps.addDir !== false ? ['--add-dir', ...dirs] : [];
18
+ }
19
+ // Continue the CLI's own session across turns so it keeps its
20
+ // working memory (files read, edits made, tool history) instead of
21
+ // re-deriving everything from the rendered transcript each turn.
22
+ // `--resume <id>` continues a stored session; `--session-id <uuid>`
23
+ // starts a new one with an id the daemon controls and persists.
24
+ export function sessionArgs(runtimeContext) {
25
+ if (typeof runtimeContext.resumeSessionId === 'string' && runtimeContext.resumeSessionId) {
26
+ return ['--resume', runtimeContext.resumeSessionId];
27
+ }
28
+ if (typeof runtimeContext.newSessionId === 'string' && runtimeContext.newSessionId) {
29
+ return ['--session-id', runtimeContext.newSessionId];
30
+ }
31
+ return [];
32
+ }
33
+ // See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default (unchanged
34
+ // behavior) unless a caller explicitly opts into a restricted run.
35
+ export function permissionModeArgs(options) {
36
+ return options.permissionMode !== 'restricted' ? ['--permission-mode', 'bypassPermissions'] : [];
37
+ }
38
+ /** `<flag> <value>` unless the value is empty or the CLI-owned `default` sentinel. */
39
+ export function nonDefaultFlag({ flag, value }) {
40
+ return value && value !== 'default' ? [flag, value] : [];
41
+ }
42
+ //# sourceMappingURL=claude-compatible-args.js.map
@@ -1,5 +1,9 @@
1
+ import type { RuntimeBuildOptions } from '../types.js';
1
2
  export declare const claudeAgentDef: {
2
3
  id: string;
4
+ supportsNativeToolAccess: true;
5
+ supportsSubagents: true;
6
+ supportsChromeIntegration: true;
3
7
  name: string;
4
8
  bin: string;
5
9
  fallbackBins: string[];
@@ -15,6 +19,7 @@ export declare const claudeAgentDef: {
15
19
  '--effort': string;
16
20
  '--append-system-prompt': string;
17
21
  '--setting-sources': string;
22
+ '--chrome': string;
18
23
  };
19
24
  fallbackModels: import("../types.js").RuntimeModelOption[];
20
25
  fallbackModelsAssertedAt: string;
@@ -26,12 +31,12 @@ export declare const claudeAgentDef: {
26
31
  id: string;
27
32
  label: string;
28
33
  }[];
29
- buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }: {
34
+ buildArgs: (_requiredArgs: {
30
35
  prompt: string;
31
36
  imagePaths: string[];
32
37
  }, { extraAllowedDirs, options, runtimeContext }?: {
33
38
  extraAllowedDirs?: string[];
34
- options?: import("../types.js").RuntimeBuildOptions;
39
+ options?: RuntimeBuildOptions;
35
40
  runtimeContext?: import("../types.js").RuntimeContext;
36
41
  } | undefined) => string[];
37
42
  promptViaStdin: true;
@@ -1,3 +1,4 @@
1
+ import { resolveNativeCapabilityDenies, resolveNativeToolDenies } from '../native-tool-policy.js';
1
2
  import { createAgentModelDiscovery } from '../model-discovery-native.js';
2
3
  /**
3
4
  * Claude Code has no dedicated image-attachment flag. imageDelivery: 'prompt-path' makes the
@@ -5,7 +6,7 @@ import { createAgentModelDiscovery } from '../model-discovery-native.js';
5
6
  * buildArgs then grants --add-dir access so the CLI can read them itself. Native-delivery defs
6
7
  * must not also receive this augmentation; see RuntimeAgentDef.imageDelivery for that contract.
7
8
  */
8
- import { agentCapabilities } from '../capabilities.js';
9
+ import { addDirArgs, nonDefaultFlag, permissionModeArgs, resolveCapabilities, sessionArgs } from './claude-compatible-args.js';
9
10
  import { buildClaudeMcpConfigArgs, DEFAULT_MODEL_OPTION } from './shared.js';
10
11
  import { loadMmdRouteModels } from '../mmd-routes.js';
11
12
  import { loadAnthropicLiveModels, mergeLiveModels } from '../anthropic-live-models.js';
@@ -69,9 +70,60 @@ const CLAUDE_FALLBACK_MODELS = [
69
70
  { id: 'claude-opus-4-5', label: 'claude-opus-4-5' },
70
71
  { id: 'claude-sonnet-4-5', label: 'claude-sonnet-4-5' },
71
72
  ];
73
+ // `--effort` is newer than `--model`, so it gets the same probe gate as
74
+ // `--include-partial-messages`: an older build rejects an unknown option
75
+ // with exit 1, which kills the chat rather than degrading it.
76
+ function claudeEffortArgs({ options, caps }) {
77
+ const reasoning = options.reasoning;
78
+ return caps.effort && typeof reasoning === 'string' && CLAUDE_EFFORT_LEVELS.has(reasoning) ? ['--effort', reasoning] : [];
79
+ }
80
+ // Finding 2 (SEC-assistant-env-isolation-2026-09-07): `RuntimeBuildOptions.disallowedTools`/
81
+ // `allowedTools` are a `@jini-ai/agent-runtime`-level *mechanism* only — no product policy is
82
+ // baked in here (see `types.ts`'s own doc on those fields). Verified against installed Claude
83
+ // Code 2.1.263's own `-p --help`: `--disallowedTools, --disallowed-tools <tools...>` /
84
+ // `--allowedTools, --allowed-tools <tools...>`. Placed last, after every other flag, so an
85
+ // omitted (default) value is a true no-op — every existing call site that never passes these
86
+ // options sees byte-identical argv to before this change.
87
+ function claudeToolPolicyArgs(options) {
88
+ const deniedTools = resolveNativeCapabilityDenies({
89
+ ...(options.nativeCapabilities !== undefined ? { capabilities: options.nativeCapabilities } : {}),
90
+ denied: resolveNativeToolDenies({ enabled: options.nativeToolAccess,
91
+ ...(options.disallowedTools !== undefined ? { denied: options.disallowedTools } : {}) }, {})
92
+ }, {});
93
+ const allowedTools = options.allowedTools ?? [];
94
+ return [
95
+ ...(deniedTools.length > 0 ? ['--disallowedTools', ...deniedTools] : []),
96
+ ...(allowedTools.length > 0 ? ['--allowedTools', ...allowedTools] : []),
97
+ ];
98
+ }
99
+ // See `RuntimeBuildOptions.settingSources`. Probe-gated like `--effort`: an older build
100
+ // rejects an unknown option with exit 1, which would kill the chat rather than degrade it.
101
+ function claudeSettingSourcesArgs({ options, caps }) {
102
+ if (options.nativeCapabilities?.userSettings === false) {
103
+ // This is an explicit restriction, not an optional enhancement: do not probe it away.
104
+ return ['--setting-sources', '', '--disable-slash-commands'];
105
+ }
106
+ if (options.settingSources !== undefined && caps.settingSources) {
107
+ return ['--setting-sources', options.settingSources.join(',')];
108
+ }
109
+ return [];
110
+ }
111
+ // See `RuntimeBuildOptions.chromeIntegration`. Probe-gated like `--effort`: `--chrome`/`--no-chrome`
112
+ // are newer than `--model`, and an older build rejects an unknown option with exit 1, which would
113
+ // kill the chat rather than degrade it. Undefined emits nothing, so existing argv is unchanged.
114
+ function claudeChromeArgs({ options, caps }) {
115
+ if (options.chromeIntegration === undefined || !caps.chrome)
116
+ return [];
117
+ return [options.chromeIntegration ? '--chrome' : '--no-chrome'];
118
+ }
72
119
  export const claudeAgentDef = {
73
120
  ...createAgentModelDiscovery('claude', { fallbackModels: () => claudeAgentDef.fallbackModels }),
74
121
  id: 'claude',
122
+ supportsNativeToolAccess: true,
123
+ // Native Task/Agent subagent tool (see `native-tool-policy.ts`'s `subagents` dimension).
124
+ supportsSubagents: true,
125
+ // `--chrome`/`--no-chrome` via `RuntimeBuildOptions.chromeIntegration` (see `claudeChromeArgs`).
126
+ supportsChromeIntegration: true,
75
127
  name: 'Claude Code',
76
128
  bin: 'claude',
77
129
  // Drop-in forks that ship a CLI argv-compatible with `claude`. Tried in
@@ -96,6 +148,8 @@ export const claudeAgentDef = {
96
148
  '--effort': 'effort',
97
149
  '--append-system-prompt': 'appendSystemPrompt',
98
150
  '--setting-sources': 'settingSources',
151
+ // Also matches `--no-chrome`; both ship together (Claude Code 2.1.307 `-p --help`).
152
+ '--chrome': 'chrome',
99
153
  },
100
154
  // `claude` has no list-models subcommand, so the model list is answered from the best source
101
155
  // available, in this order:
@@ -127,7 +181,7 @@ export const claudeAgentDef = {
127
181
  return routed;
128
182
  const [fromCli, fromApi] = await Promise.all([
129
183
  loadClaudeCodeModels(resolvedBin, env, CLAUDE_FALLBACK_MODELS),
130
- loadAnthropicLiveModels(env, CLAUDE_FALLBACK_MODELS),
184
+ loadAnthropicLiveModels({ env, fallbackModels: CLAUDE_FALLBACK_MODELS }),
131
185
  ]);
132
186
  if (!fromCli)
133
187
  return fromApi;
@@ -156,89 +210,46 @@ export const claudeAgentDef = {
156
210
  // prompt reads the prompt from stdin under `--input-format text` (the
157
211
  // default), which has no length cap. Mirrors the codex/opencode/
158
212
  // cursor/qwen entries below.
159
- buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
160
- const caps = (options.capabilities ?? agentCapabilities.get('claude')) || {};
161
- // `--input-format stream-json` lets the daemon stream multiple JSONL
162
- // messages into stdin instead of closing it after the initial prompt,
163
- // keeping the turn open so the daemon can stream further user messages
164
- // mid-conversation. Paired with `--output-format stream-json` so the
165
- // adapter parses structured events (see claude-stream.ts).
166
- const args = ['-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose'];
167
- // `--include-partial-messages` lands richer streaming events but only
168
- // exists in newer Claude Code builds. Older installs reject it with
169
- // "unknown option" and exit 1, killing the chat. Gate on the probe.
170
- if (caps.partialMessages) {
171
- args.push('--include-partial-messages');
172
- }
173
- if (options.model && options.model !== 'default') {
174
- args.push('--model', options.model);
175
- }
176
- // `--effort` is newer than `--model`, so it gets the same probe gate as
177
- // `--include-partial-messages`: an older build rejects an unknown option
178
- // with exit 1, which kills the chat rather than degrading it.
179
- if (caps.effort
180
- && typeof options.reasoning === 'string'
181
- && CLAUDE_EFFORT_LEVELS.has(options.reasoning)) {
182
- args.push('--effort', options.reasoning);
183
- }
184
- const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
185
- // `--add-dir` is older but still gate it for symmetry — old/forked
186
- // builds may lack it.
187
- if (dirs.length > 0 && caps.addDir !== false) {
188
- args.push('--add-dir', ...dirs);
189
- }
190
- // `--append-system-prompt` delivery now lives outside this function — see
191
- // `systemPromptDelivery` below and `@jini-ai/daemon`'s `resolveSystemPromptOverlayDelivery`
192
- // (the single dispatch point for every def, not just this one). The probe-gate reasoning
193
- // (an older build rejects an unknown option with exit 1, which kills the chat rather than
194
- // degrading it) is preserved there via `capabilityKey: 'appendSystemPrompt'`, read from the
195
- // same `capabilityFlags` probe above — moving the *call site* changed nothing about the gate
196
- // itself.
197
- // Continue Claude's own CLI session across turns so it keeps its
198
- // working memory (files read, edits made, tool history) instead of
199
- // re-deriving everything from the rendered transcript each turn.
200
- // `--resume <id>` continues a stored session; `--session-id <uuid>`
201
- // starts a new one with an id the daemon controls and persists.
202
- if (typeof runtimeContext.resumeSessionId === 'string' && runtimeContext.resumeSessionId) {
203
- args.push('--resume', runtimeContext.resumeSessionId);
204
- }
205
- else if (typeof runtimeContext.newSessionId === 'string' && runtimeContext.newSessionId) {
206
- args.push('--session-id', runtimeContext.newSessionId);
207
- }
208
- // See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default (unchanged
209
- // behavior) unless a caller explicitly opts into a restricted run.
210
- if (options.permissionMode !== 'restricted') {
211
- args.push('--permission-mode', 'bypassPermissions');
212
- }
213
- // Explicit `--strict-mcp-config --mcp-config <path>` instead of relying on Claude Code's
214
- // auto-discovery of `.mcp.json` from cwd. Shared with every other `'claude-mcp-json'` def —
215
- // see `buildClaudeMcpConfigArgs`'s own doc for why explicit, why strict, and why this is one
216
- // implementation rather than a copy per def. A no-op (`[]`) whenever the caller staged no
217
- // file, so a host that never configured MCP injection sees no argv change.
218
- args.push(...buildClaudeMcpConfigArgs(runtimeContext));
219
- // Finding 2 (SEC-assistant-env-isolation-2026-09-07): `RuntimeBuildOptions.disallowedTools`/
220
- // `allowedTools` are a `@jini-ai/agent-runtime`-level *mechanism* only — no product policy is
221
- // baked in here (see `types.ts`'s own doc on those fields). Verified against installed Claude
222
- // Code 2.1.263's own `-p --help`: `--disallowedTools, --disallowed-tools <tools...>` /
223
- // `--allowedTools, --allowed-tools <tools...>`. Placed last, after every other flag, so an
224
- // omitted (default) value is a true no-op — every existing call site that never passes these
225
- // options sees byte-identical argv to before this change.
226
- if (options.disallowedTools && options.disallowedTools.length > 0) {
227
- args.push('--disallowedTools', ...options.disallowedTools);
228
- }
229
- if (options.allowedTools && options.allowedTools.length > 0) {
230
- args.push('--allowedTools', ...options.allowedTools);
231
- }
232
- // See `RuntimeBuildOptions.settingSources`. Probe-gated like `--effort`: an older build
233
- // rejects an unknown option with exit 1, which would kill the chat rather than degrade it.
234
- if (options.settingSources !== undefined && caps.settingSources) {
235
- args.push('--setting-sources', options.settingSources.join(','));
236
- }
237
- // See `RuntimeBuildOptions.settings`. Not probe-gated: `--settings` long predates `--setting-sources`.
238
- if (options.settings) {
239
- args.push('--settings', options.settings);
240
- }
241
- return args;
213
+ buildArgs: (_requiredArgs, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
214
+ const caps = resolveCapabilities({ agentId: 'claude', options });
215
+ return [
216
+ // `--input-format stream-json` lets the daemon stream multiple JSONL
217
+ // messages into stdin instead of closing it after the initial prompt,
218
+ // keeping the turn open so the daemon can stream further user messages
219
+ // mid-conversation. Paired with `--output-format stream-json` so the
220
+ // adapter parses structured events (see claude-stream.ts).
221
+ '-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose',
222
+ // `--include-partial-messages` lands richer streaming events but only
223
+ // exists in newer Claude Code builds. Older installs reject it with
224
+ // "unknown option" and exit 1, killing the chat. Gate on the probe.
225
+ ...(caps.partialMessages ? ['--include-partial-messages'] : []),
226
+ ...nonDefaultFlag({ flag: '--model', value: options.model }),
227
+ ...claudeEffortArgs({ options, caps }),
228
+ // `--add-dir` is older but still gate it for symmetry — old/forked
229
+ // builds may lack it.
230
+ ...addDirArgs({ extraAllowedDirs, caps }),
231
+ // `--append-system-prompt` delivery now lives outside this function — see
232
+ // `systemPromptDelivery` below and `@jini-ai/daemon`'s `resolveSystemPromptOverlayDelivery`
233
+ // (the single dispatch point for every def, not just this one). The probe-gate reasoning
234
+ // (an older build rejects an unknown option with exit 1, which kills the chat rather than
235
+ // degrading it) is preserved there via `capabilityKey: 'appendSystemPrompt'`, read from the
236
+ // same `capabilityFlags` probe above — moving the *call site* changed nothing about the gate
237
+ // itself.
238
+ // Continue Claude's own CLI session across turns (see `sessionArgs`).
239
+ ...sessionArgs(runtimeContext),
240
+ ...permissionModeArgs(options),
241
+ // Explicit `--strict-mcp-config --mcp-config <path>` instead of relying on Claude Code's
242
+ // auto-discovery of `.mcp.json` from cwd. Shared with every other `'claude-mcp-json'` def —
243
+ // see `buildClaudeMcpConfigArgs`'s own doc for why explicit, why strict, and why this is one
244
+ // implementation rather than a copy per def. A no-op (`[]`) whenever the caller staged no
245
+ // file, so a host that never configured MCP injection sees no argv change.
246
+ ...buildClaudeMcpConfigArgs(runtimeContext, options),
247
+ ...claudeToolPolicyArgs(options),
248
+ ...claudeSettingSourcesArgs({ options, caps }),
249
+ // See `RuntimeBuildOptions.settings`. Not probe-gated: `--settings` long predates `--setting-sources`.
250
+ ...(options.settings ? ['--settings', options.settings] : []),
251
+ ...claudeChromeArgs({ options, caps }),
252
+ ];
242
253
  },
243
254
  promptViaStdin: true,
244
255
  promptInputFormat: 'stream-json',
@@ -7,7 +7,7 @@ export declare const clineAgentDef: {
7
7
  resolvedBin: string;
8
8
  env: import("../types.js").RuntimeEnv;
9
9
  }, { acpModelProbe }?: {
10
- acpModelProbe?: import("../acp-model-probe.js").AcpModelProbe;
10
+ acpModelProbe?: import("../types.js").AcpModelProbe;
11
11
  } | undefined) => Promise<import("../types.js").RuntimeModelOption[]>;
12
12
  fallbackModels: import("../types.js").RuntimeModelOption[];
13
13
  buildArgs: () => string[];
@@ -14,7 +14,7 @@ export declare const codebuddyAgentDef: {
14
14
  id: string;
15
15
  label: string;
16
16
  }[];
17
- buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }: {
17
+ buildArgs: (_requiredArgs: {
18
18
  prompt: string;
19
19
  imagePaths: string[];
20
20
  }, { extraAllowedDirs, options, runtimeContext }?: {
@@ -1,5 +1,5 @@
1
1
  import { createAgentModelDiscovery } from '../model-discovery-native.js';
2
- import { agentCapabilities } from '../capabilities.js';
2
+ import { addDirArgs, nonDefaultFlag, permissionModeArgs, resolveCapabilities, sessionArgs } from './claude-compatible-args.js';
3
3
  import { buildClaudeMcpConfigArgs, DEFAULT_MODEL_OPTION } from './shared.js';
4
4
  // Codebuddy Code (https://www.codebuddy.cn) — a Claude Code–compatible CLI
5
5
  // that ships as `codebuddy` (short alias: `cbc`). The argument surface is a
@@ -78,51 +78,34 @@ export const codebuddyAgentDef = {
78
78
  { id: 'xhigh', label: 'XHigh' },
79
79
  { id: 'max', label: 'Max' },
80
80
  ],
81
- buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
82
- const caps = (options.capabilities ?? agentCapabilities.get('codebuddy')) || {};
83
- // Same stdin strategy as Claude Code: `--input-format stream-json`
84
- // enables JSONL stdin so the daemon can answer AskUserQuestion tool
85
- // calls. `--output-format stream-json` gives us SSE-style events.
86
- const args = ['-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose'];
87
- // `--include-partial-messages` lands richer streaming deltas. Gate on
88
- // the help-text probe to avoid "unknown option" errors on older builds.
89
- if (caps.partialMessages) {
90
- args.push('--include-partial-messages');
91
- }
92
- if (options.model && options.model !== 'default') {
93
- args.push('--model', options.model);
94
- }
95
- // Reasoning effort control — Codebuddy supports `--effort <level>`.
96
- // The `default` sentinel means "let Codebuddy pick" — omit the flag.
97
- if (options.reasoning && options.reasoning !== 'default') {
98
- args.push('--effort', options.reasoning);
99
- }
100
- const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
101
- if (dirs.length > 0 && caps.addDir !== false) {
102
- args.push('--add-dir', ...dirs);
103
- }
104
- // Session continuity: Codebuddy supports `--resume <id>` and
105
- // `--session-id <uuid>` identically to Claude Code.
106
- if (typeof runtimeContext.resumeSessionId === 'string' && runtimeContext.resumeSessionId) {
107
- args.push('--resume', runtimeContext.resumeSessionId);
108
- }
109
- else if (typeof runtimeContext.newSessionId === 'string' && runtimeContext.newSessionId) {
110
- args.push('--session-id', runtimeContext.newSessionId);
111
- }
112
- // See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default (unchanged
113
- // behavior) unless a caller explicitly opts into a restricted run.
114
- if (options.permissionMode !== 'restricted') {
115
- args.push('--permission-mode', 'bypassPermissions');
116
- }
117
- // Same explicit staged-config delivery as the claude def, through the same shared helper —
118
- // see `buildClaudeMcpConfigArgs`'s doc. Without this, declaring
119
- // `externalMcpInjection: 'claude-mcp-json'` (below) only got the file *written*; Codebuddy
120
- // then had to auto-discover it, which is exactly the headless-trust-prompt hang the claude
121
- // fix was built to avoid. Both flags are documented on Codebuddy's own CLI reference
122
- // (`--mcp-config <fileOrString>`, `--strict-mcp-config`), so the strict-isolation guarantee
123
- // is not silently degraded here relative to claude.
124
- args.push(...buildClaudeMcpConfigArgs(runtimeContext));
125
- return args;
81
+ buildArgs: (_requiredArgs, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
82
+ const caps = resolveCapabilities({ agentId: 'codebuddy', options });
83
+ return [
84
+ // Same stdin strategy as Claude Code: `--input-format stream-json`
85
+ // enables JSONL stdin so the daemon can answer AskUserQuestion tool
86
+ // calls. `--output-format stream-json` gives us SSE-style events.
87
+ '-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose',
88
+ // `--include-partial-messages` lands richer streaming deltas. Gate on
89
+ // the help-text probe to avoid "unknown option" errors on older builds.
90
+ ...(caps.partialMessages ? ['--include-partial-messages'] : []),
91
+ ...nonDefaultFlag({ flag: '--model', value: options.model }),
92
+ // Reasoning effort control — Codebuddy supports `--effort <level>`.
93
+ // The `default` sentinel means "let Codebuddy pick" — omit the flag.
94
+ ...nonDefaultFlag({ flag: '--effort', value: options.reasoning }),
95
+ ...addDirArgs({ extraAllowedDirs, caps }),
96
+ // Session continuity: Codebuddy supports `--resume <id>` and
97
+ // `--session-id <uuid>` identically to Claude Code.
98
+ ...sessionArgs(runtimeContext),
99
+ ...permissionModeArgs(options),
100
+ // Same explicit staged-config delivery as the claude def, through the same shared helper —
101
+ // see `buildClaudeMcpConfigArgs`'s doc. Without this, declaring
102
+ // `externalMcpInjection: 'claude-mcp-json'` (below) only got the file *written*; Codebuddy
103
+ // then had to auto-discover it, which is exactly the headless-trust-prompt hang the claude
104
+ // fix was built to avoid. Both flags are documented on Codebuddy's own CLI reference
105
+ // (`--mcp-config <fileOrString>`, `--strict-mcp-config`), so the strict-isolation guarantee
106
+ // is not silently degraded here relative to claude.
107
+ ...buildClaudeMcpConfigArgs(runtimeContext, options),
108
+ ];
126
109
  },
127
110
  promptViaStdin: true,
128
111
  promptInputFormat: 'stream-json',
@@ -1,4 +1,15 @@
1
1
  import type { RuntimeModelOption, RuntimeReasoningOption } from '../types.js';
2
+ import type { RuntimeBuildOptions, RuntimeContext } from '../types.js';
3
+ /**
4
+ * Parses `codex debug models` stdout into the Local-CLI picker's model rows.
5
+ *
6
+ * Each row carries the model's OWN supported effort levels when the catalog reports them — see
7
+ * `RuntimeModelOption.reasoning`. Hidden entries are dropped (see `isHiddenVisibility`).
8
+ *
9
+ * @returns The rows, `default` sentinel first; `null` when the output is unparseable or yielded no
10
+ * model at all, which is `detection.ts#fetchModels`'s signal to keep the static fallback list.
11
+ * @complexity O(n·m) — one pass over n catalog entries, each with m declared effort levels.
12
+ */
2
13
  export declare function parseCodexDebugModels({ stdout }: {
3
14
  stdout: string;
4
15
  }): RuntimeModelOption[] | null;
@@ -27,6 +38,7 @@ export declare function codexNeedsDangerFullAccessSandbox({}: {}, { platform, en
27
38
  }): boolean;
28
39
  export declare const codexAgentDef: {
29
40
  id: string;
41
+ supportsNativeToolAccess: true;
30
42
  name: string;
31
43
  bin: string;
32
44
  versionArgs: string[];
@@ -46,13 +58,13 @@ export declare const codexAgentDef: {
46
58
  label: string;
47
59
  }[];
48
60
  deriveReasoningOptions: typeof unionModelReasoningOptions;
49
- buildArgs: ({ prompt: _prompt, imagePaths }: {
61
+ buildArgs: ({ imagePaths }: {
50
62
  prompt: string;
51
63
  imagePaths: string[];
52
64
  }, { extraAllowedDirs, options, runtimeContext }?: {
53
65
  extraAllowedDirs?: string[];
54
- options?: import("../types.js").RuntimeBuildOptions;
55
- runtimeContext?: import("../types.js").RuntimeContext;
66
+ options?: RuntimeBuildOptions;
67
+ runtimeContext?: RuntimeContext;
56
68
  } | undefined) => string[];
57
69
  promptViaStdin: true;
58
70
  resumesSessionViaCli: true;