@celljs/ta-agents 4.18.0 → 4.20.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/extension/index.mjs +173 -68
- package/host/index.mjs +19 -4
- package/package.json +4 -4
package/extension/index.mjs
CHANGED
|
@@ -69,6 +69,7 @@ var PRESETS = [
|
|
|
69
69
|
clientMeta: { "codebuddy.ai": { mainAgentSupport: true, toolModeSupport: true } },
|
|
70
70
|
options: { mode: "fullAccess" },
|
|
71
71
|
processPerSession: true,
|
|
72
|
+
confined: { args: ["--tools", "REPL", "--strict-mcp-config"] },
|
|
72
73
|
install: { packages: ["@tencent-ai/codebuddy-code"], bin: "cbc", args: ["--acp"], login: ["cbc"] }
|
|
73
74
|
},
|
|
74
75
|
{
|
|
@@ -78,6 +79,7 @@ var PRESETS = [
|
|
|
78
79
|
args: ["-y", CLAUDE_ADAPTER],
|
|
79
80
|
programs: ["claude"],
|
|
80
81
|
login: "claude",
|
|
82
|
+
confined: { meta: { claudeCode: { options: { tools: [], strictMcpConfig: true } } } },
|
|
81
83
|
install: {
|
|
82
84
|
packages: ["@anthropic-ai/claude-code", CLAUDE_ADAPTER],
|
|
83
85
|
bin: "claude-agent-acp",
|
|
@@ -99,6 +101,19 @@ var PRESETS = [
|
|
|
99
101
|
var AgentCatalog;
|
|
100
102
|
((AgentCatalog) => {
|
|
101
103
|
AgentCatalog.DEFAULT_MODEL = "default";
|
|
104
|
+
function confine(config) {
|
|
105
|
+
if (!config.confined) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const { confined, ...rest } = config;
|
|
109
|
+
return {
|
|
110
|
+
...rest,
|
|
111
|
+
args: [...config.args, ...confined.args ?? []],
|
|
112
|
+
sessionMeta: { ...config.sessionMeta, ...confined.meta },
|
|
113
|
+
binding: `${config.id}:confined`
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
AgentCatalog.confine = confine;
|
|
102
117
|
function presets() {
|
|
103
118
|
return PRESETS.map(({ id, name, programs, install }) => ({ id, name, programs, install }));
|
|
104
119
|
}
|
|
@@ -404,15 +419,21 @@ class AgentTurn {
|
|
|
404
419
|
fail(message, code) {
|
|
405
420
|
this.finish({ type: "error", message, code });
|
|
406
421
|
}
|
|
407
|
-
async next(signal) {
|
|
422
|
+
async next(signal, woken) {
|
|
408
423
|
while (!this.items.length) {
|
|
409
424
|
if (signal?.aborted) {
|
|
410
425
|
return;
|
|
411
426
|
}
|
|
427
|
+
if (woken?.()) {
|
|
428
|
+
return { type: "woken" };
|
|
429
|
+
}
|
|
412
430
|
await this.changed(signal);
|
|
413
431
|
}
|
|
414
432
|
return this.items.shift();
|
|
415
433
|
}
|
|
434
|
+
poke() {
|
|
435
|
+
this.notify();
|
|
436
|
+
}
|
|
416
437
|
async whenEnded(timeoutMs) {
|
|
417
438
|
const until = Date.now() + timeoutMs;
|
|
418
439
|
while (!this.ended && Date.now() < until) {
|
|
@@ -1181,10 +1202,10 @@ var TEXTS = {
|
|
|
1181
1202
|
"ja-JP": (agent) => `${agent} はこのコンピュータのディレクトリでのみ動作します。リモートディレクトリはまだサポートしていません。`
|
|
1182
1203
|
},
|
|
1183
1204
|
narrowed: {
|
|
1184
|
-
"en-US": (agent) => `${agent}
|
|
1185
|
-
"zh-CN": (agent) => `${agent}
|
|
1186
|
-
"zh-TW": (agent) => `${agent}
|
|
1187
|
-
"ja-JP": (agent) => `${agent}
|
|
1205
|
+
"en-US": (agent) => `${agent} cannot work without its own tools (files, commands), and this conversation may use only some of Ta's: pick a model of Ta, or CodeBuddy Code or Claude Code, for it.`,
|
|
1206
|
+
"zh-CN": (agent) => `${agent} 离不开自己读写文件、跑命令的工具,这个对话只能用 Ta 给的几样工具,所以用不了它:请换成 Ta 的模型,或 CodeBuddy Code、Claude Code。`,
|
|
1207
|
+
"zh-TW": (agent) => `${agent} 離不開自己讀寫檔案、執行命令的工具,這個對話只能用 Ta 給的幾樣工具,所以用不了它:請換成 Ta 的模型,或 CodeBuddy Code、Claude Code。`,
|
|
1208
|
+
"ja-JP": (agent) => `${agent} は自分のツール(ファイル、コマンド)なしでは動けません。この会話は Ta のツールの一部しか使えないため、${agent} は使えません。Ta のモデル、または CodeBuddy Code、Claude Code に切り替えてください。`
|
|
1188
1209
|
},
|
|
1189
1210
|
signIn: {
|
|
1190
1211
|
"en-US": (agent, command) => `${agent} is not signed in. Run \`${command}\` in a terminal to sign in, then try again.`,
|
|
@@ -1364,15 +1385,15 @@ class AcpAgent {
|
|
|
1364
1385
|
this.starting.catch(() => this.starting = undefined);
|
|
1365
1386
|
return this.starting;
|
|
1366
1387
|
}
|
|
1367
|
-
async newSession(cwd, signal, servers = []) {
|
|
1388
|
+
async newSession(cwd, signal, servers = [], meta) {
|
|
1368
1389
|
const init = await this.start();
|
|
1369
|
-
const setup = await this.request("session/new", { cwd, mcpServers: AcpAgent.reachable(init, servers) }, signal);
|
|
1390
|
+
const setup = await this.request("session/new", { cwd, mcpServers: AcpAgent.reachable(init, servers), ...AcpAgent.meta(meta) }, signal);
|
|
1370
1391
|
if (!setup?.sessionId) {
|
|
1371
1392
|
throw new Error(`${this.name} did not open a session`);
|
|
1372
1393
|
}
|
|
1373
1394
|
return this.add(setup.sessionId, setup);
|
|
1374
1395
|
}
|
|
1375
|
-
async loadSession(id, cwd, signal, servers = []) {
|
|
1396
|
+
async loadSession(id, cwd, signal, servers = [], meta) {
|
|
1376
1397
|
const known = this.sessions.get(id);
|
|
1377
1398
|
if (known) {
|
|
1378
1399
|
return known;
|
|
@@ -1382,7 +1403,7 @@ class AcpAgent {
|
|
|
1382
1403
|
return;
|
|
1383
1404
|
}
|
|
1384
1405
|
try {
|
|
1385
|
-
const setup = await this.request("session/load", { sessionId: id, cwd, mcpServers: AcpAgent.reachable(init, servers) }, signal);
|
|
1406
|
+
const setup = await this.request("session/load", { sessionId: id, cwd, mcpServers: AcpAgent.reachable(init, servers), ...AcpAgent.meta(meta) }, signal);
|
|
1386
1407
|
return this.add(id, setup ?? {});
|
|
1387
1408
|
} catch (error) {
|
|
1388
1409
|
if (error instanceof JsonRpcError && error.code !== Acp.AUTH_REQUIRED) {
|
|
@@ -1391,6 +1412,9 @@ class AcpAgent {
|
|
|
1391
1412
|
throw error;
|
|
1392
1413
|
}
|
|
1393
1414
|
}
|
|
1415
|
+
static meta(meta) {
|
|
1416
|
+
return meta && Object.keys(meta).length ? { _meta: meta } : {};
|
|
1417
|
+
}
|
|
1394
1418
|
static reachable(init, servers) {
|
|
1395
1419
|
return init?.agentCapabilities?.mcpCapabilities?.http ? servers : [];
|
|
1396
1420
|
}
|
|
@@ -1636,19 +1660,20 @@ class AgentBindings {
|
|
|
1636
1660
|
return this.agentOf(config, this.cwd, this.owner);
|
|
1637
1661
|
}
|
|
1638
1662
|
ready(config) {
|
|
1639
|
-
return this.opened.has(config
|
|
1663
|
+
return this.opened.has(AgentBindings.key(config)) && this.agentOf(config, this.cwd, this.owner).running;
|
|
1640
1664
|
}
|
|
1641
1665
|
open(config, signal) {
|
|
1642
|
-
|
|
1666
|
+
const key = AgentBindings.key(config);
|
|
1667
|
+
this.used.set(JSON.stringify([key, this.cwd, this.owner]), { config, cwd: this.cwd, owner: this.owner });
|
|
1643
1668
|
const agent = this.agentOf(config, this.cwd, this.owner);
|
|
1644
|
-
let opened = this.opened.get(
|
|
1669
|
+
let opened = this.opened.get(key);
|
|
1645
1670
|
if (opened) {
|
|
1646
1671
|
opened = opened.then((value) => agent.running && agent.sessions.get(value.session.id) === value.session ? { ...value, fresh: false, missed: undefined } : this.connect(config, agent, signal));
|
|
1647
1672
|
} else {
|
|
1648
1673
|
opened = this.connect(config, agent, signal);
|
|
1649
1674
|
}
|
|
1650
|
-
opened.catch(() => this.opened.delete(
|
|
1651
|
-
this.opened.set(
|
|
1675
|
+
opened.catch(() => this.opened.delete(key));
|
|
1676
|
+
this.opened.set(key, opened);
|
|
1652
1677
|
return opened;
|
|
1653
1678
|
}
|
|
1654
1679
|
close() {
|
|
@@ -1662,26 +1687,30 @@ class AgentBindings {
|
|
|
1662
1687
|
if (AgentBindings.isRemote(this.cwd)) {
|
|
1663
1688
|
throw new Error(text("remote", config.name));
|
|
1664
1689
|
}
|
|
1665
|
-
const
|
|
1690
|
+
const key = AgentBindings.key(config);
|
|
1691
|
+
const known = this.ids.get(key);
|
|
1666
1692
|
const servers = await this.servers();
|
|
1667
|
-
let session = known ? await agent.loadSession(known, this.cwd, signal, servers) : undefined;
|
|
1693
|
+
let session = known ? await agent.loadSession(known, this.cwd, signal, servers, config.sessionMeta) : undefined;
|
|
1668
1694
|
const fresh = !session;
|
|
1669
1695
|
if (!session) {
|
|
1670
|
-
session = await agent.newSession(this.cwd, signal, servers);
|
|
1696
|
+
session = await agent.newSession(this.cwd, signal, servers, config.sessionMeta);
|
|
1671
1697
|
for (const [option, value] of Object.entries(config.options ?? {})) {
|
|
1672
1698
|
await session.select(option, value, signal).catch(() => {
|
|
1673
1699
|
return;
|
|
1674
1700
|
});
|
|
1675
1701
|
}
|
|
1676
|
-
this.ids.set(
|
|
1677
|
-
this.save({ agent:
|
|
1702
|
+
this.ids.set(key, session.id);
|
|
1703
|
+
this.save({ agent: key, session: session.id });
|
|
1678
1704
|
}
|
|
1679
1705
|
this.prepare(config, session);
|
|
1680
|
-
const waiting = this.waiting.get(
|
|
1681
|
-
this.waiting.delete(
|
|
1706
|
+
const waiting = this.waiting.get(key);
|
|
1707
|
+
this.waiting.delete(key);
|
|
1682
1708
|
const missed = waiting?.session === session.id && waiting.at.length ? waiting.at : undefined;
|
|
1683
1709
|
return { session, fresh, images: !!agent.initialized?.agentCapabilities?.promptCapabilities?.image, dirs: AgentBindings.dirs(this.cwd), missed };
|
|
1684
1710
|
}
|
|
1711
|
+
static key(config) {
|
|
1712
|
+
return config.binding ?? config.id;
|
|
1713
|
+
}
|
|
1685
1714
|
static dirs(cwd) {
|
|
1686
1715
|
try {
|
|
1687
1716
|
const real = realpathSync(cwd);
|
|
@@ -2208,6 +2237,7 @@ var THINKING = {
|
|
|
2208
2237
|
|
|
2209
2238
|
class AgentStreamer {
|
|
2210
2239
|
host;
|
|
2240
|
+
relayed = new Map;
|
|
2211
2241
|
constructor(host) {
|
|
2212
2242
|
this.host = host;
|
|
2213
2243
|
}
|
|
@@ -2225,9 +2255,16 @@ class AgentStreamer {
|
|
|
2225
2255
|
}
|
|
2226
2256
|
async run(config, model, context, options, builder) {
|
|
2227
2257
|
const signal = options?.signal;
|
|
2228
|
-
|
|
2229
|
-
|
|
2258
|
+
const narrowed = !!this.host.narrowed?.();
|
|
2259
|
+
const relay = narrowed ? this.host.relay : undefined;
|
|
2260
|
+
if (narrowed) {
|
|
2261
|
+
const confined = relay && AgentCatalog.confine(config);
|
|
2262
|
+
if (!confined) {
|
|
2263
|
+
throw new Error(text("narrowed", config.name));
|
|
2264
|
+
}
|
|
2265
|
+
config = confined;
|
|
2230
2266
|
}
|
|
2267
|
+
this.answer(context.messages);
|
|
2231
2268
|
let signedIn = false;
|
|
2232
2269
|
const signIn = async (error) => {
|
|
2233
2270
|
if (signedIn || !AgentSignIn.required(error) || !await this.host.signIn?.(config, signal)) {
|
|
@@ -2271,6 +2308,7 @@ class AgentStreamer {
|
|
|
2271
2308
|
builder.done("stop");
|
|
2272
2309
|
return;
|
|
2273
2310
|
}
|
|
2311
|
+
this.cancel();
|
|
2274
2312
|
session.delivered = Math.max(session.delivered, ...pending.map((message) => message.timestamp ?? 0));
|
|
2275
2313
|
const earlier = fresh ? AgentPrompt.transcript(context.messages, pending.length) : undefined;
|
|
2276
2314
|
if (earlier) {
|
|
@@ -2290,55 +2328,104 @@ class AgentStreamer {
|
|
|
2290
2328
|
turn = session.prompt(prompt);
|
|
2291
2329
|
sent = prompt;
|
|
2292
2330
|
}
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
break;
|
|
2305
|
-
case "tool":
|
|
2306
|
-
await this.tools(config, session, turn, item.id, builder, dirs, signal);
|
|
2331
|
+
await this.follow(config, session, turn, builder, dirs, signal, sent, signIn, relay);
|
|
2332
|
+
}
|
|
2333
|
+
async follow(config, session, current, builder, dirs, signal, first, signIn, relay) {
|
|
2334
|
+
let turn = current;
|
|
2335
|
+
let sent = first;
|
|
2336
|
+
const unlisten = relay?.listen(() => turn.poke());
|
|
2337
|
+
try {
|
|
2338
|
+
for (;; ) {
|
|
2339
|
+
const calls = relay?.take() ?? [];
|
|
2340
|
+
if (calls.length) {
|
|
2341
|
+
this.give(calls, builder);
|
|
2307
2342
|
return;
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
sent = queued;
|
|
2315
|
-
break;
|
|
2316
|
-
}
|
|
2317
|
-
if (item.reason === "cancelled" && signal?.aborted) {
|
|
2318
|
-
builder.error("aborted", "Aborted");
|
|
2319
|
-
} else if (item.reason === "refusal") {
|
|
2320
|
-
session.failure = text("refused", config.name);
|
|
2321
|
-
builder.error("error", session.failure);
|
|
2322
|
-
} else {
|
|
2323
|
-
if (turn.command && !turn.produced) {
|
|
2324
|
-
builder.append("text", text("commandDone", config.name, turn.command));
|
|
2325
|
-
}
|
|
2326
|
-
builder.done("stop", AgentStreamer.usage(turn));
|
|
2327
|
-
}
|
|
2343
|
+
}
|
|
2344
|
+
const item = await turn.next(signal, relay ? () => relay.pending : undefined);
|
|
2345
|
+
if (!item) {
|
|
2346
|
+
session.abandon(turn);
|
|
2347
|
+
this.cancel();
|
|
2348
|
+
builder.error("aborted", "Aborted");
|
|
2328
2349
|
return;
|
|
2329
2350
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2351
|
+
switch (item.type) {
|
|
2352
|
+
case "woken":
|
|
2353
|
+
break;
|
|
2354
|
+
case "text":
|
|
2355
|
+
case "thinking":
|
|
2356
|
+
builder.append(item.type, item.text);
|
|
2334
2357
|
break;
|
|
2358
|
+
case "tool":
|
|
2359
|
+
if (!relay) {
|
|
2360
|
+
await this.tools(config, session, turn, item.id, builder, dirs, signal);
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
break;
|
|
2364
|
+
case "end": {
|
|
2365
|
+
session.finished(turn);
|
|
2366
|
+
this.host.ended(config, session);
|
|
2367
|
+
const queued = session.takeQueued();
|
|
2368
|
+
if (queued) {
|
|
2369
|
+
turn = session.prompt(queued);
|
|
2370
|
+
sent = queued;
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
if (item.reason === "cancelled" && signal?.aborted) {
|
|
2374
|
+
builder.error("aborted", "Aborted");
|
|
2375
|
+
} else if (item.reason === "refusal") {
|
|
2376
|
+
session.failure = text("refused", config.name);
|
|
2377
|
+
builder.error("error", session.failure);
|
|
2378
|
+
} else {
|
|
2379
|
+
if (turn.command && !turn.produced) {
|
|
2380
|
+
builder.append("text", text("commandDone", config.name, turn.command));
|
|
2381
|
+
}
|
|
2382
|
+
builder.done("stop", AgentStreamer.usage(turn));
|
|
2383
|
+
}
|
|
2384
|
+
return;
|
|
2335
2385
|
}
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2386
|
+
case "error":
|
|
2387
|
+
session.finished(turn);
|
|
2388
|
+
if (sent && !turn.produced && await signIn(item)) {
|
|
2389
|
+
turn = session.prompt(sent);
|
|
2390
|
+
break;
|
|
2391
|
+
}
|
|
2392
|
+
session.failure = AgentStreamer.describe(config, item);
|
|
2393
|
+
builder.error("error", session.failure);
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
} finally {
|
|
2398
|
+
unlisten?.();
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
give(calls, builder) {
|
|
2402
|
+
for (const call of calls) {
|
|
2403
|
+
const id = `ta_${Math.random().toString(36).slice(2, 12)}`;
|
|
2404
|
+
this.relayed.set(id, call);
|
|
2405
|
+
builder.toolCall({ type: "toolCall", id, name: call.name, arguments: call.args });
|
|
2406
|
+
}
|
|
2407
|
+
builder.done("toolUse");
|
|
2408
|
+
}
|
|
2409
|
+
answer(messages) {
|
|
2410
|
+
if (!this.relayed.size) {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
for (const message of messages) {
|
|
2414
|
+
const { role, toolCallId, content, isError } = message;
|
|
2415
|
+
const call = role === "toolResult" && toolCallId ? this.relayed.get(toolCallId) : undefined;
|
|
2416
|
+
if (call) {
|
|
2417
|
+
this.relayed.delete(toolCallId);
|
|
2418
|
+
const parts = (Array.isArray(content) ? content : []).filter((part) => part.type === "text" || part.type === "image");
|
|
2419
|
+
call.resolve({ content: parts.length ? parts : [{ type: "text", text: "(no output)" }], ...isError ? { isError: true } : {} });
|
|
2339
2420
|
}
|
|
2340
2421
|
}
|
|
2341
2422
|
}
|
|
2423
|
+
cancel() {
|
|
2424
|
+
for (const call of this.relayed.values()) {
|
|
2425
|
+
call.resolve({ content: [{ type: "text", text: "Cancelled" }], isError: true });
|
|
2426
|
+
}
|
|
2427
|
+
this.relayed.clear();
|
|
2428
|
+
}
|
|
2342
2429
|
async tools(config, session, turn, first, builder, dirs, signal) {
|
|
2343
2430
|
const ids = [first];
|
|
2344
2431
|
while (turn.peek()?.type === "tool") {
|
|
@@ -2405,7 +2492,8 @@ class AgentToolCalls {
|
|
|
2405
2492
|
}
|
|
2406
2493
|
list() {
|
|
2407
2494
|
const active = new Set(this.active());
|
|
2408
|
-
|
|
2495
|
+
const offered = active.has(AgentTool.NAME) ? AgentToolCalls.offered : AgentToolCalls.left;
|
|
2496
|
+
return this.tools().filter((tool) => offered(tool, active)).map((tool) => ({
|
|
2409
2497
|
name: tool.name,
|
|
2410
2498
|
description: tool.description ?? "",
|
|
2411
2499
|
inputSchema: AgentToolCalls.schema(tool.parameters)
|
|
@@ -2415,7 +2503,7 @@ class AgentToolCalls {
|
|
|
2415
2503
|
return new Promise((resolve) => {
|
|
2416
2504
|
const timer = setTimeout(() => settle({ content: [{ type: "text", text: `Ta could not run ${name} now: no turn of Ta is waiting for you.` }], isError: true }), UNTAKEN_MS);
|
|
2417
2505
|
timer.unref?.();
|
|
2418
|
-
const waiting = { name, args, signal, resolve: (result) => settle(result) };
|
|
2506
|
+
const waiting = { name, args, signal, resolve: (result) => settle(result), taken: () => clearTimeout(timer) };
|
|
2419
2507
|
const settle = (result) => {
|
|
2420
2508
|
clearTimeout(timer);
|
|
2421
2509
|
const index = this.waiting.indexOf(waiting);
|
|
@@ -2434,6 +2522,17 @@ class AgentToolCalls {
|
|
|
2434
2522
|
get pending() {
|
|
2435
2523
|
return this.waiting.length > 0;
|
|
2436
2524
|
}
|
|
2525
|
+
take() {
|
|
2526
|
+
const calls = this.waiting.splice(0);
|
|
2527
|
+
for (const call of calls) {
|
|
2528
|
+
call.taken();
|
|
2529
|
+
}
|
|
2530
|
+
return calls;
|
|
2531
|
+
}
|
|
2532
|
+
listen(listener) {
|
|
2533
|
+
this.wakers.add(listener);
|
|
2534
|
+
return () => this.wakers.delete(listener);
|
|
2535
|
+
}
|
|
2437
2536
|
async serve(run, until, signal) {
|
|
2438
2537
|
let done = false;
|
|
2439
2538
|
until.finally(() => done = true).catch(() => {
|
|
@@ -2443,6 +2542,7 @@ class AgentToolCalls {
|
|
|
2443
2542
|
while (!done && !signal?.aborted) {
|
|
2444
2543
|
const next = this.waiting.shift();
|
|
2445
2544
|
if (next) {
|
|
2545
|
+
next.taken();
|
|
2446
2546
|
taken.push(this.runOne(run, next));
|
|
2447
2547
|
continue;
|
|
2448
2548
|
}
|
|
@@ -2494,6 +2594,9 @@ class AgentToolCalls {
|
|
|
2494
2594
|
return false;
|
|
2495
2595
|
}
|
|
2496
2596
|
}
|
|
2597
|
+
static left(tool, active) {
|
|
2598
|
+
return tool.name !== AgentTool.NAME && active.has(tool.name) && tool.exposure !== "hidden";
|
|
2599
|
+
}
|
|
2497
2600
|
static schema(parameters) {
|
|
2498
2601
|
const schema = parameters && typeof parameters === "object" ? JSON.parse(JSON.stringify(parameters)) : {};
|
|
2499
2602
|
return schema.type === "object" ? schema : { type: "object", properties: {} };
|
|
@@ -2638,13 +2741,14 @@ function activate(pi, options = {}) {
|
|
|
2638
2741
|
},
|
|
2639
2742
|
queued: (at) => {
|
|
2640
2743
|
if (context) {
|
|
2641
|
-
const entry = { agent: config
|
|
2744
|
+
const entry = { agent: AgentBindings.key(config), session: session.id, at };
|
|
2642
2745
|
pi.appendEntry(QUEUE_ENTRY, entry);
|
|
2643
2746
|
}
|
|
2644
2747
|
}
|
|
2645
2748
|
};
|
|
2646
2749
|
learn(config, session);
|
|
2647
2750
|
}, options.agentOf, options.release);
|
|
2751
|
+
const tools = new AgentToolCalls(() => pi.getAllTools(), () => pi.getActiveTools());
|
|
2648
2752
|
const streamer = new AgentStreamer({
|
|
2649
2753
|
open: async (config, signal) => {
|
|
2650
2754
|
if (bindings.ready(config)) {
|
|
@@ -2665,6 +2769,7 @@ function activate(pi, options = {}) {
|
|
|
2665
2769
|
},
|
|
2666
2770
|
narrowed: () => !pi.getActiveTools().includes(AgentTool.NAME),
|
|
2667
2771
|
notes: () => served && tools.list().length ? [AgentPrompt.toolsNote(AgentMcp.NAME)] : [],
|
|
2772
|
+
relay: tools,
|
|
2668
2773
|
ended: (config, session) => {
|
|
2669
2774
|
if (session.title && !pi.getSessionName()) {
|
|
2670
2775
|
pi.setSessionName(session.title);
|
|
@@ -2677,7 +2782,6 @@ function activate(pi, options = {}) {
|
|
|
2677
2782
|
});
|
|
2678
2783
|
const self = { configs: () => configs, streamer };
|
|
2679
2784
|
let sessionId;
|
|
2680
|
-
const tools = new AgentToolCalls(() => pi.getAllTools(), () => pi.getActiveTools());
|
|
2681
2785
|
let served;
|
|
2682
2786
|
bindings.servers = async () => {
|
|
2683
2787
|
served ??= (options.mcp ?? mcp()).add(tools);
|
|
@@ -2715,6 +2819,7 @@ function activate(pi, options = {}) {
|
|
|
2715
2819
|
toggleTool(ctx.model);
|
|
2716
2820
|
});
|
|
2717
2821
|
pi.on("model_select", (event) => toggleTool(event.model));
|
|
2822
|
+
pi.on("agent_settled", () => toggleTool(context?.model));
|
|
2718
2823
|
pi.on("session_tree", () => bindings.forget());
|
|
2719
2824
|
pi.on("session_before_compact", (event, ctx) => {
|
|
2720
2825
|
if (!ours(ctx.model)) {
|
package/host/index.mjs
CHANGED
|
@@ -19,6 +19,7 @@ var PRESETS = [
|
|
|
19
19
|
clientMeta: { "codebuddy.ai": { mainAgentSupport: true, toolModeSupport: true } },
|
|
20
20
|
options: { mode: "fullAccess" },
|
|
21
21
|
processPerSession: true,
|
|
22
|
+
confined: { args: ["--tools", "REPL", "--strict-mcp-config"] },
|
|
22
23
|
install: { packages: ["@tencent-ai/codebuddy-code"], bin: "cbc", args: ["--acp"], login: ["cbc"] }
|
|
23
24
|
},
|
|
24
25
|
{
|
|
@@ -28,6 +29,7 @@ var PRESETS = [
|
|
|
28
29
|
args: ["-y", CLAUDE_ADAPTER],
|
|
29
30
|
programs: ["claude"],
|
|
30
31
|
login: "claude",
|
|
32
|
+
confined: { meta: { claudeCode: { options: { tools: [], strictMcpConfig: true } } } },
|
|
31
33
|
install: {
|
|
32
34
|
packages: ["@anthropic-ai/claude-code", CLAUDE_ADAPTER],
|
|
33
35
|
bin: "claude-agent-acp",
|
|
@@ -49,6 +51,19 @@ var PRESETS = [
|
|
|
49
51
|
var AgentCatalog;
|
|
50
52
|
((AgentCatalog) => {
|
|
51
53
|
AgentCatalog.DEFAULT_MODEL = "default";
|
|
54
|
+
function confine(config) {
|
|
55
|
+
if (!config.confined) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const { confined, ...rest } = config;
|
|
59
|
+
return {
|
|
60
|
+
...rest,
|
|
61
|
+
args: [...config.args, ...confined.args ?? []],
|
|
62
|
+
sessionMeta: { ...config.sessionMeta, ...confined.meta },
|
|
63
|
+
binding: `${config.id}:confined`
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
AgentCatalog.confine = confine;
|
|
52
67
|
function presets() {
|
|
53
68
|
return PRESETS.map(({ id, name, programs, install }) => ({ id, name, programs, install }));
|
|
54
69
|
}
|
|
@@ -234,10 +249,10 @@ var TEXTS = {
|
|
|
234
249
|
"ja-JP": (agent) => `${agent} はこのコンピュータのディレクトリでのみ動作します。リモートディレクトリはまだサポートしていません。`
|
|
235
250
|
},
|
|
236
251
|
narrowed: {
|
|
237
|
-
"en-US": (agent) => `${agent}
|
|
238
|
-
"zh-CN": (agent) => `${agent}
|
|
239
|
-
"zh-TW": (agent) => `${agent}
|
|
240
|
-
"ja-JP": (agent) => `${agent}
|
|
252
|
+
"en-US": (agent) => `${agent} cannot work without its own tools (files, commands), and this conversation may use only some of Ta's: pick a model of Ta, or CodeBuddy Code or Claude Code, for it.`,
|
|
253
|
+
"zh-CN": (agent) => `${agent} 离不开自己读写文件、跑命令的工具,这个对话只能用 Ta 给的几样工具,所以用不了它:请换成 Ta 的模型,或 CodeBuddy Code、Claude Code。`,
|
|
254
|
+
"zh-TW": (agent) => `${agent} 離不開自己讀寫檔案、執行命令的工具,這個對話只能用 Ta 給的幾樣工具,所以用不了它:請換成 Ta 的模型,或 CodeBuddy Code、Claude Code。`,
|
|
255
|
+
"ja-JP": (agent) => `${agent} は自分のツール(ファイル、コマンド)なしでは動けません。この会話は Ta のツールの一部しか使えないため、${agent} は使えません。Ta のモデル、または CodeBuddy Code、Claude Code に切り替えてください。`
|
|
241
256
|
},
|
|
242
257
|
signIn: {
|
|
243
258
|
"en-US": (agent, command) => `${agent} is not signed in. Run \`${command}\` in a terminal to sign in, then try again.`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-agents",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.20.0",
|
|
4
4
|
"description": "A pi package for Ta: other coding agents (CodeBuddy Code, Claude Code, Codex and any agent that speaks ACP) as models to pick, each running a conversation on its own harness",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@celljs/ta-exec": "4.
|
|
32
|
-
"@celljs/ta-protocol": "4.
|
|
33
|
-
"@celljs/ta-web": "4.
|
|
31
|
+
"@celljs/ta-exec": "4.20.0",
|
|
32
|
+
"@celljs/ta-protocol": "4.20.0",
|
|
33
|
+
"@celljs/ta-web": "4.20.0",
|
|
34
34
|
"@earendil-works/pi-ai": "^1.5.2",
|
|
35
35
|
"@earendil-works/pi-coding-agent": "^1.5.2",
|
|
36
36
|
"@types/react": "^19.3.0"
|