# @blade-hq/agent-client 公共 API 报告

> 本文件由 `scripts/public-api-report.mjs` 生成，请勿手改。
> 公共面变更时重新生成本报告，并同步更新 README 对应章节——CI 会校验两者。

共 247 个公开声明。

## `acceptedPostChatFollowupCompletesLatestRun` (function)

```ts
acceptedPostChatFollowupCompletesLatestRun: (events: RawEvent[], updates: ProjectionUpdate[]) => boolean
```

## `AccountComputer` (interface)

```ts
arch: string | null | undefined
blade_home: string | null | undefined
created_at: string
daemon_version: string | null | undefined
hostname: string | null | undefined
id: string
label: string
last_seen_at: string | null | undefined
online: boolean
os: string | null | undefined
workspace: string | null | undefined
```

## `AccountComputerList` (interface)

```ts
computers: AccountComputer[]
```

## `acknowledgeTurnEvents` (function)

```ts
acknowledgeTurnEvents: (acknowledge?: () => void) => void
```

## `ActiveCompactionState` (interface)

```ts
archived_count: number | null | undefined
archived_files: ArchivedFileInfo[] | null | undefined
archived_tool_calls: ArchivedToolCallInfo[] | null | undefined
compaction_id: string
failure_reason: string | null | undefined
fallback_applied: boolean | null | undefined
saved_ratio: number | null | undefined
status: "streaming" | "completed" | "paused" | "failed" | "interrupted"
summary_full: string | null | undefined
summary_preview: string | null | undefined
tokens_after: number | null | undefined
tokens_before: number | null | undefined
trigger: "auto" | "manual" | "forced_retry" | null | undefined
turn_id: string
```

## `AgentLoopInfo` (interface)

```ts
description: string
status: "running" | "done" | "error" | "cancelled" | "awaiting_answer"
toolCallId: string
```

## `AgentSession` (class)

```ts
attach: (label: string, data: unknown) => void
attachApp: (options: AttachAppOptions) => Promise<AppCliAttachment | null>
cancelPendingLocate: () => void
cancelQueuedMessage: (itemId: string, expectedVersion?: number) => Promise<QueueOperationResult>
compact: () => Promise<Record<string, unknown>>
countFiles: (dirPath?: string) => Promise<number>
deliverQueuedMessage: (itemId: string, expectedVersion: number) => Promise<QueueOperationResult>
dispose: () => void
downloadFile: (filePath: string, downloadName?: string) => Promise<void>
exitReplay: () => Promise<void>
getState: () => SessionState
hasOlderHistory: boolean
insertText: (text: string) => void
isDisposed: boolean
isStatic: boolean
listDir: (dirPath?: string) => Promise<FileEntry[]>
loadOlderHistory: (options?: { beforeCommit?: () => void; }) => Promise<void>
loadTurnIndex: () => Promise<SessionTurnIndexItem[]>
locateEntry: (entryId: string) => Promise<boolean>
off: <K extends keyof AgentSessionEvents>(name: K, handler: (event: AgentSessionEvents[K]) => void) => void
on: <K extends keyof AgentSessionEvents>(name: K, handler: (event: AgentSessionEvents[K]) => void) => () => void
onCommand: (action: string, handler: CommandHandler) => () => void
queueMessage: (content: string) => Promise<QueueOperationResult>
refreshQueue: () => Promise<QueueOperationResult>
reorderQueuedMessages: (expectedRevision: number, orderedIds: string[]) => Promise<QueueOperationResult>
resumeQueue: () => Promise<QueueOperationResult>
send: (content: MessageContent, options?: SendOptions) => Promise<boolean>
sessionId: string
setReplaySpeed: (speed: ReplaySpeed) => Promise<void>
stop: () => Promise<Record<string, unknown>>
subscribe: (listener: () => void) => () => void
updateQueuedMessage: (itemId: string, expectedVersion: number, content: string) => Promise<QueueOperationResult>
```

## `AgentSessionError` (class)

```ts
cause: unknown
code: string | undefined
message: string
name: "AgentSessionError"
stack: string | undefined
```

## `AgentSessionEventName` (type)

```ts
export type AgentSessionEventName = keyof AgentSessionEvents
```

## `AgentSessionEvents` (interface)

```ts
artifact: { filePath: string; contentType: string; title: string; content: string; oldString?: string; newString?: string; kind: "created" | "updated"; }
attachRequested: { label: string; content: string; }
backgroundTask: { id: string; command: string; description?: string; status: "starting" | "running" | "cancelling" | "succeeded" | "failed" | "cancelled" | "lost"; failureReason?: string | null; exitCode?: number | null; elapsedSeconds: number; output?: string; }
chatEnd: { status: string; }
command: { action: string; payload: unknown; toolCallId?: string; }
error: { message: string; code?: string; }
insertTextRequested: { text: string; }
message: { message: ChatMessage; turn: TurnProjection; }
modeChange: { mode: "planning" | "executing"; }
notification: { type: string; title: string; detail?: string; status: "info" | "running" | "done" | "error"; loopId?: string; metadata?: Record<string, unknown>; }
replayMismatch: { actualMessage?: string; expectedMessage?: string; respond: (decision: "keep_replay" | "continue_replay") => void; }
rewind: { checkpointId: string; }
sandboxOom: { toolCallId: string; }
sessionUpdated: { workspacePath?: string; chatGroupId?: string | null; intent?: string; status?: SessionStatus; model?: string | null; boundSkillId?: string | null; replayState?: Record<string, unknown> | null; }
taskListUpdated: { tasks: unknown[]; }
toolCall: { toolCall: ToolCallInfo; turn: TurnProjection; }
toolPreview: { sourcePath?: string; toolCallId: string; type: "resource-html" | "resource-uri" | "resource-file"; content: string; title: string; mcpApp?: McpAppData; }
toolResult: { toolCall: ToolCallInfo; turn: TurnProjection; source: "live" | "bootstrap_replay" | "reconnect_replay"; }
workspaceChanged: { filePath?: string; }
```

## `AppCliAttachment` (interface)

```ts
command: string
digest: string
runtime: "python" | "executable"
```

## `AppCliDefinition` (interface)

```ts
command: string
filename: string | undefined
runtime: "python" | "executable"
source: string | Blob | URL
```

## `ArchivedFileInfo` (interface)

```ts
filename: string | null | undefined
relative_path: string | null | undefined
size_bytes: number | null | undefined
tool_name: string | null | undefined
```

## `ArchivedToolCallInfo` (interface)

```ts
archive_path: string | null | undefined
entry_id: string | null | undefined
replacement_content: string | null | undefined
tool_call_id: string | null | undefined
tool_name: string | null | undefined
```

## `AskUserAnswerData` (interface)

```ts
custom: Record<number, string>
note: string | undefined
selections: Record<number, number[]>
```

## `AsrAudioPayload` (type)

```ts
export type AsrAudioPayload =
  | ArrayBuffer
  | Uint8Array
  | { pcm: ArrayBuffer | Uint8Array; request_id?: string }
```

## `AttachAppOptions` (interface)

```ts
cli: AppCliDefinition | undefined
getContext: () => Record<string, unknown> | Promise<Record<string, unknown>>
```

## `AuthBusyReconnect` (class)

```ts
cancel: () => void
pending: boolean
schedule: (error: unknown, reconnect: () => void) => boolean
```

## `authBusyRetryDelayMs` (function)

```ts
authBusyRetryDelayMs: (error: unknown) => number | null
```

## `AuthResource` (class)

```ts
exchangeCode: (params: ExchangeCodeParams) => Promise<ExchangeCodeResult>
getMe: () => Promise<UserInfo>
getProviders: () => Promise<ProvidersResponse>
login: (options?: LoginOptions) => Promise<LoginResult>
logout: () => Promise<{ logout_url: string; }>
logoutToken: () => void
```

