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.
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, PointerEventHandler } from 'react';
4
- import { q as Source, L as LangchainAgentEvent, N as NodeRegistry, v as TierOverrides, I as InteractionBus, M as MarkdownRenderer, p as SessionTree, R as ReducerError, r as SourceEventContext, T as Task, t as TaskPhase, l as SessionStatus, E as EventTier } from './multi-session-xvSZstSN.js';
5
- export { C as CommonFields, D as DEFAULT_EVENT_TIERS, a as EventType, b as InteractionBusHandlers, c as MarkdownRendererProps, d as MultiAgentSession, e as MultiAgentSessionProps, f as MultiSessionSourceConfig, g as MultiSessionStore, h as MultiSessionStoreOptions, i as MultiSessionStoreState, j as NodeWidget, k as NodeWidgetProps, P as PermissionResolvePayload, S as SessionSlice, m as SessionStore, n as SessionStoreOptions, o as SessionStoreState, s as SourceHandler, u as TaskStatus, w as createActiveSessionBridge, x as createEmptyTree, y as createInteractionBus, z as createMultiSessionStore, A as createSessionStore, B as getNoopInteractionBus, F as useActiveSession, G as useSessionIds } from './multi-session-xvSZstSN.js';
6
- import { T as ToolDisplayRegistry, P as PermissionUiMode, b as DisplayMode, c as ProjectionContext, R as RenderableEntry, C as CanonicalNodeRef } from './sessionViewOptions-WM00Fpcn.js';
7
- export { a as CollapsedExplorePayload, D as DEFAULT_SESSION_VIEW_OPTIONS, S as SessionViewOptions, d as ToolUseSnapshot, e as buildProjectionContext, f as buildProjectionViewContext, g as createDefaultToolRegistry, h as createProjectionContext, r as resolveEffectiveToolBodyMode, s as shouldApplyGrouping, i as shouldShowExploreDetail } from './sessionViewOptions-WM00Fpcn.js';
4
+ import { q as Source, L as LangchainAgentEvent, N as NodeRegistry, v as TierOverrides, I as InteractionBus, M as MarkdownRenderer, p as SessionTree, R as ReducerError, r as SourceEventContext, T as Task, t as TaskPhase, l as SessionStatus, E as EventTier } from './multi-session-CerO558Y.js';
5
+ export { C as CommonFields, D as DEFAULT_EVENT_TIERS, a as EventType, b as InteractionBusHandlers, c as MarkdownRendererProps, d as MultiAgentSession, e as MultiAgentSessionProps, f as MultiSessionSourceConfig, g as MultiSessionStore, h as MultiSessionStoreOptions, i as MultiSessionStoreState, j as NodeWidget, k as NodeWidgetProps, P as PermissionResolvePayload, S as SessionSlice, m as SessionStore, n as SessionStoreOptions, o as SessionStoreState, s as SourceHandler, u as TaskStatus, w as createActiveSessionBridge, x as createEmptyTree, y as createInteractionBus, z as createMultiSessionStore, A as createSessionStore, B as getNoopInteractionBus, F as useActiveSession, G as useSessionIds } from './multi-session-CerO558Y.js';
6
+ import { T as ToolDisplayRegistry, P as PermissionUiMode, b as DisplayMode, c as ProjectionContext, R as RenderableEntry, C as CanonicalNodeRef } from './sessionViewOptions-DQRzPuN_.js';
7
+ export { a as CollapsedExplorePayload, D as DEFAULT_SESSION_VIEW_OPTIONS, S as SessionViewOptions, d as ToolUseSnapshot, e as buildProjectionContext, f as buildProjectionViewContext, g as createDefaultToolRegistry, h as createProjectionContext, r as resolveEffectiveToolBodyMode, s as shouldApplyGrouping, i as shouldShowExploreDetail } from './sessionViewOptions-DQRzPuN_.js';
8
8
  import { a as ToolBodyMode } from './types-BEXSHQG7.js';
9
9
  export { T as ToolBodyComponent, b as ToolDisplayProps } from './types-BEXSHQG7.js';
10
10
  import { StoreApi } from 'zustand/vanilla';
11
11
  export { DEFAULT_ESTIMATE_SIZE, DEFAULT_VIRTUALIZE_THRESHOLD, SessionTimeline, SessionTimelineProps, VirtualTimeline, VirtualTimelineProps } from './virtual.js';
12
- export { A as AgentToolBody, a as AskUserQuestionToolBody, B as BashToolBody, D as DefaultToolBody, E as EditToolBody, G as GlobToolBody, b as GrepToolBody, R as ReadToolBody, S as SkillToolBody, W as WebFetchToolBody, c as WebSearchToolBody, d as WriteToolBody, f as formatToolTitle, r as resolveToolBody } from './AskUserQuestionToolBody-BG1StdvE.js';
12
+ export { A as AgentToolBody, a as AskUserQuestionToolBody, B as BashToolBody, D as DefaultToolBody, E as EditToolBody, G as GlobToolBody, b as GrepToolBody, R as ReadToolBody, S as SkillToolBody, W as WebFetchToolBody, c as WebSearchToolBody, d as WriteToolBody, f as formatToolTitle, r as resolveToolBody } from './AskUserQuestionToolBody-CUXqUkar.js';
13
13
  import { S as SessionNode, a as SessionNodeKind } from './nodes-BcyPw6Fr.js';
14
14
  export { E as ErrorNode, N as NodeDetail, P as PermissionNode, R as ReasoningNode, b as StepDetail, c as StepNode, d as SubAgentNode, T as TextNode, h as ToolCallNode, U as UnknownNode } from './nodes-BcyPw6Fr.js';
15
15
  export { B as BodyBlock, a as BodyBlockList, D as DiffView, M as MAX_PREVIEW_LINES, b as MarkdownBlock, T as TruncatedContent, c as buildBashBodyBlocks, d as displayPath, f as formatDiffFromStrings, e as formatPatternTitle, g as formatSearchResultBody, h as formatTimeoutFooter, p as parseDiffText, t as truncateCommand } from './MarkdownBlock-CcXZ5nTm.js';
