@livx.cc/agentx 0.99.1 → 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;
@@ -4676,7 +4677,21 @@ var EMOTIONS = [
4676
4677
  "confident",
4677
4678
  "skeptical",
4678
4679
  "contemplative",
4679
- "determined"
4680
+ "determined",
4681
+ // remaining sonic-3 vocabulary — without these a valid model tag would be DROPPED (flat delivery).
4682
+ "joking",
4683
+ "trust",
4684
+ "anticipation",
4685
+ "outraged",
4686
+ "threatened",
4687
+ "contempt",
4688
+ "envious",
4689
+ "dejected",
4690
+ "rejected",
4691
+ "wistful",
4692
+ "insecure",
4693
+ "resigned",
4694
+ "distant"
4680
4695
  ];
4681
4696
  var VALID = new Set(EMOTIONS);
4682
4697
  var ALIASES = {
@@ -4721,7 +4736,9 @@ var ALIASES = {
4721
4736
  peaceful: "calm",
4722
4737
  serene: "calm",
4723
4738
  relaxed: "calm",
4724
- sleepy: "tired"
4739
+ sleepy: "tired",
4740
+ comedic: "joking"
4741
+ // Cartesia lists "joking/comedic" as one — canonicalize to joking
4725
4742
  };
4726
4743
  var NONVERBAL = { laughter: "laughter", laughs: "laughter", laugh: "laughter", laughing: "laughter" };
4727
4744
  function normalizeEmotion(raw) {
@@ -7332,6 +7349,34 @@ function cursorProviderOptions(model, cwd, mcpServers) {
7332
7349
  if (!(model ?? "").startsWith("cursor/")) return void 0;
7333
7350
  return { cwd, ...toCursorMcp(mcpServers) ?? {}, ...process.env.CURSOR_WARM === "0" ? {} : { cursorSession: randomUUID() } };
7334
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
+ }
7335
7380
  async function buildAgent(o) {
7336
7381
  if (typeof o.sandbox !== "boolean")
7337
7382
  throw new Error(
@@ -7344,9 +7389,11 @@ async function buildAgent(o) {
7344
7389
  jailedDisk.setCwd(cwd);
7345
7390
  const virtual = o.sandbox || !!o.boddb;
7346
7391
  const isCursor = (o.model ?? "").startsWith("cursor/");
7347
- if (virtual && isCursor)
7392
+ const isClaudeCode = (o.model ?? "").startsWith("claude-code/");
7393
+ const isDelegated = isCursor || isClaudeCode;
7394
+ if (virtual && isDelegated)
7348
7395
  throw new Error(
7349
- "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).`
7350
7397
  );
7351
7398
  let fs = jailedDisk;
7352
7399
  if (o.sandbox) {
@@ -7413,7 +7460,7 @@ Reference files in them by their mount path (the left side).`;
7413
7460
  const hooks = o.learnFromMistakes && memoryWriteDir ? composeHooks(o.hooks, lessonCapture({ fs, dir: memoryWriteDir, minRepeats: 2 })) : o.hooks;
7414
7461
  let realShell = [];
7415
7462
  const useRealShell = o.realShell ?? !virtual;
7416
- if (useRealShell && !virtual) {
7463
+ if (useRealShell && !virtual && !isClaudeCode) {
7417
7464
  const jobs = new ShellJobRegistry({ cwd, killOnExit: true, osSandbox: o.osSandbox });
7418
7465
  realShell = [makeRealShellTool({ cwd, registry: jobs, osSandbox: o.osSandbox }), ...makeShellJobTools(jobs)];
7419
7466
  }
@@ -7432,7 +7479,7 @@ Reference files in them by their mount path (the left side).`;
7432
7479
  // Warm cursor session (default on; CURSOR_WARM=0 to disable): one long-lived agent reused across
7433
7480
  // turns, amortising the ~2s Agent.create + h2 handshake. Keyed per agentx launch.
7434
7481
  ...(() => {
7435
- const po = cursorProviderOptions(o.model, cwd, o.mcpServers);
7482
+ const po = providerOptionsFor(o.model, cwd, o.mcpServers);
7436
7483
  return po ? { providerOptions: po } : {};
7437
7484
  })(),
7438
7485
  ...(() => {
@@ -7464,6 +7511,7 @@ The filesystem root '/' is the real machine root \u2014 you have full filesystem
7464
7511
  return { systemPrompt: basePrompt + "\n\n" + extra };
7465
7512
  })(),
7466
7513
  tools: (() => {
7514
+ if (isClaudeCode) return [];
7467
7515
  const requested = o.tools ?? DEFAULT_TOOLS;
7468
7516
  const base = toolsByName([...requested, ...autoWebTools()]);
7469
7517
  const tail = [...o.extraTools ?? []];
@@ -12034,7 +12082,7 @@ async function repl(args, ai, cfg, cwd) {
12034
12082
  ...args.voiceModel ?? cfg.reflexModel ? { reflexModel: resolveModelOrNewest(args.voiceModel ?? cfg.reflexModel) } : {},
12035
12083
  actModel: agent.options.model,
12036
12084
  actOptions: workerOptions,
12037
- providerOptionsFor: (m) => cursorProviderOptions(m, cwd, cfg.mcpServers),
12085
+ providerOptionsFor: (m) => providerOptionsFor(m, cwd, cfg.mcpServers),
12038
12086
  ...(args.thinkModel ?? cfg.thinkModel) !== void 0 ? { thinkModel: (args.thinkModel ?? cfg.thinkModel) === false ? false : resolveModelOrNewest(String(args.thinkModel ?? cfg.thinkModel)) } : {},
12039
12087
  host,
12040
12088
  ...args.voice ? { voiceStyle: "conversational", progressUpdates: true, askRelay: true, emotionTags: emotionsOn } : {},
@@ -12115,7 +12163,7 @@ async function repl(args, ai, cfg, cwd) {
12115
12163
  };
12116
12164
  const setModel = (m) => {
12117
12165
  work.model = m;
12118
- work.providerOptions = cursorProviderOptions(m, cwd, cfg.mcpServers);
12166
+ work.providerOptions = providerOptionsFor(m, cwd, cfg.mcpServers);
12119
12167
  if (dx) dx.options.actModel = m;
12120
12168
  persistModel(cwd, m);
12121
12169
  err(dim(" model \u2192 " + m + "\n"));
@@ -12195,6 +12243,10 @@ async function repl(args, ai, cfg, cwd) {
12195
12243
  disposeCursorSessions();
12196
12244
  } catch {
12197
12245
  }
12246
+ try {
12247
+ disposeClaudeCodeSessions();
12248
+ } catch {
12249
+ }
12198
12250
  void closeMcp(mounted);
12199
12251
  process.exit(code);
12200
12252
  };
@@ -13940,6 +13992,7 @@ ${out}
13940
13992
  voiceIO?.stop();
13941
13993
  releaseStdin();
13942
13994
  disposeCursorSessions();
13995
+ disposeClaudeCodeSessions();
13943
13996
  await closeMcp(mounted);
13944
13997
  process.exit(130);
13945
13998
  }
@@ -13949,6 +14002,7 @@ ${out}
13949
14002
  }
13950
14003
  releaseStdin();
13951
14004
  disposeCursorSessions();
14005
+ disposeClaudeCodeSessions();
13952
14006
  await closeMcp(mounted);
13953
14007
  }
13954
14008
  function readAllStdin() {