## `BackgroundTask` (interface)

```ts
command: string
description: string | undefined
elapsed_seconds: number
exit_code: number | null | undefined
failure_reason: string | null | undefined
finished_at: number | null | undefined
id: string
log_path: string | null | undefined
output: string | undefined
output_lines_count: number | undefined
output_preview: string[] | undefined
started_at: number | null | undefined
status: "failed" | "running" | "cancelled" | "starting" | "cancelling" | "succeeded" | "lost"
```

## `BackgroundTaskStopResult` (interface)

```ts
message: string
ok: boolean
reason: string | null | undefined
task: BackgroundTask | null | undefined
```

## `BizRole` (interface)

```ts
description: string | null | undefined
id: string
name: string
preview: { url: string; title?: string | null; } | null | undefined
```

## `BladeApiError` (class)

```ts
cause: unknown
message: string
name: string
response: Response
stack: string | undefined
status: number
statusText: string
```

## `BladeClient` (class)

```ts
auth: AuthResource
blob: (method: HttpMethod, path: string) => Promise<Blob>
buildAuthedUrl: (path: string) => string
chatGroups: ChatGroupsResource
computers: ComputersResource
fetch: (method: HttpMethod, path: string, init?: BladeFetchInit, isRetry?: boolean) => Promise<Response>
formData: (method: HttpMethod, path: string, form: FormData, options?: { expectOk?: boolean; onUploadProgress?: (progress: UploadProgress) => void; }) => Promise<Response>
hasToken: () => boolean
headless: HeadlessResource
hub: SessionHub
json: <T>(method: HttpMethod, path: string, body?: unknown) => Promise<T>
jsonFromInit: <T>(path: string, init?: RequestInit) => Promise<T>
login: (options?: LoginOptions) => Promise<LoginResult>
logoutToken: () => void
models: ModelsResource
onSocketReplaced: (listener: () => void) => () => void
options: BladeClientOptions
plugins: PluginsResource
requestCommand: (event: string, payload: Record<string, unknown>, timeoutMs: number) => Promise<Record<string, unknown>>
responseFromInit: (path: string, init?: RequestInit) => Promise<Response>
sessions: SessionsResource
setBaseUrl: (baseUrl: string) => void
setToken: (token: string | null) => void
siteVisits: SiteVisitsResource
socket: () => TypedSocket
text: (method: HttpMethod, path: string) => Promise<string>
textFromInit: (path: string, init?: RequestInit) => Promise<string>
token: string | null
```

## `BladeClientOptions` (interface)

```ts
baseUrl: string
commandTransport: ((event: string, payload: Record<string, unknown>, send: () => Promise<Record<string, unknown>>) => Promise<Record<string, unknown>>) | undefined
fetchImpl: { (input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined
onRefreshSuccess: (() => void | Promise<void>) | undefined
socketToken: string | (() => string | null | undefined) | undefined
token: string | (() => string | null | undefined) | undefined
tokenStorage: TokenStorageMode | undefined
```

## `buildMessageContent` (function)

```ts
buildMessageContent: (text: string, attachments: Array<{ kind: "file"; name: string; uploadedPath?: string; textContent?: string | null; mimeType?: string; }>) => MessageContent
```

## `buildToolUiCardKey` (function)

```ts
buildToolUiCardKey: (toolCallId: string, type: ToolUiCardContentType, content: string, sourcePath?: string) => string
```

## `canCancelQueuedMessage` (function)

```ts
canCancelQueuedMessage: (item: QueuedMessage) => boolean
```

## `canDeliverQueuedMessage` (function)

```ts
canDeliverQueuedMessage: (item: QueuedMessage) => boolean
```

## `canEditQueuedMessage` (function)

```ts
canEditQueuedMessage: (item: QueuedMessage) => boolean
```

## `canToggleComputer` (function)

```ts
canToggleComputer: (computer: SessionComputer) => boolean
```

## `ChatEnd` (interface)

```ts
duration_ms: number
status: string
```

## `chatErrorForDisplay` (function)

```ts
chatErrorForDisplay: (message: string, developer?: boolean) => string
```

## `ChatGroup` (interface)

```ts
created_at: string
id: string
initiator: "ui" | "sdk" | null
instructions: string
name: string
session_count: number
updated_at: string
workspace_path: string
```

## `ChatGroupsResource` (class)

```ts
create: (payload: { name: string; instructions?: string; initiator?: "ui" | "sdk"; }) => Promise<ChatGroup>
delete: (groupId: string, options?: { deleteWorkspace?: boolean; }) => Promise<{ deleted: boolean; deleted_sessions: number; }>
list: () => Promise<ChatGroup[]>
update: (groupId: string, payload: { name?: string; instructions?: string; }) => Promise<ChatGroup>
```

## `ChatMessage` (interface)

```ts
blocks: ContentBlock[] | undefined
chat_run: RunTiming | null | undefined
compaction: CompactionInfo | undefined
content: MessageContent
context: ContextProjectionData | undefined
duration_ms: number | undefined
entry_id: string | undefined
kind: string | undefined
loop_name: string | undefined
memory_refs: MemoryRefInfo[] | undefined
parent_id: string | null | undefined
reasoning: string | undefined
render_id: string | undefined
role: "error" | "user" | "assistant" | "tool"
status: "streaming" | "completed" | "paused" | "failed" | "interrupted" | undefined
timestamp: string | undefined
tool_calls: ToolCallInfo[] | undefined
```

## `ClientProjectionBuilder` (class)

```ts
processBatch: (events: RawEvent[]) => ProjectionUpdate[]
processEvent: (event: RawEvent) => ProjectionUpdate[] | null
reset: () => void
seedSequence: (maxSeq: number) => void
```

## `collectInlineToolUiCards` (function)

```ts
collectInlineToolUiCards: (messages: ChatMessage[]) => InlineToolUiCardEntry[]
```

## `collectPreviewToolUiCards` (function)

```ts
collectPreviewToolUiCards: (messages: ChatMessage[]) => PreviewToolUiCardEntry[]
```

## `CommandEnvelope` (interface)

```ts
action: string
direction: "agent-to-host"
meta: { sessionId: string; toolCallId?: string; timestamp: number; }
payload: unknown
```

## `CommandHandler` (type)

```ts
export type CommandHandler = (payload: unknown, meta: { toolCallId?: string }) => void
```

## `CompactionInfo` (interface)

```ts
archived_count: number | null | undefined
archived_files: ArchivedFileInfo[] | null | undefined
archived_tool_calls: ArchivedToolCallInfo[] | null | undefined
compaction_id: string
failure_reason: string | null | undefined
fallback_applied: boolean | null | undefined
saved_ratio: number | null | undefined
summary_full: string | null | undefined
summary_preview: string | null | undefined
tokens_after: number | null | undefined
tokens_before: number | null | undefined
trigger: "auto" | "manual" | "forced_retry" | null | undefined
```

## `computerDaemonVersion` (function)

```ts
computerDaemonVersion: (computer: SessionComputer) => string
```

## `computerOS` (function)

```ts
computerOS: (computer: SessionComputer) => ComputerOS
```

## `ComputerOS` (type)

```ts
export type ComputerOS = "macos" | "windows" | "linux" | "unknown"
```

## `computerPlatformLabel` (function)

```ts
computerPlatformLabel: (computer: SessionComputer) => string
```

## `ComputersResource` (class)

```ts
list: (sessionId: string) => Promise<SessionComputerList>
listAccount: () => Promise<AccountComputerList>
setEnabled: (sessionId: string, computer: string, enabled: boolean) => Promise<SessionComputer>
```

## `computerState` (function)

```ts
computerState: (computer: SessionComputer) => ComputerState
```

## `ComputerState` (type)

