@blade-hq/agent-client 2612.0.0-beta.97 → 2612.0.0-beta.99

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/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export type { BladeClientOptions, UploadProgress } from "./blade-client";
9
9
  export { BladeApiError } from "./rest";
10
10
  export type { LoginOptions, LoginResult, TokenStorageMode } from "./auth-login";
11
11
  export { SDK_NAME, SDK_VERSION } from "./version";
12
+ export type { ApprovePlanInput, PlanAgentRef, PlanDocument, PlanLeafStatus, PlanNode, PlanPhase } from "./schemas/plan";
12
13
  export { AgentSession } from "./session/agent-session";
13
14
  export type { AttachAppOptions, InputKind, SendOptions, DeliveryReceipt } from "./session/agent-session";
14
15
  export { AgentSessionError } from "./session/errors";
@@ -31,7 +32,7 @@ export type { AccountComputer, SessionComputer } from "./resources/computers";
31
32
  export type { PhoneDevice, PhoneHealth, PhoneList, PhoneAccessKey, PhonePipeline, PhoneState, PhonesResource, } from "./resources/phones";
32
33
  export type { AppCliAttachment, AppCliDefinition, CreateSessionRequest, UpdateSessionConfigurationRequest, SessionConfiguration, SessionRunResult, SessionRequestEvidence, McpSourceConfig, FileEntry, PaginatedSessionsResult, SessionsResource, SessionTurnsPage, SessionTurnsQuery, UploadFileEntry, UploadFilesOptions, } from "./resources/sessions";
33
34
  export { DEFAULT_REPLAY_SPEED, SessionInfo, SessionStatus } from "./schemas/session";
34
- export type { ReplaySpeed, ReplayState, SessionDetail } from "./schemas/session";
35
+ export type { ReplayMode, ReplayPreset, ReplaySettings, ReplaySpeed, ReplayState, ReplayToolAction, SessionDetail } from "./schemas/session";
35
36
  export type { ChatMessage, FileContentPart, ImageUrlContentPart, MemoryRefInfo, MessageContent, MessageContentPart, TextContentPart, ToolCallInfo, WorkflowStepInfo, } from "./schemas/message";
36
37
  export { chatErrorForDisplay, contentPreview, getFileParts, getImageParts, getTextContent, groupMessagesByLoop, transformSlashCommand, } from "./schemas/message-utils";
37
38
  export type { SkillMentionAvailability } from "./schemas/message-utils";
@@ -54,7 +55,7 @@ export { ProfileResource, PacksResource } from "./resources/profile";
54
55
  export { PackRecordsResource } from "./resources/pack-records";
55
56
  export type { PackRecord, PackRecordQuery } from "./resources/pack-records";
56
57
  export { attachPackPageBridge } from "./pack-page-bridge";
57
- export type { PackProfile, ProfileComponent, PackManifest, PackLayoutOperation, InstalledPack } from "./resources/profile";
58
+ export type { PackEvent, PackProfile, ProfileAdjustment, PersonalLayoutOperation, StyleSummary, StyleAppearance, ProfileComponent, PackManifest, PackLayoutOperation, InstalledPack } from "./resources/profile";
58
59
  export { CapabilitiesResource } from "./resources/capabilities";
59
60
  export type { CapabilitySnapshot } from "./resources/capabilities";
60
61
  export type { CompactionPreference } from "./resources/sessions";
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  parseAskUserQuestion,
37
37
  transformSlashCommand,
38
38
  userFacingErrorText