@@ -48,9 +48,11 @@ interface AgentSessionProps {
48
48
  exploreFullscreenBash?: boolean;
49
49
  memoryDir?: string | null;
50
50
  workspaceRoot?: string | null;
51
+ /** D34 P2 LeakGate synthesize;默认 false */
52
+ subagentLeakGate?: boolean;
51
53
  children?: ReactNode;
52
54
  }
53
- declare function AgentSession({ source, initialEvents, registry, tierOverrides: _tierOverrides, onError, autoReconnect: _autoReconnect, debug, virtualized, virtualizeThreshold, interactionBus, toolDisplayRegistry, defaultBodyMode, groupParallelTools, permissionUiMode, markdownRenderer, displayMode, verbose, exploreFullscreenBash, memoryDir, workspaceRoot, children, }: AgentSessionProps): react_jsx_runtime.JSX.Element;
55
+ declare function AgentSession({ source, initialEvents, registry, tierOverrides: _tierOverrides, onError, autoReconnect: _autoReconnect, debug, virtualized, virtualizeThreshold, interactionBus, toolDisplayRegistry, defaultBodyMode, groupParallelTools, permissionUiMode, markdownRenderer, displayMode, verbose, exploreFullscreenBash, memoryDir, workspaceRoot, subagentLeakGate, children, }: AgentSessionProps): react_jsx_runtime.JSX.Element;
54
56
 
55
57
  interface AgentLoopViewProps {
56
58
  /** 传入时使用隔离 store(workflow scoped);省略则使用上层 SessionStoreContext */
@@ -213,6 +215,8 @@ interface WorkflowAuthoritySnapshot {
213
215
  execution_authority?: true;
214
216
  orphan_items_reaped?: number;
215
217
  partial_success_kind?: string;
218
+ projection_status?: 'complete' | 'degraded' | 'running';
219
+ projection_dropped_count?: number;
216
220
  };
217
221
  }
218
222
  /** 纯投影 / 传输展示态 — 不可驱动宿主 phase(D33) */
@@ -286,12 +290,59 @@ interface WorkflowSessionState {
286
290
  /** P2:completed hydrated loop LRU 热缓存(最近使用在数组尾部) */
287
291
  hotCompletedLoopSessionIds: string[];
288
292
  activeLoopSessionId: string | null;
293
+ /** D36 P4:snapshot hydrate 后的 tail 游标 */
294
+ projectionCursor: string | null;
295
+ snapshotVersion: number | null;
296
+ reconnectSuppressedReason: string | null;
297
+ /** D36 T6:snapshot 404/409 时展示降级,禁止 history fallback */
298
+ snapshotHydrateFailed: boolean;
289
299
  /** @deprecated P1 起由 containerTree.activeContainerIds 替代 */
290
300
  openScopeStack: WorkflowScopeFrame[];
291
301
  internalErrors: ReducerError[];
292
302
  }
293
303
  declare function createEmptyWorkflowSessionState(): WorkflowSessionState;
294
304
 
305
+ /**
306
+ * workflowSnapshot.ts — WorkflowDisplaySnapshot DTO(D36 P3)
307
+ *
308
+ * 职责:
309
+ * remount hydrate SSOT;与 AgentEvent 协议独立。
310
+ *
311
+ * 链路位置:
312
+ * GET /projection/snapshot → hydrateWorkflowFromSnapshot(P4)。
313
+ *
314
+ * 当前裁剪范围:
315
+ * 类型定义 + fixture 契约;不含 hydrate 实现。
316
+ */
317
+
318
+ type WorkflowSnapshotProjectionStatus = 'complete' | 'degraded' | 'running';
319
+ interface WorkflowCoalescedBlock {
320
+ scopeKey: string;
321
+ kind: 'reasoning' | 'text' | 'tool';
322
+ tailPreview: string;
323
+ droppedDeltaCount: number;
324
+ }
325
+ interface WorkflowDisplaySnapshotMetadata {
326
+ projection_status?: WorkflowSnapshotProjectionStatus;
327
+ s0_event_count?: number;
328
+ dropped_s2_count?: number;
329
+ }
330
+ /** remount SSOT — 对齐 WorkflowSessionState 投影子集,非 AgentEvent[] */
331
+ interface WorkflowDisplaySnapshot {
332
+ taskId: string;
333
+ /** 单调;SSE tail 只发严格 > cursor 的帧(evt_{n:06d}) */
334
+ cursor: string;
335
+ /** hydrate 时写入 store;tail 事件须 version 一致或更新 */
336
+ snapshotVersion: number;
337
+ capturedAt: number;
338
+ display: WorkflowDisplayProjection;
339
+ /** 与 WorkflowContainerTreeState 同构 */
340
+ containerTree: WorkflowContainerTreeState;
341
+ /** P4 可选;degraded 首屏 tail 预览 */
342
+ coalescedBlocks?: WorkflowCoalescedBlock[];
343
+ metadata?: WorkflowDisplaySnapshotMetadata;
344
+ }
345
+
295
346
  /**
296
347
  * workflowAuthoritySource.ts — 宿主 workflow 业务权威输入契约(D33 §6.1)
297
348
  *
@@ -312,9 +363,13 @@ interface WorkflowAuthoritySource {
312
363
  }
313
364
 
314
365
  interface WorkflowSessionProps {
315
- source: Source;
366
+ source: Source | null;
316
367
  /** 宿主业务权威(必填);测试可用 createMockAuthoritySource */
317
368
  authoritySource: WorkflowAuthoritySource;
369
+ /** D36 P4:remount 时 GET snapshot 结果(先于 SSE tail hydrate) */
370
+ snapshotBootstrap?: WorkflowDisplaySnapshot | null;
371
+ /** T6:snapshot GET 失败时标记,禁止 history fallback */
372
+ snapshotHydrateFailed?: boolean;
318
373
  initialEvents?: LangchainAgentEvent[];
319
374
  registry?: NodeRegistry;
320
375
  tierOverrides?: TierOverrides;
@@ -342,7 +397,7 @@ interface WorkflowSessionProps {
342
397
  onDisplayStreamEnded?: () => void;
343
398
  children?: ReactNode;
344
399
  }
