@jini-ai/agent-runtime 0.4.10 → 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 +9 -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 +7 -0
- package/dist/providers/google-messages.js +69 -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/gemini.d.ts +0 -24
- package/dist/defs/gemini.js +0 -81
package/dist/executables.js
CHANGED
|
@@ -20,7 +20,7 @@ import { defaultRuntimeState } from './runtime-state.js';
|
|
|
20
20
|
* `AGENT_RUNTIME_RESOURCE_ROOT`, with no sandbox dependency. See
|
|
21
21
|
* `archived provenance ledger` for the exact original names.
|
|
22
22
|
*/
|
|
23
|
-
import { accessSync, constants,
|
|
23
|
+
import { accessSync, constants, statSync } from 'node:fs';
|
|
24
24
|
import { delimiter } from 'node:path';
|
|
25
25
|
import path from 'node:path';
|
|
26
26
|
import { homedir } from 'node:os';
|
|
@@ -54,6 +54,16 @@ const AGENT_BIN_ENV_KEYS = new Map([
|
|
|
54
54
|
['trae-cli', 'TRAE_CLI_BIN'],
|
|
55
55
|
['vibe', 'VIBE_BIN'],
|
|
56
56
|
]);
|
|
57
|
+
function withDefaults(options) {
|
|
58
|
+
return { env: options.env ?? process.env, state: options.state ?? defaultRuntimeState };
|
|
59
|
+
}
|
|
60
|
+
// `<name>.exe` on Windows, `<name>` elsewhere.
|
|
61
|
+
function platformExecutableName({ name }) {
|
|
62
|
+
return process.platform === 'win32' ? `${name}.exe` : name;
|
|
63
|
+
}
|
|
64
|
+
function pathExtEntries(env) {
|
|
65
|
+
return (env.PATHEXT || '.EXE;.CMD;.BAT').split(';');
|
|
66
|
+
}
|
|
57
67
|
/**
|
|
58
68
|
* Override the env var names `resolveDetectionHome` / the packaged-binary
|
|
59
69
|
* lookup read. The host application (e.g. the OD adapter) calls this once
|
|
@@ -74,18 +84,16 @@ const TOOLCHAIN_DIR_CACHE_TTL_MS = 5000;
|
|
|
74
84
|
// strictly to the override home (skipping real-machine system locations) so
|
|
75
85
|
// sandboxed detection runs and tests stay deterministic instead of
|
|
76
86
|
// reaching the host.
|
|
77
|
-
function resolveDetectionHome(
|
|
78
|
-
const
|
|
79
|
-
const homeOverride = env[(options.state ?? defaultRuntimeState).executable.envNames.agentHomeEnvVar];
|
|
87
|
+
function resolveDetectionHome({ env, state }) {
|
|
88
|
+
const homeOverride = env[state.executable.envNames.agentHomeEnvVar];
|
|
80
89
|
return { home: homeOverride || env.HOME || env.USERPROFILE || homedir(), hasOverride: Boolean(homeOverride) };
|
|
81
90
|
}
|
|
82
|
-
function userToolchainDirs(options
|
|
83
|
-
const env = options
|
|
84
|
-
const cache =
|
|
91
|
+
function userToolchainDirs(options) {
|
|
92
|
+
const { env } = options;
|
|
93
|
+
const cache = options.state.executable;
|
|
85
94
|
const { home, hasOverride } = resolveDetectionHome(options);
|
|
86
95
|
// Every environment field the existing toolchain adapter consults participates in the cache key.
|
|
87
96
|
const key = JSON.stringify([home, hasOverride, ...['VP_HOME', 'NPM_CONFIG_PREFIX', 'npm_config_prefix', 'APPDATA', 'LOCALAPPDATA', 'MISE_DATA_DIR', 'FNM_DIR'].map(name => env[name])]);
|
|
88
|
-
const homeOverride = hasOverride ? home : undefined;
|
|
89
97
|
const now = Date.now();
|
|
90
98
|
if (cache.toolchainKey === key &&
|
|
91
99
|
cache.toolchainDirs &&
|
|
@@ -102,8 +110,8 @@ function userToolchainDirs(options = {}) {
|
|
|
102
110
|
// home would be machine-environment-dependent.
|
|
103
111
|
cache.toolchainDirs = wellKnownUserToolchainBins({
|
|
104
112
|
home,
|
|
105
|
-
includeSystemBins: process.platform !== 'win32' && !
|
|
106
|
-
env:
|
|
113
|
+
includeSystemBins: process.platform !== 'win32' && !hasOverride,
|
|
114
|
+
env: hasOverride ? {} : env,
|
|
107
115
|
});
|
|
108
116
|
return cache.toolchainDirs;
|
|
109
117
|
}
|
|
@@ -114,13 +122,12 @@ function userToolchainDirs(options = {}) {
|
|
|
114
122
|
// (e.g. `#!/usr/bin/env bun`) lives in one of these dirs and the spawn PATH
|
|
115
123
|
// doesn't include it. Keeping resolution and spawn PATH symmetric fixes that.
|
|
116
124
|
export function userToolchainBinDirs(_required = {}, options = {}) {
|
|
117
|
-
return userToolchainDirs(options);
|
|
125
|
+
return userToolchainDirs(withDefaults(options));
|
|
118
126
|
}
|
|
119
|
-
function resolvePathDirs(options
|
|
120
|
-
const env = options.env ?? process.env;
|
|
127
|
+
function resolvePathDirs(options) {
|
|
121
128
|
const seen = new Set();
|
|
122
129
|
const dirs = [
|
|
123
|
-
...(env.PATH || '').split(delimiter),
|
|
130
|
+
...(options.env.PATH || '').split(delimiter),
|
|
124
131
|
// GUI launchers (macOS .app bundles, Linux .desktop files) often start
|
|
125
132
|
// with a minimal PATH. Include common user-level CLI install locations
|
|
126
133
|
// so agent detection matches the user's shell-installed tools,
|
|
@@ -128,7 +135,7 @@ function resolvePathDirs(options = {}) {
|
|
|
128
135
|
...userToolchainDirs(options),
|
|
129
136
|
];
|
|
130
137
|
return dirs.filter((dir) => {
|
|
131
|
-
if (!dir || seen.has(dir))
|
|
138
|
+
if (!path.isAbsolute(dir) || seen.has(dir))
|
|
132
139
|
return false;
|
|
133
140
|
seen.add(dir);
|
|
134
141
|
return true;
|
|
@@ -139,7 +146,7 @@ function resolvePathDirs(options = {}) {
|
|
|
139
146
|
// shows the user where we actually looked before asking them to set an
|
|
140
147
|
// explicit binary path, instead of recomputing PATH client-side.
|
|
141
148
|
export function agentSearchDirs(_required = {}, options = {}) {
|
|
142
|
-
return resolvePathDirs(options);
|
|
149
|
+
return resolvePathDirs(withDefaults(options));
|
|
143
150
|
}
|
|
144
151
|
// The `*_BIN` environment variable that overrides PATH detection for a given
|
|
145
152
|
// agent id (e.g. `cursor-agent` → `CURSOR_AGENT_BIN`), or null when the agent
|
|
@@ -150,58 +157,56 @@ export function agentBinEnvKey({ agentId }) {
|
|
|
150
157
|
return AGENT_BIN_ENV_KEYS.get(agentId) ?? null;
|
|
151
158
|
}
|
|
152
159
|
export function resolveOnPath({ bin }, options = {}) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
for (const dir of dirs) {
|
|
160
|
+
return searchPath({ bin }, withDefaults(options));
|
|
161
|
+
}
|
|
162
|
+
function searchPath({ bin }, options) {
|
|
163
|
+
const exts = process.platform === 'win32' ? pathExtEntries(options.env) : [''];
|
|
164
|
+
for (const dir of resolvePathDirs(options)) {
|
|
159
165
|
for (const ext of exts) {
|
|
160
166
|
const full = path.join(dir, bin + ext);
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
const executable = executableFilePath(full, options);
|
|
168
|
+
if (executable)
|
|
169
|
+
return executable;
|
|
163
170
|
}
|
|
164
171
|
}
|
|
165
172
|
return null;
|
|
166
173
|
}
|
|
167
|
-
function looksExecutableOnWindows(filePath,
|
|
168
|
-
const env = options.env ?? process.env;
|
|
174
|
+
function looksExecutableOnWindows(filePath, { env }) {
|
|
169
175
|
const ext = path.extname(filePath).trim().toUpperCase();
|
|
170
176
|
if (!ext)
|
|
171
177
|
return false;
|
|
172
|
-
const executableExts = (env
|
|
173
|
-
.split(';')
|
|
178
|
+
const executableExts = pathExtEntries(env)
|
|
174
179
|
.map((value) => value.trim().toUpperCase())
|
|
175
180
|
.filter(Boolean);
|
|
176
181
|
return executableExts.includes(ext);
|
|
177
182
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!path.isAbsolute(expanded))
|
|
183
|
-
return null;
|
|
183
|
+
// A regular file the host may launch: on Windows its extension must be in
|
|
184
|
+
// PATHEXT, elsewhere it must carry the execute permission. Any stat/access
|
|
185
|
+
// failure (missing, unreadable) counts as "not runnable".
|
|
186
|
+
function isRunnableFile(filePath, options) {
|
|
184
187
|
try {
|
|
185
|
-
if (!statSync(
|
|
186
|
-
return
|
|
187
|
-
if (process.platform === 'win32')
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
else {
|
|
192
|
-
accessSync(expanded, constants.X_OK);
|
|
193
|
-
}
|
|
194
|
-
return expanded;
|
|
188
|
+
if (!statSync(filePath).isFile())
|
|
189
|
+
return false;
|
|
190
|
+
if (process.platform === 'win32')
|
|
191
|
+
return looksExecutableOnWindows(filePath, options);
|
|
192
|
+
accessSync(filePath, constants.X_OK);
|
|
193
|
+
return true;
|
|
195
194
|
}
|
|
196
195
|
catch {
|
|
197
|
-
return
|
|
196
|
+
return false;
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
function executableFilePath(raw, options) {
|
|
200
|
+
if (typeof raw !== 'string' || raw.trim().length === 0)
|
|
201
|
+
return null;
|
|
202
|
+
const { env } = options;
|
|
203
|
+
// `~` in an override expands from the supplied env, so sandboxed detection never reaches the real home.
|
|
204
|
+
const expanded = expandHomePath({ value: raw.trim() }, { home: env.HOME || env.USERPROFILE || homedir() });
|
|
205
|
+
if (!path.isAbsolute(expanded))
|
|
206
|
+
return null;
|
|
207
|
+
return isRunnableFile(expanded, options) ? expanded : null;
|
|
208
|
+
}
|
|
209
|
+
function configuredExecutableOverride(def, configuredEnv, options) {
|
|
205
210
|
const envKey = AGENT_BIN_ENV_KEYS.get(def?.id);
|
|
206
211
|
if (!envKey)
|
|
207
212
|
return null;
|
|
@@ -209,24 +214,25 @@ function configuredExecutableOverride(def, configuredEnv = {}, options = {}) {
|
|
|
209
214
|
}
|
|
210
215
|
export function resolveAmrOpenCodeExecutable({}, { env = process.env, state = defaultRuntimeState } = {}) {
|
|
211
216
|
const options = { env, state };
|
|
212
|
-
const executableResolutionEnv = state.executable.envNames;
|
|
213
|
-
const configured = executableFilePath(env.VELA_OPENCODE_BIN, options);
|
|
214
|
-
if (configured)
|
|
215
|
-
return configured;
|
|
216
217
|
// In packaged builds prefer the bundled companion under
|
|
217
218
|
// `<resourceRoot>/bin/libexec/opencode/opencode` so a stale global
|
|
218
219
|
// `opencode` on the user's PATH can't override the known-good build that
|
|
219
220
|
// shipped with this app. PATH is only consulted as a last resort.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
return executableFilePath(env.VELA_OPENCODE_BIN, options)
|
|
222
|
+
?? bundledAmrOpenCode({ resourceRoot: resourceRootOf(options) }, options)
|
|
223
|
+
?? searchPath({ bin: 'opencode-cli' }, options)
|
|
224
|
+
?? searchPath({ bin: 'opencode' }, options);
|
|
225
|
+
}
|
|
226
|
+
function resourceRootOf({ env, state }) {
|
|
227
|
+
return env[state.executable.envNames.resourceRootEnvVar]?.trim();
|
|
228
|
+
}
|
|
229
|
+
function bundledAmrOpenCode({ resourceRoot }, options) {
|
|
230
|
+
if (!resourceRoot)
|
|
231
|
+
return null;
|
|
232
|
+
const bundledDir = packagedVelaOpenCodeCompanionTree(resourceRoot, options);
|
|
233
|
+
if (!bundledDir)
|
|
234
|
+
return null;
|
|
235
|
+
return executableFilePath(path.join(bundledDir, platformExecutableName({ name: 'opencode' })), options);
|
|
230
236
|
}
|
|
231
237
|
// The AMR (vela) OpenCode companion ships as a
|
|
232
238
|
// `<resourceRoot>/bin/libexec/opencode/opencode` *executable file*, not just
|
|
@@ -234,55 +240,29 @@ export function resolveAmrOpenCodeExecutable({}, { env = process.env, state = de
|
|
|
234
240
|
// a false-positive availability path: `detectAgents()` would surface AMR as
|
|
235
241
|
// available even though the first real run can't launch. Verify the inner
|
|
236
242
|
// executable too.
|
|
237
|
-
function packagedVelaOpenCodeCompanionTree(resourceRoot, options
|
|
243
|
+
function packagedVelaOpenCodeCompanionTree(resourceRoot, options) {
|
|
238
244
|
const candidate = path.join(resourceRoot, 'bin', 'libexec', 'opencode');
|
|
239
|
-
const exe = path.join(candidate, process.platform === 'win32' ? 'opencode.exe' : 'opencode');
|
|
240
245
|
try {
|
|
241
246
|
if (!statSync(candidate).isDirectory())
|
|
242
247
|
return null;
|
|
243
|
-
if (!statSync(exe).isFile())
|
|
244
|
-
return null;
|
|
245
|
-
if (process.platform === 'win32') {
|
|
246
|
-
if (!looksExecutableOnWindows(exe, options))
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
accessSync(exe, constants.X_OK);
|
|
251
|
-
}
|
|
252
|
-
return candidate;
|
|
253
248
|
}
|
|
254
249
|
catch {
|
|
255
250
|
return null;
|
|
256
251
|
}
|
|
252
|
+
return isRunnableFile(path.join(candidate, platformExecutableName({ name: 'opencode' })), options) ? candidate : null;
|
|
257
253
|
}
|
|
258
|
-
function packagedBuiltInExecutable(def, configuredEnv
|
|
254
|
+
function packagedBuiltInExecutable(def, configuredEnv, options) {
|
|
259
255
|
if (def.id !== 'amr')
|
|
260
256
|
return null;
|
|
261
|
-
const
|
|
262
|
-
const executableResolutionEnv = (options.state ?? defaultRuntimeState).executable.envNames;
|
|
263
|
-
const resourceRoot = env[executableResolutionEnv.resourceRootEnvVar]?.trim();
|
|
257
|
+
const resourceRoot = resourceRootOf(options);
|
|
264
258
|
if (!resourceRoot)
|
|
265
259
|
return null;
|
|
266
|
-
if (!resolveAmrOpenCodeExecutable({}, { ...options, env: { ...env, ...configuredEnv } }) &&
|
|
260
|
+
if (!resolveAmrOpenCodeExecutable({}, { ...options, env: { ...options.env, ...configuredEnv } }) &&
|
|
267
261
|
!packagedVelaOpenCodeCompanionTree(resourceRoot, options)) {
|
|
268
262
|
return null;
|
|
269
263
|
}
|
|
270
|
-
const candidate = path.join(resourceRoot, 'bin',
|
|
271
|
-
|
|
272
|
-
if (!statSync(candidate).isFile())
|
|
273
|
-
return null;
|
|
274
|
-
if (process.platform === 'win32') {
|
|
275
|
-
if (!looksExecutableOnWindows(candidate, options))
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
accessSync(candidate, constants.X_OK);
|
|
280
|
-
}
|
|
281
|
-
return candidate;
|
|
282
|
-
}
|
|
283
|
-
catch {
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
264
|
+
const candidate = path.join(resourceRoot, 'bin', platformExecutableName({ name: 'vela' }));
|
|
265
|
+
return isRunnableFile(candidate, options) ? candidate : null;
|
|
286
266
|
}
|
|
287
267
|
// The official OpenAI Codex desktop app ships the `codex` CLI *inside* its
|
|
288
268
|
// macOS application bundle and does NOT add it to PATH unless the user
|
|
@@ -293,10 +273,10 @@ function packagedBuiltInExecutable(def, configuredEnv = {}, options = {}) {
|
|
|
293
273
|
// bundle. Probe the well-known bundle locations so app-only installs are
|
|
294
274
|
// detected. This is a last-resort fallback that ranks below PATH, so an
|
|
295
275
|
// explicit `npm i -g` / Homebrew / version-manager install always wins.
|
|
296
|
-
function codexAppBundleExecutable(def, options
|
|
276
|
+
function codexAppBundleExecutable(def, options) {
|
|
297
277
|
if (def?.id !== 'codex')
|
|
298
278
|
return null;
|
|
299
|
-
for (const candidate of
|
|
279
|
+
for (const candidate of appBundleCandidates(options)) {
|
|
300
280
|
const resolved = executableFilePath(candidate, options);
|
|
301
281
|
if (resolved)
|
|
302
282
|
return resolved;
|
|
@@ -309,6 +289,9 @@ function codexAppBundleExecutable(def, options = {}) {
|
|
|
309
289
|
// assert the built candidate list directly to catch a path typo or
|
|
310
290
|
// ordering regression in the common real-world install case.
|
|
311
291
|
export function codexAppBundleCandidates(_required = {}, options = {}) {
|
|
292
|
+
return appBundleCandidates(withDefaults(options));
|
|
293
|
+
}
|
|
294
|
+
function appBundleCandidates(options) {
|
|
312
295
|
// The Codex app bundle is a macOS-only concept; other platforms have no
|
|
313
296
|
// analogous standalone install of the `codex` CLI to probe for here.
|
|
314
297
|
if (process.platform !== 'darwin')
|
|
@@ -326,6 +309,22 @@ export function codexAppBundleCandidates(_required = {}, options = {}) {
|
|
|
326
309
|
}
|
|
327
310
|
return candidates;
|
|
328
311
|
}
|
|
312
|
+
// Resolve the first available binary for an agent definition. Tries
|
|
313
|
+
// `def.bin` first, then walks `def.fallbackBins` in order. Used for agents
|
|
314
|
+
// whose forks ship under a different binary name but speak the exact same
|
|
315
|
+
// CLI. Returns null when no candidate is on PATH.
|
|
316
|
+
function firstBinOnPath(def, options) {
|
|
317
|
+
const candidates = [
|
|
318
|
+
def.bin,
|
|
319
|
+
...(Array.isArray(def.fallbackBins) ? def.fallbackBins : []),
|
|
320
|
+
];
|
|
321
|
+
for (const bin of candidates) {
|
|
322
|
+
const resolved = searchPath({ bin }, options);
|
|
323
|
+
if (resolved)
|
|
324
|
+
return resolved;
|
|
325
|
+
}
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
329
328
|
export function resolveAgentExecutable({ def }, options = {}) {
|
|
330
329
|
return inspectAgentExecutableResolution({ def: def }, options).selectedPath;
|
|
331
330
|
}
|
|
@@ -337,22 +336,12 @@ export function inspectAgentExecutableResolution({ def }, options = {}) {
|
|
|
337
336
|
selectedPath: null,
|
|
338
337
|
};
|
|
339
338
|
}
|
|
339
|
+
const resolved = withDefaults(options);
|
|
340
340
|
const configuredEnv = options.configuredEnv ?? {};
|
|
341
|
-
const configuredOverridePath = configuredExecutableOverride(def, configuredEnv,
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
];
|
|
346
|
-
let pathResolvedPath = null;
|
|
347
|
-
for (const bin of candidates) {
|
|
348
|
-
const resolved = resolveOnPath({ bin: bin }, options);
|
|
349
|
-
if (resolved) {
|
|
350
|
-
pathResolvedPath = resolved;
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const builtInPath = packagedBuiltInExecutable(def, configuredEnv, options);
|
|
355
|
-
const appBundlePath = codexAppBundleExecutable(def, options);
|
|
341
|
+
const configuredOverridePath = configuredExecutableOverride(def, configuredEnv, resolved);
|
|
342
|
+
const pathResolvedPath = firstBinOnPath(def, resolved);
|
|
343
|
+
const builtInPath = packagedBuiltInExecutable(def, configuredEnv, resolved);
|
|
344
|
+
const appBundlePath = codexAppBundleExecutable(def, resolved);
|
|
356
345
|
return {
|
|
357
346
|
configuredOverridePath,
|
|
358
347
|
pathResolvedPath,
|
package/dist/index.d.ts
CHANGED