@blade-hq/agent-react 2610.0.0-beta.51 → 2610.0.0-beta.53
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 +7 -1
- package/dist/components/ChatInput.d.ts +2 -2
- package/dist/components/ChatSurface.d.ts +4 -2
- package/dist/components/SessionQueuePanel.d.ts +25 -0
- package/dist/components/plugin-config-draft.d.ts +13 -0
- package/dist/components/plugin-config-schema.d.ts +0 -45
- package/dist/embed/entry.d.ts +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17095 -2745
- package/dist/index.js.map +1 -1
- package/dist/style.full.css +1 -1
- package/package.json +2 -2
- package/public-api.md +155 -5
package/README.md
CHANGED
|
@@ -388,7 +388,13 @@ blade-chat { --primary: 262 83% 58%; height: 640px; }
|
|
|
388
388
|
|
|
389
389
|
为方便单包引入,本包 re-export 了 agent-client 的全部公开声明(`BladeClient`、`AgentSession`、`SessionState`、协议类型等),文档一律见 [agent-client 的 README](../agent-client/README.md)。完整签名见 [public-api.md](./public-api.md)。
|
|
390
390
|
|
|
391
|
-
本包自有声明:`BladeProvider`、`BladeProviderProps`、`useBladeClient`、`useAgentSession`、`UseAgentSessionOptions`、`UseAgentSessionResult`、`useMessagePin`、`UseMessagePinOptions`、`useReplay`、`UseReplayResult`、`ReplayMismatch`、`ReplayBar`、`ReplayBarProps`、`ReplayMismatchPrompt`、`ReplayMismatchPromptProps`、`ChatView`、`ChatViewProps`、`ChatViewClassNames`、`ChatViewRenderers`、`ChatViewSlots`、`FollowupInteractionEvent`、`ToolCallRenderer`、`CurrentPlanPanel`、`PlanUpdateBlock`、`PlanUpdateData`、`PlanUpdateDisplayState`、`PlanStepStatus`、`getPlanUpdateDisplayState`、`isPlanUpdateTool`、`parsePlanUpdate`、`pickCurrentPlanStep`、`PLAN_AUTO_COLLAPSE_MS`、`MarkdownContent`、`MarkdownContentProps`、`parseWhatIfPrompt`、`ParsedWhatIfPrompt`、`WhatIfQuote`、`WhatIfUserBubble`、`WhatIfUserBubbleProps`。
|
|
391
|
+
本包自有声明:`BladeProvider`、`BladeProviderProps`、`useBladeClient`、`useAgentSession`、`UseAgentSessionOptions`、`UseAgentSessionResult`、`useMessagePin`、`UseMessagePinOptions`、`useReplay`、`UseReplayResult`、`ReplayMismatch`、`ReplayBar`、`ReplayBarProps`、`ReplayMismatchPrompt`、`ReplayMismatchPromptProps`、`ChatView`、`ChatViewProps`、`ChatViewClassNames`、`ChatViewRenderers`、`ChatViewSlots`、`FollowupInteractionEvent`、`ToolCallRenderer`、`CurrentPlanPanel`、`PlanUpdateBlock`、`PlanUpdateData`、`PlanUpdateDisplayState`、`PlanStepStatus`、`getPlanUpdateDisplayState`、`isPlanUpdateTool`、`parsePlanUpdate`、`pickCurrentPlanStep`、`PLAN_AUTO_COLLAPSE_MS`、`MarkdownContent`、`MarkdownContentProps`、`parseWhatIfPrompt`、`ParsedWhatIfPrompt`、`WhatIfQuote`、`WhatIfUserBubble`、`WhatIfUserBubbleProps`、`SessionQueuePanel`、`SessionQueuePanelProps`。
|
|
392
|
+
|
|
393
|
+
## 会话消息队列
|
|
394
|
+
|
|
395
|
+
智能体会话的等待消息由服务端持久化,`ChatView` / `AgentChat` 已在输入框上方渲染队列区域(空队列不占位,条目数超过三条可折叠)。输入框不再有「直接插入 / 排队执行」开关:会话空闲时提交直接开始处理,运行中提交默认入队;暂停时在面板上显示原因和「继续执行」。面板数据来自 `useAgentSession` 状态里的 `queue`(`SessionQueueSnapshot`),可编辑/删除/立即补充的判定来自 agent-client 的 `canEditQueuedMessage` / `canCancelQueuedMessage` / `canDeliverQueuedMessage`,文案用 `queuedMessageStatusLabel` / `queuePauseReasonLabel`。
|
|
396
|
+
|
|
397
|
+
自建布局可直接使用 `<SessionQueuePanel>`,属性类型为 `SessionQueuePanelProps`:传 `snapshot`、`canDeliver`、可选的 `pendingItemId`(提交中的条目禁用操作)与 `notice`(冲突/失败说明),以及 `onResume` / `onCancel` / `onEdit` / `onMove` / `onReorder` / `onDeliver` 回调。上移/下移与拖动排序最终都提交当前 pending 条目的完整 id 顺序。冲突时队列由服务端快照刷新,`ChatView` 会把未保存的正文放回输入框,不会静默丢掉用户编辑的内容。
|
|
392
398
|
|
|
393
399
|
`PollingBackoff` 从 agent-client 重导出,供自定义只读轮询计算退避时间;它不发送或重放请求。用法见 [agent-client 轮询说明](../agent-client/README.md#只读轮询退避)。
|
|
394
400
|
|
|
@@ -3,8 +3,8 @@ interface Props {
|
|
|
3
3
|
value: string;
|
|
4
4
|
onValueChange: (value: string) => void;
|
|
5
5
|
onSend: (text: string) => boolean | Promise<boolean>;
|
|
6
|
-
/**
|
|
7
|
-
onAppend?: (text: string) =>
|
|
6
|
+
/** 运行中提交:把消息交给服务端队列(入队)。 */
|
|
7
|
+
onAppend?: (text: string) => boolean | undefined | Promise<boolean>;
|
|
8
8
|
onStop: () => void;
|
|
9
9
|
isStreaming: boolean;
|
|
10
10
|
isStopping?: boolean;
|
|
@@ -45,7 +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) =>
|
|
48
|
+
onAppend?: (text: string) => boolean | undefined | Promise<boolean>;
|
|
49
49
|
onStop: () => void;
|
|
50
50
|
sessionStatus?: string;
|
|
51
51
|
askAnswers?: Record<string, AskUserAnswerData>;
|
|
@@ -56,6 +56,8 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
56
56
|
onResultFeedbackSaved?: (feedback: ResultFeedback) => void;
|
|
57
57
|
/** 输入框上方的内部区域(纯 LLM 模式的高级设置用)。不传时不渲染任何节点。 */
|
|
58
58
|
beforeInput?: ReactNode;
|
|
59
|
+
/** 输入框上方的会话队列面板(智能体模式用)。不传时不渲染任何节点。 */
|
|
60
|
+
queuePanel?: ReactNode;
|
|
59
61
|
/** 仅 Agent 模式启用 Blade 的 update_plan 面板。 */
|
|
60
62
|
showPlanUpdates?: boolean;
|
|
61
63
|
/** 仅实时成功的 update_plan 递增;历史 hydration 不得改变。 */
|
|
@@ -75,5 +77,5 @@ interface ChatSurfaceProps extends ChatPresentationProps {
|
|
|
75
77
|
* 这里的 DOM 结构受 tests/chat-view-compat.test.tsx 的快照保护——接入方拿
|
|
76
78
|
* .blade-chat-* 类名写了自己的样式,结构一动他们的页面就歪。
|
|
77
79
|
*/
|
|
78
|
-
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, historyPaging, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
80
|
+
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, queuePanel, showPlanUpdates, planRevealRevision, historyPaging, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
79
81
|
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type QueuedMessage, type SessionQueueSnapshot } from "@blade-hq/agent-client";
|
|
2
|
+
import { type JSX } from "react";
|
|
3
|
+
export interface SessionQueuePanelProps {
|
|
4
|
+
snapshot: SessionQueueSnapshot;
|
|
5
|
+
/** 当前是否有可接收补充的运行任务(决定「立即补充」是否可用) */
|
|
6
|
+
canDeliver: boolean;
|
|
7
|
+
/** 正在等服务端确认的条目 id:禁用该条目的操作,避免重复提交 */
|
|
8
|
+
pendingItemId?: string | null;
|
|
9
|
+
/** 冲突/失败提示,例如「该消息已开始执行」;展示在面板顶部 */
|
|
10
|
+
notice?: string | null;
|
|
11
|
+
onResume: () => void;
|
|
12
|
+
onCancel: (item: QueuedMessage) => void;
|
|
13
|
+
onEdit: (item: QueuedMessage, content: string) => boolean | undefined | Promise<boolean>;
|
|
14
|
+
onRequeue?: (content: string) => Promise<boolean>;
|
|
15
|
+
onMove: (item: QueuedMessage, delta: -1 | 1) => void;
|
|
16
|
+
onReorder: (orderedIds: string[]) => void;
|
|
17
|
+
onDeliver: (item: QueuedMessage) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 会话消息队列面板:输入框上方的「待执行 · N」区域。
|
|
21
|
+
*
|
|
22
|
+
* 纯展示组件,不持有会话状态;能否编辑/删除/补充全部用 agent-client 的判定函数,
|
|
23
|
+
* 不在本包重写一份。上移/下移、拖动排序最终都由调用方提交完整的 pending id 顺序。
|
|
24
|
+
*/
|
|
25
|
+
export declare function SessionQueuePanel({ snapshot, canDeliver, pendingItemId, notice, onResume, onCancel, onEdit, onRequeue, onMove, onReorder, onDeliver, }: SessionQueuePanelProps): JSX.Element | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SessionPluginConfigSet, SessionPluginConfigState } from "@blade-hq/agent-client";
|
|
2
|
+
export type ConfigPath = (string | number)[];
|
|
3
|
+
export type ConfigValues = Record<string, unknown>;
|
|
4
|
+
export declare function createConfigDraft(config: SessionPluginConfigState): {
|
|
5
|
+
values: ConfigValues;
|
|
6
|
+
retained: Map<string, string>;
|
|
7
|
+
};
|
|
8
|
+
/** Array edits address the original indices because the API applies sets before removals. */
|
|
9
|
+
export declare function originalConfigPath(path: ConfigPath, removed: Set<string>): ConfigPath;
|
|
10
|
+
export declare function configDraftOperations(initial: ConfigValues, values: ConfigValues, retained: Map<string, string>, removed: Set<string>): {
|
|
11
|
+
set: SessionPluginConfigSet[];
|
|
12
|
+
remove: string[];
|
|
13
|
+
};
|
|
@@ -1,51 +1,6 @@
|
|
|
1
1
|
import type { SessionPluginConfigState } from "@blade-hq/agent-client";
|
|
2
|
-
/**
|
|
3
|
-
* JSON Schema (Draft 2020-12) support surface for the shared plugin form.
|
|
4
|
-
*
|
|
5
|
-
* The platform validates with the full standard validator; the form only
|
|
6
|
-
* renders the constructs it can render honestly. Anything outside this list is
|
|
7
|
-
* reported with a located reason instead of being dropped or downgraded to a
|
|
8
|
-
* raw JSON editor — "不支持的呈现明确报错,不静默丢字段".
|
|
9
|
-
*/
|
|
10
2
|
export type JsonSchema = Record<string, unknown>;
|
|
11
|
-
export interface Discriminator {
|
|
12
|
-
key: string;
|
|
13
|
-
label: string;
|
|
14
|
-
options: {
|
|
15
|
-
value: string;
|
|
16
|
-
label: string;
|
|
17
|
-
}[];
|
|
18
|
-
}
|
|
19
3
|
export declare function pointerOf(parts: (string | number)[]): string;
|
|
20
4
|
export declare function pointerParts(pointer: string): string[];
|
|
21
|
-
/** Follow intra-document `$ref` chains. Package-relative refs are refused. */
|
|
22
|
-
export declare function resolveNode(root: JsonSchema, node: JsonSchema): JsonSchema | null;
|
|
23
|
-
export declare function nodeTypes(node: JsonSchema): string[];
|
|
24
|
-
export declare function isSecret(node: JsonSchema): boolean;
|
|
25
|
-
export declare function optionsOf(node: JsonSchema): {
|
|
26
|
-
value: unknown;
|
|
27
|
-
label: string;
|
|
28
|
-
}[] | null;
|
|
29
|
-
export declare function labelOf(node: JsonSchema, fallback: string): string;
|
|
30
|
-
export declare function hintOf(node: JsonSchema): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* Whether a branch keyword can be rendered, and why not when it cannot.
|
|
33
|
-
*
|
|
34
|
-
* `oneOf` is supported only in the shape a login form actually needs: every
|
|
35
|
-
* branch pins the same discriminator property with `const`. Anything else would
|
|
36
|
-
* mean guessing which fields to show.
|
|
37
|
-
*/
|
|
38
|
-
export declare function unsupportedReason(root: JsonSchema, node: JsonSchema, pointer?: string, ancestors?: Set<JsonSchema>): string | null;
|
|
39
|
-
/**
|
|
40
|
-
* The switch a form can render: a property every `oneOf` branch pins with
|
|
41
|
-
* `const`, declared with an `enum` (or `const`) in `properties`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function discriminatorOf(root: JsonSchema, node: JsonSchema): Discriminator | null;
|
|
44
|
-
/** Required pointers for the whole document, following the active branch. */
|
|
45
|
-
export declare function requiredPointers(root: JsonSchema, values: Record<string, unknown>): Set<string>;
|
|
46
|
-
/** Whether a subtree holds `writeOnly` anywhere inside it. */
|
|
47
|
-
export declare function containsSecret(root: JsonSchema, node: JsonSchema): boolean;
|
|
48
|
-
export declare function readAt(document: Record<string, unknown>, pointer: string): unknown;
|
|
49
|
-
/** The form's support verdict for a whole declaration. */
|
|
50
5
|
export declare function formSupport(schema: JsonSchema | null): string | null;
|
|
51
6
|
export declare function configIsEditable(state: SessionPluginConfigState): boolean;
|
package/dist/embed/entry.d.ts
CHANGED
|
@@ -32,6 +32,15 @@ declare const BladeAgent: {
|
|
|
32
32
|
reconcileHistoricalUserTurns: typeof agentClient.reconcileHistoricalUserTurns;
|
|
33
33
|
reconcileOptimisticUserTurns: typeof agentClient.reconcileOptimisticUserTurns;
|
|
34
34
|
toReplaySnapshot: typeof agentClient.toReplaySnapshot;
|
|
35
|
+
EMPTY_SESSION_QUEUE: agentClient.SessionQueueSnapshot;
|
|
36
|
+
canCancelQueuedMessage: typeof agentClient.canCancelQueuedMessage;
|
|
37
|
+
canDeliverQueuedMessage: typeof agentClient.canDeliverQueuedMessage;
|
|
38
|
+
canEditQueuedMessage: typeof agentClient.canEditQueuedMessage;
|
|
39
|
+
isSessionQueueSnapshot: typeof agentClient.isSessionQueueSnapshot;
|
|
40
|
+
parseQueueAck: typeof agentClient.parseQueueAck;
|
|
41
|
+
queuePauseReasonLabel: typeof agentClient.queuePauseReasonLabel;
|
|
42
|
+
queuedMessageStatusLabel: typeof agentClient.queuedMessageStatusLabel;
|
|
43
|
+
shouldApplySnapshot: typeof agentClient.shouldApplySnapshot;
|
|
35
44
|
connectEmbedded: typeof agentClient.connectEmbedded;
|
|
36
45
|
isCommandEnvelope: typeof agentClient.isCommandEnvelope;
|
|
37
46
|
isInboundEnvelope: typeof agentClient.isInboundEnvelope;
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export { McpAppCard } from "./components/McpAppCard";
|
|
|
45
45
|
export type { McpAppMessage } from "./components/McpAppCard";
|
|
46
46
|
export { SessionMemoryToggle } from "./components/SessionMemoryToggle";
|
|
47
47
|
export type { SessionMemoryToggleProps } from "./components/SessionMemoryToggle";
|
|
48
|
+
export { SessionQueuePanel } from "./components/SessionQueuePanel";
|
|
49
|
+
export type { SessionQueuePanelProps } from "./components/SessionQueuePanel";
|
|
48
50
|
export { isAgentComputerCommand, isAgentComputerToolCall, classifyAgentComputerLaunchOutcome, } from "./lib/agent-computer-command";
|
|
49
51
|
export type { AgentComputerLaunchOutcome } from "./lib/agent-computer-command";
|
|
50
52
|
export * from "@blade-hq/agent-client";
|