@commonlyai/cli 0.1.367 → 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 +1 -1
- package/src/lib/adapters/opencode.js +25 -0
package/package.json
CHANGED
|
@@ -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`);
|