@blade-hq/agent-client 2610.0.1-alpha.1 → 2610.0.2

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 (44) hide show
  1. package/README.md +281 -11
  2. package/dist/auth.d.ts +0 -1
  3. package/dist/blade-client.d.ts +24 -1
  4. package/dist/index.d.ts +38 -7
  5. package/dist/index.js +2520 -283
  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 +238 -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 +8 -0
  21. package/dist/schemas/projection-utils.d.ts +3 -0
  22. package/dist/schemas/projection.d.ts +53 -2
  23. package/dist/schemas/session.d.ts +10 -1
  24. package/dist/session/agent-session.d.ts +160 -16
  25. package/dist/session/definition.d.ts +6 -1
  26. package/dist/session/errors.d.ts +11 -0
  27. package/dist/session/events.d.ts +16 -2
  28. package/dist/session/history-page.d.ts +9 -0
  29. package/dist/session/hub.d.ts +9 -1
  30. package/dist/session/queue.d.ts +104 -0
  31. package/dist/session/state.d.ts +19 -2
  32. package/dist/shared/auth-busy.d.ts +9 -0
  33. package/dist/shared/projection/builder.d.ts +17 -0
  34. package/dist/shared/projection/context.d.ts +3 -0
  35. package/dist/shared/projection/helpers.d.ts +4 -2
  36. package/dist/shared/projection/history.d.ts +1 -0
  37. package/dist/shared/projection/index.d.ts +2 -1
  38. package/dist/shared/projection/state.d.ts +7 -0
  39. package/dist/shared/tool-ui-card.d.ts +60 -0
  40. package/dist/shared/type-guards.d.ts +2 -0
  41. package/dist/socket.d.ts +2 -0
  42. package/dist/types/socket-events.d.ts +201 -2
  43. package/package.json +4 -2
  44. package/public-api.md +1071 -23
