@blade-hq/agent-client 1.1.12-beta.4 → 1.2.0-beta.2

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.
@@ -115,6 +115,21 @@ export type UploadFileEntry = File | {
115
115
  export interface UploadFilesOptions {
116
116
  onProgress?: (progress: UploadProgress) => void;
117
117
  }
118
+ export interface AppCliDefinition {
119
+ /** 智能体在 Bash 中直接执行的业务命令名,例如 `library`。 */
120
+ command: string;
121
+ /** Python 脚本由沙盒系统 Python 执行;executable 必须是 Linux 可执行文件。 */
122
+ runtime: "python" | "executable";
123
+ /** CLI 文件本身,或浏览器可以读取的 URL。 */
124
+ source: Blob | string | URL;
125
+ /** source 是普通 Blob 时使用的上传文件名。 */
126
+ filename?: string;
127
+ }
128
+ export interface AppCliAttachment {
129
+ command: string;
130
+ runtime: "python" | "executable";
131
+ digest: string;
132
+ }
118
133
  export interface ImportPreviewSkill {
119
134
  name: string;
120
135
  description: string;
@@ -241,6 +256,7 @@ export declare class SessionsResource {
241
256
  }>;
242
257
  probeSessionUrl(sessionId: string, url: string): Promise<{
243
258
  reachable: boolean;
259
+ requires_proxy: boolean;
244
260
  }>;
245
261
  listDir(sessionId: string, dirPath: string): Promise<FileEntry[]>;
246
262
  countFiles(sessionId: string, dirPath?: string): Promise<number>;
@@ -250,6 +266,8 @@ export declare class SessionsResource {
250
266
  uploaded: string[];
251
267
  failed: string[];
252
268
  }>;
269
+ /** 把应用自己的业务 CLI 安装到会话沙盒,并保留开发者声明的命令名。 */
270
+ attachAppCli(sessionId: string, definition: AppCliDefinition): Promise<AppCliAttachment>;
253
271
  deleteFile(sessionId: string, filePath: string): Promise<void>;
254
272
  writeFile(sessionId: string, filePath: string, content: string): Promise<{
255
273
  success: boolean;
@@ -4,7 +4,7 @@ import type { PatchEnvelope, TurnProjection } from "../schemas/projection";
4
4
  import type { SessionStatus } from "../schemas/session";
5
5
  import { type CommandHandler } from "../commands/registry";
6
6
  import { type AgentSessionEvents } from "./events";
7
- import type { FileEntry } from "../resources/sessions";
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 {
@@ -15,8 +15,15 @@ export interface SessionRuntime {
15
15
  listDir(sessionId: string, dirPath: string): Promise<FileEntry[]>;
16
16
  countFiles(sessionId: string, dirPath?: string): Promise<number>;
17
17
  downloadFile(sessionId: string, filePath: string, downloadName?: string): Promise<void>;
18
+ attachAppCli(sessionId: string, definition: AppCliDefinition): Promise<AppCliAttachment>;
18
19
  onDispose(session: AgentSession): void;
19
20
  }
21
+ export interface AttachAppOptions {
22
+ /** 可选;只需要页面上下文时无需提供 CLI。 */
23
+ cli?: AppCliDefinition;
24
+ /** 每次发送前执行一次;返回当前页面状态的 JSON 对象快照。 */
25
+ getContext: () => Record<string, unknown> | Promise<Record<string, unknown>>;
26
+ }
20
27
  export interface SendOptions {
21
28
  /** planning / executing 模式。 */
22
29
  mode?: string;
@@ -58,6 +65,8 @@ export declare class AgentSession {
58
65
  private pendingReplayMode;
59
66
  private recentChatEndAt;
60
67
  private disposed;
68
+ private getAppContext;
69
+ private sendPending;
61
70
  private readonly deliveredCommandKeys;
62
71
  private readonly deliveredToolPreviews;
63
72
  private readonly oomNotifiedKeys;
@@ -83,8 +92,15 @@ export declare class AgentSession {
83
92
  * "map.highlight"),由你和技能作者约定;注册前到达的指令会被缓冲补投。
84
93
  */
85
94
  onCommand(action: string, handler: CommandHandler): () => void;
95
+ /**
96
+ * 声明当前应用提供的页面上下文和业务 CLI。
97
+ *
98
+ * CLI 安装成功后才保存 getContext;之后每次 send 前恰好读取一次。
99
+ */
100
+ attachApp(options: AttachAppOptions): Promise<AppCliAttachment | null>;
86
101
  /** 发送一条消息。字符串或多模态内容均可。 */
87
102
  send(content: MessageContent, options?: SendOptions): Promise<void>;
103
+ private sendUnlocked;
88
104
  /** 智能体运行期间追加补充说明(不打断当前回复)。 */
89
105
  append(text: string): void;
90
106
  /** 停止当前回复。 */
@@ -29,6 +29,7 @@ export declare class ClientProjectionBuilder {
29
29
  processEvent(event: RawEvent): ProjectionUpdate[] | null;
30
30
  reset(): void;
31
31
  seedSequence(maxSeq: number): void;
32
+ _seedTurns(turns: TurnProjection[]): void;
32
33
  private onMemoryInject;
33
34
  private onLoopTurn;
34
35
  private onModeChange;
@@ -39,6 +40,7 @@ export declare class ClientProjectionBuilder {
39
40
  private onBgTasksCompleted;
40
41
  private onAskUserAnswer;
41
42
  private onUserMessage;
43
+ private onPostChatFollowup;
42
44
  private onDelta;
43
45
  private onToolCallCreated;
44
46
  private onResponseDone;
@@ -27,6 +27,9 @@ export declare namespace ChatSendPayloadSchema {
27
27
  type RuntimeEnv = ({
28
28
  [k: string]: string;
29
29
  } | null);
30
+ type AppContext = ({
31
+ [k: string]: unknown;
32
+ } | null);
30
33
  type CompactionRatio = (number | null);
31
34
  interface ChatSendPayload {
32
35
  session_id: SessionId;
@@ -41,6 +44,7 @@ export declare namespace ChatSendPayloadSchema {
41
44
  whatif?: (WhatIfPayload | null);
42
45
  replay_decision?: ReplayDecision;
43
46
  runtime_env?: RuntimeEnv;
47
+ app_context?: AppContext;
44
48
  compaction_ratio?: CompactionRatio;
45
49
  [k: string]: unknown;
46
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blade-hq/agent-client",
3
- "version": "1.1.12-beta.4",
3
+ "version": "1.2.0-beta.2",
4
4
  "description": "Blade Agent 框架无关客户端:会话实时状态机、REST 通道、弹窗登录、页面协作。浏览器与 Node.js 通用。",
5
5
  "repository": {
6
6
  "type": "git",
package/public-api.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > 本文件由 `scripts/public-api-report.mjs` 生成,请勿手改。
4
4
  > 公共面变更时重新生成本报告,并同步更新 README 对应章节——CI 会校验两者。
5
5
 
6
- 共 111 个公开声明。
6
+ 共 114 个公开声明。
7
7
 
8
8
  ## `ActiveCompactionState` (interface)
9
9
 
@@ -37,6 +37,7 @@ toolCallId: string
37
37
  ```ts
38
38
  append: (text: string) => void
39
39
  attach: (label: string, data: unknown) => void
40
+ attachApp: (options: AttachAppOptions) => Promise<AppCliAttachment | null>
40
41
  compact: () => Promise<Record<string, unknown>>
41
42
  countFiles: (dirPath?: string) => Promise<number>
42
43
  dispose: () => void
@@ -84,6 +85,23 @@ toolResult: { toolCall: ToolCallInfo; turn: TurnProjection; }
84
85
  workspaceChanged: { filePath?: string; }
85
86
  ```
86
87
 
88
+ ## `AppCliAttachment` (interface)
89
+
90
+ ```ts
91
+ command: string
92
+ digest: string
93
+ runtime: "python" | "executable"
94
+ ```
95
+
96
+ ## `AppCliDefinition` (interface)
97
+
98
+ ```ts
99
+ command: string
100
+ filename: string | undefined
101
+ runtime: "python" | "executable"
102
+ source: string | Blob | URL
103
+ ```
104
+
87
105
  ## `ArchivedFileInfo` (interface)
88
106
 
89
107
  ```ts
@@ -119,6 +137,13 @@ export type AsrAudioPayload =
119
137
  | { pcm: ArrayBuffer | Uint8Array; request_id?: string }
120
138
  ```
121
139
 
140
+ ## `AttachAppOptions` (interface)
141
+
142
+ ```ts
143
+ cli: AppCliDefinition | undefined
144
+ getContext: () => Record<string, unknown> | Promise<Record<string, unknown>>
145
+ ```
146
+
122
147
  ## `AuthResource` (class)
123
148
 
124
149
  ```ts
@@ -857,6 +882,7 @@ export type SessionSetupStage = "solution" | "session" | "skill" | "connection"
857
882
  ## `SessionsResource` (class)
858
883
 
859
884
  ```ts
885
+ attachAppCli: (sessionId: string, definition: AppCliDefinition) => Promise<AppCliAttachment>
860
886
  checkoutSession: (sessionId: string, checkpointId: string, position: "before" | "turn_end", mode?: "both" | "conversation" | "code", linear?: boolean) => Promise<{ id: string; content: string; position: string; mode?: string; files_restored?: boolean; linear?: boolean; }>
861
887
  connect: (sessionId: string) => Promise<AgentSession>
862
888
  copyFile: (sessionId: string, filePath: string) => Promise<{ path: string; }>
@@ -887,7 +913,7 @@ listSessionsPaginated: (params: { limit: number; offset: number; template_id_pre
887
913
  listSessionsWithSkillData: () => Promise<SkillDevSession[]>
888
914
  pinSession: (sessionId: string, pinned: boolean) => Promise<SessionInfo>
889
915
  previewImport: (file: File) => Promise<ImportPreview>
890
- probeSessionUrl: (sessionId: string, url: string) => Promise<{ reachable: boolean; }>
916
+ probeSessionUrl: (sessionId: string, url: string) => Promise<{ reachable: boolean; requires_proxy: boolean; }>
891
917
  renameFile: (sessionId: string, filePath: string, newName: string) => Promise<{ path: string; }>
892
918
  revokeShare: (sessionId: string, token: string) => Promise<{ revoked: boolean; }>
893
919
  rewindSession: (sessionId: string, checkpointId: string) => Promise<{ id: string; content: string; }>