@blade-hq/agent-react 2612.0.0-beta.0 → 2612.0.0-beta.1
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 +88 -258
- package/dist/chat/AgentLoopBlock.d.ts +14 -0
- package/dist/{components → chat}/AskUserQuestionBlock.d.ts +3 -7
- package/dist/chat/AssistantTurnBlock.d.ts +50 -0
- package/dist/chat/AttachmentPreviewDialog.d.ts +26 -0
- package/dist/chat/ChatPanel.d.ts +64 -0
- package/dist/chat/CompactionCard.d.ts +6 -0
- package/dist/chat/ConnectionBanner.d.ts +10 -0
- package/dist/chat/CurrentPlanPanel.d.ts +20 -0
- package/dist/chat/FileDeliveryCards.d.ts +26 -0
- package/dist/chat/FinalArtifactCards.d.ts +8 -0
- package/dist/chat/ImageLightbox.d.ts +11 -0
- package/dist/chat/LightComposer.d.ts +7 -0
- package/dist/chat/LiteMessageList.d.ts +82 -0
- package/dist/chat/MessageActions.d.ts +6 -0
- package/dist/chat/MessageContextPills.d.ts +6 -0
- package/dist/chat/MessageFileAttachmentList.d.ts +13 -0
- package/dist/chat/MessageList.d.ts +54 -0
- package/dist/chat/PostChatFollowupBlock.d.ts +11 -0
- package/dist/{components → chat}/RenderErrorBoundary.d.ts +0 -1
- package/dist/chat/ResultFeedback.d.ts +11 -0
- package/dist/chat/SessionReplayBar.d.ts +12 -0
- package/dist/chat/TextAttachmentPills.d.ts +10 -0
- package/dist/chat/ToolCallBlock.d.ts +48 -0
- package/dist/chat/ToolUiCard.d.ts +6 -0
- package/dist/chat/TurnNavRail.d.ts +17 -0
- package/dist/chat/UserMessageBubble.d.ts +20 -0
- package/dist/chat/WorkflowRunBlock.d.ts +13 -0
- package/dist/chat/ai-elements/reasoning.d.ts +32 -0
- package/dist/chat/ai-elements/shimmer.d.ts +15 -0
- package/dist/chat/assistant-turn-questions.d.ts +14 -0
- package/dist/chat/card/CardContext.d.ts +7 -0
- package/dist/chat/chat-theme.d.ts +19 -0
- package/dist/chat/customization.d.ts +214 -0
- package/dist/chat/display-utils.d.ts +48 -0
- package/dist/{components/PostChatFollowupBlock.d.ts → chat/followup-interaction.d.ts} +5 -17
- package/dist/chat/index.d.ts +100 -0
- package/dist/chat/lib/citations.d.ts +30 -0
- package/dist/chat/lib/code-language.d.ts +5 -0
- package/dist/chat/lib/loopback.d.ts +8 -0
- package/dist/chat/lib/markdown-asset-url.d.ts +5 -0
- package/dist/chat/lib/preview-dispatch.d.ts +24 -0
- package/dist/chat/lib/skill-name.d.ts +9 -0
- package/dist/chat/lib/skill-visibility.d.ts +8 -0
- package/dist/chat/lib/ui-meta.d.ts +5 -0
- package/dist/chat/lib/use-async-value.d.ts +8 -0
- package/dist/chat/markdown/ExternalAnchor.d.ts +9 -0
- package/dist/chat/markdown/MarkdownContent.d.ts +40 -0
- package/dist/chat/markdown/text.d.ts +11 -0
- package/dist/chat/message-list-blocks.d.ts +92 -0
- package/dist/chat/plan/PlanSummaryCard.d.ts +10 -0
- package/dist/chat/plan/extract-plan-messages.d.ts +4 -0
- package/dist/chat/plan/parse-plan-messages.d.ts +10 -0
- package/dist/chat/plan/parse-plan-tree.d.ts +16 -0
- package/dist/chat/plan/types.d.ts +56 -0
- package/dist/chat/reasoning-visibility.d.ts +2 -0
- package/dist/chat/runtime/actions.d.ts +22 -0
- package/dist/chat/runtime/background-task-dismissals.d.ts +10 -0
- package/dist/chat/runtime/composer-channels.d.ts +46 -0
- package/dist/chat/runtime/environment.d.ts +152 -0
- package/dist/chat/runtime/input-cache-reset.d.ts +8 -0
- package/dist/chat/runtime/input-services.d.ts +111 -0
- package/dist/chat/runtime/session-source.d.ts +49 -0
- package/dist/chat/runtime/use-chat-actions.d.ts +19 -0
- package/dist/chat/runtime/use-session-replay.d.ts +16 -0
- package/dist/chat/scroll-anchor.d.ts +46 -0
- package/dist/chat/tool-renderers/BashRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/FileEditRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/FileReadRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/KbSearchRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/SearchRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/SubmitResultRenderer.d.ts +2 -0
- package/dist/chat/tool-renderers/kb-search-result.d.ts +19 -0
- package/dist/chat/tool-renderers/registry.d.ts +5 -0
- package/dist/chat/tool-renderers/shared.d.ts +30 -0
- package/dist/chat/tool-renderers/write-preview-scroll.d.ts +5 -0
- package/dist/chat-OCLOVB3H.css +175 -0
- package/dist/chat.css +175 -0
- package/dist/chunk-6ZDOQEWK.js +49365 -0
- package/dist/chunk-6ZDOQEWK.js.map +1 -0
- package/dist/chunk-FQQJP2GJ.js +26986 -0
- package/dist/chunk-FQQJP2GJ.js.map +1 -0
- package/dist/{chunk-G3PMV62Z.js → chunk-PR4QN5HX.js} +9 -2
- package/dist/chunk-WCMGQJLE.js +258 -0
- package/dist/chunk-WCMGQJLE.js.map +1 -0
- package/dist/components/AgentChat.d.ts +3 -3
- package/dist/components/ChatView.d.ts +2 -2
- package/dist/components/ConnectorPanel.d.ts +1 -1
- package/dist/components/ContextCard.d.ts +1 -1
- package/dist/components/LlmChat.d.ts +1 -1
- package/dist/components/McpAppCard.d.ts +1 -1
- package/dist/components/PlanUpdateBlock.d.ts +0 -8
- package/dist/components/PluginConnectorList.d.ts +1 -1
- package/dist/components/ReplayBar.d.ts +1 -1
- package/dist/components/SessionPluginConfigDialog.d.ts +1 -1
- package/dist/components/SessionPluginConfigForm.d.ts +1 -1
- package/dist/components/SessionPluginIcon.d.ts +1 -1
- package/dist/components/SessionPluginSelector.d.ts +1 -1
- package/dist/components/SessionQueuePanel.d.ts +1 -1
- package/dist/components/ToolUiCardView.d.ts +1 -1
- package/dist/components/plugin-config-draft.d.ts +1 -1
- package/dist/components/plugin-config-schema.d.ts +1 -1
- package/dist/components/plugin-connector.d.ts +1 -1
- package/dist/components/use-session-plugin-activation.d.ts +1 -1
- package/dist/context.d.ts +11 -2
- package/dist/embed/blade-chat-element.d.ts +14 -1
- package/dist/embed/entry.d.ts +8 -78
- package/dist/hooks/use-replay.d.ts +1 -1
- package/dist/hooks/use-turn-navigation.d.ts +1 -1
- package/dist/host.d.ts +54 -0
- package/dist/index.d.ts +11 -69
- package/dist/index.js +12 -63525
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +60 -0
- package/dist/internal.js +656 -0
- package/dist/internal.js.map +1 -0
- package/dist/lib/mount-renderers.d.ts +25 -0
- package/dist/lib/use-effect-event.d.ts +3 -0
- package/dist/rich-input/BackgroundTasksPill.d.ts +3 -0
- package/dist/rich-input/ChatInput.d.ts +59 -0
- package/dist/rich-input/ComposerAttachmentViewport.d.ts +3 -0
- package/dist/rich-input/ConnectButton.d.ts +24 -0
- package/dist/rich-input/FileCompletionMenu.d.ts +44 -0
- package/dist/rich-input/FileSizeLimitDialog.d.ts +9 -0
- package/dist/rich-input/ModelSelector.d.ts +10 -0
- package/dist/rich-input/PlanningToggle.d.ts +7 -0
- package/dist/rich-input/ProgressCircle.d.ts +12 -0
- package/dist/rich-input/ReasoningModeSelect.d.ts +9 -0
- package/dist/rich-input/SkillCompletionMenu.d.ts +9 -0
- package/dist/rich-input/SkillStatusBar.d.ts +15 -0
- package/dist/rich-input/extensions/file-mention.d.ts +12 -0
- package/dist/rich-input/extensions/kb-mention.d.ts +18 -0
- package/dist/rich-input/extensions/skill-mention.d.ts +48 -0
- package/dist/rich-input/extensions/workflow-mention.d.ts +10 -0
- package/dist/rich-input/index.d.ts +48 -0
- package/dist/rich-input/input-keyboard.d.ts +13 -0
- package/dist/rich-input/lib/attachment-upload.d.ts +10 -0
- package/dist/rich-input/lib/background-tasks-view.d.ts +31 -0
- package/dist/rich-input/lib/client-query.d.ts +32 -0
- package/dist/rich-input/lib/composer-content.d.ts +42 -0
- package/dist/rich-input/lib/image-input-availability.d.ts +3 -0
- package/dist/rich-input/lib/kb-suggestions.d.ts +37 -0
- package/dist/rich-input/lib/reasoning-levels.d.ts +1 -0
- package/dist/rich-input/lib/session-data.d.ts +20 -0
- package/dist/rich-input/lib/skill-suggestions.d.ts +19 -0
- package/dist/rich-input/lib/token-estimate.d.ts +2 -0
- package/dist/rich-input/lib/token-pressure.d.ts +8 -0
- package/dist/rich-input/lib/upload-results.d.ts +8 -0
- package/dist/rich-input/lib/user-home.d.ts +33 -0
- package/dist/rich-input/model/model-data.d.ts +6 -0
- package/dist/rich-input/model/resolve-model.d.ts +59 -0
- package/dist/rich-input/model/use-composer-model.d.ts +24 -0
- package/dist/rich-input/services.d.ts +22 -0
- package/dist/rich-input/use-dismiss-skill-suggestions-on-mode-change.d.ts +3 -0
- package/dist/rich-input/use-input-history.d.ts +14 -0
- package/dist/rich-input/voice/VoiceWaveform.d.ts +10 -0
- package/dist/rich-input/voice/use-tiptap-voice-input.d.ts +47 -0
- package/dist/rich-input/voice/use-voice-input.d.ts +2 -0
- package/dist/rich-input/voice/voice-input-support.d.ts +5 -0
- package/dist/rich-input.js +29853 -0
- package/dist/rich-input.js.map +1 -0
- package/dist/style.css +30 -64
- package/dist/style.full.css +210 -65
- package/dist/{webapi-W3IB5DO4.js → webapi-E7K2CNM7.js} +2 -2
- package/package.json +12 -3
- package/public-api.md +206 -3603
- package/dist/components/AgentLoopBlock.d.ts +0 -8
- package/dist/components/AgentTaskCard.d.ts +0 -12
- package/dist/components/AssistantTurnBlock.d.ts +0 -36
- package/dist/components/ChatSurface.d.ts +0 -199
- package/dist/components/ConnectionBanner.d.ts +0 -8
- package/dist/components/MarkdownContent.d.ts +0 -30
- package/dist/components/MessageList.d.ts +0 -62
- package/dist/components/Shimmer.d.ts +0 -7
- package/dist/components/ToolCallBlock.d.ts +0 -41
- package/dist/components/TurnNavRail.d.ts +0 -23
- package/dist/components/UserMessageBubble.d.ts +0 -25
- package/dist/components/display-utils.d.ts +0 -4
- /package/dist/{chunk-G3PMV62Z.js.map → chunk-PR4QN5HX.js.map} +0 -0
- /package/dist/{webapi-W3IB5DO4.js.map → webapi-E7K2CNM7.js.map} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ChatMessage } from "@blade-hq/agent-client/internal";
|
|
2
|
+
export declare const RECENT_RESIDENT_TURNS = 8;
|
|
3
|
+
type RenderBlockBase = {
|
|
4
|
+
key: string;
|
|
5
|
+
persistentId: string | null;
|
|
6
|
+
isStreaming: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type AssistantTurnRenderBlock = RenderBlockBase & {
|
|
9
|
+
type: "assistant_turn";
|
|
10
|
+
messages: ChatMessage[];
|
|
11
|
+
anchorId: string;
|
|
12
|
+
railTitle: string;
|
|
13
|
+
/**
|
|
14
|
+
* 本轮对应的用户发言 entry_id。导航条以用户发言命名,跳转也应落在用户
|
|
15
|
+
* 发言上而不是智能体回复上;只给紧跟用户发言的第一个回复块,同一发言
|
|
16
|
+
* 后的第二个回复块(被压缩卡/规划分隔线切开)回退到自身锚点。
|
|
17
|
+
*/
|
|
18
|
+
userEntryId: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type RenderBlock = (RenderBlockBase & {
|
|
21
|
+
type: "message";
|
|
22
|
+
message: ChatMessage;
|
|
23
|
+
anchorId: string | null;
|
|
24
|
+
}) | AssistantTurnRenderBlock | (RenderBlockBase & {
|
|
25
|
+
type: "context_group";
|
|
26
|
+
messages: ChatMessage[];
|
|
27
|
+
}) | (RenderBlockBase & {
|
|
28
|
+
type: "context_divider";
|
|
29
|
+
}) | (RenderBlockBase & {
|
|
30
|
+
type: "compaction";
|
|
31
|
+
message: ChatMessage;
|
|
32
|
+
}) | (RenderBlockBase & {
|
|
33
|
+
type: "planning_divider";
|
|
34
|
+
kind: "enter" | "exit";
|
|
35
|
+
message: ChatMessage;
|
|
36
|
+
});
|
|
37
|
+
export declare function shouldAppendPendingAssistantTurn(sessionIsStreaming: boolean, lastMessage: ChatMessage | undefined): boolean;
|
|
38
|
+
/** 从同一份消息序列生成唯一的渲染计划,流式和历史加载都复用它。 */
|
|
39
|
+
export declare function buildMessageListBlocks({ messages, agentLoopNames, sessionIsStreaming, showContexts, }: {
|
|
40
|
+
messages: ChatMessage[];
|
|
41
|
+
agentLoopNames: ReadonlySet<string>;
|
|
42
|
+
sessionIsStreaming: boolean;
|
|
43
|
+
showContexts?: boolean;
|
|
44
|
+
}): RenderBlock[];
|
|
45
|
+
export declare function getRenderBlockPersistentId(block: RenderBlock): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* 完整 turn 从上一个 assistant turn 之后开始,到当前已完成 assistant turn 结束。
|
|
48
|
+
* 返回最近 N 个完整 turn 的起点;更靠后的流式/pending 内容自然落入常驻尾部。
|
|
49
|
+
*/
|
|
50
|
+
export declare function startIndexOfLastNCompleteTurns(blocks: RenderBlock[], count: number): number;
|
|
51
|
+
export declare function findStablePrefixEnd(blocks: RenderBlock[], recentResidentTurns?: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* 目录刷新信号:窗口里**最后一条**用户发言的稳定 entry id。
|
|
54
|
+
*
|
|
55
|
+
* 与 SDK 的 `latestUserSpeechEntryId`(agent-react 的 use-turn-navigation.ts)同一
|
|
56
|
+
* 判据、同一名称,输入不同:那边拿投影轮,这边拿渲染好的消息。两边都只认"最新
|
|
57
|
+
* 一条",因为往前翻页补进的更早发言不改变目录的结尾,用"窗口里全部发言"当信号
|
|
58
|
+
* 会把正在进行的定位判成过期。
|
|
59
|
+
*
|
|
60
|
+
* AskUserQuestion 的回答在列表里也渲染成用户发言(entry id 就是它自己),所以算一条。
|
|
61
|
+
*/
|
|
62
|
+
export declare function latestUserSpeechEntryId(messages: ChatMessage[]): string | null;
|
|
63
|
+
export declare function buildMessageListBlockIndexes(blocks: RenderBlock[]): {
|
|
64
|
+
entryIdToBlockIndex: Map<string, number>;
|
|
65
|
+
turnIdToBlockIndex: Map<string, number>;
|
|
66
|
+
};
|
|
67
|
+
export type VisibleTurnRect = {
|
|
68
|
+
turnId: string;
|
|
69
|
+
top: number;
|
|
70
|
+
bottom: number;
|
|
71
|
+
};
|
|
72
|
+
/** 判定“已滚到底”的容差:浏览器 scrollTop 按物理像素取整会留 1-2px 残差。 */
|
|
73
|
+
export declare const NAV_AT_BOTTOM_EPSILON_PX = 4;
|
|
74
|
+
/** 按原有 viewport 15% 位置语义,从已相交的 turn 中选择导航高亮项。 */
|
|
75
|
+
export declare function selectActiveTurnAtViewportPosition({ visibleTurns, containerTop, containerBottom, fallbackTurnId, currentTurnId, atBottom, }: {
|
|
76
|
+
visibleTurns: Iterable<VisibleTurnRect>;
|
|
77
|
+
containerTop: number;
|
|
78
|
+
containerBottom: number;
|
|
79
|
+
fallbackTurnId: string | null;
|
|
80
|
+
currentTurnId?: string | null;
|
|
81
|
+
/** 滚动容器已到底。 */
|
|
82
|
+
atBottom?: boolean;
|
|
83
|
+
}): string | null;
|
|
84
|
+
/** 测试双通道最终渲染计划时忽略仅影响布局的 wrapper。 */
|
|
85
|
+
export declare function snapshotMessageListRenderPlan(blocks: RenderBlock[]): {
|
|
86
|
+
type: "assistant_turn" | "compaction" | "context_divider" | "context_group" | "message" | "planning_divider";
|
|
87
|
+
persistentId: string | null;
|
|
88
|
+
globalIndex: number;
|
|
89
|
+
messages: ChatMessage[];
|
|
90
|
+
isStreaming: boolean;
|
|
91
|
+
}[];
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatMessage } from "@blade-hq/agent-client/internal";
|
|
2
|
+
interface Props {
|
|
3
|
+
messages: ChatMessage[];
|
|
4
|
+
sessionStatus?: string;
|
|
5
|
+
onConfirmPlan?: (action: "execute" | "revise", text?: string) => void;
|
|
6
|
+
isHistorical?: boolean;
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function PlanSummaryCard({ messages, sessionStatus, onConfirmPlan, isHistorical, sessionId, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ChatMessage } from "@blade-hq/agent-client/internal";
|
|
2
|
+
export declare function extractLatestPlanMessages(messages: ChatMessage[]): ChatMessage[];
|
|
3
|
+
/** Keep each card within its submission while retaining the phase's skill context. */
|
|
4
|
+
export declare function extractPlanMessagesForTurn(messages: ChatMessage[], turnLastMessage: ChatMessage): ChatMessage[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatMessage } from "@blade-hq/agent-client/internal";
|
|
2
|
+
import type { PlanData } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Extract structured plan data from planning phase messages.
|
|
5
|
+
*
|
|
6
|
+
* Expects messages between planning-mode mode_change markers containing:
|
|
7
|
+
* - ReadSkill tool calls (技能调研:成功结果 = 选定技能,歧义 candidates = 候选列表)
|
|
8
|
+
* - Write tool call to PLAN.yaml with plan YAML
|
|
9
|
+
*/
|
|
10
|
+
export declare function parsePlanMessages(allMessages: ChatMessage[]): PlanData;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PlanNode } from "./types";
|
|
2
|
+
interface ParsedPlanResult {
|
|
3
|
+
plan: {
|
|
4
|
+
root: PlanNode;
|
|
5
|
+
notes: string[];
|
|
6
|
+
} | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type PlanStatusMap = Record<string, PlanNode["status"]>;
|
|
10
|
+
export declare function parsePlanTree(content: string): {
|
|
11
|
+
root: PlanNode;
|
|
12
|
+
notes: string[];
|
|
13
|
+
} | null;
|
|
14
|
+
export declare function applyPlanStatusesById(root: PlanNode, statuses: PlanStatusMap): PlanNode;
|
|
15
|
+
export declare function parsePlanTreeResult(content: string): ParsedPlanResult;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface SkillInfo {
|
|
2
|
+
skillId: string;
|
|
3
|
+
displayName?: string;
|
|
4
|
+
description: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
references?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SkillCatalogItem {
|
|
9
|
+
skillId: string;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PlanNode {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
skillRef: string | null;
|
|
16
|
+
children: PlanNode[];
|
|
17
|
+
depth: number;
|
|
18
|
+
status: "pending" | "running" | "done" | "failed";
|
|
19
|
+
}
|
|
20
|
+
export type Phase = "discovering" | "analyzing" | "generating";
|
|
21
|
+
export interface PlanData {
|
|
22
|
+
intent: string;
|
|
23
|
+
/** All skills returned by search_skills (candidates) */
|
|
24
|
+
searchResults: SkillInfo[];
|
|
25
|
+
/** Skills selected via get_skill_content (subset of searchResults, with content populated) */
|
|
26
|
+
selectedSkills: SkillInfo[];
|
|
27
|
+
plan: {
|
|
28
|
+
root: PlanNode;
|
|
29
|
+
notes: string[];
|
|
30
|
+
} | null;
|
|
31
|
+
/** Raw plan YAML content (non-empty even if parsePlanTree yields no plan) */
|
|
32
|
+
hasPlanContent: boolean;
|
|
33
|
+
/** PLAN.yaml exists but failed to parse/validate for UI rendering */
|
|
34
|
+
parseError: string | null;
|
|
35
|
+
/** AskUserQuestion tool calls found in planning messages */
|
|
36
|
+
askQuestions: Array<{
|
|
37
|
+
toolCallId: string;
|
|
38
|
+
data: {
|
|
39
|
+
questions: Array<{
|
|
40
|
+
question: string;
|
|
41
|
+
options: Array<{
|
|
42
|
+
label: string;
|
|
43
|
+
description: string;
|
|
44
|
+
}>;
|
|
45
|
+
multiSelect?: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
/** File paths from Read tool calls (with status) */
|
|
50
|
+
readFiles: Array<{
|
|
51
|
+
path: string;
|
|
52
|
+
status: "pending" | "done" | "error" | "cancelled" | "awaiting_answer";
|
|
53
|
+
}>;
|
|
54
|
+
/** The last pause-triggering tool in this phase: determines what UI to show */
|
|
55
|
+
lastPauseTool: "AskUserQuestion" | "ExitPlanMode" | null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentSession, MessageContent, SendOptions, SessionState } from "@blade-hq/agent-client/internal";
|
|
2
|
+
/**
|
|
3
|
+
* 等待回答时直接在输入框里打字:把这段文字当作最近一个子回路 AskUserQuestion 的自由作答,
|
|
4
|
+
* 服务端据此恢复运行,而不是另起一轮。
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildPendingAskUserAnswer(state: SessionState, message: MessageContent): Record<string, unknown> | undefined;
|
|
7
|
+
/** 发送附加项(模型、推理档位、知识库等由富输入给出)。 */
|
|
8
|
+
export interface ChatSendExtras {
|
|
9
|
+
model?: string;
|
|
10
|
+
thinkingOverride?: boolean;
|
|
11
|
+
reasoningLevel?: string;
|
|
12
|
+
kbIds?: number[];
|
|
13
|
+
whatif?: SendOptions["whatif"];
|
|
14
|
+
replayDecision?: SendOptions["replayDecision"];
|
|
15
|
+
/**
|
|
16
|
+
* 声明「会话在跑就把这条消息放进等待队列」。只有渲染了队列面板、能展示等待消息的宿主才该传:
|
|
17
|
+
* 没有面板时排队等于消息凭空消失。
|
|
18
|
+
*/
|
|
19
|
+
queueWhenRunning?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** 向会话发送一条消息。返回服务端是否接受(或已改道进等待队列)。 */
|
|
22
|
+
export declare function sendToSession(session: AgentSession, message: MessageContent, mode?: string, askUserAnswer?: Record<string, unknown>, extras?: ChatSendExtras): Promise<boolean>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Dismissed = Record<string, string[]>;
|
|
2
|
+
export declare const backgroundTaskDismissals: {
|
|
3
|
+
getState: () => Dismissed;
|
|
4
|
+
subscribe(listener: () => void): () => void;
|
|
5
|
+
dismiss(sessionId: string, taskId: string): void;
|
|
6
|
+
/** 换身份:清空。 */
|
|
7
|
+
reset(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function useDismissedBackgroundTasks(sessionId: string): string[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface PendingContextSignal {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
content: string;
|
|
5
|
+
imageUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DraftAppendSignal {
|
|
8
|
+
id: string;
|
|
9
|
+
text: string;
|
|
10
|
+
separate?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SendRequestSignal {
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ComposerChannelsState {
|
|
16
|
+
pendingContexts: Record<string, PendingContextSignal[]>;
|
|
17
|
+
draftAppends: Record<string, DraftAppendSignal[]>;
|
|
18
|
+
sendRequests: Record<string, SendRequestSignal[]>;
|
|
19
|
+
modelDrafts: Record<string, string>;
|
|
20
|
+
rewindDrafts: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export declare const composerChannels: {
|
|
23
|
+
getState: () => ComposerChannelsState;
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
addPendingContext(sessionId: string, context: Omit<PendingContextSignal, "id">): void;
|
|
26
|
+
removePendingContext(sessionId: string, contextId: string): void;
|
|
27
|
+
consumePendingContexts: (sessionId: string) => PendingContextSignal[];
|
|
28
|
+
clearPendingContexts(sessionId: string): void;
|
|
29
|
+
addDraftAppend(sessionId: string, text: string, separate?: boolean): void;
|
|
30
|
+
consumeDraftAppends: (sessionId: string) => DraftAppendSignal[];
|
|
31
|
+
clearDraftAppends(sessionId: string): void;
|
|
32
|
+
addSendRequest(sessionId: string): void;
|
|
33
|
+
consumeSendRequests: (sessionId: string) => SendRequestSignal[];
|
|
34
|
+
clearSendRequests(sessionId: string): void;
|
|
35
|
+
setModelDraft(sessionId: string, model: string): void;
|
|
36
|
+
clearModelDraft(sessionId: string): void;
|
|
37
|
+
/** 回退到某一步后,把那一步的用户原话放回输入框(null 清除)。 */
|
|
38
|
+
setRewindDraft(sessionId: string, text: string | null): void;
|
|
39
|
+
/** 会话被关闭 / 删除:清掉它还没被取走的信号。 */
|
|
40
|
+
clearSession(sessionId: string): void;
|
|
41
|
+
/** 换身份:清空全部通道。 */
|
|
42
|
+
reset(): void;
|
|
43
|
+
};
|
|
44
|
+
export type ComposerChannels = typeof composerChannels;
|
|
45
|
+
/** 读通道里的一小块状态;selector 应返回状态里的原值(引用稳定)。 */
|
|
46
|
+
export declare function useComposerChannels<T>(selector: (state: ComposerChannelsState) => T): T;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聊天环境(第一方内部):内置 Web 需要、`<blade-chat>` 不需要的能力。每一项都可选,
|
|
3
|
+
* 缺省时走轻量实现——重依赖(虚拟列表、代码高亮、mermaid、streamdown、富输入)因此只在
|
|
4
|
+
* 注入它们的宿主里出现,不会进 blade-agent.js。
|
|
5
|
+
*
|
|
6
|
+
* hook 形式的注入点必须是稳定引用(模块常量),组件会无条件调用它们。
|
|
7
|
+
*/
|
|
8
|
+
import type { PostChatFollowup, ResultFeedback, SessionInfo, ToolCallInfo, ToolUiCard, TurnProjection } from "@blade-hq/agent-client/internal";
|
|
9
|
+
import type { AskUserAnswerData } from "../AskUserQuestionBlock";
|
|
10
|
+
import type { ComposerProps } from "../customization";
|
|
11
|
+
import { type ComponentPropsWithoutRef, type ComponentType, type ReactNode } from "react";
|
|
12
|
+
import type { CodeBlockOverrides } from "../../components/markdown";
|
|
13
|
+
export type ChatRenderMode = "normal" | "lite" | "developer";
|
|
14
|
+
/** `@tanstack/react-virtual` 的 `useVirtualizer` 里消息列表用到的那一部分。 */
|
|
15
|
+
export interface ChatVirtualItem {
|
|
16
|
+
key: string | number | bigint;
|
|
17
|
+
index: number;
|
|
18
|
+
start: number;
|
|
19
|
+
size: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ChatVirtualizer {
|
|
22
|
+
getVirtualItems(): ChatVirtualItem[];
|
|
23
|
+
getTotalSize(): number;
|
|
24
|
+
measureElement(element: Element | null): void;
|
|
25
|
+
scrollToIndex(index: number, options?: {
|
|
26
|
+
align?: "start" | "center" | "end" | "auto";
|
|
27
|
+
}): void;
|
|
28
|
+
getOffsetForIndex(index: number, align?: "start" | "center" | "end" | "auto"): readonly [number, string] | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface ChatVirtualizerOptions {
|
|
31
|
+
count: number;
|
|
32
|
+
getScrollElement: () => Element | null;
|
|
33
|
+
getItemKey: (index: number) => string | number;
|
|
34
|
+
estimateSize: (index: number) => number;
|
|
35
|
+
overscan?: number;
|
|
36
|
+
scrollMargin?: number;
|
|
37
|
+
/** 测量变化回调;`sync` 为 false 表示异步测量结果(不是用户滚动引起的)。 */
|
|
38
|
+
onChange?: (instance: ChatVirtualizer, sync: boolean) => void;
|
|
39
|
+
}
|
|
40
|
+
export type UseChatVirtualizer = (options: ChatVirtualizerOptions) => ChatVirtualizer;
|
|
41
|
+
export type ChatCodeProps = ComponentPropsWithoutRef<"code"> & {
|
|
42
|
+
"data-block-offset"?: number;
|
|
43
|
+
};
|
|
44
|
+
/** 开发者视图(只在内置 Web 注入):按投影原样展示每一轮。 */
|
|
45
|
+
export interface DeveloperMessageListProps {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
turns: TurnProjection[];
|
|
48
|
+
isViewer: boolean;
|
|
49
|
+
isLoadingHistory: boolean;
|
|
50
|
+
isStreaming?: boolean;
|
|
51
|
+
sessionStatus?: string;
|
|
52
|
+
postChatFollowup?: PostChatFollowup | null;
|
|
53
|
+
resultFeedbackByEntry?: ReadonlyMap<string, ResultFeedback>;
|
|
54
|
+
onResultFeedbackSaved?: (feedback: ResultFeedback) => void;
|
|
55
|
+
onAnswer?: (answer: string, toolCallId: string, answerData: AskUserAnswerData) => void;
|
|
56
|
+
onLoadOlder?: (beforeCommit?: () => void) => Promise<boolean>;
|
|
57
|
+
isLoadingOlder?: boolean;
|
|
58
|
+
historyLoadRevision?: number;
|
|
59
|
+
isStopping?: boolean;
|
|
60
|
+
onRevealingChange?: (revealing: boolean) => void;
|
|
61
|
+
isReplay?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface ChatEnvironment {
|
|
64
|
+
/** 当前渲染模式;不注入时是普通模式。 */
|
|
65
|
+
renderMode?: ChatRenderMode;
|
|
66
|
+
/** 开发者视图;不注入时开发者模式按普通模式显示。 */
|
|
67
|
+
DeveloperMessageList?: ComponentType<DeveloperMessageListProps>;
|
|
68
|
+
/** 默认输入框(内置 Web 注入富输入);不注入时用轻输入。 */
|
|
69
|
+
Composer?: ComponentType<ComposerProps>;
|
|
70
|
+
/** 虚拟列表;不注入时消息全部按常驻行渲染。 */
|
|
71
|
+
useVirtualizer?: UseChatVirtualizer;
|
|
72
|
+
/** 代码高亮(返回 null 时按纯文本显示)。 */
|
|
73
|
+
useHighlightedCode?: (code: string, language: string | null | undefined) => {
|
|
74
|
+
highlightedHtml: string | null;
|
|
75
|
+
};
|
|
76
|
+
/** Markdown 里 `code` 元素的渲染(内置 Web 用它渲染业务卡片与高亮)。 */
|
|
77
|
+
MarkdownCode?: ComponentType<ChatCodeProps>;
|
|
78
|
+
/** Markdown 里按语言整体替换的代码块(如 mermaid)。 */
|
|
79
|
+
markdownCodeBlocks?: CodeBlockOverrides;
|
|
80
|
+
/** 思考过程的 Markdown 渲染;不注入时用普通 Markdown。 */
|
|
81
|
+
ReasoningMarkdown?: ComponentType<{
|
|
82
|
+
children: string;
|
|
83
|
+
className?: string;
|
|
84
|
+
}>;
|
|
85
|
+
/** 消息里 tool_ui 卡片(MCP 应用、工具界面)的渲染;不注入时用 SDK 的 ToolUiCardView。 */
|
|
86
|
+
ToolUiCard?: ComponentType<{
|
|
87
|
+
card: ToolUiCard;
|
|
88
|
+
sessionId: string;
|
|
89
|
+
}>;
|
|
90
|
+
/** 会话详情(标题、方案等);不注入时只用会话状态里的字段。 */
|
|
91
|
+
useSessionDetail?: (sessionId: string | null | undefined) => SessionInfo | null | undefined;
|
|
92
|
+
/** 用户是否关闭了任务进度面板。 */
|
|
93
|
+
useHideTodo?: () => boolean;
|
|
94
|
+
/** 普通提示(成功 / 失败 / 说明);不注入时只打日志。 */
|
|
95
|
+
notify?: (kind: ChatNoticeKind, message: string, options?: ChatNoticeOptions) => void;
|
|
96
|
+
/** 打开工具界面卡片的预览页签。 */
|
|
97
|
+
openToolPreview?: (target: {
|
|
98
|
+
sessionId: string;
|
|
99
|
+
toolCall: ToolCallInfo;
|
|
100
|
+
card: ToolUiCard;
|
|
101
|
+
title: string;
|
|
102
|
+
}) => void;
|
|
103
|
+
/** 打开「计划」侧栏。 */
|
|
104
|
+
openPlanPanel?: (sessionId: string) => void;
|
|
105
|
+
/** 在沙盒浏览器里打开链接(本机地址)。 */
|
|
106
|
+
openInSandboxBrowser?: (sessionId: string, url: string) => void;
|
|
107
|
+
/** 把文字放进输入框(跟进建议等);`separate` 为 true 时另起一段。不注入时走 `AgentSession.insertText`。 */
|
|
108
|
+
appendToComposer?: (sessionId: string, text: string, separate?: boolean) => void;
|
|
109
|
+
/** 把一段待发送的上下文放进输入框(MCP 应用消息);不注入时走 `AgentSession.attach`。 */
|
|
110
|
+
addComposerContext?: (sessionId: string, context: {
|
|
111
|
+
label: string;
|
|
112
|
+
content: string;
|
|
113
|
+
}) => void;
|
|
114
|
+
/** 记忆页链接;不注入时记忆引用不显示跳转。 */
|
|
115
|
+
memoriesHref?: string;
|
|
116
|
+
}
|
|
117
|
+
export declare function ChatEnvironmentProvider({ value, children }: {
|
|
118
|
+
value: ChatEnvironment;
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
121
|
+
export declare function useChatEnvironment(): ChatEnvironment;
|
|
122
|
+
/** 代码高亮:注入时用注入的实现,否则纯文本。 */
|
|
123
|
+
export declare function useHighlightedCode(code: string, language: string | null | undefined): {
|
|
124
|
+
highlightedHtml: string | null;
|
|
125
|
+
};
|
|
126
|
+
export declare function useChatSessionDetail(sessionId: string | null | undefined): SessionInfo | null | undefined;
|
|
127
|
+
export declare function useHideTodo(): boolean;
|
|
128
|
+
export declare function useChatRenderMode(): ChatRenderMode;
|
|
129
|
+
export type ChatNoticeKind = "success" | "error" | "info";
|
|
130
|
+
export interface ChatNoticeOptions {
|
|
131
|
+
description?: string;
|
|
132
|
+
duration?: number;
|
|
133
|
+
}
|
|
134
|
+
export declare function notifyChat(environment: ChatEnvironment, kind: ChatNoticeKind, message: string, options?: ChatNoticeOptions): void;
|
|
135
|
+
/**
|
|
136
|
+
* 往输入框里放东西(跟进建议、MCP 应用消息)。内置 Web 注入自己的输入框桥接;否则走
|
|
137
|
+
* `AgentSession.insertText` / `attach`,由聊天面板的输入框接住——两种宿主同一条路径。
|
|
138
|
+
*/
|
|
139
|
+
export declare function useComposerBridge(sessionId: string | null | undefined): {
|
|
140
|
+
appendText(text: string, separate?: boolean): void;
|
|
141
|
+
addContext(context: {
|
|
142
|
+
label: string;
|
|
143
|
+
content: string;
|
|
144
|
+
}): void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* 虚拟列表:注入了就用,没注入时返回空实现,`enabled` 为 false——调用方据此把全部行按常驻行渲染。
|
|
148
|
+
*/
|
|
149
|
+
export declare function useChatVirtualizer(options: ChatVirtualizerOptions): {
|
|
150
|
+
virtualizer: ChatVirtualizer;
|
|
151
|
+
enabled: boolean;
|
|
152
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 换身份(登出、换账号、换后端)时清掉富输入按 client 缓存的数据(技能菜单、模型目录等),
|
|
3
|
+
* 新身份不会看到上一个身份的清单。富输入的缓存在这里登记清理函数;宿主在身份变化时调用
|
|
4
|
+
* `resetInputCaches`。放在 internal 入口,宿主调用它不必引入富输入。
|
|
5
|
+
*/
|
|
6
|
+
import type { BladeClient } from "@blade-hq/agent-client";
|
|
7
|
+
export declare function onInputCachesReset(client: BladeClient, reset: () => void): void;
|
|
8
|
+
export declare function resetInputCaches(client: BladeClient): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 富输入(`@blade-hq/agent-react/rich-input`)可替换的数据来源与宿主部件。富输入对每一项都有基于
|
|
3
|
+
* BladeClient 的默认实现(插件侧栏直接用默认);内置 Web 只在要和自己的 React Query 缓存、
|
|
4
|
+
* 全局 store 打通的地方覆盖,或补上只有它有的部件(远程电脑、外部账号)。
|
|
5
|
+
*
|
|
6
|
+
* 这个上下文放在 internal 入口:内置 Web 在应用根部提供它,不必为此引入富输入的依赖。
|
|
7
|
+
* hook 形式的注入点必须是稳定引用(模块常量),输入框无条件调用。
|
|
8
|
+
*/
|
|
9
|
+
import type { BackgroundTask, ConnectionStatus, SessionContextStats } from "@blade-hq/agent-client/internal";
|
|
10
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
11
|
+
/** 模型目录(`GET /api/config/models`)。 */
|
|
12
|
+
export interface InputModelOption {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
inputModalities?: string[];
|
|
16
|
+
supportsImage?: boolean;
|
|
17
|
+
thinkingAvailable?: boolean;
|
|
18
|
+
reasoningLevels?: string[];
|
|
19
|
+
defaultReasoningLevel?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface InputModelCatalog {
|
|
22
|
+
models: InputModelOption[];
|
|
23
|
+
defaultModel: string;
|
|
24
|
+
thinkingAvailable: boolean;
|
|
25
|
+
unavailableProviderIds: string[];
|
|
26
|
+
unavailableModelIds: string[];
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
isFetching: boolean;
|
|
29
|
+
refresh: () => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export interface InputModelPreferences {
|
|
32
|
+
/** 用户上次选的模型(新建会话时优先用)。 */
|
|
33
|
+
preferredModel: string | null;
|
|
34
|
+
setPreferredModel: (modelId: string) => void;
|
|
35
|
+
/** 各模型上次选的推理强度(模型 id → 档位)。 */
|
|
36
|
+
reasoningLevels: Record<string, string>;
|
|
37
|
+
setReasoningLevel: (modelId: string, level: string) => void;
|
|
38
|
+
}
|
|
39
|
+
/** 偏好里存的是 JSON 字符串(模型 id → 档位);坏数据当作没有。 */
|
|
40
|
+
export declare function parseModelReasoningLevels(value: string | null | undefined): Record<string, string>;
|
|
41
|
+
export interface InputKnowledgeBase {
|
|
42
|
+
id: number;
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface InputSessionSkill {
|
|
47
|
+
skill_id: string;
|
|
48
|
+
display_name?: string | null;
|
|
49
|
+
description: string;
|
|
50
|
+
local: boolean;
|
|
51
|
+
builtin?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface InputSkillStats {
|
|
54
|
+
loaded_skill_count: number;
|
|
55
|
+
loaded_skill_names: string[];
|
|
56
|
+
remote_configured: boolean;
|
|
57
|
+
remote_connected: boolean;
|
|
58
|
+
installed_skill_count: number;
|
|
59
|
+
}
|
|
60
|
+
export interface InputConnection {
|
|
61
|
+
status: ConnectionStatus;
|
|
62
|
+
/** 正在第几次重连(0 表示没有在重连)。 */
|
|
63
|
+
reconnectAttempt: number;
|
|
64
|
+
hasEverConnected: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface InputDataState<T> {
|
|
67
|
+
data: T | undefined;
|
|
68
|
+
loading: boolean;
|
|
69
|
+
error: unknown;
|
|
70
|
+
}
|
|
71
|
+
export interface ConnectorComputerSectionProps {
|
|
72
|
+
sessionId: string | null;
|
|
73
|
+
query: string;
|
|
74
|
+
pendingSelection?: string[];
|
|
75
|
+
onPendingSelectionChange?: (ids: string[]) => void;
|
|
76
|
+
/** 收起连接器面板(打开设置之类的动作前调用)。 */
|
|
77
|
+
closePanel: () => void;
|
|
78
|
+
}
|
|
79
|
+
export interface RichInputServices {
|
|
80
|
+
useModelCatalog?: () => InputModelCatalog;
|
|
81
|
+
useModelPreferences?: () => InputModelPreferences;
|
|
82
|
+
/** 知识库清单(`@` 菜单打开时才调用)。 */
|
|
83
|
+
useKnowledgeBaseLoader?: () => () => Promise<InputKnowledgeBase[]>;
|
|
84
|
+
/** 语音是否可用(部署可以关掉);默认不可用,不显示麦克风。 */
|
|
85
|
+
voiceEnabled?: boolean;
|
|
86
|
+
/** 语音的 AudioWorklet 脚本地址。 */
|
|
87
|
+
voiceWorkletUrl?: string;
|
|
88
|
+
/** 连接状态;默认读当前会话的连接状态(没有会话时视为已连接)。 */
|
|
89
|
+
useConnection?: (sessionId: string | null) => InputConnection;
|
|
90
|
+
useSessionSkills?: (sessionId: string | null) => InputDataState<InputSessionSkill[]>;
|
|
91
|
+
useSkillStats?: (sessionId: string | null) => InputDataState<InputSkillStats>;
|
|
92
|
+
useContextStats?: (sessionId: string | null) => InputDataState<SessionContextStats>;
|
|
93
|
+
useBackgroundTasks?: (sessionId: string | null) => InputDataState<BackgroundTask[]>;
|
|
94
|
+
/** 宿主在这些变化后刷新自己的缓存(文件树、技能状态)。 */
|
|
95
|
+
useSessionDataInvalidation?: () => {
|
|
96
|
+
filesUploaded: (sessionId: string) => void;
|
|
97
|
+
pluginsChanged: (sessionId: string) => void;
|
|
98
|
+
};
|
|
99
|
+
/** 连接器面板里的「电脑」分区;不提供时不显示。 */
|
|
100
|
+
ConnectorComputerSection?: ComponentType<ConnectorComputerSectionProps>;
|
|
101
|
+
/** 连接器面板里的「外部账号」分区;不提供时不显示。 */
|
|
102
|
+
ConnectorAccountsSection?: ComponentType<{
|
|
103
|
+
query: string;
|
|
104
|
+
closePanel: () => void;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
export declare function RichInputServicesProvider({ value, children }: {
|
|
108
|
+
value: RichInputServices;
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
111
|
+
export declare function useRichInputServices(): RichInputServices;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聊天组件读会话状态的来源。组件只认 `AgentSession`,不关心实例由谁持有:
|
|
3
|
+
* 内置 Web 用自己的会话登记表(含静态会话、保留区),SDK 的 ChatView / `<blade-chat>` / 插件
|
|
4
|
+
* 用 `useAgentSession` 持有的那一个实例(`createSingleSessionSource`)。
|
|
5
|
+
*/
|
|
6
|
+
import { type AgentSession, type SessionState } from "@blade-hq/agent-client/internal";
|
|
7
|
+
import { type ReactNode } from "react";
|
|
8
|
+
export interface SessionSource {
|
|
9
|
+
subscribe(listener: () => void): () => void;
|
|
10
|
+
getSession(sessionId: string | null | undefined): AgentSession | undefined;
|
|
11
|
+
/** 首次进入会话、历史还没就绪(刚创建的会话不算)。 */
|
|
12
|
+
isHistoryLoading(sessionId: string | null | undefined): boolean;
|
|
13
|
+
/** 计划实时揭示计数:只在实时成功的 update_plan 后递增,任务进度面板据此自动展开。 */
|
|
14
|
+
planRevealRevision(sessionId: string | null | undefined): number;
|
|
15
|
+
/**
|
|
16
|
+
* 在会话就绪(历史与订阅都加载完)后执行动作。来源里的实例可能在首次加载完成前就已可见,
|
|
17
|
+
* 这时直接发送会拿着空状态判断(比如看不到正在等回答的子提问)。不提供时来源里的实例总是就绪的。
|
|
18
|
+
*/
|
|
19
|
+
whenReady?<T>(sessionId: string, run: (session: AgentSession) => Promise<T>): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
export declare function SessionSourceProvider({ source, children }: {
|
|
22
|
+
source: SessionSource;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function useSessionSource(): SessionSource;
|
|
26
|
+
/**
|
|
27
|
+
* 由单个会话实例组成的来源(SDK 聊天界面、插件用)。实例还没就绪时传 null;
|
|
28
|
+
* `loading` 表示正在连接或加载历史。
|
|
29
|
+
*/
|
|
30
|
+
export declare function useSingleSessionSource(session: AgentSession | null, loading: boolean): SessionSource;
|
|
31
|
+
/** 会话实例(给动作用),不订阅状态变化。 */
|
|
32
|
+
export declare function useSessionHandle(sessionId: string | null | undefined): AgentSession | null;
|
|
33
|
+
/**
|
|
34
|
+
* 读一小块会话状态;会话还没有实例时对空状态求值。
|
|
35
|
+
*
|
|
36
|
+
* selector 应直接返回 SessionState 里的字段或基本值(引用在未变化时稳定);需要派生数组 / 对象时
|
|
37
|
+
* 在组件里用 useMemo 基于返回值派生,否则每次状态变化都会产生新引用、触发重渲染。
|
|
38
|
+
*/
|
|
39
|
+
export declare function useSessionState<T>(sessionId: string | null | undefined, selector: (state: SessionState) => T): T;
|
|
40
|
+
/** 首次进入会话、历史还在加载。 */
|
|
41
|
+
export declare function useIsSessionHistoryLoading(sessionId: string | null | undefined): boolean;
|
|
42
|
+
/** 计划实时揭示计数。 */
|
|
43
|
+
export declare function usePlanRevealRevision(sessionId: string | null | undefined): number;
|
|
44
|
+
/** 当前聊天面板对应的会话;叶子组件没拿到 sessionId prop 时用它兜底。 */
|
|
45
|
+
export declare function CurrentChatSessionProvider({ sessionId, children }: {
|
|
46
|
+
sessionId: string | null;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function useCurrentChatSessionId(): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 聊天面板的动作与交互态:发送(等待回答时自动当作作答)、停止(带「停止中」)、等待消息队列命令
|
|
3
|
+
* (冲突提示与进行中的条目)。全部直接作用在会话实例上。
|
|
4
|
+
*/
|
|
5
|
+
import type { MessageContent } from "@blade-hq/agent-client/internal";
|
|
6
|
+
import { type ChatSendExtras } from "./actions";
|
|
7
|
+
export declare function useChatActions(sessionId: string): {
|
|
8
|
+
isStopping: boolean;
|
|
9
|
+
send: (msg: MessageContent, targetMode?: string, askuserAnswer?: Record<string, unknown>, options?: ChatSendExtras) => Promise<boolean>;
|
|
10
|
+
stop: () => Promise<void>;
|
|
11
|
+
queueNotice: string | null;
|
|
12
|
+
pendingQueueItemId: string | null;
|
|
13
|
+
queueMessage: (content: string) => Promise<boolean>;
|
|
14
|
+
updateQueuedMessage: (itemId: string, expectedVersion: number, content: string) => Promise<boolean>;
|
|
15
|
+
reorderQueuedMessages: (expectedRevision: number, orderedIds: string[]) => Promise<boolean>;
|
|
16
|
+
cancelQueuedMessage: (itemId: string, expectedVersion?: number) => Promise<boolean>;
|
|
17
|
+
deliverQueuedMessage: (itemId: string, expectedVersion: number) => Promise<boolean>;
|
|
18
|
+
resumeQueue: () => Promise<boolean>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReplaySpeed } from "@blade-hq/agent-client/internal";
|
|
2
|
+
export interface UseSessionReplayResult {
|
|
3
|
+
isReplay: boolean;
|
|
4
|
+
/** 能不能改回放(owner 专属)。只读身份仍然看得到"在回放",但不能操作。 */
|
|
5
|
+
canControl: boolean;
|
|
6
|
+
speed: ReplaySpeed;
|
|
7
|
+
setSpeed: (speed: ReplaySpeed) => Promise<void>;
|
|
8
|
+
exitToAutonomous: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 回放会话的状态与控制,只服务于回放条(不接管「输入对不上录制内容」的处理)。
|
|
12
|
+
*
|
|
13
|
+
* 状态与控制都来自 AgentSession(`state.replay`、`setReplaySpeed` / `exitReplay`,控制请求在会话实例里
|
|
14
|
+
* 串行执行,晚到的旧响应不会把已经退出的会话又显示成回放中)。
|
|
15
|
+
*/
|
|
16
|
+
export declare function useSessionReplay(sessionId: string | null | undefined): UseSessionReplayResult;
|