langchain_agentx_stream_ui 0.3.0 → 0.3.2

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,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { b as ToolDisplayProps, T as ToolBodyComponent } from './types-BEXSHQG7.js';
3
- import { T as ToolDisplayRegistry } from './sessionViewOptions-WM00Fpcn.js';
3
+ import { T as ToolDisplayRegistry } from './sessionViewOptions-DQRzPuN_.js';
4
4
 
5
5
  declare function DefaultToolBody({ result, bodyMode, onBodyModeChange, }: ToolDisplayProps): react_jsx_runtime.JSX.Element;
6
6
 
@@ -12,8 +12,10 @@ import {
12
12
  Write,
13
13
  coerceSubagentProgressEntries,
14
14
  createDefaultToolRegistry,
15
- extractLastToolInfoFromProgress
16
- } from "./chunk-7CLAU74Y.js";
15
+ extractLastToolInfoFromProgress,
16
+ formatExploreSummaryText,
17
+ formatThoughtDurationPrefix
18
+ } from "./chunk-FL2G7SV3.js";
17
19
 
18
20
  // src/types/tree.ts
19
21
  function createEmptyTree() {
@@ -149,7 +151,7 @@ function flushDeferredMainText(buffer) {
149
151
  }
150
152
 
151
153
  // src/core/eventVisibility.ts
152
- var SUBAGENT_LEAK_FOLD_TOOLS = /* @__PURE__ */ new Set(["Bash", "Read", "Glob", "Grep"]);
154
+ var SUBAGENT_LEAK_FOLD_TOOLS = /* @__PURE__ */ new Set(["Bash", "Read", "Glob", "Grep", "Write", "Edit"]);
153
155
  function isSubagentLeakFoldToolName(toolName) {
154
156
  return SUBAGENT_LEAK_FOLD_TOOLS.has(toolName);
155
157
  }
@@ -1004,7 +1006,31 @@ function resolveSubagentToolLeak(tree, data, toolName, existing) {
1004
1006
  runningAgentParentCallIds: getRunningAgentParentCallIds(tree)
1005
1007
  });
1006
1008
  }
