@blade-hq/agent-client 2610.0.0-beta.30 → 2610.0.0-beta.32
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/README.md +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +131 -33
- package/dist/index.js.map +1 -1
- package/dist/schemas/context.d.ts +15 -0
- package/dist/schemas/message-utils.d.ts +3 -1
- package/dist/session/agent-session.d.ts +7 -1
- package/dist/session/events.d.ts +2 -0
- package/dist/session/hub.d.ts +8 -1
- package/package.json +1 -1
- package/public-api.md +30 -4
|
@@ -29,6 +29,21 @@ export interface ContextDisplayState {
|
|
|
29
29
|
detail: string;
|
|
30
30
|
isRemoved: boolean;
|
|
31
31
|
}
|
|
32
|
+
export interface ContextGroupDisplayState {
|
|
33
|
+
title: string;
|
|
34
|
+
summary: string;
|
|
35
|
+
count: number;
|
|
36
|
+
}
|
|
32
37
|
export declare function contextProjectionData(fields: ContextProjectionFields): ContextProjectionData | null;
|
|
33
38
|
/** The single status-to-display mapping used by both React chat surfaces. */
|
|
34
39
|
export declare function getContextDisplayState(context: ContextProjectionData): ContextDisplayState;
|
|
40
|
+
/**
|
|
41
|
+
* 把一段渲染序列里连续的 Context 归成组。
|
|
42
|
+
*
|
|
43
|
+
* 入参是序列里每一项的 context kind,非 Context 项传 null;返回每一段连续
|
|
44
|
+
* Context 的下标数组。纯下标运算,不认识任何 UI 类型,所以调试日志、Lite 视图
|
|
45
|
+
* 和 SDK 卡片可以共用同一份分组判定,各自只管排版。
|
|
46
|
+
*/
|
|
47
|
+
export declare function groupAdjacentContextRuns(kinds: readonly (string | null)[]): readonly (readonly number[])[];
|
|
48
|
+
/** 折叠行的文案。展开后才逐条显示各自的标题与状态。 */
|
|
49
|
+
export declare function getContextGroupDisplayState(contexts: readonly ContextProjectionData[]): ContextGroupDisplayState;
|
|
@@ -5,7 +5,9 @@ export declare function normalizeMessageContent(content: unknown): MessageConten
|
|
|
5
5
|
export declare function getTextContent(content: MessageContent): string;
|
|
6
6
|
export declare function isSystemReminderText(text: string): boolean;
|
|
7
7
|
export declare function isLegacyForkContextText(text: string): boolean;
|
|
8
|
-
export declare function isHiddenInternalMessage(message: Pick<ChatMessage, "role" | "content"
|
|
8
|
+
export declare function isHiddenInternalMessage(message: Pick<ChatMessage, "role" | "content">, options?: {
|
|
9
|
+
includeLegacyForkContext?: boolean;
|
|
10
|
+
}): boolean;
|
|
9
11
|
export declare function buildMessageContent(text: string, attachments: Array<{
|
|
10
12
|
kind: "file";
|
|
11
13
|
name: string;
|
|
@@ -76,11 +76,13 @@ export declare class AgentSession {
|
|
|
76
76
|
private patchFlushCancel;
|
|
77
77
|
private joined;
|
|
78
78
|
private joinPending;
|
|
79
|
+
private subscriptionQueue;
|
|
79
80
|
private replayQueue;
|
|
80
81
|
private pendingReplayMessage;
|
|
81
82
|
private pendingReplayMode;
|
|
82
83
|
private pendingReplayKbIds;
|
|
83
84
|
private recentChatEndAt;
|
|
85
|
+
private subscriptionReplaySource;
|
|
84
86
|
private disposed;
|
|
85
87
|
private getAppContext;
|
|
86
88
|
private sendPending;
|
|
@@ -152,6 +154,8 @@ export declare class AgentSession {
|
|
|
152
154
|
_rejoinAfterReconnect(): Promise<void>;
|
|
153
155
|
/** @internal 首次连接:加载历史 + 加入房间。 */
|
|
154
156
|
_bootstrap(): Promise<void>;
|
|
157
|
+
/** 订阅生命周期串行执行;一次失败只由自己的调用方观察,不截断后续重连。 */
|
|
158
|
+
private enqueueSubscription;
|
|
155
159
|
/** 改回放是 owner 专属(服务端 PATCH 走 _get_owned_session)。 */
|
|
156
160
|
private get canControlReplay();
|
|
157
161
|
/** 拉一次会话详情,填回放状态和只读身份;失败按非回放会话处理,不挡启动。 */
|
|
@@ -169,7 +173,7 @@ export declare class AgentSession {
|
|
|
169
173
|
/** @internal */
|
|
170
174
|
_handleTurnEnd(turn: TurnProjection): void;
|
|
171
175
|
/** @internal 历史回放通道(event_format: raw)。 */
|
|
172
|
-
_handleTurnEvents(events: RawEvent[]): void;
|
|
176
|
+
_handleTurnEvents(events: RawEvent[], replayed?: boolean): void;
|
|
173
177
|
/** @internal */
|
|
174
178
|
_handleChatStart(): void;
|
|
175
179
|
/** @internal */
|
|
@@ -215,6 +219,8 @@ export declare class AgentSession {
|
|
|
215
219
|
private dispatchCommand;
|
|
216
220
|
private notifySandboxOom;
|
|
217
221
|
private syncTurnsFromHistory;
|
|
222
|
+
/** 首次订阅前的 REST 历史建立语义事件基线,随后同一工具的订阅回放不再投递。 */
|
|
223
|
+
private seedToolCallDeliveryBaseline;
|
|
218
224
|
/**
|
|
219
225
|
* 把历史里的指令补投给宿主页面。
|
|
220
226
|
*
|
package/dist/session/events.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface AgentSessionEvents {
|
|
|
23
23
|
toolResult: {
|
|
24
24
|
toolCall: ToolCallInfo;
|
|
25
25
|
turn: TurnProjection;
|
|
26
|
+
/** 实时到达,或首次连接/断线重连时由服务端回放。 */
|
|
27
|
+
source: "live" | "bootstrap_replay" | "reconnect_replay";
|
|
26
28
|
};
|
|
27
29
|
/** 一轮回复结束。status: completed / paused / interrupted / failed。 */
|
|
28
30
|
chatEnd: {
|
package/dist/session/hub.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { BladeClient } from "../blade-client";
|
|
2
2
|
import { AgentSession } from "./agent-session";
|
|
3
3
|
import type { ConnectionStatus } from "./state";
|
|
4
|
+
export interface SessionConnectOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 在会话进入事件路由后、历史加载与房间订阅开始前同步执行。
|
|
7
|
+
* 适合安装不能漏掉 bootstrap 回放事件的监听器。
|
|
8
|
+
*/
|
|
9
|
+
setup?: (session: AgentSession) => void;
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
12
|
* 每个 BladeClient 一个:管理一条 Socket.IO 连接,按 session_id 把事件
|
|
6
13
|
* 路由给各 AgentSession 实例。多会话共享连接、状态互不干扰。
|
|
@@ -27,7 +34,7 @@ export declare class SessionHub {
|
|
|
27
34
|
* 只有最后一份归还才退订房间——否则 StrictMode 双跑、路由抖动这类"连两次
|
|
28
35
|
* 只释放一次"的场景会把仍在用的会话退订掉,之后所有 turn/chat 事件静默丢失。
|
|
29
36
|
*/
|
|
30
|
-
connect(sessionId: string): Promise<AgentSession>;
|
|
37
|
+
connect(sessionId: string, options?: SessionConnectOptions): Promise<AgentSession>;
|
|
31
38
|
/** 已有实例则返回,不触发网络请求。 */
|
|
32
39
|
peek(sessionId: string): AgentSession | undefined;
|
|
33
40
|
/** 手动重连(例如登录态变化后)。 */
|
package/package.json
CHANGED
package/public-api.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> 本文件由 `scripts/public-api-report.mjs` 生成,请勿手改。
|
|
4
4
|
> 公共面变更时重新生成本报告,并同步更新 README 对应章节——CI 会校验两者。
|
|
5
5
|
|
|
6
|
-
共
|
|
6
|
+
共 162 个公开声明。
|
|
7
7
|
|
|
8
8
|
## `acceptedPostChatFollowupCompletesLatestRun` (function)
|
|
9
9
|
|
|
@@ -89,7 +89,7 @@ sessionUpdated: { intent?: string; status?: SessionStatus; model?: string | null
|
|
|
89
89
|
taskListUpdated: { tasks: unknown[]; }
|
|
90
90
|
toolCall: { toolCall: ToolCallInfo; turn: TurnProjection; }
|
|
91
91
|
toolPreview: { toolCallId: string; type: "resource-html" | "resource-uri"; content: string; title: string; }
|
|
92
|
-
toolResult: { toolCall: ToolCallInfo; turn: TurnProjection; }
|
|
92
|
+
toolResult: { toolCall: ToolCallInfo; turn: TurnProjection; source: "live" | "bootstrap_replay" | "reconnect_replay"; }
|
|
93
93
|
workspaceChanged: { filePath?: string; }
|
|
94
94
|
```
|
|
95
95
|
|
|
@@ -394,6 +394,14 @@ summary: string
|
|
|
394
394
|
title: string
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
+
## `ContextGroupDisplayState` (interface)
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
count: number
|
|
401
|
+
summary: string
|
|
402
|
+
title: string
|
|
403
|
+
```
|
|
404
|
+
|
|
397
405
|
## `contextProjectionData` (function)
|
|
398
406
|
|
|
399
407
|
```ts
|
|
@@ -567,6 +575,12 @@ target: string
|
|
|
567
575
|
getContextDisplayState: (context: ContextProjectionData) => ContextDisplayState
|
|
568
576
|
```
|
|
569
577
|
|
|
578
|
+
## `getContextGroupDisplayState` (function)
|
|
579
|
+
|
|
580
|
+
```ts
|
|
581
|
+
getContextGroupDisplayState: (contexts: readonly ContextProjectionData[]) => ContextGroupDisplayState
|
|
582
|
+
```
|
|
583
|
+
|
|
570
584
|
## `getFileParts` (function)
|
|
571
585
|
|
|
572
586
|
```ts
|
|
@@ -621,6 +635,12 @@ export type GlobalSearchResultItem =
|
|
|
621
635
|
| GlobalSearchFileResult
|
|
622
636
|
```
|
|
623
637
|
|
|
638
|
+
## `groupAdjacentContextRuns` (function)
|
|
639
|
+
|
|
640
|
+
```ts
|
|
641
|
+
groupAdjacentContextRuns: (kinds: readonly (string | null)[]) => readonly (readonly number[])[]
|
|
642
|
+
```
|
|
643
|
+
|
|
624
644
|
## `groupMessagesByLoop` (function)
|
|
625
645
|
|
|
626
646
|
```ts
|
|
@@ -672,7 +692,7 @@ isCommandEnvelope: (value: unknown) => value is CommandEnvelope
|
|
|
672
692
|
## `isHiddenInternalMessage` (function)
|
|
673
693
|
|
|
674
694
|
```ts
|
|
675
|
-
isHiddenInternalMessage: (message: Pick<ChatMessage, "role" | "content"
|
|
695
|
+
isHiddenInternalMessage: (message: Pick<ChatMessage, "role" | "content">, options?: { includeLegacyForkContext?: boolean; }) => boolean
|
|
676
696
|
```
|
|
677
697
|
|
|
678
698
|
## `isInboundEnvelope` (function)
|
|
@@ -1078,6 +1098,12 @@ memoryEnabled: boolean | undefined
|
|
|
1078
1098
|
model: string | undefined
|
|
1079
1099
|
```
|
|
1080
1100
|
|
|
1101
|
+
## `SessionConnectOptions` (interface)
|
|
1102
|
+
|
|
1103
|
+
```ts
|
|
1104
|
+
setup: ((session: AgentSession) => void) | undefined
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1081
1107
|
## `SessionContextStats` (interface)
|
|
1082
1108
|
|
|
1083
1109
|
```ts
|
|
@@ -1148,7 +1174,7 @@ tools_tokens: number | null | undefined
|
|
|
1148
1174
|
## `SessionHub` (class)
|
|
1149
1175
|
|
|
1150
1176
|
```ts
|
|
1151
|
-
connect: (sessionId: string) => Promise<AgentSession>
|
|
1177
|
+
connect: (sessionId: string, options?: SessionConnectOptions) => Promise<AgentSession>
|
|
1152
1178
|
disconnect: () => void
|
|
1153
1179
|
disposeAll: () => void
|
|
1154
1180
|
getConnection: () => ConnectionStatus
|