@blade-hq/agent-client 2608.0.6 → 2608.0.7-beta.0
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 +137 -5
- package/dist/blade-client.d.ts +2 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +327 -72
- package/dist/index.js.map +1 -1
- package/dist/resources/auth.d.ts +26 -0
- package/dist/resources/models.d.ts +22 -0
- package/dist/resources/sessions.d.ts +45 -3
- package/dist/schemas/message-utils.d.ts +11 -1
- package/dist/schemas/message.d.ts +2 -0
- package/dist/schemas/projection-utils.d.ts +3 -0
- package/dist/schemas/projection.d.ts +16 -0
- package/dist/schemas/session.d.ts +18 -1
- package/dist/session/agent-session.d.ts +23 -1
- package/dist/session/state.d.ts +15 -1
- package/dist/shared/projection/builder.d.ts +5 -0
- package/dist/shared/projection/helpers.d.ts +10 -0
- package/dist/shared/projection/index.d.ts +1 -1
- package/dist/types/socket-events.d.ts +6 -0
- package/package.json +1 -1
- package/public-api.md +187 -4
package/dist/resources/auth.d.ts
CHANGED
|
@@ -16,6 +16,24 @@ export interface ProvidersResponse {
|
|
|
16
16
|
}>;
|
|
17
17
|
password_enabled: boolean;
|
|
18
18
|
}
|
|
19
|
+
export interface ExchangeCodeParams {
|
|
20
|
+
/** 授权回调页 postMessage 回来的一次性 code。 */
|
|
21
|
+
code: string;
|
|
22
|
+
/** 发起授权时用的 state,必须原样传回。 */
|
|
23
|
+
state: string;
|
|
24
|
+
/** 发起授权的页面 origin,要和 authorize 时传的 `client_origin` 完全一致。 */
|
|
25
|
+
clientOrigin: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ExchangeCodeResult {
|
|
28
|
+
access_token: string;
|
|
29
|
+
token_type: string;
|
|
30
|
+
user: {
|
|
31
|
+
id: string;
|
|
32
|
+
username: string;
|
|
33
|
+
display_name: string;
|
|
34
|
+
avatar_url: string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
19
37
|
export declare class AuthResource {
|
|
20
38
|
private client;
|
|
21
39
|
constructor(client: BladeClient);
|
|
@@ -24,6 +42,14 @@ export declare class AuthResource {
|
|
|
24
42
|
* 自动取得 PAT 并热挂载到当前 client。等价于 client.login()。
|
|
25
43
|
*/
|
|
26
44
|
login(options?: LoginOptions): Promise<LoginResult>;
|
|
45
|
+
/**
|
|
46
|
+
* 用一次性 code 换 PAT。给**服务端**用:浏览器把 code 交给你自己的后端,
|
|
47
|
+
* 后端换到的 PAT 不进浏览器。浏览器里直接用 `login()` 就够了。
|
|
48
|
+
*
|
|
49
|
+
* 服务端调用时会自己补上 `Origin` 头(浏览器会自动带,服务端不会,缺了
|
|
50
|
+
* 后端报 `missing_request_origin`)。
|
|
51
|
+
*/
|
|
52
|
+
exchangeCode(params: ExchangeCodeParams): Promise<ExchangeCodeResult>;
|
|
27
53
|
/** 清除 login() 存储的令牌。 */
|
|
28
54
|
logoutToken(): void;
|
|
29
55
|
getProviders(): Promise<ProvidersResponse>;
|
|
@@ -2,10 +2,32 @@ import type { BladeClient } from "../blade-client";
|
|
|
2
2
|
export interface ModelOption {
|
|
3
3
|
id: string;
|
|
4
4
|
label: string;
|
|
5
|
+
/**
|
|
6
|
+
* 把这个模型发给 `baseUrl` 时该用的名字。`id` 是平台内部标识,接了多个模型服务时
|
|
7
|
+
* 形如 `provider-xxx::name`,直接发过去会被拒。不在 `baseUrl` 那个服务上的模型
|
|
8
|
+
* 这里是空串——自己做模型选择器时据此过滤。
|
|
9
|
+
*/
|
|
10
|
+
serviceModelId?: string;
|
|
5
11
|
}
|
|
6
12
|
export interface ModelCatalog {
|
|
7
13
|
default: string;
|
|
8
14
|
models: ModelOption[];
|
|
15
|
+
/**
|
|
16
|
+
* 平台默认模型服务的 OpenAI 兼容地址(Server ≥ 提供 `baseUrl` 的版本才有,否则为空)。
|
|
17
|
+
* 自建应用可以带用户的 PAT 直接调它,不必让用户自己填地址——网关端口各部署不同,
|
|
18
|
+
* 推算不出来。
|
|
19
|
+
*
|
|
20
|
+
* 这是**服务端视角**的地址:平台可能配的是 `http://127.0.0.1:30000/v1`,从自己后端
|
|
21
|
+
* 转发没问题,直接丢给浏览器就指向用户自己的机器了。默认形态是后端透传(密钥也不该
|
|
22
|
+
* 进浏览器),浏览器直连只适合这个地址对浏览器同样可达的场景。
|
|
23
|
+
*/
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 直接调 `baseUrl` 时该用的默认模型名。**不要用 `default`**——那是平台内部标识,
|
|
27
|
+
* 平台默认模型来自额外接的模型服务时它带 `provider-xxx::` 前缀,发过去只会得到
|
|
28
|
+
* 「模型不存在」。没有可直调的模型时为空串。
|
|
29
|
+
*/
|
|
30
|
+
defaultServiceModel?: string;
|
|
9
31
|
}
|
|
10
32
|
/** Server 可供当前用户选择的模型目录。 */
|
|
11
33
|
export declare class ModelsResource {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BackgroundTask, BackgroundTaskStopResult } from "../schemas/background";
|
|
2
2
|
import type { TurnProjection } from "../schemas/projection";
|
|
3
|
-
import type { PublishedSolutionRef, SessionDetail, SessionInfo, TemplateId } from "../schemas/session";
|
|
3
|
+
import type { PublishedSolutionRef, ReplayPreview, ReplaySpeed, SessionDetail, SessionInfo, TemplateId } from "../schemas/session";
|
|
4
4
|
import type { Task } from "../schemas/task";
|
|
5
5
|
import type { BladeClient, UploadProgress } from "../blade-client";
|
|
6
6
|
import type { AgentSession } from "../session/agent-session";
|
|
@@ -90,6 +90,26 @@ export interface PaginatedSessionsResult {
|
|
|
90
90
|
offset: number;
|
|
91
91
|
content_match_truncated?: boolean;
|
|
92
92
|
}
|
|
93
|
+
export interface GlobalSearchConversationResult {
|
|
94
|
+
type: "conversation";
|
|
95
|
+
session: SessionInfo;
|
|
96
|
+
snippet: string;
|
|
97
|
+
matched: "title" | "content";
|
|
98
|
+
}
|
|
99
|
+
export interface GlobalSearchFileResult {
|
|
100
|
+
type: "file";
|
|
101
|
+
session: SessionInfo;
|
|
102
|
+
path: string;
|
|
103
|
+
name: string;
|
|
104
|
+
snippet: string;
|
|
105
|
+
matched: "name" | "path";
|
|
106
|
+
}
|
|
107
|
+
export type GlobalSearchResultItem = GlobalSearchConversationResult | GlobalSearchFileResult;
|
|
108
|
+
export interface GlobalSearchResult {
|
|
109
|
+
items: GlobalSearchResultItem[];
|
|
110
|
+
truncated: boolean;
|
|
111
|
+
indexing: boolean;
|
|
112
|
+
}
|
|
93
113
|
export interface SkillDevSession {
|
|
94
114
|
session: SessionInfo;
|
|
95
115
|
skill_id: string;
|
|
@@ -106,6 +126,17 @@ export interface SessionContextStats {
|
|
|
106
126
|
context_window: number;
|
|
107
127
|
compaction_ratio: number;
|
|
108
128
|
}
|
|
129
|
+
export type ResultFeedbackReason = "not_solved" | "inaccurate" | "incomplete" | "needs_major_changes" | "too_slow" | "other";
|
|
130
|
+
export interface ResultFeedback {
|
|
131
|
+
session_id: string;
|
|
132
|
+
assistant_entry_id: string;
|
|
133
|
+
surface: "chat" | "software_factory" | "unknown";
|
|
134
|
+
project_id: string | null;
|
|
135
|
+
helpful: boolean;
|
|
136
|
+
reason: ResultFeedbackReason | null;
|
|
137
|
+
created_at: string;
|
|
138
|
+
updated_at: string;
|
|
139
|
+
}
|
|
109
140
|
export interface FileEntry {
|
|
110
141
|
name: string;
|
|
111
142
|
path: string;
|
|
@@ -185,6 +216,10 @@ export declare class SessionsResource {
|
|
|
185
216
|
q?: string;
|
|
186
217
|
}): Promise<PaginatedSessionsResult>;
|
|
187
218
|
listSessionsWithSkillData(): Promise<SkillDevSession[]>;
|
|
219
|
+
searchOwnedContent(params: {
|
|
220
|
+
q: string;
|
|
221
|
+
limit?: number;
|
|
222
|
+
}): Promise<GlobalSearchResult>;
|
|
188
223
|
createSession(intent?: string, template_id?: TemplateId, primary_skill_id?: string | null): Promise<{
|
|
189
224
|
session_id: string;
|
|
190
225
|
}>;
|
|
@@ -203,15 +238,17 @@ export declare class SessionsResource {
|
|
|
203
238
|
}): Promise<SessionDetail>;
|
|
204
239
|
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
205
240
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
206
|
-
startReplaySession(sourceSessionId: string, speed?:
|
|
241
|
+
startReplaySession(sourceSessionId: string, speed?: ReplaySpeed): Promise<{
|
|
207
242
|
session_id: string;
|
|
208
243
|
}>;
|
|
209
244
|
updateReplaySession(sessionId: string, payload: {
|
|
210
|
-
speed?:
|
|
245
|
+
speed?: ReplaySpeed;
|
|
211
246
|
status?: "autonomous";
|
|
212
247
|
}): Promise<{
|
|
213
248
|
replay_state: SessionInfo["replay_state"];
|
|
214
249
|
}>;
|
|
250
|
+
/** 查询会话能否作为回放来源;不支持时 reason 可直接展示,用来提前禁用入口。 */
|
|
251
|
+
getReplayPreview(sessionId: string): Promise<ReplayPreview>;
|
|
215
252
|
updateSharing(sessionId: string, shared: boolean): Promise<{
|
|
216
253
|
shared: boolean;
|
|
217
254
|
}>;
|
|
@@ -225,6 +262,11 @@ export declare class SessionsResource {
|
|
|
225
262
|
getSharedSession(token: string): Promise<TurnProjection[]>;
|
|
226
263
|
getSessionTasks(sessionId: string): Promise<Task[]>;
|
|
227
264
|
getSessionTurns(sessionId: string): Promise<TurnProjection[]>;
|
|
265
|
+
listResultFeedback(sessionId: string): Promise<ResultFeedback[]>;
|
|
266
|
+
putResultFeedback(sessionId: string, assistantEntryId: string, feedback: {
|
|
267
|
+
helpful: boolean;
|
|
268
|
+
reason?: ResultFeedbackReason | null;
|
|
269
|
+
}): Promise<ResultFeedback>;
|
|
228
270
|
getSessionContextStats(sessionId: string, init?: RequestInit): Promise<SessionContextStats>;
|
|
229
271
|
getSessionHistory(sessionId: string, init?: RequestInit): Promise<SessionHistory>;
|
|
230
272
|
tokenizePrompt(prompt: string, model?: string): Promise<TokenizeResult>;
|
|
@@ -12,11 +12,21 @@ export declare function buildMessageContent(text: string, attachments: Array<{
|
|
|
12
12
|
mimeType?: string;
|
|
13
13
|
}>): MessageContent;
|
|
14
14
|
export declare function contentPreview(content: MessageContent, maxLen?: number): string;
|
|
15
|
+
/** `/` 选中的技能当前处于什么状态,决定智能体要不要先装、先加载。 */
|
|
16
|
+
export interface SkillMentionAvailability {
|
|
17
|
+
/** 本地已有(内置 / 技能目录 / 会话已加载),直接可用。 */
|
|
18
|
+
local?: boolean;
|
|
19
|
+
/** Blade Hub 上该账号是否已安装。本地技能恒为 true。 */
|
|
20
|
+
installed?: boolean;
|
|
21
|
+
}
|
|
15
22
|
/**
|
|
16
23
|
* Transform a skill mention into a natural language skill invocation.
|
|
17
24
|
* Strips the `<skill>name</skill>` tag from the raw input and prepends the instruction.
|
|
25
|
+
*
|
|
26
|
+
* Hub 技能装没装、加载没加载,用户不需要知道,但智能体需要——所以把状态翻译
|
|
27
|
+
* 成它能直接照做的 CLI 步骤。不传 availability 时按本地技能处理,与旧行为一致。
|
|
18
28
|
*/
|
|
19
|
-
export declare function transformSlashCommand(skillName: string, rawInput: string): string;
|
|
29
|
+
export declare function transformSlashCommand(skillName: string, rawInput: string, { local, installed }?: SkillMentionAvailability): string;
|
|
20
30
|
export interface ParsedTextAttachment {
|
|
21
31
|
name: string;
|
|
22
32
|
uploadedPath?: string;
|
|
@@ -70,6 +70,8 @@ export interface ChatMessage {
|
|
|
70
70
|
duration_ms?: number;
|
|
71
71
|
timestamp?: string;
|
|
72
72
|
entry_id?: string;
|
|
73
|
+
/** Stable React key retained when an optimistic user message is confirmed. */
|
|
74
|
+
render_id?: string;
|
|
73
75
|
parent_id?: string | null;
|
|
74
76
|
loop_name?: string;
|
|
75
77
|
/** Entry kind from backend -- present for non-message entries like mode changes. */
|
|
@@ -29,6 +29,19 @@ export interface MemoryRef {
|
|
|
29
29
|
content_preview: string;
|
|
30
30
|
skill_name?: string | null;
|
|
31
31
|
}
|
|
32
|
+
export interface FinalArtifact {
|
|
33
|
+
kind: "file" | "link";
|
|
34
|
+
target: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PostChatFollowup {
|
|
38
|
+
assistant_entry_id: string;
|
|
39
|
+
recaption?: string;
|
|
40
|
+
suggestions: string[];
|
|
41
|
+
final_artifacts?: FinalArtifact[];
|
|
42
|
+
feedback_eligible: boolean;
|
|
43
|
+
feedback_scope: "latest_result";
|
|
44
|
+
}
|
|
32
45
|
export interface TurnProjection {
|
|
33
46
|
id: string;
|
|
34
47
|
sequence: number;
|
|
@@ -46,6 +59,8 @@ export interface TurnProjection {
|
|
|
46
59
|
context_window?: number;
|
|
47
60
|
memory_refs?: MemoryRef[] | null;
|
|
48
61
|
parent_fork_tool_call_id?: string | null;
|
|
62
|
+
/** Client-only stable identity for reconciling an optimistic user turn. */
|
|
63
|
+
client_render_id?: string | null;
|
|
49
64
|
compaction_id?: string | null;
|
|
50
65
|
summary_preview?: string | null;
|
|
51
66
|
summary_full?: string | null;
|
|
@@ -58,6 +73,7 @@ export interface TurnProjection {
|
|
|
58
73
|
trigger?: "auto" | "manual" | "forced_retry" | null;
|
|
59
74
|
failure_reason?: string | null;
|
|
60
75
|
fallback_applied?: boolean | null;
|
|
76
|
+
post_chat_followup?: PostChatFollowup | null;
|
|
61
77
|
}
|
|
62
78
|
export interface ArchivedFileInfo {
|
|
63
79
|
tool_name?: string | null;
|
|
@@ -12,14 +12,31 @@ export type PublishedSolutionRef = {
|
|
|
12
12
|
org: string;
|
|
13
13
|
name: string;
|
|
14
14
|
};
|
|
15
|
+
/** 回放时录制内容的播放倍速。 */
|
|
16
|
+
export type ReplaySpeed = 1 | 2 | 5;
|
|
17
|
+
/**
|
|
18
|
+
* 新建回放会话时的默认倍速。
|
|
19
|
+
*
|
|
20
|
+
* 所有创建入口都用它——曾经侧栏走 API 默认 5x、设置菜单初始化成 1x,
|
|
21
|
+
* 同一个源对话从不同入口开出来速度不一样。
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_REPLAY_SPEED: ReplaySpeed;
|
|
15
24
|
export interface ReplayState {
|
|
16
25
|
source_session_id?: string;
|
|
17
26
|
status?: "replay" | "autonomous";
|
|
18
|
-
speed?:
|
|
27
|
+
speed?: ReplaySpeed;
|
|
19
28
|
next_source_entry_id?: string | null;
|
|
20
29
|
ended_at?: string | null;
|
|
21
30
|
autonomous_reason?: string | null;
|
|
22
31
|
}
|
|
32
|
+
/** 某个会话能否作为回放来源。 */
|
|
33
|
+
export interface ReplayPreview {
|
|
34
|
+
session_id: string;
|
|
35
|
+
intent?: string | null;
|
|
36
|
+
supported: boolean;
|
|
37
|
+
/** supported 为 false 时给出的原因,可直接展示给用户。 */
|
|
38
|
+
reason?: string | null;
|
|
39
|
+
}
|
|
23
40
|
export interface SessionPortMapping {
|
|
24
41
|
container_port: number;
|
|
25
42
|
host_port: number;
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { type RawEvent } from "../shared/projection";
|
|
2
2
|
import type { MessageContent } from "../schemas/message";
|
|
3
3
|
import type { PatchEnvelope, TurnProjection } from "../schemas/projection";
|
|
4
|
-
import type { SessionStatus } from "../schemas/session";
|
|
4
|
+
import type { ReplaySpeed, ReplayState, SessionStatus } from "../schemas/session";
|
|
5
5
|
import { type CommandHandler } from "../commands/registry";
|
|
6
6
|
import { type AgentSessionEvents } from "./events";
|
|
7
7
|
import type { AppCliAttachment, AppCliDefinition, FileEntry } from "../resources/sessions";
|
|
8
8
|
import { type ConnectionStatus, type SessionState } from "./state";
|
|
9
9
|
/** SessionHub 注入给 AgentSession 的运行时依赖(socket 收发 + REST 补数)。 */
|
|
10
10
|
export interface SessionRuntime {
|
|
11
|
+
streamTokens: boolean;
|
|
11
12
|
emitEvent(event: string, data: unknown): void;
|
|
12
13
|
emitWithAck(event: string, data: unknown, timeoutMs: number): Promise<Record<string, unknown> | undefined>;
|
|
13
14
|
ensureConnected(): void;
|
|
14
15
|
fetchTurns(sessionId: string): Promise<TurnProjection[]>;
|
|
16
|
+
/** 会话详情,目前只用来取回放状态。 */
|
|
17
|
+
fetchSessionInfo(sessionId: string): Promise<{
|
|
18
|
+
replay_state?: ReplayState | null;
|
|
19
|
+
viewer_role?: "owner" | "viewer";
|
|
20
|
+
}>;
|
|
21
|
+
updateReplay(sessionId: string, payload: {
|
|
22
|
+
speed?: ReplaySpeed;
|
|
23
|
+
status?: "autonomous";
|
|
24
|
+
}): Promise<ReplayState | null>;
|
|
15
25
|
listDir(sessionId: string, dirPath: string): Promise<FileEntry[]>;
|
|
16
26
|
countFiles(sessionId: string, dirPath?: string): Promise<number>;
|
|
17
27
|
downloadFile(sessionId: string, filePath: string, downloadName?: string): Promise<void>;
|
|
@@ -65,6 +75,7 @@ export declare class AgentSession {
|
|
|
65
75
|
private patchFlushCancel;
|
|
66
76
|
private joined;
|
|
67
77
|
private joinPending;
|
|
78
|
+
private replayQueue;
|
|
68
79
|
private pendingReplayMessage;
|
|
69
80
|
private pendingReplayMode;
|
|
70
81
|
private recentChatEndAt;
|
|
@@ -139,6 +150,16 @@ export declare class AgentSession {
|
|
|
139
150
|
_rejoinAfterReconnect(): Promise<void>;
|
|
140
151
|
/** @internal 首次连接:加载历史 + 加入房间。 */
|
|
141
152
|
_bootstrap(): Promise<void>;
|
|
153
|
+
/** 改回放是 owner 专属(服务端 PATCH 走 _get_owned_session)。 */
|
|
154
|
+
private get canControlReplay();
|
|
155
|
+
/** 拉一次会话详情,填回放状态和只读身份;失败按非回放会话处理,不挡启动。 */
|
|
156
|
+
private syncReplayFromSession;
|
|
157
|
+
/** 调整回放倍速;不是回放会话、或只读身份时什么都不做。 */
|
|
158
|
+
setReplaySpeed(speed: ReplaySpeed): Promise<void>;
|
|
159
|
+
/** 退出回放,之后的对话交给真实模型运行;不是回放会话、或只读身份时什么都不做。 */
|
|
160
|
+
exitReplay(): Promise<void>;
|
|
161
|
+
/** 把一次回放控制请求排进队列;前一个完成后才发出,响应直接安装。 */
|
|
162
|
+
private applyReplayControl;
|
|
142
163
|
/** @internal */
|
|
143
164
|
_handleTurnStart(turn: TurnProjection): void;
|
|
144
165
|
/** @internal */
|
|
@@ -182,6 +203,7 @@ export declare class AgentSession {
|
|
|
182
203
|
_applyRunningState(isRunning: boolean): void;
|
|
183
204
|
private markRunningIfIdle;
|
|
184
205
|
private finishStreaming;
|
|
206
|
+
private completeChat;
|
|
185
207
|
private applyTurn;
|
|
186
208
|
private schedulePatchFlush;
|
|
187
209
|
private cancelPatchFlush;
|
package/dist/session/state.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChatMessage, CompactionInfo, MessageContent } from "../schemas/message";
|
|
2
2
|
import type { ContentBlock, PatchEnvelope, TurnProjection } from "../schemas/projection";
|
|
3
|
-
import type { SessionStatus } from "../schemas/session";
|
|
3
|
+
import type { ReplaySpeed, ReplayState, SessionStatus } from "../schemas/session";
|
|
4
4
|
/** 一次 AskUserQuestion 的用户作答(选项选择 + 自定义输入)。 */
|
|
5
5
|
export interface AskUserAnswerData {
|
|
6
6
|
selections: Record<number, number[]>;
|
|
@@ -39,9 +39,23 @@ export interface SessionState {
|
|
|
39
39
|
askAnswers: Record<string, AskUserAnswerData>;
|
|
40
40
|
agentLoops: Record<string, AgentLoopInfo>;
|
|
41
41
|
activeCompaction: ActiveCompactionState | null;
|
|
42
|
+
/** 回放(演示 / 彩排)状态;不是回放会话时为 null。 */
|
|
43
|
+
replay: ReplaySnapshot | null;
|
|
44
|
+
/** 当前身份对这个会话的权限;"viewer" 表示只读(分享链接打开的)。 */
|
|
45
|
+
viewerRole: "owner" | "viewer" | null;
|
|
42
46
|
}
|
|
47
|
+
/** 回放会话的快照视图,由服务端的 replay_state 归一化而来。 */
|
|
48
|
+
export interface ReplaySnapshot {
|
|
49
|
+
/** 仍在按录制内容走;转自主运行后为 false。 */
|
|
50
|
+
isReplay: boolean;
|
|
51
|
+
speed: ReplaySpeed;
|
|
52
|
+
sourceSessionId: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** 把服务端的 replay_state 归一化成快照;不是回放会话时返回 null。 */
|
|
55
|
+
export declare function toReplaySnapshot(raw: ReplayState | null | undefined): ReplaySnapshot | null;
|
|
43
56
|
export declare function createInitialSessionState(sessionId: string): SessionState;
|
|
44
57
|
export declare function extractModeFromBlocks(blocks: ContentBlock[]): "planning" | "executing" | null;
|
|
58
|
+
export declare function reconcileOptimisticUserTurns(currentTurns: TurnProjection[], incomingTurns: TurnProjection[]): TurnProjection[];
|
|
45
59
|
/**
|
|
46
60
|
* 用一份新的 turn 列表重建会话状态。
|
|
47
61
|
* addErrorMessage 注入的 role==="error" 消息不在 turns 里,默认会被物化过程抹掉;
|
|
@@ -13,6 +13,11 @@ export type ProjectionUpdate = {
|
|
|
13
13
|
toolName?: string;
|
|
14
14
|
workspacePath?: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* 缺失 chat:end 时的终态兜底。只有被投影接受到当前 assistant turn 的 followup
|
|
18
|
+
* 才能结束流式态;陈旧 followup 或其后已有新轮事件时均返回 false。
|
|
19
|
+
*/
|
|
20
|
+
export declare function acceptedPostChatFollowupCompletesLatestRun(events: RawEvent[], updates: ProjectionUpdate[]): boolean;
|
|
16
21
|
export declare class ClientProjectionBuilder {
|
|
17
22
|
private activeTurns;
|
|
18
23
|
private lastTurnIds;
|
|
@@ -26,6 +26,13 @@ export declare function sourceLoopFor(loopId: string, loopDescriptions: Map<stri
|
|
|
26
26
|
loop_name: string;
|
|
27
27
|
description: string;
|
|
28
28
|
} | null;
|
|
29
|
+
/** 本轮交付给用户的成果:工作区里的文件,或可以打开的网址。 */
|
|
30
|
+
export interface FinalArtifact {
|
|
31
|
+
kind: "file" | "link";
|
|
32
|
+
/** file 是文件路径(相对工作目录或容器内绝对路径);link 是 http/https 网址。 */
|
|
33
|
+
target: string;
|
|
34
|
+
label: string;
|
|
35
|
+
}
|
|
29
36
|
/**
|
|
30
37
|
* Shared by the streaming and history channels — both must decide "is this
|
|
31
38
|
* follow-up showable" identically. Returns null when there is nothing to show.
|
|
@@ -34,6 +41,9 @@ export declare function normalizePostChatFollowup(data: Record<string, unknown>,
|
|
|
34
41
|
assistant_entry_id: string;
|
|
35
42
|
recaption: string;
|
|
36
43
|
suggestions: string[];
|
|
44
|
+
final_artifacts: FinalArtifact[];
|
|
45
|
+
feedback_eligible: boolean;
|
|
46
|
+
feedback_scope: "latest_result";
|
|
37
47
|
} | null;
|
|
38
48
|
export declare function normalizeChildPause(pausePayload: Record<string, unknown>): {
|
|
39
49
|
pauseToolData: Record<string, unknown>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ClientProjectionBuilder, type RawEvent, type ProjectionUpdate } from "./builder";
|
|
1
|
+
export { acceptedPostChatFollowupCompletesLatestRun, ClientProjectionBuilder, 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";
|
|
@@ -93,12 +93,14 @@ export declare namespace SessionSubscribePayloadSchema {
|
|
|
93
93
|
type EventFormat = "raw";
|
|
94
94
|
type AfterSequence = number;
|
|
95
95
|
type Resume = boolean;
|
|
96
|
+
type StreamTokens = boolean;
|
|
96
97
|
interface SessionSubscribePayload {
|
|
97
98
|
session_id: SessionId;
|
|
98
99
|
mode?: Mode;
|
|
99
100
|
event_format?: EventFormat;
|
|
100
101
|
after_sequence?: AfterSequence;
|
|
101
102
|
resume?: Resume;
|
|
103
|
+
stream_tokens?: StreamTokens;
|
|
102
104
|
[k: string]: unknown;
|
|
103
105
|
}
|
|
104
106
|
}
|
|
@@ -114,6 +116,7 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
|
|
|
114
116
|
type EventFormat = "raw";
|
|
115
117
|
type AfterSequence = number;
|
|
116
118
|
type Resume = boolean;
|
|
119
|
+
type StreamTokens = boolean;
|
|
117
120
|
interface SessionSubscribeBatchPayload {
|
|
118
121
|
sessions: Sessions;
|
|
119
122
|
[k: string]: unknown;
|
|
@@ -124,6 +127,7 @@ export declare namespace SessionSubscribeBatchPayloadSchema {
|
|
|
124
127
|
event_format?: EventFormat;
|
|
125
128
|
after_sequence?: AfterSequence;
|
|
126
129
|
resume?: Resume;
|
|
130
|
+
stream_tokens?: StreamTokens;
|
|
127
131
|
[k: string]: unknown;
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -154,8 +158,10 @@ export declare namespace AgentBoardProjectUnsubscribePayloadSchema {
|
|
|
154
158
|
export type AgentBoardProjectUnsubscribePayload = AgentBoardProjectUnsubscribePayloadSchema.AgentBoardProjectUnsubscribePayload;
|
|
155
159
|
export declare namespace ChatStartPayloadSchema {
|
|
156
160
|
type SessionId = (string | null);
|
|
161
|
+
type ChatRunId = (string | null);
|
|
157
162
|
interface ChatStartPayload {
|
|
158
163
|
session_id?: SessionId;
|
|
164
|
+
chat_run_id?: ChatRunId;
|
|
159
165
|
[k: string]: unknown;
|
|
160
166
|
}
|
|
161
167
|
}
|