@livx.cc/agentx 0.99.2 → 0.99.4
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/{Agent-B_JD31Zx.d.ts → Agent-BPEXD7n7.d.ts} +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +52 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/{mcp-BZcizHav.d.ts → mcp-DyeLLday.d.ts} +1 -1
- package/dist/mcp.client.d.ts +2 -2
- package/dist/{tools-DmrqMJcI.d.ts → tools-CrsRHvvl.d.ts} +15 -0
- package/dist/tools.shell.d.ts +1 -1
- package/dist/tools.shell.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
2
|
-
import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent } from './tools-
|
|
2
|
+
import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent } from './tools-CrsRHvvl.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Hooks — deterministic interception points around tool execution, run by the
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { H as Hooks, h as RunResult, R as ReasoningEffort, A as Agent } from './Agent-
|
|
2
|
+
import { H as Hooks, h as RunResult, R as ReasoningEffort, A as Agent } from './Agent-BPEXD7n7.js';
|
|
3
3
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
4
|
-
import { M as Message, c as ContentPart, e as MessageContent } from './tools-
|
|
4
|
+
import { M as Message, c as ContentPart, e as MessageContent } from './tools-CrsRHvvl.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* On-disk session store for the CLI: each conversation is one JSON file at
|
package/dist/cli.js
CHANGED
|
@@ -2028,7 +2028,7 @@ function copyTextToClipboard(text, platform2 = process.platform) {
|
|
|
2028
2028
|
|
|
2029
2029
|
// cli/cli.ts
|
|
2030
2030
|
import { join as join14, resolve as resolve3, basename as basename2, extname, dirname as dirname4 } from "path";
|
|
2031
|
-
import { AIClient, listModels, listProviders, getProviderFromModel, getModelInfo, resolveModel, isModelSupported, disposeCursorSessions } from "ai.libx.js";
|
|
2031
|
+
import { AIClient, listModels, listProviders, getProviderFromModel, getModelInfo, resolveModel, isModelSupported, disposeCursorSessions, disposeClaudeCodeSessions } from "ai.libx.js";
|
|
2032
2032
|
|
|
2033
2033
|
// src/llm.ts
|
|
2034
2034
|
function contentText(content) {
|
|
@@ -3566,6 +3566,7 @@ var Agent = class _Agent {
|
|
|
3566
3566
|
let res;
|
|
3567
3567
|
const sent = this.trimContext();
|
|
3568
3568
|
const frag = reasoningToChatFragment(o.model, o.reasoning);
|
|
3569
|
+
const sentTools = o.model.startsWith("claude-code/") ? [] : wireTools;
|
|
3569
3570
|
const isCursorWithTools = o.model.startsWith("cursor/") && wireTools.length > 0;
|
|
3570
3571
|
const cursorPo = isCursorWithTools ? {
|
|
3571
3572
|
toolExecutor: async (name, args) => {
|
|
@@ -3583,10 +3584,10 @@ var Agent = class _Agent {
|
|
|
3583
3584
|
for (let attempt = 0; ; attempt++) {
|
|
3584
3585
|
try {
|
|
3585
3586
|
if (useStream) {
|
|
3586
|
-
const r = await o.ai.chat({ model: o.model, messages: sent, tools:
|
|
3587
|
+
const r = await o.ai.chat({ model: o.model, messages: sent, tools: sentTools, stream: true, signal: o.signal, ...o.toolChoice ? { toolChoice: o.toolChoice } : {}, ...reasonOpts });
|
|
3587
3588
|
res = await this.consumeStream(r);
|
|
3588
3589
|
} else {
|
|
3589
|
-
const r = await o.ai.chat({ model: o.model, messages: sent, tools:
|
|
3590
|
+
const r = await o.ai.chat({ model: o.model, messages: sent, tools: sentTools, stream: false, signal: o.signal, ...o.toolChoice ? { toolChoice: o.toolChoice } : {}, ...reasonOpts });
|
|
3590
3591
|
res = r;
|
|
3591
3592
|
}
|
|
3592
3593
|
break;
|
|
@@ -3680,6 +3681,11 @@ var Agent = class _Agent {
|
|
|
3680
3681
|
for await (const chunk of stream) {
|
|
3681
3682
|
if (this.options.signal?.aborted) break;
|
|
3682
3683
|
if (chunk.reasoningContent) this.options.host.notify({ kind: "thinking_delta", message: chunk.reasoningContent });
|
|
3684
|
+
if (chunk.toolActivity) {
|
|
3685
|
+
const a = chunk.toolActivity;
|
|
3686
|
+
const verb = a.status === "error" ? "\u2717" : a.status === "completed" ? "\u2713" : "\u2192";
|
|
3687
|
+
this.options.host.notify({ kind: "tool_activity", id: a.id, name: a.name, input: a.input, status: a.status, message: `${verb} ${a.name}` });
|
|
3688
|
+
}
|
|
3683
3689
|
if (chunk.content) {
|
|
3684
3690
|
content += chunk.content;
|
|
3685
3691
|
this.options.host.notify({ kind: "text_delta", message: chunk.content });
|
|
@@ -7348,6 +7354,34 @@ function cursorProviderOptions(model, cwd, mcpServers) {
|
|
|
7348
7354
|
if (!(model ?? "").startsWith("cursor/")) return void 0;
|
|
7349
7355
|
return { cwd, ...toCursorMcp(mcpServers) ?? {}, ...process.env.CURSOR_WARM === "0" ? {} : { cursorSession: randomUUID() } };
|
|
7350
7356
|
}
|
|
7357
|
+
function toClaudeCodeMcp(servers) {
|
|
7358
|
+
if (!servers) return void 0;
|
|
7359
|
+
const out = {};
|
|
7360
|
+
for (const [name, s] of Object.entries(servers)) {
|
|
7361
|
+
if (!s || s.disabled) continue;
|
|
7362
|
+
if (s.command) {
|
|
7363
|
+
out[name] = { type: "stdio", command: s.command, ...s.args ? { args: s.args } : {}, ...s.env ? { env: s.env } : {} };
|
|
7364
|
+
} else if (s.url) {
|
|
7365
|
+
if (s.auth === "oauth" && !s.bearerToken) continue;
|
|
7366
|
+
const headers = { ...s.headers ?? {}, ...s.bearerToken ? { Authorization: `Bearer ${s.bearerToken}` } : {} };
|
|
7367
|
+
out[name] = { type: "http", url: s.url, ...Object.keys(headers).length ? { headers } : {} };
|
|
7368
|
+
}
|
|
7369
|
+
}
|
|
7370
|
+
return Object.keys(out).length ? { mcpServers: out } : void 0;
|
|
7371
|
+
}
|
|
7372
|
+
function claudeCodeProviderOptions(model, cwd, mcpServers) {
|
|
7373
|
+
if (!(model ?? "").startsWith("claude-code/")) return void 0;
|
|
7374
|
+
const env = (() => {
|
|
7375
|
+
if (process.env.AGENTX_CC_USE_API_KEY) return void 0;
|
|
7376
|
+
const { ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ...rest } = process.env;
|
|
7377
|
+
return rest;
|
|
7378
|
+
})();
|
|
7379
|
+
const warm = process.env.AGENTX_CC_WARM === "0" ? {} : { claudeCodeSession: randomUUID() };
|
|
7380
|
+
return { cwd, ...env ? { env } : {}, ...warm, ...toClaudeCodeMcp(mcpServers) ?? {} };
|
|
7381
|
+
}
|
|
7382
|
+
function providerOptionsFor(model, cwd, mcpServers) {
|
|
7383
|
+
return cursorProviderOptions(model, cwd, mcpServers) ?? claudeCodeProviderOptions(model, cwd, mcpServers);
|
|
7384
|
+
}
|
|
7351
7385
|
async function buildAgent(o) {
|
|
7352
7386
|
if (typeof o.sandbox !== "boolean")
|
|
7353
7387
|
throw new Error(
|
|
@@ -7360,9 +7394,11 @@ async function buildAgent(o) {
|
|
|
7360
7394
|
jailedDisk.setCwd(cwd);
|
|
7361
7395
|
const virtual = o.sandbox || !!o.boddb;
|
|
7362
7396
|
const isCursor = (o.model ?? "").startsWith("cursor/");
|
|
7363
|
-
|
|
7397
|
+
const isClaudeCode = (o.model ?? "").startsWith("claude-code/");
|
|
7398
|
+
const isDelegated = isCursor || isClaudeCode;
|
|
7399
|
+
if (virtual && isDelegated)
|
|
7364
7400
|
throw new Error(
|
|
7365
|
-
"cursor/* models cannot run in --sandbox/--boddb: the
|
|
7401
|
+
`${isCursor ? "cursor" : "claude-code"}/* models cannot run in --sandbox/--boddb: the delegated agent runs its own real-disk tools and bypasses the VFS jail. Use disk mode (default).`
|
|
7366
7402
|
);
|
|
7367
7403
|
let fs = jailedDisk;
|
|
7368
7404
|
if (o.sandbox) {
|
|
@@ -7429,7 +7465,7 @@ Reference files in them by their mount path (the left side).`;
|
|
|
7429
7465
|
const hooks = o.learnFromMistakes && memoryWriteDir ? composeHooks(o.hooks, lessonCapture({ fs, dir: memoryWriteDir, minRepeats: 2 })) : o.hooks;
|
|
7430
7466
|
let realShell = [];
|
|
7431
7467
|
const useRealShell = o.realShell ?? !virtual;
|
|
7432
|
-
if (useRealShell && !virtual) {
|
|
7468
|
+
if (useRealShell && !virtual && !isClaudeCode) {
|
|
7433
7469
|
const jobs = new ShellJobRegistry({ cwd, killOnExit: true, osSandbox: o.osSandbox });
|
|
7434
7470
|
realShell = [makeRealShellTool({ cwd, registry: jobs, osSandbox: o.osSandbox }), ...makeShellJobTools(jobs)];
|
|
7435
7471
|
}
|
|
@@ -7448,7 +7484,7 @@ Reference files in them by their mount path (the left side).`;
|
|
|
7448
7484
|
// Warm cursor session (default on; CURSOR_WARM=0 to disable): one long-lived agent reused across
|
|
7449
7485
|
// turns, amortising the ~2s Agent.create + h2 handshake. Keyed per agentx launch.
|
|
7450
7486
|
...(() => {
|
|
7451
|
-
const po =
|
|
7487
|
+
const po = providerOptionsFor(o.model, cwd, o.mcpServers);
|
|
7452
7488
|
return po ? { providerOptions: po } : {};
|
|
7453
7489
|
})(),
|
|
7454
7490
|
...(() => {
|
|
@@ -7480,6 +7516,7 @@ The filesystem root '/' is the real machine root \u2014 you have full filesystem
|
|
|
7480
7516
|
return { systemPrompt: basePrompt + "\n\n" + extra };
|
|
7481
7517
|
})(),
|
|
7482
7518
|
tools: (() => {
|
|
7519
|
+
if (isClaudeCode) return [];
|
|
7483
7520
|
const requested = o.tools ?? DEFAULT_TOOLS;
|
|
7484
7521
|
const base = toolsByName([...requested, ...autoWebTools()]);
|
|
7485
7522
|
const tail = [...o.extraTools ?? []];
|
|
@@ -12050,7 +12087,7 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
12050
12087
|
...args.voiceModel ?? cfg.reflexModel ? { reflexModel: resolveModelOrNewest(args.voiceModel ?? cfg.reflexModel) } : {},
|
|
12051
12088
|
actModel: agent.options.model,
|
|
12052
12089
|
actOptions: workerOptions,
|
|
12053
|
-
providerOptionsFor: (m) =>
|
|
12090
|
+
providerOptionsFor: (m) => providerOptionsFor(m, cwd, cfg.mcpServers),
|
|
12054
12091
|
...(args.thinkModel ?? cfg.thinkModel) !== void 0 ? { thinkModel: (args.thinkModel ?? cfg.thinkModel) === false ? false : resolveModelOrNewest(String(args.thinkModel ?? cfg.thinkModel)) } : {},
|
|
12055
12092
|
host,
|
|
12056
12093
|
...args.voice ? { voiceStyle: "conversational", progressUpdates: true, askRelay: true, emotionTags: emotionsOn } : {},
|
|
@@ -12131,7 +12168,7 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
12131
12168
|
};
|
|
12132
12169
|
const setModel = (m) => {
|
|
12133
12170
|
work.model = m;
|
|
12134
|
-
work.providerOptions =
|
|
12171
|
+
work.providerOptions = providerOptionsFor(m, cwd, cfg.mcpServers);
|
|
12135
12172
|
if (dx) dx.options.actModel = m;
|
|
12136
12173
|
persistModel(cwd, m);
|
|
12137
12174
|
err(dim(" model \u2192 " + m + "\n"));
|
|
@@ -12211,6 +12248,10 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
12211
12248
|
disposeCursorSessions();
|
|
12212
12249
|
} catch {
|
|
12213
12250
|
}
|
|
12251
|
+
try {
|
|
12252
|
+
disposeClaudeCodeSessions();
|
|
12253
|
+
} catch {
|
|
12254
|
+
}
|
|
12214
12255
|
void closeMcp(mounted);
|
|
12215
12256
|
process.exit(code);
|
|
12216
12257
|
};
|
|
@@ -13956,6 +13997,7 @@ ${out}
|
|
|
13956
13997
|
voiceIO?.stop();
|
|
13957
13998
|
releaseStdin();
|
|
13958
13999
|
disposeCursorSessions();
|
|
14000
|
+
disposeClaudeCodeSessions();
|
|
13959
14001
|
await closeMcp(mounted);
|
|
13960
14002
|
process.exit(130);
|
|
13961
14003
|
}
|
|
@@ -13965,6 +14007,7 @@ ${out}
|
|
|
13965
14007
|
}
|
|
13966
14008
|
releaseStdin();
|
|
13967
14009
|
disposeCursorSessions();
|
|
14010
|
+
disposeClaudeCodeSessions();
|
|
13968
14011
|
await closeMcp(mounted);
|
|
13969
14012
|
}
|
|
13970
14013
|
function readAllStdin() {
|