345
- declare function WorkflowSession({ source, authoritySource, initialEvents, registry, tierOverrides, onError, interactionBus, toolDisplayRegistry, defaultBodyMode, permissionUiMode, markdownRenderer, displayMode, verbose, exploreFullscreenBash, memoryDir, workspaceRoot, virtualized, virtualizeThreshold, groupParallelTools, workflowScale, onRequestLoopReplay, onAuthorityTerminal, onDisplayStreamEnded, children, }: WorkflowSessionProps): react_jsx_runtime.JSX.Element;
400
+ declare function WorkflowSession({ source, authoritySource, snapshotBootstrap, snapshotHydrateFailed, initialEvents, registry, tierOverrides, onError, interactionBus, toolDisplayRegistry, defaultBodyMode, permissionUiMode, markdownRenderer, displayMode, verbose, exploreFullscreenBash, memoryDir, workspaceRoot, virtualized, virtualizeThreshold, groupParallelTools, workflowScale, onRequestLoopReplay, onAuthorityTerminal, onDisplayStreamEnded, children, }: WorkflowSessionProps): react_jsx_runtime.JSX.Element;
346
401
 
347
402
  /**
348
403
  * createMockAuthoritySource.ts — 测试 / demo 用 authority 源
@@ -450,6 +505,11 @@ interface WorkflowSessionStoreState {
450
505
  hydrateLoopSession: (loopSessionId: string, events: LangchainAgentEvent[]) => void;
451
506
  /** DES-1:宿主默认 replay 路径 — 分批 + rAF yield */
452
507
  hydrateLoopSessionAsync: (loopSessionId: string, events: LangchainAgentEvent[], options?: HydrateLoopSessionAsyncOptions) => Promise<void>;
508
+ /** D36 P4:remount snapshot hydrate */
509
+ hydrateFromSnapshot: (snapshot: WorkflowDisplaySnapshot, options?: {
510
+ preserveAuthority?: boolean;
511
+ }) => void;
512
+ markSnapshotHydrateFailed: () => void;
453
513
  }