1007
- function handleToolCall(tree, event, seq) {
1009
+ function maybeSynthesizeLeakedToolProgress(tree, options, params) {
1010
+ if (!options?.subagentLeakGate || !params.isSubagentLeak) return;
1011
+ if (typeof params.data.agent_id === "string" && params.data.agent_id.trim()) return;
1012
+ if (resolveParentAgentToolCallId(params.data) != null) return;
1013
+ const runningIds = getRunningAgentParentCallIds(tree);
1014
+ if (runningIds.length === 0) return;
1015
+ const parentCallId = runningIds[runningIds.length - 1];
1016
+ const parent = findAgentToolCallNodeByCallId(tree, parentCallId);
1017
+ if (!parent) return;
1018
+ const progress = parent.subagentProgress ?? [];
1019
+ const step = progress.length === 0 ? 1 : Math.max(...progress.map((entry) => entry.step)) + 1;
1020
+ const toolCallId = typeof params.data.tool_call_id === "string" ? params.data.tool_call_id.trim() : "";
1021
+ const toolInput = params.data.input ?? (typeof params.data.tool_input === "object" ? params.data.tool_input : void 0);
1022
+ patchToolNode(tree, parent.id, {
1023
+ subagentProgress: applySubagentToolCall(progress, {
1024
+ agentId: "leak-synthesized",
1025
+ step,
1026
+ toolName: params.toolName,
1027
+ summary: `calling ${params.toolName}`,
1028
+ toolInput,
1029
+ childToolCallId: toolCallId || void 0
1030
+ })
1031
+ });
1032
+ }
1033
+ function handleToolCall(tree, event, seq, options) {
1008
1034
  const id = toolNodeId(tree, event);
1009
1035
  const data = event.data;
1010
1036
  const existing = tree.byId[id];
@@ -1026,6 +1052,11 @@ function handleToolCall(tree, event, seq) {
1026
1052
  seq,
1027
1053
  mountMain
1028
1054
  );
1055
+ maybeSynthesizeLeakedToolProgress(tree, options, {
1056
+ isSubagentLeak,
1057
+ data: dataRecord,
1058
+ toolName
1059
+ });
1029
1060
  }
1030
1061
  function resolveToolName(event, data, existing) {
1031
1062
  return event.tool_name ?? data.tool_name ?? existing?.toolName ?? "unknown";
@@ -1098,12 +1129,14 @@ function handleToolError(tree, event, seq) {
1098
1129
  function handleToolProgress(tree, event, parentNodeId, _seq) {
1099
1130
  const data = event.data;
1100
1131
  if (typeof data.agent_id === "string" && data.agent_id.length > 0) {
1101
- const nested = data.data && typeof data.data === "object" ? data.data : {};
1132
+ const nestedRaw = data.data;
1133
+ const nested = nestedRaw != null && typeof nestedRaw === "object" && !Array.isArray(nestedRaw) ? nestedRaw : {};
1102
1134
  const stepRaw = data.step ?? nested.step ?? 0;
1103
1135
  const step = typeof stepRaw === "number" ? stepRaw : 0;
1104
1136
  const summary = (typeof data.summary === "string" ? data.summary : "") || (typeof nested.summary === "string" ? nested.summary : "");
1105
1137
  const toolName = String(data.tool_name ?? nested.tool_name ?? "");
1106
1138
  const subagentType = typeof nested.subagent_type === "string" ? nested.subagent_type : void 0;
1139
+ const toolInput = data.tool_input ?? nested.tool_input ?? data.input ?? nested.input;
1107
1140
  const toolCallId = typeof data.tool_call_id === "string" && data.tool_call_id || (parentNodeId?.startsWith("tool:") ? parentNodeId.slice("tool:".length) : "");
1108
1141
  if (!toolCallId) return;
1109
1142
  if (data.phase === "tool_use") {
@@ -1113,7 +1146,8 @@ function handleToolProgress(tree, event, parentNodeId, _seq) {
1113
1146
  subagent_type: subagentType,
1114
1147
  step,
1115
1148
  tool_name: toolName,
1116
- summary: summary || (toolName ? `calling ${toolName}` : "")
1149
+ summary: summary || (toolName ? `calling ${toolName}` : ""),
1150
+ tool_input: toolInput
1117
1151
  });
1118
1152
  } else if (data.phase === "tool_result") {
1119
1153
  handleSubagentToolResult(tree, event, parentNodeId, {
@@ -1516,7 +1550,7 @@ function applyClassified(tree, classified, eventIndex, options) {
1516
1550
  break;
1517
1551
  case "tool-call":
1518
1552
  if (isDroppedByEmitterRoute(event.data)) break;
1519
- handleToolCall(tree, event, seq);
1553
+ handleToolCall(tree, event, seq, options);
1520
1554
  break;
1521
1555
  case "tool-result":
1522
1556
  if (isDroppedByEmitterRoute(event.data)) break;
@@ -1605,10 +1639,13 @@ function getChildIds(tree, parentId) {
1605
1639
 
1606
1640
  // src/core/replay.ts
1607
1641
  function toReduceOptions(options) {
1608
- if (!options?.tierOverrides && !options?.collectDebug) return void 0;
1642
+ if (!options?.tierOverrides && !options?.collectDebug && options?.subagentLeakGate !== true) {
1643
+ return void 0;
1644
+ }
1609
1645
  return {
1610
1646
  tierOverrides: options.tierOverrides,
1611
- collectDebug: options.collectDebug
1647
+ collectDebug: options.collectDebug,
1648
+ subagentLeakGate: options.subagentLeakGate
1612
1649
  };
1613
1650
  }
1614
1651
  function replayEvents(events, options) {
@@ -1695,7 +1732,8 @@ var DEFAULT_SESSION_VIEW_OPTIONS = {
1695
1732
  verbose: false,
1696
1733
  exploreFullscreenBash: true,
1697
1734
  memoryDir: null,
1698
- workspaceRoot: null
1735
+ workspaceRoot: null,
1736
+ subagentLeakGate: false
1699
1737
  };
1700
1738
  function buildProjectionViewContext(options = DEFAULT_SESSION_VIEW_OPTIONS) {
1701
1739
  return {
@@ -2309,188 +2347,6 @@ function summarizeSystemEvents(events) {
2309
2347
  return mergeSystemSummaryLines(lines);
2310
2348
  }
2311
2349
 
2312
- // src/core/projection/exploreSummary.ts
2313
- function memoryReadTotal(counts) {
2314
- if (counts.memoryReadCount === 0 && counts.relevantRecallCount > 0) {
2315
- return counts.relevantRecallCount;
2316
- }
2317
- return counts.memoryReadCount;
2318
- }
2319
- function tenseVerb(options) {
2320
- if (options.active) {
2321
- return options.isFirst ? options.presentCap : options.presentLower;
2322
- }
2323
- return options.isFirst ? options.pastCap : options.pastLower;
2324
- }
2325
- function exploreSummaryParts(counts, active, continuingSentence = false) {
2326
- const parts = [];
2327
- let isFirst = !continuingSentence;
2328
- const memRead = memoryReadTotal(counts);
2329
- if (memRead > 0) {
2330
- parts.push({
2331
- verb: tenseVerb({
2332
- active,
2333
- isFirst,
2334
- presentCap: "Recalling",
2335
- presentLower: "recalling",
2336
- pastCap: "Recalled",
2337
- pastLower: "recalled"
2338
- }),
2339
- count: memRead,
2340
- suffix: memRead === 1 ? "memory" : "memories"
2341
- });
2342
- isFirst = false;
2343
- }
2344
- if (counts.memorySearchCount > 0) {
2345
- parts.push({
2346
- verb: tenseVerb({
2347
- active,
2348
- isFirst,
2349
- presentCap: "Searching",
2350
- presentLower: "searching",
2351
- pastCap: "Searched",
2352
- pastLower: "searched"
2353
- }),
2354
- count: null,
2355
- suffix: "memories"
2356
- });
2357
- isFirst = false;
2358
- }
2359
- if (counts.memoryWriteCount > 0) {
2360
- parts.push({
2361
- verb: tenseVerb({
2362
- active,
2363
- isFirst,
2364
- presentCap: "Writing",
2365
- presentLower: "writing",
2366
- pastCap: "Wrote",
2367
- pastLower: "wrote"
2368
- }),
2369
- count: counts.memoryWriteCount,
2370
- suffix: counts.memoryWriteCount === 1 ? "memory" : "memories"
2371
- });
2372
- isFirst = false;
2373
- }
2374
- if (counts.searchCount > 0) {
2375
- parts.push({
2376
- verb: tenseVerb({
2377
- active,
2378
- isFirst,
2379
- presentCap: "Searching for",
2380
- presentLower: "searching for",
2381
- pastCap: "Searched for",
2382
- pastLower: "searched for"
2383
- }),
2384
- count: counts.searchCount,
2385
- suffix: counts.searchCount === 1 ? "pattern" : "patterns"
2386
- });
2387
- isFirst = false;
2388
- }
2389
- if (counts.readCount > 0) {
2390
- parts.push({
2391
- verb: tenseVerb({
2392
- active,
2393
- isFirst,
2394
- presentCap: "Reading",
2395
- presentLower: "reading",
2396
- pastCap: "Read",
2397
- pastLower: "read"
2398
- }),
2399
- count: counts.readCount,
2400
- suffix: counts.readCount === 1 ? "file" : "files"
2401
- });
2402
- isFirst = false;
2403
- }
2404
- if (counts.listCount > 0) {
2405
- parts.push({
2406
- verb: tenseVerb({
2407
- active,
2408
- isFirst,
2409
- presentCap: "Listing",
2410
- presentLower: "listing",
2411
- pastCap: "Listed",
2412
- pastLower: "listed"
2413
- }),
2414
- count: counts.listCount,
2415
- suffix: counts.listCount === 1 ? "directory" : "directories"
2416
- });
2417
- isFirst = false;
2418
- }
2419
- if (counts.bashCount > 0) {
2420
- parts.push({
2421
- verb: tenseVerb({
2422
- active,
2423
- isFirst,
2424
- presentCap: "Running",
2425
- presentLower: "running",
2426
- pastCap: "Ran",
2427
- pastLower: "ran"
2428
- }),
2429
- count: counts.bashCount,
2430
- suffix: counts.bashCount === 1 ? "bash command" : "bash commands"
2431
- });
2432
- isFirst = false;
2433
- }
2434
- if (counts.gitOpBashCount > 0) {
2435
- parts.push({
2436
- verb: tenseVerb({
2437
- active,
2438
- isFirst,
2439
- presentCap: "Running",
2440
- presentLower: "running",
2441
- pastCap: "Ran",
2442
- pastLower: "ran"
2443
- }),
2444
- count: counts.gitOpBashCount,
2445
- suffix: counts.gitOpBashCount === 1 ? "git command" : "git commands"
2446
- });
2447
- isFirst = false;
2448
- }
2449
- if (counts.mcpCallCount > 0) {
2450
- parts.push({
2451
- verb: tenseVerb({
2452
- active,
2453
- isFirst,
2454
- presentCap: "Querying",
2455
- presentLower: "querying",
2456
- pastCap: "Queried",
2457
- pastLower: "queried"
2458
- }),
2459
- count: counts.mcpCallCount,
2460
- suffix: counts.mcpCallCount === 1 ? "MCP tool" : "MCP tools"
2461
- });
2462
- isFirst = false;
2463
- }
2464
- return parts;
2465
- }
2466
- function partPlainText(part) {
2467
- if (part.count !== null) {
2468
- return `${part.verb} ${part.count} ${part.suffix}`.trim();
2469
- }
2470
- return `${part.verb} ${part.suffix}`.trim();
2471
- }
2472
- function formatExploreSummaryText(counts, options = { active: false }) {
2473
- const parts = exploreSummaryParts(
2474
- counts,
2475
- options.active,
2476
- options.continuingSentence ?? false
2477
- );
2478
- if (parts.length === 0) return null;
2479
- const joiner = options.joiner ?? ", ";
2480
- let text = parts.map(partPlainText).join(joiner);
2481
- if (options.active) {
2482
- text = `${text}\u2026`;
2483
- }
2484
- if (options.prefix) {
2485
- text = options.prefix + text;
2486
- }
2487
- return text;
2488
- }
2489
- function formatThoughtDurationPrefix(seconds) {
2490
- const rounded = Math.max(1, Math.round(seconds));
2491
- return `Thought for ${rounded}s, `;
2492
- }
2493
-
2494
2350
  // src/core/projection/shellProgress.ts
2495
2351
  var SHELL_PROGRESS_MIN_ELAPSED_SECONDS = 2;
2496
2352
  function formatDuration(totalSeconds) {
@@ -5603,7 +5459,6 @@ export {
5603
5459
  entryKey,
5604
5460
  iterMountCandidates,
5605
5461
  formatHookFinishedSummary,
5606
- formatExploreSummaryText,
5607
5462
  SHELL_PROGRESS_MIN_ELAPSED_SECONDS,
5608
5463
  formatShellProgressSuffix,
5609
5464
  resolveShellProgressFromPayload,
@@ -5643,4 +5498,4 @@ export {
5643
5498
  VirtualTimeline,
5644
5499
  SessionTimeline
5645
5500
  };
5646
- //# sourceMappingURL=chunk-SUEMZC4U.js.map
5501
+ //# sourceMappingURL=chunk-6ORA5RMV.js.map