@blade-hq/agent-client 2612.0.0-beta.7 → 2612.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.
Files changed (95) hide show
  1. package/README.md +352 -34
  2. package/dist/application-client.d.ts +19 -0
  3. package/dist/blade-client.d.ts +25 -9
  4. package/dist/{chunk-E7J2JBML.js → chunk-DMVWOTJB.js} +1588 -391
  5. package/dist/chunk-DMVWOTJB.js.map +1 -0
  6. package/dist/index.d.ts +18 -5
  7. package/dist/index.js +15 -1
  8. package/dist/internal.d.ts +12 -4
  9. package/dist/internal.js +29 -3
  10. package/dist/internal.js.map +1 -1
  11. package/dist/resources/auth.d.ts +9 -1
  12. package/dist/resources/computers.d.ts +2 -7
  13. package/dist/resources/connectors.d.ts +323 -0
  14. package/dist/resources/headless.d.ts +1 -1
  15. package/dist/resources/llm.d.ts +64 -0
  16. package/dist/resources/models.d.ts +6 -1
  17. package/dist/resources/phones.d.ts +109 -0
  18. package/dist/resources/plugins.d.ts +22 -0
  19. package/dist/resources/sandbox.d.ts +22 -0
  20. package/dist/resources/sessions.d.ts +105 -10
  21. package/dist/schemas/ask-user-question.d.ts +21 -0
  22. package/dist/schemas/context-attachments.d.ts +18 -0
  23. package/dist/schemas/message-utils.d.ts +3 -9
  24. package/dist/schemas/message.d.ts +16 -2
  25. package/dist/schemas/plugin-refs.d.ts +7 -0
  26. package/dist/schemas/projection.d.ts +14 -1
  27. package/dist/schemas/session.d.ts +2 -48
  28. package/dist/server-clock.d.ts +2 -0
  29. package/dist/session/agent-session.d.ts +44 -95
  30. package/dist/session/definition.d.ts +3 -0
  31. package/dist/session/events.d.ts +0 -1
  32. package/dist/session/hub.d.ts +0 -24
  33. package/dist/session/state.d.ts +8 -1
  34. package/dist/session/workflow.d.ts +10 -3
  35. package/dist/shared/projection/builder.d.ts +0 -2
  36. package/dist/shared/projection/index.d.ts +1 -0
  37. package/dist/shared/projection/workflow.d.ts +24 -0
  38. package/dist/tool-provider.d.ts +60 -0
  39. package/dist/types/socket-events.d.ts +167 -11
  40. package/dist/version.d.ts +0 -1
  41. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +2 -3
  42. package/node_modules/engine.io-client/build/cjs/index.d.ts +3 -3
  43. package/node_modules/engine.io-client/build/cjs/index.js +1 -4
  44. package/node_modules/engine.io-client/build/cjs/socket.d.ts +39 -82
  45. package/node_modules/engine.io-client/build/cjs/socket.js +151 -218
  46. package/node_modules/engine.io-client/build/cjs/transport.d.ts +1 -1
  47. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +4 -4
  48. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +2 -2
  49. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +17 -7
  50. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +17 -7
  51. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +2 -3
  52. package/node_modules/engine.io-client/build/esm/index.d.ts +3 -3
  53. package/node_modules/engine.io-client/build/esm/index.js +1 -2
  54. package/node_modules/engine.io-client/build/esm/socket.d.ts +39 -82
  55. package/node_modules/engine.io-client/build/esm/socket.js +141 -206
  56. package/node_modules/engine.io-client/build/esm/transport.d.ts +1 -1
  57. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +4 -4
  58. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +2 -2
  59. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +2 -3
  60. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +3 -3
  61. package/node_modules/engine.io-client/build/esm-debug/index.js +1 -2
  62. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +39 -82
  63. package/node_modules/engine.io-client/build/esm-debug/socket.js +150 -215
  64. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +1 -1
  65. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +4 -4
  66. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +2 -2
  67. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +3 -3
  68. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -1
  69. package/node_modules/engine.io-client/dist/engine.io.js +164 -239
  70. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -1
  71. package/node_modules/engine.io-client/dist/engine.io.min.js +3 -3
  72. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -1
  73. package/node_modules/engine.io-client/package.json +2 -2
  74. package/node_modules/socket.io-parser/build/cjs/binary.js +4 -1
  75. package/node_modules/socket.io-parser/build/cjs/index.d.ts +14 -4
  76. package/node_modules/socket.io-parser/build/cjs/index.js +18 -11
  77. package/node_modules/socket.io-parser/build/esm/binary.js +4 -1
  78. package/node_modules/socket.io-parser/build/esm/index.d.ts +14 -4
  79. package/node_modules/socket.io-parser/build/esm/index.js +14 -10
  80. package/node_modules/socket.io-parser/build/esm-debug/binary.js +4 -1
  81. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +14 -4
  82. package/node_modules/socket.io-parser/build/esm-debug/index.js +14 -10
  83. package/node_modules/socket.io-parser/package.json +1 -1
  84. package/node_modules/ws/index.js +15 -6
  85. package/node_modules/ws/lib/constants.js +1 -0
  86. package/node_modules/ws/lib/permessage-deflate.js +9 -7
  87. package/node_modules/ws/lib/receiver.js +37 -0
  88. package/node_modules/ws/lib/sender.js +6 -1
  89. package/node_modules/ws/lib/websocket-server.js +18 -6
  90. package/node_modules/ws/lib/websocket.js +50 -17
  91. package/node_modules/ws/package.json +8 -3
  92. package/node_modules/ws/wrapper.mjs +14 -1
  93. package/package.json +4 -4
  94. package/public-api.md +662 -36
  95. package/dist/chunk-E7J2JBML.js.map +0 -1