```ts
export type ComputerState = "primary" | "enabled" | "offline" | "idle"
```

## `connectEmbedded` (function)

```ts
connectEmbedded: (options: EmbeddedChatOptions) => EmbeddedChat
```

## `ConnectionStatus` (type)

```ts
export type ConnectionStatus = "connecting" | "connected" | "reconnecting" | "disconnected"
```

## `ContentBlock` (interface)

```ts
content: unknown
delivery_id: string | null | undefined
display_name: string | null | undefined
tool_call_id: string | null | undefined
tool_name: string | null | undefined
type: "text" | "thinking" | "tool_use" | "tool_result" | "tool_ui" | "tool_bridge" | "system_notification" | "mode_change" | "plan_status" | "ask_user_answer"
```

## `ContentDelta` (interface)

```ts
content: string
loop_name: string | undefined
```

## `contentPreview` (function)

```ts
contentPreview: (content: MessageContent, maxLen?: number) => string
```

## `ContextAction` (type)

```ts
export type ContextAction = "published" | "retained" | "removed"
```

## `ContextDisplayState` (interface)

```ts
detail: string
isRemoved: boolean
summary: string
title: string
```

## `ContextGroupDisplayState` (interface)

```ts
count: number
summary: string
title: string
```

## `contextProjectionData` (function)

```ts
contextProjectionData: (fields: ContextProjectionFields) => ContextProjectionData | null
```

## `ContextProjectionData` (interface)

```ts
context_action: ContextAction
context_key: string
context_kind: string
context_name: string
context_order: number
context_revision: string
display_summary: string | null | undefined
display_title: string | null | undefined
sources: ContextSourceInfo[]
```

## `ContextProjectionFields` (interface)

```ts
context_action: ContextAction | null | undefined
context_key: string | null | undefined
context_kind: string | null | undefined
context_name: string | null | undefined
context_order: number | null | undefined
context_revision: string | null | undefined
display_summary: string | null | undefined
display_title: string | null | undefined
sources: ContextSourceInfo[] | null | undefined
```

## `ContextSourceInfo` (type)

```ts
export type ContextSourceInfo = Record<string, unknown>
```

## `createInitialSessionState` (function)

```ts
createInitialSessionState: (sessionId: string) => SessionState
```

## `CreateSessionRequest` (interface)

```ts
agent_runtime_id: string | null | undefined
biz_role_id: string | null | undefined
chat_group_id: string | null | undefined
compaction_ratio: number | null | undefined
daemon_id: string | null | undefined
disable_tools: string[] | null | undefined
enable_thinking: boolean | null | undefined
env: Record<string, string> | undefined
intent: string | undefined
memory_enabled: boolean | null | undefined
model: string | null | undefined
primary_skill_id: string | null | undefined
runtime_type: "sandbox" | "daemon" | "native" | null | undefined
session_solution_asset_id: string | null | undefined
solution_id: string | undefined
solution_ref: PublishedSolutionRef | undefined
solution_snapshot_session_id: string | undefined
template_id: TemplateId | undefined
```

## `createSocket` (function)

```ts
createSocket: (options: CreateSocketOptions) => TypedSocket
```

## `CreateSocketOptions` (interface)

```ts
baseUrl: string
path: string | undefined
token: string | (() => string | null | undefined) | undefined
transports: ("polling" | "websocket")[] | undefined
```

## `DEFAULT_REPLAY_SPEED` (const)

```ts
DEFAULT_REPLAY_SPEED: ReplaySpeed
```

## `EmbeddedChat` (interface)

```ts
attach: (label: string, data: unknown) => void
dispose: () => void
insertText: (text: string) => void
onCommand: (action: string, handler: CommandHandler) => () => void
send: (text: string) => void
```

## `EmbeddedChatOptions` (interface)

```ts
allowedOrigins: string[]
iframe: HTMLIFrameElement | undefined
```

## `EMPTY_PLATFORM_ENDPOINTS` (const)

```ts
EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints
```

## `EMPTY_SESSION_QUEUE` (const)

```ts
EMPTY_SESSION_QUEUE: SessionQueueSnapshot
```

## `ExchangeCodeParams` (interface)

```ts
clientOrigin: string
code: string
state: string
```

## `ExchangeCodeResult` (interface)

```ts
access_token: string
token_type: string
user: { id: string; username: string; display_name: string; avatar_url: string | null; }
```

## `ExistingSolutionRef` (interface)

```ts
bizRoleId: string | undefined
kind: "existing"
solutionId: string
```

## `extractTextAttachments` (function)

```ts
extractTextAttachments: (content: MessageContent) => { cleanText: string; attachments: ParsedTextAttachment[]; contexts: ParsedTextContext[]; }
```

## `FileContentPart` (interface)

```ts
data: string
name: string
type: "file"
```

## `FileEntry` (interface)

```ts
created_at: number
is_dir: boolean
name: string
path: string
tags: string[] | undefined
```

## `FinalArtifact` (interface)

```ts
kind: "link" | "file"
label: string
target: string
```

## `getContextDisplayState` (function)

```ts
getContextDisplayState: (context: ContextProjectionData) => ContextDisplayState
```

## `getContextGroupDisplayState` (function)

```ts
getContextGroupDisplayState: (contexts: readonly ContextProjectionData[]) => ContextGroupDisplayState
```

## `getFileParts` (function)

```ts
getFileParts: (content: MessageContent) => FileContentPart[]
```

## `getImageParts` (function)

```ts
getImageParts: (content: MessageContent) => ImageUrlContentPart[]
```

## `getTextContent` (function)

```ts
getTextContent: (content: MessageContent) => string
```

## `GlobalSearchConversationResult` (interface)

```ts
matched: "title" | "content"
session: SessionInfo
snippet: string
type: "conversation"
```

## `GlobalSearchFileResult` (interface)

```ts
matched: "name" | "path"
name: string
path: string
session: SessionInfo
snippet: string
type: "file"
```

## `GlobalSearchResult` (interface)

```ts
indexing: boolean
items: GlobalSearchResultItem[]
truncated: boolean
```

## `GlobalSearchResultItem` (type)

```ts
export type GlobalSearchResultItem =
  | GlobalSearchConversationResult
  | GlobalSearchFileResult
```

## `groupAdjacentContextRuns` (function)

```ts
groupAdjacentContextRuns: (kinds: readonly (string | null)[]) => readonly (readonly number[])[]
```

## `groupMessagesByLoop` (function)

```ts
groupMessagesByLoop: (messages: ChatMessage[]) => MessageGroup[]
```

## `hasChatRunEvent` (function)

```ts
hasChatRunEvent: (events: RawEvent[]) => boolean
```

## `HeadlessResource` (class)

```ts
run: { <T = unknown>(prompt: string, options: HeadlessRunOptions & { schema: JsonSchemaObject; }): Promise<T>; (prompt: string, options?: HeadlessRunOptions): Promise<string>; }
runInSession: { <T = unknown>(sessionId: string, prompt: string, options: HeadlessRunOptions & { schema: JsonSchemaObject; }): Promise<T>; (sessionId: string, prompt: string, options?: HeadlessRunOptions): Promise<string>; }
runWithSession: { <T = unknown>(prompt: string, options: HeadlessRunOptions & { schema: JsonSchemaObject; }): Promise<HeadlessRunInSessionResult<T>>; (prompt: string, options?: HeadlessRunOptions): Promise<HeadlessRunInSessionResult<string>>; }
```

## `HistoricalCommand` (interface)

```ts
action: string
deliveryId: string
payload: unknown
toolCallId: string | undefined
```

## `ImageUrlContentPart` (interface)

```ts
image_url: { url: string; source_path?: string; width?: number; height?: number; }
type: "image_url"
```

## `ImportSessionOptions` (interface)

