@addai/node 0.22.0 → 0.23.0
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/dist/codex-spawn.js +31 -19
- package/dist/desktop/relay-client.js +20 -2
- package/dist/gemini-spawn.d.ts +15 -0
- package/dist/gemini-spawn.js +20 -0
- package/dist/grok-spawn.js +25 -10
- package/dist/install.d.ts +1 -0
- package/dist/install.js +13 -19
- package/dist/kimi-spawn.d.ts +7 -0
- package/dist/kimi-spawn.js +20 -0
- package/dist/mcp-headers.d.ts +15 -0
- package/dist/mcp-headers.js +49 -0
- package/package.json +1 -1
package/dist/codex-spawn.js
CHANGED
|
@@ -52,6 +52,7 @@ const codex_binary_1 = require("./codex-binary");
|
|
|
52
52
|
const diskguard_1 = require("./diskguard");
|
|
53
53
|
const win_1 = require("./win");
|
|
54
54
|
const events_1 = require("./events");
|
|
55
|
+
const mcp_headers_1 = require("./mcp-headers");
|
|
55
56
|
/** Quote a string as a TOML basic string (double-quoted, escape backslash + quote). */
|
|
56
57
|
function tomlString(s) {
|
|
57
58
|
return '"' + String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"';
|
|
@@ -60,6 +61,11 @@ function tomlString(s) {
|
|
|
60
61
|
* Only the NAME goes in config.toml — the value rides on the child env, so
|
|
61
62
|
* the token never lands on disk. */
|
|
62
63
|
const bearerEnvVar = (slug) => `AINODE_MCP_${slug.replace(/[^A-Za-z0-9]+/g, '_').toUpperCase()}_TOKEN`;
|
|
64
|
+
/** Env var name carrying one HTTP header's value into the codex process.
|
|
65
|
+
* config.toml references it by name via env_http_headers, so the value
|
|
66
|
+
* itself never lands on disk. */
|
|
67
|
+
const headerEnvVar = (slug, header) => `AINODE_MCP_${slug.replace(/[^A-Za-z0-9]+/g, '_').toUpperCase()}` +
|
|
68
|
+
`_H_${header.replace(/[^A-Za-z0-9]+/g, '_').toUpperCase()}`;
|
|
63
69
|
/** Build a config.toml that declares only the supplied MCP servers and
|
|
64
70
|
* return the CODEX_HOME directory plus any env vars the child needs
|
|
65
71
|
* (bearer tokens for remote servers). Caller is responsible for cleanup
|
|
@@ -74,12 +80,16 @@ function writeCodexHome(servers, workingDirectory) {
|
|
|
74
80
|
// Remote MCP servers. Registry rows store command='http'|'sse' with
|
|
75
81
|
// args=[url]; codex spells that `url = "..."`, NOT command/args. Writing
|
|
76
82
|
// the row verbatim made codex try to exec a binary called `http`, so the
|
|
77
|
-
// server never started and its tools silently vanished
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
// server never started and its tools silently vanished.
|
|
84
|
+
//
|
|
85
|
+
// Credentials go through env_http_headers, which maps a header name to the
|
|
86
|
+
// NAME of an env var holding its value — so the whole credential set is
|
|
87
|
+
// forwarded and config.toml still never contains a secret. This adapter
|
|
88
|
+
// used to send only ONE credential as a bearer token, on the belief that
|
|
89
|
+
// codex could not send custom headers; it can, and a server needing more
|
|
90
|
+
// than one header (addai-drive carries three) was arriving half-authorised.
|
|
91
|
+
if ((0, mcp_headers_1.isRemoteMcp)(s.command)) {
|
|
92
|
+
const url = (0, mcp_headers_1.remoteMcpUrl)(s.args);
|
|
83
93
|
if (!url) {
|
|
84
94
|
console.error(`[codex] MCP ${s.slug}: ${s.command} server has no URL — skipped`);
|
|
85
95
|
continue;
|
|
@@ -87,22 +97,24 @@ function writeCodexHome(servers, workingDirectory) {
|
|
|
87
97
|
const name = tomlString(s.slug).slice(1, -1);
|
|
88
98
|
toml += `[mcp_servers.${name}]\n`;
|
|
89
99
|
toml += `url = ${tomlString(url)}\n`;
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const bearer = creds.find(([k]) => k === 'OAUTH_ACCESS_TOKEN') ?? creds[0];
|
|
100
|
+
const headers = (0, mcp_headers_1.remoteMcpHeaders)(s.env);
|
|
101
|
+
// An OAuth access token is spelled as codex's native bearer rather than
|
|
102
|
+
// a hand-rolled Authorization header, so its OAuth handling still applies.
|
|
103
|
+
const bearer = headers.Authorization;
|
|
95
104
|
if (bearer) {
|
|
105
|
+
delete headers.Authorization;
|
|
96
106
|
const varName = bearerEnvVar(s.slug);
|
|
97
|
-
extraEnv[varName] =
|
|
107
|
+
extraEnv[varName] = bearer.replace(/^Bearer\s+/i, '');
|
|
98
108
|
toml += `bearer_token_env_var = ${tomlString(varName)}\n`;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
}
|
|
110
|
+
const entries = Object.entries(headers);
|
|
111
|
+
if (entries.length > 0) {
|
|
112
|
+
// Sub-table must follow the parent table's scalar keys.
|
|
113
|
+
toml += `[mcp_servers.${name}.env_http_headers]\n`;
|
|
114
|
+
for (const [header, value] of entries) {
|
|
115
|
+
const varName = headerEnvVar(s.slug, header);
|
|
116
|
+
extraEnv[varName] = value;
|
|
117
|
+
toml += `${tomlString(header)} = ${tomlString(varName)}\n`;
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
toml += '\n';
|
|
@@ -93,10 +93,28 @@ function dropBridges() {
|
|
|
93
93
|
}
|
|
94
94
|
bridges.clear();
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Start a connection attempt that CANNOT take the daemon down with it.
|
|
98
|
+
*
|
|
99
|
+
* `connect` is fire-and-forget. While the socket was gated on having a
|
|
100
|
+
* running desktop, most nodes returned early and never reached the pairing
|
|
101
|
+
* read or the WebSocket construction — so a throw there was unreachable in
|
|
102
|
+
* practice. Making the socket unconditional put every node on that path, and
|
|
103
|
+
* an unhandled rejection in Node terminates the process. At boot. In a loop.
|
|
104
|
+
* A relay that cannot connect must cost this node its push channel, nothing
|
|
105
|
+
* more.
|
|
106
|
+
*/
|
|
107
|
+
function connectSafely() {
|
|
108
|
+
connect().catch(err => {
|
|
109
|
+
ws = null;
|
|
110
|
+
console.error('[relay] connect failed:', err?.message ?? String(err));
|
|
111
|
+
scheduleReconnect();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
96
114
|
function scheduleReconnect() {
|
|
97
115
|
if (stopped)
|
|
98
116
|
return;
|
|
99
|
-
setTimeout(
|
|
117
|
+
setTimeout(connectSafely, backoff);
|
|
100
118
|
backoff = Math.min(backoff * 2, RECONNECT_MAX_MS);
|
|
101
119
|
}
|
|
102
120
|
async function connect() {
|
|
@@ -215,7 +233,7 @@ function startRelayClient() {
|
|
|
215
233
|
return;
|
|
216
234
|
stopped = false;
|
|
217
235
|
backoff = RECONNECT_MIN_MS;
|
|
218
|
-
|
|
236
|
+
connectSafely();
|
|
219
237
|
}
|
|
220
238
|
function stopRelayClient() {
|
|
221
239
|
stopped = true;
|
package/dist/gemini-spawn.d.ts
CHANGED
|
@@ -26,6 +26,21 @@ export interface GeminiHandle {
|
|
|
26
26
|
onEvent(cb: (e: RuntimeEvent) => void): void;
|
|
27
27
|
done: Promise<number>;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Write a workspace-scope `<cwd>/.gemini/settings.json` for THIS spawn.
|
|
31
|
+
*
|
|
32
|
+
* gemini-cli's settings hierarchy is workspace > user — a workspace
|
|
33
|
+
* settings file wins over `~/.gemini/settings.json` field-by-field, so
|
|
34
|
+
* we can override `mcpServers` (the field we care about) without
|
|
35
|
+
* touching the user's home dir.
|
|
36
|
+
*
|
|
37
|
+
* The OLD approach pointed HOME at a temp dir to suppress the host's
|
|
38
|
+
* `~/.gemini/settings.json`. That was destructive: gemini-cli shells out
|
|
39
|
+
* to git, npm, node, and those tools read `~/.gitconfig`, `~/.npmrc`,
|
|
40
|
+
* `~/.netrc` from HOME. Pointing HOME at an empty dir blew them all
|
|
41
|
+
* away → silent tool failures (git push without creds, etc.).
|
|
42
|
+
*/
|
|
43
|
+
export declare function writeGeminiWorkspaceSettings(cwd: string, servers: GeminiMcpServer[]): string;
|
|
29
44
|
/** gemini-cli session ids are v4 UUIDs (createSessionId → node randomUUID).
|
|
30
45
|
* Only pass a plausibly-gemini id to `--resume`; a foreign id would just be
|
|
31
46
|
* reported "Invalid session identifier" and the run degrades to fresh via the
|
package/dist/gemini-spawn.js
CHANGED
|
@@ -44,6 +44,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.writeGeminiWorkspaceSettings = writeGeminiWorkspaceSettings;
|
|
47
48
|
exports.isGeminiSessionId = isGeminiSessionId;
|
|
48
49
|
exports.lineToEvents = lineToEvents;
|
|
49
50
|
exports.spawnGemini = spawnGemini;
|
|
@@ -55,6 +56,7 @@ const gemini_binary_1 = require("./gemini-binary");
|
|
|
55
56
|
const win_1 = require("./win");
|
|
56
57
|
const events_1 = require("./events");
|
|
57
58
|
const think_split_1 = require("./think-split");
|
|
59
|
+
const mcp_headers_1 = require("./mcp-headers");
|
|
58
60
|
/**
|
|
59
61
|
* Write a workspace-scope `<cwd>/.gemini/settings.json` for THIS spawn.
|
|
60
62
|
*
|
|
@@ -76,6 +78,24 @@ function writeGeminiWorkspaceSettings(cwd, servers) {
|
|
|
76
78
|
for (const s of servers) {
|
|
77
79
|
if (!s.slug || !s.command)
|
|
78
80
|
continue;
|
|
81
|
+
// Remote MCP servers. gemini's settings schema spells streamable HTTP as
|
|
82
|
+
// `httpUrl` and SSE as `url` + `type: "sse"`, both with a `headers` map.
|
|
83
|
+
// Writing the registry row verbatim made gemini try to exec a binary
|
|
84
|
+
// called `http`, so the server never started and its tools were simply
|
|
85
|
+
// absent from the run — no error, nothing in the DB.
|
|
86
|
+
if ((0, mcp_headers_1.isRemoteMcp)(s.command)) {
|
|
87
|
+
const url = (0, mcp_headers_1.remoteMcpUrl)(s.args);
|
|
88
|
+
if (!url) {
|
|
89
|
+
console.error(`[gemini] MCP ${s.slug}: ${s.command} server has no URL — skipped`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const headers = (0, mcp_headers_1.remoteMcpHeaders)(s.env);
|
|
93
|
+
const hasHeaders = Object.keys(headers).length > 0;
|
|
94
|
+
mcpServers[s.slug] = s.command === 'sse'
|
|
95
|
+
? { url, type: 'sse', ...(hasHeaders ? { headers } : {}) }
|
|
96
|
+
: { httpUrl: url, ...(hasHeaders ? { headers } : {}) };
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
79
99
|
// `cmd /c` wrapper for npm-shim commands on native Windows (no-op on POSIX).
|
|
80
100
|
const wrapped = (0, win_1.wrapMcpCommandForPlatform)(s.command, Array.isArray(s.args) ? s.args : []);
|
|
81
101
|
mcpServers[s.slug] = {
|
package/dist/grok-spawn.js
CHANGED
|
@@ -74,6 +74,7 @@ const grok_binary_1 = require("./grok-binary");
|
|
|
74
74
|
const win_1 = require("./win");
|
|
75
75
|
const events_1 = require("./events");
|
|
76
76
|
const think_split_1 = require("./think-split");
|
|
77
|
+
const mcp_headers_1 = require("./mcp-headers");
|
|
77
78
|
/** Real config dir for the logged-in account. GROK_HOME points here so the
|
|
78
79
|
* entity uses the same account and token refresh works. */
|
|
79
80
|
function realGrokHome() {
|
|
@@ -160,16 +161,30 @@ function writeProjectMcpConfig(workingDirectory, servers) {
|
|
|
160
161
|
}
|
|
161
162
|
const lines = [];
|
|
162
163
|
for (const s of usable) {
|
|
163
|
-
// Remote MCP servers
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
164
|
+
// Remote MCP servers. xAI documents [mcp_servers.<name>] with `url` and a
|
|
165
|
+
// `headers` inline table, so grok now gets them properly instead of the
|
|
166
|
+
// skip this used to do — a skip that was safe (better than emitting
|
|
167
|
+
// `command = "http"`, which grok would try to exec) but meant an entity
|
|
168
|
+
// running on grok silently had none of its remote servers.
|
|
169
|
+
//
|
|
170
|
+
// Folder trust still gates repo-local config.toml servers, so the --trust
|
|
171
|
+
// launch flag remains load-bearing for these entries to start at all.
|
|
172
|
+
if ((0, mcp_headers_1.isRemoteMcp)(s.command)) {
|
|
173
|
+
const url = (0, mcp_headers_1.remoteMcpUrl)(s.args);
|
|
174
|
+
if (!url) {
|
|
175
|
+
console.error(`[grok] MCP ${s.slug}: ${s.command} server has no URL — skipped`);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
lines.push(`[mcp_servers.${tomlStr(s.slug)}]`);
|
|
179
|
+
lines.push(`url = ${tomlStr(url)}`);
|
|
180
|
+
const headers = Object.entries((0, mcp_headers_1.remoteMcpHeaders)(s.env));
|
|
181
|
+
if (headers.length > 0) {
|
|
182
|
+
const kv = headers.map(([k, v]) => `${tomlStr(k)} = ${tomlStr(v)}`).join(', ');
|
|
183
|
+
lines.push(`headers = { ${kv} }`);
|
|
184
|
+
}
|
|
185
|
+
lines.push('enabled = true');
|
|
186
|
+
lines.push('startup_timeout_sec = 30');
|
|
187
|
+
lines.push('');
|
|
173
188
|
continue;
|
|
174
189
|
}
|
|
175
190
|
// `cmd /c` wrapper for npm-shim commands on native Windows (no-op on POSIX).
|
package/dist/install.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface InstallResult {
|
|
|
42
42
|
/** Cleanup callback — removes everything this install wrote. */
|
|
43
43
|
dispose: () => Promise<void>;
|
|
44
44
|
}
|
|
45
|
+
export declare function writeMcpConfig(cwd: string, mcps: ResolvedMcp[]): string | null;
|
|
45
46
|
/**
|
|
46
47
|
* Run install side-effects against `cwd` and return paths to clean up
|
|
47
48
|
* later. Safe to call with an empty set — returns a no-op result.
|
package/dist/install.js
CHANGED
|
@@ -47,12 +47,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
})();
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.LEGACY_MCP_CONFIG_FILENAME = exports.MCP_CONFIG_FILENAME = void 0;
|
|
50
|
+
exports.writeMcpConfig = writeMcpConfig;
|
|
50
51
|
exports.install = install;
|
|
51
52
|
const fs = __importStar(require("fs"));
|
|
52
53
|
const path = __importStar(require("path"));
|
|
53
54
|
const supabase_client_1 = require("./supabase-client");
|
|
54
55
|
const store_1 = require("./store");
|
|
55
56
|
const win_1 = require("./win");
|
|
57
|
+
const mcp_headers_1 = require("./mcp-headers");
|
|
56
58
|
/** Hidden per-session MCP config written next to the agent's working dir. */
|
|
57
59
|
exports.MCP_CONFIG_FILENAME = '.ainode.mcp.json';
|
|
58
60
|
/** Pre-rename filename; removed when found so agents don't read a stale copy. */
|
|
@@ -111,27 +113,19 @@ function writeMcpConfig(cwd, mcps) {
|
|
|
111
113
|
if (!m.slug || !m.command)
|
|
112
114
|
continue;
|
|
113
115
|
// Remote MCP servers: registry rows use command='http' (or 'sse') with
|
|
114
|
-
// args=[url].
|
|
115
|
-
//
|
|
116
|
-
// headless sessions use account-authenticated remote
|
|
117
|
-
// official Higgsfield server) without an interactive OAuth
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
// args=[url]. Credentials ride as request headers — see mcp-headers.ts for
|
|
117
|
+
// the naming rule and why OAUTH_* keys other than the access token are
|
|
118
|
+
// withheld. This is how headless sessions use account-authenticated remote
|
|
119
|
+
// MCPs (e.g. the official Higgsfield server) without an interactive OAuth
|
|
120
|
+
// dance.
|
|
121
|
+
if ((0, mcp_headers_1.isRemoteMcp)(m.command)) {
|
|
122
|
+
const url = (0, mcp_headers_1.remoteMcpUrl)(m.args);
|
|
123
|
+
if (!url) {
|
|
124
|
+
console.error(`[install] MCP ${m.slug}: ${m.command} server has no URL — skipped`);
|
|
121
125
|
continue;
|
|
122
|
-
const entry = { type: m.command, url };
|
|
123
|
-
const headers = {};
|
|
124
|
-
const token = m.env?.OAUTH_ACCESS_TOKEN;
|
|
125
|
-
if (token)
|
|
126
|
-
headers.Authorization = `Bearer ${token}`;
|
|
127
|
-
// Other env keys become literal headers (so remote MCPs with custom
|
|
128
|
-
// header auth work), but OAUTH_* keys are token bookkeeping (refresh
|
|
129
|
-
// token, expiry) — never send them as request headers.
|
|
130
|
-
for (const [k, v] of Object.entries(m.env || {})) {
|
|
131
|
-
if (!v || k.startsWith('OAUTH_'))
|
|
132
|
-
continue;
|
|
133
|
-
headers[k.replace(/_/g, '-')] = v;
|
|
134
126
|
}
|
|
127
|
+
const entry = { type: m.command, url };
|
|
128
|
+
const headers = (0, mcp_headers_1.remoteMcpHeaders)(m.env);
|
|
135
129
|
if (Object.keys(headers).length > 0)
|
|
136
130
|
entry.headers = headers;
|
|
137
131
|
servers[m.slug] = entry;
|
package/dist/kimi-spawn.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export interface KimiHandle {
|
|
|
39
39
|
onActivity(cb: () => void): void;
|
|
40
40
|
done: Promise<number>;
|
|
41
41
|
}
|
|
42
|
+
/** Write a sandbox $HOME with an empty .kimi dir so kimi's default
|
|
43
|
+
* `~/.kimi/mcp.json` resolves to nothing. Caller is responsible for
|
|
44
|
+
* cleanup (we drop it under os.tmpdir() so the OS reaps it). */
|
|
45
|
+
export declare function writeKimiSandboxHome(servers: KimiMcpServer[]): {
|
|
46
|
+
homeDir: string;
|
|
47
|
+
mcpConfigPath: string;
|
|
48
|
+
};
|
|
42
49
|
/** Parse one stream-json line into 0+ RuntimeEvents. Kimi's shapes are
|
|
43
50
|
* similar in spirit to claude's: assistant text deltas, tool calls,
|
|
44
51
|
* turn completion, and session metadata. Anything we don't recognise
|
package/dist/kimi-spawn.js
CHANGED
|
@@ -42,6 +42,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
};
|
|
43
43
|
})();
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.writeKimiSandboxHome = writeKimiSandboxHome;
|
|
45
46
|
exports.lineToEvents = lineToEvents;
|
|
46
47
|
exports.spawnKimi = spawnKimi;
|
|
47
48
|
const child_process_1 = require("child_process");
|
|
@@ -52,6 +53,7 @@ const kimi_binary_1 = require("./kimi-binary");
|
|
|
52
53
|
const win_1 = require("./win");
|
|
53
54
|
const events_1 = require("./events");
|
|
54
55
|
const think_split_1 = require("./think-split");
|
|
56
|
+
const mcp_headers_1 = require("./mcp-headers");
|
|
55
57
|
/** Write a sandbox $HOME with an empty .kimi dir so kimi's default
|
|
56
58
|
* `~/.kimi/mcp.json` resolves to nothing. Caller is responsible for
|
|
57
59
|
* cleanup (we drop it under os.tmpdir() so the OS reaps it). */
|
|
@@ -62,6 +64,24 @@ function writeKimiSandboxHome(servers) {
|
|
|
62
64
|
for (const s of servers) {
|
|
63
65
|
if (!s.slug || !s.command)
|
|
64
66
|
continue;
|
|
67
|
+
// Remote MCP servers. kimi's mcp.json takes `url` and infers the transport
|
|
68
|
+
// from url-vs-command, so no `transport` key is needed for streamable HTTP;
|
|
69
|
+
// SSE is stated explicitly. Headers carry the credential set. Writing the
|
|
70
|
+
// registry row verbatim made kimi try to exec a binary called `http`.
|
|
71
|
+
if ((0, mcp_headers_1.isRemoteMcp)(s.command)) {
|
|
72
|
+
const url = (0, mcp_headers_1.remoteMcpUrl)(s.args);
|
|
73
|
+
if (!url) {
|
|
74
|
+
console.error(`[kimi] MCP ${s.slug}: ${s.command} server has no URL — skipped`);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const headers = (0, mcp_headers_1.remoteMcpHeaders)(s.env);
|
|
78
|
+
mcpConfig.mcpServers[s.slug] = {
|
|
79
|
+
url,
|
|
80
|
+
...(s.command === 'sse' ? { transport: 'sse' } : {}),
|
|
81
|
+
...(Object.keys(headers).length > 0 ? { headers } : {}),
|
|
82
|
+
};
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
65
85
|
// `cmd /c` wrapper for npm-shim commands on native Windows (no-op on POSIX).
|
|
66
86
|
const wrapped = (0, win_1.wrapMcpCommandForPlatform)(s.command, Array.isArray(s.args) ? s.args : []);
|
|
67
87
|
mcpConfig.mcpServers[s.slug] = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** True when a registry row describes a remote MCP server rather than a
|
|
2
|
+
* local process to spawn. */
|
|
3
|
+
export declare function isRemoteMcp(command: string): boolean;
|
|
4
|
+
/** The endpoint a remote row points at. Returns null for a malformed row so
|
|
5
|
+
* callers can skip it loudly rather than emit a broken config entry. */
|
|
6
|
+
export declare function remoteMcpUrl(args?: string[] | null): string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Convert a registry env map into the HTTP headers the remote server expects.
|
|
9
|
+
*
|
|
10
|
+
* Underscores become hyphens (ENTITY_API_KEY -> ENTITY-API-KEY), matching the
|
|
11
|
+
* deployed github-mcp server. OAUTH_ACCESS_TOKEN becomes an Authorization
|
|
12
|
+
* bearer; every OTHER OAUTH_* key is token bookkeeping (refresh token, expiry)
|
|
13
|
+
* and must never be sent as a header.
|
|
14
|
+
*/
|
|
15
|
+
export declare function remoteMcpHeaders(env?: Record<string, string> | null): Record<string, string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shared handling for remote (http/sse) MCP registry rows.
|
|
3
|
+
//
|
|
4
|
+
// Registry rows store remote servers as command='http'|'sse' with args=[url]
|
|
5
|
+
// and the credential set in env. Each agent CLI spells the config differently,
|
|
6
|
+
// but all five make the same three decisions first — is this row remote, what
|
|
7
|
+
// URL does it point at, and what headers does its env map become. That lived
|
|
8
|
+
// inline in install.ts (the claude path) and the other four adapters each got
|
|
9
|
+
// it wrong in their own way, so it lives here now and they all call it.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.isRemoteMcp = isRemoteMcp;
|
|
12
|
+
exports.remoteMcpUrl = remoteMcpUrl;
|
|
13
|
+
exports.remoteMcpHeaders = remoteMcpHeaders;
|
|
14
|
+
/** True when a registry row describes a remote MCP server rather than a
|
|
15
|
+
* local process to spawn. */
|
|
16
|
+
function isRemoteMcp(command) {
|
|
17
|
+
return command === 'http' || command === 'sse';
|
|
18
|
+
}
|
|
19
|
+
/** The endpoint a remote row points at. Returns null for a malformed row so
|
|
20
|
+
* callers can skip it loudly rather than emit a broken config entry. */
|
|
21
|
+
function remoteMcpUrl(args) {
|
|
22
|
+
if (!Array.isArray(args))
|
|
23
|
+
return null;
|
|
24
|
+
const first = args[0];
|
|
25
|
+
return typeof first === 'string' && first.length > 0 ? first : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a registry env map into the HTTP headers the remote server expects.
|
|
29
|
+
*
|
|
30
|
+
* Underscores become hyphens (ENTITY_API_KEY -> ENTITY-API-KEY), matching the
|
|
31
|
+
* deployed github-mcp server. OAUTH_ACCESS_TOKEN becomes an Authorization
|
|
32
|
+
* bearer; every OTHER OAUTH_* key is token bookkeeping (refresh token, expiry)
|
|
33
|
+
* and must never be sent as a header.
|
|
34
|
+
*/
|
|
35
|
+
function remoteMcpHeaders(env) {
|
|
36
|
+
const headers = {};
|
|
37
|
+
for (const [key, value] of Object.entries(env || {})) {
|
|
38
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
39
|
+
continue;
|
|
40
|
+
if (key === 'OAUTH_ACCESS_TOKEN') {
|
|
41
|
+
headers.Authorization = `Bearer ${value}`;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (key.startsWith('OAUTH_'))
|
|
45
|
+
continue;
|
|
46
|
+
headers[key.replace(/_/g, '-')] = value;
|
|
47
|
+
}
|
|
48
|
+
return headers;
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@addai/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Daemon that pairs a machine with your +Ai account and runs Claude / Codex / Kimi / Gemini agents on its behalf. Reachable via Supabase from Vault, Entity Studio, or any other +Ai surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|