@blade-hq/agent-client 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.
@@ -0,0 +1,50 @@
1
+ import type { ChatMessage, ToolCallInfo } from "../schemas/message";
2
+ /**
3
+ * 挂载式渲染器:SDK 给一个 DOM 节点和这个区块的数据,由宿主自己把内容挂上去
4
+ * (Vue 组件、原生 DOM 都行),不需要 React。
5
+ *
6
+ * - 返回清理函数:数据变化时 SDK 先清理再重新挂载,区块卸载时清理。
7
+ * - 返回 `{ update, destroy }`:数据变化时调用 `update` 原地更新,区块卸载时调用 `destroy`。
8
+ */
9
+ export type MountResult<T> = undefined | (() => void) | MountHandle<T>;
10
+ export interface MountHandle<T> {
11
+ update?(data: T): void;
12
+ destroy(): void;
13
+ }
14
+ export interface MountRendererObject<T> {
15
+ /** 返回 false 时这个区块走 SDK 默认渲染;不写等于全部接管。 */
16
+ match?(data: T): boolean;
17
+ mount(target: HTMLElement, data: T): MountResult<T>;
18
+ }
19
+ /** 直接写函数等于 `{ mount }`:接管这一类区块的全部实例。 */
20
+ export type MountRenderer<T> = MountRendererObject<T> | ((target: HTMLElement, data: T) => MountResult<T>);
21
+ /**
22
+ * `<blade-chat>` 元素的 `renderers` 属性(JS 属性,不是 HTML 属性):
23
+ *
24
+ * ```js
25
+ * chat.renderers = {
26
+ * toolCall: {
27
+ * match: ({ toolCall }) => toolCall.name === "draw_chart",
28
+ * mount(target, { toolCall }) { target.textContent = toolCall.arguments; return () => {} },
29
+ * },
30
+ * }
31
+ * ```
32
+ */
33
+ export interface BladeChatMountRenderers {
34
+ /** 工具调用卡片。 */
35
+ toolCall?: MountRenderer<{
36
+ toolCall: ToolCallInfo;
37
+ sessionId?: string;
38
+ }>;
39
+ /** 用户消息气泡。 */
40
+ userMessage?: MountRenderer<{
41
+ message: ChatMessage;
42
+ }>;
43
+ /** 助手正文;`compact` 为真时正文在执行过程里。 */
44
+ assistantText?: MountRenderer<{
45
+ message: ChatMessage;
46
+ streaming: boolean;
47
+ compact: boolean;
48
+ sessionId?: string;
49
+ }>;
50
+ }
package/dist/index.d.ts CHANGED
@@ -1,72 +1,29 @@
1
1
  export { BladeClient } from "./blade-client";
2
2
  export type { BladeClientOptions, UploadProgress } from "./blade-client";
3
3
  export { BladeApiError } from "./rest";
4
- export { isEntryGoneError } from "./resources/sessions";
5
- export { PollingBackoff } from "./polling-backoff";
6
4
  export type { LoginOptions, LoginResult, TokenStorageMode } from "./auth-login";
7
- export { EMPTY_PLATFORM_ENDPOINTS, loadPlatformEndpoints, resolveServiceUrl, } from "./platform-endpoints";
8
- export type { LoadPlatformEndpointsOptions, PlatformEndpoints, PlatformServiceName, } from "./platform-endpoints";
9
5
  export { SDK_NAME, SDK_VERSION } from "./version";
10
6
  export { AgentSession } from "./session/agent-session";
11
7
  export type { AttachAppOptions, SendOptions } from "./session/agent-session";
12
8
  export { AgentSessionError } from "./session/errors";
13
- export { SessionHub } from "./session/hub";
14
- export type { SessionConnectOptions } from "./session/hub";
15
9
  export type { AgentSessionEvents, AgentSessionEventName } from "./session/events";
16
- export { isMcpAppData } from "./schemas/mcp-app";
17
- export type { McpAppArchive, McpAppContextState, McpAppContextUpdate, McpAppData, } from "./schemas/mcp-app";
10
+ export type { WorkflowRunEntry, WorkflowRunState } from "./session/workflow";
11
+ export type { ActiveCompactionState, AgentLoopInfo, AskUserAnswerData, ConnectionStatus, ReplaySnapshot, SessionState, } from "./session/state";
18
12
  export { SessionSetupError } from "./session/definition";
