@blade-hq/agent-client 2612.0.0-beta.68 → 2612.0.0-beta.69

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 CHANGED
@@ -312,6 +312,27 @@ await client.sessions.updateSessionPluginConfig(id, "crm", {
312
312
  配置保持不变。平台只写用户 Home 下的 `~/.plugin/<plugin_id>/config.json`,不会
313
313
  重启 MCP、清缓存或刷新 token。
314
314
 
315
+ 文件打开方式由插件目录的 `file_openers` 声明,单项类型为 `PluginFileOpener`。
316
+ `client.plugins.getCatalogSnapshot()` 和 `subscribeCatalog()` 可观察已加载的目录;
317
+ `ensureCatalog()` 在缺少快照时按需加载,并与其他目录消费者共享在途请求。
318
+ 这些方法本身不会在客户端启动时请求目录。
319
+
320
+ 选定打开方式后,先用现有 `setSessionPluginActivation` 确保插件在对话中启用,再打开文件:
321
+
322
+ ```ts
323
+ const app: FileOpenerInstance = await client.sessions.openFileOpener(sessionId, {
324
+ plugin: "docx-opener-demo", opener: "edit", path: "公文/通知.docx",
325
+ })
326
+ const saved = await client.sessions.callFileOpener(sessionId, {
327
+ token: app.token, request_id: "save-1", name: "save_document", arguments: {},
328
+ file: "save", base_revision: app.file.revision,
329
+ })
330
+ ```
331
+
332
+ `FileOpenerInstance` 包含界面资源、文件信息和本次打开的令牌。
333
+ 保存成功后使用响应里的新版本;409 表示文件已变化,重新加载后再编辑。
334
+ 文件打开方式实例不进入聊天历史。
335
+
315
336
  ### 会话回放(演示 / 彩排)
316
337
 
317
338
  拿一个已经聊完的会话当素材,重现当时的回复和工具调用,**完全不调用模型**。
@@ -227,7 +227,7 @@ var ToolProvider = class {
227
227
 
228
228
  // src/version.ts
229
229
  var SDK_NAME = "agent-client";
230
- var SDK_VERSION = true ? "2612.0.0-beta.68" : "1.1.1";
230
+ var SDK_VERSION = true ? "2612.0.0-beta.69" : "1.1.1";
231
231
 
232
232
  // src/auth-login.ts
233
233
  function isAuthCallbackMessage(value) {
@@ -3625,6 +3625,20 @@ var SessionsResource = class {
3625
3625
  this.pendingImages.set(identity, pending);
3626
3626
  return pending;
3627
3627
  }
3628
+ openFileOpener(sessionId, body, init) {
3629
+ return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/file-openers:open`, {
3630
+ ...init,
3631
+ method: "POST",
3632
+ body: JSON.stringify(body)
3633
+ });
3634
+ }
3635
+ callFileOpener(sessionId, body, init) {
3636
+ return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/file-openers:call`, {
3637
+ ...init,
3638
+ method: "POST",
3639
+ body: JSON.stringify(body)
3640
+ });
3641
+ }
3628
3642
  getMcpApp(sessionId, sourceId, init) {
3629
3643
  return this.client.jsonFromInit(`/api/sessions/${encodeURIComponent(sessionId)}/mcp-apps/${encodeURIComponent(sourceId)}`, init);
3630
3644
  }
@@ -4258,6 +4272,19 @@ var PluginsResource = class {
4258
4272
  this.client = client;
4259
4273
  }
4260
4274
  client;
4275
+ catalogSnapshot;
4276
+ pendingCatalog;
4277
+ catalogListeners = /* @__PURE__ */ new Set();
4278
+ /** Observe the directory loaded by existing plugin surfaces without starting a request. */
4279
+ getCatalogSnapshot() {
4280
+ return this.catalogSnapshot?.token === this.client.token ? this.catalogSnapshot?.entries : void 0;
4281
+ }
4282
+ subscribeCatalog(listener) {
4283
+ this.catalogListeners.add(listener);
4284
+ return () => {
4285
+ this.catalogListeners.delete(listener);
4286
+ };
4287
+ }
4261
4288
  /**
4262
4289
  * 列出当前用户安装的插件及其展示信息。
4263
4290
  *
@@ -4265,7 +4292,24 @@ var PluginsResource = class {
4265
4292
  * 单个插件的展示信息读不出来只会降级成占位,不会让整份目录失败。
4266
4293
  */
4267
4294
  catalog(init) {
4268
- return this.client.jsonFromInit("/api/plugins/catalog", init);
4295
+ const token = this.client.token;
4296
+ if (!init && this.pendingCatalog && this.pendingCatalog.token === token) return this.pendingCatalog.request;
4297
+ const request = this.client.jsonFromInit("/api/plugins/catalog", init).then((result) => {
4298
+ if (token === this.client.token) {
4299
+ this.catalogSnapshot = { token, entries: result.plugins };
4300
+ for (const listener of this.catalogListeners) listener();
4301
+ }
4302
+ return result;
4303
+ }).finally(() => {
4304
+ if (this.pendingCatalog?.request === request) this.pendingCatalog = void 0;
4305
+ });
4306
+ if (!init) this.pendingCatalog = { token, request };
4307
+ return request;
4308
+ }
4309
+ /** Load once on demand; share both the snapshot and any request already in flight. */
4310
+ ensureCatalog() {
4311
+ const plugins = this.getCatalogSnapshot();
4312
+ return plugins ? Promise.resolve({ plugins }) : this.catalog();
4269
4313
  }
4270
4314
  /** 取一个插件的包内图标字节(用户级,不需要会话)。 */
4271
4315
  fetchIcon(name) {
@@ -9347,4 +9391,4 @@ export {
9347
9391
  parseAskUserQuestion,
9348
9392
  formatAskUserAnswer
9349
9393
  };
9350
- //# sourceMappingURL=chunk-T2R7FOOX.js.map
9394
+ //# sourceMappingURL=chunk-4W4L4K3J.js.map