@livx.cc/agentx 0.99.2 → 0.99.3

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/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: wireTools, stream: true, signal: o.signal, ...o.toolChoice ? { toolChoice: o.toolChoice } : {}, ...reasonOpts });
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: wireTools, stream: false, signal: o.signal, ...o.toolChoice ? { toolChoice: o.toolChoice } : {}, ...reasonOpts });
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;
@@ -7348,6 +7349,34 @@ function cursorProviderOptions(model, cwd, mcpServers) {
7348
7349
  if (!(model ?? "").startsWith("cursor/")) return void 0;
7349
7350
  return { cwd, ...toCursorMcp(mcpServers) ?? {}, ...process.env.CURSOR_WARM === "0" ? {} : { cursorSession: randomUUID() } };
7350
7351
  }
7352
+ function toClaudeCodeMcp(servers) {
7353
+ if (!servers) return void 0;
7354
+ const out = {};
7355
+ for (const [name, s] of Object.entries(servers)) {
7356
+ if (!s || s.disabled) continue;
7357
+ if (s.command) {
7358
+ out[name] = { type: "stdio", command: s.command, ...s.args ? { args: s.args } : {}, ...s.env ? { env: s.env } : {} };
7359
+ } else if (s.url) {
7360
+ if (s.auth === "oauth" && !s.bearerToken) continue;
7361
+ const headers = { ...s.headers ?? {}, ...s.bearerToken ? { Authorization: `Bearer ${s.bearerToken}` } : {} };
7362
+ out[name] = { type: "http", url: s.url, ...Object.keys(headers).length ? { headers } : {} };
7363
+ }
7364
+ }
7365
+ return Object.keys(out).length ? { mcpServers: out } : void 0;
7366
+ }
7367
+ function claudeCodeProviderOptions(model, cwd, mcpServers) {
7368
+ if (!(model ?? "").startsWith("claude-code/")) return void 0;
7369
+ const env = (() => {
7370
+ if (process.env.AGENTX_CC_USE_API_KEY) return void 0;
7371
+ const { ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ...rest } = process.env;
7372
+ return rest;
7373
+ })();
7374
+ const warm = process.env.AGENTX_CC_WARM === "0" ? {} : { claudeCodeSession: randomUUID() };
7375
+ return { cwd, ...env ? { env } : {}, ...warm, ...toClaudeCodeMcp(mcpServers) ?? {} };
7376
+ }
7377
+ function providerOptionsFor(model, cwd, mcpServers) {
7378
+ return cursorProviderOptions(model, cwd, mcpServers) ?? claudeCodeProviderOptions(model, cwd, mcpServers);
7379
+ }
7351
7380
  async function buildAgent(o) {
7352
7381
  if (typeof o.sandbox !== "boolean")
7353
7382
  throw new Error(
@@ -7360,9 +7389,11 @@ async function buildAgent(o) {
7360
7389
  jailedDisk.setCwd(cwd);
7361
7390
  const virtual = o.sandbox || !!o.boddb;
7362
7391
  const isCursor = (o.model ?? "").startsWith("cursor/");
7363
- if (virtual && isCursor)
7392
+ const isClaudeCode = (o.model ?? "").startsWith("claude-code/");
7393
+ const isDelegated = isCursor || isClaudeCode;
7394
+ if (virtual && isDelegated)
7364
7395
  throw new Error(
7365
- "cursor/* models cannot run in --sandbox/--boddb: the Cursor agent runs its own real-disk tools and bypasses the VFS jail. Use disk mode (default)."
7396
+ `${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
7397
  );
7367
7398
  let fs = jailedDisk;
7368
7399
  if (o.sandbox) {
@@ -7429,7 +7460,7 @@ Reference files in them by their mount path (the left side).`;
7429
7460
  const hooks = o.learnFromMistakes && memoryWriteDir ? composeHooks(o.hooks, lessonCapture({ fs, dir: memoryWriteDir, minRepeats: 2 })) : o.hooks;
7430
7461
  let realShell = [];
7431
7462
  const useRealShell = o.realShell ?? !virtual;
7432
- if (useRealShell && !virtual) {
7463
+ if (useRealShell && !virtual && !isClaudeCode) {
7433
7464
  const jobs = new ShellJobRegistry({ cwd, killOnExit: true, osSandbox: o.osSandbox });
7434
7465
  realShell = [makeRealShellTool({ cwd, registry: jobs, osSandbox: o.osSandbox }), ...makeShellJobTools(jobs)];
7435
7466
  }
@@ -7448,7 +7479,7 @@ Reference files in them by their mount path (the left side).`;
7448
7479
  // Warm cursor session (default on; CURSOR_WARM=0 to disable): one long-lived agent reused across
7449
7480
  // turns, amortising the ~2s Agent.create + h2 handshake. Keyed per agentx launch.
7450
7481
  ...(() => {
7451
- const po = cursorProviderOptions(o.model, cwd, o.mcpServers);
7482
+ const po = providerOptionsFor(o.model, cwd, o.mcpServers);
7452
7483
  return po ? { providerOptions: po } : {};
7453
7484
  })(),
7454
7485
  ...(() => {
@@ -7480,6 +7511,7 @@ The filesystem root '/' is the real machine root \u2014 you have full filesystem
7480
7511
  return { systemPrompt: basePrompt + "\n\n" + extra };
7481
7512
  })(),
7482
7513
  tools: (() => {
7514
+ if (isClaudeCode) return [];
7483
7515
  const requested = o.tools ?? DEFAULT_TOOLS;
7484
7516
  const base = toolsByName([...requested, ...autoWebTools()]);
7485
7517
  const tail = [...o.extraTools ?? []];
@@ -12050,7 +12082,7 @@ async function repl(args, ai, cfg, cwd) {
12050
12082
  ...args.voiceModel ?? cfg.reflexModel ? { reflexModel: resolveModelOrNewest(args.voiceModel ?? cfg.reflexModel) } : {},
12051
12083
  actModel: agent.options.model,
12052
12084
  actOptions: workerOptions,
12053
- providerOptionsFor: (m) => cursorProviderOptions(m, cwd, cfg.mcpServers),
12085
+ providerOptionsFor: (m) => providerOptionsFor(m, cwd, cfg.mcpServers),
12054
12086
  ...(args.thinkModel ?? cfg.thinkModel) !== void 0 ? { thinkModel: (args.thinkModel ?? cfg.thinkModel) === false ? false : resolveModelOrNewest(String(args.thinkModel ?? cfg.thinkModel)) } : {},
12055
12087
  host,
12056
12088
  ...args.voice ? { voiceStyle: "conversational", progressUpdates: true, askRelay: true, emotionTags: emotionsOn } : {},
@@ -12131,7 +12163,7 @@ async function repl(args, ai, cfg, cwd) {
12131
12163
  };
12132
12164
  const setModel = (m) => {
12133
12165
  work.model = m;
12134
- work.providerOptions = cursorProviderOptions(m, cwd, cfg.mcpServers);
12166
+ work.providerOptions = providerOptionsFor(m, cwd, cfg.mcpServers);
12135
12167
  if (dx) dx.options.actModel = m;
12136
12168
  persistModel(cwd, m);
12137
12169
  err(dim(" model \u2192 " + m + "\n"));
@@ -12211,6 +12243,10 @@ async function repl(args, ai, cfg, cwd) {
12211
12243
  disposeCursorSessions();
12212
12244
  } catch {
12213
12245
  }
12246
+ try {
12247
+ disposeClaudeCodeSessions();
12248
+ } catch {
12249
+ }
12214
12250
  void closeMcp(mounted);
12215
12251
  process.exit(code);
12216
12252
  };
@@ -13956,6 +13992,7 @@ ${out}
13956
13992
  voiceIO?.stop();
13957
13993
  releaseStdin();
13958
13994
  disposeCursorSessions();
13995
+ disposeClaudeCodeSessions();
13959
13996
  await closeMcp(mounted);
13960
13997
  process.exit(130);
13961
13998
  }
@@ -13965,6 +14002,7 @@ ${out}
13965
14002
  }
13966
14003
  releaseStdin();
13967
14004
  disposeCursorSessions();
14005
+ disposeClaudeCodeSessions();
13968
14006
  await closeMcp(mounted);
13969
14007
  }
13970
14008
  function readAllStdin() {