19
- export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, SkillFile, TextFile, SolutionDefinition, } from "./session/definition";
20
- export { createInitialSessionState, reconcileHistoricalUserTurns, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
21
- export type { AskUserAnswerData, AgentLoopInfo, ActiveCompactionState, ConnectionStatus, ReplaySnapshot, SessionState, } from "./session/state";
22
- export { EMPTY_SESSION_QUEUE, canCancelQueuedMessage, canDeliverQueuedMessage, canEditQueuedMessage, isSessionQueueSnapshot, parseQueueAck, queuePauseReasonLabel, queuedMessageStatusLabel, shouldApplySnapshot, } from "./session/queue";
23
- export type { QueueAck, QueueOperationResult, QueuedMessage, QueuedMessageStatus, SessionQueueSnapshot, } from "./session/queue";
24
- export { connectEmbedded } from "./commands/embedded";
25
- export type { EmbeddedChat, EmbeddedChatOptions } from "./commands/embedded";
13
+ export type { SessionConfig, SessionDefinition, SessionSetupStage, SkillDefinition, SkillFile, SolutionDefinition, TextFile, } from "./session/definition";
14
+ export type { QueuedMessage, QueuedMessageStatus, QueueOperationResult, SessionQueueSnapshot, } from "./session/queue";
26
15
  export type { CommandHandler } from "./commands/registry";
27
- export type { CommandEnvelope, InboundAction, InboundEnvelope } from "./commands/protocol";
28
- export { isCommandEnvelope, isInboundEnvelope } from "./commands/protocol";
16
+ export type { BladeChatMountRenderers, MountHandle, MountRenderer, MountRendererObject, MountResult, } from "./embed/mount-renderer";
29
17
  export type { AuthResource, ExchangeCodeParams, ExchangeCodeResult, ProvidersResponse, UserInfo, } from "./resources/auth";
30
18
  export type { HeadlessResource } from "./resources/headless";
31
- export { ComputersResource } from "./resources/computers";
32
- export { canToggleComputer, computerDaemonVersion, computerOS, computerPlatformLabel, computerState, sortComputers, } from "./resources/computers";
33
- export type { AccountComputer, AccountComputerList, ComputerOS, ComputerState, SessionComputer, SessionComputerList, } from "./resources/computers";
34
- export { ModelsResource } from "./resources/models";
35
- export type { ModelCatalog, ModelOption } from "./resources/models";
36
- export type { SessionsResource } from "./resources/sessions";
37
- export type { SessionPlugin, SessionPluginActivation } from "./resources/sessions";
38
- export type { SessionPluginConfigError, SessionPluginConfigSet, SessionPluginConfigState, SessionPluginConfigStateName, SessionPluginConfigSummary, SessionPluginConfigUpdate, } from "./resources/sessions";
39
- export { ChatGroupsResource } from "./resources/chat-groups";
40
- export type { ChatGroup } from "./resources/chat-groups";
41
- export { PluginsResource } from "./resources/plugins";
42
- export type { PluginCatalogEntry } from "./resources/plugins";
43
- export type { SiteVisitsResource, SiteVisitsSummary } from "./resources/site-visits";
44
- export { hasChatRunEvent } from "./shared/projection";
45
- export type { CreateSessionRequest, AppCliAttachment, AppCliDefinition, FileEntry, ImportSessionOptions, PaginatedSessionsResult, GlobalSearchConversationResult, GlobalSearchFileResult, GlobalSearchResult, GlobalSearchResultItem, ResultFeedback, ResultFeedbackReason, HistoricalCommand, SessionContextStats, SessionHistory, SessionTurnsPage, SessionTurnsQuery, SessionTurnIndex, SessionTurnIndexItem, ShareLinkResult, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
46
- export type { ArchivedFileInfo, ArchivedToolCallInfo, ChatMessage, CompactionInfo, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolBridgeContent, ToolCallInfo, } from "./schemas/message";
47
- export { inferToolStatus } from "./schemas/message";
48
- export type { ChatEnd, ContentDelta, LlmResponseDone, SessionStatusEvent, SystemError, ToolCallArgumentsDelta, ToolCallCreated, ToolResultDelta, ToolResultDone, } from "./schemas/event";
49
- export { buildMessageContent, chatErrorForDisplay, contentPreview, extractTextAttachments, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, isHiddenInternalMessage, isBackgroundWakeMessage, normalizeMessageContent, transformSlashCommand, } from "./schemas/message-utils";
50
- export { contextProjectionData, getContextDisplayState, getContextGroupDisplayState, groupAdjacentContextRuns, } from "./schemas/context";
51
- export type { ContextAction, ContextDisplayState, ContextGroupDisplayState, ContextProjectionData, ContextProjectionFields, ContextSourceInfo, } from "./schemas/context";
52
- export type { ParsedTextAttachment, ParsedTextContext, SkillMentionAvailability, } from "./schemas/message-utils";
53
- export type { ContentBlock, FinalArtifact, MemoryRef, PatchEnvelope, PendingQuestionRef, PostChatFollowup, RunTiming, ToolCallProjection, TurnProjection, } from "./schemas/projection";
54
- export { latestPostChatFollowup } from "./schemas/projection-utils";
55
- export { buildToolUiCardKey, collectInlineToolUiCards, collectPreviewToolUiCards, isAppDevToolUiCard, isInternalStatusToolUiCard, isToolUiCard, resolveToolUiCardContent, } from "./shared/tool-ui-card";
56
- export type { InlineToolUiCardEntry, PreviewToolUiCardEntry, ToolUiCard, ToolUiCardContentType, } from "./shared/tool-ui-card";
57
- export { prependOlder, replaceWindow } from "./session/history-page";
58
- export type { LiveRevisionState } from "./session/history-page";
59
- export { DEFAULT_REPLAY_SPEED } from "./schemas/session";
60
- export { SessionInfo, SessionStatus } from "./schemas/session";
61
- export type { ModeId, PrimarySkillParallelMode, PrimarySkillSnapshot, PrimarySkillStageSpec, PrimarySkillStepSpec, PublishedSolutionRef, ReplayPreview, ReplaySpeed, ReplayState, SessionDetail, SessionPortMapping, SessionSearchMatch, SkillEditorTemplateId, TemplateId, } from "./schemas/session";
62
- export { LayoutType } from "./schemas/solution";
63
- export type { BizRole, Solution, SolutionAppField, SolutionAppState, SolutionAppUiConfig, } from "./schemas/solution";
64
- export { Task, TaskStatus } from "./schemas/task";
65
- export type { BackgroundTask, BackgroundTaskStopResult } from "./schemas/background";
66
- export { acceptedPostChatFollowupCompletesLatestRun, acknowledgeTurnEvents, ClientProjectionBuilder, } from "./shared/projection";
67
- export type { RawEvent } from "./shared/projection";
68
- export { AuthBusyReconnect, authBusyRetryDelayMs } from "./shared/auth-busy";
69
- export { createSocket } from "./socket";
70
- export type { CreateSocketOptions, TypedSocket } from "./socket";
71
- export type { AsrAudioPayload } from "./types/socket-events";
72
- export type * from "./types/sdk-profile";
19
+ export type { RunOptions, RunResult, RunTrace } from "./types/sdk-profile";
20
+ export type { ModelsResource, ModelCatalog, ModelOption } from "./resources/models";
21
+ export type { ComputersResource } from "./resources/computers";
22
+ export type { AccountComputer, SessionComputer } from "./resources/computers";
23
+ export type { AppCliAttachment, AppCliDefinition, CreateSessionRequest, FileEntry, PaginatedSessionsResult, SessionsResource, SessionTurnsPage, SessionTurnsQuery, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
24
+ export { DEFAULT_REPLAY_SPEED, SessionInfo, SessionStatus } from "./schemas/session";
25
+ export type { ReplaySpeed, ReplayState, SessionDetail } from "./schemas/session";
26
+ export type { ChatMessage, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolCallInfo, } from "./schemas/message";
27
+ export { chatErrorForDisplay, contentPreview, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, transformSlashCommand, } from "./schemas/message-utils";
28
+ export type { SkillMentionAvailability } from "./schemas/message-utils";
29
+ export { userFacingErrorText } from "./shared/oom";