langchain_agentx_stream_ui 0.6.4 → 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/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  fixDiagramSvg,
24
24
  markEventIdSeen,
25
25
  shouldSkipDuplicateEvent
26
- } from "./chunk-YHCK76OU.js";
26
+ } from "./chunk-VBUKRPEO.js";
27
27
  import {
28
28
  DefaultToolBody,
29
29
  InteractionBusContext,
@@ -32,7 +32,7 @@ import {
32
32
  getNoopInteractionBus,
33
33
  resolveToolBody,
34
34
  useInteractionBus
35
- } from "./chunk-5XELRP3S.js";
35
+ } from "./chunk-B2NG5KGH.js";
36
36
  import "./chunk-6Z4ZF36Z.js";
37
37
  import {
38
38
  CollapseKind,
@@ -79,6 +79,7 @@ import {
79
79
  getChildIds,
80
80
  getDisplayProjectionStatus,
81
81
  getMainStageIds,
82
+ isAgentInputLocked,
82
83
  isAuthorityTerminal,
83
84
  isAuthorityTerminalStatus,
84
85
  isGitOperationCommand,
@@ -119,7 +120,7 @@ import {
119
120
  useSessionStatus,
120
121
  useSessionViewOptions,
121
122
  useTimeline
122
- } from "./chunk-O5GERXTY.js";
123
+ } from "./chunk-UBYOUDQE.js";
123
124
  import {
124
125
  AGENT_PROGRESS_GUTTER,
125
126
  AGENT_PROGRESS_INDENT,
@@ -149,7 +150,7 @@ import {
149
150
  createDefaultToolRegistry,
150
151
  formatAgentTitle,
151
152
  formatExploreSummaryText
152
- } from "./chunk-GYFC2DI7.js";
153
+ } from "./chunk-7XSQYG3X.js";
153
154
  import {
154
155
  BodyBlockList,
155
156
  DiffView,
@@ -990,6 +991,70 @@ function trimWorkflowLoopTreesSoft(state, options) {
990
991
  };
991
992
  }
992
993
 
994
+ // src/core/sessionTreeAuthorityFinalize.ts
995
+ function finalizeSessionTreeOnAuthorityCanceled(tree, endedAtMs = Date.now()) {
996
+ const byId = { ...tree.byId };
997
+ let changed = false;
998
+ for (const [id, node] of Object.entries(byId)) {
999
+ if (!node) continue;
1000
+ if ((node.kind === "text" || node.kind === "reasoning") && node.status === "streaming") {
1001
+ byId[id] = { ...node, status: "done" };
1002
+ changed = true;
1003
+ continue;
1004
+ }
1005
+ if (node.kind !== "tool_call") continue;
1006
+ let next = node;
1007
+ if (node.status === "running") {
1008
+ next = {
1009
+ ...next,
1010
+ status: "failed",
1011
+ endedAt: node.endedAt ?? endedAtMs
1012
+ };
1013
+ changed = true;
1014
+ }
1015
+ if (next.subagentSessions) {
1016
+ const sessions = { ...next.subagentSessions };
1017
+ let sessChanged = false;
1018
+ for (const [agentId, marker] of Object.entries(sessions)) {
1019
+ if (marker.status === "running") {
1020
+ sessions[agentId] = {
1021
+ ...marker,
1022
+ status: "done",
1023
+ endedAt: endedAtMs
1024
+ };
1025
+ sessChanged = true;
1026
+ }
1027
+ }
1028
+ if (sessChanged) {
1029
+ next = { ...next, subagentSessions: sessions };
1030
+ changed = true;
1031
+ }
1032
+ }
1033
+ if (next.subagentProgress?.some((e) => e.status === "running")) {
1034
+ next = {
1035
+ ...next,
1036
+ subagentProgress: next.subagentProgress.map(
1037
+ (entry) => entry.status === "running" ? { ...entry, status: "error" } : entry
1038
+ )
1039
+ };
1040
+ changed = true;
1041
+ }
1042
+ if (next !== node) {
1043
+ byId[id] = next;
1044
+ }
1045
+ }
1046
+ if (!changed) {
1047
+ return tree;
1048
+ }
1049
+ return {
1050
+ ...tree,
1051
+ byId,
1052
+ activeRoundId: null,
1053
+ // 展示树终态;不升格 / 不写 REST authority(P-AUTH)
1054
+ status: tree.status === "done" || tree.status === "done_with_warning" ? tree.status : "error"
1055
+ };
1056
+ }
1057
+
993
1058
  // src/core/store.ts
994
1059
  function safeReduce(tree, event, eventIndex, options) {
995
1060
  try {
@@ -1059,7 +1124,12 @@ function createSessionStore(initialTree = createEmptyTree(), storeOptions) {
1059
1124
  set({ tree, eventCount });
1060
1125
  },
1061
1126
  applyAuthoritySnapshot(snapshot) {
1062
- set({ authority: snapshot });
1127
+ const current = get();
1128
+ let tree = current.tree;
1129
+ if (snapshot.status === "canceled") {
1130
+ tree = finalizeSessionTreeOnAuthorityCanceled(tree);
1131
+ }
1132
+ set({ authority: snapshot, tree });
1063
1133
  },
1064
1134
  setAuthoritySubscribeFailed(failed) {
1065
1135
  set({ authoritySubscribeFailed: failed });
@@ -3383,6 +3453,38 @@ function safeReduceWorkflow(state, event, eventIndex, options) {
3383
3453
  };
3384
3454
  }
3385
3455
  }
3456
+ function finalizeWorkflowContainersOnAuthorityCanceled(state) {
3457
+ const containersById = {
3458
+ ...state.containerTree.containersById
3459
+ };
3460
+ let changed = false;
3461
+ for (const [id, node] of Object.entries(containersById)) {
3462
+ if (node.status !== "running" && node.status !== "pending") {
3463
+ continue;
3464
+ }
3465
+ const display = node.display ? { ...node.display, metrics_running: 0 } : node.display;
3466
+ containersById[id] = {
3467
+ ...node,
3468
+ status: "failed",
3469
+ is_open: false,
3470
+ display
3471
+ };
3472
+ changed = true;
3473
+ }
3474
+ if (!changed) {
3475
+ return state;
3476
+ }
3477
+ return {
3478
+ ...state,
3479
+ containerTree: {
3480
+ ...state.containerTree,
3481
+ containersById,
3482
+ activeContainerIds: state.containerTree.activeContainerIds.filter(
3483
+ (id) => containersById[id]?.is_open
3484
+ )
3485
+ }
3486
+ };
3487
+ }
3386
3488
  function finalizeWorkflowSessionOnStreamError(state, message, eventIndex, stack) {
3387
3489
  const containersById = {
3388
3490
  ...state.containerTree.containersById
@@ -3522,17 +3624,33 @@ function createWorkflowSessionStore(initialState = createEmptyWorkflowSessionSta
3522
3624
  }));
3523
3625
  },
3524
3626
  applyAuthoritySnapshot(snapshot) {
3525
- set((current) => ({
3526
- state: {
3527
- ...current.state,
3528
- authority: snapshot,
3529
- display: {
3530
- ...current.state.display,
3531
- awaitingAuthority: false,
3532
- authoritySyncFailed: false
3627
+ set((current) => {
3628
+ let nextState = current.state;
3629
+ if (snapshot.status === "canceled") {
3630
+ nextState = finalizeWorkflowContainersOnAuthorityCanceled(nextState);
3631
+ const nextLoops = {
3632
+ ...nextState.loopTreesBySessionId
3633
+ };
3634
+ for (const [loopSessionId, loopTree] of Object.entries(nextLoops)) {
3635
+ nextLoops[loopSessionId] = finalizeSessionTreeOnAuthorityCanceled(loopTree);
3533
3636
  }
3637
+ nextState = {
3638
+ ...nextState,
3639
+ loopTreesBySessionId: nextLoops
3640
+ };
3534
3641
  }
3535
- }));
3642
+ return {
3643
+ state: {
3644
+ ...nextState,
3645
+ authority: snapshot,
3646
+ display: {
3647
+ ...nextState.display,
3648
+ awaitingAuthority: false,
3649
+ authoritySyncFailed: false
3650
+ }
3651
+ }
3652
+ };
3653
+ });
3536
3654
  },
3537
3655
  setAwaitingAuthority(value) {
3538
3656
  set((current) => ({
@@ -5392,8 +5510,17 @@ function WorkflowSessionBanners({ state }) {
5392
5510
  if (banner.kind === "none" && display.projectionStatus !== "error" && display.projectionStatus !== "done_with_warning" && state.internalErrors.length === 0) {
5393
5511
  return null;
5394
5512
  }
5395
- const showTransportError = (display.projectionStatus === "error" || state.internalErrors.length > 0) && banner.kind !== "projection_degraded" && banner.kind !== "authority_error";
5513
+ const showTransportError = (display.projectionStatus === "error" || state.internalErrors.length > 0) && banner.kind !== "projection_degraded" && banner.kind !== "authority_error" && banner.kind !== "canceled";
5396
5514
  return /* @__PURE__ */ jsxs14(Fragment4, { children: [
5515
+ banner.kind === "canceled" ? /* @__PURE__ */ jsx17(
5516
+ "div",
5517
+ {
5518
+ className: "lax-workflow-banner lax-workflow-banner--canceled",
5519
+ "data-testid": "lax-workflow-canceled-banner",
5520
+ role: "status",
5521
+ children: banner.message
5522
+ }
5523
+ ) : null,
5397
5524
  banner.kind === "authority_error" ? /* @__PURE__ */ jsx17(
5398
5525
  "div",
5399
5526
  {
@@ -6138,6 +6265,7 @@ export {
6138
6265
  displayPath,
6139
6266
  entryKey,
6140
6267
  filterAgentLoopReplayEvents,
6268
+ finalizeSessionTreeOnAuthorityCanceled,
6141
6269
  finalizeWorkflowDisplayOnStreamEnded,
6142
6270
  fixDiagramSvg,
6143
6271
  formatAgentTitle,
@@ -6156,6 +6284,7 @@ export {
6156
6284
  getNoopInteractionBus,
6157
6285
  hydrateAskFromSnapshot,
6158
6286
  hydrateWorkflowFromSnapshot,
6287
+ isAgentInputLocked,
6159
6288
  isAgentLoopReplayEventType,
6160
6289
  isAtOrBeforeProjectionCursor,
6161
6290
  isAuthorityTerminal,