@blade-hq/agent-client 2610.0.0-beta.9 → 2610.0.0-beta.90

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.
Files changed (43) hide show
  1. package/README.md +266 -11
  2. package/dist/auth.d.ts +0 -1
  3. package/dist/blade-client.d.ts +24 -3
  4. package/dist/index.d.ts +37 -7
  5. package/dist/index.js +2395 -295
  6. package/dist/index.js.map +1 -1
  7. package/dist/platform-endpoints.d.ts +14 -0
  8. package/dist/polling-backoff.d.ts +11 -0
  9. package/dist/resources/chat-groups.d.ts +31 -0
  10. package/dist/resources/computers.d.ts +115 -0
  11. package/dist/resources/models.d.ts +2 -0
  12. package/dist/resources/plugins.d.ts +43 -0
  13. package/dist/resources/sessions.d.ts +193 -2
  14. package/dist/resources/site-visits.d.ts +32 -0
  15. package/dist/rest.d.ts +8 -0
  16. package/dist/schemas/context.d.ts +49 -0
  17. package/dist/schemas/event.d.ts +9 -0
  18. package/dist/schemas/mcp-app.d.ts +30 -0
  19. package/dist/schemas/message-utils.d.ts +15 -1
  20. package/dist/schemas/message.d.ts +6 -0
  21. package/dist/schemas/projection.d.ts +37 -2
  22. package/dist/schemas/session.d.ts +10 -1
  23. package/dist/session/agent-session.d.ts +159 -17
  24. package/dist/session/definition.d.ts +6 -1
  25. package/dist/session/errors.d.ts +11 -0
  26. package/dist/session/events.d.ts +16 -2
  27. package/dist/session/history-page.d.ts +9 -0
  28. package/dist/session/hub.d.ts +9 -1
  29. package/dist/session/queue.d.ts +104 -0
  30. package/dist/session/state.d.ts +18 -2
  31. package/dist/shared/auth-busy.d.ts +9 -0
  32. package/dist/shared/projection/builder.d.ts +12 -0
  33. package/dist/shared/projection/context.d.ts +3 -0
  34. package/dist/shared/projection/helpers.d.ts +2 -2
  35. package/dist/shared/projection/history.d.ts +1 -0
  36. package/dist/shared/projection/index.d.ts +2 -1
  37. package/dist/shared/projection/state.d.ts +7 -0
  38. package/dist/shared/tool-ui-card.d.ts +60 -0
  39. package/dist/shared/type-guards.d.ts +2 -0
  40. package/dist/socket.d.ts +2 -0
  41. package/dist/types/socket-events.d.ts +199 -6
  42. package/package.json +1 -1
  43. package/public-api.md +960 -17
@@ -1,10 +1,13 @@
1
1
  import type { ChatMessage, CompactionInfo, MessageContent } from "../schemas/message";
2
2
  import type { ContentBlock, PatchEnvelope, TurnProjection } from "../schemas/projection";
3
3
  import type { ReplaySpeed, ReplayState, SessionStatus } from "../schemas/session";
4
- /** 一次 AskUserQuestion 的用户作答(选项选择 + 自定义输入)。 */
4
+ import { type SessionQueueSnapshot } from "./queue";
5
+ /** 一次 AskUserQuestion 的用户作答(选项选择 + 自定义输入 + 可选补充)。 */
5
6
  export interface AskUserAnswerData {
6
7
  selections: Record<number, number[]>;
7
8
  custom: Record<number, string>;
9
+ /** 选完选项后的自由补充,空着就是没有。 */
10
+ note?: string;
8
11
  }
