@blade-hq/agent-react 1.2.1-beta.1 → 1.2.1-beta.10
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 +8 -1
- package/dist/components/AssistantTurnBlock.d.ts +3 -1
- package/dist/components/FileCard.d.ts +16 -0
- package/dist/components/MarkdownContent.d.ts +8 -4
- package/dist/components/MessageList.d.ts +3 -1
- package/dist/index.js +399 -163
- package/dist/index.js.map +1 -1
- package/dist/lib/media-tags.d.ts +24 -0
- package/dist/style.css +146 -2
- package/package.json +2 -2
- package/public-api.md +2 -1
package/README.md
CHANGED
|
@@ -90,15 +90,22 @@ await session?.send("你好")
|
|
|
90
90
|
|
|
91
91
|
- 必须引入 `@blade-hq/agent-react/style.css`。组件自带 `.blade-chat-*` 前缀的自包含样式,宿主没装 Tailwind 也开箱可用;颜色走 CSS 变量,可整体换肤/暗色。
|
|
92
92
|
- `renderers.toolCall` 返回 `null` 时回落到默认工具卡片。
|
|
93
|
+
- **内边距按容器宽度伸缩**,嵌进窄侧栏(300–400px)时会自动收窄,不看浏览器视口。代价是聊天容器需要有确定宽度——放在 flex/grid 里被拉伸,或显式给宽度都可以;放进 `width: fit-content`、`inline-flex` 这类由内容决定宽度的父容器会塌缩。
|
|
93
94
|
|
|
94
95
|
## MarkdownContent
|
|
95
96
|
|
|
96
|
-
单独渲染一段智能体消息 Markdown(含代码复制按钮、XSS
|
|
97
|
+
单独渲染一段智能体消息 Markdown(含代码复制按钮、XSS 消毒;HTML 经 sanitize 白名单处理,不接受任意 raw HTML):
|
|
97
98
|
|
|
98
99
|
```tsx
|
|
99
100
|
<MarkdownContent content={markdownText} />
|
|
100
101
|
```
|
|
101
102
|
|
|
103
|
+
传了 `sessionId` 才会把智能体产出文件的 `MEDIA:` 行折叠成下载卡片(下载要用它)。`ChatView` 内部已经传好,只有单独用 `MarkdownContent` 时需要自己给:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<MarkdownContent sessionId={sessionId}>{markdownText}</MarkdownContent>
|
|
107
|
+
```
|
|
108
|
+
|
|
102
109
|
## 选择模型
|
|
103
110
|
|
|
104
111
|
SDK 的 ChatView / `<blade-chat>` 不内置模型选择器(默认用后端配置的模型)。指定模型有两种方式:
|
|
@@ -7,10 +7,12 @@ interface Props {
|
|
|
7
7
|
onAnswer?: (answer: string, toolCallId: string, answerData: AskUserAnswerData) => void;
|
|
8
8
|
sessionStatus?: string;
|
|
9
9
|
toolCallRenderer?: ToolCallRenderer;
|
|
10
|
+
/** 传给 Markdown 渲染,用于把 MEDIA 行折叠成文件下载卡片。 */
|
|
11
|
+
sessionId?: string;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* 一轮助手回复:按消息顺序渲染 thinking 折叠块、正文 Markdown 与工具调用。
|
|
13
15
|
* 相比第一方版本去掉了紧凑/详细模式切换、文件交付卡片与内联资源 iframe。
|
|
14
16
|
*/
|
|
15
|
-
export declare function AssistantTurnBlock({ messages, isStreaming, askAnswers, onAnswer, sessionStatus, toolCallRenderer, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function AssistantTurnBlock({ messages, isStreaming, askAnswers, onAnswer, sessionStatus, toolCallRenderer, sessionId, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
2
|
+
import type { ExtraProps } from "streamdown";
|
|
3
|
+
export type FileCardProps = ComponentPropsWithRef<"span"> & ExtraProps & {
|
|
4
|
+
"data-path"?: string;
|
|
5
|
+
"data-name"?: string;
|
|
6
|
+
dataPath?: string;
|
|
7
|
+
dataName?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 智能体产出文件的下载卡片(由 MEDIA 行折叠而来)。
|
|
12
|
+
*
|
|
13
|
+
* 整张卡片只有一个动作:下载。第一方界面点卡片是「在右侧预览」,那依赖 app 的 artifact
|
|
14
|
+
* 面板,SDK 里没有这块,所以不摆预览入口也不写预览文案——UI 不能承诺不存在的能力。
|
|
15
|
+
*/
|
|
16
|
+
export declare function FileCard({ node, "data-path": pathAttribute, "data-name": nameAttribute, dataPath, dataName, sessionId, children, className, ...props }: FileCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,10 +3,14 @@ export interface MarkdownContentProps {
|
|
|
3
3
|
className?: string;
|
|
4
4
|
/** 流式渲染传 "streaming",历史静态内容默认 "static"。 */
|
|
5
5
|
mode?: "streaming" | "static";
|
|
6
|
+
/**
|
|
7
|
+
* 会话 id。传了才会把 `MEDIA:` 行折叠成文件下载卡片——下载要用它。
|
|
8
|
+
* 不要给用户消息传:用户自己在输入框打一行 `MEDIA:` 不该被当成平台产物。
|
|
9
|
+
*/
|
|
10
|
+
sessionId?: string;
|
|
6
11
|
}
|
|
7
12
|
/**
|
|
8
|
-
* SDK 版 Markdown
|
|
9
|
-
*
|
|
10
|
-
* 会话文件卡片等第一方能力。
|
|
13
|
+
* SDK 版 Markdown 渲染:附带代码块复制按钮、智能体产出文件的下载卡片;
|
|
14
|
+
* 相比第一方版本去掉了 mermaid、外链确认弹窗与文件预览。
|
|
11
15
|
*/
|
|
12
|
-
export declare function MarkdownContent({ children, className, mode }: MarkdownContentProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function MarkdownContent({ children, className, mode, sessionId }: MarkdownContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,10 +10,12 @@ interface Props {
|
|
|
10
10
|
toolCallRenderer?: ToolCallRenderer;
|
|
11
11
|
emptyState?: ReactNode;
|
|
12
12
|
className?: string;
|
|
13
|
+
/** 传给助手消息的 Markdown 渲染,用于把 MEDIA 行折叠成文件下载卡片。 */
|
|
14
|
+
sessionId?: string;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* 消息列表:use-stick-to-bottom 自动滚动 + 按轮次分组渲染。
|
|
16
18
|
* 相比第一方版本去掉了轮次导航栏、吸顶状态条与规划摘要卡片。
|
|
17
19
|
*/
|
|
18
|
-
export declare function MessageList({ messages, isStreaming, sessionStatus, askAnswers, onAnswer, toolCallRenderer, emptyState, className, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function MessageList({ messages, isStreaming, sessionStatus, askAnswers, onAnswer, toolCallRenderer, emptyState, className, sessionId, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
export {};
|