@blade-hq/agent-react 2608.0.8-beta.0 → 2608.0.8

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/public-api.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > 本文件由 `scripts/public-api-report.mjs` 生成,请勿手改。
4
4
  > 公共面变更时重新生成本报告,并同步更新 README 对应章节——CI 会校验两者。
5
5
 
6
- 共 159 个公开声明。
6
+ 共 137 个公开声明。
7
7
 
8
8
  ## `ActiveCompactionState` (interface)
9
9
 
@@ -24,27 +24,6 @@ trigger: "auto" | "manual" | "forced_retry" | null | undefined
24
24
  turn_id: string
25
25
  ```
26
26
 
27
- ## `AgentChat` (function)
28
-
29
- ```ts
30
- AgentChat: (props: AgentChatProps) => JSX.Element
31
- ```
32
-
33
- ## `AgentChatProps` (interface)
34
-
35
- ```ts
36
- classNames: ChatViewClassNames | undefined
37
- commands: Record<string, (data: unknown) => void> | undefined
38
- createOptions: CreateSessionRequest | undefined
39
- onSessionCreated: ((sessionId: string) => void) | undefined
40
- onSessionReady: ((session: AgentSession) => void) | undefined
41
- placeholder: string | undefined
42
- renderers: ChatViewRenderers | undefined
43
- sessionId: string | undefined
44
- slots: ChatViewSlots | undefined
45
- theme: "light" | "dark" | undefined
46
- ```
47
-
48
27
  ## `AgentLoopInfo` (interface)
49
28
 
50
29
  ```ts
@@ -63,7 +42,6 @@ compact: () => Promise<Record<string, unknown>>
63
42
  countFiles: (dirPath?: string) => Promise<number>
64
43
  dispose: () => void
65
44
  downloadFile: (filePath: string, downloadName?: string) => Promise<void>
66
- exitReplay: () => Promise<void>
67
45
  getState: () => SessionState
68
46
  insertText: (text: string) => void
69
47
  isDisposed: boolean
