langchain_agentx_stream_ui 0.6.2 → 0.6.8
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/{AskUserQuestionToolBody-J8MqSUEs.d.ts → AskUserQuestionToolBody-CutLY-dS.d.ts} +2 -2
- package/dist/{MarkdownBlock-DeICJUtu.d.ts → MarkdownBlock-Hf-kcLh6.d.ts} +1 -1
- package/dist/{chunk-DP7V33X7.js → chunk-6Z4ZF36Z.js} +1 -1
- package/dist/chunk-6Z4ZF36Z.js.map +1 -0
- package/dist/{chunk-ZR37OKV6.js → chunk-7XSQYG3X.js} +6 -5
- package/dist/chunk-7XSQYG3X.js.map +1 -0
- package/dist/{chunk-4TG4TGIL.js → chunk-B2NG5KGH.js} +4 -4
- package/dist/chunk-B2NG5KGH.js.map +1 -0
- package/dist/{chunk-4RIOBLGB.js → chunk-GBY5DJ7L.js} +1 -1
- package/dist/chunk-GBY5DJ7L.js.map +1 -0
- package/dist/{chunk-DJPNJBFL.js → chunk-UBYOUDQE.js} +204 -9
- package/dist/chunk-UBYOUDQE.js.map +1 -0
- package/dist/{chunk-ED67MXSG.js → chunk-VBUKRPEO.js} +19 -9
- package/dist/chunk-VBUKRPEO.js.map +1 -0
- package/dist/default.css +12 -0
- package/dist/index.d.ts +45 -16
- package/dist/index.js +418 -92
- package/dist/index.js.map +1 -1
- package/dist/{multi-session-B7kIVfyG.d.ts → multi-session-t7dWsecW.d.ts} +32 -3
- package/dist/multi-session.d.ts +4 -4
- package/dist/multi-session.js +6 -6
- package/dist/{nodes-7_0rCAc4.d.ts → nodes-C2rGC3J7.d.ts} +5 -0
- package/dist/{sessionViewOptions-EIBugOkf.d.ts → sessionViewOptions-2Hv9BGeg.d.ts} +1 -1
- package/dist/tools-presentation.d.ts +3 -3
- package/dist/tools-presentation.js +2 -2
- package/dist/tools.d.ts +5 -5
- package/dist/tools.js +4 -4
- package/dist/{types-DAkw2VOv.d.ts → types-kH4WQSM2.d.ts} +1 -1
- package/dist/virtual.d.ts +1 -1
- package/dist/virtual.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-4RIOBLGB.js.map +0 -1
- package/dist/chunk-4TG4TGIL.js.map +0 -1
- package/dist/chunk-DJPNJBFL.js.map +0 -1
- package/dist/chunk-DP7V33X7.js.map +0 -1
- package/dist/chunk-ED67MXSG.js.map +0 -1
- package/dist/chunk-ZR37OKV6.js.map +0 -1
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
extractLastToolInfoFromProgress,
|
|
16
16
|
formatExploreSummaryText,
|
|
17
17
|
formatThoughtDurationPrefix
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7XSQYG3X.js";
|
|
19
19
|
|
|
20
20
|
// src/types/tree.ts
|
|
21
21
|
function createEmptyTree() {
|
|
@@ -85,6 +85,8 @@ var DEFAULT_EVENT_TIERS = {
|
|
|
85
85
|
"task-progress": "debug",
|
|
86
86
|
"task-notification-enqueued": "debug",
|
|
87
87
|
"task-notification-consumed": "debug",
|
|
88
|
+
/** 与 subagent-end 同级 collapsed(不可当可丢 debug) */
|
|
89
|
+
"task-notification": "collapsed",
|
|
88
90
|
"task-terminated": "debug",
|
|
89
91
|
"task-list-snapshot": "state",
|
|
90
92
|
error: "main",
|
|
@@ -113,7 +115,7 @@ function resolveToolParentId(event, ctx, eventIndex) {
|
|
|
113
115
|
return toolNodeIdFromEvent(event, eventIndex);
|
|
114
116
|
}
|
|
115
117
|
function isSubagentFoldEvent(event) {
|
|
116
|
-
if (event.event_type === "subagent-start" || event.event_type === "subagent-end" || event.event_type === "subagent-tool-call" || event.event_type === "subagent-tool-result" || event.event_type === "subagent-transcript-message" || event.event_type === "subagent-model-step") {
|
|
118
|
+
if (event.event_type === "subagent-start" || event.event_type === "subagent-end" || event.event_type === "subagent-tool-call" || event.event_type === "subagent-tool-result" || event.event_type === "subagent-transcript-message" || event.event_type === "subagent-model-step" || event.event_type === "task-notification") {
|
|
117
119
|
return true;
|
|
118
120
|
}
|
|
119
121
|
if (event.event_type === "tool-progress") {
|
|
@@ -124,7 +126,12 @@ function isSubagentFoldEvent(event) {
|
|
|
124
126
|
}
|
|
125
127
|
function resolveAgentToolParentId(event) {
|
|
126
128
|
const data = event.data;
|
|
127
|
-
if (data.tool_call_id
|
|
129
|
+
if (typeof data.tool_call_id === "string" && data.tool_call_id) {
|
|
130
|
+
return `tool:${data.tool_call_id}`;
|
|
131
|
+
}
|
|
132
|
+
if (typeof data.tool_use_id === "string" && data.tool_use_id) {
|
|
133
|
+
return `tool:${data.tool_use_id}`;
|
|
134
|
+
}
|
|
128
135
|
return void 0;
|
|
129
136
|
}
|
|
130
137
|
function classifyEvent(event, ctx, overrides, eventIndex = 0) {
|
|
@@ -525,6 +532,150 @@ function formatModelRetryCategoryLabel(category) {
|
|
|
525
532
|
}
|
|
526
533
|
}
|
|
527
534
|
|
|
535
|
+
// src/core/finishCancel.ts
|
|
536
|
+
var DEFAULT_DISPLAY_INTERRUPT_TEXT = "[Request interrupted by user]";
|
|
537
|
+
var USER_CANCEL_TERMINAL_REASONS = /* @__PURE__ */ new Set([
|
|
538
|
+
"aborted_streaming",
|
|
539
|
+
"aborted_tools"
|
|
540
|
+
]);
|
|
541
|
+
function isUserCancelledFinish(data) {
|
|
542
|
+
if (data.error_kind === "hook_stopped") return false;
|
|
543
|
+
if (data.error_kind === "user_cancelled") return true;
|
|
544
|
+
const reason = typeof data.terminal_reason === "string" ? data.terminal_reason : "";
|
|
545
|
+
if (USER_CANCEL_TERMINAL_REASONS.has(reason)) return true;
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
function isHookStoppedFinish(data) {
|
|
549
|
+
return data.error_kind === "hook_stopped";
|
|
550
|
+
}
|
|
551
|
+
function classifyFinishErrorPresentation(data) {
|
|
552
|
+
if (isHookStoppedFinish(data)) return "hook_stopped";
|
|
553
|
+
if (isUserCancelledFinish(data)) return "interrupt";
|
|
554
|
+
return "error";
|
|
555
|
+
}
|
|
556
|
+
function resolveInterruptDisplayText(data) {
|
|
557
|
+
if (typeof data.display_interrupt_text === "string" && data.display_interrupt_text.trim()) {
|
|
558
|
+
return data.display_interrupt_text.trim();
|
|
559
|
+
}
|
|
560
|
+
return DEFAULT_DISPLAY_INTERRUPT_TEXT;
|
|
561
|
+
}
|
|
562
|
+
function resolveHookStoppedMessage(data) {
|
|
563
|
+
if (Array.isArray(data.errors) && data.errors.length > 0) {
|
|
564
|
+
return data.errors.map(String).join("\n");
|
|
565
|
+
}
|
|
566
|
+
return "Stopped by hook";
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// src/core/taskNotification.ts
|
|
570
|
+
function trimStr(value) {
|
|
571
|
+
return typeof value === "string" ? value.trim() : "";
|
|
572
|
+
}
|
|
573
|
+
function markTaskNotificationClosed(tree, taskId) {
|
|
574
|
+
tree.meta.taskNotificationClosedIds = {
|
|
575
|
+
...tree.meta.taskNotificationClosedIds ?? {},
|
|
576
|
+
[taskId]: true
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function isTaskNotificationClosed(tree, taskId) {
|
|
580
|
+
return tree.meta.taskNotificationClosedIds?.[taskId] === true;
|
|
581
|
+
}
|
|
582
|
+
function findTaskNotificationTarget(tree, data) {
|
|
583
|
+
const toolUseId = trimStr(data.tool_use_id);
|
|
584
|
+
const agentId = trimStr(data.agent_id);
|
|
585
|
+
const taskId = trimStr(data.task_id);
|
|
586
|
+
if (toolUseId) {
|
|
587
|
+
const byTool = findAgentToolCallNodeByCallId(tree, toolUseId);
|
|
588
|
+
if (byTool) {
|
|
589
|
+
return { nodeId: byTool.id, agentId: agentId || taskId || null };
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const sessionKey = agentId || taskId;
|
|
593
|
+
if (sessionKey) {
|
|
594
|
+
for (const node of Object.values(tree.byId)) {
|
|
595
|
+
if (node?.kind !== "tool_call" || node.toolName !== "Agent") continue;
|
|
596
|
+
if (node.subagentSessions?.[sessionKey]) {
|
|
597
|
+
return { nodeId: node.id, agentId: sessionKey };
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
if (taskId) {
|
|
602
|
+
const byTaskAsCall = findAgentToolCallNodeByCallId(tree, taskId);
|
|
603
|
+
if (byTaskAsCall) {
|
|
604
|
+
return { nodeId: byTaskAsCall.id, agentId: agentId || null };
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
function finalizeRunningProgressForAgent(tool, agentId, terminal) {
|
|
610
|
+
const progress = tool.subagentProgress;
|
|
611
|
+
if (!progress?.length || !agentId) return progress;
|
|
612
|
+
return progress.map(
|
|
613
|
+
(entry) => entry.agentId === agentId && entry.status === "running" ? { ...entry, status: terminal } : entry
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
function hasRunningSession(sessions) {
|
|
617
|
+
return Object.values(sessions).some((marker) => marker.status === "running");
|
|
618
|
+
}
|
|
619
|
+
function applyTaskNotification(tree, data, endedAt) {
|
|
620
|
+
const taskId = trimStr(data.task_id);
|
|
621
|
+
if (!taskId) return false;
|
|
622
|
+
if (isTaskNotificationClosed(tree, taskId)) return false;
|
|
623
|
+
const status = data.status;
|
|
624
|
+
if (status !== "stopped" && status !== "completed" && status !== "failed") {
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
const target = findTaskNotificationTarget(tree, data);
|
|
628
|
+
if (!target) return false;
|
|
629
|
+
const tool = tree.byId[target.nodeId];
|
|
630
|
+
if (!tool || tool.kind !== "tool_call") return false;
|
|
631
|
+
const agentKey = target.agentId;
|
|
632
|
+
let nextSessions = tool.subagentSessions ?? {};
|
|
633
|
+
let sessionChanged = false;
|
|
634
|
+
if (agentKey) {
|
|
635
|
+
const existing = nextSessions[agentKey];
|
|
636
|
+
if (!existing || existing.status === "running") {
|
|
637
|
+
nextSessions = upsertSubagentSession(nextSessions, {
|
|
638
|
+
agentId: agentKey,
|
|
639
|
+
subagentType: existing?.subagentType,
|
|
640
|
+
status: "done",
|
|
641
|
+
startedAt: existing?.startedAt ?? endedAt,
|
|
642
|
+
endedAt
|
|
643
|
+
});
|
|
644
|
+
sessionChanged = true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const progressTerminal = status === "completed" ? "completed" : "error";
|
|
648
|
+
const hasRunningProgress = !!agentKey && !!tool.subagentProgress?.some(
|
|
649
|
+
(entry) => entry.agentId === agentKey && entry.status === "running"
|
|
650
|
+
);
|
|
651
|
+
const nextProgress = hasRunningProgress ? finalizeRunningProgressForAgent(tool, agentKey, progressTerminal) : tool.subagentProgress;
|
|
652
|
+
const progressChanged = nextProgress !== tool.subagentProgress;
|
|
653
|
+
let nextToolStatus = tool.status;
|
|
654
|
+
let nextEndedAt = tool.endedAt;
|
|
655
|
+
let toolStatusChanged = false;
|
|
656
|
+
if (tool.status === "running") {
|
|
657
|
+
const shouldCloseParent = !agentKey || !hasRunningSession(nextSessions);
|
|
658
|
+
if (shouldCloseParent) {
|
|
659
|
+
nextToolStatus = status === "completed" ? "done" : "failed";
|
|
660
|
+
nextEndedAt = endedAt;
|
|
661
|
+
toolStatusChanged = true;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (!sessionChanged && !progressChanged && !toolStatusChanged) {
|
|
665
|
+
markTaskNotificationClosed(tree, taskId);
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
tree.byId[target.nodeId] = {
|
|
669
|
+
...tool,
|
|
670
|
+
status: nextToolStatus,
|
|
671
|
+
endedAt: nextEndedAt,
|
|
672
|
+
subagentSessions: nextSessions,
|
|
673
|
+
subagentProgress: nextProgress
|
|
674
|
+
};
|
|
675
|
+
markTaskNotificationClosed(tree, taskId);
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
|
|
528
679
|
// src/core/reducer.ts
|
|
529
680
|
function isInternalTool(toolName) {
|
|
530
681
|
return INTERNAL_TOOL_NAMES.has(toolName);
|
|
@@ -722,17 +873,34 @@ function resolveFinishErrorMessage(data) {
|
|
|
722
873
|
return "Agent finished with an error";
|
|
723
874
|
}
|
|
724
875
|
function appendFinishErrorNode(tree, event, data, seq) {
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
876
|
+
const presentation = classifyFinishErrorPresentation(data);
|
|
877
|
+
let message;
|
|
878
|
+
let type;
|
|
879
|
+
let variant = "error";
|
|
880
|
+
if (presentation === "interrupt") {
|
|
881
|
+
message = resolveInterruptDisplayText(data);
|
|
882
|
+
type = typeof data.error_kind === "string" && data.error_kind || typeof data.terminal_reason === "string" && data.terminal_reason || "user_cancelled";
|
|
883
|
+
variant = "interrupt";
|
|
884
|
+
} else if (presentation === "hook_stopped") {
|
|
885
|
+
message = resolveHookStoppedMessage(data);
|
|
886
|
+
type = "hook_stopped";
|
|
887
|
+
variant = "hook_stopped";
|
|
888
|
+
} else {
|
|
889
|
+
const resolved = resolveErrorEventFields({
|
|
890
|
+
message: resolveFinishErrorMessage(data),
|
|
891
|
+
type: typeof data.error_kind === "string" && data.error_kind || typeof data.terminal_reason === "string" && data.terminal_reason || void 0
|
|
892
|
+
});
|
|
893
|
+
message = resolved.message;
|
|
894
|
+
type = resolved.type;
|
|
895
|
+
}
|
|
729
896
|
const id = `finish-error:${seq}`;
|
|
730
897
|
const node = {
|
|
731
898
|
kind: "error",
|
|
732
899
|
id,
|
|
733
900
|
message,
|
|
734
901
|
errorType: type,
|
|
735
|
-
startedAt: eventTimeToMs(event.timestamp)
|
|
902
|
+
startedAt: eventTimeToMs(event.timestamp),
|
|
903
|
+
variant
|
|
736
904
|
};
|
|
737
905
|
tree.byId[id] = node;
|
|
738
906
|
appendMainStageChild(tree, id, event, seq);
|
|
@@ -1266,6 +1434,13 @@ function handleToolProgress(tree, event, parentNodeId, _seq) {
|
|
|
1266
1434
|
}
|
|
1267
1435
|
});
|
|
1268
1436
|
}
|
|
1437
|
+
function handleTaskNotification(tree, event) {
|
|
1438
|
+
applyTaskNotification(
|
|
1439
|
+
tree,
|
|
1440
|
+
event.data,
|
|
1441
|
+
eventTimeToMs(event.timestamp)
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1269
1444
|
function handleSubagentBoundaryStart(tree, event, parentNodeId, options) {
|
|
1270
1445
|
const data = event.data;
|
|
1271
1446
|
let parentId = parentNodeId;
|
|
@@ -1601,6 +1776,9 @@ function applyClassified(tree, classified, eventIndex, options) {
|
|
|
1601
1776
|
break;
|
|
1602
1777
|
case "subagent-model-step":
|
|
1603
1778
|
break;
|
|
1779
|
+
case "task-notification":
|
|
1780
|
+
handleTaskNotification(tree, event);
|
|
1781
|
+
break;
|
|
1604
1782
|
case "start-step":
|
|
1605
1783
|
handleStepStart(tree, event, parentNodeId, seq);
|
|
1606
1784
|
break;
|
|
@@ -1806,6 +1984,9 @@ function resolveWorkflowBanner(state) {
|
|
|
1806
1984
|
return { kind: "sync_failed", message: "\u540C\u6B65\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u5237\u65B0" };
|
|
1807
1985
|
}
|
|
1808
1986
|
const auth = state.authority?.status;
|
|
1987
|
+
if (auth === "canceled") {
|
|
1988
|
+
return { kind: "canceled", message: "\u5DF2\u53D6\u6D88" };
|
|
1989
|
+
}
|
|
1809
1990
|
if (auth === "error") {
|
|
1810
1991
|
return { kind: "authority_error", message: "Workflow \u6267\u884C\u5931\u8D25" };
|
|
1811
1992
|
}
|
|
@@ -1834,6 +2015,12 @@ function resolveWorkflowBanner(state) {
|
|
|
1834
2015
|
message: `\u4F20\u8F93\u5F02\u5E38\uFF0C\u5C55\u793A\u53EF\u80FD\u4E0D\u5B8C\u6574${suffix}`
|
|
1835
2016
|
};
|
|
1836
2017
|
}
|
|
2018
|
+
if (state.meta.loopDisplayTruncated) {
|
|
2019
|
+
return {
|
|
2020
|
+
kind: "loop_display_truncated",
|
|
2021
|
+
message: "\u8F83\u65E9\u7684\u65F6\u95F4\u7EBF\u5DF2\u622A\u65AD\u4EE5\u63A7\u5236\u5185\u5B58\uFF0C\u6700\u65B0\u5DE5\u5177\u6D3B\u52A8\u4ECD\u5728\u66F4\u65B0"
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
1837
2024
|
if (state.display.terminalKind === "forced_closeout" && auth === "done") {
|
|
1838
2025
|
return { kind: "forced_closeout", message: "Workflow \u5DF2\u7ED3\u675F\uFF08\u90E8\u5206\u5BB9\u5668\u672A\u6B63\u5E38\u5173\u95ED\uFF09" };
|
|
1839
2026
|
}
|
|
@@ -4087,6 +4274,13 @@ function shouldShowAgentSpinner(state) {
|
|
|
4087
4274
|
if (isAuthorityTerminalStatus(auth)) return false;
|
|
4088
4275
|
return true;
|
|
4089
4276
|
}
|
|
4277
|
+
function isAgentInputLocked(state) {
|
|
4278
|
+
if (!state.authorityBindingActive) {
|
|
4279
|
+
const status = state.tree.status;
|
|
4280
|
+
return status === "running" || status === "connecting";
|
|
4281
|
+
}
|
|
4282
|
+
return !isAuthorityTerminalStatus(state.authority?.status);
|
|
4283
|
+
}
|
|
4090
4284
|
|
|
4091
4285
|
// src/view/TaskList.tsx
|
|
4092
4286
|
import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef2, useState as useState3 } from "react";
|
|
@@ -5694,6 +5888,7 @@ export {
|
|
|
5694
5888
|
CollapsedExploreNode,
|
|
5695
5889
|
SystemSummaryNode,
|
|
5696
5890
|
shouldShowAgentSpinner,
|
|
5891
|
+
isAgentInputLocked,
|
|
5697
5892
|
TaskList,
|
|
5698
5893
|
Spinner,
|
|
5699
5894
|
formatTaskFooterLabel,
|
|
@@ -5707,4 +5902,4 @@ export {
|
|
|
5707
5902
|
VirtualTimeline,
|
|
5708
5903
|
SessionTimeline
|
|
5709
5904
|
};
|
|
5710
|
-
//# sourceMappingURL=chunk-
|
|
5905
|
+
//# sourceMappingURL=chunk-UBYOUDQE.js.map
|