@blade-hq/agent-react 2610.0.0-beta.70 → 2610.0.0-beta.72

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.
Files changed (30) hide show
  1. package/README.md +160 -5
  2. package/dist/{chunk-MAAMCOAU.js → chunk-IA6J2NTB.js} +4 -3
  3. package/dist/components/AgentLoopBlock.d.ts +2 -1
  4. package/dist/components/AskUserQuestionBlock.d.ts +3 -1
  5. package/dist/components/AssistantTurnBlock.d.ts +8 -4
  6. package/dist/components/ChatInput.d.ts +7 -1
  7. package/dist/components/ChatSurface.d.ts +105 -1
  8. package/dist/components/ChatView.d.ts +1 -1
  9. package/dist/components/MessageList.d.ts +13 -4
  10. package/dist/components/PlanUpdateBlock.d.ts +2 -1
  11. package/dist/components/PostChatFollowupBlock.d.ts +5 -1
  12. package/dist/components/ToolCallBlock.d.ts +6 -2
  13. package/dist/components/TurnNavRail.d.ts +23 -0
  14. package/dist/components/UserMessageBubble.d.ts +6 -2
  15. package/dist/embed/blade-chat-element.d.ts +4 -3
  16. package/dist/embed/entry.d.ts +2 -0
  17. package/dist/{highlighted-body-B3W2YXNL-IASCZDV2.js → highlighted-body-B3W2YXNL-YF4GVJGP.js} +2 -2
  18. package/dist/hooks/use-turn-navigation.d.ts +117 -0
  19. package/dist/index.d.ts +6 -1
  20. package/dist/index.js +1911 -1176
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/utils.d.ts +15 -2
  23. package/dist/{mermaid-3ZIDBTTL-BPVVWTVV.js → mermaid-3ZIDBTTL-QL4YGD6I.js} +2 -2
  24. package/dist/style.css +488 -494
  25. package/dist/style.full.css +499 -498
  26. package/package.json +2 -2
  27. package/public-api.md +329 -4
  28. /package/dist/{chunk-MAAMCOAU.js.map → chunk-IA6J2NTB.js.map} +0 -0
  29. /package/dist/{highlighted-body-B3W2YXNL-IASCZDV2.js.map → highlighted-body-B3W2YXNL-YF4GVJGP.js.map} +0 -0
  30. /package/dist/{mermaid-3ZIDBTTL-BPVVWTVV.js.map → mermaid-3ZIDBTTL-QL4YGD6I.js.map} +0 -0