```ts
solution_ref: PublishedSolutionRef | undefined
solution_snapshot_session_id: string | undefined
```

## `InboundAction` (type)

```ts
export type InboundAction = "addContext" | "appendInput" | "sendMessage"
```

## `InboundEnvelope` (interface)

```ts
action: InboundAction
direction: "host-to-agent"
payload: unknown
```

## `inferToolStatus` (function)

```ts
inferToolStatus: (resultStr: string) => "done" | "error" | "cancelled"
```

## `InlineToolUiCardEntry` (interface)

```ts
card: ToolUiCard
key: string
toolCallId: string
```

## `isAppDevToolUiCard` (function)

```ts
isAppDevToolUiCard: (card: ToolUiCard, isAppDev: boolean) => boolean
```

## `isBackgroundWakeMessage` (function)

```ts
isBackgroundWakeMessage: (message: Pick<ChatMessage, "blocks">) => boolean
```

## `isCommandEnvelope` (function)

```ts
isCommandEnvelope: (value: unknown) => value is CommandEnvelope
```

## `isEntryGoneError` (function)

```ts
isEntryGoneError: (error: unknown) => boolean
```

## `isHiddenInternalMessage` (function)

```ts
isHiddenInternalMessage: (message: Pick<ChatMessage, "role" | "content">, options?: { includeLegacyForkContext?: boolean; }) => boolean
```

## `isInboundEnvelope` (function)

```ts
isInboundEnvelope: (value: unknown) => value is InboundEnvelope
```

## `isInternalStatusToolUiCard` (function)

```ts
isInternalStatusToolUiCard: (card: { title?: string | null; } | null) => boolean
```

## `isMcpAppData` (function)

```ts
isMcpAppData: (value: unknown) => value is McpAppData
```

## `isSessionQueueSnapshot` (function)

```ts
isSessionQueueSnapshot: (value: unknown) => value is SessionQueueSnapshot
```

## `isToolUiCard` (function)

```ts
isToolUiCard: (value: unknown) => value is ToolUiCard
```

## `latestPostChatFollowup` (function)

```ts
latestPostChatFollowup: (turns: TurnProjection[]) => PostChatFollowup | null
```

## `LayoutType` (enum)

```ts
export enum LayoutType {
  Default = "default",
  SkillEditor = "skill-editor",
  BladeCoa = "blade-coa",
  SolutionEditor = "solution-editor",
  SolutionEditor2 = "solution-editor2",
  ChatPreview = "chat-preview",
  ChatOnly = "chat-only",
  SolutionApp = "solution-app",
  Custom = "custom",
}
```

## `LiveRevisionState` (interface)

```ts
byTurnId: ReadonlyMap<string, number>
current: number
```

## `LlmResponseDone` (interface)

```ts
content: string | null | undefined
loop_name: string | undefined
reasoning: string | null | undefined
role: string
tool_calls: { id: string; function: { name: string; arguments: string; }; }[] | undefined
```

## `loadPlatformEndpoints` (function)

```ts
loadPlatformEndpoints: (options?: LoadPlatformEndpointsOptions) => Promise<PlatformEndpoints>
```

## `LoadPlatformEndpointsOptions` (interface)

```ts
baseUrl: string | undefined
fetchImpl: { (input: RequestInfo | URL, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; } | undefined
timeoutMs: number | undefined
```

## `LoginOptions` (interface)

```ts
height: number | undefined
timeoutMs: number | undefined
width: number | undefined
```

## `LoginResult` (interface)

```ts
token: string
user: { id?: string; username?: string; display_name?: string; } | undefined
```

## `McpAppArchive` (interface)

```ts
html: string
mimeType: string
plugin: string
previousToolInput: Record<string, unknown> | undefined
previousToolResult: Record<string, unknown> | undefined
resourceMeta: Record<string, unknown>
resourceUri: string
sourceId: string
toolInput: Record<string, unknown>
toolResult: Record<string, unknown>
```

## `McpAppContextState` (interface)

```ts
content: string
plugin: string | null
revision: string
server_alias: string | null
```

## `McpAppContextUpdate` (interface)

```ts
content: string
expected_revision: string | null
request_id: string
```

## `McpAppData` (interface)

```ts
mimeType: string
resourceMeta: Record<string, unknown>
resourceUri: string
sourceId: string
toolInput: Record<string, unknown>
toolResult: Record<string, unknown>
```

## `MemoryRef` (interface)

```ts
content_preview: string
id: number
skill_name: string | null | undefined
```

## `MemoryRefInfo` (interface)

```ts
content_preview: string
id: number
skill_name: string | null | undefined
```

## `MessageContent` (type)

```ts
export type MessageContent = string | MessageContentPart[]
```

## `MessageContentPart` (type)

```ts
export type MessageContentPart = TextContentPart | ImageUrlContentPart | FileContentPart
```

## `ModeId` (type)

```ts
export type ModeId = "planning" | "executing"
```

## `ModelCatalog` (interface)

```ts
baseUrl: string | undefined
default: string
defaultServiceModel: string | undefined
models: ModelOption[]
unavailableModelIds: string[] | undefined
unavailableProviderIds: string[] | undefined
```

## `ModelOption` (interface)

```ts
id: string
label: string
serviceModelId: string | undefined
```

## `ModelsResource` (class)

```ts
list: () => Promise<ModelCatalog>
```

## `normalizeMessageContent` (function)

```ts
normalizeMessageContent: (content: unknown) => MessageContent
```

## `PaginatedSessionsResult` (interface)

```ts
content_match_truncated: boolean | undefined
items: SessionInfo[]
limit: number
offset: number
total: number
```

## `ParsedTextAttachment` (interface)

```ts
name: string
uploadedPath: string | undefined
```

## `ParsedTextContext` (interface)

```ts
content: string
label: string
```

## `parseQueueAck` (function)

```ts
parseQueueAck: (response: unknown, fallbackSessionId: string) => QueueOperationResult
```

## `PatchEnvelope` (interface)

```ts
data: { turn?: TurnProjection; workspace_changed?: { tool_call_id?: string; tool_name?: string; workspace_path?: string; }; }
loop_id: string
patch_type: string
sequence: number
turn_id: string
```

## `PendingQuestionRef` (interface)

```ts
child_loop_name: string
child_tool_call_id: string
description: string | null | undefined
```

## `PlatformEndpoints` (interface)

```ts
services: Partial<Record<"os" | "hub" | "agent" | "oauth" | "llmGateway" | "gitea" | "tile", string>>
```

## `PlatformServiceName` (type)

```ts
export type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]
```

## `PluginCatalogEntry` (interface)

```ts
display_name: string | null
icon: string | null
installed: boolean
name: string
```

## `PluginsResource` (class)

```ts
catalog: (init?: RequestInit) => Promise<{ plugins: PluginCatalogEntry[]; }>
fetchIcon: (name: string) => Promise<Blob>
iconUrl: (name: string) => string
```

## `PollingBackoff` (class)

```ts
failed: (error: unknown) => void
reset: () => void
waitMs: () => number | false
```

## `PostChatFollowup` (interface)

```ts
assistant_entry_id: string
feedback_eligible: boolean
feedback_scope: "latest_result"
final_artifacts: FinalArtifact[] | undefined
recaption: string | undefined
suggestions: string[]
```

## `PreparedSolution` (interface)

```ts
assetId: string
bizRoleId: string | undefined
expiresAt: string
kind: "prepared"
roles: string[]
solutionId: string
```

## `PreparedSolutionAsset` (interface)

```ts
assetId: string
bizRoleId: string | undefined
kind: "prepared"
```

## `prependOlder` (function)

```ts
prependOlder: (current: TurnProjection[], page: TurnProjection[]) => TurnProjection[]
```

## `PreviewToolUiCardEntry` (interface)