@@ -0,0 +1,323 @@
1
+ export declare function isLocalConnectorName(name: string): boolean;
2
+ import type { BladeClient } from "../blade-client";
3
+ import type { SessionPluginConfigState, SessionPluginConfigUpdate } from "./sessions";
4
+ export interface ConnectorConnection {
5
+ status: "disconnected" | "connected" | "auth_required";
6
+ revision: number;
7
+ account_label: string;
8
+ verified_at: string;
9
+ }
10
+ export interface AccountConnector {
11
+ /** Package image as a data URL; absent when the package has no valid icon. */
12
+ icon?: string | null;
13
+ available?: boolean;
14
+ authorization?: {
15
+ type: "browser" | "device" | "managed";
16
+ url: string;
17
+ } | null;
18
+ name: string;
19
+ display_name: string;
20
+ operations: number;
21
+ connection: ConnectorConnection;
22
+ description: string;
23
+ source: "personal" | "builtin";
24
+ active: boolean;
25
+ }
26
+ export interface ConnectorDraft {
27
+ display_name: string;
28
+ description: string;
29
+ url?: string;
30
+ bearer_token?: string;
31
+ }
32
+ export interface ConnectorConnectionView {
33
+ url?: string | null;
34
+ description?: string;
35
+ display_name?: string;
36
+ authorization?: {
37
+ type: "browser" | "device" | "managed";
38
+ url: string;
39
+ } | null;
40
+ name: string;
41
+ config: SessionPluginConfigState;
42
+ connection: ConnectorConnection;
43
+ }
44
+ /** Platform approval classification with a verifiable source; unknown is not exemption. */
45
+ export type ConnectorApprovalStatus = "exempt" | "review_required" | "unknown";
46
+ export interface ConnectorDomain {
47
+ id: string;
48
+ name: string;
49
+ description?: string;
50
+ }
51
+ /** SW reports each capability independently; BA controls only its local binding. */
52
+ export interface ConnectorCapability {
53
+ category?: string;
54
+ category_name?: string;
55
+ tool_name?: string;
56
+ /** The local selection key; operation id may instead be its MCP tool name. */
57
+ capability_id?: string;
58
+ approval?: ConnectorApprovalStatus;
59
+ approval_evidence?: string;
60
+ effect?: string;
61
+ /** SW implements this operation; current permission availability is reported by status. */
62
+ executable?: boolean;
63
+ id: string;
64
+ name: string;
65
+ identity: "bot" | "user";
66
+ status: "available" | "not_selected" | "permission_required" | "user_auth_required" | "app_required" | "unsupported" | "unknown" | "temporarily_unavailable";
67
+ scopes: string[];
68
+ /** Alternative grants accepted by SW for this capability. */
69
+ scope_alternatives?: string[];
70
+ /** Grants that remain required alongside the resolved alternative. */
71
+ required_scopes?: string[];
72
+ description: string;
73
+ limitations: string[];
74
+ default?: boolean;
75
+ reason?: string;
76
+ next_action?: string;
77
+ actor?: string;
78
+ evidence?: string;
79
+ verified_at?: number;
80
+ }
81
+ export interface ConnectorPermission {
82
+ /** Application activation and personal consent are independent. */
83
+ app_status?: "granted" | "missing" | "unknown";
84
+ user_status?: "granted" | "not_granted" | "unknown";
85
+ category_name?: string;
86
+ template?: boolean;
87
+ scope: string;
88
+ name: string;
89
+ identity: "bot" | "user";
90
+ description?: string;
91
+ approval?: string;
92
+ approval_status?: ConnectorApprovalStatus;
93
+ approval_evidence?: string;
94
+ status?: string;
95
+ evidence?: string;
96
+ }
97
+ export interface ConnectorAuthorizationFailure {
98
+ code: string;
99
+ message: string;
100
+ retryable: boolean;
101
+ next_action?: string;
102
+ platform_code?: string;
103
+ platform_request_id?: string;
104
+ trace_id: string;
105
+ }
106
+ export interface ConnectorAuthorizationStep {
107
+ action?: string;
108
+ id: string;
109
+ state: string;
110
+ message: string;
111
+ capabilities?: string[];
112
+ /** Unix milliseconds. */
113
+ at: number;
114
+ }
115
+ export interface ConnectorAuthorization {
116
+ provider?: "feishu" | "qq-mail" | "netease-mail";
117
+ /** Public identity from SW; never a credential or execution authority. */
118
+ push_identity?: {
119
+ platform: "feishu" | "email";
120
+ connection_id: string;
121
+ app_id?: string;
122
+ };
123
+ reference_scope?: {
124
+ connection_id: string;
125
+ app_id?: string;
126
+ };
127
+ authorization_result?: {
128
+ status: "waiting" | "complete" | "partial" | "incomplete";
129
+ mode: "automatic" | "manual";
130
+ capabilities: string[];
131
+ missing_permissions: {
132
+ scope: string;
133
+ identity: "bot" | "user";
134
+ status: string;
135
+ }[];
136
+ next_action: string;
137
+ manual_url?: string;
138
+ };
139
+ permission_template?: {
140
+ id: string;
141
+ name: string;
142
+ source: string;
143
+ };
144
+ catalog_revision?: string;
145
+ domains?: ConnectorDomain[];
146
+ operations?: ConnectorCapability[];
147
+ current_step?: ConnectorAuthorizationStep;
148
+ /** The old binding is gone; the initial capability directory can be retried. */
149
+ catalog_unavailable?: boolean;
150
+ connected?: boolean;
151
+ /** Local BA binding. Disabling it leaves the SW account and PA subscription intact. */
152
+ enabled?: boolean;
153
+ /** A new binding is waiting for its first finish; explicit disablement clears this intent. */
154
+ activation_pending?: boolean;
155
+ connection_id?: string;
156
+ revision?: number;
157
+ phase: "disconnected" | "authorization_required" | "connected" | "app" | "app_ready" | "permissions" | "user" | "expired" | "ready";
158
+ authorization_url?: string;
159
+ /** Unix seconds. */
160
+ expires_at?: number;
161
+ app_id?: string;
162
+ label?: string;
163
+ user_authorized: boolean;
164
+ delivery_bound: boolean;
165
+ subscription_state?: "not_bound" | "enabled" | "paused" | "missing";
166
+ capabilities?: ConnectorCapability[];
167
+ permissions?: ConnectorPermission[];
168
+ selected_capabilities?: string[];
169
+ steps?: ConnectorAuthorizationStep[];
170
+ attempt_id?: string;
171
+ trace_id?: string;
172
+ error?: ConnectorAuthorizationFailure;
173
+ }
174
+ export interface ConnectorAuthorizationOptions {
175
+ /** 仅 credentials 动作使用;只透传给邮箱服务,不进入连接状态。 */
176
+ email?: string;
177
+ authorization_code?: string;
178
+ /** Bind an authorization step to the expected connection; required for remove. Never MCP authority. */
179
+ expected_connection_id?: string;
180
+ capabilities?: string[];
181
+ attempt_id?: string;
182
+ /** BA 在 finish 或 credentials 时应用;false 保留停用状态。 */
183
+ enable?: boolean;
184
+ }
185
+ export interface ConnectorAuthorizationPlan {
186
+ recovery_requirements?: Array<{
187
+ connection_id: string;
188
+ app_id: string;
189
+ capabilities: string[];
190
+ identity: "bot" | "user";
191
+ mode: "automatic" | "manual" | "enable";
192
+ required_scopes: string[];
193
+ scopes: string[];
194
+ next_action: string;
195
+ manual_url?: string;
196
+ }>;
197
+ capabilities: ConnectorCapability[];
198
+ requested_scopes: string[];
199
+ blocked_capabilities: string[];
200
+ permissions_url?: string;
201
+ ready_capabilities?: string[];
202
+ user_authorization_capabilities?: string[];
203
+ admin_review_capabilities?: string[];
204
+ unknown_capabilities?: string[];
205
+ unsupported_capabilities?: string[];
206
+ }
207
+ export interface ConnectorAuditEvent {
208
+ type?: string;
209
+ at_ms?: number;
210
+ platform_code?: string;
211
+ platform_request_id?: string;
212
+ id?: string | number;
213
+ trace_id?: string;
214
+ action?: string;
215
+ capability?: string;
216
+ outcome?: string;
217
+ code?: string;
218
+ message?: string;
219
+ at?: number;
220
+ [key: string]: unknown;
221
+ }
222
+ export interface ConnectorRuntimeDiagnostics {
223
+ account_id: string;
224
+ /** Last recorded channel event; it is not an independent live health check. */
225
+ channel_state: string;
226
+ last_event_at_ms: number;
227
+ channel_events: Array<{
228
+ trace_id: string;
229
+ at_ms: number;
230
+ type: string;
231
+ }>;
232
+ deliveries: Array<{
233
+ delivery_id: string;
234
+ status: string;
235
+ attempt: number;
236
+ next_at_ms: number;
237
+ created_at_ms: number;
238
+ }>;
239
+ delivery_attempts: Array<{
240
+ id: string | number;
241
+ delivery_id: string;
242
+ attempt: number;
243
+ started_at_ms: number;
244
+ finished_at_ms: number;
245
+ status: string;
246
+ }>;
247
+ }
248
+ export interface ConnectorDiagnostics {
249
+ connection: ConnectorAuthorization;
250
+ audit_events: ConnectorAuditEvent[];
251
+ runtime?: ConnectorRuntimeDiagnostics;
252
+ }
253
+ export type ConnectorAuthorizationAction = "authorize" | "credentials" | "permissions" | "pause" | "resume" | "app" | "user" | "poll" | "finish" | "bind" | "cancel" | "check" | "remove";
254
+ export interface ConnectorArtifact {
255
+ artifact_id: string;
256
+ name: string;
257
+ size: number;
258
+ sha256: string;
259
+ content_type: string;
260
+ expires_at?: number;
261
+ reference_scope: {
262
+ connection_id: string;
263
+ app_id?: string;
264
+ };
265
+ /** Authenticated same-origin path; use downloadFile rather than a public URL. */
266
+ download_path: string;
267
+ }
268
+ export declare class ConnectorsResource {
269
+ private client;
270
+ constructor(client: BladeClient);
271
+ /** Stage an explicit attachment in the current user's SW connection. Reuse requestId on retry. */
272
+ uploadFile(name: string, file: Blob, fileName: string, requestId: string): Promise<ConnectorArtifact>;
273
+ /** Fetch a private artifact through BA authentication; no SW PAT or public URL is exposed. */
274
+ downloadFile(name: string, artifactId: string): Promise<Blob>;
275
+ authorization(name: string, init?: RequestInit): Promise<ConnectorAuthorization>;
276
+ authorize(name: string, action: ConnectorAuthorizationAction, pushUrl?: string, options?: ConnectorAuthorizationOptions): Promise<ConnectorAuthorization>;
277
+ authorizationPlan(name: string, capabilities: string[]): Promise<ConnectorAuthorizationPlan>;
278
+ diagnostics(name: string, init?: RequestInit): Promise<ConnectorDiagnostics>;
279
+ create(draft: ConnectorDraft & {
280
+ url: string;
281
+ }): Promise<{
282
+ name: string;
283
+ }>;
284
+ update(name: string, draft: ConnectorDraft): Promise<{
285
+ name: string;
286
+ }>;
287
+ delete(name: string): Promise<{
288
+ name: string;
289
+ }>;
290
+ /** Create a generation conversation and send its visible Skill request.
291
+ * Hosts use onCreated only to register caches and navigate before sending. */
292
+ startGeneration({ connector, onCreated, initiator }?: {
293
+ connector?: Pick<AccountConnector, "name" | "display_name">;
294
+ onCreated?: (created: {
295
+ session_id: string;
296
+ intent: string;
297
+ }) => void | Promise<void>;
298
+ initiator?: "ui" | "sdk";
299
+ }): Promise<{
300
+ session_id: string;
301
+ sent: boolean;
302
+ }>;
303
+ list(init?: RequestInit): Promise<{
304
+ connectors: AccountConnector[];
305
+ }>;
306
+ listForSession(sessionId: string, init?: RequestInit): Promise<{
307
+ connectors: AccountConnector[];
308
+ }>;
309
+ read(name: string, init?: RequestInit): Promise<ConnectorConnectionView>;
310
+ connect(name: string, update: SessionPluginConfigUpdate & {
311
+ session_id?: string;
312
+ }, init?: RequestInit): Promise<ConnectorConnectionView>;
313
+ browserAuthorizationUrl(name: string): string;
314
+ /** One-use, one-minute identity handoff to this client's trusted Blade origin.
315
+ * Tokens travel only through a source/origin-bound message, never a URL/storage. */
316
+ bindBrowserAuthorizationFrame(frame: HTMLIFrameElement, name: string): () => void;
317
+ startBrowserAuthorization(name: string, sessionId?: string): Promise<{
318
+ session_id: string;
319
+ view: ConnectorConnectionView;
320
+ }>;
321
+ verify(name: string): Promise<ConnectorConnectionView>;
322
+ disconnect(name: string): Promise<ConnectorConnectionView>;
323
+ }
@@ -6,7 +6,7 @@ export interface HeadlessRunOptions {
6
6
  model?: string | null;
7
7
  timeoutMs?: number;
8
8
  /** Assets explicitly selected for this message in a topic-linked session. */
9
- refs?: import("../schemas/plugin-refs").PluginRef[];
9
+ refs?: import("../schemas/plugin-refs").MessageRef[];
10
10
  topicAssetRefs?: TopicAssetRef[];
11
11
  }