@@ -18,6 +18,7 @@ declare function getChat(element: Element | null): Promise<AgentSession>;
18
18
  declare const BladeAgent: {
19
19
  BladeClient: typeof agentClient.BladeClient;
20
20
  BladeApiError: typeof agentClient.BladeApiError;
21
+ isEntryGoneError: typeof agentClient.isEntryGoneError;
21
22
  PollingBackoff: typeof agentClient.PollingBackoff;
22
23
  EMPTY_PLATFORM_ENDPOINTS: agentClient.PlatformEndpoints;
23
24
  loadPlatformEndpoints: typeof agentClient.loadPlatformEndpoints;
@@ -55,6 +56,7 @@ declare const BladeAgent: {
55
56
  ChatGroupsResource: typeof agentClient.ChatGroupsResource;
56
57
  PluginsResource: typeof agentClient.PluginsResource;
57
58
  hasChatRunEvent: typeof agentClient.hasChatRunEvent;
59
+ inferToolStatus: typeof agentClient.inferToolStatus;
58
60
  buildMessageContent: typeof agentClient.buildMessageContent;
59
61
  chatErrorForDisplay: typeof agentClient.chatErrorForDisplay;
60
62
  contentPreview: typeof agentClient.contentPreview;
@@ -3,7 +3,7 @@ import {
3
3
  Ks,
4
4
  Qe,
5
5
  R
6
- } from "./chunk-MAAMCOAU.js";
6
+ } from "./chunk-IA6J2NTB.js";
7
7
  import "./chunk-G3PMV62Z.js";
8
8
 
9
9
  // ../../node_modules/.pnpm/streamdown@2.3.0_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/streamdown/dist/highlighted-body-B3W2YXNL.js
@@ -25,4 +25,4 @@ var L = ({ code: s, language: t, raw: e, className: n, ...d$1 }) => {
25
25
  export {
26
26
  L as HighlightedCodeBlockBody
27
27
  };
28
- //# sourceMappingURL=highlighted-body-B3W2YXNL-IASCZDV2.js.map
28
+ //# sourceMappingURL=highlighted-body-B3W2YXNL-YF4GVJGP.js.map
@@ -0,0 +1,117 @@
1
+ import { type ChatMessage, type SessionTurnIndexItem, type TurnProjection } from "@blade-hq/agent-client";
2
+ /** 高亮用的类名。样式在 agent-react 的 style.css 与内置 Web 的 app.css 各有一份。 */
3
+ export declare const TURN_NAV_HIGHLIGHT_CLASS = "blade-turn-nav-flash";
4
+ /**
5
+ * 消息导航的数据源:宿主把"目录从哪来""定位怎么发"接给共享时序。
6
+ *
7
+ * SDK 的 AgentChat 用 `AgentSession.loadTurnIndex` / `locateEntry`;内置 Web 用
8
+ * 自己的 store。没有会话目录的宿主(例如分享页)只传 `locateEntry` 与兜底条目。
9
+ */
10
+ /** 刻度轨的一条:稳定 entry id + 标题。内置 Web 的同名类型形状一致。 */
11
+ export interface TurnNavItem {
12
+ id: string;
13
+ title: string;
14
+ }
15
+ export interface TurnNavigationSource {
16
+ /** 目录来源;不传就不请求目录,导航条目只由 `fallbackItems` 兜底。 */
17
+ loadTurnIndex?: () => Promise<SessionTurnIndexItem[]>;
18
+ /** 定位:服务端返回"从这条发言到最新"的窗口并整窗替换。成功返回 true。 */
19
+ locateEntry: (entryId: string) => Promise<boolean>;
20
+ /**
21
+ * 取消在途定位。每次新的选择都会先调它每次新的选择都会先调它:用户改点一条**已加载**的发言时不发定位请求,
22
+ * 前一次在途的定位却已经发出去了——不取消的话它晚回来照样换窗口,把用户刚选中的
23
+ * 那一段换掉。
24
+ */
25
+ cancelPendingLocate?: () => void;
26
+ /**
27
+ * 目录刷新信号:会话里最新的用户发言变了(新发言、乐观发言被服务端确认)。
28
+ *
29
+ * 只认**最新一条**发言:往上翻页会补进更早的发言,用"窗口里全部发言"当信号的话,
30
+ * 正在进行的定位会被自己触发的刷新作废——翻页成功了却不滚动,要再点一次。
31
+ */
32
+ reloadKey?: number | string | null;
33
+ /**
34
+ * timeline 被**外部**整体重写(rewind / checkout / 修复重载)时变化。与 `reloadKey`
35
+ * 的区别是语义:`reloadKey` 变化只是「可能变了」,刷新期间先照旧显示;这里变化一定是
36
+ * 旧目录作废,旧条目必须立刻丢掉——它们的 entry id 可能已经不在 timeline 上了。
37
+ *
38
+ * 必须只由外部改写推进:定位自己换窗口同样会推进"窗口世代",拿它当信号会把正在进行的
39
+ * 那次定位当场作废(点了没反应,要再点一次)。内置 Web 用 store 的
40
+ * `historyRewriteRevision`,SDK 用会话的 `rewind` 事件。
41
+ */
42
+ rewriteKey?: number | string | null;
43
+ /**
44
+ * 目录拿不到时的兜底条目。
45
+ *
46
+ * 分享页的历史本来就是整份加载的:它没有会话目录接口,导航条目直接由已加载的
47
+ * 发言推出来。这只覆盖"整份都在窗口里"的场景,长会话不能拿它代替目录。
48
+ */
49
+ fallbackItems?: TurnNavItem[];
50
+ }
51
+ /** 共享时序还要知道"怎么在宿主自己的列表里找到那一行"。 */
52
+ export interface TurnNavigationOptions extends TurnNavigationSource {
53
+ /** 当前会话;变了就丢弃在途的定位结果、目录和高亮。 */
54
+ sessionId?: string | null;
55
+ /** 已加载窗口里该发言的行;不在当前列表里返回 null。 */
56
+ getLoadedEntryElement: (entryId: string) => HTMLElement | null;
57
+ /**
58
+ * 这条发言在不在已加载窗口里(哪怕它的行因为虚拟列表还没挂出来)。
59
+ *
60
+ * 没有它就只能拿"DOM 里有没有这一行"当"加载没加载":长会话里滚出挂载范围的旧发言
61
+ * 会被当成窗口外,白白发一次定位请求(分享页更糟——那里根本没有定位接口)。不传则
62
+ * 退回只看 DOM。
63
+ */
64
+ isEntryLoaded?: (entryId: string) => boolean;
65
+ /**
66
+ * 已加载但还没进 DOM 的行(虚拟列表)——让宿主先把目标挂出来,下一帧
67
+ * `getLoadedEntryElement` 就能查到。宿主没有虚拟列表时不用传。
68
+ */
69
+ revealEntry?: (entryId: string) => void;
70
+ /**
71
+ * 开始定位前的一次性钩子:宿主在这里放弃自己的滚动控制(新轮置顶动画、
72
+ * 「跟随到底」),否则它们会继续写 `scrollTop`,把视口从目标行上拽走。
73
+ */
74
+ beforeSeek?: (entryId: string) => void;
75
+ }
76
+ /**
77
+ * 目录刷新信号:窗口里**最后一条**用户发言的稳定 id。
78
+ *
79
+ * 与内置 Web 的 `latestUserSpeechEntryId`(message-list-blocks.ts)同一判据、同一
80
+ * 名称,输入不同:那边拿渲染好的消息,这边拿投影轮。两边都只认"最新一条",因为
81
+ * 往前翻页补进的更早发言不改变目录的结尾,用"窗口里全部发言"当信号会把正在进行的
82
+ * 定位判成过期。
83
+ *
84
+ * AskUserQuestion 的回答在消息列表里也渲染成用户发言,所以带回答标记的轮同样算一条。
85
+ */
86
+ export declare function latestUserSpeechEntryId(turns: TurnProjection[]): string | null;
87
+ /**
88
+ * 从已加载的消息推出轨道条目:给没有目录接口的宿主(分享页、静态会话)兜底。
89
+ *
90
+ * 判据与内置 Web 的 `MessageList` 一致:根循环里渲染成用户发言的消息、排除内部提示,
91
+ * 标题按服务端目录同一口径截断。**不能**拿它代替长会话的目录——窗口里没有更早的发言。
92
+ */
93
+ export declare function turnNavItemsFromMessages(messages: ChatMessage[]): TurnNavItem[];
94
+ export interface TurnNavigationResult {
95
+ /** 当前会话的用户发言目录。 */
96
+ items: TurnNavItem[];
97
+ /** 正在请求定位的那条发言;请求结束就清空。 */
98
+ loadingEntryId: string | null;
99
+ /** 上一条定位失败的提示;点下一条时清空。 */
100
+ error: string | null;
101
+ /** 定位失败的那条发言:重试就是再点它一次。 */
102
+ failedEntryId: string | null;
103
+ /** 最后一条被定位(或正在定位)的发言,用来给刻度轨选中态。 */
104
+ activeEntryId: string | null;
105
+ selectEntry: (entryId: string) => void;
106
+ }
107
+ /**
108
+ * 用户发言的跨页定位:滚动、加载状态、高亮三件事的唯一实现,内置 Web 与 SDK
109
+ * 共用同一份时序。
110
+ *
111
+ * 点已加载的发言:不请求任何东西,直接滚动 + 高亮。点窗口外的发言:发一次定位请求
112
+ * (服务端返回"从它到最新"的窗口),等 React 提交、目标行挂出来再滚动 + 高亮;
113
+ * 请求失败或行始终没出现就报一句可重试的提示,**不动滚动位置**。
114
+ *
115
+ * 会话切换、历史被整体重写、或用户点了下一条时,在途结果一律丢弃。
116
+ */
117
+ export declare function useTurnNavigation({ sessionId, getLoadedEntryElement, isEntryLoaded, locateEntry, cancelPendingLocate, loadTurnIndex, fallbackItems, revealEntry, beforeSeek, reloadKey, rewriteKey, }: TurnNavigationOptions): TurnNavigationResult;
package/dist/index.d.ts CHANGED
@@ -9,9 +9,13 @@ export { useMessagePin } from "./hooks/use-message-pin";
9
9
  export type { UseMessagePinOptions } from "./hooks/use-message-pin";
10
10
  export { useTypewriterReveal } from "./hooks/use-typewriter-reveal";
11
11
  export type { UseTypewriterRevealResult } from "./hooks/use-typewriter-reveal";
12
+ export { latestUserSpeechEntryId, TURN_NAV_HIGHLIGHT_CLASS, turnNavItemsFromMessages, useTurnNavigation, } from "./hooks/use-turn-navigation";
13
+ export type { TurnNavigationOptions, TurnNavigationResult, TurnNavigationSource, } from "./hooks/use-turn-navigation";
14
+ export { TurnNavRail } from "./components/TurnNavRail";
15
+ export type { TurnNavRailProps } from "./components/TurnNavRail";
12
16
  export type { ChatCompletionTool, LlmChatOptions, LlmToolCall, UseLlmChatResult, } from "./hooks/use-llm-chat";
13
17
  export { ChatView } from "./components/ChatView";
14
- export type { ChatViewClassNames, ChatViewProps, ChatViewRenderers, ChatViewSlots, FollowupInteractionEvent, } from "./components/ChatView";
18
+ export type { AssistantTextRendererProps, AskUserQuestionRendererProps, ChatViewClassNames, ChatViewProps, ChatViewRenderers, ChatViewSlots, FollowupInteractionEvent, PlanUpdateRendererProps, UserMessageRendererProps, } from "./components/ChatView";
15
19
  export { ConnectorPanel } from "./components/ConnectorPanel";
16
20
  export type { ConnectorPanelProps } from "./components/ConnectorPanel";
17
21
  export { PluginConnectorList } from "./components/PluginConnectorList";
@@ -55,6 +59,7 @@ export { ContextCard, ContextGroupCard } from "./components/ContextCard";
55
59
  export type { ContextCardProps, ContextGroupCardProps } from "./components/ContextCard";
56
60
  export { collectMemoryRefs, MemoryRefsHint } from "./components/AssistantTurnBlock";
57
61
  export { ToolUiCardView } from "./components/ToolUiCardView";
62
+ export type { AskUserQuestionData } from "./components/AskUserQuestionBlock";
58
63
  export { McpAppCard } from "./components/McpAppCard";
59
64
  export type { McpAppMessage } from "./components/McpAppCard";
60
65
  export { SessionMemoryToggle } from "./components/SessionMemoryToggle";