@@ -73,7 +51,6 @@ on: <K extends keyof AgentSessionEvents>(name: K, handler: (event: AgentSessionE
73
51
  onCommand: (action: string, handler: CommandHandler) => () => void
74
52
  send: (content: MessageContent, options?: SendOptions) => Promise<boolean>
75
53
  sessionId: string
76
- setReplaySpeed: (speed: ReplaySpeed) => Promise<void>
77
54
  stop: () => Promise<Record<string, unknown>>
78
55
  subscribe: (listener: () => void) => () => void
79
56
  ```
@@ -170,7 +147,6 @@ getContext: () => Record<string, unknown> | Promise<Record<string, unknown>>
170
147
  ## `AuthResource` (class)
171
148
 
172
149
  ```ts
173
- exchangeCode: (params: ExchangeCodeParams) => Promise<ExchangeCodeResult>
174
150
  getMe: () => Promise<UserInfo>
175
151
  getProviders: () => Promise<ProvidersResponse>
176
152
  login: (options?: LoginOptions) => Promise<LoginResult>
@@ -284,13 +260,6 @@ client: BladeClient
284
260
  buildMessageContent: (text: string, attachments: Array<{ kind: "file"; name: string; uploadedPath?: string; textContent?: string | null; mimeType?: string; }>) => MessageContent
285
261
  ```
286
262
 
287
- ## `ChatCompletionTool` (interface)
288
-
289
- ```ts
290
- function: { name: string; description?: string; parameters?: Record<string, unknown>; }
291
- type: "function"
292
- ```
293
-
294
263
  ## `ChatMessage` (interface)
295
264
 
296
265
  ```ts
@@ -331,9 +300,6 @@ root: string | undefined
331
300
  classNames: ChatViewClassNames | undefined
332
301
  commands: Record<string, (data: unknown) => void> | undefined
333
302
  createOptions: CreateSessionRequest | undefined
334
- llm: (LlmChatOptions & { advanced?: boolean | LlmAdvancedSettings; onOverrideChange?: (override: LlmOverride) => void; }) | undefined
335
- mode: "agent" | "llm" | undefined
336
- onLlmReady: ((handle: LlmChatHandle) => void) | undefined
337
303
  onSessionCreated: ((sessionId: string) => void) | undefined
338
304
  onSessionReady: ((session: AgentSession) => void) | undefined
339
305
  placeholder: string | undefined
@@ -467,12 +433,6 @@ path: string | undefined
467
433
  token: string | (() => string | null | undefined) | undefined
468
434
  ```
469
435
 
470
- ## `DEFAULT_REPLAY_SPEED` (const)
471
-
472
- ```ts
473
- DEFAULT_REPLAY_SPEED: ReplaySpeed
474
- ```
475
-
476
436
  ## `EmbeddedChat` (interface)
477
437
 
478
438
  ```ts
@@ -490,20 +450,10 @@ allowedOrigins: string[]
490
450
  iframe: HTMLIFrameElement | undefined
491
451
  ```
492
452
 
493
- ## `ExchangeCodeParams` (interface)
453
+ ## `EMPTY_PLATFORM_ENDPOINTS` (const)
494
454
 
495
455
  ```ts
496
- clientOrigin: string
497
- code: string
498
- state: string
499
- ```
500
-
501
- ## `ExchangeCodeResult` (interface)
502
-
503
- ```ts
504
- access_token: string
505
- token_type: string
506
- user: { id: string; username: string; display_name: string; avatar_url: string | null; }
456
+ EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints
507
457
  ```
508
458
 
509
459
  ## `ExistingSolutionRef` (interface)
@@ -632,86 +582,18 @@ export enum LayoutType {
632
582
  }
633
583
  ```
634
584
 
635
- ## `LlmAdvancedSettings` (interface)
636
-
637
- ```ts
638
- apiKey: boolean | undefined
639
- baseURL: boolean | undefined
640
- model: boolean | undefined
641
- storage: "local" | "memory" | undefined
642
- storageKey: string | undefined
643
- ```
644
-
645
- ## `LlmChat` (function)
585
+ ## `loadPlatformEndpoints` (function)
646
586
 
647
587
  ```ts
648
- LlmChat: ({ classNames, renderers, slots, placeholder, theme, onReady, advanced, onOverrideChange, ...options }: LlmChatProps) => JSX.Element
588
+ loadPlatformEndpoints: (options?: LoadPlatformEndpointsOptions) => Promise<PlatformEndpoints>
649
589
  ```
650
590
 
651
- ## `LlmChatHandle` (interface)
591
+ ## `LoadPlatformEndpointsOptions` (interface)
652
592
 
653
593
  ```ts
654
- insertText: (text: string) => void
655
- reset: () => void
656
- send: (text: string) => Promise<boolean>
657
- ```
658
-
659
- ## `LlmChatOptions` (interface)
660
-
661
- ```ts
662
- apiKey: string | undefined
663
- baseURL: string
664
- extraBody: Record<string, unknown> | undefined
665
- fetchImpl: { (input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined
666
- headers: Record<string, string> | undefined
667
- historyTurns: number | undefined
668
- maxToolRounds: number | undefined
669
- model: string
670
- onToolCall: ((call: LlmToolCall) => Promise<unknown>) | undefined
671
- system: string | undefined
672
- temperature: number | undefined
673
- tools: ChatCompletionTool[] | undefined
674
- ```
675
-
676
- ## `LlmChatProps` (interface)
677
-
678
- ```ts
679
- advanced: boolean | LlmAdvancedSettings | undefined
680
- apiKey: string | undefined
681
- baseURL: string
682
- classNames: ChatViewClassNames | undefined
683
- extraBody: Record<string, unknown> | undefined
594
+ baseUrl: string | undefined
684
595
  fetchImpl: { (input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined
685
- headers: Record<string, string> | undefined
686
- historyTurns: number | undefined
687
- maxToolRounds: number | undefined
688
- model: string
689
- onOverrideChange: ((override: LlmOverride) => void) | undefined
690
- onReady: ((handle: LlmChatHandle) => void) | undefined
691
- onToolCall: ((call: LlmToolCall) => Promise<unknown>) | undefined
692
- placeholder: string | undefined
693
- renderers: ChatViewRenderers | undefined
694
- slots: ChatViewSlots | undefined
695
- system: string | undefined
696
- temperature: number | undefined
697
- theme: "light" | "dark" | undefined
698
- tools: ChatCompletionTool[] | undefined
699
- ```
700
-
701
- ## `LlmOverride` (interface)
702
-
703
- ```ts
704
- apiKey: string | undefined
705
- baseURL: string | undefined
706
- model: string | undefined
707
- ```
708
-
709
- ## `LlmToolCall` (interface)
710
-
711
- ```ts
712
- arguments: string
713
- id: string
714
- name: string
596
+ timeoutMs: number | undefined
715
597
  ```
716
598
 
717
599
  ## `LoginOptions` (interface)
@@ -781,9 +663,7 @@ export type ModeId = "planning" | "executing"
781
663
  ## `ModelCatalog` (interface)
782
664
 
783
665
  ```ts
784
- baseUrl: string | undefined
785
666
  default: string
786
- defaultServiceModel: string | undefined
787
667
  models: ModelOption[]
788
668
  ```
789
669
 
@@ -792,7 +672,6 @@ models: ModelOption[]
792
672
  ```ts
793
673
  id: string
794
674
  label: string
795
- serviceModelId: string | undefined
796
675
  ```
797
676
 
798
677
  ## `ModelsResource` (class)
@@ -841,6 +720,18 @@ sequence: number
841
720
  turn_id: string
842
721
  ```
843
722
 
723
+ ## `PlatformEndpoints` (interface)
724
+
725
+ ```ts
726
+ services: Partial<Record<"os" | "hub" | "agent" | "oauth" | "llmGateway" | "gitea", string>>
727
+ ```
728
+
729
+ ## `PlatformServiceName` (type)
730
+
731
+ ```ts
732
+ export type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]
733
+ ```
734
+
844
735
  ## `PreparedSolution` (interface)
845
736
 
846
737
  ```ts
@@ -902,76 +793,10 @@ payload: Record<string, unknown>
902
793
  type: string
903
794
  ```
904
795
 
905
- ## `ReplayBar` (function)
906
-
907
- ```ts
908
- ReplayBar: ({ isReplay, speed, onSpeedChange, onExit, canControl, className, }: ReplayBarProps) => JSX.Element | null
909
- ```
910
-
911
- ## `ReplayBarProps` (interface)
912
-
913
- ```ts
914
- canControl: boolean | undefined
915
- className: string | undefined
916
- isReplay: boolean
917
- onExit: () => void
918
- onSpeedChange: (speed: ReplaySpeed) => void
919
- speed: ReplaySpeed
920
- ```
921
-
922
- ## `ReplayMismatch` (interface)
923
-
924
- ```ts
925
- actualMessage: string
926
- expectedMessage: string
927
- resolve: (decision: "keep_replay" | "continue_replay") => void
928
- ```
929
-
930
- ## `ReplayMismatchPrompt` (function)
931
-
932
- ```ts
933
- ReplayMismatchPrompt: ({ mismatch, className }: ReplayMismatchPromptProps) => JSX.Element | null
934
- ```
935
-
936
- ## `ReplayMismatchPromptProps` (interface)
937
-
938
- ```ts
939
- className: string | undefined
940
- mismatch: ReplayMismatch | null
941
- ```
942
-
943
- ## `ReplayPreview` (interface)
944
-
945
- ```ts
946
- intent: string | null | undefined
947
- reason: string | null | undefined
948
- session_id: string
949
- supported: boolean
950
- ```
951
-
952
- ## `ReplaySnapshot` (interface)
953
-
954
- ```ts
955
- isReplay: boolean
956
- sourceSessionId: string | null
957
- speed: ReplaySpeed
958
- ```
959
-
960
- ## `ReplaySpeed` (type)
796
+ ## `resolveServiceUrl` (function)
961
797
 
962
798
  ```ts
963
- export type ReplaySpeed = 1 | 2 | 5
964
- ```
965
-
966
- ## `ReplayState` (interface)
967
-
968
- ```ts
969
- autonomous_reason: string | null | undefined
970
- ended_at: string | null | undefined
971
- next_source_entry_id: string | null | undefined
972
- source_session_id: string | undefined
973
- speed: ReplaySpeed | undefined
974
- status: "replay" | "autonomous" | undefined
799
+ resolveServiceUrl: (endpoints: PlatformEndpoints, name: PlatformServiceName, path?: string) => string | null
975
800
  ```
976
801
 
977
802
  ## `RunOptions` (interface)
@@ -1210,7 +1035,6 @@ downloadFile: (sessionId: string, filePath: string, downloadName?: string) => Pr
1210
1035
  exportSession: (sessionId: string) => Promise<void>
1211
1036
  getBackgroundTask: (sessionId: string, taskId: string, tail?: number, init?: RequestInit) => Promise<BackgroundTask>
1212
1037
  getDownloadDirUrl: (sessionId: string, dirPath: string) => string
1213
- getReplayPreview: (sessionId: string) => Promise<ReplayPreview>
1214
1038
  getSession: (sessionId: string, init?: RequestInit) => Promise<SessionDetail>
1215
1039
  getSessionCheckpoints: (sessionId: string, init?: RequestInit) => Promise<{ nodes: CheckpointNode[]; leaf_id: string | null; }>
1216
1040
  getSessionContextStats: (sessionId: string, init?: RequestInit) => Promise<SessionContextStats>
@@ -1232,12 +1056,12 @@ revokeShare: (sessionId: string, token: string) => Promise<{ revoked: boolean; }
1232
1056
  rewindSession: (sessionId: string, checkpointId: string) => Promise<{ id: string; content: string; }>
1233
1057
  setSessionEnv: (sessionId: string, env: Record<string, string>) => Promise<SessionDetail>
1234
1058
  shareFile: (sessionId: string, sourcePath: string, linkName?: string, shareFolder?: string) => Promise<{ path: string; target: string; }>
1235
- startReplaySession: (sourceSessionId: string, speed?: ReplaySpeed) => Promise<{ session_id: string; }>
1059
+ startReplaySession: (sourceSessionId: string, speed?: 1 | 2 | 5) => Promise<{ session_id: string; }>
1236
1060
  stopBackgroundTask: (sessionId: string, taskId: string) => Promise<BackgroundTaskStopResult>
1237
1061
  switchBranch: (sessionId: string, checkpointId: string) => Promise<{ id: string; leaf_id: string; }>
1238
1062
  tokenizeMessages: (messages: Array<Record<string, unknown>>, options?: { model?: string; add_generation_prompt?: boolean; enable_thinking?: boolean | null; tools?: Array<Record<string, unknown>>; }) => Promise<TokenizeResult>
1239
1063
  tokenizePrompt: (prompt: string, model?: string) => Promise<TokenizeResult>
1240
- updateReplaySession: (sessionId: string, payload: { speed?: ReplaySpeed; status?: "autonomous"; }) => Promise<{ replay_state: SessionInfo["replay_state"]; }>
1064
+ updateReplaySession: (sessionId: string, payload: { speed?: 1 | 2 | 5; status?: "autonomous"; }) => Promise<{ replay_state: SessionInfo["replay_state"]; }>
1241
1065
  updateSession: (sessionId: string, payload: { intent?: string; }) => Promise<SessionDetail>
1242
1066
  updateSessionMemory: (sessionId: string, memoryEnabled: boolean) => Promise<{ memory_enabled: boolean; }>
1243
1067
  updateSharing: (sessionId: string, shared: boolean) => Promise<{ shared: boolean; }>
@@ -1256,11 +1080,9 @@ errorMessage: string | null
1256
1080
  isStreaming: boolean
1257
1081
  messages: ChatMessage[]
1258
1082
  mode: "planning" | "executing" | null
1259
- replay: ReplaySnapshot | null
1260
1083
  sessionId: string
1261
1084
  status: "completed" | "failed" | "interrupted" | "running" | "created" | "waiting_for_input" | null
1262
1085
  turns: TurnProjection[]
1263
- viewerRole: "owner" | "viewer" | null
1264
1086
  ```
1265
1087
 
1266
1088
  ## `SessionStatus` (type)
@@ -1286,13 +1108,6 @@ files: TextFile[]
1286
1108
  name: string
1287
1109
  ```
1288
1110
 
1289
- ## `SkillMentionAvailability` (interface)
1290
-
1291
- ```ts
1292
- installed: boolean | undefined
1293
- local: boolean | undefined
1294
- ```
1295
-
1296
1111
  ## `Solution` (interface)
1297
1112
 
1298
1113
  ```ts
@@ -1442,16 +1257,10 @@ status: "done" | "error" | "cancelled" | "awaiting_answer" | "pending" | undefin
1442
1257
  export type ToolCallRenderer = (info: ToolCallInfo) => ReactNode | null
1443
1258
  ```
1444
1259
 
1445
- ## `toReplaySnapshot` (function)
1446
-
1447
- ```ts
1448
- toReplaySnapshot: (raw: ReplayState | null | undefined) => ReplaySnapshot | null
1449
- ```
1450
-
1451
1260
  ## `transformSlashCommand` (function)
1452
1261
 
1453
1262
  ```ts
1454
- transformSlashCommand: (skillName: string, rawInput: string, { local, installed }?: SkillMentionAvailability) => string
1263
+ transformSlashCommand: (skillName: string, rawInput: string) => string
1455
1264
  ```
1456
1265
 
1457
1266
  ## `TurnProjection` (interface)
@@ -1540,45 +1349,6 @@ state: SessionState | null
1540
1349
  useBladeClient: () => BladeClient
1541
1350
  ```
1542
1351
 
1543
- ## `useLlmChat` (function)
1544
-
1545
- ```ts
1546
- useLlmChat: (options: LlmChatOptions) => UseLlmChatResult
1547
- ```
1548
-
1549
- ## `UseLlmChatResult` (interface)
1550
-
1551
- ```ts
1552
- error: string | null
1553
- isStreaming: boolean
1554
- messages: ChatMessage[]
1555
- reset: () => void
1556
- send: (text: string) => Promise<boolean>
1557
- stop: () => void
1558
- ```
1559
-
1560
- ## `useReplay` (function)
1561
-
1562
- ```ts
1563
- useReplay: (session: AgentSession | null) => UseReplayResult
1564
- ```
1565
-
1566
- ## `UseReplayResult` (interface)
1567
-
1568
- ```ts
1569
- canControl: boolean
1570
- canReplay: boolean
1571
- error: Error | null
1572
- exitToAutonomous: () => Promise<void>
1573
- isReplay: boolean
1574
- isStarting: boolean
1575
- mismatch: ReplayMismatch | null
1576
- setSpeed: (speed: ReplaySpeed) => Promise<void>
1577
- speed: ReplaySpeed
1578
- startReplay: (speed?: ReplaySpeed) => Promise<string>
1579
- unsupportedReason: string | null
1580
- ```
1581
-
1582
1352
  ## `UserInfo` (interface)
1583
1353
 
1584
1354
  ```ts
@@ -1,18 +0,0 @@
1
- import type { AgentSession, CreateSessionRequest } from "@blade-hq/agent-client";
2
- import { type ChatPresentationProps } from "./ChatSurface";
3
- export interface AgentChatProps extends ChatPresentationProps {
4
- /** 连接既有会话;不传则按 createOptions 自动新建。 */
5
- sessionId?: string;
6
- createOptions?: CreateSessionRequest;
7
- /** 自动创建出的 sessionId 通过此回调交还调用方持有。 */
8
- onSessionCreated?: (sessionId: string) => void;
9
- /** 会话连接完成后回调(页面协作场景拿 AgentSession 实例用)。 */
10
- onSessionReady?: (session: AgentSession) => void;
11
- /** 智能体下发给宿主页面的指令处理器(action → handler)。 */
12
- commands?: Record<string, (data: unknown) => void>;
13
- }
14
- /**
15
- * 智能体模式的聊天界面:连接(或新建)一个 Blade 会话,渲染消息流与输入框。
16
- * 状态全部来自 useAgentSession,不依赖任何全局 store。
17
- */
18
- export declare function AgentChat(props: AgentChatProps): import("react/jsx-runtime").JSX.Element;
@@ -1,59 +0,0 @@
1
- import type { AskUserAnswerData, ChatMessage, ConnectionStatus } from "@blade-hq/agent-client";
2
- import type { ReactNode } from "react";
3
- import type { ToolCallRenderer } from "./ToolCallBlock";
4
- export interface ChatViewClassNames {
5
- root?: string;
6
- banner?: string;
7
- messageList?: string;
8
- chatInput?: string;
9
- }
10
- export interface ChatViewRenderers {
11
- /** 自定义工具调用渲染;返回 null 走默认渲染。 */
12
- toolCall?: ToolCallRenderer;
13
- }
14
- export interface ChatViewSlots {
15
- /** 消息列表上方的自定义区域。 */
16
- header?: ReactNode;
17
- /** 无消息时的空状态。 */
18
- emptyState?: ReactNode;
19
- /** 输入框下方的自定义区域。 */
20
- footer?: ReactNode;
21
- }
22
- /** 两种模式共用的外观属性。 */
23
- export interface ChatPresentationProps {
24
- classNames?: ChatViewClassNames;
25
- renderers?: ChatViewRenderers;
26
- slots?: ChatViewSlots;
27
- placeholder?: string;
28
- /** 配色主题,默认浅色。宿主已经在祖先元素上写了 data-theme 时不用传。 */
29
- theme?: "light" | "dark";
30
- }
31
- /** 主题落到聊天根节点上:深色变量挂在 [data-theme="dark"] 上,由它继承给整棵子树。 */
32
- export declare function themeAttr(theme: ChatPresentationProps["theme"]): "dark" | undefined;
33
- interface ChatSurfaceProps extends ChatPresentationProps {
34
- connection: ConnectionStatus;
35
- errorMessage: string | null;
36
- messages: ChatMessage[];
37
- isStreaming: boolean;
38
- isStopping: boolean;
39
- inputText: string;
40
- onInputChange: (value: string) => void;
41
- onSend: (text: string) => Promise<boolean>;
42
- onStop: () => void;
43
- sessionStatus?: string;
44
- askAnswers?: Record<string, AskUserAnswerData>;
45
- onAnswer?: (answer: string, toolCallId: string, answerData: AskUserAnswerData) => void;
46
- sessionId?: string;
47
- /** 输入框上方的内部区域(纯 LLM 模式的高级设置用)。不传时不渲染任何节点。 */
48
- beforeInput?: ReactNode;
49
- /** 连接状态条下方的横幅(回放模式条用)。不传时不渲染任何节点。 */
50
- banner?: ReactNode;
51
- }
52
- /**
53
- * 消息流 + 输入框:智能体模式与纯 LLM 模式共用同一套外观,差别只在谁喂数据。
54
- *
55
- * 这里的 DOM 结构受 tests/chat-view-compat.test.tsx 的快照保护——接入方拿
56
- * .blade-chat-* 类名写了自己的样式,结构一动他们的页面就歪。
57
- */
58
- export declare function ChatSurface({ theme, classNames, renderers, slots, placeholder, connection, errorMessage, messages, isStreaming, isStopping, inputText, onInputChange, onSend, onStop, sessionStatus, askAnswers, onAnswer, sessionId, beforeInput, banner, }: ChatSurfaceProps): import("react/jsx-runtime").JSX.Element;
59
- export {};
@@ -1,40 +0,0 @@
1
- /** 纯 LLM 模式的高级设置:让用户自己改模型服务地址。 */
2
- export interface LlmAdvancedSettings {
3
- /** 允许改模型服务地址,默认允许。 */
4
- baseURL?: boolean;
5
- /** 允许改模型名,默认允许。 */
6
- model?: boolean;
7
- /**
8
- * 允许在界面上填密钥,默认**不允许**。
9
- * 打开意味着密钥存在浏览器里,只适合受控内网、演示,或密钥本身就属于当前用户的场景。
10
- */
11
- apiKey?: boolean;
12
- /** 覆盖值存哪:`local` 记住用户的选择(默认),`memory` 只在本次会话有效。 */
13
- storage?: "local" | "memory";
14
- /** localStorage 的键,默认按组件拿到的 baseURL 生成。 */
15
- storageKey?: string;
16
- }
17
- export interface LlmOverride {
18
- baseURL?: string;
19
- model?: string;
20
- apiKey?: string;
21
- }
22
- export declare function normalizeAdvanced(value: boolean | LlmAdvancedSettings | undefined): Required<Pick<LlmAdvancedSettings, "baseURL" | "model" | "apiKey" | "storage">> | null;
23
- export declare function readOverride(settings: boolean | LlmAdvancedSettings | undefined, baseURL: string): LlmOverride;
24
- declare function writeOverride(settings: boolean | LlmAdvancedSettings | undefined, baseURL: string, override: LlmOverride): void;
25
- interface Props {
26
- settings: boolean | LlmAdvancedSettings;
27
- /** 组件拿到的默认值,用来做占位提示与"恢复默认" */
28
- defaults: {
29
- baseURL: string;
30
- model: string;
31
- };
32
- override: LlmOverride;
33
- onChange: (next: LlmOverride) => void;
34
- }
35
- /**
36
- * 输入框上方的一行「高级设置」:默认收起,展开后可以改模型服务地址与模型。
37
- * 只有调用方显式打开才渲染——不传 advanced 时这里一个节点都不会出现。
38
- */
39
- export declare function LlmAdvancedSettingsBar({ settings, defaults, override, onChange }: Props): import("react/jsx-runtime").JSX.Element | null;
40
- export { writeOverride };
@@ -1,29 +0,0 @@
1
- import { type LlmChatOptions } from "../hooks/use-llm-chat";
2
- import { type ChatPresentationProps } from "./ChatSurface";
3
- import { type LlmAdvancedSettings, type LlmOverride } from "./LlmAdvancedSettings";
4
- /** 纯 LLM 模式的操作句柄,对应智能体模式的 session.insertText() / send()。 */
5
- export interface LlmChatHandle {
6
- /** 把文本放进输入框交给用户确认,不直接发出去。 */
7
- insertText: (text: string) => void;
8
- send: (text: string) => Promise<boolean>;
9
- /** 清空这段对话。 */
10
- reset: () => void;
11
- }
12
- export interface LlmChatProps extends LlmChatOptions, ChatPresentationProps {
13
- /** 拿到操作句柄:业务界面把选中的数据塞进输入框,或直接发一句。 */
14
- onReady?: (handle: LlmChatHandle) => void;
15
- /**
16
- * 打开输入框上方的「高级设置」,让用户自己改模型服务地址(默认还能改模型名)。
17
- * 不传就一个节点都不渲染。传 `true` 用默认配置,或用对象细调。
18
- */
19
- advanced?: boolean | LlmAdvancedSettings;
20
- /** 用户改了覆盖值时回调,方便宿主自己也记一份。 */
21
- onOverrideChange?: (override: LlmOverride) => void;
22
- }
23
- /**
24
- * 纯 LLM 模式的聊天界面:不建会话、不连实时通道、也不要求登录 Blade,
25
- * 只按 **OpenAI Chat Completions** 标准协议跟模型服务一问一答。
26
- *
27
- * 默认形态是把 `baseURL` 指向自己后端的透传路径,由后端补密钥再转发,浏览器不持有密钥。
28
- */
29
- export declare function LlmChat({ classNames, renderers, slots, placeholder, theme, onReady, advanced, onOverrideChange, ...options }: LlmChatProps): import("react/jsx-runtime").JSX.Element;
@@ -1,13 +0,0 @@
1
- import type { ReplaySpeed } from "@blade-hq/agent-client";
2
- export interface ReplayBarProps {
3
- /** 非回放会话传 false 时整条不渲染。 */
4
- isReplay: boolean;
5
- speed: ReplaySpeed;
6
- onSpeedChange: (speed: ReplaySpeed) => void;
7
- onExit: () => void;
8
- /** 传 useReplay().canControl。只读身份下仍然显示"在回放",但操作按钮禁用。 */
9
- canControl?: boolean;
10
- className?: string;
11
- }
12
- /** 回放会话的顶部状态条:说明当前在回放、切换倍速、随时退出回放。 */
13
- export declare function ReplayBar({ isReplay, speed, onSpeedChange, onExit, canControl, className, }: ReplayBarProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,8 +0,0 @@
1
- import type { ReplayMismatch } from "../hooks/use-replay";
2
- export interface ReplayMismatchPromptProps {
3
- /** 来自 useReplay().mismatch;为 null 时不渲染。 */
4
- mismatch: ReplayMismatch | null;
5
- className?: string;
6
- }
7
- /** 回放中输入和录制内容对不上时的选择卡:按录制继续,还是从这里真跑。 */
8
- export declare function ReplayMismatchPrompt({ mismatch, className }: ReplayMismatchPromptProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,57 +0,0 @@
1
- import type { ChatMessage } from "@blade-hq/agent-client";
2
- /** OpenAI 标准的工具声明,原样发给模型服务。 */
3
- export interface ChatCompletionTool {
4
- type: "function";
5
- function: {
6
- name: string;
7
- description?: string;
8
- parameters?: Record<string, unknown>;
9
- };
10
- }
11
- export interface LlmToolCall {
12
- id: string;
13
- name: string;
14
- /** 模型生成的 JSON 字符串,是不可信输入,用之前自己校验。 */
15
- arguments: string;
16
- }
17
- export interface LlmChatOptions {
18
- /** OpenAI 兼容根地址,如 `/api/llm`(自己后端的透传路径)或 `http://host:30000/v1`。 */
19
- baseURL: string;
20
- model: string;
21
- /**
22
- * 直连模型服务时才需要。默认形态是让 `baseURL` 指向自己的后端,由后端补密钥转发,
23
- * 浏览器不持有密钥。
24
- */
25
- apiKey?: string;
26
- headers?: Record<string, string>;
27
- /** 系统提示词,合成到消息最前面。 */
28
- system?: string;
29
- /** 每次带上最近多少轮,默认 12。越长越贵,也越容易超上下文。 */
30
- historyTurns?: number;
31
- temperature?: number;
32
- /** 透传给模型服务的额外字段。 */
33
- extraBody?: Record<string, unknown>;
34
- tools?: ChatCompletionTool[];
35
- /** 执行模型请求的工具,返回值会被序列化后回喂给模型。 */
36
- onToolCall?: (call: LlmToolCall) => Promise<unknown>;
37
- /** 工具最多来回几轮,默认 4,防止模型绕圈烧 token。 */
38
- maxToolRounds?: number;
39
- fetchImpl?: typeof fetch;
40
- }
41
- export interface UseLlmChatResult {
42
- messages: ChatMessage[];
43
- isStreaming: boolean;
44
- /** 出错原因;下一次发送会清掉。 */
45
- error: string | null;
46
- send: (text: string) => Promise<boolean>;
47
- stop: () => void;
48
- reset: () => void;
49
- }
50
- /**
51
- * 纯 LLM 对话的状态机,协议就是 **OpenAI Chat Completions**——任何兼容实现都能直接接,
52
- * 不需要为这个组件专门写后端。
53
- *
54
- * 工具调用走 OpenAI 标准的多轮流程:模型返回 tool_calls → 调 onToolCall 执行 →
55
- * 结果作为 role:"tool" 消息回喂 → 再请求一次。
56
- */
57
- export declare function useLlmChat(options: LlmChatOptions): UseLlmChatResult;