@jini-ai/agent-runtime 0.4.11 → 0.4.12
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/CHANGELOG.md +4 -0
- package/dist/acp-model-probe.d.ts +2 -20
- package/dist/agent-protocol/acp/json.js +46 -37
- package/dist/agent-protocol/acp/models.js +91 -73
- package/dist/agent-protocol/acp/rpc.d.ts +3 -2
- package/dist/agent-protocol/acp/rpc.js +3 -2
- package/dist/agent-protocol/acp/session-params.d.ts +1 -1
- package/dist/agent-protocol/acp/session-params.js +33 -30
- package/dist/agent-protocol/acp/session.d.ts +3 -1
- package/dist/agent-protocol/acp/session.js +62 -24
- package/dist/agent-protocol/acp/updates.js +49 -35
- package/dist/agent-protocol/pi-rpc/session.js +3 -1
- package/dist/anthropic-live-models.d.ts +12 -4
- package/dist/anthropic-live-models.js +0 -0
- package/dist/auth.js +84 -91
- package/dist/claude-code-models.d.ts +6 -5
- package/dist/claude-code-models.js +19 -12
- package/dist/claude-segment-usage.d.ts +3 -3
- package/dist/claude-segment-usage.js +63 -29
- package/dist/claude-stream.js +12 -5
- package/dist/copilot-stream.js +42 -50
- package/dist/defs/aider.js +3 -4
- package/dist/defs/amr.js +52 -61
- package/dist/defs/antigravity.d.ts +6 -5
- package/dist/defs/antigravity.js +48 -34
- package/dist/defs/auggie.d.ts +1 -1
- package/dist/defs/claude-compatible-args.d.ts +19 -0
- package/dist/defs/claude-compatible-args.js +42 -0
- package/dist/defs/claude.d.ts +7 -2
- package/dist/defs/claude.js +96 -85
- package/dist/defs/cline.d.ts +1 -1
- package/dist/defs/codebuddy.d.ts +1 -1
- package/dist/defs/codebuddy.js +29 -46
- package/dist/defs/codex.d.ts +15 -3
- package/dist/defs/codex.js +143 -108
- package/dist/defs/cursor-agent.d.ts +9 -7
- package/dist/defs/cursor-agent.js +53 -51
- package/dist/defs/devin.d.ts +1 -1
- package/dist/defs/goose.d.ts +1 -1
- package/dist/defs/hermes.d.ts +1 -1
- package/dist/defs/kilo.d.ts +1 -1
- package/dist/defs/kimi.d.ts +1 -1
- package/dist/defs/kiro.d.ts +1 -1
- package/dist/defs/opencode.d.ts +5 -4
- package/dist/defs/opencode.js +26 -32
- package/dist/defs/pi.d.ts +6 -5
- package/dist/defs/pi.js +24 -26
- package/dist/defs/qoder.d.ts +4 -3
- package/dist/defs/qoder.js +25 -25
- package/dist/defs/reasonix.d.ts +1 -1
- package/dist/defs/shared.d.ts +12 -3
- package/dist/defs/shared.js +19 -13
- package/dist/defs/trae-cli.d.ts +1 -1
- package/dist/defs/vibe.d.ts +1 -1
- package/dist/detection.d.ts +13 -20
- package/dist/detection.js +129 -111
- package/dist/env.js +56 -41
- package/dist/executables.js +103 -114
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json-event-stream.js +611 -527
- package/dist/launch.js +44 -37
- package/dist/model-discovery-adapters.d.ts +17 -0
- package/dist/model-discovery-adapters.js +223 -164
- package/dist/model-discovery-config.js +107 -87
- package/dist/model-discovery-sdk.d.ts +16 -2
- package/dist/model-discovery-sdk.js +4 -3
- package/dist/model-discovery-shared.d.ts +14 -0
- package/dist/model-discovery-shared.js +50 -15
- package/dist/model-discovery-types.d.ts +2 -0
- package/dist/model-discovery.js +219 -117
- package/dist/models.d.ts +14 -1
- package/dist/models.js +75 -19
- package/dist/native-tool-policy.d.ts +29 -0
- package/dist/native-tool-policy.js +36 -0
- package/dist/opencode-log.js +46 -30
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +3 -3
- package/dist/providers/aihubmix.js +13 -18
- package/dist/providers/anthropic-messages.d.ts +7 -0
- package/dist/providers/anthropic-messages.js +45 -21
- package/dist/providers/azure-chat.d.ts +5 -0
- package/dist/providers/azure-chat.js +13 -5
- package/dist/providers/connection-guard.d.ts +2 -45
- package/dist/providers/connection-guard.js +11 -10
- package/dist/providers/connection-test.d.ts +4 -0
- package/dist/providers/connection-test.js +127 -110
- package/dist/providers/elevenlabs.js +4 -1
- package/dist/providers/google-messages.d.ts +4 -0
- package/dist/providers/google-messages.js +48 -23
- package/dist/providers/google-schema.js +17 -23
- package/dist/providers/model-catalog.js +160 -145
- package/dist/providers/oauth-callback-server.js +37 -34
- package/dist/providers/oauth-credentials.js +23 -23
- package/dist/providers/oauth-tokens.js +16 -24
- package/dist/providers/openai-chat.d.ts +42 -0
- package/dist/providers/openai-chat.js +80 -10
- package/dist/providers/operation-schema.d.ts +25 -0
- package/dist/providers/operation-schema.js +226 -0
- package/dist/providers/response-text.d.ts +10 -0
- package/dist/providers/response-text.js +23 -0
- package/dist/providers/tool-turn-types.d.ts +35 -9
- package/dist/providers/tool-turn.d.ts +7 -0
- package/dist/providers/tool-turn.js +113 -32
- package/dist/qoder-stream.js +93 -80
- package/dist/registry.d.ts +45 -0
- package/dist/registry.js +39 -0
- package/dist/runtime-state.d.ts +1 -1
- package/dist/types.d.ts +43 -1
- package/package.json +16 -7
package/dist/defs/codex.js
CHANGED
|
@@ -96,16 +96,6 @@ function readCodexCatalogEntries(stdout) {
|
|
|
96
96
|
const models = parsed.models;
|
|
97
97
|
return Array.isArray(models) ? models : null;
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Parses `codex debug models` stdout into the Local-CLI picker's model rows.
|
|
101
|
-
*
|
|
102
|
-
* Each row carries the model's OWN supported effort levels when the catalog reports them — see
|
|
103
|
-
* `RuntimeModelOption.reasoning`. Hidden entries are dropped (see `isHiddenVisibility`).
|
|
104
|
-
*
|
|
105
|
-
* @returns The rows, `default` sentinel first; `null` when the output is unparseable or yielded no
|
|
106
|
-
* model at all, which is `detection.ts#fetchModels`'s signal to keep the static fallback list.
|
|
107
|
-
* @complexity O(n·m) — one pass over n catalog entries, each with m declared effort levels.
|
|
108
|
-
*/
|
|
109
99
|
/** One catalog entry as a picker row, or `null` when it is malformed, hidden, id-less, or a repeat
|
|
110
100
|
* of an id already taken. Split from the loop below purely to keep both units small. */
|
|
111
101
|
function codexCatalogRow(raw, takenIds) {
|
|
@@ -120,6 +110,16 @@ function codexCatalogRow(raw, takenIds) {
|
|
|
120
110
|
const reasoning = parseCodexEntryReasoning(entry.supported_reasoning_levels);
|
|
121
111
|
return { id, label: codexEntryLabel(entry, id), ...(reasoning ? { reasoning } : {}) };
|
|
122
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Parses `codex debug models` stdout into the Local-CLI picker's model rows.
|
|
115
|
+
*
|
|
116
|
+
* Each row carries the model's OWN supported effort levels when the catalog reports them — see
|
|
117
|
+
* `RuntimeModelOption.reasoning`. Hidden entries are dropped (see `isHiddenVisibility`).
|
|
118
|
+
*
|
|
119
|
+
* @returns The rows, `default` sentinel first; `null` when the output is unparseable or yielded no
|
|
120
|
+
* model at all, which is `detection.ts#fetchModels`'s signal to keep the static fallback list.
|
|
121
|
+
* @complexity O(n·m) — one pass over n catalog entries, each with m declared effort levels.
|
|
122
|
+
*/
|
|
123
123
|
export function parseCodexDebugModels({ stdout }) {
|
|
124
124
|
const models = readCodexCatalogEntries(stdout);
|
|
125
125
|
if (!models)
|
|
@@ -176,9 +176,115 @@ export function codexNeedsDangerFullAccessSandbox({}, { platform = process.platf
|
|
|
176
176
|
// workspace-write sandbox path when launched from there.
|
|
177
177
|
return Boolean(env.WSL_DISTRO_NAME?.trim());
|
|
178
178
|
}
|
|
179
|
+
const CODEX_TURN_COMMAND = {
|
|
180
|
+
create: ['exec', '--json', '--skip-git-repo-check'],
|
|
181
|
+
resume: ['exec', 'resume', '--json', '--skip-git-repo-check'],
|
|
182
|
+
};
|
|
183
|
+
// `codex exec resume` rejects `--sandbox` (only valid on a fresh
|
|
184
|
+
// `exec`); the sandbox mode must be passed as a `-c sandbox_mode=...`
|
|
185
|
+
// config override. We mirror the exact same effective sandbox policy as
|
|
186
|
+
// the create turn so Codex's per-turn `turn_context` block byte-matches
|
|
187
|
+
// across turns and does not break the upstream prefix cache the resume
|
|
188
|
+
// is meant to reuse.
|
|
189
|
+
const CODEX_SANDBOX_ARGS = {
|
|
190
|
+
'read-only': {
|
|
191
|
+
create: ['-c', 'sandbox_mode="read-only"'],
|
|
192
|
+
resume: ['-c', 'sandbox_mode="read-only"'],
|
|
193
|
+
},
|
|
194
|
+
'danger-full-access': {
|
|
195
|
+
create: ['--sandbox', 'danger-full-access'],
|
|
196
|
+
resume: ['-c', 'sandbox_mode="danger-full-access"'],
|
|
197
|
+
},
|
|
198
|
+
'workspace-write': {
|
|
199
|
+
create: ['--sandbox', 'workspace-write', '-c', 'sandbox_workspace_write.network_access=true'],
|
|
200
|
+
resume: ['-c', 'sandbox_mode="workspace-write"', '-c', 'sandbox_workspace_write.network_access=true'],
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
// Read-only prevents direct patches; disable every shell transport as well.
|
|
204
|
+
// CLI config overrides apply on BOTH create and resume, regardless of the saved session.
|
|
205
|
+
const CODEX_NATIVE_TOOLS_LOCKED_ARGS = [
|
|
206
|
+
'-c', 'features.shell_tool=false', '-c', 'features.unified_exec=false',
|
|
207
|
+
'-c', 'features.code_mode=false', '-c', 'features.apply_patch_freeform=false',
|
|
208
|
+
'-c', 'features.multi_agent=false', '-c', 'features.collab=false', '-c', 'features.plugins=false',
|
|
209
|
+
'-c', 'approval_policy="never"',
|
|
210
|
+
];
|
|
211
|
+
// Per-turn overrides also apply to resumed sessions, ahead of persisted CLI defaults.
|
|
212
|
+
// One `-c` override per value, emitted in this order for each capability the host set to false.
|
|
213
|
+
const CODEX_CAPABILITY_OVERRIDES = [
|
|
214
|
+
['shell', ['features.shell_tool=false', 'features.unified_exec=false', 'features.code_mode=false']],
|
|
215
|
+
['fileWrite', ['features.apply_patch_freeform=false']],
|
|
216
|
+
['subagents', ['features.multi_agent=false', 'features.collab=false']],
|
|
217
|
+
['web', ['web_search="disabled"']],
|
|
218
|
+
['workflows', ['features.worktrees=false', 'features.remote_control=false']],
|
|
219
|
+
['userSettings', ['features.skills=false', 'features.plugins=false']],
|
|
220
|
+
];
|
|
221
|
+
// Capture-style resume: when the caller has a stored Codex thread id
|
|
222
|
+
// for this conversation it asks the CLI to continue that session
|
|
223
|
+
// with `exec resume <thread_id>` instead of `exec` (a fresh
|
|
224
|
+
// session). Codex mints its own id, so the caller does not specify
|
|
225
|
+
// one — it captures the id from the create turn's
|
|
226
|
+
// `thread.started.thread_id` event (see the json-event-stream
|
|
227
|
+
// `codex` parser) and replays it here on resume.
|
|
228
|
+
function codexResumeSessionId(runtimeContext) {
|
|
229
|
+
const resumeSessionId = runtimeContext.resumeSessionId;
|
|
230
|
+
return typeof resumeSessionId === 'string' && resumeSessionId.length > 0 ? resumeSessionId : null;
|
|
231
|
+
}
|
|
232
|
+
function codexSandboxTier(options) {
|
|
233
|
+
if (options.nativeToolAccess === false || options.nativeCapabilities?.fileWrite === false)
|
|
234
|
+
return 'read-only';
|
|
235
|
+
// Codex CLI's `workspace-write` sandbox blocks shell invocations on
|
|
236
|
+
// Windows ("powershell.exe ... rejected: blocked by policy"),
|
|
237
|
+
// because Codex has no working OS-level sandbox on Windows and falls
|
|
238
|
+
// back to a coarse policy that rejects any shell. macOS (Seatbelt)
|
|
239
|
+
// and Linux (Landlock+seccomp) keep workspace-write because their
|
|
240
|
+
// sandbox enforcement permits shell while restricting writes.
|
|
241
|
+
const trustedBypass = options.cliParity === true && options.permissionMode === 'bypass';
|
|
242
|
+
return trustedBypass || codexNeedsDangerFullAccessSandbox({}) ? 'danger-full-access' : 'workspace-write';
|
|
243
|
+
}
|
|
244
|
+
/** Approval, native-tool lock, per-capability overrides and plugin policy, in that order. */
|
|
245
|
+
function codexPolicyArgs(options) {
|
|
246
|
+
const nativeToolsLocked = options.nativeToolAccess === false;
|
|
247
|
+
const native = options.nativeCapabilities;
|
|
248
|
+
return [
|
|
249
|
+
...(options.cliParity && options.permissionMode === 'bypass' && !nativeToolsLocked ? ['-c', 'approval_policy="never"'] : []),
|
|
250
|
+
...(nativeToolsLocked ? CODEX_NATIVE_TOOLS_LOCKED_ARGS : []),
|
|
251
|
+
...CODEX_CAPABILITY_OVERRIDES.flatMap(([key, values]) => (native?.[key] === false ? values.flatMap((value) => ['-c', value]) : [])),
|
|
252
|
+
...(options.codexDisablePlugins === true ? ['--disable', 'plugins'] : []),
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
// `-C <cwd>` and `--add-dir <dir>` are CREATE-only flags: `codex exec
|
|
256
|
+
// resume` rejects both (`error: unexpected argument '-C' found`), so
|
|
257
|
+
// appending them on a resume turn would make the follow-up turn die
|
|
258
|
+
// before the first event. The caller already spawns the child with
|
|
259
|
+
// `cwd: effectiveCwd`, and resuming by explicit SESSION_ID does not
|
|
260
|
+
// use codex's cwd-based session filtering, so the resumed turn still
|
|
261
|
+
// runs in the right workspace without `-C`. The extra writable dirs
|
|
262
|
+
// were granted when the session was created and are carried by the
|
|
263
|
+
// resumed session.
|
|
264
|
+
function codexCreateOnlyArgs({ extraAllowedDirs, runtimeContext }) {
|
|
265
|
+
return [
|
|
266
|
+
...(runtimeContext.cwd ? ['-C', runtimeContext.cwd] : []),
|
|
267
|
+
...nonEmptyStrings(extraAllowedDirs).flatMap((d) => ['--add-dir', d]),
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
function codexModelArgs(options) {
|
|
271
|
+
const args = options.model && options.model !== 'default' ? ['--model', options.model] : [];
|
|
272
|
+
if (options.reasoning && options.reasoning !== 'default') {
|
|
273
|
+
const effort = clampCodexReasoning(options.model, options.reasoning);
|
|
274
|
+
// Codex accepts `-c key=value` config overrides; reasoning effort
|
|
275
|
+
// is exposed as `model_reasoning_effort`.
|
|
276
|
+
args.push('-c', `model_reasoning_effort="${effort}"`);
|
|
277
|
+
}
|
|
278
|
+
return args;
|
|
279
|
+
}
|
|
280
|
+
/** Non-empty string entries only; a nullish list (loosely-typed caller) yields none. */
|
|
281
|
+
function nonEmptyStrings(values) {
|
|
282
|
+
return (values || []).filter((value) => typeof value === 'string' && value.length > 0);
|
|
283
|
+
}
|
|
179
284
|
export const codexAgentDef = {
|
|
180
|
-
...createAgentModelDiscovery('codex', { fallbackModels: () => codexAgentDef.fallbackModels, args: ['debug', 'models'], parse:
|
|
285
|
+
...createAgentModelDiscovery('codex', { fallbackModels: () => codexAgentDef.fallbackModels, args: ['debug', 'models'], parse: parseCodexDebugModels }),
|
|
181
286
|
id: 'codex',
|
|
287
|
+
supportsNativeToolAccess: true,
|
|
182
288
|
name: 'Codex CLI',
|
|
183
289
|
bin: 'codex',
|
|
184
290
|
versionArgs: ['--version'],
|
|
@@ -247,103 +353,32 @@ export const codexAgentDef = {
|
|
|
247
353
|
// `error: unexpected argument '-' found` and the agent exits with
|
|
248
354
|
// code 2 before any prompt is read. The pipe alone is sufficient for
|
|
249
355
|
// stdin delivery.
|
|
250
|
-
buildArgs: ({
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
? resumeSessionId
|
|
277
|
-
? ['-c', 'sandbox_mode="danger-full-access"']
|
|
278
|
-
: ['--sandbox', 'danger-full-access']
|
|
279
|
-
: resumeSessionId
|
|
280
|
-
? [
|
|
281
|
-
'-c',
|
|
282
|
-
'sandbox_mode="workspace-write"',
|
|
283
|
-
'-c',
|
|
284
|
-
'sandbox_workspace_write.network_access=true',
|
|
285
|
-
]
|
|
286
|
-
: [
|
|
287
|
-
'--sandbox',
|
|
288
|
-
'workspace-write',
|
|
289
|
-
'-c',
|
|
290
|
-
'sandbox_workspace_write.network_access=true',
|
|
291
|
-
];
|
|
292
|
-
const args = resumeSessionId
|
|
293
|
-
? ['exec', 'resume', '--json', '--skip-git-repo-check', ...sandboxArgs]
|
|
294
|
-
: ['exec', '--json', '--skip-git-repo-check', ...sandboxArgs];
|
|
295
|
-
if (options.codexDisablePlugins === true) {
|
|
296
|
-
args.push('--disable', 'plugins');
|
|
297
|
-
}
|
|
298
|
-
// `-C <cwd>` and `--add-dir <dir>` are CREATE-only flags: `codex exec
|
|
299
|
-
// resume` rejects both (`error: unexpected argument '-C' found`), so
|
|
300
|
-
// appending them on a resume turn would make the follow-up turn die
|
|
301
|
-
// before the first event. The caller already spawns the child with
|
|
302
|
-
// `cwd: effectiveCwd`, and resuming by explicit SESSION_ID does not
|
|
303
|
-
// use codex's cwd-based session filtering, so the resumed turn still
|
|
304
|
-
// runs in the right workspace without `-C`. The extra writable dirs
|
|
305
|
-
// were granted when the session was created and are carried by the
|
|
306
|
-
// resumed session.
|
|
307
|
-
if (!resumeSessionId) {
|
|
308
|
-
if (runtimeContext.cwd) {
|
|
309
|
-
args.push('-C', runtimeContext.cwd);
|
|
310
|
-
}
|
|
311
|
-
const dirs = (extraAllowedDirs || []).filter((d) => typeof d === 'string' && d.length > 0);
|
|
312
|
-
for (const d of dirs) {
|
|
313
|
-
args.push('--add-dir', d);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (options.model && options.model !== 'default') {
|
|
317
|
-
args.push('--model', options.model);
|
|
318
|
-
}
|
|
319
|
-
if (options.reasoning && options.reasoning !== 'default') {
|
|
320
|
-
const effort = clampCodexReasoning(options.model, options.reasoning);
|
|
321
|
-
// Codex accepts `-c key=value` config overrides; reasoning effort
|
|
322
|
-
// is exposed as `model_reasoning_effort`.
|
|
323
|
-
args.push('-c', `model_reasoning_effort="${effort}"`);
|
|
324
|
-
}
|
|
325
|
-
// Own dedicated `-i/--image <FILE>` argv flag — confirmed against a
|
|
326
|
-
// real installed Codex CLI (0.151.0) on BOTH `codex exec --help` and
|
|
327
|
-
// `codex exec resume --help`, so unlike `-C`/`--add-dir` above this is
|
|
328
|
-
// not create-only and needs no `resumeSessionId` guard. Pushed for
|
|
329
|
-
// every claimed attachment path the caller hands in here, not only
|
|
330
|
-
// ones actually of kind "image": the caller
|
|
331
|
-
// (`agent-daemon-server.ts#resolveAttachmentRunFields`, in the consuming product) already
|
|
332
|
-
// stopped filtering by kind for the same reason `qoderAgentDef`'s
|
|
333
|
-
// `--attachment` above does not filter either — a same-shaped
|
|
334
|
-
// repeated-flag mechanism, see `imageDelivery`'s doc below.
|
|
335
|
-
const attachments = (imagePaths || []).filter((p) => typeof p === 'string' && p.length > 0);
|
|
336
|
-
for (const p of attachments) {
|
|
337
|
-
args.push('-i', p);
|
|
338
|
-
}
|
|
339
|
-
// The resume thread id is the positional SESSION_ID argument of
|
|
340
|
-
// `codex exec resume`; it must come after the flags. The prompt is
|
|
341
|
-
// delivered via stdin (promptViaStdin), so the thread id is the final
|
|
342
|
-
// argv entry.
|
|
343
|
-
if (resumeSessionId) {
|
|
344
|
-
args.push(resumeSessionId);
|
|
345
|
-
}
|
|
346
|
-
return args;
|
|
356
|
+
buildArgs: ({ imagePaths }, { extraAllowedDirs = [], options = {}, runtimeContext = {} } = {}) => {
|
|
357
|
+
const resumeSessionId = codexResumeSessionId(runtimeContext);
|
|
358
|
+
const turn = resumeSessionId ? 'resume' : 'create';
|
|
359
|
+
return [
|
|
360
|
+
...CODEX_TURN_COMMAND[turn],
|
|
361
|
+
...CODEX_SANDBOX_ARGS[codexSandboxTier(options)][turn],
|
|
362
|
+
...codexPolicyArgs(options),
|
|
363
|
+
...(resumeSessionId ? [] : codexCreateOnlyArgs({ extraAllowedDirs, runtimeContext })),
|
|
364
|
+
...codexModelArgs(options),
|
|
365
|
+
// Own dedicated `-i/--image <FILE>` argv flag — confirmed against a
|
|
366
|
+
// real installed Codex CLI (0.151.0) on BOTH `codex exec --help` and
|
|
367
|
+
// `codex exec resume --help`, so unlike `-C`/`--add-dir` above this is
|
|
368
|
+
// not create-only and needs no `resumeSessionId` guard. Pushed for
|
|
369
|
+
// every claimed attachment path the caller hands in here, not only
|
|
370
|
+
// ones actually of kind "image": the caller
|
|
371
|
+
// (`agent-daemon-server.ts#resolveAttachmentRunFields`, in the consuming product) already
|
|
372
|
+
// stopped filtering by kind for the same reason `qoderAgentDef`'s
|
|
373
|
+
// `--attachment` above does not filter either — a same-shaped
|
|
374
|
+
// repeated-flag mechanism, see `imageDelivery`'s doc below.
|
|
375
|
+
...nonEmptyStrings(imagePaths).flatMap((p) => ['-i', p]),
|
|
376
|
+
// The resume thread id is the positional SESSION_ID argument of
|
|
377
|
+
// `codex exec resume`; it must come after the flags. The prompt is
|
|
378
|
+
// delivered via stdin (promptViaStdin), so the thread id is the final
|
|
379
|
+
// argv entry.
|
|
380
|
+
...(resumeSessionId ? [resumeSessionId] : []),
|
|
381
|
+
];
|
|
347
382
|
},
|
|
348
383
|
promptViaStdin: true,
|
|
349
384
|
// Codex's CLI carries its own session across spawns: on a follow-up turn
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { RuntimeModelOption } from '../types.js';
|
|
1
|
+
import type { RuntimeBuildOptions, RuntimeModelOption } from '../types.js';
|
|
2
2
|
export declare function parseCursorAgentModels({ stdout }: {
|
|
3
3
|
stdout: string;
|
|
4
4
|
}): RuntimeModelOption[] | null;
|
|
5
|
+
declare function parseCursorAgentListing({ stdout }: {
|
|
6
|
+
stdout: string;
|
|
7
|
+
}): RuntimeModelOption[] | null;
|
|
5
8
|
export declare const cursorAgentDef: {
|
|
6
9
|
id: string;
|
|
7
10
|
name: string;
|
|
@@ -14,17 +17,15 @@ export declare const cursorAgentDef: {
|
|
|
14
17
|
listModels: {
|
|
15
18
|
args: string[];
|
|
16
19
|
timeoutMs: number;
|
|
17
|
-
parse:
|
|
18
|
-
stdout: string;
|
|
19
|
-
}) => RuntimeModelOption[] | null;
|
|
20
|
+
parse: typeof parseCursorAgentListing;
|
|
20
21
|
};
|
|
21
22
|
fallbackModels: RuntimeModelOption[];
|
|
22
|
-
buildArgs: (
|
|
23
|
+
buildArgs: (_requiredArgs: {
|
|
23
24
|
prompt: string;
|
|
24
25
|
imagePaths: string[];
|
|
25
|
-
}, {
|
|
26
|
+
}, { options, runtimeContext }?: {
|
|
26
27
|
extraAllowedDirs?: string[];
|
|
27
|
-
options?:
|
|
28
|
+
options?: RuntimeBuildOptions;
|
|
28
29
|
runtimeContext?: import("../types.js").RuntimeContext;
|
|
29
30
|
} | undefined) => string[];
|
|
30
31
|
promptViaStdin: true;
|
|
@@ -50,4 +51,5 @@ export declare const cursorAgentDef: {
|
|
|
50
51
|
deps?: import("../model-discovery-types.js").ModelDiscoveryDeps;
|
|
51
52
|
}): Promise<import("../model-discovery-types.js").DefaultModelResolution>;
|
|
52
53
|
};
|
|
54
|
+
export {};
|
|
53
55
|
//# sourceMappingURL=cursor-agent.d.ts.map
|
|
@@ -1,33 +1,62 @@
|
|
|
1
1
|
import { createAgentModelDiscovery } from '../model-discovery-native.js';
|
|
2
2
|
import { DEFAULT_MODEL_OPTION } from './shared.js';
|
|
3
3
|
import { agentCapabilities } from '../capabilities.js';
|
|
4
|
+
/** One `<id>` or `<id> - <label>` listing line; header lines and non-id lines yield null. */
|
|
5
|
+
function parseCursorAgentModelLine(line) {
|
|
6
|
+
if (/^(available models|models)$/i.test(line))
|
|
7
|
+
return null;
|
|
8
|
+
const match = line.match(/^([A-Za-z0-9][A-Za-z0-9._/:@-]*)(?:\s+-\s+(.+))?$/);
|
|
9
|
+
if (!match)
|
|
10
|
+
return null;
|
|
11
|
+
// The id group is mandatory and non-empty whenever the pattern matched.
|
|
12
|
+
const id = match[1];
|
|
13
|
+
return { id, label: match[2]?.trim() || id };
|
|
14
|
+
}
|
|
4
15
|
export function parseCursorAgentModels({ stdout }) {
|
|
5
16
|
const lines = String(stdout || '')
|
|
6
17
|
.split('\n')
|
|
7
18
|
.map((line) => line.trim())
|
|
8
19
|
.filter((line) => line.length > 0 && !line.startsWith('#'));
|
|
9
|
-
if (lines.length === 0)
|
|
10
|
-
return null;
|
|
11
20
|
const out = [DEFAULT_MODEL_OPTION];
|
|
12
21
|
const seen = new Set([DEFAULT_MODEL_OPTION.id]);
|
|
13
22
|
for (const line of lines) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const match = line.match(/^([A-Za-z0-9][A-Za-z0-9._/:@-]*)(?:\s+-\s+(.+))?$/);
|
|
17
|
-
if (!match)
|
|
18
|
-
continue;
|
|
19
|
-
const id = match[1];
|
|
20
|
-
if (!id || seen.has(id))
|
|
23
|
+
const model = parseCursorAgentModelLine(line);
|
|
24
|
+
if (!model || seen.has(model.id))
|
|
21
25
|
continue;
|
|
22
|
-
seen.add(id);
|
|
23
|
-
|
|
24
|
-
out.push({ id, label });
|
|
26
|
+
seen.add(model.id);
|
|
27
|
+
out.push(model);
|
|
25
28
|
}
|
|
26
29
|
return out.length > 1 ? out : null;
|
|
27
30
|
}
|
|
31
|
+
// `cursor-agent models` prints account-bound model ids per line. When
|
|
32
|
+
// the user isn't authed it prints "No models available for this
|
|
33
|
+
// account." — that's not a model list, so we detect it and fall back.
|
|
34
|
+
function parseCursorAgentListing({ stdout }) {
|
|
35
|
+
const trimmed = String(stdout || '').trim();
|
|
36
|
+
if (!trimmed || /no models available/i.test(trimmed))
|
|
37
|
+
return null;
|
|
38
|
+
return parseCursorAgentModels({ stdout: trimmed });
|
|
39
|
+
}
|
|
40
|
+
/** Approval flags: `--force` always, `--trust` only when this build's `--help` probe saw it. */
|
|
41
|
+
function bypassArgs(options) {
|
|
42
|
+
// See `RuntimeBuildOptions.permissionMode`'s doc: bypass is the default
|
|
43
|
+
// (unchanged behavior) unless a caller explicitly opts into a restricted
|
|
44
|
+
// run. Both flags below are auto-approval, so both are gated on it —
|
|
45
|
+
// `--force` bypasses the per-action prompt and `--trust` pre-grants the
|
|
46
|
+
// workspace trust that same prompt would otherwise ask for, so omitting
|
|
47
|
+
// only one of them would still hand the run most of what it asked to
|
|
48
|
+
// withhold.
|
|
49
|
+
if (options.permissionMode === 'restricted')
|
|
50
|
+
return [];
|
|
51
|
+
const caps = (options.capabilities ?? agentCapabilities.get('cursor-agent')) || {};
|
|
52
|
+
// `--trust` grants workspace trust in headless runs, but only newer
|
|
53
|
+
// cursor-agent builds accept it; older ones exit 1 with "unknown option"
|
|
54
|
+
// (issue #4461). Pass it only when the `--help` probe saw it.
|
|
55
|
+
return caps.trust ? ['--force', '--trust'] : ['--force'];
|
|
56
|
+
}
|
|
28
57
|
export const cursorAgentDef = {
|
|
29
58
|
// UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
|
|
30
|
-
...createAgentModelDiscovery('cursor-agent', { fallbackModels: () => cursorAgentDef.fallbackModels, args: ['models'], parse:
|
|
59
|
+
...createAgentModelDiscovery('cursor-agent', { fallbackModels: () => cursorAgentDef.fallbackModels, args: ['models'], parse: parseCursorAgentListing }),
|
|
31
60
|
id: 'cursor-agent',
|
|
32
61
|
name: 'Cursor Agent',
|
|
33
62
|
bin: 'cursor-agent',
|
|
@@ -42,18 +71,11 @@ export const cursorAgentDef = {
|
|
|
42
71
|
// execution (issue #4461). Gate on the probe like claude/codebuddy do.
|
|
43
72
|
'--trust': 'trust',
|
|
44
73
|
},
|
|
45
|
-
//
|
|
46
|
-
// the user isn't authed it prints "No models available for this
|
|
47
|
-
// account." — that's not a model list, so we detect it and fall back.
|
|
74
|
+
// See `parseCursorAgentListing` for the unauthenticated "No models available" fallback.
|
|
48
75
|
listModels: {
|
|
49
76
|
args: ['models'],
|
|
50
77
|
timeoutMs: 5000,
|
|
51
|
-
parse:
|
|
52
|
-
const trimmed = String(stdout || '').trim();
|
|
53
|
-
if (!trimmed || /no models available/i.test(trimmed))
|
|
54
|
-
return null;
|
|
55
|
-
return parseCursorAgentModels({ stdout: trimmed });
|
|
56
|
-
},
|
|
78
|
+
parse: parseCursorAgentListing,
|
|
57
79
|
},
|
|
58
80
|
fallbackModels: [
|
|
59
81
|
DEFAULT_MODEL_OPTION,
|
|
@@ -66,35 +88,15 @@ export const cursorAgentDef = {
|
|
|
66
88
|
// Passing it makes the CLI treat the dash as the literal user prompt,
|
|
67
89
|
// which then surfaces as "your message only contains '-'". Keep stdin
|
|
68
90
|
// piped for prompt delivery, but do not append a fake prompt arg.
|
|
69
|
-
buildArgs: (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// only one of them would still hand the run most of what it asked to
|
|
79
|
-
// withhold.
|
|
80
|
-
const bypassPermissions = options.permissionMode !== 'restricted';
|
|
81
|
-
if (bypassPermissions) {
|
|
82
|
-
args.push('--force');
|
|
83
|
-
}
|
|
84
|
-
// `--trust` grants workspace trust in headless runs, but only newer
|
|
85
|
-
// cursor-agent builds accept it; older ones exit 1 with "unknown option"
|
|
86
|
-
// (issue #4461). Pass it only when the `--help` probe saw it.
|
|
87
|
-
if (bypassPermissions && caps.trust) {
|
|
88
|
-
args.push('--trust');
|
|
89
|
-
}
|
|
90
|
-
if (runtimeContext.cwd) {
|
|
91
|
-
args.push('--workspace', runtimeContext.cwd);
|
|
92
|
-
}
|
|
93
|
-
if (options.model && options.model !== 'default') {
|
|
94
|
-
args.push('--model', options.model);
|
|
95
|
-
}
|
|
96
|
-
return args;
|
|
97
|
-
},
|
|
91
|
+
buildArgs: (_requiredArgs, { options = {}, runtimeContext = {} } = {}) => [
|
|
92
|
+
'--print',
|
|
93
|
+
'--output-format',
|
|
94
|
+
'stream-json',
|
|
95
|
+
'--stream-partial-output',
|
|
96
|
+
...bypassArgs(options),
|
|
97
|
+
...(runtimeContext.cwd ? ['--workspace', runtimeContext.cwd] : []),
|
|
98
|
+
...(options.model && options.model !== 'default' ? ['--model', options.model] : []),
|
|
99
|
+
],
|
|
98
100
|
promptViaStdin: true,
|
|
99
101
|
streamFormat: 'json-event-stream',
|
|
100
102
|
eventParser: 'cursor-agent',
|
package/dist/defs/devin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const devinAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
10
|
+
acpModelProbe?: import("../types.js").AcpModelProbe;
|
|
11
11
|
} | undefined) => Promise<import("../types.js").RuntimeModelOption[]>;
|
|
12
12
|
fallbackModels: import("../types.js").RuntimeModelOption[];
|
|
13
13
|
buildArgs: ({ prompt: _prompt, imagePaths: _imagePaths }: {
|
package/dist/defs/goose.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const gooseAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
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[];
|
package/dist/defs/hermes.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const hermesAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
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[];
|
package/dist/defs/kilo.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const kiloAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
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[];
|
package/dist/defs/kimi.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const kimiAgentDef: {
|
|
|
8
8
|
resolvedBin: string;
|
|
9
9
|
env: import("../types.js").RuntimeEnv;
|
|
10
10
|
}, { acpModelProbe }?: {
|
|
11
|
-
acpModelProbe?: import("../
|
|
11
|
+
acpModelProbe?: import("../types.js").AcpModelProbe;
|
|
12
12
|
} | undefined) => Promise<import("../types.js").RuntimeModelOption[]>;
|
|
13
13
|
buildArgs: () => string[];
|
|
14
14
|
streamFormat: string;
|
package/dist/defs/kiro.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const kiroAgentDef: {
|
|
|
7
7
|
resolvedBin: string;
|
|
8
8
|
env: import("../types.js").RuntimeEnv;
|
|
9
9
|
}, { acpModelProbe }?: {
|
|
10
|
-
acpModelProbe?: import("../
|
|
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[];
|
package/dist/defs/opencode.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseLineSeparatedModels } from './shared.js';
|
|
2
|
+
import type { RuntimeBuildOptions, RuntimeContext } from '../types.js';
|
|
2
3
|
export declare const opencodeAgentDef: {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
@@ -16,13 +17,13 @@ export declare const opencodeAgentDef: {
|
|
|
16
17
|
};
|
|
17
18
|
fallbackModels: import("../types.js").RuntimeModelOption[];
|
|
18
19
|
fallbackModelsAssertedAt: string;
|
|
19
|
-
buildArgs: (
|
|
20
|
+
buildArgs: (_requiredArgs: {
|
|
20
21
|
prompt: string;
|
|
21
22
|
imagePaths: string[];
|
|
22
|
-
}, {
|
|
23
|
+
}, { options, runtimeContext }?: {
|
|
23
24
|
extraAllowedDirs?: string[];
|
|
24
|
-
options?:
|
|
25
|
-
runtimeContext?:
|
|
25
|
+
options?: RuntimeBuildOptions;
|
|
26
|
+
runtimeContext?: RuntimeContext;
|
|
26
27
|
} | undefined) => string[];
|
|
27
28
|
promptViaStdin: true;
|
|
28
29
|
resumesSessionViaCli: true;
|
package/dist/defs/opencode.js
CHANGED
|
@@ -2,8 +2,25 @@ import { createAgentModelDiscovery } from '../model-discovery-native.js';
|
|
|
2
2
|
import { DEFAULT_MODEL_OPTION, parseLineSeparatedModels } from './shared.js';
|
|
3
3
|
import { agentCapabilities } from '../capabilities.js';
|
|
4
4
|
const SKIP_PERMISSIONS_FLAG = '--dangerously-skip-permissions';
|
|
5
|
+
// Gated on two independent things: whether this OpenCode build even supports the flag
|
|
6
|
+
// (`skipPermissions`, probed from `--help` text) AND whether the caller wants it — see
|
|
7
|
+
// `RuntimeBuildOptions.permissionMode`'s doc. Bypass remains the default (unchanged
|
|
8
|
+
// behavior) unless a caller explicitly opts into a restricted run.
|
|
9
|
+
function skipsPermissions(options) {
|
|
10
|
+
return Boolean((options.capabilities ?? agentCapabilities.get('opencode'))?.skipPermissions) && options.permissionMode !== 'restricted';
|
|
11
|
+
}
|
|
12
|
+
// Capture-style resume: OpenCode mints its own session id (reported on
|
|
13
|
+
// the stream as `sessionID`, e.g. `ses_...`). On a follow-up turn the
|
|
14
|
+
// daemon continues that session with `-s <id>` instead of re-sending the
|
|
15
|
+
// flattened transcript, so the first upstream call reuses the warm prefix
|
|
16
|
+
// cache. `-s` continues an EXISTING session (the create turn passes no id
|
|
17
|
+
// and we capture the one OpenCode generated), mirroring codex.
|
|
18
|
+
function resumeArgs(runtimeContext) {
|
|
19
|
+
const resumeSessionId = runtimeContext.resumeSessionId;
|
|
20
|
+
return typeof resumeSessionId === 'string' && resumeSessionId.length > 0 ? ['-s', resumeSessionId] : [];
|
|
21
|
+
}
|
|
5
22
|
export const opencodeAgentDef = {
|
|
6
|
-
...createAgentModelDiscovery('opencode', { fallbackModels: () => opencodeAgentDef.fallbackModels, args: ['models'], parse:
|
|
23
|
+
...createAgentModelDiscovery('opencode', { fallbackModels: () => opencodeAgentDef.fallbackModels, args: ['models'], parse: parseLineSeparatedModels }),
|
|
7
24
|
id: 'opencode',
|
|
8
25
|
name: 'OpenCode',
|
|
9
26
|
bin: 'opencode-cli',
|
|
@@ -48,37 +65,14 @@ export const opencodeAgentDef = {
|
|
|
48
65
|
// avoid Windows `spawn ENAMETOOLONG` while preserving OpenCode's
|
|
49
66
|
// structured stream. A literal `-` is parsed as a positional message by
|
|
50
67
|
// OpenCode 1.14.x and can surface as "Session not found".
|
|
51
|
-
buildArgs: (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// `RuntimeBuildOptions.permissionMode`'s doc. Bypass remains the default (unchanged
|
|
60
|
-
// behavior) unless a caller explicitly opts into a restricted run.
|
|
61
|
-
if ((options.capabilities ?? agentCapabilities.get('opencode'))?.skipPermissions && options.permissionMode !== 'restricted') {
|
|
62
|
-
args.push(SKIP_PERMISSIONS_FLAG);
|
|
63
|
-
}
|
|
64
|
-
// Capture-style resume: OpenCode mints its own session id (reported on
|
|
65
|
-
// the stream as `sessionID`, e.g. `ses_...`). On a follow-up turn the
|
|
66
|
-
// daemon continues that session with `-s <id>` instead of re-sending the
|
|
67
|
-
// flattened transcript, so the first upstream call reuses the warm prefix
|
|
68
|
-
// cache. `-s` continues an EXISTING session (the create turn passes no id
|
|
69
|
-
// and we capture the one OpenCode generated), mirroring codex.
|
|
70
|
-
const resumeSessionId = typeof runtimeContext.resumeSessionId === 'string' &&
|
|
71
|
-
runtimeContext.resumeSessionId.length > 0
|
|
72
|
-
? runtimeContext.resumeSessionId
|
|
73
|
-
: null;
|
|
74
|
-
if (resumeSessionId) {
|
|
75
|
-
args.push('-s', resumeSessionId);
|
|
76
|
-
}
|
|
77
|
-
if (options.model && options.model !== 'default') {
|
|
78
|
-
args.push('-m', options.model);
|
|
79
|
-
}
|
|
80
|
-
return args;
|
|
81
|
-
},
|
|
68
|
+
buildArgs: (_requiredArgs, { options = {}, runtimeContext = {} } = {}) => [
|
|
69
|
+
'run',
|
|
70
|
+
'--format',
|
|
71
|
+
'json',
|
|
72
|
+
...(skipsPermissions(options) ? [SKIP_PERMISSIONS_FLAG] : []),
|
|
73
|
+
...resumeArgs(runtimeContext),
|
|
74
|
+
...(options.model && options.model !== 'default' ? ['-m', options.model] : []),
|
|
75
|
+
],
|
|
82
76
|
promptViaStdin: true,
|
|
83
77
|
// OpenCode's CLI carries its own session across spawns: on a follow-up turn
|
|
84
78
|
// the daemon resumes the captured session id (`-s <id>`) instead of
|