@blade-hq/agent-react 2610.0.0-beta.32 → 2610.0.0-beta.34
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 +20 -0
- package/dist/components/ChatInput.d.ts +4 -1
- package/dist/components/ChatSurface.d.ts +2 -1
- package/dist/components/SessionMemoryToggle.d.ts +19 -0
- package/dist/components/display-utils.d.ts +2 -0
- package/dist/context.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +406 -216
- package/dist/index.js.map +1 -1
- package/dist/style.css +4 -1
- package/dist/style.full.css +5 -2
- package/package.json +2 -2
- package/public-api.md +22 -1
package/README.md
CHANGED
|
@@ -74,6 +74,26 @@ await session?.send("你好")
|
|
|
74
74
|
- 必须覆盖连接窗口内事件时,用 `onSessionConnected` 在历史加载和房间订阅开始前完成订阅,并返回取消订阅函数。
|
|
75
75
|
- 同一 `sessionId` 的多次调用复用同一 `AgentSession` 实例(引用计数);卸载后延迟释放,路由抖动不会断连。
|
|
76
76
|
|
|
77
|
+
## SessionMemoryToggle
|
|
78
|
+
|
|
79
|
+
把当前会话是否使用记忆放进宿主自己的会话设置面板:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
const [memoryEnabled, setMemoryEnabled] = useState(session.memory_enabled !== false)
|
|
83
|
+
|
|
84
|
+
<SessionMemoryToggle
|
|
85
|
+
sessionId={session.id}
|
|
86
|
+
enabled={memoryEnabled}
|
|
87
|
+
onSaved={(_sessionId, enabled) => setMemoryEnabled(enabled)}
|
|
88
|
+
onError={(error) => toast.error(String(error))}
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
组件默认使用 `BladeProvider` 的 client;已有独立 client 装配层的宿主也可以显式传
|
|
93
|
+
`client={client}`。同一 client、同一会话的多个开关共享保存锁,即使切换会话或同时存在多个
|
|
94
|
+
设置入口,也不会并发提交相互覆盖。服务端确认后的权威值通过 `onSaved` 返回。
|
|
95
|
+
全部属性见 `SessionMemoryToggleProps`。
|
|
96
|
+
|
|
77
97
|
## useReplay
|
|
78
98
|
|
|
79
99
|
会话回放(演示 / 彩排):拿一个已经聊完的会话当素材,重现当时的回复和工具调用,
|
|
@@ -3,16 +3,19 @@ interface Props {
|
|
|
3
3
|
value: string;
|
|
4
4
|
onValueChange: (value: string) => void;
|
|
5
5
|
onSend: (text: string) => boolean | Promise<boolean>;
|
|
6
|
+
/** Optional direct insertion path used while another response streams. */
|
|
7
|
+
onAppend?: (text: string) => void;
|
|
6
8
|
onStop: () => void;
|
|
7
9
|
isStreaming: boolean;
|
|
8
10
|
isStopping?: boolean;
|
|
9
11
|
placeholder?: string;
|
|
10
12
|
className?: string;
|
|
13
|
+
queueKey?: string;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* 轻量聊天输入框:textarea(Enter 发送 / Shift+Enter 换行)+ 发送/停止按钮。
|
|
14
17
|
* 不含第一方版本的富文本编辑、@ 补全、技能菜单、语音输入与模型选择。
|
|
15
18
|
* 内容受控,session.attach() / insertText() 通过 ChatView 注入到这里。
|
|
16
19
|
*/
|
|
17
|
-
export declare function ChatInput({ value, onValueChange, onSend, onStop, isStreaming, isStopping, placeholder, className, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function ChatInput({ value, onValueChange, onSend, onAppend, onStop, isStreaming, isStopping, placeholder, className, queueKey, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
18
21
|
export {};
|
|
@@ -45,6 +45,7 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
45
45
|
onInputChange: (value: string) => void;
|
|
46
46
|
onSuggestion?: (value: string) => void;
|
|
47
47
|
onSend: (text: string) => Promise<boolean>;
|
|
48
|
+
onAppend?: (text: string) => void;
|
|
48
49
|
onStop: () => void;
|
|
49
50
|
sessionStatus?: string;
|
|
50
51
|
askAnswers?: Record<string, AskUserAnswerData>;
|
|
@@ -68,5 +69,5 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
68
69
|
* 这里的 DOM 结构受 tests/chat-view-compat.test.tsx 的快照保护——接入方拿
|
|
69
70
|
* .blade-chat-* 类名写了自己的样式,结构一动他们的页面就歪。
|
|
70
71
|
*/
|
|
71
|
-
export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, postChatFollowup, isStreaming, isStopping, inputText, onInputChange, onSuggestion, onSend, onStop, sessionStatus, askAnswers, onAnswer, sessionId, isViewer, resultFeedbackByEntry, onResultFeedbackSaved, onFollowupInteraction, beforeInput, showPlanUpdates, planRevealRevision, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, postChatFollowup, isStreaming, isStopping, inputText, onInputChange, onSuggestion, onSend, onAppend, onStop, sessionStatus, askAnswers, onAnswer, sessionId, isViewer, resultFeedbackByEntry, onResultFeedbackSaved, onFollowupInteraction, beforeInput, showPlanUpdates, planRevealRevision, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
72
73
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BladeClient } from "@blade-hq/agent-client";
|
|
2
|
+
export interface SessionMemoryToggleProps {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
/** 不在 BladeProvider 内使用时显式传入,与宿主现有 BladeClient 复用连接和鉴权。 */
|
|
6
|
+
client?: BladeClient;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
label?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
labelClassName?: string;
|
|
11
|
+
inputClassName?: string;
|
|
12
|
+
onSaved?: (sessionId: string, enabled: boolean) => void;
|
|
13
|
+
onError?: (error: unknown) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 当前会话记忆开关。同一 client + sessionId 的所有实例共享保存锁,避免多个聊天入口
|
|
17
|
+
* 或会话切换时发出乱序更新;服务端成功后才通过 onSaved 交还权威值。
|
|
18
|
+
*/
|
|
19
|
+
export declare function SessionMemoryToggle({ sessionId, enabled, client: clientProp, disabled, label, className, labelClassName, inputClassName, onSaved, onError, }: SessionMemoryToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,6 +10,8 @@ export declare function getSkillNameFromFilePath(filePath: string | null | undef
|
|
|
10
10
|
/** 归一化工具名:去掉命名空间前缀并映射到别名表(如 "fork:Agent" → "Agent")。 */
|
|
11
11
|
export declare function formatToolName(name: string): string;
|
|
12
12
|
export declare function extractToolFilePath(toolCall: ToolCallInfo): string | null;
|
|
13
|
+
/** 从文件类工具参数中提取全部可定位的文件路径(按出现顺序去重)。 */
|
|
14
|
+
export declare function extractToolFilePaths(toolCall: ToolCallInfo): string[];
|
|
13
15
|
/**
|
|
14
16
|
* 返回工具调用的中文展示标签:优先取参数里的 description,
|
|
15
17
|
* 其次取后端下发的 display_name / 系统工具中文名。
|
package/dist/context.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export interface BladeProviderProps {
|
|
|
11
11
|
export declare function BladeProvider({ client, children }: BladeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
/** 读取当前 BladeProvider 提供的 client。不在 Provider 内使用时抛错。 */
|
|
13
13
|
export declare function useBladeClient(): BladeClient;
|
|
14
|
+
export declare function useOptionalBladeClient(): BladeClient | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type { PlanStepStatus, PlanUpdateData, PlanUpdateDisplayState, } from "./
|
|
|
32
32
|
export { ContextCard, ContextGroupCard } from "./components/ContextCard";
|
|
33
33
|
export type { ContextCardProps, ContextGroupCardProps } from "./components/ContextCard";
|
|
34
34
|
export { collectMemoryRefs, MemoryRefsHint } from "./components/AssistantTurnBlock";
|
|
35
|
+
export { SessionMemoryToggle } from "./components/SessionMemoryToggle";
|
|
36
|
+
export type { SessionMemoryToggleProps } from "./components/SessionMemoryToggle";
|
|
35
37
|
export { isAgentComputerCommand, isAgentComputerToolCall, classifyAgentComputerLaunchOutcome, } from "./lib/agent-computer-command";
|
|
36
38
|
export type { AgentComputerLaunchOutcome } from "./lib/agent-computer-command";
|
|
37
39
|
export * from "@blade-hq/agent-client";
|