39
- } from "./chunk-3XQ7HYKA.js";
39
+ } from "./chunk-W2OSMFBN.js";
40
40
  export {
41
41
  AgentSession,
42
42
  AgentSessionError,
@@ -10,7 +10,7 @@ export type { ChatEndPayload, SessionDetailSnapshot } from "./session/agent-sess
10
10
  export { isWorkflowRunToolName, workflowEntriesFromOutput, workflowNameFromArguments, } from "./session/workflow";
11
11
  export { isMcpAppData } from "./schemas/mcp-app";
12
12
  export type { McpAppArchive, McpAppContextState, McpAppContextUpdate, McpAppData, } from "./schemas/mcp-app";
13
- export { applyTurnPatch, createInitialSessionState, parentForkToolCallIdFromTurn, messageContentFromTurn, upsertTurn, withTurns, reconcileHistoricalUserTurns, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
13
+ export { createInitialSessionState, parentForkToolCallIdFromTurn, messageContentFromTurn, upsertTurn, withTurns, reconcileHistoricalUserTurns, reconcileOptimisticUserTurns, toReplaySnapshot, } from "./session/state";
14
14
  export { EMPTY_SESSION_QUEUE, canCancelQueuedMessage, canDeliverQueuedMessage, canEditQueuedMessage, isSessionQueueSnapshot, parseQueueAck, queuePauseReasonLabel, queuedMessageStatusLabel, shouldApplySnapshot, } from "./session/queue";
15
15
  export type { QueueAck } from "./session/queue";
16
16
  export { prependOlder, replaceWindow } from "./session/history-page";
@@ -50,7 +50,7 @@ export type { BizRole, Solution, SolutionAppField, SolutionAppState, SolutionApp
50
50
  export { Task, TaskStatus } from "./schemas/task";
51
51
  export type { BackgroundTask, BackgroundTaskStopResult } from "./schemas/background";
52
52
  export type * from "./types/sdk-profile";
53
- export { acceptedPostChatFollowupCompletesLatestRun, acknowledgeTurnEvents, ClientProjectionBuilder, hasChatRunEvent, } from "./shared/projection";
53
+ export { acknowledgeTurnEvents, ClientProjectionBuilder, hasChatRunEvent, } from "./shared/projection";
54
54
  export type { RawEvent } from "./shared/projection";
55
55
  export { AuthBusyReconnect, authBusyRetryDelayMs } from "./shared/auth-busy";
56
56
  export { isOomText, OOM_MESSAGE } from "./shared/oom";
@@ -67,3 +67,8 @@ export { isLocalConnectorName } from "./resources/connectors";
67
67
  export type { FileOpenerInstance } from "./resources/sessions";
68
68
  export type { PluginFileOpener } from "./resources/plugins";
69
69
  export { packEventTitle } from "./shared/pack-events";
70
+ export { readPlanDocument } from "./schemas/plan";
71
+ export { completionNotice, namedSubagent } from "./shared/completion-notices";
72
+ export type { CompletionNotice, CompletionSource, NamedSubagent } from "./shared/completion-notices";
73
+ export type { BoardTaskStatus, ProjectTaskSummary } from "./schemas/board";
74
+ export { isReadOnlySession } from "./session/state";
package/dist/internal.js CHANGED
@@ -29,9 +29,7 @@ import {
29
29
  SessionSetupError,
30
30
  SessionStatus,
31
31
  ToolProvider,
32
- acceptedPostChatFollowupCompletesLatestRun,
33
32
  acknowledgeTurnEvents,
34
- applyTurnPatch,
35
33
  attachPackPageBridge,
36
34
  authBusyRetryDelayMs,
37
35
  buildMessageContent,
@@ -43,6 +41,7 @@ import {
43
41
  chatErrorForDisplay,
44
42
  collectInlineToolUiCards,
45
43
  collectPreviewToolUiCards,
44
+ completionNotice,
46
45
  computerDaemonVersion,
47
46
  computerOS,
48
47
  computerPlatformLabel,
@@ -73,16 +72,17 @@ import {
73
72
  isLocalConnectorName,
74
73
  isMcpAppData,
75
74
  isOomText,
75
+ isReadOnlySession,
76
76
  isRecord,
77
77
  isSessionQueueSnapshot,
78
78
  isToolUiCard,
79
79
  isWorkflowRunToolName,
80
80
  messageContentFromTurn,
81
+ namedSubagent,
81
82
  normalizeMessageContent,
82
83
  normalizeMessageRefs,
83
84
  normalizePluginRefs,
84
85
  normalizeTopicAssetRefs,
85
- packEventTitle,
86
86
  parentForkToolCallIdFromTurn,
87
87
  parseAskUserQuestion,
88
88
  parseQueueAck,
@@ -91,6 +91,7 @@ import {
91
91
  prependOlder,
92
92
  queuePauseReasonLabel,
93
93
  queuedMessageStatusLabel,
94
+ readPlanDocument,
94
95
  reconcileHistoricalUserTurns,
95
96
  reconcileOptimisticUserTurns,
96
97
  replaceWindow,
@@ -107,7 +108,7 @@ import {
107
108
  withTurns,
108
109
  workflowEntriesFromOutput,
109
110
  workflowNameFromArguments
110
- } from "./chunk-3XQ7HYKA.js";
111
+ } from "./chunk-W2OSMFBN.js";
111
112
 
112
113
  // src/polling-backoff.ts
113
114
  var MAX_BACKOFF_MS = 6e4;
@@ -242,7 +243,7 @@ function latestPostChatFollowup(turns) {
242
243
  for (let index = turns.length - 1; index >= 0; index -= 1) {
243
244
  const turn = turns[index];
244
245
  if (turn.loop_id === "root" && (turn.role === "user" || turn.role === "assistant") && (turn.kind ?? "message") === "message" && !turn.blocks.some(
245
- (block) => ["mode_change", "plan_status", "ask_user_answer"].includes(block.type)
246
+ (block) => ["mode_change", "plan_status", "plan_update", "ask_user_answer"].includes(block.type)
246
247
  )) {
247
248
  return turn.role === "assistant" ? turn.post_chat_followup ?? null : null;
248
249
  }
@@ -272,6 +273,14 @@ var Task = type({
272
273
  result_summary: "string",
273
274
  number: "string"
274
275
  });
276
+
277
+ // src/shared/pack-events.ts
278
+ function packEventTitle(message) {
279
+ for (const block of message.blocks ?? []) {
280
+ if (block.type === "system_notification" && isRecord(block.content) && block.content.notification_type === "pack:event" && typeof block.content.title === "string") return block.content.title;
281
+ }
282
+ return null;
283
+ }
275
284
  export {
276
285
  AgentSession,
277
286
  AgentSessionError,
@@ -308,9 +317,7 @@ export {
308
317
  Task,
309
318
  TaskStatus,
310
319
  ToolProvider,
311
- acceptedPostChatFollowupCompletesLatestRun,
312
320
  acknowledgeTurnEvents,
313
- applyTurnPatch,
314
321
  attachPackPageBridge,
315
322
  authBusyRetryDelayMs,
316
323
  buildMessageContent,
@@ -322,6 +329,7 @@ export {
322
329
  chatErrorForDisplay,
323
330
  collectInlineToolUiCards,
324
331
  collectPreviewToolUiCards,
332
+ completionNotice,
325
333
  computerDaemonVersion,
326
334
  computerOS,
327
335
  computerPlatformLabel,
@@ -354,12 +362,14 @@ export {
354
362
  isLocalConnectorName,
355
363
  isMcpAppData,
356
364
  isOomText,
365
+ isReadOnlySession,
357
366
  isSessionQueueSnapshot,
358
367
  isToolUiCard,
359
368
  isWorkflowRunToolName,
360
369
  latestPostChatFollowup,
361
370
  loadPlatformEndpoints,
362
371
  messageContentFromTurn,
372
+ namedSubagent,
363
373
  normalizeMessageContent,
364
374
  normalizeMessageRefs,
365
375
  normalizePluginRefs,
@@ -373,6 +383,7 @@ export {
373
383
  prependOlder,
374
384
  queuePauseReasonLabel,
375
385
  queuedMessageStatusLabel,
386
+ readPlanDocument,
376
387
  reconcileHistoricalUserTurns,
377
388
  reconcileOptimisticUserTurns,
378
389
  replaceWindow,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/polling-backoff.ts","../src/platform-endpoints.ts","../src/commands/protocol.ts","../src/schemas/projection-utils.ts","../src/schemas/solution.ts","../src/schemas/task.ts"],"sourcesContent":["import { BladeApiError } from \"./rest\"\n\nconst MAX_BACKOFF_MS = 60_000\nconst MAX_TIMER_MS = 2_147_483_647\n\n/** Scheduling policy for read-only polling; never sends or replays a request. */\nexport class PollingBackoff {\n private failures = 0\n private nextAt: number | false = 0\n\n constructor(private readonly intervalMs: number) {\n if (!Number.isFinite(intervalMs) || intervalMs <= 0 || intervalMs > MAX_BACKOFF_MS) {\n throw new RangeError(\"Polling interval must be between 0 and 60000 ms\")\n }\n }\n\n reset(): void {\n this.failures = 0\n this.nextAt = 0\n }\n\n failed(error: unknown): void {\n if (\n (error instanceof Error && error.name === \"AbortError\") ||\n (error instanceof BladeApiError && error.status < 500 &&\n error.status !== 408 && error.status !== 429)\n ) {\n this.nextAt = false\n return\n }\n this.failures = Math.min(this.failures + 1, 10)\n const ceiling = Math.min(MAX_BACKOFF_MS, this.intervalMs * 2 ** this.failures)\n const backoff = Math.max(this.intervalMs, ceiling * (0.5 + Math.random() * 0.5))\n const header = error instanceof BladeApiError\n ? error.response.headers.get(\"Retry-After\")?.trim()\n : undefined\n const retryAfter = header\n ? /^\\d+$/.test(header) ? Number(header) * 1000 : Date.parse(header) - Date.now()\n : 0\n const delay = Math.max(backoff, Number.isNaN(retryAfter) ? 0 : retryAfter)\n // Oversized server delays must not overflow browser timers into a hot loop.\n this.nextAt = delay > MAX_TIMER_MS ? false : Date.now() + delay\n }\n\n /** Zero means ready, false means stop, otherwise wait at least this many ms. */\n waitMs(): number | false {\n return this.nextAt === false ? false : Math.max(0, this.nextAt - Date.now())\n }\n}\n","import { isRecord } from \"./shared/type-guards\"\n\nexport const PLATFORM_SERVICE_NAMES = [\n \"os\",\n \"hub\",\n \"agent\",\n \"oauth\",\n \"llmGateway\",\n \"gitea\",\n \"tile\",\n] as const\n\nexport type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]\n\nexport interface PlatformEndpoints {\n services: Partial<Record<PlatformServiceName, string>>\n}\n\nexport const EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints = Object.freeze({\n services: Object.freeze({}),\n})\n\nexport interface LoadPlatformEndpointsOptions {\n baseUrl?: string\n fetchImpl?: typeof fetch\n timeoutMs?: number\n}\n\nfunction defaultDocumentBaseUrl(): string | undefined {\n if (typeof document === \"undefined\") return undefined\n if (document.querySelector(\"base[href]\")) return document.baseURI\n if (typeof location !== \"undefined\" && location.origin) return `${location.origin}/`\n return document.baseURI\n}\n\nfunction normalizeServiceUrl(value: unknown): string | null {\n if (typeof value !== \"string\" || !value.trim()) return null\n if (value.includes(\"?\") || value.includes(\"#\")) return null\n try {\n const url = new URL(value.trim())\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null\n if (url.username || url.password || url.search || url.hash) return null\n return url.toString().replace(/\\/$/, \"\")\n } catch {\n return null\n }\n}\n\nexport function parsePlatformEndpoints(value: unknown): PlatformEndpoints | null {\n if (!isRecord(value) || !isRecord(value.services)) return null\n\n const services: Partial<Record<PlatformServiceName, string>> = {}\n for (const name of PLATFORM_SERVICE_NAMES) {\n if (!(name in value.services)) continue\n const url = normalizeServiceUrl(value.services[name])\n if (!url) return null\n if (name === \"agent\" && new URL(url).pathname !== \"/\") return null\n services[name] = url\n }\n\n return { services }\n}\n\nexport async function loadPlatformEndpoints(\n options: LoadPlatformEndpointsOptions = {},\n): Promise<PlatformEndpoints> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch\n const baseUrl = options.baseUrl ?? defaultDocumentBaseUrl()\n if (!fetchImpl || !baseUrl) return EMPTY_PLATFORM_ENDPOINTS\n\n const controller = new AbortController()\n const timeout = globalThis.setTimeout(() => controller.abort(), options.timeoutMs ?? 3_000)\n try {\n const response = await fetchImpl(new URL(\"config.json\", baseUrl), {\n cache: \"no-store\",\n credentials: \"same-origin\",\n headers: { Accept: \"application/json\" },\n signal: controller.signal,\n })\n if (!response.ok) return EMPTY_PLATFORM_ENDPOINTS\n return parsePlatformEndpoints(await response.json()) ?? EMPTY_PLATFORM_ENDPOINTS\n } catch {\n return EMPTY_PLATFORM_ENDPOINTS\n } finally {\n globalThis.clearTimeout(timeout)\n }\n}\n\nexport function resolveServiceUrl(\n endpoints: PlatformEndpoints,\n name: PlatformServiceName,\n path = \"\",\n): string | null {\n const baseUrl = endpoints.services[name]\n if (!baseUrl) return null\n if (!path) return baseUrl\n const pathReference = path.trimStart()\n if (\n path.includes(\"\\\\\") ||\n pathReference.startsWith(\"//\") ||\n /^[a-z][a-z0-9+.-]*:/i.test(pathReference)\n ) {\n return null\n }\n const base = new URL(`${baseUrl}/`)\n const target = new URL(path.replace(/^\\/+/, \"\"), base)\n if (target.origin !== base.origin || !target.pathname.startsWith(base.pathname)) {\n return null\n }\n return target.toString()\n}\n","/**\n * 页面协作协议(对应后端 `_meta.bridge` 通道,见 docs/specs/260417-embed-bridge)。\n *\n * ## action 从哪里来\n *\n * 智能体 → 宿主方向的每一条指令,都源自**技能作者写的工具代码**:工具返回值\n * JSON 里带 `_meta.bridge: { action, payload }`,后端在持久化前把它剥离成独立\n * 事件送达前端(LLM 的对话历史里读不到它)。因此:\n *\n * - action 字符串(如 \"map.highlight\")是**技能作者与宿主页面开发者之间的业务\n * 契约**,LLM 不参与协议、SDK 不做枚举校验;\n * - 宿主页面用 `session.onCommand(\"map.highlight\", fn)` 消费;\n * - 未注册 handler 的 action 会进入有限缓冲等待注册,超限后丢弃并 console 告警。\n *\n * 宿主 → 智能体方向只有三个白名单动作:attach(附件入输入框)/ insertText\n * (追加输入文本)/ send(直接发消息),对应协议层的 addContext / appendInput /\n * sendMessage。\n */\n\nexport interface CommandEnvelope {\n __bladeBridge: true\n direction: \"agent-to-host\"\n action: string\n payload: unknown\n meta: {\n sessionId: string\n toolCallId?: string\n timestamp: number\n }\n}\n\nexport type InboundAction = \"addContext\" | \"appendInput\" | \"sendMessage\"\n\nexport interface InboundEnvelope {\n __bladeBridge: true\n direction: \"host-to-agent\"\n action: InboundAction\n payload: unknown\n}\n\nexport function isCommandEnvelope(value: unknown): value is CommandEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"agent-to-host\" &&\n typeof record.action === \"string\"\n )\n}\n\nexport function isInboundEnvelope(value: unknown): value is InboundEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"host-to-agent\" &&\n (record.action === \"addContext\" || record.action === \"appendInput\" || record.action === \"sendMessage\")\n )\n}\n","import type { PostChatFollowup, TurnProjection } from \"./projection\"\n\n/** 返回最新根会话轮次的小结;新用户消息到达后旧小结立即失效。 */\nexport function latestPostChatFollowup(turns: TurnProjection[]): PostChatFollowup | null {\n for (let index = turns.length - 1; index >= 0; index -= 1) {\n const turn = turns[index]\n if (\n turn.loop_id === \"root\" &&\n (turn.role === \"user\" || turn.role === \"assistant\") &&\n (turn.kind ?? \"message\") === \"message\" &&\n !turn.blocks.some((block) =>\n [\"mode_change\", \"plan_status\", \"ask_user_answer\"].includes(block.type),\n )\n ) {\n return turn.role === \"assistant\" ? (turn.post_chat_followup ?? null) : null\n }\n }\n return null\n}\n","export enum LayoutType {\n Default = \"default\",\n SkillEditor = \"skill-editor\",\n SolutionEditor = \"solution-editor\",\n SolutionApp = \"solution-app\",\n Custom = \"custom\",\n}\n\nexport interface Solution {\n id: string\n name: string\n version: string\n description?: string | null\n source?: \"builtin\" | \"personal\" | string | null\n layout_type: LayoutType | string\n initial_mode?: \"planning\" | \"executing\" | string | null\n initial_message?: string | null\n preview?: { url: string; title?: string | null } | null\n layout?: {\n available?: boolean\n source_dir?: string\n entry?: string\n export?: string\n } | null\n roles?: BizRole[] | null\n data?: Record<string, unknown> | null\n ui_config?: SolutionAppUiConfig | null\n}\n\nexport interface SolutionAppUiConfig {\n branding: {\n name: string\n subtitle?: string\n icon_text: string\n icon_gradient?: string\n }\n list: {\n title: string\n create_button: string\n card?: {\n subtitle?: string\n stats?: Array<{\n label: string\n value: string\n color?: string\n }>\n }\n }\n create: {\n title: string\n description?: string\n submit_button: string\n sections: Array<{\n id: string\n title: string\n description?: string\n fields: Array<SolutionAppField>\n }>\n }\n}\n\nexport type SolutionAppField =\n | {\n id: string\n kind: \"textarea\"\n label: string\n placeholder?: string\n }\n | {\n id: string\n kind: \"file-upload\"\n accept?: string[]\n categories?: Array<{\n label: string\n description: string\n color: string\n }>\n }\n\nexport interface SolutionAppState {\n pipeline: Array<{\n id: string\n label: string\n status: \"done\" | \"active\" | \"pending\" | \"error\"\n }>\n meta: Record<\n string,\n {\n label: string\n value: string\n color?: string\n }\n >\n}\n\nexport interface BizRole {\n id: string\n name: string\n description?: string | null\n preview?: { url: string; title?: string | null } | null\n}\n","import { type } from \"arktype\"\n\nexport const TaskStatus = type(\"'pending' | 'in_progress' | 'done' | 'failed' | 'skipped'\")\nexport type TaskStatus = typeof TaskStatus.infer\n\nexport const Task = type({\n id: \"string\",\n goal: \"string\",\n skills: \"string[]\",\n depends_on: \"string[]\",\n status: TaskStatus,\n result_summary: \"string\",\n number: \"string\",\n})\nexport type Task = typeof Task.infer\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,iBAAiB;AACvB,IAAM,eAAe;AAGd,IAAM,iBAAN,MAAqB;AAAA,EAI1B,YAA6B,YAAoB;AAApB;AAC3B,QAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,KAAK,aAAa,gBAAgB;AAClF,YAAM,IAAI,WAAW,iDAAiD;AAAA,IACxE;AAAA,EACF;AAAA,EAJ6B;AAAA,EAHrB,WAAW;AAAA,EACX,SAAyB;AAAA,EAQjC,QAAc;AACZ,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,OAAsB;AAC3B,QACG,iBAAiB,SAAS,MAAM,SAAS,gBACzC,iBAAiB,iBAAiB,MAAM,SAAS,OAChD,MAAM,WAAW,OAAO,MAAM,WAAW,KAC3C;AACA,WAAK,SAAS;AACd;AAAA,IACF;AACA,SAAK,WAAW,KAAK,IAAI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EAAE,SAAS,MAAM,IAAI;AAAA,IACvE,GACA;AACA,aAAO,KAAK,SAAS,cAAe,KAAK,sBAAsB,OAAQ;AAAA,IACzE;AAAA,EACF;AACA,SAAO;AACT;;;AClBO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,oBAAiB;AACjB,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,YAAS;AALC,SAAAA;AAAA,GAAA;;;ACAZ,SAAS,YAAY;AAEd,IAAM,aAAa,KAAK,2DAA2D;AAGnF,IAAM,OAAO,KAAK;AAAA,EACvB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,QAAQ;AACV,CAAC;","names":["LayoutType"]}
1
+ {"version":3,"sources":["../src/polling-backoff.ts","../src/platform-endpoints.ts","../src/commands/protocol.ts","../src/schemas/projection-utils.ts","../src/schemas/solution.ts","../src/schemas/task.ts","../src/shared/pack-events.ts"],"sourcesContent":["import { BladeApiError } from \"./rest\"\n\nconst MAX_BACKOFF_MS = 60_000\nconst MAX_TIMER_MS = 2_147_483_647\n\n/** Scheduling policy for read-only polling; never sends or replays a request. */\nexport class PollingBackoff {\n private failures = 0\n private nextAt: number | false = 0\n\n constructor(private readonly intervalMs: number) {\n if (!Number.isFinite(intervalMs) || intervalMs <= 0 || intervalMs > MAX_BACKOFF_MS) {\n throw new RangeError(\"Polling interval must be between 0 and 60000 ms\")\n }\n }\n\n reset(): void {\n this.failures = 0\n this.nextAt = 0\n }\n\n failed(error: unknown): void {\n if (\n (error instanceof Error && error.name === \"AbortError\") ||\n (error instanceof BladeApiError && error.status < 500 &&\n error.status !== 408 && error.status !== 429)\n ) {\n this.nextAt = false\n return\n }\n this.failures = Math.min(this.failures + 1, 10)\n const ceiling = Math.min(MAX_BACKOFF_MS, this.intervalMs * 2 ** this.failures)\n const backoff = Math.max(this.intervalMs, ceiling * (0.5 + Math.random() * 0.5))\n const header = error instanceof BladeApiError\n ? error.response.headers.get(\"Retry-After\")?.trim()\n : undefined\n const retryAfter = header\n ? /^\\d+$/.test(header) ? Number(header) * 1000 : Date.parse(header) - Date.now()\n : 0\n const delay = Math.max(backoff, Number.isNaN(retryAfter) ? 0 : retryAfter)\n // Oversized server delays must not overflow browser timers into a hot loop.\n this.nextAt = delay > MAX_TIMER_MS ? false : Date.now() + delay\n }\n\n /** Zero means ready, false means stop, otherwise wait at least this many ms. */\n waitMs(): number | false {\n return this.nextAt === false ? false : Math.max(0, this.nextAt - Date.now())\n }\n}\n","import { isRecord } from \"./shared/type-guards\"\n\nexport const PLATFORM_SERVICE_NAMES = [\n \"os\",\n \"hub\",\n \"agent\",\n \"oauth\",\n \"llmGateway\",\n \"gitea\",\n \"tile\",\n] as const\n\nexport type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number]\n\nexport interface PlatformEndpoints {\n services: Partial<Record<PlatformServiceName, string>>\n}\n\nexport const EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints = Object.freeze({\n services: Object.freeze({}),\n})\n\nexport interface LoadPlatformEndpointsOptions {\n baseUrl?: string\n fetchImpl?: typeof fetch\n timeoutMs?: number\n}\n\nfunction defaultDocumentBaseUrl(): string | undefined {\n if (typeof document === \"undefined\") return undefined\n if (document.querySelector(\"base[href]\")) return document.baseURI\n if (typeof location !== \"undefined\" && location.origin) return `${location.origin}/`\n return document.baseURI\n}\n\nfunction normalizeServiceUrl(value: unknown): string | null {\n if (typeof value !== \"string\" || !value.trim()) return null\n if (value.includes(\"?\") || value.includes(\"#\")) return null\n try {\n const url = new URL(value.trim())\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null\n if (url.username || url.password || url.search || url.hash) return null\n return url.toString().replace(/\\/$/, \"\")\n } catch {\n return null\n }\n}\n\nexport function parsePlatformEndpoints(value: unknown): PlatformEndpoints | null {\n if (!isRecord(value) || !isRecord(value.services)) return null\n\n const services: Partial<Record<PlatformServiceName, string>> = {}\n for (const name of PLATFORM_SERVICE_NAMES) {\n if (!(name in value.services)) continue\n const url = normalizeServiceUrl(value.services[name])\n if (!url) return null\n if (name === \"agent\" && new URL(url).pathname !== \"/\") return null\n services[name] = url\n }\n\n return { services }\n}\n\nexport async function loadPlatformEndpoints(\n options: LoadPlatformEndpointsOptions = {},\n): Promise<PlatformEndpoints> {\n const fetchImpl = options.fetchImpl ?? globalThis.fetch\n const baseUrl = options.baseUrl ?? defaultDocumentBaseUrl()\n if (!fetchImpl || !baseUrl) return EMPTY_PLATFORM_ENDPOINTS\n\n const controller = new AbortController()\n const timeout = globalThis.setTimeout(() => controller.abort(), options.timeoutMs ?? 3_000)\n try {\n const response = await fetchImpl(new URL(\"config.json\", baseUrl), {\n cache: \"no-store\",\n credentials: \"same-origin\",\n headers: { Accept: \"application/json\" },\n signal: controller.signal,\n })\n if (!response.ok) return EMPTY_PLATFORM_ENDPOINTS\n return parsePlatformEndpoints(await response.json()) ?? EMPTY_PLATFORM_ENDPOINTS\n } catch {\n return EMPTY_PLATFORM_ENDPOINTS\n } finally {\n globalThis.clearTimeout(timeout)\n }\n}\n\nexport function resolveServiceUrl(\n endpoints: PlatformEndpoints,\n name: PlatformServiceName,\n path = \"\",\n): string | null {\n const baseUrl = endpoints.services[name]\n if (!baseUrl) return null\n if (!path) return baseUrl\n const pathReference = path.trimStart()\n if (\n path.includes(\"\\\\\") ||\n pathReference.startsWith(\"//\") ||\n /^[a-z][a-z0-9+.-]*:/i.test(pathReference)\n ) {\n return null\n }\n const base = new URL(`${baseUrl}/`)\n const target = new URL(path.replace(/^\\/+/, \"\"), base)\n if (target.origin !== base.origin || !target.pathname.startsWith(base.pathname)) {\n return null\n }\n return target.toString()\n}\n","/**\n * 页面协作协议(对应后端 `_meta.bridge` 通道,见 docs/specs/260417-embed-bridge)。\n *\n * ## action 从哪里来\n *\n * 智能体 → 宿主方向的每一条指令,都源自**技能作者写的工具代码**:工具返回值\n * JSON 里带 `_meta.bridge: { action, payload }`,后端在持久化前把它剥离成独立\n * 事件送达前端(LLM 的对话历史里读不到它)。因此:\n *\n * - action 字符串(如 \"map.highlight\")是**技能作者与宿主页面开发者之间的业务\n * 契约**,LLM 不参与协议、SDK 不做枚举校验;\n * - 宿主页面用 `session.onCommand(\"map.highlight\", fn)` 消费;\n * - 未注册 handler 的 action 会进入有限缓冲等待注册,超限后丢弃并 console 告警。\n *\n * 宿主 → 智能体方向只有三个白名单动作:attach(附件入输入框)/ insertText\n * (追加输入文本)/ send(直接发消息),对应协议层的 addContext / appendInput /\n * sendMessage。\n */\n\nexport interface CommandEnvelope {\n __bladeBridge: true\n direction: \"agent-to-host\"\n action: string\n payload: unknown\n meta: {\n sessionId: string\n toolCallId?: string\n timestamp: number\n }\n}\n\nexport type InboundAction = \"addContext\" | \"appendInput\" | \"sendMessage\"\n\nexport interface InboundEnvelope {\n __bladeBridge: true\n direction: \"host-to-agent\"\n action: InboundAction\n payload: unknown\n}\n\nexport function isCommandEnvelope(value: unknown): value is CommandEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"agent-to-host\" &&\n typeof record.action === \"string\"\n )\n}\n\nexport function isInboundEnvelope(value: unknown): value is InboundEnvelope {\n if (typeof value !== \"object\" || value === null) return false\n const record = value as Record<string, unknown>\n return (\n record.__bladeBridge === true &&\n record.direction === \"host-to-agent\" &&\n (record.action === \"addContext\" || record.action === \"appendInput\" || record.action === \"sendMessage\")\n )\n}\n","import type { PostChatFollowup, TurnProjection } from \"./projection\"\n\n/** 返回最新根会话轮次的小结;新用户消息到达后旧小结立即失效。 */\nexport function latestPostChatFollowup(turns: TurnProjection[]): PostChatFollowup | null {\n for (let index = turns.length - 1; index >= 0; index -= 1) {\n const turn = turns[index]\n if (\n turn.loop_id === \"root\" &&\n (turn.role === \"user\" || turn.role === \"assistant\") &&\n (turn.kind ?? \"message\") === \"message\" &&\n !turn.blocks.some((block) =>\n [\"mode_change\", \"plan_status\", \"plan_update\", \"ask_user_answer\"].includes(block.type),\n )\n ) {\n return turn.role === \"assistant\" ? (turn.post_chat_followup ?? null) : null\n }\n }\n return null\n}\n","export enum LayoutType {\n Default = \"default\",\n SkillEditor = \"skill-editor\",\n SolutionEditor = \"solution-editor\",\n SolutionApp = \"solution-app\",\n Custom = \"custom\",\n}\n\nexport interface Solution {\n id: string\n name: string\n version: string\n description?: string | null\n source?: \"builtin\" | \"personal\" | string | null\n layout_type: LayoutType | string\n initial_mode?: \"planning\" | \"executing\" | string | null\n initial_message?: string | null\n preview?: { url: string; title?: string | null } | null\n layout?: {\n available?: boolean\n source_dir?: string\n entry?: string\n export?: string\n } | null\n roles?: BizRole[] | null\n data?: Record<string, unknown> | null\n ui_config?: SolutionAppUiConfig | null\n}\n\nexport interface SolutionAppUiConfig {\n branding: {\n name: string\n subtitle?: string\n icon_text: string\n icon_gradient?: string\n }\n list: {\n title: string\n create_button: string\n card?: {\n subtitle?: string\n stats?: Array<{\n label: string\n value: string\n color?: string\n }>\n }\n }\n create: {\n title: string\n description?: string\n submit_button: string\n sections: Array<{\n id: string\n title: string\n description?: string\n fields: Array<SolutionAppField>\n }>\n }\n}\n\nexport type SolutionAppField =\n | {\n id: string\n kind: \"textarea\"\n label: string\n placeholder?: string\n }\n | {\n id: string\n kind: \"file-upload\"\n accept?: string[]\n categories?: Array<{\n label: string\n description: string\n color: string\n }>\n }\n\nexport interface SolutionAppState {\n pipeline: Array<{\n id: string\n label: string\n status: \"done\" | \"active\" | \"pending\" | \"error\"\n }>\n meta: Record<\n string,\n {\n label: string\n value: string\n color?: string\n }\n >\n}\n\nexport interface BizRole {\n id: string\n name: string\n description?: string | null\n preview?: { url: string; title?: string | null } | null\n}\n","import { type } from \"arktype\"\n\nexport const TaskStatus = type(\"'pending' | 'in_progress' | 'done' | 'failed' | 'skipped'\")\nexport type TaskStatus = typeof TaskStatus.infer\n\nexport const Task = type({\n id: \"string\",\n goal: \"string\",\n skills: \"string[]\",\n depends_on: \"string[]\",\n status: TaskStatus,\n result_summary: \"string\",\n number: \"string\",\n})\nexport type Task = typeof Task.infer\n","import type { ContentBlock } from \"../schemas/projection\"\nimport type { ChatMessage } from \"../schemas/message\"\nimport { isRecord } from \"./type-guards\"\n\nexport function packEventNotification(source: unknown): ContentBlock | null {\n if (!isRecord(source) || typeof source.pack !== \"string\" || !source.pack ||\n typeof source.event_id !== \"string\" || !source.event_id || typeof source.title !== \"string\") return null\n return { type: \"system_notification\", content: {\n notification_type: \"pack:event\", status: \"received\", title: `来自『${source.title}』的事件`,\n detail: null, metadata: source,\n } }\n}\n\nexport function packEventTitle(message: Pick<ChatMessage, \"blocks\">): string | null {\n for (const block of message.blocks ?? []) {\n if (block.type === \"system_notification\" && isRecord(block.content) &&\n block.content.notification_type === \"pack:event\" && typeof block.content.title === \"string\") return block.content.title\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,iBAAiB;AACvB,IAAM,eAAe;AAGd,IAAM,iBAAN,MAAqB;AAAA,EAI1B,YAA6B,YAAoB;AAApB;AAC3B,QAAI,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,KAAK,aAAa,gBAAgB;AAClF,YAAM,IAAI,WAAW,iDAAiD;AAAA,IACxE;AAAA,EACF;AAAA,EAJ6B;AAAA,EAHrB,WAAW;AAAA,EACX,SAAyB;AAAA,EAQjC,QAAc;AACZ,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,OAAsB;AAC3B,QACG,iBAAiB,SAAS,MAAM,SAAS,gBACzC,iBAAiB,iBAAiB,MAAM,SAAS,OAChD,MAAM,WAAW,OAAO,MAAM,WAAW,KAC3C;AACA,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AAO;AAAA,MAAK,CAAC,UACjB,CAAC,eAAe,eAAe,eAAe,iBAAiB,EAAE,SAAS,MAAM,IAAI;AAAA,IACtF,GACA;AACA,aAAO,KAAK,SAAS,cAAe,KAAK,sBAAsB,OAAQ;AAAA,IACzE;AAAA,EACF;AACA,SAAO;AACT;;;AClBO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,oBAAiB;AACjB,EAAAA,YAAA,iBAAc;AACd,EAAAA,YAAA,YAAS;AALC,SAAAA;AAAA,GAAA;;;ACAZ,SAAS,YAAY;AAEd,IAAM,aAAa,KAAK,2DAA2D;AAGnF,IAAM,OAAO,KAAK;AAAA,EACvB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,QAAQ;AACV,CAAC;;;ACAM,SAAS,eAAe,SAAqD;AAClF,aAAW,SAAS,QAAQ,UAAU,CAAC,GAAG;AACxC,QAAI,MAAM,SAAS,yBAAyB,SAAS,MAAM,OAAO,KAChE,MAAM,QAAQ,sBAAsB,gBAAgB,OAAO,MAAM,QAAQ,UAAU,SAAU,QAAO,MAAM,QAAQ;AAAA,EACtH;AACA,SAAO;AACT;","names":["LayoutType"]}
@@ -15,8 +15,37 @@ export interface PackLayoutOperation {
15
15
  region?: string;
16
16
  component?: string;
17
17
  after?: string;
18
+ first?: boolean;
19
+ }
20
+ export interface PersonalLayoutOperation {
21
+ op: "hide" | "show";
22
+ target: string;
23
+ }
24
+ export interface ProfileAdjustment {
25
+ region: string;
26
+ id: string;
27
+ title: string;
28
+ visible: boolean;
29
+ }
30
+ export interface StyleAppearance {
31
+ theme: "default" | "military" | "win98";
32
+ detail: "normal" | "lite";
33
+ }
34
+ export interface StyleSummary {
35
+ name: string;
36
+ title: string;
37
+ summary: string;
38
+ preview: string;
39
+ current: boolean;
40
+ has_triggers: boolean;
41
+ unavailable_reason?: string;
18
42
  }
19
43
  export interface PackManifest {
44
+ kind?: "style";
45
+ summary?: string;
46
+ preview?: string;
47
+ appearance?: StyleAppearance;
48
+ landing?: string;
20
49
  name: string;
21
50
  version: string;
22
51
  title: string;
@@ -49,6 +78,16 @@ export interface InstalledPack {
49
78
  }
50
79
  /** The server computes composition. Hosts only select available renderers. */
51
80
  export interface PackProfile {
81
+ adjustments: ProfileAdjustment[];
82
+ style: {
83
+ name: string;
84
+ title: string;
85
+ };
86
+ appearance: StyleAppearance;
87
+ landing: {
88
+ component: string;
89
+ href: string;
90
+ };
52
91
  version: string;
53
92
  regions: Record<string, ProfileComponent[]>;
54
93
  hidden: string[];
@@ -82,6 +121,17 @@ export declare class ProfileResource {
82
121
  /** Also refresh after reconnect, since changes may have happened offline. */
83
122
  onChanged(listener: () => void): () => void;
84
123
  }
124
+ export interface PackEvent {
125
+ id: string;
126
+ pack: string;
127
+ version: string;
128
+ dedupe_key: string;
129
+ type: string;
130
+ payload: unknown;
131
+ status: "pending" | "delivered" | "skipped" | "failed";
132
+ reason: string;
133
+ created_at: string;
134
+ }
85
135
  export declare class PacksResource {
86
136
  private readonly client;
87
137
  readonly records: PackRecordsResource;
@@ -89,12 +139,38 @@ export declare class PacksResource {
89
139
  sessionByTag(name: string, tag: string, init?: RequestInit): Promise<{
90
140
  session_id: string;
91
141
  }>;
142
+ emitEvent(name: string, input: {
143
+ type: string;
144
+ payload: unknown;
145
+ dedupe_key: string;
146
+ }, init?: RequestInit): Promise<PackEvent>;
147
+ event(name: string, id: string, init?: RequestInit): Promise<PackEvent>;
148
+ hookKey(name: string, rotate?: boolean, init?: RequestInit): Promise<{
149
+ configured: boolean;
150
+ url: string;
151
+ key?: string;
152
+ }>;
153
+ clearSimulated(name: string, collection: string, init?: RequestInit): Promise<{
154
+ deleted: number;
155
+ }>;
92
156
  list(): Promise<{
93
157
  items: InstalledPack[];
94
158
  }>;
95
159
  save(manifest: PackManifest, files?: Record<string, string>): Promise<PackProfile>;
96
160
  enable(name: string): Promise<PackProfile>;
97
161
  disable(name: string): Promise<PackProfile>;
162
+ /** Restore defaults of the current style, keeping other styles and extensions. */
163
+ reset(): Promise<PackProfile>;
164
+ applyLayout(ops: PersonalLayoutOperation[]): Promise<PackProfile>;
165
+ file(name: string, path: string, init?: RequestInit): Promise<string>;
166
+ }
167
+ export declare class StylesResource {
168
+ private readonly client;
169
+ constructor(client: BladeClient);
170
+ list(): Promise<{
171
+ items: StyleSummary[];
172
+ }>;
173
+ select(name: string): Promise<PackProfile>;
98
174
  reset(): Promise<PackProfile>;
99
175
  file(name: string, path: string, init?: RequestInit): Promise<string>;
100
176
  }
@@ -1,7 +1,7 @@
1
1
  import type { BackgroundTask, BackgroundTaskStopResult } from "../schemas/background";
2
2
  import type { TurnProjection } from "../schemas/projection";
3
3
  import type { McpAppArchive } from "../schemas/mcp-app";
4
- import type { PublishedSolutionRef, ReplayPreview, ReplaySpeed, SessionDetail, SessionInfo } from "../schemas/session";
4
+ import type { PublishedSolutionRef, ReplayMode, ReplayPreset, ReplayPreview, ReplaySettings, ReplaySpeed, ReplayToolAction, SessionDetail, SessionInfo } from "../schemas/session";
5
5
  import type { McpAppContextState, McpAppContextUpdate } from "../schemas/mcp-app";
6
6
  import type { Task } from "../schemas/task";
7
7
  import type { BladeClient, UploadProgress } from "../blade-client";
@@ -129,6 +129,9 @@ export interface CreateSessionRequest {
129
129
  compaction_ratio?: number | null;
130
130
  compaction_preference?: CompactionPreference;
131
131
  chat_group_id?: string | null;
132
+ enabled_plugin_ids?: string[];
133
+ disabled_plugin_ids?: string[];
134
+ excluded_computers?: string[];
132
135
  }
133
136
  export interface McpSourceConfig {
134
137
  /** Source summary shown before lazy tool discovery. */
@@ -543,12 +546,17 @@ export declare class SessionsResource {
543
546
  updateSessionConfiguration(sessionId: string, request: UpdateSessionConfigurationRequest): Promise<SessionConfiguration>;
544
547
  setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
545
548
  pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
546
- startReplaySession(sourceSessionId: string, speed?: ReplaySpeed): Promise<{
549
+ startReplaySession(sourceSessionId: string, speed?: ReplaySpeed, options?: ReplaySettings & {
550
+ mode: ReplayMode;
551
+ preset?: ReplayPreset;
552
+ }): Promise<{
547
553
  session_id: string;
548
554
  }>;
549
- updateReplaySession(sessionId: string, payload: {
555
+ updateReplaySession(sessionId: string, payload: ReplaySettings & {
550
556
  speed?: ReplaySpeed;
551
557
  status?: "autonomous";
558
+ record_workspace_snapshots?: boolean;
559
+ tool_action?: ReplayToolAction;
552
560
  }): Promise<{
553
561
  replay_state: SessionInfo["replay_state"];
554
562
  }>;
@@ -675,6 +683,13 @@ export declare class SessionsResource {
675
683
  importSession(file: File, name?: string, solutionOverride?: string | null | ImportSessionOptions): Promise<{
676
684
  session_id: string;
677
685
  }>;
686
+ importReplay(file: File, options: {
687
+ mode: ReplayMode;
688
+ preset?: ReplayPreset;
689
+ name?: string;
690
+ }): Promise<{
691
+ session_id: string;
692
+ }>;
678
693
  }
679
694
  export interface SessionRunResult<T = unknown> {
680
695
  kind: "run_end";
@@ -0,0 +1,6 @@
1
+ /** Status persisted by the board and projected in its change event. */
2
+ export type BoardTaskStatus = "todo" | "running" | "ended" | "archive";
3
+ /** One project in GET /api/agent-board/board-task-summary. */
4
+ export type ProjectTaskSummary = {
5
+ project_id: number;
6
+ } & Record<BoardTaskStatus, number>;
@@ -38,6 +38,7 @@ export interface ToolCallInfo {
38
38
  display_name?: string | null;
39
39
  arguments: string;
40
40
  result?: unknown;
41
+ recorded_result?: string;
41
42
  status?: "pending" | "done" | "error" | "cancelled" | "awaiting_answer";
42
43
  duration_ms?: number | null;
43
44
  pending_question_ref?: PendingQuestionRef | null;
@@ -0,0 +1,29 @@
1
+ export type PlanLeafStatus = "pending" | "running" | "done" | "failed" | "skipped";
2
+ export type PlanPhase = "draft" | "executing" | "completed";
3
+ export interface PlanAgentRef {
4
+ agent: string;
5
+ execution_id?: string;
6
+ request_id?: string;
7
+ }
8
+ export interface PlanNode {
9
+ id: string;
10
+ label: string;
11
+ parent_id?: string;
12
+ depends_on?: string[];
13
+ agent_ref?: PlanAgentRef;
14
+ status?: PlanLeafStatus;
15
+ note?: string;
16
+ }
17
+ export interface PlanDocument {
18
+ plan_id: string;
19
+ title: string;
20
+ phase: PlanPhase;
21
+ nodes: PlanNode[];
22
+ revision: number;
23
+ }
24
+ export interface ApprovePlanInput {
25
+ plan_id: string;
26
+ revision: number;
27
+ expected_branch_tip: string;
28
+ }
29
+ export declare function readPlanDocument(value: unknown): PlanDocument | null;
@@ -3,7 +3,7 @@ export interface ToolBridgeContent {
3
3
  payload?: unknown;
4
4
  }
5
5
  export interface ContentBlock {
6
- type: "text" | "thinking" | "tool_use" | "tool_result" | "tool_ui" | "tool_bridge" | "system_notification" | "mode_change" | "plan_status" | "ask_user_answer";
6
+ type: "text" | "thinking" | "tool_use" | "tool_result" | "tool_ui" | "tool_bridge" | "system_notification" | "mode_change" | "plan_status" | "plan_update" | "ask_user_answer";
7
7
  content: unknown;
8
8
  /** Stable history-entry identity for a tool_bridge delivery. */
9
9
  delivery_id?: string | null;
@@ -59,6 +59,7 @@ export interface ToolCallProjection {
59
59
  arguments: string;
60
60
  status: "pending" | "done" | "error" | "cancelled" | "awaiting_answer" | string;
61
61
  result?: unknown;
62
+ recorded_result?: string;
62
63
  duration_ms?: number | null;
63
64
  /** 工具真正进入执行的墙钟起点;排队/待审批的调用没有该值。 */
64
65
  started_at?: string | null;
@@ -19,13 +19,32 @@ export type ReplaySpeed = 1 | 2 | 5;
19
19
  * 同一个源对话从不同入口开出来速度不一样。
20
20
  */
21
21
  export declare const DEFAULT_REPLAY_SPEED: ReplaySpeed;
22
- export interface ReplayState {
22
+ export interface ReplaySettings {
23
+ hide_failed_tools?: boolean;
24
+ on_mismatch?: "silent" | "ask";
25
+ show_input_hint?: boolean;
26
+ show_next_button?: boolean;
27
+ }
28
+ export type ReplayMode = "sandbox_files_only" | "live_tools";
29
+ export type ReplayPreset = "formal" | "technical";
30
+ export type ReplayToolAction = {
31
+ id: string;
32
+ choice: "retry" | "skip" | "stop";
33
+ };
34
+ export interface ReplayState extends ReplaySettings {
23
35
  source_session_id?: string;
24
36
  status?: "replay" | "autonomous";
25
37
  speed?: ReplaySpeed;
26
38
  next_source_entry_id?: string | null;
27
39
  ended_at?: string | null;
28
40
  autonomous_reason?: string | null;
41
+ mode?: ReplayMode;
42
+ next_input_hint?: string | null;
43
+ record_workspace_snapshots?: boolean;
44
+ tool_failure?: {
45
+ id: string;
46
+ tool: string;
47
+ } | null;
29
48
  }
30
49
  /** 某个会话能否作为回放来源。 */
31
50
  export interface ReplayPreview {
@@ -64,6 +83,9 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
64
83
  initiator?: "sdk" | "ui" | "unknown" | null | undefined;
65
84
  is_headless?: boolean | undefined;
66
85
  scheduled_task_id?: string | undefined;
86
+ parent_session_id?: string | null | undefined;
87
+ subagent_name?: string | null | undefined;
88
+ subagent_readonly?: boolean | null | undefined;
67
89
  viewer_role?: "owner" | "viewer" | undefined;
68
90
  model?: string | null | undefined;
69
91
  enable_thinking?: boolean | null | undefined;
@@ -110,6 +132,8 @@ export type SessionInfo = Omit<typeof SessionInfo.infer, "solution" | "ports" |
110
132
  match?: SessionSearchMatch | null;
111
133
  };
112
134
  export interface SessionDetail extends SessionInfo {
135
+ active_plan?: import("./plan").PlanDocument | null;
136
+ active_branch_tip?: string;
113
137
  /** Fresh history writer occupancy; absent when the server cannot report it. */
114
138
  history_busy?: boolean;
115
139
  preview_url?: string | null;