@commonlyai/cli 0.1.366 → 0.1.368
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/package.json
CHANGED
|
@@ -1404,16 +1404,31 @@ const CODEX_PROVIDER_KEY_ENVS = [
|
|
|
1404
1404
|
// What the turn will launch, asked for its version. 30 s, as in goose: a first
|
|
1405
1405
|
// launch after an upgrade can be slow. A failed probe isn't cached, so the next
|
|
1406
1406
|
// turn reads it again. `_codexVersion` and `_versionProbe` are test seams only.
|
|
1407
|
+
//
|
|
1408
|
+
// A Codex that can't be launched at all throws what the turn's own launch would
|
|
1409
|
+
// (F262), so the pod hears that it won't start, not that it needs upgrading.
|
|
1410
|
+
// "Can't be launched" is the probe's own ENOENT, the error execFile and the
|
|
1411
|
+
// turn's spawn share: a codex found any way the OS finds it (a relative PATH
|
|
1412
|
+
// entry, PATH unset) but exiting non-zero is a version refusal.
|
|
1407
1413
|
const readCodexVersion = async (ctx, env) => {
|
|
1408
1414
|
if (ctx._codexVersion !== undefined) return ctx._codexVersion;
|
|
1415
|
+
const { command, args } = resolveLaunch('codex', [], { env, ...ctx._commandResolution });
|
|
1416
|
+
let notFound = false;
|
|
1417
|
+
let version = null;
|
|
1409
1418
|
try {
|
|
1410
|
-
|
|
1411
|
-
return await probeVersion(command, {
|
|
1419
|
+
version = await probeVersion(command, {
|
|
1412
1420
|
args, env, timeoutMs: 30000, parse: parseCodexVersion, ...ctx._versionProbe,
|
|
1421
|
+
onError: (error) => { if (error?.code === 'ENOENT') notFound = true; },
|
|
1413
1422
|
});
|
|
1414
1423
|
} catch {
|
|
1415
|
-
|
|
1424
|
+
version = null;
|
|
1425
|
+
}
|
|
1426
|
+
if (version === null && notFound) {
|
|
1427
|
+
const missing = new Error(`spawn ${command} ENOENT`);
|
|
1428
|
+
missing.code = 'ENOENT';
|
|
1429
|
+
throw missing;
|
|
1416
1430
|
}
|
|
1431
|
+
return version;
|
|
1417
1432
|
};
|
|
1418
1433
|
|
|
1419
1434
|
// `ownGroup`: see runClaude in claude.js.
|
|
@@ -679,6 +679,13 @@ const substitutePublicPlaceholders = (value, ctx) => {
|
|
|
679
679
|
return value.replace(PLACEHOLDER_RE, (whole, key) => replacements[key] || whole);
|
|
680
680
|
};
|
|
681
681
|
|
|
682
|
+
// F193: OpenCode expands `{env:NAME}` and then `{file:path}` across the config
|
|
683
|
+
// it loads (so `{file:{env:X}}` nests). A remote entry that spells one itself
|
|
684
|
+
// reaches a file or env value buildMcpConfig never wrote, the seat credential
|
|
685
|
+
// included, and is never recorded in `bearerFileServers`. Only the bearer
|
|
686
|
+
// rewrite below may carry one.
|
|
687
|
+
const OPENCODE_SUBSTITUTION_RE = /\{(?:env|file):/;
|
|
688
|
+
|
|
682
689
|
const isSafeMcpName = (name) => typeof name === 'string'
|
|
683
690
|
&& /^[A-Za-z0-9_-]+$/.test(name);
|
|
684
691
|
|
|
@@ -762,11 +769,18 @@ const buildMcpConfig = (servers, ctx = {}) => {
|
|
|
762
769
|
// Runtime credentials only travel through OpenCode's measured {file:}
|
|
763
770
|
// header expansion, never as environment values or literal config text.
|
|
764
771
|
if (runtimeToken && url.includes(runtimeToken)) continue;
|
|
772
|
+
if (OPENCODE_SUBSTITUTION_RE.test(url)) {
|
|
773
|
+
// eslint-disable-next-line no-console
|
|
774
|
+
console.warn(`[opencode] skipping MCP server ${server.name}: its url spells an OpenCode substitution`);
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
765
777
|
const headers = {};
|
|
766
778
|
let unsupportedCredential = false;
|
|
779
|
+
let ownSubstitution = '';
|
|
767
780
|
for (const [key, rawValue] of Object.entries(server.headers || {})) {
|
|
768
781
|
if (typeof rawValue !== 'string') continue;
|
|
769
782
|
let value = substitutePublicPlaceholders(rawValue, ctx);
|
|
783
|
+
let rewritten = false;
|
|
770
784
|
if (rawValue.includes('${COMMONLY_AGENT_TOKEN}')) {
|
|
771
785
|
if (key.toLowerCase() !== 'authorization'
|
|
772
786
|
|| rawValue !== 'Bearer ${COMMONLY_AGENT_TOKEN}'
|
|
@@ -775,13 +789,24 @@ const buildMcpConfig = (servers, ctx = {}) => {
|
|
|
775
789
|
break;
|
|
776
790
|
}
|
|
777
791
|
value = `Bearer {file:${ctx.credentialFile}}`;
|
|
792
|
+
rewritten = true;
|
|
778
793
|
}
|
|
779
794
|
if (runtimeToken && value.includes(runtimeToken)) {
|
|
780
795
|
unsupportedCredential = true;
|
|
781
796
|
break;
|
|
782
797
|
}
|
|
798
|
+
// The name is checked too: OpenCode substitutes the config text, keys included.
|
|
799
|
+
if (OPENCODE_SUBSTITUTION_RE.test(key) || (!rewritten && OPENCODE_SUBSTITUTION_RE.test(value))) {
|
|
800
|
+
ownSubstitution = key;
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
783
803
|
headers[key] = value;
|
|
784
804
|
}
|
|
805
|
+
if (ownSubstitution) {
|
|
806
|
+
// eslint-disable-next-line no-console
|
|
807
|
+
console.warn(`[opencode] skipping MCP server ${server.name}: a header spells an OpenCode substitution`);
|
|
808
|
+
continue;
|
|
809
|
+
}
|
|
785
810
|
if (unsupportedCredential) {
|
|
786
811
|
// eslint-disable-next-line no-console
|
|
787
812
|
console.warn(`[opencode] skipping MCP server ${server.name}: remote credentials must use the bearer file channel`);
|
|
@@ -94,9 +94,11 @@ const resolveBinary = (binary, env) => {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
// `onError` sees the launch's own error when the probe fails, so a caller can
|
|
98
|
+
// tell a binary that isn't there (ENOENT) from one that ran and refused.
|
|
97
99
|
export const probeVersion = async (binary, {
|
|
98
100
|
args = [], env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
|
|
99
|
-
now = Date.now,
|
|
101
|
+
now = Date.now, onError,
|
|
100
102
|
} = {}) => {
|
|
101
103
|
const resolved = args.length ? null : resolveBinary(binary, env);
|
|
102
104
|
const key = resolved?.key || null;
|
|
@@ -104,6 +106,7 @@ export const probeVersion = async (binary, {
|
|
|
104
106
|
if (hit && hit.mtimeMs === resolved.mtimeMs && now() - hit.at < VERSION_CACHE_MAX_AGE_MS) return hit.version;
|
|
105
107
|
const stdout = await new Promise((resolve) => {
|
|
106
108
|
execFileImpl(key || binary, [...args, '--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
|
|
109
|
+
if (error && onError) onError(error);
|
|
107
110
|
resolve(error ? null : out);
|
|
108
111
|
});
|
|
109
112
|
});
|
|
@@ -48,6 +48,9 @@ const CLAUDE_SIGNED_OUT_WORDINGS = [
|
|
|
48
48
|
];
|
|
49
49
|
const WONT_START_WORDINGS = [
|
|
50
50
|
/^spawn \S+ ENOENT/,
|
|
51
|
+
// windows-command.js resolveLaunch: not on PATH, or a .cmd/.ps1 that only a
|
|
52
|
+
// shell can run. The harness never started, as with ENOENT (F262).
|
|
53
|
+
/^cannot launch \S+ on Windows without a shell: /,
|
|
51
54
|
/^\w+ adapter: \S+ (?:is not set|is missing)/, // the seat has no provider key
|
|
52
55
|
];
|
|
53
56
|
// The vendors' credit wordings open at the adapter's own label or the claude
|