@livx.cc/agentx 0.99.21 → 0.99.23

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.
@@ -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, U as UserQuestion } from './tools-ClgFZjUr.js';
2
+ import { M as Message, H as HostBridge, A as AgentTool, C as ChatLike, e as MessageContent, U as UserQuestion } from './tools-hAKTlzty.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-CM7HL95r.js';
2
+ import { H as Hooks, h as RunResult, R as ReasoningEffort, A as Agent } from './Agent-CSCWkq0C.js';
3
3
  import { IFilesystem } from '@livx.cc/wcli/core';
4
- import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, e as MessageContent } from './tools-ClgFZjUr.js';
4
+ import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, e as MessageContent } from './tools-hAKTlzty.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
@@ -3716,8 +3716,33 @@ var Agent = class _Agent {
3716
3716
  usage.cacheCreationTokens += res.usage.cacheCreationTokens ?? 0;
3717
3717
  usage.cacheReadTokens += res.usage.cacheReadTokens ?? 0;
3718
3718
  }
3719
+ const delegatedTools = res.delegatedTools ?? [];
3720
+ if (delegatedTools.length) {
3721
+ const cap = this.options.maxToolResultBytes ?? 0;
3722
+ this.transcript.push({
3723
+ role: "assistant",
3724
+ content: "",
3725
+ tool_calls: delegatedTools.map((a) => ({ id: a.id, type: "function", function: { name: a.name || "tool", arguments: (() => {
3726
+ try {
3727
+ return JSON.stringify(a.input ?? {});
3728
+ } catch {
3729
+ return "{}";
3730
+ }
3731
+ })() } }))
3732
+ });
3733
+ for (const a of delegatedTools) {
3734
+ const out = typeof a.output === "string" ? a.output : a.output == null ? "" : (() => {
3735
+ try {
3736
+ return JSON.stringify(a.output);
3737
+ } catch {
3738
+ return String(a.output);
3739
+ }
3740
+ })();
3741
+ this.transcript.push({ role: "tool", tool_call_id: a.id, content: cap > 0 && out.length > cap ? cropResult(out, cap) : out });
3742
+ }
3743
+ }
3719
3744
  const toolCalls = res.toolCalls ?? [];
3720
- const emptyTurn = toolCalls.length === 0 && contentText(res.content ?? "").trim() === "";
3745
+ const emptyTurn = toolCalls.length === 0 && delegatedTools.length === 0 && contentText(res.content ?? "").trim() === "";
3721
3746
  if (!emptyTurn) {
3722
3747
  this.transcript.push({
3723
3748
  role: "assistant",
@@ -3816,6 +3841,8 @@ var Agent = class _Agent {
3816
3841
  let finishReason;
3817
3842
  let toolCalls;
3818
3843
  let usage;
3844
+ const delegated = /* @__PURE__ */ new Map();
3845
+ const delegatedOrder = [];
3819
3846
  for await (const chunk of stream) {
3820
3847
  poke?.();
3821
3848
  if (this.options.signal?.aborted) break;
@@ -3824,6 +3851,17 @@ var Agent = class _Agent {
3824
3851
  const a = chunk.toolActivity;
3825
3852
  const verb = a.status === "error" ? "\u2717" : a.status === "completed" ? "\u2713" : "\u2192";
3826
3853
  this.options.host.notify({ kind: "tool_activity", id: a.id, name: a.name, input: a.input, output: a.output, status: a.status, truncated: a.truncated, message: `${verb} ${a.name}` });
3854
+ const key = a.id ?? `${a.name}:${delegatedOrder.length}`;
3855
+ const prev = delegated.get(key);
3856
+ if (!prev) {
3857
+ delegated.set(key, { id: key, name: a.name, input: a.input, output: a.output, status: a.status });
3858
+ delegatedOrder.push(key);
3859
+ } else {
3860
+ if (a.name) prev.name = a.name;
3861
+ if (a.input !== void 0) prev.input = a.input;
3862
+ if (a.output !== void 0) prev.output = a.output;
3863
+ prev.status = a.status;
3864
+ }
3827
3865
  }
3828
3866
  if (chunk.content) {
3829
3867
  content += chunk.content;
@@ -3833,7 +3871,8 @@ var Agent = class _Agent {
3833
3871
  if (chunk.toolCalls?.length) toolCalls = chunk.toolCalls;
3834
3872
  if (chunk.usage) usage = chunk.usage;
3835
3873
  }
3836
- return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {} };
3874
+ const delegatedTools = delegatedOrder.map((k) => delegated.get(k));
3875
+ return { content, ...finishReason ? { finishReason } : {}, ...toolCalls ? { toolCalls } : {}, ...usage ? { usage } : {}, ...delegatedTools.length ? { delegatedTools } : {} };
3837
3876
  }
3838
3877
  async dispatch(tc) {
3839
3878
  const tool = this.activeTools.find((t) => t.name === tc.function.name);
@@ -13051,7 +13090,8 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
13051
13090
  const m = res.usageEstimated ? "~" : "";
13052
13091
  const tok = res.usage?.totalTokens ? `${m}${(res.usage.totalTokens / 1e3).toFixed(1)}k tok \xB7 ${cost > 0 ? m + fmtUsd(cost) + " \xB7 " : ""}` : "";
13053
13092
  const lastUser = res.messages.map((m2) => m2.role).lastIndexOf("user");
13054
- const tools = res.messages.slice(lastUser).filter((m2) => m2.role === "tool").length + (agent.options.host?.takeToolCount?.() ?? 0);
13093
+ agent.options.host?.takeToolCount?.();
13094
+ const tools = res.messages.slice(lastUser).filter((m2) => m2.role === "tool").length;
13055
13095
  const ok = res.finishReason === "stop";
13056
13096
  const shortId = session.meta.id.replace(/^\d{8}-/, "");
13057
13097
  const didWork = agent.transcript.slice(msgsBefore).some((m2) => m2.role === "assistant" || m2.role === "tool");