@blade-hq/agent-client 2610.0.0-beta.7 → 2610.0.0-beta.71
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 +248 -9
- package/dist/auth.d.ts +0 -1
- package/dist/blade-client.d.ts +21 -3
- package/dist/index.d.ts +35 -6
- package/dist/index.js +2210 -268
- package/dist/index.js.map +1 -1
- package/dist/platform-endpoints.d.ts +14 -0
- package/dist/polling-backoff.d.ts +11 -0
- package/dist/resources/chat-groups.d.ts +26 -0
- package/dist/resources/computers.d.ts +115 -0
- package/dist/resources/models.d.ts +2 -0
- package/dist/resources/plugins.d.ts +43 -0
- package/dist/resources/sessions.d.ts +186 -1
- package/dist/resources/site-visits.d.ts +32 -0
- package/dist/rest.d.ts +8 -0
- package/dist/schemas/context.d.ts +49 -0
- package/dist/schemas/event.d.ts +9 -0
- package/dist/schemas/mcp-app.d.ts +30 -0
- package/dist/schemas/message-utils.d.ts +13 -1
- package/dist/schemas/message.d.ts +3 -0
- package/dist/schemas/projection.d.ts +37 -2
- package/dist/schemas/session.d.ts +9 -1
- package/dist/session/agent-session.d.ts +142 -16
- package/dist/session/events.d.ts +4 -0
- package/dist/session/history-page.d.ts +9 -0
- package/dist/session/hub.d.ts +9 -1
- package/dist/session/queue.d.ts +99 -0
- package/dist/session/state.d.ts +18 -2
- package/dist/shared/auth-busy.d.ts +9 -0
- package/dist/shared/projection/builder.d.ts +12 -0
- package/dist/shared/projection/context.d.ts +3 -0
- package/dist/shared/projection/helpers.d.ts +2 -2
- package/dist/shared/projection/history.d.ts +1 -0
- package/dist/shared/projection/index.d.ts +2 -1
- package/dist/shared/projection/state.d.ts +7 -0
- package/dist/shared/tool-ui-card.d.ts +58 -0
- package/dist/shared/type-guards.d.ts +2 -0
- package/dist/types/socket-events.d.ts +195 -6
- package/package.json +1 -1
- package/public-api.md +918 -12
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const PLATFORM_SERVICE_NAMES: readonly ["os", "hub", "agent", "oauth", "llmGateway", "gitea", "tile"];
|
|
2
|
+
export type PlatformServiceName = (typeof PLATFORM_SERVICE_NAMES)[number];
|
|
3
|
+
export interface PlatformEndpoints {
|
|
4
|
+
services: Partial<Record<PlatformServiceName, string>>;
|
|
5
|
+
}
|
|
6
|
+
export declare const EMPTY_PLATFORM_ENDPOINTS: PlatformEndpoints;
|
|
7
|
+
export interface LoadPlatformEndpointsOptions {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function parsePlatformEndpoints(value: unknown): PlatformEndpoints | null;
|
|
13
|
+
export declare function loadPlatformEndpoints(options?: LoadPlatformEndpointsOptions): Promise<PlatformEndpoints>;
|
|
14
|
+
export declare function resolveServiceUrl(endpoints: PlatformEndpoints, name: PlatformServiceName, path?: string): string | null;
|
|
@@ -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,26 @@
|
|
|
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
|
+
}
|
|
10
|
+
export declare class ChatGroupsResource {
|
|
11
|
+
private readonly client;
|
|
12
|
+
constructor(client: BladeClient);
|
|
13
|
+
list(): Promise<ChatGroup[]>;
|
|
14
|
+
create(payload: {
|
|
15
|
+
name: string;
|
|
16
|
+
instructions?: string;
|
|
17
|
+
}): Promise<ChatGroup>;
|
|
18
|
+
update(groupId: string, payload: {
|
|
19
|
+
name?: string;
|
|
20
|
+
instructions?: string;
|
|
21
|
+
}): Promise<ChatGroup>;
|
|
22
|
+
delete(groupId: string): Promise<{
|
|
23
|
+
deleted: boolean;
|
|
24
|
+
deleted_sessions: number;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { BladeClient } from "../blade-client";
|
|
2
|
+
/** 一台远程电脑在某个会话眼里的样子。 */
|
|
3
|
+
export interface SessionComputer {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
hostname?: string | null;
|
|
7
|
+
os?: string | null;
|
|
8
|
+
arch?: string | null;
|
|
9
|
+
/** 那台机器的用户主目录,命令默认在这里执行。 */
|
|
10
|
+
home?: string | null;
|
|
11
|
+
/** daemon 启动时所在的目录。 */
|
|
12
|
+
workspace?: string | null;
|
|
13
|
+
blade_home?: string | null;
|
|
14
|
+
allowed_paths?: string[];
|
|
15
|
+
agent_runtimes?: unknown[];
|
|
16
|
+
daemon_version?: string | null;
|
|
17
|
+
created_at: string;
|
|
18
|
+
last_seen_at?: string | null;
|
|
19
|
+
/** 这台电脑此刻连着后端。由服务端读心跳时间判定,不做实时探测。 */
|
|
20
|
+
online: boolean;
|
|
21
|
+
/** 这次会话已经启动了它。和 `online` 互相独立。 */
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
/** 这次会话本身就跑在这台电脑上。 */
|
|
24
|
+
is_primary: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface SessionComputerList {
|
|
27
|
+
computers: SessionComputer[];
|
|
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
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 一台电脑在界面上该显示成什么状态。
|
|
54
|
+
*
|
|
55
|
+
* - `primary` 会话自己就住在这台机器上,恒为可用且不能停用
|
|
56
|
+
* - `enabled` 本次会话已启动
|
|
57
|
+
* - `offline` 没启动且当前离线
|
|
58
|
+
* - `idle` 没启动,在线
|
|
59
|
+
*
|
|
60
|
+
* 判定只写这一份,界面只管样式和排版——两边各写一份必然会分叉,
|
|
61
|
+
* 然后其中一边的兜底会把另一边的错误盖住。
|
|
62
|
+
*/
|
|
63
|
+
export type ComputerState = "primary" | "enabled" | "offline" | "idle";
|
|
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;
|
|
82
|
+
/** 这台电脑的勾选框能不能动。主运行时不能停用——那是会话自己的工作目录所在。 */
|
|
83
|
+
export declare function canToggleComputer(computer: SessionComputer): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* 列表顺序:按接入时间,稳定不变。
|
|
86
|
+
*
|
|
87
|
+
* **刻意不按在线/可用排序。** 那样排看着"手边的在前面",代价是电脑上下线、
|
|
88
|
+
* 勾选状态一变,整个列表就重排——用户正要点的那一项会在手指底下跑掉。
|
|
89
|
+
* 一个会自己动的列表比一个排序不那么聪明的列表难用得多。
|
|
90
|
+
*
|
|
91
|
+
* 用 `created_at` 而不是名字:改名不会让位置变,新接入的稳定排在末尾。
|
|
92
|
+
*/
|
|
93
|
+
export declare function sortComputers(computers: SessionComputer[]): SessionComputer[];
|
|
94
|
+
/** 会话可以操作哪些远程电脑。 */
|
|
95
|
+
export declare class ComputersResource {
|
|
96
|
+
private client;
|
|
97
|
+
constructor(client: BladeClient);
|
|
98
|
+
/**
|
|
99
|
+
* 列出当前账号登记过的全部电脑及其在线状态。
|
|
100
|
+
*
|
|
101
|
+
* 首页还没有会话,也要能看到同一份清单——判定各写一份必然分叉,一边的兜底会把
|
|
102
|
+
* 另一边的错误盖住(#1597)。所以账号事实只从这一个接口读。
|
|
103
|
+
*/
|
|
104
|
+
listAccount(): Promise<AccountComputerList>;
|
|
105
|
+
/**
|
|
106
|
+
* 列出当前用户的全部电脑,带上"在不在线"和"这次会话能不能用"。
|
|
107
|
+
* 服务端只查库,电脑离线时同样返回,所以拿得到"它离线了"这个结论。
|
|
108
|
+
*/
|
|
109
|
+
list(sessionId: string): Promise<SessionComputerList>;
|
|
110
|
+
/**
|
|
111
|
+
* 启动或停止一台电脑。只改这次会话的可用范围,不会碰远程机器,
|
|
112
|
+
* 电脑离线时同样能登记,等它上线就直接可用。
|
|
113
|
+
*/
|
|
114
|
+
setEnabled(sessionId: string, computer: string, enabled: boolean): Promise<SessionComputer>;
|
|
115
|
+
}
|
|
@@ -12,6 +12,8 @@ export interface ModelOption {
|
|
|
12
12
|
export interface ModelCatalog {
|
|
13
13
|
default: string;
|
|
14
14
|
models: ModelOption[];
|
|
15
|
+
unavailableProviderIds?: string[];
|
|
16
|
+
unavailableModelIds?: string[];
|
|
15
17
|
/**
|
|
16
18
|
* 平台默认模型服务的 OpenAI 兼容地址(Server ≥ 提供 `baseUrl` 的版本才有,否则为空)。
|
|
17
19
|
* 自建应用可以带用户的 PAT 直接调它,不必让用户自己填地址——网关端口各部署不同,
|
|
@@ -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;
|
|
@@ -24,8 +94,11 @@ export interface CreateSessionRequest {
|
|
|
24
94
|
disable_tools?: string[] | null;
|
|
25
95
|
session_solution_asset_id?: string | null;
|
|
26
96
|
compaction_ratio?: number | null;
|
|
27
|
-
runtime_type?: "sandbox" | "daemon" | null;
|
|
97
|
+
runtime_type?: "sandbox" | "daemon" | "native" | null;
|
|
28
98
|
daemon_id?: string | null;
|
|
99
|
+
/** runtime_type 为 "native" 时必填:daemon 上要用哪个原生智能体(如 rt_codex)。 */
|
|
100
|
+
agent_runtime_id?: string | null;
|
|
101
|
+
chat_group_id?: string | null;
|
|
29
102
|
}
|
|
30
103
|
export interface CheckpointNode {
|
|
31
104
|
id: string;
|
|
@@ -126,6 +199,43 @@ export interface SessionContextStats {
|
|
|
126
199
|
context_window: number;
|
|
127
200
|
compaction_ratio: number;
|
|
128
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
|
+
}
|
|
129
239
|
export type ResultFeedbackReason = "not_solved" | "inaccurate" | "incomplete" | "needs_major_changes" | "too_slow" | "other";
|
|
130
240
|
export interface ResultFeedback {
|
|
131
241
|
session_id: string;
|
|
@@ -195,11 +305,70 @@ export interface ImportSessionOptions {
|
|
|
195
305
|
export declare class SessionsResource {
|
|
196
306
|
private client;
|
|
197
307
|
constructor(client: BladeClient);
|
|
308
|
+
getMcpApp(sessionId: string, sourceId: string, init?: RequestInit): Promise<McpAppArchive>;
|
|
309
|
+
onMcpAppChanged(sessionId: string, sourceId: string, listener: () => void): () => void;
|
|
310
|
+
callMcpApp(sessionId: string, sourceId: string, request: {
|
|
311
|
+
request_id: string;
|
|
312
|
+
name: string;
|
|
313
|
+
arguments: Record<string, unknown>;
|
|
314
|
+
}, init?: RequestInit): Promise<{
|
|
315
|
+
response: Record<string, unknown>;
|
|
316
|
+
replayed: boolean;
|
|
317
|
+
}>;
|
|
198
318
|
/**
|
|
199
319
|
* 连接一个已存在的会话,返回实时会话对象 AgentSession
|
|
200
320
|
* (自动完成历史加载、Socket.IO 订阅、断线重连补数)。
|
|
201
321
|
*/
|
|
202
322
|
connect(sessionId: string): Promise<AgentSession>;
|
|
323
|
+
listSessionPlugins(sessionId: string, init?: RequestInit): Promise<{
|
|
324
|
+
plugins: SessionPlugin[];
|
|
325
|
+
sync_version: number;
|
|
326
|
+
sync_pending: boolean;
|
|
327
|
+
}>;
|
|
328
|
+
setSessionPluginActivation(sessionId: string, name: string, active: boolean, init?: RequestInit): Promise<{
|
|
329
|
+
plugin: SessionPluginActivation;
|
|
330
|
+
sync_version: number;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* Fetch a plugin's package-local icon as bytes.
|
|
334
|
+
*
|
|
335
|
+
* The request carries the client's own bearer credentials, so callers turn
|
|
336
|
+
* the blob into an object URL instead of pointing `<img>` at an API path and
|
|
337
|
+
* hoping the request is authenticated.
|
|
338
|
+
*/
|
|
339
|
+
fetchSessionPluginIcon(sessionId: string, name: string): Promise<Blob>;
|
|
340
|
+
/** Authenticated URL for the icon; useful where a blob URL cannot be used. */
|
|
341
|
+
sessionPluginIconUrl(sessionId: string, name: string): string;
|
|
342
|
+
/**
|
|
343
|
+
* 准备一个插件的配置:把包准备好并读出用户的配置契约,**不启用**它。
|
|
344
|
+
*
|
|
345
|
+
* 开启插件前必须先走这一步:缺配置时用户只会看到配置表单,服务端不会先把
|
|
346
|
+
* active 持久化成 true 再靠补偿关掉。它不修改会话的插件选择、不连接 MCP。
|
|
347
|
+
*/
|
|
348
|
+
prepareSessionPluginConfig(sessionId: string, name: string, init?: RequestInit): Promise<{
|
|
349
|
+
plugin: string;
|
|
350
|
+
config: SessionPluginConfigState;
|
|
351
|
+
}>;
|
|
352
|
+
/**
|
|
353
|
+
* Read a plugin's configuration contract and the user's stored values.
|
|
354
|
+
*
|
|
355
|
+
* Secrets are never returned: `write_only` lists the pointers that hold one.
|
|
356
|
+
*/
|
|
357
|
+
getSessionPluginConfig(sessionId: string, name: string, init?: RequestInit): Promise<{
|
|
358
|
+
plugin: string;
|
|
359
|
+
config: SessionPluginConfigState;
|
|
360
|
+
}>;
|
|
361
|
+
/**
|
|
362
|
+
* Publish explicit set/remove operations to the user's keychain file.
|
|
363
|
+
*
|
|
364
|
+
* Fields absent from both lists keep their stored value, so a form never has
|
|
365
|
+
* to round-trip a secret. Rejections leave the previous file untouched; the
|
|
366
|
+
* call never restarts MCP servers.
|
|
367
|
+
*/
|
|
368
|
+
updateSessionPluginConfig(sessionId: string, name: string, update: SessionPluginConfigUpdate, init?: RequestInit): Promise<{
|
|
369
|
+
plugin: string;
|
|
370
|
+
config: SessionPluginConfigState;
|
|
371
|
+
}>;
|
|
203
372
|
/** 创建新会话并直接连接,返回可收发消息的 AgentSession。 */
|
|
204
373
|
create(request?: CreateSessionRequest | SessionDefinition): Promise<AgentSession>;
|
|
205
374
|
private createDeclared;
|
|
@@ -214,6 +383,7 @@ export declare class SessionsResource {
|
|
|
214
383
|
solution_id?: string;
|
|
215
384
|
solution_registry_id?: string;
|
|
216
385
|
q?: string;
|
|
386
|
+
chat_group_id?: string;
|
|
217
387
|
}): Promise<PaginatedSessionsResult>;
|
|
218
388
|
listSessionsWithSkillData(): Promise<SkillDevSession[]>;
|
|
219
389
|
searchOwnedContent(params: {
|
|
@@ -235,6 +405,7 @@ export declare class SessionsResource {
|
|
|
235
405
|
getSession(sessionId: string, init?: RequestInit): Promise<SessionDetail>;
|
|
236
406
|
updateSession(sessionId: string, payload: {
|
|
237
407
|
intent?: string;
|
|
408
|
+
chat_group_id?: string | null;
|
|
238
409
|
}): Promise<SessionDetail>;
|
|
239
410
|
setSessionEnv(sessionId: string, env: Record<string, string>): Promise<SessionDetail>;
|
|
240
411
|
pinSession(sessionId: string, pinned: boolean): Promise<SessionInfo>;
|
|
@@ -262,6 +433,20 @@ export declare class SessionsResource {
|
|
|
262
433
|
getSharedSession(token: string): Promise<TurnProjection[]>;
|
|
263
434
|
getSessionTasks(sessionId: string): Promise<Task[]>;
|
|
264
435
|
getSessionTurns(sessionId: string): Promise<TurnProjection[]>;
|
|
436
|
+
getSessionTurnsPage(sessionId: string, options?: SessionTurnsQuery, init?: RequestInit): Promise<SessionTurnsPage>;
|
|
437
|
+
/**
|
|
438
|
+
* 当前分支上可导航的用户发言目录(消息导航侧栏)。
|
|
439
|
+
*
|
|
440
|
+
* 只回 id、标题和时间:侧栏要列的是**整条会话**的发言,而窗口外的发言 id 只能
|
|
441
|
+
* 从服务端拿;消息体仍然走 `/turns`。
|
|
442
|
+
*/
|
|
443
|
+
getSessionTurnIndex(sessionId: string): Promise<SessionTurnIndex>;
|
|
444
|
+
getMcpAppContext(sessionId: string, sourceId: string, init?: RequestInit): Promise<McpAppContextState>;
|
|
445
|
+
updateMcpAppContext(sessionId: string, sourceId: string, body: McpAppContextUpdate, init?: RequestInit): Promise<{
|
|
446
|
+
status: "accepted";
|
|
447
|
+
revision: string;
|
|
448
|
+
}>;
|
|
449
|
+
getSessionTurnCommands(sessionId: string): Promise<HistoricalCommand[]>;
|
|
265
450
|
listResultFeedback(sessionId: string): Promise<ResultFeedback[]>;
|
|
266
451
|
putResultFeedback(sessionId: string, assistantEntryId: string, feedback: {
|
|
267
452
|
helpful: boolean;
|
|
@@ -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,49 @@
|
|
|
1
|
+
export type ContextAction = "published" | "retained" | "removed";
|
|
2
|
+
/** Safe display-source metadata retained for headless consumers. */
|
|
3
|
+
export type ContextSourceInfo = Record<string, unknown>;
|
|
4
|
+
export interface ContextProjectionData {
|
|
5
|
+
context_kind: string;
|
|
6
|
+
context_key: string;
|
|
7
|
+
context_name: string;
|
|
8
|
+
context_order: number;
|
|
9
|
+
context_action: ContextAction;
|
|
10
|
+
context_revision: string;
|
|
11
|
+
display_title?: string | null;
|
|
12
|
+
display_summary?: string | null;
|
|
13
|
+
sources: ContextSourceInfo[];
|
|
14
|
+
}
|
|
15
|
+
export interface ContextProjectionFields {
|
|
16
|
+
context_kind?: string | null;
|
|
17
|
+
context_key?: string | null;
|
|
18
|
+
context_name?: string | null;
|
|
19
|
+
context_order?: number | null;
|
|
20
|
+
context_action?: ContextAction | null;
|
|
21
|
+
context_revision?: string | null;
|
|
22
|
+
display_title?: string | null;
|
|
23
|
+
display_summary?: string | null;
|
|
24
|
+
sources?: ContextSourceInfo[] | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ContextDisplayState {
|
|
27
|
+
title: string;
|
|
28
|
+
summary: string;
|
|
29
|
+
detail: string;
|
|
30
|
+
isRemoved: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface ContextGroupDisplayState {
|
|
33
|
+
title: string;
|
|
34
|
+
summary: string;
|
|
35
|
+
count: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function contextProjectionData(fields: ContextProjectionFields): ContextProjectionData | null;
|
|
38
|
+
/** The single status-to-display mapping used by both React chat surfaces. */
|
|
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;
|
package/dist/schemas/event.d.ts
CHANGED
|
@@ -11,6 +11,15 @@ export interface ToolCallCreated {
|
|
|
11
11
|
arguments: string;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
export interface ToolCallArgumentsDelta {
|
|
15
|
+
index: number;
|
|
16
|
+
id: string;
|
|
17
|
+
loop_name?: string;
|
|
18
|
+
function: {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
arguments_delta: string;
|
|
22
|
+
}
|
|
14
23
|
export interface ToolResultDone {
|
|
15
24
|
tool_call_id: string;
|
|
16
25
|
loop_name?: string;
|
|
@@ -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
|
+
}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import type { ChatMessage, FileContentPart, ImageUrlContentPart, MessageContent } from "./message";
|
|
2
|
+
/** Ordinary chat uses business copy; developer mode may retain diagnostics. */
|
|
3
|
+
export declare function chatErrorForDisplay(message: string, developer?: boolean): string;
|
|
2
4
|
export declare function normalizeMessageContent(content: unknown): MessageContent;
|
|
3
5
|
export declare function getTextContent(content: MessageContent): string;
|
|
4
6
|
export declare function isSystemReminderText(text: string): boolean;
|
|
5
7
|
export declare function isLegacyForkContextText(text: string): boolean;
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 平台自己写进去、不该露给用户的内部提示。
|
|
10
|
+
*
|
|
11
|
+
* 服务端的消息导航目录有一份同名同语义的 Python 实现
|
|
12
|
+
* (`server/.../routes/sessions.py` 的 `_is_hidden_internal_message`):客户端靠它决定
|
|
13
|
+
* 渲染不渲染,服务端靠它决定进不进目录。改这里必须同时改那边,否则目录会列出没有对应
|
|
14
|
+
* 行的死条目,或者把内部提示原文当标题露出去。
|
|
15
|
+
*/
|
|
16
|
+
export declare function isHiddenInternalMessage(message: Pick<ChatMessage, "role" | "content">, options?: {
|
|
17
|
+
includeLegacyForkContext?: boolean;
|
|
18
|
+
}): boolean;
|
|
7
19
|
export declare function buildMessageContent(text: string, attachments: Array<{
|
|
8
20
|
kind: "file";
|
|
9
21
|
name: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContentBlock, PendingQuestionRef, ToolBridgeContent } from "./projection";
|
|
2
|
+
import type { ContextProjectionData } from "./context";
|
|
2
3
|
export interface TextContentPart {
|
|
3
4
|
type: "text";
|
|
4
5
|
text: string;
|
|
@@ -82,4 +83,6 @@ export interface ChatMessage {
|
|
|
82
83
|
blocks?: ContentBlock[];
|
|
83
84
|
/** Compaction metadata for compaction turns. */
|
|
84
85
|
compaction?: CompactionInfo;
|
|
86
|
+
/** Sourced Context metadata for rendering or headless consumers. */
|
|
87
|
+
context?: ContextProjectionData;
|
|
85
88
|
}
|