12
12
  export interface HeadlessRunInSessionResult<T = unknown> {
@@ -0,0 +1,64 @@
1
+ import type { BladeClient } from "../blade-client";
2
+ export interface ChatCompletionRequest {
3
+ model: string;
4
+ messages: {
5
+ role: string;
6
+ content?: unknown;
7
+ [key: string]: unknown;
8
+ }[];
9
+ tools?: {
10
+ type: "function";
11
+ function: {
12
+ name: string;
13
+ description?: string;
14
+ parameters: Record<string, unknown>;
15
+ };
16
+ }[];
17
+ tool_choice?: "auto" | "none" | "required" | {
18
+ type: "function";
19
+ function: {
20
+ name: string;
21
+ };
22
+ };
23
+ stream?: false;
24
+ [key: string]: unknown;
25
+ }
26
+ export interface ChatCompletion {
27
+ id: string;
28
+ object: "chat.completion";
29
+ created: number;
30
+ model: string;
31
+ choices: {
32
+ index: number;
33
+ finish_reason: string;
34
+ message: {
35
+ role: "assistant";
36
+ content: string | null;
37
+ tool_calls?: {
38
+ id: string;
39
+ type: "function";
40
+ function: {
41
+ name: string;
42
+ arguments: string;
43
+ };
44
+ }[];
45
+ };
46
+ }[];
47
+ usage?: {
48
+ prompt_tokens: number;
49
+ completion_tokens: number;
50
+ total_tokens: number;
51
+ };
52
+ }
53
+ /** One model call. Returned tool calls are data; BA does not execute them. */
54
+ export declare class LlmResource {
55
+ private client;
56
+ constructor(client: BladeClient);
57
+ readonly chat: {
58
+ completions: {
59
+ create: (body: ChatCompletionRequest, options?: {
60
+ signal?: AbortSignal;
61
+ }) => Promise<ChatCompletion>;
62
+ };
63
+ };
64
+ }
@@ -2,6 +2,9 @@ import type { BladeClient } from "../blade-client";
2
2
  export interface ModelOption {
3
3
  id: string;
4
4
  label: string;
5
+ thinkingAvailable?: boolean;
6
+ reasoningLevels?: string[];
7
+ defaultReasoningLevel?: string;
5
8
  /**
6
9
  * 把这个模型发给 `baseUrl` 时该用的名字。`id` 是平台内部标识,接了多个模型服务时
7
10
  * 形如 `provider-xxx::name`,直接发过去会被拒。不在 `baseUrl` 那个服务上的模型
@@ -35,5 +38,7 @@ export interface ModelCatalog {
35
38
  export declare class ModelsResource {
36
39
  private client;
37
40
  constructor(client: BladeClient);
38
- list(): Promise<ModelCatalog>;
41
+ list(options?: {
42
+ signal?: AbortSignal;
43
+ }): Promise<ModelCatalog>;
39
44
  }
@@ -0,0 +1,109 @@
1
+ import type { BladeClient } from "../blade-client";
2
+ /** 用户接进来的一台手机。 */
3
+ export interface PhoneDevice {
4
+ id: string;
5
+ /** 展示名,重名时后台会追加序号;用户可以认这个。 */
6
+ label: string;
7
+ /** `ro.serialno`,设备身份。智能体用它指定 `adb -s`。 */
8
+ serial: string;
9
+ model?: string | null;
10
+ android_version?: string | null;
11
+ created_at: string;
12
+ last_seen_at?: string | null;
13
+ /** 此刻隧道连着后台。由隧道服务实时判定,不读心跳时间。 */
14
+ online: boolean;
15
+ /**
16
+ * 沙盒里的 adb 此刻能不能对这台手机执行命令。
17
+ *
18
+ * 与 `online` 分开:手机连着但沙盒里没装 adb、或者 adb 认证没过,用户执行
19
+ * `adb shell` 照样失败,而 `online` 仍然是 true。
20
+ */
21
+ adb_online: boolean;
22
+ /** 本次会话已启用它。与 `online` 互相独立。 */
23
+ enabled: boolean;
24
+ /** 当前绑定到哪个会话;`null` 表示没有被任何会话使用。 */
25
+ session_id?: string | null;
26
+ }
27
+ export interface PhoneList {
28
+ phones: PhoneDevice[];
29
+ }
30
+ /** 用户级接入密钥。设置页只展示它,手机把它填进 App 就能连。 */
31
+ export interface PhoneAccessKey {
32
+ key: string;
33
+ /**
34
+ * **服务器地址本身**(协议+主机+端口),不带隧道路径。
35
+ *
36
+ * 由服务端从请求来源推导,不接受手填;手机 App 自己补 `/api/mobile/hub`。
37
+ * 用户看到的应该是 `http://agent.ba.test` 这样能一眼认出的地址,而不是一个
38
+ * 他不需要理解、还容易抄错的路径。
39
+ */
40
+ hub_url: string;
41
+ /**
42
+ * 手机连接器的下载地址。
43
+ *
44
+ * 默认是服务端的相对路径(`/api/phone/connector.apk`,由后端读构建产物发出去);
45
+ * 管理员可以配成自己的静态文件地址。相对路径由前端按当前 origin 展开。
46
+ */
47
+ connector_url: string;
48
+ }
49
+ export interface PhonePipeline {
50
+ running: boolean;
51
+ /** 最后一帧距今多久;-1 表示还没出过帧。静止画面不出帧是正常的。 */
52
+ last_frame_ago_ms: number;
53
+ viewers: number;
54
+ width: number;
55
+ height: number;
56
+ codec: string;
57
+ start_error: string;
58
+ }
59
+ export interface PhoneHealth {
60
+ online: boolean;
61
+ reason: string;
62
+ /** 沙盒已休眠(不是"手机坏了"),前端据此给"打开会话唤醒"而不是"重试"。 */
63
+ dormant: boolean;
64
+ pipeline: PhonePipeline | null;
65
+ }
66
+ /**
67
+ * 一台手机在界面上该显示成什么状态。
68
+ *
69
+ * 与 `computerState` 同形同语义:判定只写这一份,界面只管样式和排版。
70
+ * 两边各写一份必然会分叉,然后其中一边的兜底会把另一边的错误盖住。
71
+ */
72
+ export type PhoneState = "enabled" | "offline" | "idle";
73
+ export declare function phoneState(phone: PhoneDevice): PhoneState;
74
+ /** 列表顺序:按接入时间,稳定不变;不按在线状态重排。 */
75
+ export declare function sortPhones(phones: PhoneDevice[]): PhoneDevice[];
76
+ /** 手机的 adb 序列号,展示时用不会太长的那一截。 */
77
+ export declare function phoneSerialLabel(phone: PhoneDevice): string;
78
+ export declare class PhonesResource {
79
+ private client;
80
+ constructor(client: BladeClient);
81
+ /** 账号下的全部手机(不含"本次会话是否可用")。 */
82
+ listAccount(): Promise<PhoneList>;
83
+ /**
84
+ * 当前接入密钥;没有就补一个。
85
+ *
86
+ * **取的时候不轮换**:每次打开设置页都换钥匙会让已配好的手机集体掉线。
87
+ */
88
+ getKey(): Promise<PhoneAccessKey>;
89
+ /** 换一把新密钥(旧的立即失效)。 */
90
+ resetKey(): Promise<{
91
+ key: string;
92
+ }>;
93
+ /** 作废密钥;设备记录保留,用户下次取密钥会得到一把新的。 */
94
+ revokeKey(): Promise<void>;
95
+ remove(phoneId: string): Promise<void>;
96
+ /** 本次会话能用的手机 + 账号下的其他手机。 */
97
+ listForSession(sessionId: string): Promise<PhoneList>;
98
+ setEnabled(sessionId: string, phoneId: string, enabled: boolean): Promise<PhoneDevice>;
99
+ health(sessionId: string, phoneId: string): Promise<PhoneHealth>;
100
+ /**
101
+ * WHEP 信令:POST 一个 SDP offer,拿到 answer。
102
+ *
103
+ * 走 `textFromInit` 而不是 `json()`:SDP 是纯文本,`json()` 会强制序列化成
104
+ * JSON;也不能用裸 `fetch`,那会丢掉 bearer token。
105
+ */
106
+ whep(sessionId: string, phoneId: string, offerSdp: string): Promise<string>;
107
+ /** 用户点「刷新画面」:让后台重新确认隧道服务并忘掉记住的 token。 */
108
+ wake(sessionId: string, phoneId: string): Promise<void>;
109
+ }
@@ -1,4 +1,12 @@
1
1
  import type { BladeClient } from "../blade-client";
2
+ export interface PluginFileOpener {
3
+ id: string;
4
+ label: string;
5
+ extensions: string[];
6
+ server: string;
7
+ resource: string;
8
+ default?: boolean;
9
+ }
2
10
  /**
3
11
  * 一个插件在当前用户眼里的展示信息,**与会话无关**。
4
12
  *
@@ -18,6 +26,10 @@ export interface PluginCatalogEntry {
18
26
  /** 当前用户是否安装了它。 */
19
27
  auth_status?: "login_required" | "ready" | "expired" | "unavailable";
20
28
  installed: boolean;
29
+ /** Enable once when a new conversation is created. */
30
+ default_enabled?: boolean;
31
+ file_openers?: PluginFileOpener[];
32
+ connector?: boolean;
21
33
  }
22
34
  /**
23
35
  * 按用户读取的插件目录(无会话)。
@@ -27,7 +39,13 @@ export interface PluginCatalogEntry {
27
39
  */
28
40
  export declare class PluginsResource {
29
41
  private client;
42
+ private catalogSnapshot;
43
+ private pendingCatalog;
44
+ private catalogListeners;
30
45
  constructor(client: BladeClient);
46
+ /** Observe the directory loaded by existing plugin surfaces without starting a request. */
47
+ getCatalogSnapshot(): PluginCatalogEntry[] | undefined;
48
+ subscribeCatalog(listener: () => void): () => void;
31
49
  /**
32
50
  * 列出当前用户安装的插件及其展示信息。
33
51
  *
@@ -37,6 +55,10 @@ export declare class PluginsResource {
37
55
  catalog(init?: RequestInit): Promise<{
38
56
  plugins: PluginCatalogEntry[];
39
57
  }>;
58
+ /** Load once on demand; share both the snapshot and any request already in flight. */
59
+ ensureCatalog(): Promise<{
60
+ plugins: PluginCatalogEntry[];
61
+ }>;
40
62
  /** 取一个插件的包内图标字节(用户级,不需要会话)。 */
41
63
  fetchIcon(name: string): Promise<Blob>;
42
64
  /** 带凭据的图标地址;能直接用 blob URL 的地方优先用 `fetchIcon`。 */
@@ -0,0 +1,22 @@
1
+ import type { BladeClient } from "../blade-client";
2
+ export interface SandboxScriptRequest {
3
+ script: string;
4
+ cwd: string;
5
+ /** Seconds, up to 120; defaults to 120. */
6
+ timeout?: number;
7
+ }
8
+ export interface SandboxScriptResult {
9
+ /** Combined stdout and stderr for diagnostics. */
10
+ output: string;
11
+ stdout: string;
12
+ stdout_truncated: boolean;
13
+ exit_code: number | null;
14
+ timed_out: boolean;
15
+ error: string | null;
16
+ }
17
+ /** Model-free execution in the authenticated user's sandbox. */
18
+ export declare class SandboxResource {
19
+ private client;
20
+ constructor(client: BladeClient);
21
+ execute(input: SandboxScriptRequest): Promise<SandboxScriptResult>;
22
+ }