454
514
  interface HydrateLoopSessionAsyncOptions {
455
515
  chunkSize?: number;
@@ -583,6 +643,8 @@ interface ReduceOptions {
583
643
  tierOverrides?: TierOverrides;
584
644
  /** true 时 debug tier 也写入 debugEvents(AgentSession debug prop) */
585
645
  collectDebug?: boolean;
646
+ /** D19 §5.3 / D34 P2:leak main-tier tool-call 合成父 Agent progress;默认 off */
647
+ subagentLeakGate?: boolean;
586
648
  }
587
649
  declare function streamChunk(data: {
588
650
  delta?: string;
@@ -1078,7 +1140,7 @@ declare class MissingApplicationKindError extends Error {
1078
1140
  * 不等于 workflow 业务终态(authority);phase / spinner 读 WorkflowAuthoritySnapshot(见 D33)。
1079
1141
  */
1080
1142
 
1081
- type SseTransportProfile = 'oneshot' | 'oneshot-workflow' | 'replayable-workflow';
1143
+ type SseTransportProfile = 'oneshot' | 'oneshot-workflow' | 'replayable-workflow' | 'workflow-tail';
1082
1144
  type SseReplayMode = 'none' | 'resume' | 'history';
1083
1145
  type SseReconnectMode = 'off' | 'bounded' | 'unbounded';
1084
1146
  interface SseReconnectPolicy {
@@ -1192,6 +1254,7 @@ declare function createMockSource(events: LangchainAgentEvent[]): Source;
1192
1254
  interface ReplayOptions {
1193
1255
  tierOverrides?: TierOverrides;
1194
1256
  collectDebug?: boolean;
1257
+ subagentLeakGate?: boolean;
1195
1258
  }
1196
1259
  /** 从空树回放完整事件序列。 */
1197
1260
  declare function replayEvents(events: LangchainAgentEvent[], options?: ReplayOptions): SessionTree;
@@ -1289,10 +1352,10 @@ declare function isAuthorityTerminal(state: WorkflowSessionState): boolean;
1289
1352
  /** 全局 workflow spinner:authority 非 terminal 时保持(含 projection 已 done 的 T2)。 */
1290
1353
  declare function shouldShowGlobalSpinner(state: WorkflowSessionState): boolean;
1291
1354
  interface WorkflowBannerDescriptor {
1292
- kind: 'none' | 'partial_success' | 'forced_closeout' | 'awaiting_authority' | 'sync_failed';
1355
+ kind: 'none' | 'authority_error' | 'partial_success' | 'forced_closeout' | 'projection_degraded' | 'snapshot_unavailable' | 'awaiting_authority' | 'sync_failed';
1293
1356
  message: string;
1294
1357
  }
1295
- /** Phase 1 基础文案;Phase 2 扩展 partial_success × forced_closeout 矩阵。 */
1358
+ /** D36 §00.1 Banner 优先级栈(高→低)— 返回最高优先级一条。 */
1296
1359
  declare function resolveWorkflowBanner(state: WorkflowSessionState): WorkflowBannerDescriptor;
1297
1360
  /** UI 读投影态(非 phase SSOT)。 */
1298
1361
  declare function getDisplayProjectionStatus(state: WorkflowSessionState): WorkflowSessionState['display']['projectionStatus'];
@@ -1323,6 +1386,24 @@ declare function filterAgentLoopReplayEvents<T extends {
1323
1386
  /** agent 事件缺 session_id 时,从 workflow_id (或 workflow_path 兜底) + scope key 推导。 */
1324
1387
  declare function deriveLoopSessionIdFromAgentEvent(event: LangchainAgentEvent): string | null;
1325
1388
 
1389
+ /**
1390
+ * hydrateWorkflowSnapshot.ts — remount SSOT(D36 P4)
1391
+ *
1392
+ * 职责:
1393
+ * WorkflowDisplaySnapshot → WorkflowSessionState 投影子集替换。
1394
+ *
1395
+ * 链路位置:
1396
+ * GET /projection/snapshot → workflowSessionStore.hydrateFromSnapshot。
1397
+ */
1398
+
1399
+ interface HydrateWorkflowSnapshotOptions {
1400
+ preserveAuthority?: boolean;
1401
+ }
1402
+ /** 判断 SSE event id 是否 ≤ projectionCursor(duplicate tail 丢弃)。 */
1403
+ declare function isAtOrBeforeProjectionCursor(projectionCursor: string | null | undefined, eventId: string | undefined): boolean;
1404
+ /** 冻结算法:替换投影子集,禁止写 authority(除非 preserveAuthority)。 */
1405
+ declare function hydrateWorkflowFromSnapshot(state: WorkflowSessionState, snapshot: WorkflowDisplaySnapshot, options?: HydrateWorkflowSnapshotOptions): WorkflowSessionState;
1406
+
1326
1407
  /**
1327
1408
  * 职责:事件分级类型(V2-A classify 层公共契约)。
1328
1409
  * 链路位置:classify.ts → reducer;AgentSession tierOverrides 传入。
@@ -1351,4 +1432,4 @@ interface ClassifyContext {
1351
1432
  declare function resolveEventTier(eventType: string, overrides?: TierOverrides): EventTier;
1352
1433
  declare function classifyEvent(event: LangchainAgentEvent, ctx: ClassifyContext, overrides?: TierOverrides, eventIndex?: number): ClassifiedEvent;
1353
1434
 
1354
- export { Agent, AgentLoopView, type AgentLoopViewProps, AgentSession, type AgentSessionProps, type AgentxMetaFrame, type AgentxSseSourceOptions, type ApplicationKind, ApplicationKindMismatchError, AskUserQuestion, BOUNDED_DEFAULTS, Bash, CanonicalNodeRef, type ClassifiedEvent, type ClassifyContext, CollapseKind, CollapsedExploreNode, type CollapsedExploreNodeProps, DEFAULT_WORKFLOW_SCALE_OPTIONS, type DiagramFitLayout, DiagramZoomShell, type DiagramZoomShellProps, DiagramZoomView, type DiagramZoomViewProps, DisplayMode, EXPECTED_PROTOCOL_VERSION, Edit, ErrorCard, EventTier, ExploreCollapseAccumulator, GROUPABLE_TOOL_NAMES, Glob, Grep, GroupedToolUseAccumulator, type HydrateLoopSessionAsyncOptions, InteractionBus, LangchainAgentEvent, MIN_HINT_DISPLAY_MS, MarkdownRenderer, MermaidDiagram, type MermaidDiagramProps, type MermaidInitOptions, type MermaidThemeName, MissingApplicationKindError, type MockAuthoritySourceOptions, NodeRegistry, PROFILE_PRESETS, PermissionCard, PermissionUiMode, PlantUMLBlock, type PlantUMLBlockProps, PlantUMLDiagram, type PlantUMLDiagramProps, type PollingAuthoritySourceOptions, type ProjectedTimelineItem, ProjectionContext, DisplayMode as ProjectionDisplayMode, Read, ReasoningBubble, ReconnectBudget, type ReduceOptions, ReducerError, RenderableEntry, RenderableTimelineProjector, type ReplayOptions, type ReplaySourceOptions, RichMarkdown, type RichMarkdownProps, SHELL_PROGRESS_MIN_ELAPSED_SECONDS, SessionNode, SessionNodeKind, SessionStatus, SessionTree, Skill, Source, SourceEventContext, Spinner, type SpinnerProps, type SseReconnectMode, type SseReconnectPolicy, type SseReplayMode, type SseTerminalPolicy, type SseTransportFailureKind, type SseTransportPolicy, type SseTransportPolicyOverride, type SseTransportProfile, SseTransportTerminalError, StepCard, SubAgentBlock, SystemSummaryAccumulator, SystemSummaryNode, Task, TaskList, TaskListFooter, TextBubble, TierOverrides, Timeline, TimelineItem, ToolBodyMode, ToolCallCard, ToolDisplayRegistry, ToolProjectionClassifier, UnknownCard, WORKFLOW_STRUCTURE_EVENT_PREFIXES, WORKFLOW_STRUCTURE_EVENT_TYPES, WebFetch, WebSearch, type WorkflowAuthoritySnapshot, type WorkflowAuthoritySource, type WorkflowAuthorityStatus, type WorkflowBannerDescriptor, WorkflowChrome, type WorkflowChromeProps, type WorkflowDisplayProjection, type WorkflowDisplayProjectionStatus, type WorkflowLoopReplayHandler, WorkflowLoopReplayProvider, type WorkflowProgressState, WorkflowScaleContext, type WorkflowScaleOptions, type WorkflowScopeFrame, WorkflowSession, type WorkflowSessionProps, type WorkflowSessionState, type WorkflowSessionStore, type WorkflowSessionStoreOptions, type WorkflowSessionStoreState, type WorkflowStageProgress, WorkflowTaskListFooter, type WorkflowTerminalKind, Write, applyAuthoritySnapshotToState, buildCanonicalFromTree, buildRelevantMemoriesCanonical, buildResumeStreamUrl, buildSystemEventCanonical, buildTimelineEntries, classifyEvent, commandAsHint, computeViewportFitTransform, configureMermaid, configurePlantumlServer, createAgentxSseSource, createControllableAuthoritySource, createDefaultRegistry, createDoneAuthoritySource, createEmptyWorkflowSessionState, createMockAuthoritySource, createMockSource, createPollingAuthoritySource, createReplaySource, createRunningAuthoritySource, createWorkflowSessionStore, deriveLoopSessionIdFromAgentEvent, entryKey, filterAgentLoopReplayEvents, finalizeWorkflowDisplayOnStreamEnded, fixDiagramSvg, formatAgentTitle, formatExploreSummaryText, formatHookFinishedSummary, formatShellProgressSuffix, formatTaskFooterLabel, getChildIds, getDisplayProjectionStatus, getMainStageIds, isAgentLoopReplayEventType, isAuthorityTerminal, isAuthorityTerminalStatus, isGitOperationCommand, isGroupableToolName, isMcpToolName, isSseStreamTerminalEvent, isWorkflowStructureEventType, iterMountCandidates, partitionWorkflowStages, projectCanonical, projectTimeline, reduceAgentLoopEvent, reduceEvents, reduceTree, reduceWorkflowEvents, reduceWorkflowSession, replayEvents, replayTree, resolveEventTier, resolveResponseId, resolveShellProgressFromPayload, resolveSseTransportPolicy, resolveWorkflowBanner, shouldShowGlobalSpinner, shouldShowTaskListFooter, streamChunk, useChildren, useInteractionBus, useInternalErrors, useMinDisplayTime, useNode, useNodeTyped, useProjectedTimeline, useReplayTree, useSessionMeta, useSessionStatus, useTimeline, useWorkflowSessionStatus, useWorkflowSessionStoreApi };
1435
+ export { Agent, AgentLoopView, type AgentLoopViewProps, AgentSession, type AgentSessionProps, type AgentxMetaFrame, type AgentxSseSourceOptions, type ApplicationKind, ApplicationKindMismatchError, AskUserQuestion, BOUNDED_DEFAULTS, Bash, CanonicalNodeRef, type ClassifiedEvent, type ClassifyContext, CollapseKind, CollapsedExploreNode, type CollapsedExploreNodeProps, DEFAULT_WORKFLOW_SCALE_OPTIONS, type DiagramFitLayout, DiagramZoomShell, type DiagramZoomShellProps, DiagramZoomView, type DiagramZoomViewProps, DisplayMode, EXPECTED_PROTOCOL_VERSION, Edit, ErrorCard, EventTier, ExploreCollapseAccumulator, GROUPABLE_TOOL_NAMES, Glob, Grep, GroupedToolUseAccumulator, type HydrateLoopSessionAsyncOptions, type HydrateWorkflowSnapshotOptions, InteractionBus, LangchainAgentEvent, MIN_HINT_DISPLAY_MS, MarkdownRenderer, MermaidDiagram, type MermaidDiagramProps, type MermaidInitOptions, type MermaidThemeName, MissingApplicationKindError, type MockAuthoritySourceOptions, NodeRegistry, PROFILE_PRESETS, PermissionCard, PermissionUiMode, PlantUMLBlock, type PlantUMLBlockProps, PlantUMLDiagram, type PlantUMLDiagramProps, type PollingAuthoritySourceOptions, type ProjectedTimelineItem, ProjectionContext, DisplayMode as ProjectionDisplayMode, Read, ReasoningBubble, ReconnectBudget, type ReduceOptions, ReducerError, RenderableEntry, RenderableTimelineProjector, type ReplayOptions, type ReplaySourceOptions, RichMarkdown, type RichMarkdownProps, SHELL_PROGRESS_MIN_ELAPSED_SECONDS, SessionNode, SessionNodeKind, SessionStatus, SessionTree, Skill, Source, SourceEventContext, Spinner, type SpinnerProps, type SseReconnectMode, type SseReconnectPolicy, type SseReplayMode, type SseTerminalPolicy, type SseTransportFailureKind, type SseTransportPolicy, type SseTransportPolicyOverride, type SseTransportProfile, SseTransportTerminalError, StepCard, SubAgentBlock, SystemSummaryAccumulator, SystemSummaryNode, Task, TaskList, TaskListFooter, TextBubble, TierOverrides, Timeline, TimelineItem, ToolBodyMode, ToolCallCard, ToolDisplayRegistry, ToolProjectionClassifier, UnknownCard, WORKFLOW_STRUCTURE_EVENT_PREFIXES, WORKFLOW_STRUCTURE_EVENT_TYPES, WebFetch, WebSearch, type WorkflowAuthoritySnapshot, type WorkflowAuthoritySource, type WorkflowAuthorityStatus, type WorkflowBannerDescriptor, WorkflowChrome, type WorkflowChromeProps, type WorkflowCoalescedBlock, type WorkflowDisplayProjection, type WorkflowDisplayProjectionStatus, type WorkflowDisplaySnapshot, type WorkflowDisplaySnapshotMetadata, type WorkflowLoopReplayHandler, WorkflowLoopReplayProvider, type WorkflowProgressState, WorkflowScaleContext, type WorkflowScaleOptions, type WorkflowScopeFrame, WorkflowSession, type WorkflowSessionProps, type WorkflowSessionState, type WorkflowSessionStore, type WorkflowSessionStoreOptions, type WorkflowSessionStoreState, type WorkflowSnapshotProjectionStatus, type WorkflowStageProgress, WorkflowTaskListFooter, type WorkflowTerminalKind, Write, applyAuthoritySnapshotToState, buildCanonicalFromTree, buildRelevantMemoriesCanonical, buildResumeStreamUrl, buildSystemEventCanonical, buildTimelineEntries, classifyEvent, commandAsHint, computeViewportFitTransform, configureMermaid, configurePlantumlServer, createAgentxSseSource, createControllableAuthoritySource, createDefaultRegistry, createDoneAuthoritySource, createEmptyWorkflowSessionState, createMockAuthoritySource, createMockSource, createPollingAuthoritySource, createReplaySource, createRunningAuthoritySource, createWorkflowSessionStore, deriveLoopSessionIdFromAgentEvent, entryKey, filterAgentLoopReplayEvents, finalizeWorkflowDisplayOnStreamEnded, fixDiagramSvg, formatAgentTitle, formatExploreSummaryText, formatHookFinishedSummary, formatShellProgressSuffix, formatTaskFooterLabel, getChildIds, getDisplayProjectionStatus, getMainStageIds, hydrateWorkflowFromSnapshot, isAgentLoopReplayEventType, isAtOrBeforeProjectionCursor, isAuthorityTerminal, isAuthorityTerminalStatus, isGitOperationCommand, isGroupableToolName, isMcpToolName, isSseStreamTerminalEvent, isWorkflowStructureEventType, iterMountCandidates, partitionWorkflowStages, projectCanonical, projectTimeline, reduceAgentLoopEvent, reduceEvents, reduceTree, reduceWorkflowEvents, reduceWorkflowSession, replayEvents, replayTree, resolveEventTier, resolveResponseId, resolveShellProgressFromPayload, resolveSseTransportPolicy, resolveWorkflowBanner, shouldShowGlobalSpinner, shouldShowTaskListFooter, streamChunk, useChildren, useInteractionBus, useInternalErrors, useMinDisplayTime, useNode, useNodeTyped, useProjectedTimeline, useReplayTree, useSessionMeta, useSessionStatus, useTimeline, useWorkflowSessionStatus, useWorkflowSessionStoreApi };
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  fixDiagramSvg,
24
24
  markEventIdSeen,
25
25
  shouldSkipDuplicateEvent
26
- } from "./chunk-CUKNUCGU.js";
26
+ } from "./chunk-ISQ7JWGD.js";
27
27
  import {
28
28
  DefaultToolBody,
29
29
  InteractionBusContext,
@@ -32,8 +32,8 @@ import {
32
32
  getNoopInteractionBus,
33
33
  resolveToolBody,
34
34
  useInteractionBus
35
- } from "./chunk-6DYISADG.js";
36
- import "./chunk-DP7V33X7.js";
35
+ } from "./chunk-TCKOXX7O.js";
36
+ import "./chunk-6Z4ZF36Z.js";
37
37
  import {
38
38
  CollapseKind,
39
39
  CollapsedExploreNode,
@@ -72,7 +72,6 @@ import {
72
72
  createEmptyTree,
73
73
  createProjectionContext,
74
74
  entryKey,
75
- formatExploreSummaryText,
76
75
  formatHookFinishedSummary,
77
76
  formatShellProgressSuffix,
78
77
  formatTaskFooterLabel,
@@ -111,7 +110,7 @@ import {
111
110
  useSessionStatus,
112
111
  useSessionViewOptions,
113
112
  useTimeline
114
- } from "./chunk-SUEMZC4U.js";
113
+ } from "./chunk-6ORA5RMV.js";
115
114
  import {
116
115
  Agent,
117
116
  AgentToolBody,
@@ -137,8 +136,9 @@ import {
137
136
  Write,
138
137
  WriteToolBody,
139
138
  createDefaultToolRegistry,
140
- formatAgentTitle
141
- } from "./chunk-7CLAU74Y.js";
139
+ formatAgentTitle,
140
+ formatExploreSummaryText
141
+ } from "./chunk-FL2G7SV3.js";
142
142
  import {
143
143
  BodyBlockList,
144
144
  DiffView,
@@ -154,7 +154,7 @@ import {
154
154
  formatTimeoutFooter,
155
155
  parseDiffText,
156
156
  truncateCommand
157
- } from "./chunk-4RIOBLGB.js";
157
+ } from "./chunk-GBY5DJ7L.js";
158
158
 
159
159
  // src/view/AgentSession.tsx
160
160
  import { useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
@@ -184,7 +184,8 @@ function safeReduce(tree, event, eventIndex, options) {
184
184
  function createSessionStore(initialTree = createEmptyTree(), storeOptions) {
185
185
  const reduceOpts = {
186
186
  tierOverrides: storeOptions?.tierOverrides,
187
- collectDebug: storeOptions?.debug === true
187
+ collectDebug: storeOptions?.debug === true,
188
+ subagentLeakGate: storeOptions?.subagentLeakGate === true
188
189
  };
189
190
  const initialEventCount = storeOptions?.initialEventCount ?? 0;
190
191
  const seenEventIds = new Set(storeOptions?.initialSeenEventIds);
@@ -317,6 +318,15 @@ var PROFILE_PRESETS = {
317
318
  ...BOUNDED_DEFAULTS
318
319
  },
319
320
  terminal: WORKFLOW_TERMINAL_WITH_FALLBACK
321
+ },
322
+ "workflow-tail": {
323
+ profile: "workflow-tail",
324
+ replay: "none",
325
+ reconnect: {
326
+ mode: "bounded",
327
+ ...BOUNDED_DEFAULTS
328
+ },
329
+ terminal: WORKFLOW_TERMINAL_WITH_FALLBACK
320
330
  }
321
331
  };
322
332
  function legacyTerminal(expectedApplicationKind) {
@@ -778,19 +788,22 @@ function AgentSession({
778
788
  exploreFullscreenBash = true,
779
789
  memoryDir = null,
780
790
  workspaceRoot = null,
791
+ subagentLeakGate = false,
781
792
  children
782
793
  }) {
783
794
  const storeRef = useRef2(null);
784
795
  if (storeRef.current === null) {
785
796
  const replayOpts = {
786
797
  tierOverrides: _tierOverrides,
787
- collectDebug: debug
798
+ collectDebug: debug,
799
+ subagentLeakGate
788
800
  };
789
801
  const initialTree = initialEvents && initialEvents.length > 0 ? replayEvents(initialEvents, replayOpts) : void 0;
790
802
  storeRef.current = createSessionStore(initialTree, {
791
803
  tierOverrides: _tierOverrides,
792
804
  debug,
793
- initialEventCount: initialEvents?.length ?? 0
805
+ initialEventCount: initialEvents?.length ?? 0,
806
+ subagentLeakGate
794
807
  });
795
808
  }
796
809
  const registryRef = useMemo(() => registry ?? createDefaultRegistry(), [registry]);
@@ -815,7 +828,8 @@ function AgentSession({
815
828
  verbose,
816
829
  exploreFullscreenBash,
817
830
  memoryDir,
818
- workspaceRoot
831
+ workspaceRoot,
832
+ subagentLeakGate
819
833
  }),
820
834
  [
821
835
  groupParallelTools,
@@ -825,7 +839,8 @@ function AgentSession({
825
839
  verbose,
826
840
  exploreFullscreenBash,
827
841
  memoryDir,
828
- workspaceRoot
842
+ workspaceRoot,
843
+ subagentLeakGate
829
844
  ]
830
845
  );
831
846
  const onErrorRef = useRef2(onError);
@@ -901,10 +916,19 @@ function resolveWorkflowBanner(state) {
901
916
  if (state.display.authoritySyncFailed) {
902
917
  return { kind: "sync_failed", message: "\u540C\u6B65\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u5237\u65B0" };
903
918
  }
919
+ const auth = state.authority?.status;
920
+ if (auth === "error") {
921
+ return { kind: "authority_error", message: "Workflow \u6267\u884C\u5931\u8D25" };
922
+ }
923
+ if (state.snapshotHydrateFailed) {
924
+ return {
925
+ kind: "snapshot_unavailable",
926
+ message: "\u65E0\u6CD5\u52A0\u8F7D projection snapshot\uFF0C\u5C55\u793A\u53EF\u80FD\u4E0D\u5B8C\u6574"
927
+ };
928
+ }
904
929
  if (state.display.awaitingAuthority) {
905
930
  return { kind: "awaiting_authority", message: "\u6536\u5C3E\u4E2D\u2026" };
906
931
  }
907
- const auth = state.authority?.status;
908
932
  if (auth === "partial_success") {
909
933
  const forced = state.display.terminalKind === "forced_closeout";
910
934
  return {
@@ -912,6 +936,15 @@ function resolveWorkflowBanner(state) {
912
936
  message: forced ? "\u90E8\u5206\u5B8C\u6210\uFF08\u90E8\u5206\u5BB9\u5668\u672A\u6B63\u5E38\u7ED3\u675F\uFF09" : "\u90E8\u5206\u5B8C\u6210\uFF08\u6240\u6709\u5BB9\u5668\u6B63\u5E38\u7ED3\u675F\uFF09"
913
937
  };
914
938
  }
939
+ const meta = state.authority?.metadata;
940
+ if (auth === "done" && meta?.projection_status === "degraded") {
941
+ const dropped = meta.projection_dropped_count;
942
+ const suffix = dropped != null && dropped > 0 ? `\uFF08\u7EA6 ${dropped} \u6761\u4E8B\u4EF6\u672A\u5B8C\u6574\u5C55\u793A\uFF09` : "";
943
+ return {
944
+ kind: "projection_degraded",
945
+ message: `\u5C55\u793A\u53EF\u80FD\u4E0D\u5B8C\u6574${suffix}`
946
+ };
947
+ }
915
948
  if (state.display.terminalKind === "forced_closeout" && auth === "done") {
916
949
  return { kind: "forced_closeout", message: "Workflow \u5DF2\u7ED3\u675F\uFF08\u90E8\u5206\u5BB9\u5668\u672A\u6B63\u5E38\u5173\u95ED\uFF09" };
917
950
  }
@@ -1031,6 +1064,10 @@ function createEmptyWorkflowSessionState() {
1031
1064
  stageDoneSummariesByContainerId: {},
1032
1065
  hotCompletedLoopSessionIds: [],
1033
1066
  activeLoopSessionId: null,
1067
+ projectionCursor: null,
1068
+ snapshotVersion: null,
1069
+ reconnectSuppressedReason: null,
1070
+ snapshotHydrateFailed: false,
1034
1071
  openScopeStack: [],
1035
1072
  internalErrors: []
1036
1073
  };
@@ -2753,6 +2790,41 @@ function reduceWorkflowEvents(events, options) {
2753
2790
  );
2754
2791
  }
2755
2792
 
2793
+ // src/core/workflow/hydrateWorkflowSnapshot.ts
2794
+ function isAtOrBeforeProjectionCursor(projectionCursor, eventId) {
2795
+ if (!projectionCursor || !eventId) return false;
2796
+ const cursorNum = Number.parseInt(projectionCursor, 10);
2797
+ const eventNum = Number.parseInt(eventId, 10);
2798
+ if (!Number.isNaN(cursorNum) && !Number.isNaN(eventNum)) {
2799
+ return eventNum <= cursorNum;
2800
+ }
2801
+ return eventId <= projectionCursor;
2802
+ }
2803
+ function hydrateWorkflowFromSnapshot(state, snapshot, options = {}) {
2804
+ const authority = options.preserveAuthority ? state.authority : null;
2805
+ return {
2806
+ ...createEmptyWorkflowSessionState(),
2807
+ authority,
2808
+ display: {
2809
+ ...snapshot.display,
2810
+ streamEnded: false
2811
+ },
2812
+ containerTree: structuredClone(snapshot.containerTree),
2813
+ projectionCursor: snapshot.cursor,
2814
+ snapshotVersion: snapshot.snapshotVersion,
2815
+ meta: {
2816
+ ...state.meta,
2817
+ workflowRunId: snapshot.taskId,
2818
+ lastEventId: snapshot.cursor,
2819
+ startedAt: state.meta.startedAt ?? snapshot.capturedAt
2820
+ },
2821
+ loopTreesBySessionId: {},
2822
+ internalErrors: [],
2823
+ reconnectSuppressedReason: null,
2824
+ snapshotHydrateFailed: false
2825
+ };
2826
+ }
2827
+
2756
2828
  // src/core/workflowSessionStore.ts
2757
2829
  var DEFAULT_HYDRATE_CHUNK_SIZE = 50;
2758
2830
  function nextAnimationFrame() {
@@ -2841,8 +2913,12 @@ function createWorkflowSessionStore(initialState = createEmptyWorkflowSessionSta
2841
2913
  hydratingLoopSessionIds: {},
2842
2914
  applyEvent(event, ctx) {
2843
2915
  const sseEventId = ctx?.sseEventId;
2844
- if (shouldSkipDuplicateEvent(seenEventIds, sseEventId)) return;
2845
2916
  const { state, eventCount } = get();
2917
+ if (isAtOrBeforeProjectionCursor(state.projectionCursor, sseEventId)) {
2918
+ markEventIdSeen(seenEventIds, sseEventId);
2919
+ return;
2920
+ }
2921
+ if (shouldSkipDuplicateEvent(seenEventIds, sseEventId)) return;
2846
2922
  const { state: reduced } = safeReduceWorkflow(state, event, eventCount, reduceOpts);
2847
2923
  const evicted = finalizeState(reduced);
2848
2924
  const nextMeta = sseEventId ? { ...evicted.meta, lastEventId: sseEventId } : evicted.meta;
@@ -3039,6 +3115,23 @@ function createWorkflowSessionStore(initialState = createEmptyWorkflowSessionSta
3039
3115
  loopSessionId
3040
3116
  )
3041
3117
  }));
3118
+ },
3119
+ hydrateFromSnapshot(snapshot, options) {
3120
+ const { state } = get();
3121
+ const next = finalizeState(
3122
+ hydrateWorkflowFromSnapshot(state, snapshot, options)
3123
+ );
3124
+ markEventIdSeen(seenEventIds, snapshot.cursor);
3125
+ set({ state: next });
3126
+ },
3127
+ markSnapshotHydrateFailed() {
3128
+ set((current) => ({
3129
+ state: {
3130
+ ...current.state,
3131
+ snapshotHydrateFailed: true,
3132
+ reconnectSuppressedReason: "snapshot_unavailable"
3133
+ }
3134
+ }));
3042
3135
  }
3043
3136
  }));
3044
3137
  }
@@ -4642,7 +4735,35 @@ function WorkflowSessionBanners({ state }) {
4642
4735
  if (banner.kind === "none" && display.projectionStatus !== "error" && display.projectionStatus !== "done_with_warning" && state.internalErrors.length === 0) {
4643
4736
  return null;
4644
4737
  }
4738
+ const showTransportError = (display.projectionStatus === "error" || state.internalErrors.length > 0) && banner.kind !== "projection_degraded" && banner.kind !== "authority_error";
4645
4739
  return /* @__PURE__ */ jsxs12(Fragment3, { children: [
4740
+ banner.kind === "authority_error" ? /* @__PURE__ */ jsx17(
4741
+ "div",
4742
+ {
4743
+ className: "lax-workflow-banner lax-workflow-banner--authority-error",
4744
+ "data-testid": "lax-workflow-authority-error-banner",
4745
+ role: "alert",
4746
+ children: banner.message
4747
+ }
4748
+ ) : null,
4749
+ banner.kind === "projection_degraded" ? /* @__PURE__ */ jsx17(
4750
+ "div",
4751
+ {
4752
+ className: "lax-workflow-banner lax-workflow-banner--projection-degraded",
4753
+ "data-testid": "lax-workflow-projection-degraded-banner",
4754
+ role: "status",
4755
+ children: banner.message
4756
+ }
4757
+ ) : null,
4758
+ banner.kind === "snapshot_unavailable" ? /* @__PURE__ */ jsx17(
4759
+ "div",
4760
+ {
4761
+ className: "lax-workflow-banner lax-workflow-banner--snapshot-unavailable",
4762
+ "data-testid": "lax-workflow-snapshot-unavailable-banner",
4763
+ role: "status",
4764
+ children: banner.message
4765
+ }
4766
+ ) : null,
4646
4767
  banner.kind === "partial_success" ? /* @__PURE__ */ jsx17(
4647
4768
  "div",
4648
4769
  {
@@ -4686,7 +4807,7 @@ function WorkflowSessionBanners({ state }) {
4686
4807
  children: banner.message
4687
4808
  }
4688
4809
  ) : null,
4689
- display.projectionStatus === "error" || state.internalErrors.length > 0 ? /* @__PURE__ */ jsx17(
4810
+ showTransportError ? /* @__PURE__ */ jsx17(
4690
4811
  "div",
4691
4812
  {
4692
4813
  className: "lax-workflow-error",
@@ -4825,6 +4946,8 @@ import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
4825
4946
  function WorkflowSession({
4826
4947
  source,
4827
4948
  authoritySource,
4949
+ snapshotBootstrap,
4950
+ snapshotHydrateFailed = false,
4828
4951
  initialEvents,
4829
4952
  registry,
4830
4953
  tierOverrides,
@@ -4863,6 +4986,16 @@ function WorkflowSession({
4863
4986
  const streamEnded = useStore5(store, (s) => s.state.display.streamEnded);
4864
4987
  const authorityStatus = useStore5(store, (s) => s.state.authority?.status);
4865
4988
  useWorkflowAwaitingAuthorityTimers(store, streamEnded, authorityStatus);
4989
+ useEffect10(() => {
4990
+ if (snapshotBootstrap) {
4991
+ store.getState().hydrateFromSnapshot(snapshotBootstrap, { preserveAuthority: true });
4992
+ }
4993
+ }, [snapshotBootstrap, store]);
4994
+ useEffect10(() => {
4995
+ if (snapshotHydrateFailed) {
4996
+ store.getState().markSnapshotHydrateFailed();
4997
+ }
4998
+ }, [snapshotHydrateFailed, store]);
4866
4999
  const scaleOptions = useMemo9(
4867
5000
  () => ({ ...DEFAULT_WORKFLOW_SCALE_OPTIONS, ...workflowScale }),
4868
5001
  [workflowScale]
@@ -4905,10 +5038,13 @@ function WorkflowSession({
4905
5038
  const loopTreesBySessionId = sessionState.loopTreesBySessionId;
4906
5039
  const onErrorRef = useRef4(onError);
4907
5040
  const onDisplayStreamEndedRef = useRef4(onDisplayStreamEnded);
5041
+ const streamAbortRef = useRef4(null);
4908
5042
  onErrorRef.current = onError;
4909
5043
  onDisplayStreamEndedRef.current = onDisplayStreamEnded;
4910
5044
  useEffect10(() => {
5045
+ if (!source) return void 0;
4911
5046
  const controller = new AbortController();
5047
+ streamAbortRef.current = controller;
4912
5048
  void source.start((event, ctx) => {
4913
5049
  store.getState().applyEvent(event, ctx);
4914
5050
  }, controller.signal).then(() => {
@@ -4924,8 +5060,14 @@ function WorkflowSession({
4924
5060
  });
4925
5061
  return () => {
4926
5062
  controller.abort();
5063
+ streamAbortRef.current = null;
4927
5064
  };
4928
5065
  }, [source, store]);
5066
+ useEffect10(() => {
5067
+ if (isAuthorityTerminalStatus(authorityStatus)) {
5068
+ streamAbortRef.current?.abort();
5069
+ }
5070
+ }, [authorityStatus]);
4929
5071
  return /* @__PURE__ */ jsx19(WorkflowSessionStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx19(WorkflowScaleContext.Provider, { value: scaleOptions, children: /* @__PURE__ */ jsx19(WorkflowLoopReplayProvider, { onRequestLoopReplay, children: /* @__PURE__ */ jsx19(InteractionBusContext.Provider, { value: busRef, children: /* @__PURE__ */ jsx19(NodeRegistryContext.Provider, { value: registryRef, children: /* @__PURE__ */ jsx19(MarkdownRendererContext.Provider, { value: markdownRenderer, children: /* @__PURE__ */ jsx19(ToolDisplayOptionsContext.Provider, { value: toolDisplayRef, children: /* @__PURE__ */ jsx19(SessionViewOptionsContext.Provider, { value: sessionViewRef, children: /* @__PURE__ */ jsxs14(
4930
5072
  "div",
4931
5073
  {
@@ -5315,7 +5457,9 @@ export {
5315
5457
  getDisplayProjectionStatus,
5316
5458
  getMainStageIds,
5317
5459
  getNoopInteractionBus,
5460
+ hydrateWorkflowFromSnapshot,
5318
5461
  isAgentLoopReplayEventType,
5462
+ isAtOrBeforeProjectionCursor,
5319
5463
  isAuthorityTerminal,
5320
5464
  isAuthorityTerminalStatus,
5321
5465
  isGitOperationCommand,