@blade-hq/agent-client 2612.0.0-beta.71 → 2612.0.0-beta.73

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
@@ -1041,3 +1041,21 @@ BA 桌面使用同源 `/api/auth/sdk/desktop-session` 建立自身 cookie 会话
1041
1041
  `client.connectors` 的连接声明支持 `browser`、`device`、`managed`。`browser` 仍在用户沙盒打开登录页;`managed` 表示由部署绑定的 SW 管理认证,包内 url 为空,不要调用 `startBrowserAuthorization`。通过 `authorization(name)` 获取公共连接状态,通过 `authorize(name, "credentials", undefined, {email, authorization_code})` 提交卡片凭据并启用邮箱。凭据只透传给 SW,不进入 View、聊天或持久化状态;PAT 由 BA 服务端用于访问 SW。
1042
1042
 
1043
1043
  `push_identity` 是 SW 提供的公开事件身份,`reference_scope` 用于保留查询或文件来源,均不含凭据。飞书继续携带 app_id,邮箱只有 connection_id;不要替旧引用补当前来源,也不要为邮箱虚构应用编号。文件仍用鉴权的 `uploadFile` / `downloadFile`,不能直接请求 SW 或采信任意下载 URL。邮箱当前只交付通道与类型,品牌包、授权页面、共享连接 UI 及 PA 推送随后续任务切换。
1044
+
1045
+ ### 撤销应用提供的会话上下文
1046
+
1047
+ 带 `update_format` 的 `contextAttachments` 按稳定 `id` 更新会话 Context。
1048
+ 本轮未提供某个 ID 表示沿用原状态;下线来源时必须显式撤销:
1049
+
1050
+ ```ts
1051
+ session.prepareSend("继续处理", {
1052
+ contextAttachments: [{ id: "app:board", label: "工作摘要", content: "", action: "remove" }],
1053
+ })
1054
+ ```
1055
+
1056
+ 撤销不能同时携带正文、数据、文件或 `update_format`。BA 持久保存撤销结果,
1057
+ 压缩和恢复不再注入旧快照,原始历史仍可查看。普通快照(包括撤销前已经排队的快照)不会重新启用已撤销的来源。
1058
+ 需要重新启用时,用新请求显式提供 `action: "restore"` 和同一 ID 的完整快照
1059
+ (`update_format: "snapshot"` 或 `"diff"`)。可靠请求重试应复用原 `requestId`,不能换 ID 重发。
1060
+
1061
+ BA 默认提供内置定时任务。应用自行管理定时安排时,可在声明式会话的 `config.disableTools`(或 SDK profile 的 `disableTools`)传入 `["platform:schedule"]`;底层创建与配置更新请求使用 `disable_tools: ["platform:schedule"]`。该配置隐藏 BA 定时工具并阻止调用,不影响应用自己的定时安排,也不会停止已有 BA 任务。
@@ -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.71" : "1.1.1";
230
+ var SDK_VERSION = true ? "2612.0.0-beta.73" : "1.1.1";
231
231
 
232
232
  // src/auth-login.ts