```ts
blocks: ContentBlock[]
card: ToolUiCard
key: string
toolCall: ToolCallInfo
```

## `PrimarySkillParallelMode` (interface)

```ts
id: string
name: string
prompt_hint: string
```

## `PrimarySkillSnapshot` (interface)

```ts
captured_at: string
description: string
parallel_modes: PrimarySkillParallelMode[]
skill_id: string
stages: PrimarySkillStageSpec[]
title: string
version: number
```

## `PrimarySkillStageSpec` (interface)

```ts
id: string
name: string
steps: PrimarySkillStepSpec[]
```

## `PrimarySkillStepSpec` (interface)

```ts
label: string
n: number
```

## `ProvidersResponse` (interface)

```ts
password_enabled: boolean
providers: { name: string; authorize_url: string; }[]
```

## `PublishedSolutionRef` (type)

```ts
export type PublishedSolutionRef =
  | { source: "builtin"; name: string }
  | { source: "hub"; org: string; name: string }
```

## `QueueAck` (interface)

```ts
items: QueuedMessage[] | undefined
message: string | null | undefined
pause_reason: string | null | undefined
paused: boolean | undefined
revision: number | undefined
running: boolean | undefined
session_id: string | undefined
status: "error" | "ok" | "conflict" | "queued"
```

## `QueuedMessage` (interface)

```ts
content: string
created_at: string
error: string | undefined
id: string
position: number
status: QueuedMessageStatus
target_run_id: string | undefined
updated_at: string
version: number
```

## `QueuedMessageStatus` (type)

```ts
export type QueuedMessageStatus = "pending" | "delivering" | "claimed" | "consumed" | "cancelled"
```

## `queuedMessageStatusLabel` (function)

```ts
queuedMessageStatusLabel: (status: QueuedMessageStatus) => string
```

## `QueueOperationResult` (interface)

```ts
code: string | undefined
conflict: boolean
message: string | null
ok: boolean
snapshot: SessionQueueSnapshot | null
```

## `queuePauseReasonLabel` (function)

```ts
queuePauseReasonLabel: (reason: string | null | undefined) => string | null
```

## `RawEvent` (interface)

```ts
payload: Record<string, unknown>
type: string
```

## `reconcileHistoricalUserTurns` (function)

```ts
reconcileHistoricalUserTurns: (currentTurns: TurnProjection[], incomingTurns: TurnProjection[]) => TurnProjection[]
```

## `reconcileOptimisticUserTurns` (function)

```ts
reconcileOptimisticUserTurns: (currentTurns: TurnProjection[], incomingTurns: TurnProjection[]) => TurnProjection[]
```

## `replaceWindow` (function)

```ts
replaceWindow: (current: TurnProjection[], page: TurnProjection[], liveRevisionAtStart: number, liveRevisions: LiveRevisionState) => TurnProjection[]
```

## `ReplayPreview` (interface)

```ts
intent: string | null | undefined
reason: string | null | undefined
session_id: string
supported: boolean
```

## `ReplaySnapshot` (interface)

```ts
isReplay: boolean
sourceSessionId: string | null
speed: ReplaySpeed
```

## `ReplaySpeed` (type)

```ts
export type ReplaySpeed = 1 | 2 | 5
```

## `ReplayState` (interface)

```ts
autonomous_reason: string | null | undefined
ended_at: string | null | undefined
next_source_entry_id: string | null | undefined
source_session_id: string | undefined
speed: ReplaySpeed | undefined
status: "replay" | "autonomous" | undefined
```

## `resolveServiceUrl` (function)

```ts
resolveServiceUrl: (endpoints: PlatformEndpoints, name: PlatformServiceName, path?: string) => string | null
```

## `resolveToolUiCardContent` (function)

```ts
resolveToolUiCardContent: (card: ToolUiCard) => { type: ToolUiCardContentType; content: string; } | null
```

## `ResultFeedback` (interface)

```ts
assistant_entry_id: string
created_at: string
helpful: boolean
project_id: string | null
reason: ResultFeedbackReason | null
session_id: string
surface: "unknown" | "chat" | "software_factory"
updated_at: string
```

## `ResultFeedbackReason` (type)

```ts
export type ResultFeedbackReason =
  | "not_solved"
  | "inaccurate"
  | "incomplete"
  | "needs_major_changes"
  | "too_slow"
  | "other"
```

## `RunOptions` (interface)

```ts
compactionRatio: number | undefined
headless: boolean | undefined
model: string | undefined
outputSchema: Record<string, unknown> | undefined
runtimeEnv: Record<string, string> | undefined
timeoutMs: number | undefined
trace: boolean | undefined
```

## `RunResult` (interface)

```ts
chatRunId: string | undefined
events: unknown[]
result: unknown
sessionId: string
```

## `RunTiming` (interface)

```ts
duration_ms: number | null | undefined
loop_id: string
run_id: string
scope: "chat" | "subagent"
started_at: string | null | undefined
status: "completed" | "paused" | "failed" | "cancelled" | "incomplete"
```

## `RunTrace` (interface)

```ts
configSnapshot: Record<string, unknown>
events: unknown[]
history: unknown[]
result: unknown
```

## `SDK_NAME` (const)

```ts
SDK_NAME: "agent-client"
```

## `SDK_VERSION` (const)

```ts
SDK_VERSION: string
```

## `SendOptions` (interface)

```ts
askUserAnswer: Record<string, unknown> | undefined
kbIds: number[] | undefined
mode: string | undefined
model: string | undefined
queueWhenRunning: boolean | undefined
replayDecision: "keep_replay" | "continue_replay" | undefined
thinkingOverride: boolean | undefined
whatif: { from_step: number; quotes: Array<Record<string, unknown>>; deprecate_entry_ids: string[]; } | undefined
```

## `SessionComputer` (interface)

```ts
agent_runtimes: unknown[] | undefined
allowed_paths: string[] | undefined
arch: string | null | undefined
blade_home: string | null | undefined
created_at: string
daemon_version: string | null | undefined
enabled: boolean
home: string | null | undefined
hostname: string | null | undefined
id: string
is_primary: boolean
label: string
last_seen_at: string | null | undefined
online: boolean
os: string | null | undefined
workspace: string | null | undefined
```

## `SessionComputerList` (interface)

```ts
computers: SessionComputer[]
```

## `SessionConfig` (interface)

```ts
compactionRatio: number | undefined
disableTools: string[] | undefined
enableThinking: boolean | undefined
env: Record<string, string> | undefined
memoryEnabled: boolean | undefined
model: string | undefined
```

## `SessionConnectOptions` (interface)

```ts
setup: ((session: AgentSession) => void) | undefined
```

## `SessionContextStats` (interface)

```ts
compaction_ratio: number
context_window: number
tokens_used: number
```

## `SessionDefinition` (interface)

```ts
config: SessionConfig | undefined
intent: string | undefined
skills: SkillDefinition[] | undefined
solution: SolutionDefinition | undefined
```

## `SessionDetail` (interface)

```ts
agent_runtime_id: string | null | undefined
ba_version: string | null | undefined
biz_role_id: string | null | undefined
bound_skill_id: string | null | undefined
chat_group_id: string | null | undefined
created_at: string
daemon_id: string | null | undefined
disable_tools: (string[] & string[]) | undefined
enable_thinking: boolean | null | undefined
env: Record<string, string> | undefined
id: string
initiator: "unknown" | "ui" | "sdk" | null | undefined
intent: string
is_example: boolean | undefined
is_headless: boolean | undefined
is_persistent: boolean | undefined
is_pinned: boolean | undefined
match: SessionSearchMatch | null | undefined
memory_enabled: boolean | undefined
model: string | null | undefined
pinned_at: string | null | undefined
plan_summary: string | null | undefined
ports: SessionPortMapping[] | undefined
preview_url: string | null | undefined
primary_skill_id: string | null | undefined
primary_skill_snapshot: PrimarySkillSnapshot | null | undefined
replay_state: ReplayState | null | undefined
runtime_type: string | null | undefined
sandbox_version: string | null | undefined
shared: boolean | undefined
solution: Solution | null | undefined
solution_id: string | null | undefined
solution_ref: PublishedSolutionRef | null | undefined
status: "completed" | "failed" | "interrupted" | "running" | "created" | "waiting_for_input"
template_id: TemplateId | null | undefined
updated_at: string
viewer_role: "owner" | "viewer" | undefined
workspace_path: string | null | undefined
```