9
12
  export interface AgentLoopInfo {
10
13
  toolCallId: string;
@@ -41,8 +44,13 @@ export interface SessionState {
41
44
  activeCompaction: ActiveCompactionState | null;
42
45
  /** 回放(演示 / 彩排)状态;不是回放会话时为 null。 */
43
46
  replay: ReplaySnapshot | null;
47
+ /** 服务端持久化的等待消息队列快照;只在 revision 更新时替换。 */
48
+ queue: SessionQueueSnapshot;
44
49
  /** 当前身份对这个会话的权限;"viewer" 表示只读(分享链接打开的)。 */
45
50
  viewerRole: "owner" | "viewer" | null;
51
+ /** Stable anchor for the next older projected page. */
52
+ nextBefore: string | null;
53
+ loadingOlder: boolean;
46
54
  }
47
55
  /** 回放会话的快照视图,由服务端的 replay_state 归一化而来。 */
48
56
  export interface ReplaySnapshot {
@@ -56,6 +64,9 @@ export declare function toReplaySnapshot(raw: ReplayState | null | undefined): R
56
64
  export declare function createInitialSessionState(sessionId: string): SessionState;
57
65
  export declare function extractModeFromBlocks(blocks: ContentBlock[]): "planning" | "executing" | null;
58
66
  export declare function reconcileOptimisticUserTurns(currentTurns: TurnProjection[], incomingTurns: TurnProjection[]): TurnProjection[];
67
+ /** Reconcile a bulk authoritative window only by an echoed request identity.
68
+ * Positional fallback is reserved for a single live turn from an older server. */
69
+ export declare function reconcileHistoricalUserTurns(currentTurns: TurnProjection[], incomingTurns: TurnProjection[]): TurnProjection[];
59
70
  /**
60
71
  * 用一份新的 turn 列表重建会话状态。
61
72
  * addErrorMessage 注入的 role==="error" 消息不在 turns 里,默认会被物化过程抹掉;
@@ -63,7 +74,12 @@ export declare function reconcileOptimisticUserTurns(currentTurns: TurnProjectio
63
74
  * turn 推进(新消息 / rewind / 重连)时旧错误自动消失。
64
75
  */
65
76
  export declare function withTurns(state: SessionState, turns: TurnProjection[]): SessionState;
66
- export declare function addUserMessage(state: SessionState, content: MessageContent): SessionState;
77
+ /**
78
+ * 安装一份服务端权威队列快照。旧 revision、别的会话或结构不合法的快照一律不采纳,
79
+ * 直接返回原 state——引用不变,订阅者不会收到多余通知。
80
+ */
81
+ export declare function withQueue(state: SessionState, snapshot: SessionQueueSnapshot): SessionState;
82
+ export declare function addUserMessage(state: SessionState, content: MessageContent, clientRequestId?: string): SessionState;
67
83
  export declare function upsertTurn(state: SessionState, turn: TurnProjection): SessionState;
68
84
  export declare function applyTurnPatch(state: SessionState, patch: PatchEnvelope): SessionState;
69
85
  export declare function addErrorMessage(state: SessionState, content: string): SessionState;
@@ -0,0 +1,9 @@
1
+ /** Return the server-requested delay for a typed temporary auth rejection. */
2
+ export declare function authBusyRetryDelayMs(error: unknown): number | null;
3
+ /** One pending manual reconnect for Socket.IO CONNECT_ERROR auth overloads. */
4
+ export declare class AuthBusyReconnect {
5
+ private timer;
6
+ get pending(): boolean;
7
+ schedule(error: unknown, reconnect: () => void): boolean;
8
+ cancel(): void;
9
+ }
@@ -3,6 +3,8 @@ export interface RawEvent {
3
3
  type: string;
4
4
  payload: Record<string, unknown>;
5
5
  }
6
+ /** 在任何事件处理前确认 Socket.IO 批次已到达客户端。 */
7
+ export declare function acknowledgeTurnEvents(acknowledge?: () => void): void;
6
8
  export type ProjectionUpdate = {
7
9
  kind: "upsert";
8
10
  turn: TurnProjection;
@@ -13,6 +15,8 @@ export type ProjectionUpdate = {
13
15
  toolName?: string;
14
16
  workspacePath?: string;
15
17
  };
18
+ /** 是否包含会改变聊天运行生命周期的事件。纯观测/整理事件不启动新一轮。 */
19
+ export declare function hasChatRunEvent(events: RawEvent[]): boolean;
16
20
  /**
17
21
  * 缺失 chat:end 时的终态兜底。只有被投影接受到当前 assistant turn 的 followup
18
22
  * 才能结束流式态;陈旧 followup 或其后已有新轮事件时均返回 false。
@@ -22,7 +26,10 @@ export declare class ClientProjectionBuilder {
22
26
  private activeTurns;
23
27
  private lastTurnIds;
24
28
  private latestTurns;
29
+ private turnsById;
25
30
  private loopDescriptions;
31
+ /** loop_name → 正在运行的子智能体起点,agent:end 结算并挂到父工具调用上。 */
32
+ private activeSubagentRuns;
26
33
  private pendingChildPauses;
27
34
  private pendingMemoryRefs;
28
35
  private activeCompactions;
@@ -37,6 +44,7 @@ export declare class ClientProjectionBuilder {
37
44
  seedSequence(maxSeq: number): void;
38
45
  _seedTurns(turns: TurnProjection[]): void;
39
46
  private onMemoryInject;
47
+ private onContextEntry;
40
48
  private onLoopTurn;
41
49
  private onModeChange;
42
50
  private onPlanStatusUpdate;
@@ -49,7 +57,10 @@ export declare class ClientProjectionBuilder {
49
57
  private onPostChatFollowup;
50
58
  private onDelta;
51
59
  private onToolCallCreated;
60
+ private onToolCallArgumentsDelta;
52
61
  private onResponseDone;
62
+ private applyFirstTokenDelivery;
63
+ private applyStreamTiming;
53
64
  private onToolResultDone;
54
65
  private onToolResultDelta;
55
66
  private onToolUi;
@@ -58,6 +69,7 @@ export declare class ClientProjectionBuilder {
58
69
  private onChildPause;
59
70
  private onChatEnd;
60
71
  private onAgentEnd;
72
+ private settleSubagentRun;
61
73
  private dropIncompleteToolCalls;
62
74
  private onCompaction;
63
75
  private syncPatch;
@@ -0,0 +1,3 @@
1
+ import type { TurnProjection } from "../../schemas/projection";
2
+ /** Build one Context turn from the canonical entry used by live and history paths. */
3
+ export declare function buildContextTurn(entry: Record<string, unknown>, sequence: number): TurnProjection | null;
@@ -1,10 +1,10 @@
1
1
  import type { ContentBlock, PendingQuestionRef, ToolCallProjection, TurnProjection } from "../../schemas/projection";
2
2
  import type { TurnState } from "./state";
3
3
  export declare function upsertToolCall(state: TurnState, toolCallId: string, toolName: string, displayName: string, args: string): void;
4
- export declare function applyToolResult(state: TurnState, toolCallId: string, result: unknown, status: ToolCallProjection["status"], durationMs: number | null, sourceLoop: {
4
+ export declare function applyToolResult(state: TurnState, toolCallId: string, result: unknown, status: ToolCallProjection["status"], durationMs: number | null, ranInParallel: boolean | null, sourceLoop: {
5
5
  loop_name: string;
6
6
  description: string;
7
- } | null): void;
7
+ } | null, startedAt?: string | null): void;
8
8
  export declare function appendToolResultDelta(state: TurnState, toolCallId: string, delta: string, reset?: boolean): void;
9
9
  export declare function appendTextBlock(state: TurnState, blockType: ContentBlock["type"], content: unknown): void;
10
10
  export declare function appendToolCallArguments(state: TurnState, toolCallId: string, delta: string): void;
@@ -4,6 +4,7 @@ export interface RawHistoryEntry {
4
4
  kind?: string;
5
5
  loop_name?: string;
6
6
  message?: Record<string, unknown>;
7
+ source?: Record<string, unknown>;
7
8
  data?: Record<string, unknown>;
8
9
  timestamp?: string;
9
10
  [key: string]: unknown;
@@ -1,3 +1,4 @@
1
- export { acceptedPostChatFollowupCompletesLatestRun, ClientProjectionBuilder, type RawEvent, type ProjectionUpdate, } from "./builder";
1
+ export { acceptedPostChatFollowupCompletesLatestRun, acknowledgeTurnEvents, ClientProjectionBuilder, hasChatRunEvent, type RawEvent, type ProjectionUpdate, } from "./builder";
2
2
  export { type TurnState, createTurnState, snapshot, PAUSE_TOOL_NAMES } from "./state";
3
3
  export { projectHistory, type RawHistoryEntry } from "./history";
4
+ export { buildContextTurn } from "./context";
@@ -10,6 +10,13 @@ export interface TurnState {
10
10
  toolCalls: ToolCallProjection[];
11
11
  usage: Record<string, unknown> | null;
12
12
  responseDone: boolean;
13
+ firstTokenMs: number | null;
14
+ streamDurationMs: number | null;
15
+ firstTokenDeliveryMs: number | null;
16
+ /** 生产者上报的模型请求时序;缺失时保持 null,不用浏览器时间补(#2581 A1/I1)。 */
17
+ modelStartedAt: string | null;
18
+ modelDurationMs: number | null;
19
+ modelStartedAtReported: boolean;
13
20
  memoryRefs: MemoryRef[] | null;
14
21
  parentForkToolCallId: string | null;
15
22
  }
@@ -0,0 +1,60 @@
1
+ import type { ChatMessage, ToolCallInfo } from "../schemas/message";
2
+ import type { ContentBlock } from "../schemas/projection";
3
+ import { type McpAppData } from "../schemas/mcp-app";
4
+ /**
5
+ * MCP App 卡片(`_meta.ui` → `tool_ui` block)的共享判定层。
6
+ *
7
+ * 判定逻辑不许各写一份(仓库 CLAUDE.md):agent-react 与 apps/web 都从这里消费卡片的
8
+ * 实例、可见性、身份和终态规则;样式与状态容器(侧栏页签栈等)两侧各自实现。
9
+ */
10
+ export interface ToolUiCard {
11
+ resourceUri?: string;
12
+ resourceURI?: string;
13
+ resourceHTML?: string;
14
+ /** Local HTML source file; hosts can normalize it against the session workspace. */
15
+ sourcePath?: string;
16
+ /** 历史投影标记:绝不重新解析 resourceUri(刷新不重放 MCP/资源读取)。 */
17
+ archived?: boolean;
18
+ target: "inline" | "preview";
19
+ height: number;
20
+ title?: string;
21
+ /** 留档的 MCP App 来源身份与调用数据(来源 server、ui:// 资源、CSP 元数据)。 */
22
+ mcpApp?: McpAppData;
23
+ }
24
+ /** 严格守卫:target/height 缺失、archived 无留档 HTML、或 mcpApp 来源身份残缺的
25
+ * 卡片一律判无效,消息流、侧栏、toolPreview 事件三处一致降级(不渲染、不发事件、
26
+ * 不推送)。后端 `_tool_ui_meta.py` 总会补齐 target/height 默认值,判无效即数据畸形。 */
27
+ export declare function isToolUiCard(value: unknown): value is ToolUiCard;
28
+ export type ToolUiCardContentType = "resource-html" | "resource-uri" | "resource-file";
29
+ /** 解析卡片实际要渲染的内容。archived 卡片只认留档 HTML,绝不回退到
30
+ * resourceUri——历史恢复/浏览器刷新不得因此重新发起 MCP 资源读取。 */
31
+ export declare function resolveToolUiCardContent(card: ToolUiCard): {
32
+ type: ToolUiCardContentType;
33
+ content: string;
34
+ } | null;
35
+ /** 卡片实例身份/去重键:uri 卡片按内容去重(同一 URI 多次产出只留一份),
36
+ * 文件 HTML 按来源路径,无来源的 HTML 按 toolCallId 去重。 */
37
+ export declare function buildToolUiCardKey(toolCallId: string, type: ToolUiCardContentType, content: string, sourcePath?: string): string;
38
+ /** 内部「阶段进度」卡片不对用户展示入口。 */
39
+ export declare function isInternalStatusToolUiCard(card: {
40
+ title?: string | null;
41
+ } | null): boolean;
42
+ /** app-dev 会话里的应用预览卡片:走专门的预览页签,不开普通侧栏 artifact。 */
43
+ export declare function isAppDevToolUiCard(card: ToolUiCard, isAppDev: boolean): boolean;
44
+ export interface InlineToolUiCardEntry {
45
+ key: string;
46
+ toolCallId: string;
47
+ card: ToolUiCard;
48
+ }
49
+ /** 从一轮消息里收集 target=inline 的卡片(渲染进消息流)。 */
50
+ export declare function collectInlineToolUiCards(messages: ChatMessage[]): InlineToolUiCardEntry[];
51
+ export interface PreviewToolUiCardEntry {
52
+ key: string;
53
+ toolCall: ToolCallInfo;
54
+ card: ToolUiCard;
55
+ /** 所属消息的 blocks;调用方需要还原卡片所在 block 上下文时用。 */
56
+ blocks: ContentBlock[];
57
+ }
58
+ /** 从一轮消息里收集 target=preview 的卡片(进侧栏/面板,不进消息流),
59
+ * 并绑定回所属的 toolCall。 */
60
+ export declare function collectPreviewToolUiCards(messages: ChatMessage[]): PreviewToolUiCardEntry[];
@@ -0,0 +1,2 @@
1
+ /** Return true for non-null, non-array objects. */
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
package/dist/socket.d.ts CHANGED
@@ -4,6 +4,8 @@ import type { ClientToServerEvents, ServerToClientEvents } from "./types/socket-
4
4
  export type TypedSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
5
5
  export interface CreateSocketOptions extends AuthOptions {
6
6
  baseUrl: string;
7
+ /** MV3 service workers have WebSocket but no XMLHttpRequest. */
8
+ transports?: ("polling" | "websocket")[];
7
9
  path?: string;
8
10
  }
9
11
  export declare function createSocket(options: CreateSocketOptions): TypedSocket;
@@ -32,6 +32,9 @@ export declare namespace ChatSendPayloadSchema {
32
32
  [k: string]: unknown;
33
33
  } | null);
34
34
  type CompactionRatio = (number | null);
35
+ type NativeApprovalPolicy = (("unlessTrusted" | "never") | null);
36
+ type KbIds = (number[] | null);
37
+ type QueueWhenRunning = boolean;
35
38
  interface ChatSendPayload {
36
39
  session_id: SessionId;
37
40
  message: Message;
@@ -48,6 +51,9 @@ export declare namespace ChatSendPayloadSchema {
48
51
  runtime_env?: RuntimeEnv;
49
52
  app_context?: AppContext;
50
53
  compaction_ratio?: CompactionRatio;
54
+ native_approval_policy?: NativeApprovalPolicy;
55
+ kb_ids?: KbIds;
56
+ queue_when_running?: QueueWhenRunning;
51
57
  [k: string]: unknown;
52
58
  }
53
59
  interface Message {
@@ -72,9 +78,11 @@ export type ChatStopPayload = ChatStopPayloadSchema.ChatStopPayload;
72
78
  export declare namespace ChatAppendPayloadSchema {
73
79
  type SessionId = string;
74
80
  type Message = string;
81
+ type ClientRequestId = (string | null);
75
82
  interface ChatAppendPayload {
76
83
  session_id: SessionId;
77
84
  message: Message;
85
+ client_request_id?: ClientRequestId;
78
86
  [k: string]: unknown;
79
87
  }
80
88
  }
@@ -87,20 +95,84 @@ export declare namespace ChatCompactPayloadSchema {
87
95
  }
88
96
  }
89
97
  export type ChatCompactPayload = ChatCompactPayloadSchema.ChatCompactPayload;
98
+ export declare namespace ChatQueueListPayloadSchema {
99
+ type SessionId = string;
100
+ interface ChatQueueListPayload {
101
+ session_id: SessionId;
102
+ [k: string]: unknown;
103
+ }
104
+ }
105
+ export type ChatQueueListPayload = ChatQueueListPayloadSchema.ChatQueueListPayload;
106
+ export declare namespace ChatQueueUpdatePayloadSchema {
107
+ type SessionId = string;
108
+ type ItemId = string;
109
+ type ExpectedVersion = number;
110
+ type Message = string;
111
+ interface ChatQueueUpdatePayload {
112
+ session_id: SessionId;
113
+ item_id: ItemId;
114
+ expected_version: ExpectedVersion;
115
+ message: Message;
116
+ [k: string]: unknown;
117
+ }
118
+ }
119
+ export type ChatQueueUpdatePayload = ChatQueueUpdatePayloadSchema.ChatQueueUpdatePayload;
120
+ export declare namespace ChatQueueReorderPayloadSchema {
121
+ type SessionId = string;
122
+ type ExpectedRevision = number;
123
+ type OrderedIds = string[];
124
+ interface ChatQueueReorderPayload {
125
+ session_id: SessionId;
126
+ expected_revision: ExpectedRevision;
127
+ ordered_ids: OrderedIds;
128
+ [k: string]: unknown;
129
+ }
130
+ }
131
+ export type ChatQueueReorderPayload = ChatQueueReorderPayloadSchema.ChatQueueReorderPayload;
132
+ export declare namespace ChatQueueCancelPayloadSchema {
133
+ type SessionId = string;
134
+ type ItemId = string;
135
+ type ExpectedVersion = (number | null);
136
+ interface ChatQueueCancelPayload {
137
+ session_id: SessionId;
138
+ item_id: ItemId;
139
+ expected_version?: ExpectedVersion;
140
+ [k: string]: unknown;
141
+ }
142
+ }
143
+ export type ChatQueueCancelPayload = ChatQueueCancelPayloadSchema.ChatQueueCancelPayload;
144
+ export declare namespace ChatQueueDeliverPayloadSchema {
145
+ type SessionId = string;
146
+ type ItemId = string;
147
+ type ExpectedVersion = number;
148
+ interface ChatQueueDeliverPayload {
149
+ session_id: SessionId;
150
+ item_id: ItemId;
151
+ expected_version: ExpectedVersion;
152
+ [k: string]: unknown;
153
+ }
154
+ }
155
+ export type ChatQueueDeliverPayload = ChatQueueDeliverPayloadSchema.ChatQueueDeliverPayload;
156
+ export declare namespace ChatQueueResumePayloadSchema {
157
+ type SessionId = string;
158
+ interface ChatQueueResumePayload {
159
+ session_id: SessionId;
160
+ [k: string]: unknown;
161
+ }
162
+ }
163
+ export type ChatQueueResumePayload = ChatQueueResumePayloadSchema.ChatQueueResumePayload;
90
164
  export declare namespace SessionSubscribePayloadSchema {
91
165
  type SessionId = string;
92
166
  type Mode = string;
93
167
  type EventFormat = "raw";
94
168
  type AfterSequence = number;
95
169
  type Resume = boolean;
96
- type StreamTokens = boolean;
97
170
  interface SessionSubscribePayload {
98
171
  session_id: SessionId;
99
172
  mode?: Mode;
100
173
  event_format?: EventFormat;
101
174
  after_sequence?: AfterSequence;
102
175
  resume?: Resume;
103
- stream_tokens?: StreamTokens;
104
176
  [k: string]: unknown;
105
177
  }
106
178
  }
@@ -116,7 +188,6 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
116
188
  type EventFormat = "raw";
117
189
  type AfterSequence = number;
118
190
  type Resume = boolean;
119
- type StreamTokens = boolean;
120
191
  interface SessionSubscribeBatchPayload {
121
192
  sessions: Sessions;
122
193
  [k: string]: unknown;
@@ -127,7 +198,6 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
127
198
  event_format?: EventFormat;
128
199
  after_sequence?: AfterSequence;
129
200
  resume?: Resume;
130
- stream_tokens?: StreamTokens;
131
201
  [k: string]: unknown;
132
202
  }
133
203
  }
@@ -183,7 +253,54 @@ export declare namespace ChatEndPayloadSchema {
183
253
  }
184
254
  }
185
255
  export type ChatEndPayload = ChatEndPayloadSchema.ChatEndPayload;
256
+ export declare namespace ChatQueueUpdatedPayloadSchema {
257
+ type SessionId = string;
258
+ type Revision = number;
259
+ type Paused = boolean;
260
+ type PauseReason = (string | null);
261
+ type Id = string;
262
+ type Content = string;
263
+ type Position = number;
264
+ type Version = number;
265
+ type Status = string;
266
+ type CreatedAt = string;
267
+ type UpdatedAt = string;
268
+ type TargetRunId = (string | null);
269
+ type Error = (string | null);
270
+ type Items = ChatQueueItem[];
271
+ interface ChatQueueUpdatedPayload {
272
+ session_id: SessionId;
273
+ revision: Revision;
274
+ paused?: Paused;
275
+ pause_reason?: PauseReason;
276
+ items?: Items;
277
+ [k: string]: unknown;
278
+ }
279
+ interface ChatQueueItem {
280
+ id: Id;
281
+ content: Content;
282
+ position: Position;
283
+ version: Version;
284
+ status: Status;
285
+ created_at: CreatedAt;
286
+ updated_at: UpdatedAt;
287
+ target_run_id?: TargetRunId;
288
+ error?: Error;
289
+ [k: string]: unknown;
290
+ }
291
+ }
292
+ export type ChatQueueUpdatedPayload = ChatQueueUpdatedPayloadSchema.ChatQueueUpdatedPayload;
293
+ export declare namespace SessionCreatedPayloadSchema {
294
+ type SessionId = string;
295
+ interface SessionCreatedPayload {
296
+ session_id: SessionId;
297
+ [k: string]: unknown;
298
+ }
299
+ }
300
+ export type SessionCreatedPayload = SessionCreatedPayloadSchema.SessionCreatedPayload;
186
301
  export declare namespace SessionUpdatedPayloadSchema {
302
+ type WorkspacePath = (string | null);
303
+ type ChatGroupId = (string | null);
187
304
  type SessionId = string;
188
305
  type Model = (string | null);
189
306
  type ReplayState = ({
@@ -193,6 +310,8 @@ export declare namespace SessionUpdatedPayloadSchema {
193
310
  type ProjectId = (number | null);
194
311
  type ProjectName = (string | null);
195
312
  interface SessionUpdatedPayload {
313
+ workspace_path?: WorkspacePath;
314
+ chat_group_id?: ChatGroupId;
196
315
  session_id: SessionId;
197
316
  model?: Model;
198
317
  replay_state?: ReplayState;
@@ -213,6 +332,16 @@ export declare namespace WorkspaceFilesChangedPayloadSchema {
213
332
  }
214
333
  }
215
334
  export type WorkspaceFilesChangedPayload = WorkspaceFilesChangedPayloadSchema.WorkspaceFilesChangedPayload;
335
+ export declare namespace MCPAppChangedPayloadSchema {
336
+ type SessionId = string;
337
+ type SourceId = string;
338
+ interface MCPAppChangedPayload {
339
+ session_id: SessionId;
340
+ source_id: SourceId;
341
+ [k: string]: unknown;
342
+ }
343
+ }
344
+ export type MCPAppChangedPayload = MCPAppChangedPayloadSchema.MCPAppChangedPayload;
216
345
  export declare namespace SystemErrorPayloadSchema {
217
346
  type Message = string;
218
347
  type SessionId = (string | null);
@@ -270,6 +399,20 @@ export declare namespace TurnEventsPayloadSchema {
270
399
  }
271
400
  }
272
401
  export type TurnEventsPayload = TurnEventsPayloadSchema.TurnEventsPayload;
402
+ export declare namespace TurnTimingPayloadSchema {
403
+ type SessionId = string;
404
+ type LoopName = string;
405
+ type TurnId = string;
406
+ type FirstTokenDeliveryMs = number;
407
+ interface TurnTimingPayload {
408
+ session_id: SessionId;
409
+ loop_name: LoopName;
410
+ turn_id: TurnId;
411
+ first_token_delivery_ms: FirstTokenDeliveryMs;
412
+ [k: string]: unknown;
413
+ }
414
+ }
415
+ export type TurnTimingPayload = TurnTimingPayloadSchema.TurnTimingPayload;
273
416
  export declare namespace AsrReadyPayloadSchema {
274
417
  type RequestId = string;
275
418
  type Provider = string;
@@ -386,11 +529,58 @@ export declare namespace ChatCompactAckSchema {
386
529
  }
387
530
  }
388
531
  export type ChatCompactAck = ChatCompactAckSchema.ChatCompactAck;
532
+ export declare namespace ChatQueueAckSchema {
533
+ type SessionId = string;
534
+ type Revision = number;
535
+ type Paused = boolean;
536
+ type PauseReason = (string | null);
537
+ type Id = string;
538
+ type Content = string;
539
+ type Position = number;
540
+ type Version = number;
541
+ type Status = string;
542
+ type CreatedAt = string;
543
+ type UpdatedAt = string;
544
+ type TargetRunId = (string | null);
545
+ type Error = (string | null);
546
+ type Items = ChatQueueItem[];
547
+ type Status1 = string;
548
+ type Message = (string | null);
549
+ interface ChatQueueAck {
550
+ session_id: SessionId;
551
+ revision: Revision;
552
+ paused?: Paused;
553
+ pause_reason?: PauseReason;
554
+ items?: Items;
555
+ status?: Status1;
556
+ message?: Message;
557
+ [k: string]: unknown;
558
+ }
559
+ interface ChatQueueItem {
560
+ id: Id;
561
+ content: Content;
562
+ position: Position;
563
+ version: Version;
564
+ status: Status;
565
+ created_at: CreatedAt;
566
+ updated_at: UpdatedAt;
567
+ target_run_id?: TargetRunId;
568
+ error?: Error;
569
+ [k: string]: unknown;
570
+ }
571
+ }
572
+ export type ChatQueueAck = ChatQueueAckSchema.ChatQueueAck;
389
573
  export interface ClientToServerEvents {
390
574
  "chat:send": (payload: ChatSendPayload, ack: (response: ChatSendAck) => void) => void;
391
575
  "chat:stop": (payload: ChatStopPayload, ack: (response: ChatStopAck) => void) => void;
392
- "chat:append": (payload: ChatAppendPayload) => void;
576
+ "chat:append": (payload: ChatAppendPayload, ack: (response: ChatQueueAck) => void) => void;
393
577
  "chat:compact": (payload: ChatCompactPayload, ack: (response: ChatCompactAck) => void) => void;
578
+ "chat:queue:list": (payload: ChatQueueListPayload, ack: (response: ChatQueueAck) => void) => void;
579
+ "chat:queue:update": (payload: ChatQueueUpdatePayload, ack: (response: ChatQueueAck) => void) => void;
580
+ "chat:queue:reorder": (payload: ChatQueueReorderPayload, ack: (response: ChatQueueAck) => void) => void;
581
+ "chat:queue:cancel": (payload: ChatQueueCancelPayload, ack: (response: ChatQueueAck) => void) => void;
582
+ "chat:queue:deliver": (payload: ChatQueueDeliverPayload, ack: (response: ChatQueueAck) => void) => void;
583
+ "chat:queue:resume": (payload: ChatQueueResumePayload, ack: (response: ChatQueueAck) => void) => void;
394
584
  "session:subscribe": (payload: SessionSubscribePayload) => void;
395
585
  "session:subscribe_batch": (payload: SessionSubscribeBatchPayload) => void;
396
586
  "session:unsubscribe": (payload: SessionUnsubscribePayload) => void;
@@ -404,12 +594,15 @@ export interface ClientToServerEvents {
404
594
  export interface ServerToClientEvents {
405
595
  "chat:start": (payload: ChatStartPayload) => void;
406
596
  "chat:end": (payload: ChatEndPayload) => void;
407
- "chat:append:ack": (payload: unknown) => void;
597
+ "chat:queue:updated": (payload: ChatQueueUpdatedPayload) => void;
598
+ "session:created": (payload: SessionCreatedPayload) => void;
408
599
  "session:updated": (payload: SessionUpdatedPayload) => void;
409
600
  "workspace:files_changed": (payload: WorkspaceFilesChangedPayload) => void;
601
+ "mcp-app:changed": (payload: MCPAppChangedPayload) => void;
410
602
  "system:error": (payload: SystemErrorPayload) => void;
411
603
  "system:notification": (payload: SystemNotificationPayload) => void;
412
604
  "turn:events": (payload: TurnEventsPayload) => void;
605
+ "turn:timing": (payload: TurnTimingPayload) => void;
413
606
  "task:updated": (payload: unknown) => void;
414
607
  "task:synced": (payload: unknown) => void;
415
608
  "artifact:created": (payload: unknown) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blade-hq/agent-client",
3
- "version": "2610.0.0-beta.9",
3
+ "version": "2610.0.0-beta.90",
4
4
  "description": "Blade Agent 框架无关客户端:会话实时状态机、REST 通道、弹窗登录、页面协作。浏览器与 Node.js 通用。",
5
5
  "repository": {
6
6
  "type": "git",