@@ -0,0 +1,104 @@
1
+ /**
2
+ * 会话消息队列的共享领域模型:类型、快照合并规则与中文文案。
3
+ *
4
+ * 这里是**单一定义处**:AgentSession 的状态机、agent-react 与内置 Web 的队列 UI
5
+ * 都只用这一份判定,避免"能不能编辑 / 旧快照要不要覆盖"各写一遍后各自演进。
6
+ * 服务端语义见 issue #2529 与 local://frontend-queue-contract.md。
7
+ */
8
+ /** 等待消息的服务端生命周期状态。 */
9
+ export type QueuedMessageStatus = "pending" | "delivering" | "claimed" | "consumed" | "cancelled";
10
+ /** 队列里的一条等待消息;权威快照只包含 pending(等待执行)与 delivering(等待接收)。 */
11
+ export interface QueuedMessage {
12
+ id: string;
13
+ content: string;
14
+ position: number;
15
+ version: number;
16
+ status: QueuedMessageStatus;
17
+ created_at: string;
18
+ updated_at: string;
19
+ /** 立即补充指向的当前运行 id;普通等待条目没有。 */
20
+ target_run_id?: string;
21
+ /** 领取或投递失败的原因。 */
22
+ error?: string;
23
+ }
24
+ /** 服务端权威队列快照。`revision` 单调递增,客户端据此丢弃过期快照。 */
25
+ export interface SessionQueueSnapshot {
26
+ session_id: string;
27
+ revision: number;
28
+ paused: boolean;
29
+ pause_reason: string | null;
30
+ items: QueuedMessage[];
31
+ }
32
+ /**
33
+ * 还没有拿到服务端快照时的占位。
34
+ *
35
+ * `session_id` 为空表示"身份未知":`shouldApplySnapshot` 会跳过会话身份校验、
36
+ * 只比较 revision,这样第一份快照(哪怕 revision 为 0 的暂停态)也能装进来。
37
+ */
38
+ export declare const EMPTY_SESSION_QUEUE: SessionQueueSnapshot;
39
+ /**
40
+ * 队列命令的 ack 线格式。
41
+ *
42
+ * `conflict` 表示乐观并发或状态校验失败,此时快照字段是服务端最新值,客户端必须
43
+ * 据此刷新本地并保留用户草稿;`error` 时快照字段可能缺失(如鉴权失败),此时只报错、
44
+ * 不改动本地队列。
45
+ */
46
+ export interface QueueAck {
47
+ /** `queued` 只出现在 `chat:send` 的运行中改道:消息已进等待队列,不是失败。 */
48
+ status: "ok" | "conflict" | "error" | "queued";
49
+ /**
50
+ * 只有 `queued` 会带:服务端判定这次改道时该会话是否有运行。
51
+ * 客户端据此对齐流式标记,不用自己的猜测。
52
+ */
53
+ running?: boolean;
54
+ message?: string | null;
55
+ session_id?: string;
56
+ revision?: number;
57
+ paused?: boolean;
58
+ pause_reason?: string | null;
59
+ items?: QueuedMessage[];
60
+ }
61
+ /** 解析后的队列操作结果;UI 只看这一个结构。 */
62
+ export interface QueueOperationResult {
63
+ ok: boolean;
64
+ conflict: boolean;
65
+ /** 服务端快照;缺失时为 null,调用方不得据此清空本地队列。 */
66
+ snapshot: SessionQueueSnapshot | null;
67
+ message: string | null;
68
+ /**
69
+ * 服务端给的机器可读失败原因(如 `owner_timeout` / `route_broken` / `owner_busy`),
70
+ * 供调用方决定要不要重试;`message` 是可以直接展示的业务文案。
71
+ */
72
+ code?: string;
73
+ }
74
+ /** 判定一份载荷是不是完整的权威队列快照(广播事件用)。 */
75
+ export declare function isSessionQueueSnapshot(value: unknown): value is SessionQueueSnapshot;
76
+ /**
77
+ * 是否用 `next` 覆盖 `current`。
78
+ *
79
+ * 规则只有两条:会话身份必须一致(还没拿到过快照时不校验),且 revision 必须严格
80
+ * 更新——相等或更旧一律不采纳,乱序到达的旧快照不会把新状态顶回去。
81
+ */
82
+ export declare function shouldApplySnapshot(current: SessionQueueSnapshot | undefined, next: SessionQueueSnapshot): boolean;
83
+ /**
84
+ * 解析 `emitWithAck` 的返回值。
85
+ *
86
+ * - `ok` / `queued` / `conflict` 且能解析成快照 → `snapshot` 有值;
87
+ * - `queued` → `ok=true`:`chat:send` 在运行中改道进了等待队列,调用方要撤掉乐观消息;
88
+ * - `conflict` → `ok=false, conflict=true`(快照可能仍缺失,调用方按 null 处理);
89
+ * - `error` 或结构不合法 → `ok=false, conflict=false`,`message` 为服务端文案或兜底。
90
+ */
91
+ export declare function parseQueueAck(response: unknown, fallbackSessionId: string): QueueOperationResult;
92
+ /** 等待中的条目才能改正文;已经交给运行或开始执行的条目不再可编辑。 */
93
+ export declare function canEditQueuedMessage(item: QueuedMessage): boolean;
94
+ /** 等待中的条目才能删除。 */
95
+ export declare function canCancelQueuedMessage(item: QueuedMessage): boolean;
96
+ /**
97
+ * 能否立即补充。条目本身必须是等待中的;"会话是否正在运行"由调用方判断——
98
+ * 服务端会在没有可接收补充的任务时返回冲突。
99
+ */
100
+ export declare function canDeliverQueuedMessage(item: QueuedMessage): boolean;
101
+ /** 面向前端展示的状态文案;已离开队列视图的状态没有文案。 */
102
+ export declare function queuedMessageStatusLabel(status: QueuedMessageStatus): string;
103
+ /** 暂停原因文案;未知原因原样透出,没有原因返回 null。 */
104
+ export declare function queuePauseReasonLabel(reason: string | null | undefined): string | null;
@@ -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 {
@@ -55,6 +63,10 @@ export interface ReplaySnapshot {
55
63
  export declare function toReplaySnapshot(raw: ReplayState | null | undefined): ReplaySnapshot | null;
56
64
  export declare function createInitialSessionState(sessionId: string): SessionState;
57
65
  export declare function extractModeFromBlocks(blocks: ContentBlock[]): "planning" | "executing" | null;
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[];
58
70
  /**
59
71
  * 用一份新的 turn 列表重建会话状态。
60
72
  * addErrorMessage 注入的 role==="error" 消息不在 turns 里,默认会被物化过程抹掉;
@@ -62,7 +74,12 @@ export declare function extractModeFromBlocks(blocks: ContentBlock[]): "planning
62
74
  * turn 推进(新消息 / rewind / 重连)时旧错误自动消失。
63
75
  */
64
76
  export declare function withTurns(state: SessionState, turns: TurnProjection[]): SessionState;
65
- 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;
66
83
  export declare function upsertTurn(state: SessionState, turn: TurnProjection): SessionState;
67
84
  export declare function applyTurnPatch(state: SessionState, patch: PatchEnvelope): SessionState;
68
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,11 +15,21 @@ export type ProjectionUpdate = {
13
15
  toolName?: string;
14
16
  workspacePath?: string;
15
17
  };
18
+ /** 是否包含会改变聊天运行生命周期的事件。纯观测/整理事件不启动新一轮。 */
19
+ export declare function hasChatRunEvent(events: RawEvent[]): boolean;
20
+ /**
21
+ * 缺失 chat:end 时的终态兜底。只有被投影接受到当前 assistant turn 的 followup
22
+ * 才能结束流式态;陈旧 followup 或其后已有新轮事件时均返回 false。
23
+ */
24
+ export declare function acceptedPostChatFollowupCompletesLatestRun(events: RawEvent[], updates: ProjectionUpdate[]): boolean;
16
25
  export declare class ClientProjectionBuilder {
17
26
  private activeTurns;
18
27
  private lastTurnIds;
19
28
  private latestTurns;
29
+ private turnsById;
20
30
  private loopDescriptions;
31
+ /** loop_name → 正在运行的子智能体起点,agent:end 结算并挂到父工具调用上。 */
32
+ private activeSubagentRuns;
21
33
  private pendingChildPauses;
22
34
  private pendingMemoryRefs;
23
35
  private activeCompactions;
@@ -32,6 +44,7 @@ export declare class ClientProjectionBuilder {
32
44
  seedSequence(maxSeq: number): void;
33
45
  _seedTurns(turns: TurnProjection[]): void;
34
46
  private onMemoryInject;
47
+ private onContextEntry;
35
48
  private onLoopTurn;
36
49
  private onModeChange;
37
50
  private onPlanStatusUpdate;
@@ -44,7 +57,10 @@ export declare class ClientProjectionBuilder {
44
57
  private onPostChatFollowup;
45
58
  private onDelta;
46
59
  private onToolCallCreated;
60
+ private onToolCallArgumentsDelta;
47
61
  private onResponseDone;
62
+ private applyFirstTokenDelivery;
63
+ private applyStreamTiming;
48
64
  private onToolResultDone;
49
65
  private onToolResultDelta;
50
66
  private onToolUi;
@@ -53,6 +69,7 @@ export declare class ClientProjectionBuilder {
53
69
  private onChildPause;
54
70
  private onChatEnd;
55
71
  private onAgentEnd;
72
+ private settleSubagentRun;
56
73
  private dropIncompleteToolCalls;
57
74
  private onCompaction;
58
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;
@@ -42,6 +42,8 @@ export declare function normalizePostChatFollowup(data: Record<string, unknown>,
42
42
  recaption: string;
43
43
  suggestions: string[];
44
44
  final_artifacts: FinalArtifact[];
45
+ feedback_eligible: boolean;
46
+ feedback_scope: "latest_result";
45
47
  } | null;
46
48
  export declare function normalizeChildPause(pausePayload: Record<string, unknown>): {
47
49
  pauseToolData: Record<string, unknown>;
@@ -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 { 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,6 +95,72 @@ 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;
@@ -154,8 +228,10 @@ export declare namespace AgentBoardProjectUnsubscribePayloadSchema {
154
228
  export type AgentBoardProjectUnsubscribePayload = AgentBoardProjectUnsubscribePayloadSchema.AgentBoardProjectUnsubscribePayload;
155
229
  export declare namespace ChatStartPayloadSchema {
156
230
  type SessionId = (string | null);
231
+ type ChatRunId = (string | null);
157
232
  interface ChatStartPayload {
158
233
  session_id?: SessionId;
234
+ chat_run_id?: ChatRunId;
159
235
  [k: string]: unknown;
160
236
  }
161
237
  }
@@ -177,7 +253,54 @@ export declare namespace ChatEndPayloadSchema {
177
253
  }
178
254
  }
179
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;
180
301
  export declare namespace SessionUpdatedPayloadSchema {
302
+ type WorkspacePath = (string | null);
303
+ type ChatGroupId = (string | null);
181
304
  type SessionId = string;
182
305
  type Model = (string | null);
183
306
  type ReplayState = ({
@@ -187,6 +310,8 @@ export declare namespace SessionUpdatedPayloadSchema {
187
310
  type ProjectId = (number | null);
188
311
  type ProjectName = (string | null);
189
312
  interface SessionUpdatedPayload {
313
+ workspace_path?: WorkspacePath;
314
+ chat_group_id?: ChatGroupId;
190
315
  session_id: SessionId;
191
316
  model?: Model;
192
317
  replay_state?: ReplayState;
@@ -207,6 +332,16 @@ export declare namespace WorkspaceFilesChangedPayloadSchema {
207
332
  }
208
333
  }
209
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;
210
345
  export declare namespace SystemErrorPayloadSchema {
211
346
  type Message = string;
212
347
  type SessionId = (string | null);
@@ -264,6 +399,20 @@ export declare namespace TurnEventsPayloadSchema {
264
399
  }
265
400
  }
266
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;
267
416
  export declare namespace AsrReadyPayloadSchema {
268
417
  type RequestId = string;
269
418
  type Provider = string;
@@ -380,11 +529,58 @@ export declare namespace ChatCompactAckSchema {
380
529
  }
381
530
  }
382
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;
383
573
  export interface ClientToServerEvents {
384
574
  "chat:send": (payload: ChatSendPayload, ack: (response: ChatSendAck) => void) => void;
385
575
  "chat:stop": (payload: ChatStopPayload, ack: (response: ChatStopAck) => void) => void;
386
- "chat:append": (payload: ChatAppendPayload) => void;
576
+ "chat:append": (payload: ChatAppendPayload, ack: (response: ChatQueueAck) => void) => void;
387
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;
388
584
  "session:subscribe": (payload: SessionSubscribePayload) => void;
389
585
  "session:subscribe_batch": (payload: SessionSubscribeBatchPayload) => void;
390
586
  "session:unsubscribe": (payload: SessionUnsubscribePayload) => void;
@@ -398,12 +594,15 @@ export interface ClientToServerEvents {
398
594
  export interface ServerToClientEvents {
399
595
  "chat:start": (payload: ChatStartPayload) => void;
400
596
  "chat:end": (payload: ChatEndPayload) => void;
401
- "chat:append:ack": (payload: unknown) => void;
597
+ "chat:queue:updated": (payload: ChatQueueUpdatedPayload) => void;
598
+ "session:created": (payload: SessionCreatedPayload) => void;
402
599
  "session:updated": (payload: SessionUpdatedPayload) => void;
403
600
  "workspace:files_changed": (payload: WorkspaceFilesChangedPayload) => void;
601
+ "mcp-app:changed": (payload: MCPAppChangedPayload) => void;
404
602
  "system:error": (payload: SystemErrorPayload) => void;
405
603
  "system:notification": (payload: SystemNotificationPayload) => void;
406
604
  "turn:events": (payload: TurnEventsPayload) => void;
605
+ "turn:timing": (payload: TurnTimingPayload) => void;
407
606
  "task:updated": (payload: unknown) => void;
408
607
  "task:synced": (payload: unknown) => void;
409
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.1-alpha.1",
3
+ "version": "2610.0.2",
4
4
  "description": "Blade Agent 框架无关客户端:会话实时状态机、REST 通道、弹窗登录、页面协作。浏览器与 Node.js 通用。",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,9 @@
18
18
  "files": [
19
19
  "dist",
20
20
  "README.md",
21
- "public-api.md"
21
+ "public-api.md",
22
+ "LICENSE",
23
+ "THIRD_PARTY_NOTICES.md"
22
24
  ],
23
25
  "sideEffects": [
24
26
  "**/*.css"