@blade-hq/agent-react 2610.0.1 → 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,42 @@
|
|
|
1
|
+
import type { SkillMentionAvailability } from "@blade-hq/agent-client";
|
|
2
|
+
/**
|
|
3
|
+
* 输入框(tiptap)文档的最小结构,以及把它翻译成待发送文本的规则。
|
|
4
|
+
*
|
|
5
|
+
* 首页和会话内是两个不同的输入框组件,但「药丸怎么变成文本」「开头那个技能
|
|
6
|
+
* 是哪个」必须是同一套判定——两边各写一份就会出现只有一侧修好的 bug。
|
|
7
|
+
*/
|
|
8
|
+
export interface EditorJSON {
|
|
9
|
+
type?: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
attrs?: Record<string, unknown>;
|
|
12
|
+
content?: EditorJSON[];
|
|
13
|
+
}
|
|
14
|
+
export declare function serializeEditorContent(node: EditorJSON | null | undefined): string;
|
|
15
|
+
export interface LeadingSkillMention extends SkillMentionAvailability {
|
|
16
|
+
skillId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 只有正文最开头的技能药丸才算「这条消息要用哪个技能」。前面已经有别的内容
|
|
20
|
+
* 时,药丸只是被提到,不改写整条消息的意图。
|
|
21
|
+
*/
|
|
22
|
+
export declare function findLeadingSkillMention(node: EditorJSON | null | undefined): LeadingSkillMention | null;
|
|
23
|
+
export interface KbMentionRef {
|
|
24
|
+
kbId: number;
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 收集正文里所有知识库药丸(按出现顺序去重)。位置不限——不像技能只认开头,
|
|
29
|
+
* 用户在句中 @ 一个库同样是在圈定这条消息的检索范围。
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectKbMentions(node: EditorJSON | null | undefined): KbMentionRef[];
|
|
32
|
+
/**
|
|
33
|
+
* 输入历史(ArrowUp/ArrowDown 召回)只存了序列化后的纯文本——知识库药丸序列化
|
|
34
|
+
* 成 `@库名` 就是普通文字,`kbId` 早就丢了。召回时如果只是把文字塞回编辑器,
|
|
35
|
+
* 画面上看着还是 `@库名`,但已经是纯文本、不是真的 kbMention 节点,
|
|
36
|
+
* `collectKbMentions` 找不到,后端就不会收到这次显式的知识库 Context 声明。
|
|
37
|
+
*
|
|
38
|
+
* 这里按文字里 `@库名` 出现的位置,把召回时一并存下来的 `kbMentions` 换回真的
|
|
39
|
+
* kbMention 节点,其余部分照旧当纯文本——只在能找到对应文字的地方才替换,
|
|
40
|
+
* 找不到就原样留成文字,不强行拼接、不假装恢复成功。
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildEditorDocumentWithKbMentions(text: string, kbMentions: readonly KbMentionRef[]): EditorJSON;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const IMAGE_INPUT_UNSUPPORTED_MESSAGE = "\u5F53\u524D\u6A21\u578B\u6682\u4E0D\u652F\u6301\u56FE\u7247";
|
|
2
|
+
export declare function isImageFile(file: Pick<File, "type" | "name">): boolean;
|
|
3
|
+
export declare function getUnsupportedImageFiles(files: readonly Pick<File, "type" | "name">[], supportsImage: boolean | undefined): Pick<File, "type" | "name">[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { KbSuggestionItem } from "../extensions/kb-mention";
|
|
2
|
+
/** 知识库列表里候选需要的字段(blade_hub `GET /api/kb`)。 */
|
|
3
|
+
export interface KnowledgeBaseSummary {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `@知识库` 候选:首页和会话内的输入框都从 `useKnowledgeBases()`(blade_hub
|
|
10
|
+
* `GET /api/kb`)拿同一份列表,这里只负责整形和按输入过滤——两边各写一份
|
|
11
|
+
* 过滤规则就会出现只有一侧修好的 bug。
|
|
12
|
+
*/
|
|
13
|
+
export declare function toKbSuggestionItems(knowledgeBases: readonly KnowledgeBaseSummary[]): KbSuggestionItem[];
|
|
14
|
+
/**
|
|
15
|
+
* 知识库候选和本地文件候选在 `@` 菜单里是 `Promise.all` 并发拉的:Hub 配置了但
|
|
16
|
+
* 慢或不可达时,本来秒回的文件候选会被知识库这条请求的超时(走注册中心代理,
|
|
17
|
+
* 可能到 10s)一起拖住——一个可选外部服务的延迟不该拖累本来正常工作的文件补全。
|
|
18
|
+
* 这里给知识库候选加个短超时:超时就先交回空数组,不阻塞文件候选返回;不取消
|
|
19
|
+
* 底层请求,它还在后台跑,配合 `notifyWhenKbSuggestionsArriveLate` 在真结果到了
|
|
20
|
+
* 之后把知识库分组补进已经打开的菜单——TipTap 的 suggestion 不会自己重新调用
|
|
21
|
+
* `items()`,光靠"下一次按键"接不住"用户 @ 完不再打字"这种情况。
|
|
22
|
+
*/
|
|
23
|
+
export declare const KB_SUGGESTION_TIMEOUT_MS = 300;
|
|
24
|
+
export declare function withKbSuggestionTimeout<T>(promise: Promise<T[]>, timeoutMs?: number): Promise<T[]>;
|
|
25
|
+
/**
|
|
26
|
+
* 配合 `withKbSuggestionTimeout`:这次 `items()` 因为超时空手而归(`raced` 为空)
|
|
27
|
+
* 时,挂一个回调,真结果(哪怕比超时晚)到了就通知调用方——回调里怎么把结果塞回
|
|
28
|
+
* 界面由调用方决定(组件里握着 TipTap 的 render 生命周期,这里只管"迟到了要不要
|
|
29
|
+
* 通知"这条纯逻辑,不碰 DOM/React)。`raced` 非空(超时内已经拿到真实结果,或者
|
|
30
|
+
* 知识库本来就是空列表)时什么都不做——不重复触发一次回调。
|
|
31
|
+
*/
|
|
32
|
+
export declare function notifyWhenKbSuggestionsArriveLate<T>(kbPromise: Promise<T[]>, raced: T[], onLate: (items: T[]) => void): void;
|
|
33
|
+
/**
|
|
34
|
+
* 输入里出现路径分隔符时用户是在浏览文件目录,知识库分组整个收起;
|
|
35
|
+
* 否则按名称 / 描述子串匹配(不区分大小写)。
|
|
36
|
+
*/
|
|
37
|
+
export declare function filterKbSuggestions(items: readonly KbSuggestionItem[], query: string): KbSuggestionItem[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reasoningLevelLabel(level: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 输入框工具条要读的会话数据:本会话已加载的技能、技能统计、上下文用量、后台任务。
|
|
3
|
+
* 默认实现直接用 BladeClient 请求,一轮回复结束(或收到后台任务事件)时刷新;内置 Web 用
|
|
4
|
+
* React Query 覆盖(由它的事件桥统一失效),见 `RichInputServices`。
|
|
5
|
+
*/
|
|
6
|
+
import type { BackgroundTask, SessionContextStats } from "@blade-hq/agent-client/internal";
|
|
7
|
+
import { useBladeClient } from "../../context";
|
|
8
|
+
import type { InputDataState, InputSessionSkill, InputSkillStats } from "../../chat/runtime/input-services";
|
|
9
|
+
export type { InputDataState as SessionDataState, InputSessionSkill as SessionSkillSummary, InputSkillStats as SkillStats, } from "../../chat/runtime/input-services";
|
|
10
|
+
export type { SessionContextStats };
|
|
11
|
+
/** 回复结束时让这些键过期重拉(有组件在用时)。 */
|
|
12
|
+
export declare function useRefreshWhenRunEnds(sessionId: string | null, keys: string[]): void;
|
|
13
|
+
export declare function useClientSessionSkills(sessionId: string | null): InputDataState<InputSessionSkill[]>;
|
|
14
|
+
export declare function useClientSkillStats(sessionId: string | null): InputDataState<InputSkillStats>;
|
|
15
|
+
export declare function useClientContextStats(sessionId: string | null): InputDataState<SessionContextStats>;
|
|
16
|
+
export declare function useClientBackgroundTasks(sessionId: string | null): InputDataState<BackgroundTask[]>;
|
|
17
|
+
/** 会话的技能变了(连接器开关插件等):让默认实现的技能数据重拉。 */
|
|
18
|
+
export declare function refreshClientSessionSkills(client: ReturnType<typeof useBladeClient>, sessionId: string): void;
|
|
19
|
+
/** 会话保存的模型(默认实现:请求会话详情,回复结束时刷新)。 */
|
|
20
|
+
export declare function useClientSessionModel(sessionId: string | null): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BladeClient } from "@blade-hq/agent-client";
|
|
2
|
+
import type { ChatRenderMode } from "../../chat/runtime/environment";
|
|
3
|
+
import type { SkillSuggestionItem, SkillSuggestionSkillItem } from "../extensions/skill-mention";
|
|
4
|
+
/**
|
|
5
|
+
* `/` 补全菜单的候选来源。首页和会话内共用这一份判定,两处不要各写一份——
|
|
6
|
+
* 首页没有会话,会话内有,差别只体现在这里。
|
|
7
|
+
*/
|
|
8
|
+
export interface SkillSuggestionOptions {
|
|
9
|
+
client: BladeClient;
|
|
10
|
+
/** 会话内传当前会话 id;首页传 null。 */
|
|
11
|
+
sessionId: string | null;
|
|
12
|
+
/** 开发者视图显示平台内置技能,其余视图隐藏。 */
|
|
13
|
+
renderMode: ChatRenderMode;
|
|
14
|
+
}
|
|
15
|
+
/** 会话的技能变了(连接器开关插件等):下一次 `/` 菜单重新取。 */
|
|
16
|
+
export declare function invalidateSlashSuggestions(client: BladeClient, sessionId: string | null): void;
|
|
17
|
+
/** 技能 + 工作流两类候选;工作流排在技能前面(数量少、意图明确)。 */
|
|
18
|
+
export declare function getSlashSuggestions(query: string, options: SkillSuggestionOptions): Promise<SkillSuggestionItem[]>;
|
|
19
|
+
export declare function getSkillSuggestions(query: string, options: SkillSuggestionOptions): Promise<SkillSuggestionSkillItem[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SessionContextStats } from "@blade-hq/agent-client/internal";
|
|
2
|
+
export type TokenPressureLevel = "normal" | "warn" | "critical";
|
|
3
|
+
export interface TokenPressure {
|
|
4
|
+
ratio: number;
|
|
5
|
+
level: TokenPressureLevel;
|
|
6
|
+
}
|
|
7
|
+
/** 上下文用量占窗口的比例与压力档位(接近自动整理阈值时提醒)。 */
|
|
8
|
+
export declare function tokenPressureOf(stats: SessionContextStats | undefined | null): TokenPressure;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Match a batch upload response to the submitted attachments by input position. */
|
|
2
|
+
export declare function uploadedPathsById<T extends {
|
|
3
|
+
id: string;
|
|
4
|
+
}>(attachments: readonly T[], results: readonly {
|
|
5
|
+
index: number;
|
|
6
|
+
path?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
}[]): Map<string, string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BladeClient } from "@blade-hq/agent-client";
|
|
2
|
+
export interface UserHomeEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
is_dir: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface UserHomeRuntime {
|
|
8
|
+
/** 云电脑 HOME 的绝对路径。沙盒是 `/root`,daemon 是它自报的用户目录。 */
|
|
9
|
+
homePath: string;
|
|
10
|
+
/** Windows daemon 的路径用反斜杠,拼子目录时不能写死 `/`。 */
|
|
11
|
+
separator: "/" | "\\";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 用户云电脑的 HOME 位置。不能假定是 `/root`:用户把某台 daemon 设成默认运行
|
|
15
|
+
* 环境时,HOME 是它自报的路径(`/home/alice`、`C:\Users\alice`),拿 `/root`
|
|
16
|
+
* 去问会被判为越界,补全菜单就会静默空掉。
|
|
17
|
+
*/
|
|
18
|
+
export declare function getUserHomeRuntime(client: BladeClient): Promise<UserHomeRuntime>;
|
|
19
|
+
/**
|
|
20
|
+
* 最近一次解析出的运行环境。补全菜单渲染时条目已经拉好了,此时运行环境必然
|
|
21
|
+
* 已解析——同步读一份,省得把 Promise 传进渲染路径。
|
|
22
|
+
*/
|
|
23
|
+
export declare function getLastUserHomeRuntime(): UserHomeRuntime;
|
|
24
|
+
/**
|
|
25
|
+
* 列出用户云电脑 HOME 下某个目录的内容。不需要会话——首页在还没建会话时
|
|
26
|
+
* 就要能引用这些文件。后端已按统一规则跳过隐藏项、依赖目录和编译产物。
|
|
27
|
+
*
|
|
28
|
+
* 补全菜单每敲一个字符都会问一次候选,而在同一个目录里继续输入时问的是同
|
|
29
|
+
* 一个目录——后端返回整个目录、过滤在前端做,几千个文件的目录每次就是几百
|
|
30
|
+
* KB。所以按目录缓存一小段时间:缓存的是 Promise,连续输入产生的并发请求
|
|
31
|
+
* 也会自动合并成一个。失败不留缓存,下次重试。
|
|
32
|
+
*/
|
|
33
|
+
export declare function listUserHomeDir(client: BladeClient, dirPath: string): Promise<UserHomeEntry[]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type InputModelCatalog, type InputModelPreferences } from "../../chat/runtime/input-services";
|
|
2
|
+
export type { InputModelCatalog as ModelCatalogState, InputModelOption as ModelOption, InputModelPreferences as ModelPreferencesState, } from "../../chat/runtime/input-services";
|
|
3
|
+
export declare function useClientModelCatalog(): InputModelCatalog;
|
|
4
|
+
export declare const PREFERRED_MODEL_KEY = "preferred_model";
|
|
5
|
+
export declare const MODEL_REASONING_LEVELS_KEY = "llm.model_thinking_preferences";
|
|
6
|
+
export declare function useClientModelPreferences(): InputModelPreferences;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型目录还在加载时按回车的提示。这时发出去拿不到用户选的模型与推理强度,所以不发送;
|
|
3
|
+
* 但发送按钮只对点击生效,回车绕过了它,不提示就是静默吞掉(#3103)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const MODEL_LOADING_SEND_HINT = "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u914D\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u518D\u53D1\u9001";
|
|
6
|
+
export type ModelLoadingSendGate = {
|
|
7
|
+
blocked: false;
|
|
8
|
+
} | {
|
|
9
|
+
blocked: true;
|
|
10
|
+
hint: string | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 模型目录加载中的发送判定,首页输入框(apps/web HomeInput)与会话输入框(ChatInput)共用:
|
|
14
|
+
* 加载中一律不发;输入框里有可发送的内容时给出提示,空输入框按回车不打扰。
|
|
15
|
+
* 「有没有可发送的内容」由各输入框按自己的内容模型算好传进来。
|
|
16
|
+
*/
|
|
17
|
+
export declare function gateSendWhileModelLoading(isModelLoading: boolean, hasContent: boolean): ModelLoadingSendGate;
|
|
18
|
+
interface ResolvedModelState {
|
|
19
|
+
resolvedModel: string;
|
|
20
|
+
hasAvailableModel: boolean;
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ExplicitModelSelection {
|
|
24
|
+
sessionId: string | null;
|
|
25
|
+
model: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A selector choice is a composer draft until chat:send accepts it and the
|
|
29
|
+
* server broadcasts session:updated. Keep it separate from the persisted
|
|
30
|
+
* session model so a session-list refresh cannot discard the next-send choice.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveComposerModel(activeSessionId: string | null, persistedModel: string | null | undefined, explicitSelection: ExplicitModelSelection | null): string | null;
|
|
33
|
+
export declare function resolveModelChoice({ activeSessionModel, preferredModel, defaultModel, models, isLoading, unavailableProviderIds, unavailableModelIds, }: {
|
|
34
|
+
activeSessionModel?: string | null;
|
|
35
|
+
preferredModel?: string | null;
|
|
36
|
+
defaultModel: string;
|
|
37
|
+
models: readonly {
|
|
38
|
+
id: string;
|
|
39
|
+
}[];
|
|
40
|
+
isLoading: boolean;
|
|
41
|
+
unavailableProviderIds?: readonly string[];
|
|
42
|
+
unavailableModelIds?: readonly string[];
|
|
43
|
+
}): ResolvedModelState;
|
|
44
|
+
export declare function useResolvedModel(activeSessionModel?: string | null): {
|
|
45
|
+
resolvedModel: string;
|
|
46
|
+
hasAvailableModel: boolean;
|
|
47
|
+
thinkingAvailable: boolean;
|
|
48
|
+
reasoningLevels: string[];
|
|
49
|
+
defaultReasoningLevel: string;
|
|
50
|
+
modelAvailabilityMessage: string;
|
|
51
|
+
supportsImage: boolean | undefined;
|
|
52
|
+
isLoading: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** 某个模型上次选的推理强度(没有选过时为 null)。 */
|
|
55
|
+
export declare function useReasoningLevelPreference(modelId: string): {
|
|
56
|
+
reasoningLevelPreference: string | null;
|
|
57
|
+
setReasoningLevelPreference: (level: string) => void;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ComposerSubmitModels {
|
|
2
|
+
/** 还没有会话、先建会话时用的模型。 */
|
|
3
|
+
newSessionModel: string | null;
|
|
4
|
+
/** 随消息发送的模型;null 表示沿用会话已保存的模型。 */
|
|
5
|
+
sendModel: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** 输入框当前的模型选择与推理档位(发送时带上)。 */
|
|
8
|
+
export interface ComposerModelState {
|
|
9
|
+
/** 当前选中的模型(加载中时是乐观值)。 */
|
|
10
|
+
selectedModel: string;
|
|
11
|
+
hasAvailableModel: boolean;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
/** 没有可用模型时给用户看的说明。 */
|
|
14
|
+
availabilityMessage: string;
|
|
15
|
+
thinkingAvailable: boolean;
|
|
16
|
+
reasoningLevels: string[];
|
|
17
|
+
selectedReasoningLevel: string;
|
|
18
|
+
setReasoningLevel: (level: string) => void;
|
|
19
|
+
/** 用户在选择器里选了一个模型。 */
|
|
20
|
+
selectModel: (model: string) => void;
|
|
21
|
+
/** 提交那一刻冻结的模型选择(上传与 onBeforeSend 可能要等,发出去的仍是提交时看到的模型)。 */
|
|
22
|
+
freezeForSubmit: () => ComposerSubmitModels;
|
|
23
|
+
}
|
|
24
|
+
export declare function useComposerModel(activeSessionId: string | null): ComposerModelState;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 富输入的数据来源:宿主覆盖了就用宿主的(内置 Web 的 React Query 缓存、全局 store),
|
|
3
|
+
* 否则用基于 BladeClient 的默认实现。覆盖点见 `RichInputServices`(internal 入口)。
|
|
4
|
+
*/
|
|
5
|
+
import type { BackgroundTask, ConnectionStatus, SessionContextStats } from "@blade-hq/agent-client/internal";
|
|
6
|
+
import { type InputConnection, type InputDataState, type InputKnowledgeBase, type InputModelCatalog, type InputModelPreferences, type InputSessionSkill, type InputSkillStats } from "../chat/runtime/input-services";
|
|
7
|
+
export { type ConnectorComputerSectionProps, type InputConnection, type InputDataState, type InputKnowledgeBase, type InputModelCatalog, type InputModelOption, type InputModelPreferences, type InputSessionSkill, type InputSkillStats, type RichInputServices, RichInputServicesProvider, useRichInputServices, } from "../chat/runtime/input-services";
|
|
8
|
+
export declare function useModelCatalog(): InputModelCatalog;
|
|
9
|
+
export declare function useModelPreferences(): InputModelPreferences;
|
|
10
|
+
export declare function useKnowledgeBaseLoader(): () => Promise<InputKnowledgeBase[]>;
|
|
11
|
+
/** 连接情况:宿主给了就用宿主的(内置 Web 看全局连接),否则看当前会话。 */
|
|
12
|
+
export declare function useComposerConnectionInfo(sessionId: string | null): InputConnection;
|
|
13
|
+
export declare function useComposerConnection(sessionId: string | null): ConnectionStatus;
|
|
14
|
+
export declare function useSessionSkills(sessionId: string | null): InputDataState<InputSessionSkill[]>;
|
|
15
|
+
export declare function useSkillStats(sessionId: string | null): InputDataState<InputSkillStats>;
|
|
16
|
+
export declare function useContextStats(sessionId: string | null): InputDataState<SessionContextStats>;
|
|
17
|
+
export declare function useBackgroundTaskList(sessionId: string | null): InputDataState<BackgroundTask[]>;
|
|
18
|
+
/** 附件上传、插件开关之后让相关数据刷新。 */
|
|
19
|
+
export declare function useSessionDataInvalidation(): {
|
|
20
|
+
filesUploaded: (sessionId: string) => void;
|
|
21
|
+
pluginsChanged: (sessionId: string) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KbMentionRef } from "./lib/composer-content";
|
|
2
|
+
/** 一条历史记录:文字 + 这条消息里 @ 过的知识库(召回时用来复原真的 kbMention
|
|
3
|
+
* 节点,不然画面上还是 "@库名" 但已经是纯文本,kb_search 拿不到 kbIds)。 */
|
|
4
|
+
export interface InputHistoryEntry {
|
|
5
|
+
text: string;
|
|
6
|
+
kbMentions: KbMentionRef[];
|
|
7
|
+
}
|
|
8
|
+
export declare function useInputHistory(sessionId: string | null): {
|
|
9
|
+
addEntry: (value: string, kbMentions?: KbMentionRef[]) => void;
|
|
10
|
+
navigateUp: (currentDraft?: string) => InputHistoryEntry | null;
|
|
11
|
+
navigateDown: () => InputHistoryEntry | null;
|
|
12
|
+
currentEntry: InputHistoryEntry;
|
|
13
|
+
isNavigating: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface VoiceWaveformProps {
|
|
2
|
+
/** RMS 幅度 0..1 */
|
|
3
|
+
level: number;
|
|
4
|
+
/** 线条颜色;默认跟随 currentColor */
|
|
5
|
+
color?: string;
|
|
6
|
+
/** 按钮直径参考值,决定波形尺寸 */
|
|
7
|
+
size?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function VoiceWaveform({ level, color, size }: VoiceWaveformProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Editor as TiptapEditor } from "@tiptap/react";
|
|
2
|
+
import type { VoiceInputError } from "./voice-input-support";
|
|
3
|
+
export type VoiceInputStatus = "idle" | "starting" | "recording" | "stopping" | "error";
|
|
4
|
+
export interface UseVoiceInputOptions {
|
|
5
|
+
workletUrl: string;
|
|
6
|
+
onPartial?: (text: string) => void;
|
|
7
|
+
onFinal?: (text: string) => void;
|
|
8
|
+
onError?: (error: VoiceInputError) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface UseVoiceInputResult {
|
|
11
|
+
status: VoiceInputStatus;
|
|
12
|
+
error: string | null;
|
|
13
|
+
/** 当前音频 RMS 幅度,0..1,仅在 recording 期间有意义,用于驱动波形动画 */
|
|
14
|
+
level: number;
|
|
15
|
+
start: () => Promise<void>;
|
|
16
|
+
stop: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** 语音识别(宿主注入:内置 Web 走自己的 ASR 通道)。 */
|
|
19
|
+
export type UseVoiceInput = (options: UseVoiceInputOptions) => UseVoiceInputResult;
|
|
20
|
+
export interface UseTiptapVoiceInputOptions {
|
|
21
|
+
/** Tiptap editor ref;null 时 voice 回调会静默丢弃 */
|
|
22
|
+
editorRef: {
|
|
23
|
+
current: TiptapEditor | null;
|
|
24
|
+
};
|
|
25
|
+
/** AudioWorklet processor 文件 URL */
|
|
26
|
+
workletUrl: string;
|
|
27
|
+
/** 外部可选回调:识别错误时拿 message */
|
|
28
|
+
onError?: (error: VoiceInputError) => void;
|
|
29
|
+
/** 语音识别实现;不传时语音不可用(toggle 无效果)。 */
|
|
30
|
+
useVoiceInput?: UseVoiceInput;
|
|
31
|
+
}
|
|
32
|
+
export interface UseTiptapVoiceInputResult {
|
|
33
|
+
status: VoiceInputStatus;
|
|
34
|
+
isRecording: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
/** 当前音频 RMS 幅度,0..1,仅在 recording 期间有意义,用于驱动波形动画 */
|
|
37
|
+
level: number;
|
|
38
|
+
toggle: () => void;
|
|
39
|
+
stop: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tiptap 编辑器里的语音输入集成:
|
|
43
|
+
* - partial 段用 `insertContentAt({from,to}, text)` 替换一个可变 range
|
|
44
|
+
* - final 段落定后把 range 推进到末尾,下一段重新起
|
|
45
|
+
* - 录音期间调用 `editor.setEditable(false)` 锁定键盘输入
|
|
46
|
+
*/
|
|
47
|
+
export declare function useTiptapVoiceInput(options: UseTiptapVoiceInputOptions): UseTiptapVoiceInputResult;
|