@blade-hq/agent-client 2612.0.0-beta.70 → 2612.0.0-beta.72
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 +16 -0
- package/dist/{chunk-LMPQOOAH.js → chunk-T5PXAGPI.js} +43 -4
- package/dist/chunk-T5PXAGPI.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal.js +1 -1
- package/dist/schemas/context-attachments.d.ts +2 -0
- package/dist/session/agent-session.d.ts +1 -0
- package/dist/types/socket-events.d.ts +4 -0
- package/package.json +1 -1
- package/public-api.md +2 -0
- package/dist/chunk-LMPQOOAH.js.map +0 -1
package/README.md
CHANGED
|
@@ -1041,3 +1041,19 @@ 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 重发。
|
|
@@ -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.
|
|
230
|
+
var SDK_VERSION = true ? "2612.0.0-beta.72" : "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");
|
|
@@ -5923,6 +5926,7 @@ var AgentSession = class _AgentSession {
|
|
|
5923
5926
|
lastDeliveredSystemError = null;
|
|
5924
5927
|
systemErrorGeneration = 0;
|
|
5925
5928
|
subscriptionReplaySource = null;
|
|
5929
|
+
lifetimeAbort = new AbortController();
|
|
5926
5930
|
disposed = false;
|
|
5927
5931
|
getAppContext = null;
|
|
5928
5932
|
sendPending = false;
|
|
@@ -6687,6 +6691,7 @@ var AgentSession = class _AgentSession {
|
|
|
6687
6691
|
if (this.disposed) return;
|
|
6688
6692
|
if (!this.runtime.onDispose(this)) return;
|
|
6689
6693
|
this.disposed = true;
|
|
6694
|
+
this.lifetimeAbort.abort();
|
|
6690
6695
|
this.invalidateTimeline();
|
|
6691
6696
|
this.invalidateOlderPaging();
|
|
6692
6697
|
this.state = { ...this.state, nextBefore: null, loadingOlder: false };
|
|
@@ -7611,7 +7616,41 @@ var AgentSession = class _AgentSession {
|
|
|
7611
7616
|
return join;
|
|
7612
7617
|
}
|
|
7613
7618
|
async ensureIdleBeforeSend() {
|
|
7614
|
-
if (this.
|
|
7619
|
+
if (this.disposed) throw new AgentSessionError("\u4F1A\u8BDD\u5DF2\u5173\u95ED\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\u3002", "session_disposed");
|
|
7620
|
+
if (this.state.status === "waiting_for_input" && this.state.isStreaming) {
|
|
7621
|
+
await new Promise((resolve, reject) => {
|
|
7622
|
+
const signal = this.lifetimeAbort.signal;
|
|
7623
|
+
const finish = (error) => {
|
|
7624
|
+
globalThis.clearTimeout(timeout);
|
|
7625
|
+
unsubscribe();
|
|
7626
|
+
offEnd();
|
|
7627
|
+
offError();
|
|
7628
|
+
signal.removeEventListener("abort", onDispose);
|
|
7629
|
+
if (error) reject(error);
|
|
7630
|
+
else resolve();
|
|
7631
|
+
};
|
|
7632
|
+
const onDispose = () => finish(new AgentSessionError("\u4F1A\u8BDD\u5DF2\u5173\u95ED\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\u3002", "session_disposed"));
|
|
7633
|
+
const timeout = globalThis.setTimeout(() => {
|
|
7634
|
+
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"));
|
|
7635
|
+
}, 3e4);
|
|
7636
|
+
const unsubscribe = this.subscribe(() => {
|
|
7637
|
+
if (this.state.connection !== "connected") {
|
|
7638
|
+
finish(new AgentSessionError("\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u56DE\u7B54\u672A\u53D1\u9001\uFF0C\u8BF7\u91CD\u8FDE\u540E\u91CD\u8BD5\u3002", "connection_lost"));
|
|
7639
|
+
} else if (this.state.status !== "waiting_for_input") {
|
|
7640
|
+
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"));
|
|
7641
|
+
}
|
|
7642
|
+
});
|
|
7643
|
+
const offEnd = this.on("chatEnd", ({ status }) => {
|
|
7644
|
+
if (status === "paused") finish();
|
|
7645
|
+
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"));
|
|
7646
|
+
});
|
|
7647
|
+
const offError = this.on("error", () => {
|
|
7648
|
+
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"));
|
|
7649
|
+
});
|
|
7650
|
+
signal.addEventListener("abort", onDispose, { once: true });
|
|
7651
|
+
});
|
|
7652
|
+
}
|
|
7653
|
+
if (this.state.isStreaming || this.state.status === "waiting_for_input") return;
|
|
7615
7654
|
if (Date.now() - this.recentChatEndAt > 3e3) return;
|
|
7616
7655
|
const deadline = Date.now() + 3e3;
|
|
7617
7656
|
while (Date.now() < deadline) {
|
|
@@ -9391,4 +9430,4 @@ export {
|
|
|
9391
9430
|
parseAskUserQuestion,
|
|
9392
9431
|
formatAskUserAnswer
|
|
9393
9432
|
};
|
|
9394
|
-
//# sourceMappingURL=chunk-
|
|
9433
|
+
//# sourceMappingURL=chunk-T5PXAGPI.js.map
|