## `SessionHistory` (interface)

```ts
active_branch: string | null
branches: string[]
nodes: HistoryNode[]
system_prompt_tokens: number | null | undefined
tokenizer_model: string | null | undefined
tools_tokens: number | null | undefined
```

## `SessionHub` (class)

```ts
connect: (sessionId: string, options?: SessionConnectOptions) => Promise<AgentSession>
disconnect: () => void
disposeAll: () => void
getConnection: () => ConnectionStatus
onConnectionChange: (listener: (status: ConnectionStatus) => void) => () => void
peek: (sessionId: string) => AgentSession | undefined
reconnect: () => void
```

## `SessionInfo` (type)

```ts
SessionInfo = type({
  id: "string",
  intent: "string",
  status: SessionStatus,
  created_at: "string",
  updated_at: "string",
  "shared?": "boolean",
  "memory_enabled?": "boolean",
  "is_persistent?": "boolean",
  "initiator?": "'ui' | 'sdk' | 'unknown' | null",
  "is_headless?": "boolean",
  "viewer_role?": "'owner' | 'viewer'",
  "template_id?": "string | null",
  "model?": "string | null",
  "enable_thinking?": "boolean | null",
  "solution_id?": "string | null",
  "solution_ref?": "unknown",
  "biz_role_id?": "string | null",
  "solution?": "unknown",
  "plan_summary?": "string | null",
  "primary_skill_id?": "string | null",
  // ship-attack v2：后端 engine.set_bound_skill 写入的"绑定 skill id"。
  // 未绑定 / 非 ship-attack session 为 null。
  "bound_skill_id?": "string | null",
  "replay_state?": "unknown",
  "is_pinned?": "boolean",
  "pinned_at?": "string | null",
  "is_example?": "boolean",
  "ports?": "unknown",
  "disable_tools?": "string[]",
  "runtime_type?": "string | null",
  "daemon_id?": "string | null",
  "agent_runtime_id?": "string | null",
  "workspace_path?": "string | null",
  "ba_version?": "string | null",
  "sandbox_version?": "string | null",
  "chat_group_id?": "string | null",
  "match?": "unknown",
})
```

## `SessionPlugin` (interface)

```ts
active: boolean
config: SessionPluginConfigSummary | undefined
display_name: string | null | undefined
icon: string | null | undefined
installed: boolean | null
name: string
projected: boolean
projection_source: string | null | undefined
reason: string | null | undefined
status: string
```

## `SessionPluginActivation` (type)

```ts
export type SessionPluginActivation = Pick<SessionPlugin, "name" | "active" | "status" | "reason">
```

## `SessionPluginConfigError` (interface)

```ts
message: string
path: string
```

## `SessionPluginConfigSet` (interface)

```ts
path: string
value: unknown
```

## `SessionPluginConfigState` (interface)

```ts
errors: SessionPluginConfigError[]
reason: string | null
revision: string | null
schema: Record<string, unknown> | null
state: SessionPluginConfigStateName
values: Record<string, unknown>
write_only: string[]
```

## `SessionPluginConfigStateName` (type)

```ts
export type SessionPluginConfigStateName = "not_required" | "required" | "configured" | "error"
```

## `SessionPluginConfigSummary` (type)

```ts
export type SessionPluginConfigSummary =
  | SessionPluginConfigStateName
  | "unchecked"
```

## `SessionPluginConfigUpdate` (interface)

```ts
expected_revision: string | null | undefined
remove: string[] | undefined
set: SessionPluginConfigSet[] | undefined
```

## `SessionPortMapping` (interface)

```ts
container_port: number
host_port: number
```

## `SessionProfile` (interface)

```ts
compactionRatio: number | undefined
disableTools: string[] | undefined
enableThinking: boolean | undefined
env: Record<string, string> | undefined
memoryEnabled: boolean | undefined
model: string | undefined
solution: SolutionRef | undefined
```

## `SessionQueueSnapshot` (interface)

```ts
items: QueuedMessage[]
pause_reason: string | null
paused: boolean
revision: number
session_id: string
```

## `SessionSearchMatch` (interface)

```ts
field: "title" | "content"
snippet: { role: string; text: string; } | null
```

## `SessionSetupError` (class)

```ts
cause: unknown
message: string
name: "SessionSetupError"
sessionId: string | undefined
stack: string | undefined
stage: SessionSetupStage
```

## `SessionSetupStage` (type)

```ts
export type SessionSetupStage = "solution" | "session" | "skill" | "connection"
```

## `SessionsResource` (class)

