@blade-hq/agent-react 2610.0.0-beta.30 → 2610.0.0-beta.31
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/README.md +18 -2
- package/dist/components/ContextCard.d.ts +13 -0
- package/dist/components/MarkdownContent.d.ts +2 -0
- package/dist/components/UserMessageBubble.d.ts +1 -1
- package/dist/components/WhatIfUserBubble.d.ts +7 -0
- package/dist/embed/entry.d.ts +2 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +238 -94
- package/dist/index.js.map +1 -1
- package/dist/lib/whatif-prompt.d.ts +18 -0
- package/dist/style.css +12 -1
- package/dist/style.full.css +13 -2
- package/package.json +2 -2
- package/public-api.md +76 -2
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ await replay.exitToAutonomous() // 退出回放,之后真的运
|
|
|
156
156
|
|
|
157
157
|
全部 props 见 `ChatViewProps`。样式说明:
|
|
158
158
|
|
|
159
|
-
`ChatView` 的普通展示模式不显示只供诊断的项目说明、可用能力和当前工作环境。需要自建诊断界面时,可直接使用独立的 `ContextCard`,属性见 `ContextCardProps`;状态到文案的映射来自 agent-client 的 `getContextDisplayState
|
|
159
|
+
`ChatView` 的普通展示模式不显示只供诊断的项目说明、可用能力和当前工作环境。需要自建诊断界面时,可直接使用独立的 `ContextCard`,属性见 `ContextCardProps`;状态到文案的映射来自 agent-client 的 `getContextDisplayState`,不需要接入方重复判断。一次输入通常会同时注入十几项上下文,把渲染序列里连续的几项用 `ContextGroupCard`(属性见 `ContextGroupCardProps`)折成一行更合适;哪几项算一组由 agent-client 的 `groupAdjacentContextRuns` 判定,折叠行文案来自 `getContextGroupDisplayState` / `ContextGroupDisplayState`。底层数据类型为 `ContextProjectionData` / `ContextProjectionFields`,展示结果为 `ContextDisplayState`,并保留 `ContextAction`、`ContextSourceInfo` 和 `contextProjectionData` 给 headless 消费方。
|
|
160
160
|
|
|
161
161
|
记忆引用提示可通过 `MemoryRefsHint` 展示,`collectMemoryRefs` 用于从一轮消息中聚合引用,保证宿主自定义消息布局与 SDK 默认界面保持一致。
|
|
162
162
|
|
|
@@ -272,6 +272,22 @@ models.filter((m) => m.serviceModelId)
|
|
|
272
272
|
<MarkdownContent sessionId={sessionId}>{markdownText}</MarkdownContent>
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
+
`normalizeAdjacentUrlFormatting` 可在复用其他 Markdown 渲染器前,保护紧贴行内格式标记的 URL。
|
|
276
|
+
|
|
277
|
+
## Canonical 引用消息
|
|
278
|
+
|
|
279
|
+
`ChatView` 会自动识别 ship-attack 会话中的 `[引用]` / `[用户输入]` canonical
|
|
280
|
+
消息,并按原顺序展示引用来源、快照和用户输入。自建消息列表时可用
|
|
281
|
+
`parseWhatIfPrompt` 解析同一格式,再交给 `WhatIfUserBubble` 渲染;
|
|
282
|
+
`onQuoteClick` 可接入宿主的步骤跳转。
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
const parsed = parseWhatIfPrompt(messageText)
|
|
286
|
+
return parsed ? (
|
|
287
|
+
<WhatIfUserBubble parsed={parsed} onQuoteClick={jumpToStep} />
|
|
288
|
+
) : null
|
|
289
|
+
```
|
|
290
|
+
|
|
275
291
|
## isAgentComputerCommand / isAgentComputerToolCall / classifyAgentComputerLaunchOutcome
|
|
276
292
|
|
|
277
293
|
判断智能体是否在沙盒里启动了通用 GUI 应用镜像(`computer launch`)——后端 blade-agent 通过 `computer` CLI 驱动一块虚拟屏幕运行任意 GUI 软件,这些函数用于自行接入方判断要不要展示对应的实时画面入口(比如自建一个类似「电脑镜像」的标签页)。当前 SDK 侧还没有内置这块 UI,只导出判定规则,避免各接入方重新猜一遍匹配逻辑。
|
|
@@ -340,4 +356,4 @@ blade-chat { --primary: 262 83% 58%; height: 640px; }
|
|
|
340
356
|
|
|
341
357
|
为方便单包引入,本包 re-export 了 agent-client 的全部公开声明(`BladeClient`、`AgentSession`、`SessionState`、协议类型等),文档一律见 [agent-client 的 README](../agent-client/README.md)。完整签名见 [public-api.md](./public-api.md)。
|
|
342
358
|
|
|
343
|
-
本包自有声明:`BladeProvider`、`BladeProviderProps`、`useBladeClient`、`useAgentSession`、`UseAgentSessionOptions`、`UseAgentSessionResult`、`useMessagePin`、`UseMessagePinOptions`、`useReplay`、`UseReplayResult`、`ReplayMismatch`、`ReplayBar`、`ReplayBarProps`、`ReplayMismatchPrompt`、`ReplayMismatchPromptProps`、`ChatView`、`ChatViewProps`、`ChatViewClassNames`、`ChatViewRenderers`、`ChatViewSlots`、`FollowupInteractionEvent`、`ToolCallRenderer`、`MarkdownContent`、`MarkdownContentProps`。
|
|
359
|
+
本包自有声明:`BladeProvider`、`BladeProviderProps`、`useBladeClient`、`useAgentSession`、`UseAgentSessionOptions`、`UseAgentSessionResult`、`useMessagePin`、`UseMessagePinOptions`、`useReplay`、`UseReplayResult`、`ReplayMismatch`、`ReplayBar`、`ReplayBarProps`、`ReplayMismatchPrompt`、`ReplayMismatchPromptProps`、`ChatView`、`ChatViewProps`、`ChatViewClassNames`、`ChatViewRenderers`、`ChatViewSlots`、`FollowupInteractionEvent`、`ToolCallRenderer`、`MarkdownContent`、`MarkdownContentProps`、`parseWhatIfPrompt`、`ParsedWhatIfPrompt`、`WhatIfQuote`、`WhatIfUserBubble`、`WhatIfUserBubbleProps`。
|
|
@@ -5,3 +5,16 @@ export interface ContextCardProps {
|
|
|
5
5
|
}
|
|
6
6
|
/** Business-facing Context summary. Native details keeps every card collapsed by default. */
|
|
7
7
|
export declare function ContextCard({ context, className }: ContextCardProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export interface ContextGroupCardProps {
|
|
9
|
+
contexts: readonly ContextProjectionData[];
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 一批上下文注入折叠成一行。会话首轮会一次注入十几个原子,一条一张卡片会把
|
|
14
|
+
* 真正的对话挤出屏幕。
|
|
15
|
+
*
|
|
16
|
+
* 单条和多条**共用同一个 details 外壳**,不在数量变化时切换组件:流式时第二条
|
|
17
|
+
* 到达会让这一行从单条变成多条,组件类型一换 React 就重挂 <details>,
|
|
18
|
+
* 用户刚展开的行会被收起来。同理,key 由调用方按组内第一条给,不能带数量。
|
|
19
|
+
*/
|
|
20
|
+
export declare function ContextGroupCard({ contexts, className }: ContextGroupCardProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -11,7 +11,7 @@ interface UserMessageProps {
|
|
|
11
11
|
message: UserChatMessage;
|
|
12
12
|
className?: string;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** 用户消息气泡:文本、canonical 引用消息与图片/文件附件。 */
|
|
15
15
|
export declare function UserMessageBubble({ message, className }: UserMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
/** 错误消息:居中红色提示条。 */
|
|
17
17
|
export declare function ErrorMessageBlock({ message, className, }: {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParsedWhatIfPrompt } from "../lib/whatif-prompt";
|
|
2
|
+
export interface WhatIfUserBubbleProps {
|
|
3
|
+
parsed: ParsedWhatIfPrompt;
|
|
4
|
+
onQuoteClick?: (stepNumber: number) => void;
|
|
5
|
+
}
|
|
6
|
+
/** SDK 与内置 Web 共用的 canonical 引用消息渲染。 */
|
|
7
|
+
export declare function WhatIfUserBubble({ parsed, onQuoteClick }: WhatIfUserBubbleProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/embed/entry.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ declare const BladeAgent: {
|
|
|
50
50
|
transformSlashCommand: typeof agentClient.transformSlashCommand;
|
|
51
51
|
contextProjectionData: typeof agentClient.contextProjectionData;
|
|
52
52
|
getContextDisplayState: typeof agentClient.getContextDisplayState;
|
|
53
|
+
getContextGroupDisplayState: typeof agentClient.getContextGroupDisplayState;
|
|
54
|
+
groupAdjacentContextRuns: typeof agentClient.groupAdjacentContextRuns;
|
|
53
55
|
latestPostChatFollowup: typeof agentClient.latestPostChatFollowup;
|
|
54
56
|
DEFAULT_REPLAY_SPEED: agentClient.ReplaySpeed;
|
|
55
57
|
SessionInfo: import("arktype/internal/variants/object.ts").ObjectType<{
|
package/dist/index.d.ts
CHANGED
|
@@ -16,14 +16,19 @@ export { LlmChat } from "./components/LlmChat";
|
|
|
16
16
|
export type { LlmChatHandle, LlmChatProps } from "./components/LlmChat";
|
|
17
17
|
export type { LlmAdvancedSettings, LlmOverride } from "./components/LlmAdvancedSettings";
|
|
18
18
|
export { MarkdownContent } from "./components/MarkdownContent";
|
|
19
|
+
export { normalizeAdjacentUrlFormatting } from "./components/MarkdownContent";
|
|
19
20
|
export type { MarkdownContentProps } from "./components/MarkdownContent";
|
|
21
|
+
export { WhatIfUserBubble } from "./components/WhatIfUserBubble";
|
|
22
|
+
export type { WhatIfUserBubbleProps } from "./components/WhatIfUserBubble";
|
|
23
|
+
export { parseWhatIfPrompt } from "./lib/whatif-prompt";
|
|
24
|
+
export type { ParsedWhatIfPrompt, WhatIfQuote } from "./lib/whatif-prompt";
|
|
20
25
|
export { ReplayBar } from "./components/ReplayBar";
|
|
21
26
|
export type { ReplayBarProps } from "./components/ReplayBar";
|
|
22
27
|
export { ReplayMismatchPrompt } from "./components/ReplayMismatchPrompt";
|
|
23
28
|
export type { ReplayMismatchPromptProps } from "./components/ReplayMismatchPrompt";
|
|
24
29
|
export type { ToolCallRenderer } from "./components/ToolCallBlock";
|
|
25
|
-
export { ContextCard } from "./components/ContextCard";
|
|
26
|
-
export type { ContextCardProps } from "./components/ContextCard";
|
|
30
|
+
export { ContextCard, ContextGroupCard } from "./components/ContextCard";
|
|
31
|
+
export type { ContextCardProps, ContextGroupCardProps } from "./components/ContextCard";
|
|
27
32
|
export { collectMemoryRefs, MemoryRefsHint } from "./components/AssistantTurnBlock";
|
|
28
33
|
export { isAgentComputerCommand, isAgentComputerToolCall, classifyAgentComputerLaunchOutcome, } from "./lib/agent-computer-command";
|
|
29
34
|
export type { AgentComputerLaunchOutcome } from "./lib/agent-computer-command";
|