opencara 0.108.0 → 0.108.1
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/bin.js +1 -1
- package/dist/claude-acp.js +59 -5
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1307,7 +1307,7 @@ function resolveLocalAcpAdapter(command, args) {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
|
|
1309
1309
|
// src/commands/run.ts
|
|
1310
|
-
var PKG_VERSION = "0.108.
|
|
1310
|
+
var PKG_VERSION = "0.108.1";
|
|
1311
1311
|
var LOG_FLUSH_MS = 800;
|
|
1312
1312
|
var MAX_CHUNK_SIZE = 4 * 1024;
|
|
1313
1313
|
async function run(opts = {}) {
|
package/dist/claude-acp.js
CHANGED
|
@@ -61,6 +61,43 @@ function replyError(id, code, message) {
|
|
|
61
61
|
function notify(method, params) {
|
|
62
62
|
send({ jsonrpc: "2.0", method, params });
|
|
63
63
|
}
|
|
64
|
+
function normalizeMcpServers(raw) {
|
|
65
|
+
if (!Array.isArray(raw)) return [];
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const entry of raw) {
|
|
68
|
+
if (!entry || typeof entry !== "object") continue;
|
|
69
|
+
const e = entry;
|
|
70
|
+
if (e["type"] !== "stdio") continue;
|
|
71
|
+
if (typeof e["name"] !== "string" || typeof e["command"] !== "string") continue;
|
|
72
|
+
const args = Array.isArray(e["args"]) ? e["args"].map(String) : [];
|
|
73
|
+
const env = [];
|
|
74
|
+
if (Array.isArray(e["env"])) {
|
|
75
|
+
for (const kv of e["env"]) {
|
|
76
|
+
if (!kv || typeof kv !== "object") continue;
|
|
77
|
+
const r = kv;
|
|
78
|
+
if (typeof r["name"] !== "string" || typeof r["value"] !== "string") continue;
|
|
79
|
+
env.push({ name: r["name"], value: r["value"] });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
out.push({
|
|
83
|
+
type: "stdio",
|
|
84
|
+
name: e["name"],
|
|
85
|
+
command: e["command"],
|
|
86
|
+
args,
|
|
87
|
+
env
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function buildClaudeMcpConfig(servers) {
|
|
93
|
+
const mcpServers = {};
|
|
94
|
+
for (const s of servers) {
|
|
95
|
+
const env = {};
|
|
96
|
+
for (const kv of s.env) env[kv.name] = kv.value;
|
|
97
|
+
mcpServers[s.name] = { command: s.command, args: s.args, env };
|
|
98
|
+
}
|
|
99
|
+
return JSON.stringify({ mcpServers });
|
|
100
|
+
}
|
|
64
101
|
var sessions = /* @__PURE__ */ new Map();
|
|
65
102
|
async function runClaudeTurn(sessionId, state, promptText, permissionMode) {
|
|
66
103
|
return new Promise((resolve, reject) => {
|
|
@@ -82,6 +119,13 @@ async function runClaudeTurn(sessionId, state, promptText, permissionMode) {
|
|
|
82
119
|
} else {
|
|
83
120
|
args.push("--dangerously-skip-permissions");
|
|
84
121
|
}
|
|
122
|
+
if (state.mcpServers && state.mcpServers.length > 0) {
|
|
123
|
+
args.push(
|
|
124
|
+
"--mcp-config",
|
|
125
|
+
buildClaudeMcpConfig(state.mcpServers),
|
|
126
|
+
"--strict-mcp-config"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
85
129
|
const child = spawn("claude", args, {
|
|
86
130
|
cwd: state.cwd,
|
|
87
131
|
env: process.env,
|
|
@@ -202,9 +246,9 @@ function handleInitialize(_params) {
|
|
|
202
246
|
agentCapabilities: {
|
|
203
247
|
// Session resume works by passing the ACP sessionId back as
|
|
204
248
|
// `claude --session-id <uuid>` on the next prompt — Claude CLI
|
|
205
|
-
// replays its own JSONL internally.
|
|
206
|
-
//
|
|
207
|
-
//
|
|
249
|
+
// replays its own JSONL internally. ACP's mcpServers are bridged
|
|
250
|
+
// to Claude via `--mcp-config <inline-json> --strict-mcp-config`
|
|
251
|
+
// on each turn (see SessionState.mcpServers / runClaudeTurn).
|
|
208
252
|
loadSession: true,
|
|
209
253
|
mcpCapabilities: {},
|
|
210
254
|
promptCapabilities: { embeddedContext: false, image: false, audio: false }
|
|
@@ -214,14 +258,24 @@ function handleInitialize(_params) {
|
|
|
214
258
|
}
|
|
215
259
|
function handleNewSession(params) {
|
|
216
260
|
const sessionId = randomUUID();
|
|
217
|
-
|
|
261
|
+
const mcpServers = normalizeMcpServers(params.mcpServers);
|
|
262
|
+
sessions.set(sessionId, {
|
|
263
|
+
cwd: params.cwd ?? process.cwd(),
|
|
264
|
+
resume: false,
|
|
265
|
+
...mcpServers.length > 0 ? { mcpServers } : {}
|
|
266
|
+
});
|
|
218
267
|
return { sessionId };
|
|
219
268
|
}
|
|
220
269
|
function handleLoadSession(params) {
|
|
221
270
|
if (typeof params.sessionId !== "string" || params.sessionId.length === 0) {
|
|
222
271
|
throw new Error("session/load: sessionId required");
|
|
223
272
|
}
|
|
224
|
-
|
|
273
|
+
const mcpServers = normalizeMcpServers(params.mcpServers);
|
|
274
|
+
sessions.set(params.sessionId, {
|
|
275
|
+
cwd: params.cwd ?? process.cwd(),
|
|
276
|
+
resume: true,
|
|
277
|
+
...mcpServers.length > 0 ? { mcpServers } : {}
|
|
278
|
+
});
|
|
225
279
|
return {};
|
|
226
280
|
}
|
|
227
281
|
async function handlePrompt(params) {
|