```ts
attachAppCli: (sessionId: string, definition: AppCliDefinition) => Promise<AppCliAttachment>
callMcpApp: (sessionId: string, sourceId: string, request: { request_id: string; name: string; arguments: Record<string, unknown>; }, init?: RequestInit) => Promise<{ response: Record<string, unknown>; replayed: boolean; }>
checkoutSession: (sessionId: string, checkpointId: string, position: "before" | "turn_end", mode?: "both" | "conversation" | "code", linear?: boolean) => Promise<{ id: string; content: string; position: string; mode?: string; files_restored?: boolean; linear?: boolean; }>
connect: (sessionId: string) => Promise<AgentSession>
copyFile: (sessionId: string, filePath: string) => Promise<{ path: string; }>
countFiles: (sessionId: string, dirPath?: string) => Promise<number>
create: (request?: CreateSessionRequest | SessionDefinition) => Promise<AgentSession>
createSession: (intent?: string, template_id?: TemplateId, primary_skill_id?: string | null) => Promise<{ session_id: string; }>
createSessionWithRequest: (request: CreateSessionRequest) => Promise<{ session_id: string; }>
createShare: (sessionId: string) => Promise<ShareLinkResult>
createWithProfile: (params: { intent: string; profile: SessionProfile; }) => Promise<{ session_id: string; }>
deleteFile: (sessionId: string, filePath: string) => Promise<void>
deleteSession: (sessionId: string, options?: { deleteWorkspace?: boolean; }) => Promise<{ deleted: boolean; workspace_deleted?: boolean; }>
downloadFile: (sessionId: string, filePath: string, downloadName?: string) => Promise<void>
exportSession: (sessionId: string) => Promise<void>
fetchImage: (sessionId: string, assetId: string, preview?: boolean) => Promise<Blob>
fetchSessionPluginIcon: (sessionId: string, name: string) => Promise<Blob>
fetchSharedImage: (token: string, assetId: string, preview?: boolean) => Promise<Blob>
getBackgroundTask: (sessionId: string, taskId: string, tail?: number, init?: RequestInit) => Promise<BackgroundTask>
getDownloadDirUrl: (sessionId: string, dirPath: string) => string
getMcpApp: (sessionId: string, sourceId: string, init?: RequestInit) => Promise<McpAppArchive>
getMcpAppContext: (sessionId: string, sourceId: string, init?: RequestInit) => Promise<McpAppContextState>
getReplayPreview: (sessionId: string) => Promise<ReplayPreview>
getSession: (sessionId: string, init?: RequestInit) => Promise<SessionDetail>
getSessionCheckpoints: (sessionId: string, init?: RequestInit) => Promise<{ nodes: CheckpointNode[]; leaf_id: string | null; }>
getSessionContextStats: (sessionId: string, init?: RequestInit) => Promise<SessionContextStats>
getSessionHistory: (sessionId: string, init?: RequestInit) => Promise<SessionHistory>
getSessionPluginConfig: (sessionId: string, name: string, init?: RequestInit) => Promise<{ plugin: string; config: SessionPluginConfigState; }>
getSessionTasks: (sessionId: string) => Promise<Task[]>
getSessionTurnCommands: (sessionId: string) => Promise<HistoricalCommand[]>
getSessionTurnIndex: (sessionId: string) => Promise<SessionTurnIndex>
getSessionTurns: (sessionId: string) => Promise<TurnProjection[]>
getSessionTurnsPage: (sessionId: string, options?: SessionTurnsQuery, init?: RequestInit) => Promise<SessionTurnsPage>
getSharedSession: (token: string) => Promise<TurnProjection[]>
importSession: (file: File, name?: string, solutionOverride?: string | null | ImportSessionOptions) => Promise<{ session_id: string; }>
listBackgroundTasks: (sessionId: string, init?: RequestInit) => Promise<BackgroundTask[]>
listDir: (sessionId: string, dirPath: string, showHidden?: boolean) => Promise<FileEntry[]>
listResultFeedback: (sessionId: string) => Promise<ResultFeedback[]>
listSessionPlugins: (sessionId: string, init?: RequestInit) => Promise<{ plugins: SessionPlugin[]; sync_version: number; sync_pending: boolean; }>
listSessions: (template_id_prefix?: string, solution_id?: string) => Promise<SessionInfo[]>
listSessionsPaginated: (params: { limit: number; offset: number; template_id_prefix?: string; solution_id?: string; solution_registry_id?: string; q?: string; chat_group_id?: string; }) => Promise<PaginatedSessionsResult>
listSessionsWithSkillData: () => Promise<SkillDevSession[]>
onMcpAppChanged: (sessionId: string, sourceId: string, listener: () => void) => () => void
pinSession: (sessionId: string, pinned: boolean) => Promise<SessionInfo>
prepareSessionPluginConfig: (sessionId: string, name: string, init?: RequestInit) => Promise<{ plugin: string; config: SessionPluginConfigState; }>
previewImport: (file: File) => Promise<ImportPreview>
probeSessionUrl: (sessionId: string, url: string) => Promise<{ reachable: boolean; requires_proxy: boolean; }>
putResultFeedback: (sessionId: string, assistantEntryId: string, feedback: { helpful: boolean; reason?: ResultFeedbackReason | null; }) => Promise<ResultFeedback>
renameFile: (sessionId: string, filePath: string, newName: string) => Promise<{ path: string; }>
revokeShare: (sessionId: string, token: string) => Promise<{ revoked: boolean; }>
rewindSession: (sessionId: string, checkpointId: string) => Promise<{ id: string; content: string; }>
searchOwnedContent: (params: { q: string; limit?: number; }) => Promise<GlobalSearchResult>
sessionPluginIconUrl: (sessionId: string, name: string) => string
setSessionEnv: (sessionId: string, env: Record<string, string>) => Promise<SessionDetail>
setSessionPluginActivation: (sessionId: string, name: string, active: boolean, init?: RequestInit) => Promise<{ plugin: SessionPluginActivation; sync_version: number; }>
shareFile: (sessionId: string, sourcePath: string, linkName?: string, shareFolder?: string) => Promise<{ path: string; target: string; }>
startReplaySession: (sourceSessionId: string, speed?: ReplaySpeed) => Promise<{ session_id: string; }>
stopBackgroundTask: (sessionId: string, taskId: string) => Promise<BackgroundTaskStopResult>
switchBranch: (sessionId: string, checkpointId: string) => Promise<{ id: string; leaf_id: string; }>
tokenizeMessages: (messages: Array<Record<string, unknown>>, options?: { model?: string; add_generation_prompt?: boolean; enable_thinking?: boolean | null; tools?: Array<Record<string, unknown>>; }) => Promise<TokenizeResult>
tokenizePrompt: (prompt: string, model?: string) => Promise<TokenizeResult>
updateMcpAppContext: (sessionId: string, sourceId: string, body: McpAppContextUpdate, init?: RequestInit) => Promise<{ status: "accepted"; revision: string; }>
updateReplaySession: (sessionId: string, payload: { speed?: ReplaySpeed; status?: "autonomous"; }) => Promise<{ replay_state: SessionInfo["replay_state"]; }>
updateSession: (sessionId: string, payload: { intent?: string; chat_group_id?: string | null; }) => Promise<SessionDetail>
updateSessionMemory: (sessionId: string, memoryEnabled: boolean) => Promise<{ memory_enabled: boolean; }>
updateSessionPluginConfig: (sessionId: string, name: string, update: SessionPluginConfigUpdate, init?: RequestInit) => Promise<{ plugin: string; config: SessionPluginConfigState; }>
updateSharing: (sessionId: string, shared: boolean) => Promise<{ shared: boolean; }>
uploadFiles: (sessionId: string, dirPath: string, files: FileList | File[] | UploadFileEntry[], options?: UploadFilesOptions) => Promise<{ uploaded: string[]; failed: string[]; results: Array<{ index: number; path?: string; error?: string; }>; }>
writeFile: (sessionId: string, filePath: string, content: string) => Promise<{ success: boolean; }>
```

## `SessionState` (interface)

```ts
activeCompaction: ActiveCompactionState | null
agentLoops: Record<string, AgentLoopInfo>
askAnswers: Record<string, AskUserAnswerData>
connection: ConnectionStatus
errorMessage: string | null
isStreaming: boolean
loadingOlder: boolean
messages: ChatMessage[]
mode: "planning" | "executing" | null
nextBefore: string | null
queue: SessionQueueSnapshot
replay: ReplaySnapshot | null
sessionId: string
status: "completed" | "failed" | "interrupted" | "running" | "created" | "waiting_for_input" | null
turns: TurnProjection[]
viewerRole: "owner" | "viewer" | null
```

## `SessionStatus` (type)

```ts
SessionStatus = type(
  "'created' | 'running' | 'completed' | 'failed' | 'interrupted' | 'waiting_for_input'",
)
```

## `SessionStatusEvent` (interface)

```ts
session_id: string
status: string
```

## `SessionTurnIndex` (interface)

```ts
items: SessionTurnIndexItem[]
sessionId: string
```

## `SessionTurnIndexItem` (interface)

```ts
createdAt: string | null
entryId: string
preview: string
```

## `SessionTurnsPage` (interface)

```ts
currentMode: "planning" | "executing"
nextBefore: string | null
turns: TurnProjection[]
```

## `SessionTurnsQuery` (interface)

```ts
before: string | undefined
fromEntryId: string | undefined
limit: number | undefined
```

## `ShareLinkResult` (interface)

```ts
expires_at: string | null
token: string
url: string
```

## `shouldApplySnapshot` (function)

```ts
shouldApplySnapshot: (current: SessionQueueSnapshot | undefined, next: SessionQueueSnapshot) => boolean
```

## `SiteVisitsResource` (class)

```ts
record: () => Promise<SiteVisitsSummary>
summary: () => Promise<SiteVisitsSummary>
```

## `SiteVisitsSummary` (interface)

```ts
as_of: string
date: string
timezone: string
today_pv: number
today_uv: number
total_pv: number
```

## `SkillDefinition` (interface)

```ts
files: SkillFile[]
name: string
```

## `SkillEditorTemplateId` (type)

```ts
export type SkillEditorTemplateId = "skill_editor"
```

## `SkillFile` (type)

