@blade-hq/agent-client 2610.0.0-rc.0 → 2610.0.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 +202 -12
- package/dist/auth.d.ts +0 -1
- package/dist/blade-client.d.ts +22 -1
- package/dist/index.d.ts +31 -9
- package/dist/index.js +1851 -263
- package/dist/index.js.map +1 -1
- package/dist/polling-backoff.d.ts +11 -0
- package/dist/resources/chat-groups.d.ts +31 -0
- package/dist/resources/computers.d.ts +54 -2
- package/dist/resources/plugins.d.ts +43 -0
- package/dist/resources/sessions.d.ts +190 -1
- package/dist/resources/site-visits.d.ts +32 -0
- package/dist/rest.d.ts +8 -0
- package/dist/schemas/mcp-app.d.ts +30 -0
- package/dist/schemas/message-utils.d.ts +10 -0
- package/dist/schemas/message.d.ts +3 -0
- package/dist/schemas/projection.d.ts +25 -1
- package/dist/schemas/session.d.ts +7 -0
- package/dist/session/agent-session.d.ts +152 -18
- package/dist/session/definition.d.ts +6 -1
- package/dist/session/errors.d.ts +11 -0
- package/dist/session/events.d.ts +14 -2
- package/dist/session/history-page.d.ts +9 -0
- package/dist/session/hub.d.ts +1 -0
- package/dist/session/queue.d.ts +104 -0
- package/dist/session/state.d.ts +15 -1
- package/dist/shared/auth-busy.d.ts +9 -0
- package/dist/shared/projection/builder.d.ts +10 -0
- package/dist/shared/projection/helpers.d.ts +2 -2
- package/dist/shared/projection/index.d.ts +1 -1
- package/dist/shared/projection/state.d.ts +7 -0
- package/dist/shared/tool-ui-card.d.ts +60 -0
- package/dist/shared/type-guards.d.ts +2 -0
- package/dist/socket.d.ts +2 -0
- package/dist/types/socket-events.d.ts +186 -2
- package/package.json +1 -1
- package/public-api.md +747 -11
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Scheduling policy for read-only polling; never sends or replays a request. */
|
|
2
|
+
export declare class PollingBackoff {
|
|
3
|
+
private readonly intervalMs;
|
|
4
|
+
private failures;
|
|
5
|
+
private nextAt;
|
|
6
|
+
constructor(intervalMs: number);
|
|
7
|
+
reset(): void;
|
|
8
|
+
failed(error: unknown): void;
|
|
9
|
+
/** Zero means ready, false means stop, otherwise wait at least this many ms. */
|
|
10
|
+
waitMs(): number | false;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BladeClient } from "../blade-client";
|
|
2
|
+
export interface ChatGroup {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
instructions: string;
|
|
6
|
+
created_at: string;
|
|
7
|
+
updated_at: string;
|
|
8
|
+
session_count: number;
|
|
9
|
+
initiator: "ui" | "sdk" | null;
|
|
10
|
+
workspace_path: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class ChatGroupsResource {
|
|
13
|
+
private readonly client;
|
|
14
|
+
constructor(client: BladeClient);
|
|
15
|
+
list(): Promise<ChatGroup[]>;
|
|
16
|
+
create(payload: {
|
|
17
|
+
name: string;
|
|
18
|
+
instructions?: string;
|
|
19
|
+
initiator?: "ui" | "sdk";
|
|
20
|
+
}): Promise<ChatGroup>;
|
|
21
|
+
update(groupId: string, payload: {
|
|
22
|
+
name?: string;
|
|
23
|
+
instructions?: string;
|
|
24
|
+
}): Promise<ChatGroup>;
|
|
25
|
+
delete(groupId: string, options?: {
|
|
26
|
+
deleteWorkspace?: boolean;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
deleted: boolean;
|
|
29
|
+
deleted_sessions: number;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
@@ -26,6 +26,29 @@ export interface SessionComputer {
|
|
|
26
26
|
export interface SessionComputerList {
|
|
27
27
|
computers: SessionComputer[];
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 账号级电脑目录里的一台机器。
|
|
31
|
+
*
|
|
32
|
+
* 只有「这台机器登记过、此刻在不在线」这类账号事实,**没有**会话授权状态——
|
|
33
|
+
* 「本次会话能不能用它」是另一件事,由会话接口回答。两者混在一起说,用户就会
|
|
34
|
+
* 把「在线」当成「已授权」,或者反过来。
|
|
35
|
+
*/
|
|
36
|
+
export interface AccountComputer {
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
hostname?: string | null;
|
|
40
|
+
os?: string | null;
|
|
41
|
+
arch?: string | null;
|
|
42
|
+
blade_home?: string | null;
|
|
43
|
+
workspace?: string | null;
|
|
44
|
+
daemon_version?: string | null;
|
|
45
|
+
created_at: string;
|
|
46
|
+
last_seen_at?: string | null;
|
|
47
|
+
online: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface AccountComputerList {
|
|
50
|
+
computers: AccountComputer[];
|
|
51
|
+
}
|
|
29
52
|
/**
|
|
30
53
|
* 一台电脑在界面上该显示成什么状态。
|
|
31
54
|
*
|
|
@@ -39,17 +62,46 @@ export interface SessionComputerList {
|
|
|
39
62
|
*/
|
|
40
63
|
export type ComputerState = "primary" | "enabled" | "offline" | "idle";
|
|
41
64
|
export declare function computerState(computer: SessionComputer): ComputerState;
|
|
65
|
+
/**
|
|
66
|
+
* 这台电脑跑的是哪一类系统。
|
|
67
|
+
*
|
|
68
|
+
* 判定放这里、图标映射留给界面:`os` 是 daemon 上报的 `runtime.GOOS`,
|
|
69
|
+
* 各处自己 `startsWith` 一遍必然会分叉。
|
|
70
|
+
*/
|
|
71
|
+
export type ComputerOS = "macos" | "windows" | "linux" | "unknown";
|
|
72
|
+
export declare function computerOS(computer: SessionComputer): ComputerOS;
|
|
73
|
+
/** 系统与架构,例如 `darwin/arm64`。信息不全时尽量给出已知的那部分。 */
|
|
74
|
+
export declare function computerPlatformLabel(computer: SessionComputer): string;
|
|
75
|
+
/**
|
|
76
|
+
* 那台电脑上 blade daemon 的版本。
|
|
77
|
+
*
|
|
78
|
+
* 服务端存的就是 daemon 上报的完整串(dev 构建带 commit),这里原样用,
|
|
79
|
+
* 不在前端另拼一套格式——拼两份迟早对不上。
|
|
80
|
+
*/
|
|
81
|
+
export declare function computerDaemonVersion(computer: SessionComputer): string;
|
|
42
82
|
/** 这台电脑的勾选框能不能动。主运行时不能停用——那是会话自己的工作目录所在。 */
|
|
43
83
|
export declare function canToggleComputer(computer: SessionComputer): boolean;
|
|
44
84
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
85
|
+
* 列表顺序:按接入时间,稳定不变。
|
|
86
|
+
*
|
|
87
|
+
* **刻意不按在线/可用排序。** 那样排看着"手边的在前面",代价是电脑上下线、
|
|
88
|
+
* 勾选状态一变,整个列表就重排——用户正要点的那一项会在手指底下跑掉。
|
|
89
|
+
* 一个会自己动的列表比一个排序不那么聪明的列表难用得多。
|
|
90
|
+
*
|
|
91
|
+
* 用 `created_at` 而不是名字:改名不会让位置变,新接入的稳定排在末尾。
|
|
47
92
|
*/
|
|
48
93
|
export declare function sortComputers(computers: SessionComputer[]): SessionComputer[];
|
|
49
94
|
/** 会话可以操作哪些远程电脑。 */
|
|
50
95
|
export declare class ComputersResource {
|
|
51
96
|
private client;
|
|
52
97
|
constructor(client: BladeClient);
|
|
98
|
+
/**
|
|
99
|
+
* 列出当前账号登记过的全部电脑及其在线状态。
|
|
100
|
+
*
|
|
101
|
+
* 首页还没有会话,也要能看到同一份清单——判定各写一份必然分叉,一边的兜底会把
|
|
102
|
+
* 另一边的错误盖住(#1597)。所以账号事实只从这一个接口读。
|
|
103
|
+
*/
|
|
104
|
+
listAccount(): Promise<AccountComputerList>;
|
|
53
105
|
/**
|
|
54
106
|
* 列出当前用户的全部电脑,带上"在不在线"和"这次会话能不能用"。
|
|
55
107
|
* 服务端只查库,电脑离线时同样返回,所以拿得到"它离线了"这个结论。
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BladeClient } from "../blade-client";
|
|
2
|
+
/**
|
|
3
|
+
* 一个插件在当前用户眼里的展示信息,**与会话无关**。
|
|
4
|
+
*
|
|
5
|
+
* 连接器面板在首页(还没有 sessionId)也要显示插件名称和图标,所以这份目录
|
|
6
|
+
* 只能依赖用户身份:它不激活任何插件、不启动沙盒、不读用户配置。
|
|
7
|
+
*/
|
|
8
|
+
export interface PluginCatalogEntry {
|
|
9
|
+
/** 技术 ID:路径、授权、缓存与调用一律用它。 */
|
|
10
|
+
name: string;
|
|
11
|
+
/** 包声明的业务名称;null 时界面回退到 `name`。 */
|
|
12
|
+
display_name: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* 包内图标的 opaque token,没有可用图标时为 null。
|
|
15
|
+
* 交给 `fetchPluginIcon`,**不是**路径,也不能直接当 URL 用。
|
|
16
|
+
*/
|
|
17
|
+
icon: string | null;
|
|
18
|
+
/** 当前用户是否安装了它。 */
|
|
19
|
+
installed: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 按用户读取的插件目录(无会话)。
|
|
23
|
+
*
|
|
24
|
+
* 图标只能通过带凭据的请求取字节,再转成 object URL——把 `<img>` 指向 API
|
|
25
|
+
* 路径要靠 cookie,token 用户会拿到 401/403。
|
|
26
|
+
*/
|
|
27
|
+
export declare class PluginsResource {
|
|
28
|
+
private client;
|
|
29
|
+
constructor(client: BladeClient);
|
|
30
|
+
/**
|
|
31
|
+
* 列出当前用户安装的插件及其展示信息。
|
|
32
|
+
*
|
|
33
|
+
* 服务端可能为了补齐名称/图标惰性获取包内容,但绝不激活插件、不连 MCP;
|
|
34
|
+
* 单个插件的展示信息读不出来只会降级成占位,不会让整份目录失败。
|
|
35
|
+
*/
|
|
36
|
+
catalog(init?: RequestInit): Promise<{
|
|
37
|
+
plugins: PluginCatalogEntry[];
|
|
38
|
+
}>;
|
|
39
|
+
/** 取一个插件的包内图标字节(用户级,不需要会话)。 */
|
|
40
|
+
fetchIcon(name: string): Promise<Blob>;
|
|
41
|
+
/** 带凭据的图标地址;能直接用 blob URL 的地方优先用 `fetchIcon`。 */
|
|
42
|
+
iconUrl(name: string): string;
|
|
43
|
+
}
|
|
@@ -1,11 +1,81 @@
|
|
|
1
1
|
import type { BackgroundTask, BackgroundTaskStopResult } from "../schemas/background";
|
|
2
2
|
import type { TurnProjection } from "../schemas/projection";
|
|
3
|
+
import type { McpAppArchive } from "../schemas/mcp-app";
|
|
3
4
|
import type { PublishedSolutionRef, ReplayPreview, ReplaySpeed, SessionDetail, SessionInfo, TemplateId } from "../schemas/session";
|
|
5
|
+
import type { McpAppContextState, McpAppContextUpdate } from "../schemas/mcp-app";
|
|
4
6
|
import type { Task } from "../schemas/task";
|
|
5
7
|
import type { BladeClient, UploadProgress } from "../blade-client";
|
|
6
8
|
import type { AgentSession } from "../session/agent-session";
|
|
7
9
|
import { type SessionDefinition } from "../session/definition";
|
|
8
10
|
import type { SessionProfile } from "../types/sdk-profile";
|
|
11
|
+
export interface SessionPlugin {
|
|
12
|
+
/** Technical ID: always used for paths, authorization, caching and calls. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Business name declared by the package; null falls back to `name`. */
|
|
15
|
+
display_name?: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Opaque content token for the package-local icon, or null when the plugin
|
|
18
|
+
* ships none. Pass it to `fetchSessionPluginIcon`; never used as a path.
|
|
19
|
+
*/
|
|
20
|
+
icon?: string | null;
|
|
21
|
+
/** Whether BH lists this plugin for the current user; null means BH was unavailable. */
|
|
22
|
+
installed: boolean | null;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration standing as the list could determine it without reading the
|
|
25
|
+
* user's Home: `unchecked` means nobody has looked yet, never "configured".
|
|
26
|
+
*/
|
|
27
|
+
config?: SessionPluginConfigSummary;
|
|
28
|
+
/** Persisted session choice, independent of preparation success. */
|
|
29
|
+
active: boolean;
|
|
30
|
+
/** Previously prepared skills may remain after deselection. */
|
|
31
|
+
projected: boolean;
|
|
32
|
+
projection_source?: string | null;
|
|
33
|
+
status: string;
|
|
34
|
+
reason?: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** Selection/preparation result; installed facts are obtained from the BH-backed list. */
|
|
37
|
+
export type SessionPluginActivation = Pick<SessionPlugin, "name" | "active" | "status" | "reason">;
|
|
38
|
+
/**
|
|
39
|
+
* How a plugin's user configuration stands.
|
|
40
|
+
*
|
|
41
|
+
* `not_required` — the package ships no config schema, the plugin keeps its old
|
|
42
|
+
* behaviour. `required` — a schema exists but the stored configuration is
|
|
43
|
+
* missing or does not validate. `configured` — stored configuration validates.
|
|
44
|
+
* `error` — the declaration itself is unusable.
|
|
45
|
+
*/
|
|
46
|
+
export type SessionPluginConfigStateName = "not_required" | "required" | "configured" | "error";
|
|
47
|
+
/** List-level view: `unchecked` means nobody has read this user's file yet. */
|
|
48
|
+
export type SessionPluginConfigSummary = SessionPluginConfigStateName | "unchecked";
|
|
49
|
+
export interface SessionPluginConfigError {
|
|
50
|
+
/** JSON Pointer of the offending field. */
|
|
51
|
+
path: string;
|
|
52
|
+
/** Value-free message; the platform never echoes submitted secrets. */
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
export interface SessionPluginConfigState {
|
|
56
|
+
state: SessionPluginConfigStateName;
|
|
57
|
+
reason: string | null;
|
|
58
|
+
/** The package-declared JSON Schema (Draft 2020-12), or null. */
|
|
59
|
+
schema: Record<string, unknown> | null;
|
|
60
|
+
/** Stored values with `writeOnly` properties removed. */
|
|
61
|
+
values: Record<string, unknown>;
|
|
62
|
+
/** JSON Pointers of `writeOnly` properties that currently hold a value. */
|
|
63
|
+
write_only: string[];
|
|
64
|
+
/** Opaque revision for optimistic concurrency; null when nothing is stored. */
|
|
65
|
+
revision: string | null;
|
|
66
|
+
errors: SessionPluginConfigError[];
|
|
67
|
+
}
|
|
68
|
+
export interface SessionPluginConfigSet {
|
|
69
|
+
/** JSON Pointer; arrays are replaced as a whole. */
|
|
70
|
+
path: string;
|
|
71
|
+
value: unknown;
|
|
72
|
+
}
|
|
73
|
+
export interface SessionPluginConfigUpdate {
|
|
74
|
+
/** Omit (or pass null) to publish unconditionally. */
|
|
75
|
+
expected_revision?: string | null;
|
|
76
|
+
set?: SessionPluginConfigSet[];
|
|
77
|
+
remove?: string[];
|
|
78
|
+
}
|
|
9
79
|
export interface CreateSessionRequest {
|
|
10
80
|
intent?: string;
|
|
11
81
|
template_id?: TemplateId;
|
|
@@ -28,6 +98,7 @@ export interface CreateSessionRequest {
|
|
|
28
98
|
daemon_id?: string | null;
|
|
29
99
|
/** runtime_type 为 "native" 时必填:daemon 上要用哪个原生智能体(如 rt_codex)。 */
|
|
30
100
|
agent_runtime_id?: string | null;
|
|
101
|
+
chat_group_id?: string | null;
|
|
31
102
|
}
|
|
32
103
|
export interface CheckpointNode {
|
|
33
104
|
id: string;
|
|
@@ -128,6 +199,43 @@ export interface SessionContextStats {
|
|
|
128
199
|
context_window: number;
|
|
129
200
|
compaction_ratio: number;
|
|
130
201
|
}
|
|
202
|
+
export interface SessionTurnsPage {
|
|
203
|
+
turns: TurnProjection[];
|
|
204
|
+
nextBefore: string | null;
|
|
205
|
+
currentMode: "planning" | "executing";
|
|
206
|
+
}
|
|
207
|
+
/** `getSessionTurnsPage` 的取数参数:向后翻页(before)或从某条发言定位(fromEntryId)。 */
|
|
208
|
+
export interface SessionTurnsQuery {
|
|
209
|
+
limit?: number;
|
|
210
|
+
before?: string;
|
|
211
|
+
/**
|
|
212
|
+
* 从这条用户发言开始、一直到最新。服务端按当前分支校验它,命中不了不会回空页
|
|
213
|
+
* (`entry_not_found` / `entry_not_in_branch`),窗口首条就是这条发言,它的
|
|
214
|
+
* `nextBefore` 可以继续当 `before` 往上翻。
|
|
215
|
+
*/
|
|
216
|
+
fromEntryId?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 服务端明确说这条发言不在当前分支上(`entry_not_found` / `entry_not_in_branch`),
|
|
220
|
+
* 和"这次没取到"(网络 / 5xx / 鉴权)分开:前者说明这个定位目标已经没了,后者只说明这次失败。
|
|
221
|
+
*/
|
|
222
|
+
export declare function isEntryGoneError(error: unknown): boolean;
|
|
223
|
+
/** 侧栏「消息历史」的一条:只有 id、标题和时间,没有消息体。 */
|
|
224
|
+
export interface SessionTurnIndexItem {
|
|
225
|
+
entryId: string;
|
|
226
|
+
preview: string;
|
|
227
|
+
createdAt: string | null;
|
|
228
|
+
}
|
|
229
|
+
export interface SessionTurnIndex {
|
|
230
|
+
sessionId: string;
|
|
231
|
+
items: SessionTurnIndexItem[];
|
|
232
|
+
}
|
|
233
|
+
export interface HistoricalCommand {
|
|
234
|
+
deliveryId: string;
|
|
235
|
+
toolCallId?: string;
|
|
236
|
+
action: string;
|
|
237
|
+
payload?: unknown;
|
|
238
|
+
}
|
|
131
239
|
export type ResultFeedbackReason = "not_solved" | "inaccurate" | "incomplete" | "needs_major_changes" | "too_slow" | "other";
|
|
132
240
|
export interface ResultFeedback {
|
|
133
241
|
session_id: string;
|
|
@@ -196,12 +304,77 @@ export interface ImportSessionOptions {
|
|
|
196
304
|
}
|
|
197
305
|
export declare class SessionsResource {
|
|
198
306
|
private client;
|
|
307
|
+
private readonly pendingImages;
|
|
308
|
+
/** Fetch an immutable message image using this client's authenticated identity. */
|
|
309
|
+
fetchImage(sessionId: string, assetId: string, preview?: boolean): Promise<Blob>;
|
|
310
|
+
/** Fetch a public-share image; the server validates the share token on every request. */
|
|
311
|
+
fetchSharedImage(token: string, assetId: string, preview?: boolean): Promise<Blob>;
|
|
312
|
+
private fetchImagePath;
|
|
199
313
|
constructor(client: BladeClient);
|
|
314
|
+
getMcpApp(sessionId: string, sourceId: string, init?: RequestInit): Promise<McpAppArchive>;
|
|
315
|
+
onMcpAppChanged(sessionId: string, sourceId: string, listener: () => void): () => void;
|
|
316
|
+
callMcpApp(sessionId: string, sourceId: string, request: {
|
|
317
|
+
request_id: string;
|
|
318
|
+
name: string;
|
|
319
|
+
arguments: Record<string, unknown>;
|
|
320
|
+
}, init?: RequestInit): Promise<{
|
|
321
|
+
response: Record<string, unknown>;
|
|
322
|
+
replayed: boolean;
|
|
323
|
+
}>;
|
|
200
324
|
/**
|
|
201
325
|
* 连接一个已存在的会话,返回实时会话对象 AgentSession
|
|
202
326
|
* (自动完成历史加载、Socket.IO 订阅、断线重连补数)。
|
|
203
327
|
*/
|
|
204
328
|
connect(sessionId: string): Promise<AgentSession>;
|
|
329
|
+
listSessionPlugins(sessionId: string, init?: RequestInit): Promise<{
|
|
330
|
+
plugins: SessionPlugin[];
|
|
331
|
+
sync_version: number;
|
|
332
|
+
sync_pending: boolean;
|
|
333
|
+
}>;
|
|
334
|
+
setSessionPluginActivation(sessionId: string, name: string, active: boolean, init?: RequestInit): Promise<{
|
|
335
|
+
plugin: SessionPluginActivation;
|
|
336
|
+
sync_version: number;
|
|
337
|
+
}>;
|
|
338
|
+
/**
|
|
339
|
+
* Fetch a plugin's package-local icon as bytes.
|
|
340
|
+
*
|
|
341
|
+
* The request carries the client's own bearer credentials, so callers turn
|
|
342
|
+
* the blob into an object URL instead of pointing `<img>` at an API path and
|
|
343
|
+
* hoping the request is authenticated.
|
|
344
|
+
*/
|
|
345
|
+
fetchSessionPluginIcon(sessionId: string, name: string): Promise<Blob>;
|
|
346
|
+
/** Authenticated URL for the icon; useful where a blob URL cannot be used. */
|
|
347
|
+
sessionPluginIconUrl(sessionId: string, name: string): string;
|
|
348
|
+
/**
|
|
349
|
+
* 准备一个插件的配置:把包准备好并读出用户的配置契约,**不启用**它。
|
|
350
|
+
*
|
|
351
|
+
* 开启插件前必须先走这一步:缺配置时用户只会看到配置表单,服务端不会先把
|
|
352
|
+
* active 持久化成 true 再靠补偿关掉。它不修改会话的插件选择、不连接 MCP。
|
|
353
|
+
*/
|
|
354
|
+
prepareSessionPluginConfig(sessionId: string, name: string, init?: RequestInit): Promise<{
|
|
355
|
+
plugin: string;
|
|
356
|
+
config: SessionPluginConfigState;
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* Read a plugin's configuration contract and the user's stored values.
|
|
360
|
+
*
|
|
361
|
+
* Secrets are never returned: `write_only` lists the pointers that hold one.
|
|
362
|
+
*/
|
|
363
|
+
getSessionPluginConfig(sessionId: string, name: string, init?: RequestInit): Promise<{
|
|
364
|
+
plugin: string;
|
|
365
|
+
config: SessionPluginConfigState;
|
|
366
|
+
}>;
|
|
367
|
+
/**
|
|
368
|
+
* Publish explicit set/remove operations to the user's keychain file.
|
|
369
|
+
*
|
|
370
|
+
* Fields absent from both lists keep their stored value, so a form never has
|
|
371
|
+
* to round-trip a secret. Rejections leave the previous file untouched; the
|
|
372
|
+
* call never restarts MCP servers.
|
|
373
|
+
*/
|
|
374
|
+
updateSessionPluginConfig(sessionId: string, name: string, update: SessionPluginConfigUpdate, init?: RequestInit): Promise<{
|
|
375
|
+
plugin: string;
|
|
376
|
+
config: SessionPluginConfigState;
|
|
377
|
+
}>;
|
|
205
378
|
/** 创建新会话并直接连接,返回可收发消息的 AgentSession。 */
|
|
206
379
|
create(request?: CreateSessionRequest | SessionDefinition): Promise<AgentSession>;
|
|
207
380
|
private createDeclared;
|
|
@@ -216,6 +389,7 @@ export declare class SessionsResource {
|
|
|
216
389
|
solution_id?: string;
|
|
217
390
|
solution_registry_id?: string;
|
|
218
391
|
q?: string;
|
|
392
|
+
chat_group_id?: string;
|
|
219
393
|
}): Promise<PaginatedSessionsResult>;
|
|
220
394
|
listSessionsWithSkillData(): Promise<SkillDevSession[]>;
|
|
221
395
|
searchOwnedContent(params: {
|
|
@@ -237,6 +411,7 @@ export declare class SessionsResource {
|
|
|
237
411
|
getSession(sessionId: string, init?: RequestInit): Promise<SessionDetail>;
|
|
238
412
|
updateSession(sessionId: string, payload: {
|
|
239
413
|
intent?: string;
|
|
414
|
+
chat_group_id?: string | null;
|
|
240
415
|
}): Promise<SessionDetail>;
|
|
241
416
|
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
242
417
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
@@ -264,6 +439,20 @@ export declare class SessionsResource {
|
|
|
264
439
|
getSharedSession(token: string): Promise<TurnProjection[]>;
|
|
265
440
|
getSessionTasks(sessionId: string): Promise<Task[]>;
|
|
266
441
|
getSessionTurns(sessionId: string): Promise<TurnProjection[]>;
|
|
442
|
+
getSessionTurnsPage(sessionId: string, options?: SessionTurnsQuery, init?: RequestInit): Promise<SessionTurnsPage>;
|
|
443
|
+
/**
|
|
444
|
+
* 当前分支上可导航的用户发言目录(消息导航侧栏)。
|
|
445
|
+
*
|
|
446
|
+
* 只回 id、标题和时间:侧栏要列的是**整条会话**的发言,而窗口外的发言 id 只能
|
|
447
|
+
* 从服务端拿;消息体仍然走 `/turns`。
|
|
448
|
+
*/
|
|
449
|
+
getSessionTurnIndex(sessionId: string): Promise<SessionTurnIndex>;
|
|
450
|
+
getMcpAppContext(sessionId: string, sourceId: string, init?: RequestInit): Promise<McpAppContextState>;
|
|
451
|
+
updateMcpAppContext(sessionId: string, sourceId: string, body: McpAppContextUpdate, init?: RequestInit): Promise<{
|
|
452
|
+
status: "accepted";
|
|
453
|
+
revision: string;
|
|
454
|
+
}>;
|
|
455
|
+
getSessionTurnCommands(sessionId: string): Promise<HistoricalCommand[]>;
|
|
267
456
|
listResultFeedback(sessionId: string): Promise<ResultFeedback[]>;
|
|
268
457
|
putResultFeedback(sessionId: string, assistantEntryId: string, feedback: {
|
|
269
458
|
helpful: boolean;
|
|
@@ -311,7 +500,7 @@ export declare class SessionsResource {
|
|
|
311
500
|
reachable: boolean;
|
|
312
501
|
requires_proxy: boolean;
|
|
313
502
|
}>;
|
|
314
|
-
listDir(sessionId: string, dirPath: string): Promise<FileEntry[]>;
|
|
503
|
+
listDir(sessionId: string, dirPath: string, showHidden?: boolean): Promise<FileEntry[]>;
|
|
315
504
|
countFiles(sessionId: string, dirPath?: string): Promise<number>;
|
|
316
505
|
/** 在浏览器中下载一个会话文件。 */
|
|
317
506
|
downloadFile(sessionId: string, filePath: string, downloadName?: string): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BladeClient } from "../blade-client";
|
|
2
|
+
/** 全站访问统计快照。每个数字都来自真实请求,没有基数、系数或回填。 */
|
|
3
|
+
export interface SiteVisitsSummary {
|
|
4
|
+
/** 统计日期,按北京时间切日(`YYYY-MM-DD`)。 */
|
|
5
|
+
date: string;
|
|
6
|
+
/** 统计时区,固定为 `Asia/Shanghai`。 */
|
|
7
|
+
timezone: string;
|
|
8
|
+
/** 当天出现过的匿名访客数:按天去重,不是实时在线人数。 */
|
|
9
|
+
today_uv: number;
|
|
10
|
+
/** 当天的页面访问次数。 */
|
|
11
|
+
today_pv: number;
|
|
12
|
+
/** 功能上线以来累计的页面访问次数。 */
|
|
13
|
+
total_pv: number;
|
|
14
|
+
/** 快照生成时间(RFC3339 UTC)。并发响应可能倒序到达,用它丢弃旧快照。 */
|
|
15
|
+
as_of: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 全站访问统计(内置 Web 的匿名计数)。
|
|
19
|
+
*
|
|
20
|
+
* 这两个操作刻意走独立传输:不带 bearer、不触发 401 登录刷新,也不读登录
|
|
21
|
+
* Cookie——计数只依赖匿名访客 Cookie,因此登录态失效时统计依然可用。它们
|
|
22
|
+
* 只在同源的内置 Web 里使用,不是给第三方宿主页面用的。
|
|
23
|
+
*/
|
|
24
|
+
export declare class SiteVisitsResource {
|
|
25
|
+
private readonly client;
|
|
26
|
+
constructor(client: BladeClient);
|
|
27
|
+
/** 上报一次页面访问,返回当前快照;不承诺本次已计入或已落盘。 */
|
|
28
|
+
record(): Promise<SiteVisitsSummary>;
|
|
29
|
+
/** 只读快照:不设置访客 Cookie,也不增加任何计数。 */
|
|
30
|
+
summary(): Promise<SiteVisitsSummary>;
|
|
31
|
+
private request;
|
|
32
|
+
}
|
package/dist/rest.d.ts
CHANGED
|
@@ -19,3 +19,11 @@ export interface BladeFetchInit {
|
|
|
19
19
|
headers?: HeadersInit;
|
|
20
20
|
signal?: AbortSignal | null;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* 按客户端规则把后端路径拼成绝对 URL:`baseUrl` 自带路径前缀时保留前缀,
|
|
24
|
+
* 路径里的前导 `/` 只表示"从后端根开始",不会被解释成站点根目录。
|
|
25
|
+
*
|
|
26
|
+
* 单独放在传输层,是为了让不走 `fetch()` 鉴权通道的资源(例如匿名的站点统计)
|
|
27
|
+
* 落到同一个后端地址上,不必各自再写一份 URL 规则。
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildBackendUrl(baseUrl: string, path: string): URL;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Archived MCP App data. Credentials and executable server configuration are excluded. */
|
|
2
|
+
export interface McpAppData {
|
|
3
|
+
sourceId: string;
|
|
4
|
+
resourceUri: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
resourceMeta: Record<string, unknown>;
|
|
7
|
+
toolInput: Record<string, unknown>;
|
|
8
|
+
toolResult: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface McpAppArchive extends McpAppData {
|
|
11
|
+
html: string;
|
|
12
|
+
plugin: string;
|
|
13
|
+
/** Restore the last successful view before delivering a saved failure. */
|
|
14
|
+
previousToolInput?: Record<string, unknown>;
|
|
15
|
+
previousToolResult?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare function isMcpAppData(value: unknown): value is McpAppData;
|
|
18
|
+
/** Latest model-context state one MCP App saved for its own card. */
|
|
19
|
+
export interface McpAppContextState {
|
|
20
|
+
revision: string;
|
|
21
|
+
content: string;
|
|
22
|
+
plugin: string | null;
|
|
23
|
+
server_alias: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface McpAppContextUpdate {
|
|
26
|
+
request_id: string;
|
|
27
|
+
/** null on the first save; the server rejects a stale revision. */
|
|
28
|
+
expected_revision: string | null;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
@@ -5,6 +5,14 @@ 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
|
+
/**
|
|
9
|
+
* 平台自己写进去、不该露给用户的内部提示。
|
|
10
|
+
*
|
|
11
|
+
* 服务端的消息导航目录有一份同名同语义的 Python 实现
|
|
12
|
+
* (`server/.../routes/sessions.py` 的 `_is_hidden_internal_message`):客户端靠它决定
|
|
13
|
+
* 渲染不渲染,服务端靠它决定进不进目录。改这里必须同时改那边,否则目录会列出没有对应
|
|
14
|
+
* 行的死条目,或者把内部提示原文当标题露出去。
|
|
15
|
+
*/
|
|
8
16
|
export declare function isHiddenInternalMessage(message: Pick<ChatMessage, "role" | "content">, options?: {
|
|
9
17
|
includeLegacyForkContext?: boolean;
|
|
10
18
|
}): boolean;
|
|
@@ -59,4 +67,6 @@ interface MessageGroup {
|
|
|
59
67
|
}[];
|
|
60
68
|
}
|
|
61
69
|
export declare function groupMessagesByLoop(messages: ChatMessage[]): MessageGroup[];
|
|
70
|
+
/** A typed wake input stays internal for navigation, but has a visible notice. */
|
|
71
|
+
export declare function isBackgroundWakeMessage(message: Pick<ChatMessage, "blocks">): boolean;
|
|
62
72
|
export {};
|
|
@@ -5,6 +5,8 @@ export interface ToolBridgeContent {
|
|
|
5
5
|
export interface ContentBlock {
|
|
6
6
|
type: "text" | "thinking" | "tool_use" | "tool_result" | "tool_ui" | "tool_bridge" | "system_notification" | "mode_change" | "plan_status" | "ask_user_answer";
|
|
7
7
|
content: unknown;
|
|
8
|
+
/** Stable history-entry identity for a tool_bridge delivery. */
|
|
9
|
+
delivery_id?: string | null;
|
|
8
10
|
tool_call_id?: string | null;
|
|
9
11
|
tool_name?: string | null;
|
|
10
12
|
display_name?: string | null;
|
|
@@ -14,6 +16,15 @@ export interface PendingQuestionRef {
|
|
|
14
16
|
child_tool_call_id: string;
|
|
15
17
|
description?: string | null;
|
|
16
18
|
}
|
|
19
|
+
/** 一次运行(用户轮或子智能体)的实际墙钟区间。 */
|
|
20
|
+
export interface RunTiming {
|
|
21
|
+
run_id: string;
|
|
22
|
+
scope: "chat" | "subagent";
|
|
23
|
+
loop_id: string;
|
|
24
|
+
started_at?: string | null;
|
|
25
|
+
duration_ms?: number | null;
|
|
26
|
+
status: "completed" | "failed" | "cancelled" | "paused" | "incomplete";
|
|
27
|
+
}
|
|
17
28
|
export interface ToolCallProjection {
|
|
18
29
|
id: string;
|
|
19
30
|
tool_name: string;
|
|
@@ -22,6 +33,11 @@ export interface ToolCallProjection {
|
|
|
22
33
|
status: "pending" | "done" | "error" | "cancelled" | "awaiting_answer" | string;
|
|
23
34
|
result?: unknown;
|
|
24
35
|
duration_ms?: number | null;
|
|
36
|
+
/** 工具真正进入执行的墙钟起点;排队/待审批的调用没有该值。 */
|
|
37
|
+
started_at?: string | null;
|
|
38
|
+
ran_in_parallel?: boolean;
|
|
39
|
+
/** 该工具派生的子智能体运行区间,仅作外层展示。 */
|
|
40
|
+
subagent_runs?: RunTiming[];
|
|
25
41
|
pending_question_ref?: PendingQuestionRef | null;
|
|
26
42
|
}
|
|
27
43
|
export interface MemoryRef {
|
|
@@ -54,8 +70,14 @@ export interface TurnProjection {
|
|
|
54
70
|
tool_calls: ToolCallProjection[];
|
|
55
71
|
model?: string | null;
|
|
56
72
|
usage?: Record<string, unknown> | null;
|
|
57
|
-
|
|
73
|
+
/** 模型请求区间(不含后续工具);未知时为 null,不用 0 冒充。 */
|
|
74
|
+
duration_ms?: number | null;
|
|
75
|
+
first_token_ms?: number | null;
|
|
76
|
+
stream_duration_ms?: number | null;
|
|
77
|
+
first_token_delivery_ms?: number | null;
|
|
58
78
|
started_at?: string | null;
|
|
79
|
+
/** started_at 是否来自生产者上报(而非旧会话的落盘回落)。瀑布只承认前者。 */
|
|
80
|
+
has_reported_timing?: boolean;
|
|
59
81
|
context_window?: number;
|
|
60
82
|
memory_refs?: MemoryRef[] | null;
|
|
61
83
|
parent_fork_tool_call_id?: string | null;
|
|
@@ -72,6 +94,8 @@ export interface TurnProjection {
|
|
|
72
94
|
sources?: import("./context").ContextSourceInfo[] | null;
|
|
73
95
|
/** Client-only stable identity for reconciling an optimistic user turn. */
|
|
74
96
|
client_render_id?: string | null;
|
|
97
|
+
/** Send identity echoed by the server for exact optimistic reconciliation. */
|
|
98
|
+
client_request_id?: string | null;
|
|
75
99
|
compaction_id?: string | null;
|
|
76
100
|
summary_preview?: string | null;
|
|
77
101
|
summary_full?: string | null;
|
|
@@ -62,6 +62,7 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
|
|
|
62
62
|
shared?: boolean | undefined;
|
|
63
63
|
memory_enabled?: boolean | undefined;
|
|
64
64
|
is_persistent?: boolean | undefined;
|
|
65
|
+
initiator?: "sdk" | "ui" | "unknown" | null | undefined;
|
|
65
66
|
is_headless?: boolean | undefined;
|
|
66
67
|
viewer_role?: "owner" | "viewer" | undefined;
|
|
67
68
|
template_id?: string | null | undefined;
|
|
@@ -84,6 +85,9 @@ export declare const SessionInfo: import("arktype/internal/variants/object.ts").
|
|
|
84
85
|
daemon_id?: string | null | undefined;
|
|
85
86
|
agent_runtime_id?: string | null | undefined;
|
|
86
87
|
workspace_path?: string | null | undefined;
|
|
88
|
+
ba_version?: string | null | undefined;
|
|
89
|
+
sandbox_version?: string | null | undefined;
|
|
90
|
+
chat_group_id?: string | null | undefined;
|
|
87
91
|
match?: unknown;
|
|
88
92
|
}, {}>;
|
|
89
93
|
export type SessionInfo = Omit<typeof SessionInfo.infer, "template_id" | "solution" | "ports" | "match"> & {
|
|
@@ -111,6 +115,9 @@ export type SessionInfo = Omit<typeof SessionInfo.infer, "template_id" | "soluti
|
|
|
111
115
|
daemon_id?: string | null;
|
|
112
116
|
agent_runtime_id?: string | null;
|
|
113
117
|
workspace_path?: string | null;
|
|
118
|
+
ba_version?: string | null;
|
|
119
|
+
sandbox_version?: string | null;
|
|
120
|
+
chat_group_id?: string | null;
|
|
114
121
|
/** 仅在带 q 搜索的列表响应中出现;普通列表里此字段缺省。 */
|
|
115
122
|
match?: SessionSearchMatch | null;
|
|
116
123
|
};
|