233
233
  function isAuthCallbackMessage(value) {
@@ -467,7 +467,10 @@ function snapshotContextAttachments(value) {
467
467
  const ids = /* @__PURE__ */ new Set();
468
468
  const validText = (text, limit) => typeof text === "string" && [...text].length > 0 && [...text].length <= limit;
469
469
  for (const item of snapshot2) {
470
- if (!item || !validText(item.id, 128) || !validText(item.label, 512) || !validText(item.content, 64e3) || ids.has(item.id)) throw new Error("\u9644\u52A0\u8D44\u6599\u683C\u5F0F\u9519\u8BEF\u6216 ID \u91CD\u590D");
470
+ if (!item || !validText(item.id, 128) || !validText(item.label, 512) || item.action !== "remove" && !validText(item.content, 64e3) || ids.has(item.id)) throw new Error("\u9644\u52A0\u8D44\u6599\u683C\u5F0F\u9519\u8BEF\u6216 ID \u91CD\u590D");
471
+ if (item.action != null && item.action !== "remove" && item.action !== "restore") throw new Error("\u8D44\u6599\u64CD\u4F5C\u65E0\u6548");
472
+ if (item.action === "restore" && item.update_format === void 0) throw new Error("\u6062\u590D\u4F1A\u8BDD\u8D44\u6599\u9700\u8981\u63D0\u4F9B\u5B8C\u6574\u5FEB\u7167\u7684\u66F4\u65B0\u683C\u5F0F");
473
+ if (item.action === "remove" && (item.content !== "" || item.data != null || (item.files?.length ?? 0) > 0 || item.update_format !== void 0)) throw new Error("\u64A4\u9500\u8D44\u6599\u4E0D\u80FD\u540C\u65F6\u63D0\u4F9B\u6B63\u6587\u3001\u6570\u636E\u3001\u6587\u4EF6\u6216\u66F4\u65B0\u683C\u5F0F");
471
474
  ids.add(item.id);
472
475
  if (item.update_format !== void 0 && item.update_format !== "snapshot" && item.update_format !== "diff") throw new Error("\u8D44\u6599\u66F4\u65B0\u683C\u5F0F\u65E0\u6548");
473
476
  if (item.data != null && (typeof item.data !== "object" || Array.isArray(item.data))) throw new Error("\u8D44\u6599\u6570\u636E\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
@@ -3518,6 +3521,7 @@ var SessionInfo = type({
3518
3521
  "is_persistent?": "boolean",
3519
3522
  "initiator?": "'ui' | 'sdk' | 'unknown' | null",
3520
3523
  "is_headless?": "boolean",
3524
+ "scheduled_task_id?": "string",
3521
3525
  "viewer_role?": "'owner' | 'viewer'",
3522
3526
  "model?": "string | null",
3523
3527
  "enable_thinking?": "boolean | null",
@@ -3586,6 +3590,7 @@ var builtinSolutionIds = /* @__PURE__ */ new Set([
3586
3590
  "app-dev",
3587
3591
  "general_chat",
3588
3592
  "night_build",
3593
+ "scheduled_tasks",
3589
3594
  "skill_editor",
3590
3595
  "smart_bid",
3591
3596
  "solution_generate"
@@ -5923,6 +5928,7 @@ var AgentSession = class _AgentSession {
5923
5928
  lastDeliveredSystemError = null;
5924
5929
  systemErrorGeneration = 0;
5925
5930
  subscriptionReplaySource = null;
5931
+ lifetimeAbort = new AbortController();
5926
5932
  disposed = false;
5927
5933
  getAppContext = null;
5928
5934
  sendPending = false;
@@ -6687,6 +6693,7 @@ var AgentSession = class _AgentSession {
6687
6693
  if (this.disposed) return;
6688
6694
  if (!this.runtime.onDispose(this)) return;
6689
6695
  this.disposed = true;
6696
+ this.lifetimeAbort.abort();
6690
6697
  this.invalidateTimeline();
6691
6698
  this.invalidateOlderPaging();
6692
6699
  this.state = { ...this.state, nextBefore: null, loadingOlder: false };
@@ -7611,7 +7618,41 @@ var AgentSession = class _AgentSession {
7611
7618
  return join;
7612
7619
  }
7613
7620
  async ensureIdleBeforeSend() {
7614
- if (this.state.isStreaming) return;
7621
+ if (this.disposed) throw new AgentSessionError("\u4F1A\u8BDD\u5DF2\u5173\u95ED\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\u3002", "session_disposed");
7622
+ if (this.state.status === "waiting_for_input" && this.state.isStreaming) {
7623
+ await new Promise((resolve, reject) => {
7624
+ const signal = this.lifetimeAbort.signal;
7625
+ const finish = (error) => {
7626
+ globalThis.clearTimeout(timeout);
7627
+ unsubscribe();
7628
+ offEnd();
7629
+ offError();
7630
+ signal.removeEventListener("abort", onDispose);
7631
+ if (error) reject(error);
7632
+ else resolve();
7633
+ };
7634
+ const onDispose = () => finish(new AgentSessionError("\u4F1A\u8BDD\u5DF2\u5173\u95ED\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\u3002", "session_disposed"));
7635
+ const timeout = globalThis.setTimeout(() => {
7636
+ finish(new AgentSessionError("\u95EE\u9898\u8FD8\u5728\u51C6\u5907\u4E2D\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002", "question_not_ready"));
7637
+ }, 3e4);
7638
+ const unsubscribe = this.subscribe(() => {
7639
+ if (this.state.connection !== "connected") {
7640
+ finish(new AgentSessionError("\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u91CD\u8FDE\u540E\u91CD\u8BD5\u3002", "connection_lost"));
7641
+ } else if (this.state.status !== "waiting_for_input") {
7642
+ finish(new AgentSessionError("\u95EE\u9898\u72B6\u6001\u5DF2\u6539\u53D8\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u67E5\u770B\u5F53\u524D\u5BF9\u8BDD\u3002", "question_not_ready"));
7643
+ }
7644
+ });
7645
+ const offEnd = this.on("chatEnd", ({ status }) => {
7646
+ if (status === "paused") finish();
7647
+ else finish(new AgentSessionError("\u95EE\u9898\u5DF2\u7ED3\u675F\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u67E5\u770B\u5F53\u524D\u5BF9\u8BDD\u3002", "question_not_ready"));
7648
+ });
7649
+ const offError = this.on("error", () => {
7650
+ finish(new AgentSessionError("\u95EE\u9898\u6267\u884C\u5931\u8D25\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u67E5\u770B\u5F53\u524D\u5BF9\u8BDD\u3002", "question_not_ready"));
7651
+ });
7652
+ signal.addEventListener("abort", onDispose, { once: true });
7653
+ });
7654
+ }
7655
+ if (this.state.isStreaming || this.state.status === "waiting_for_input") return;
7615
7656
  if (Date.now() - this.recentChatEndAt > 3e3) return;
7616
7657
  const deadline = Date.now() + 3e3;
7617
7658
  while (Date.now() < deadline) {
@@ -9391,4 +9432,4 @@ export {
9391
9432
  parseAskUserQuestion,
9392
9433
  formatAskUserAnswer
9393
9434
  };
9394
- //# sourceMappingURL=chunk-DMVWOTJB.js.map
9435
+ //# sourceMappingURL=chunk-H4DV34V3.js.map