```ts
export type SkillFile = TextFile & {
  /** 二进制内容使用 base64；省略时为 UTF-8 文本。 */
  encoding?: "utf-8" | "base64"
  executable?: boolean
}
```

## `SkillMentionAvailability` (interface)

```ts
installed: boolean | undefined
local: boolean | undefined
```

## `Solution` (interface)

```ts
data: Record<string, unknown> | null | undefined
description: string | null | undefined
id: string
initial_message: string | null | undefined
initial_mode: string | null | undefined
layout: { available?: boolean; source_dir?: string; entry?: string; export?: string; } | null | undefined
layout_type: string
name: string
preview: { url: string; title?: string | null; } | null | undefined
roles: BizRole[] | null | undefined
source: string | null | undefined
ui_config: SolutionAppUiConfig | null | undefined
version: string
```

## `SolutionAppField` (type)

```ts
export type SolutionAppField =
  | {
      id: string
      kind: "textarea"
      label: string
      placeholder?: string
    }
  | {
      id: string
      kind: "file-upload"
      accept?: string[]
      categories?: Array<{
        label: string
        description: string
        color: string
      }>
    }
```

## `SolutionAppState` (interface)

```ts
meta: Record<string, { label: string; value: string; color?: string; }>
pipeline: { id: string; label: string; status: "done" | "active" | "pending" | "error"; }[]
```

## `SolutionAppUiConfig` (interface)

```ts
branding: { name: string; subtitle?: string; icon_text: string; icon_gradient?: string; }
create: { title: string; description?: string; submit_button: string; sections: Array<{ id: string; title: string; description?: string; fields: Array<SolutionAppField>; }>; }
list: { title: string; create_button: string; card?: { subtitle?: string; stats?: Array<{ label: string; value: string; color?: string; }>; }; }
```

## `SolutionDefinition` (type)

```ts
export type SolutionDefinition =
  | { id: string; role?: string }
  /** 自定义 Solution：文本文件路径均相对于 Solution 根目录。 */
  | { files: TextFile[]; role?: string }
```

## `SolutionRef` (type)

```ts
export type SolutionRef = ExistingSolutionRef | PreparedSolutionAsset
```

## `sortComputers` (function)

```ts
sortComputers: (computers: SessionComputer[]) => SessionComputer[]
```

## `SystemError` (interface)

```ts
message: string
```

## `Task` (type)

```ts
Task = type({
  id: "string",
  goal: "string",
  skills: "string[]",
  depends_on: "string[]",
  status: TaskStatus,
  result_summary: "string",
  number: "string",
})
```

## `TaskStatus` (type)

```ts
TaskStatus = type("'pending' | 'in_progress' | 'done' | 'failed' | 'skipped'")
```

## `TemplateId` (type)

```ts
export type TemplateId =
  | "default"
  | "skill_editor"
  // ship-attack v2：用户从 ship-attack 页面点"新建 session"创建的会话。
  // 后端 _maybe_bind_first_skill 只对此模板触发首次绑定。
  | "ship_attack"
```

## `TextContentPart` (interface)

```ts
text: string
type: "text"
```

## `TextFile` (type)

```ts
export type TextFile = {
  path: string
  content: string
}
```

## `TokenStorageMode` (type)

```ts
export type TokenStorageMode = "local" | "memory"
```

## `ToolBridgeContent` (interface)

```ts
action: string
payload: unknown
```

## `ToolCallArgumentsDelta` (interface)

```ts
arguments_delta: string
function: { name: string; }
id: string
index: number
loop_name: string | undefined
```

## `ToolCallCreated` (interface)

```ts
function: { name: string; arguments: string; }
id: string
index: number
loop_name: string | undefined
```

## `ToolCallInfo` (interface)

```ts
arguments: string
display_name: string | null | undefined
duration_ms: number | null | undefined
id: string
name: string
pending_question_ref: PendingQuestionRef | null | undefined
result: unknown
status: "done" | "error" | "cancelled" | "awaiting_answer" | "pending" | undefined
```

## `ToolCallProjection` (interface)

```ts
arguments: string
display_name: string
duration_ms: number | null | undefined
id: string
pending_question_ref: PendingQuestionRef | null | undefined
ran_in_parallel: boolean | undefined
result: unknown
started_at: string | null | undefined
status: string
subagent_runs: RunTiming[] | undefined
tool_name: string
```

## `ToolResultDelta` (interface)

```ts
content: string
loop_name: string | undefined
stream: "stdout" | "stderr" | undefined
tool_call_id: string
```

## `ToolResultDone` (interface)

```ts
content: string
function: { name: string; }
loop_name: string | undefined
tool_call_id: string
```

## `ToolUiCard` (interface)

```ts
archived: boolean | undefined
height: number
mcpApp: McpAppData | undefined
resourceHTML: string | undefined
resourceUri: string | undefined
resourceURI: string | undefined
sourcePath: string | undefined
target: "inline" | "preview"
title: string | undefined
```

## `ToolUiCardContentType` (type)

```ts
export type ToolUiCardContentType = "resource-html" | "resource-uri" | "resource-file"
```

## `toReplaySnapshot` (function)

```ts
toReplaySnapshot: (raw: ReplayState | null | undefined) => ReplaySnapshot | null
```

## `transformSlashCommand` (function)

```ts
transformSlashCommand: (skillName: string, rawInput: string, { local, installed }?: SkillMentionAvailability) => string
```

## `TurnProjection` (interface)

```ts
archived_count: number | null | undefined
archived_files: ArchivedFileInfo[] | null | undefined
archived_tool_calls: ArchivedToolCallInfo[] | null | undefined
blocks: ContentBlock[]
chat_run: RunTiming | null | undefined
client_render_id: string | null | undefined
client_request_id: string | null | undefined
compaction_id: string | null | undefined
context_action: ContextAction | null | undefined
context_content: unknown
context_key: string | null | undefined
context_kind: string | null | undefined
context_name: string | null | undefined
context_order: number | null | undefined
context_revision: string | null | undefined
context_window: number | undefined
display_summary: string | null | undefined
display_title: string | null | undefined
duration_ms: number | null | undefined
failure_reason: string | null | undefined
fallback_applied: boolean | null | undefined
first_token_delivery_ms: number | null | undefined
first_token_ms: number | null | undefined
has_reported_timing: boolean | undefined
id: string
kind: "message" | "context" | "compaction" | undefined
loop_id: string
memory_refs: MemoryRef[] | null | undefined
model: string | null | undefined
parent_fork_tool_call_id: string | null | undefined
post_chat_followup: PostChatFollowup | null | undefined
role: "user" | "assistant" | "system"
saved_ratio: number | null | undefined
sequence: number
sources: ContextSourceInfo[] | null | undefined
started_at: string | null | undefined
status: "streaming" | "completed" | "paused" | "failed" | "interrupted"
stream_duration_ms: number | null | undefined
summary_full: string | null | undefined
summary_preview: string | null | undefined
tokens_after: number | null | undefined
tokens_before: number | null | undefined
tool_calls: ToolCallProjection[]
trigger: "auto" | "manual" | "forced_retry" | null | undefined
turn_id: string
usage: Record<string, unknown> | null | undefined
```

## `TypedSocket` (type)

```ts
export type TypedSocket = Socket<ServerToClientEvents, ClientToServerEvents>
```

## `UploadFileEntry` (type)

```ts
export type UploadFileEntry = File | { file: File; name: string }
```

## `UploadFilesOptions` (interface)

```ts
onProgress: ((progress: UploadProgress) => void) | undefined
```

## `UploadProgress` (interface)

```ts
loaded: number
percent: number | undefined
total: number | undefined
```

## `UserInfo` (interface)

```ts
auth_type: "casdoor"
avatar_url: string | null
display_name: string | null | undefined
id: string
is_admin: boolean | undefined
token: string
username: string
```

