@blade-hq/agent-client 1.2.1-beta.1 → 1.2.1-beta.10
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/dist/index.js +42 -6
- package/dist/index.js.map +1 -1
- package/dist/shared/projection/builder.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45,8 +45,8 @@ async function loginWithPopup(client, options = {}) {
|
|
|
45
45
|
authorizeUrl.searchParams.set("client_origin", clientOrigin);
|
|
46
46
|
authorizeUrl.searchParams.set("state", state);
|
|
47
47
|
const popup = window.open(
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
"about:blank",
|
|
49
|
+
`blade-sdk-login-${state}`,
|
|
50
50
|
`popup=yes,width=${width},height=${height},left=${left},top=${top}`
|
|
51
51
|
);
|
|
52
52
|
if (!popup) {
|
|
@@ -69,6 +69,7 @@ async function loginWithPopup(client, options = {}) {
|
|
|
69
69
|
};
|
|
70
70
|
const onMessage = (event) => {
|
|
71
71
|
if (event.origin !== expectedOrigin) return;
|
|
72
|
+
if (event.source !== popup) return;
|
|
72
73
|
if (!isAuthCallbackMessage(event.data)) return;
|
|
73
74
|
if (event.data.state !== state) return;
|
|
74
75
|
const message = event.data;
|
|
@@ -107,6 +108,7 @@ async function loginWithPopup(client, options = {}) {
|
|
|
107
108
|
settle(() => reject(new Error("\u767B\u5F55\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u3002")));
|
|
108
109
|
}, timeoutMs);
|
|
109
110
|
window.addEventListener("message", onMessage);
|
|
111
|
+
popup.location.replace(authorizeUrl.toString());
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -914,6 +916,7 @@ var ClientProjectionBuilder = class {
|
|
|
914
916
|
pendingChildPauses = /* @__PURE__ */ new Map();
|
|
915
917
|
pendingMemoryRefs = /* @__PURE__ */ new Map();
|
|
916
918
|
activeCompactions = /* @__PURE__ */ new Map();
|
|
919
|
+
failedCompactions = /* @__PURE__ */ new Map();
|
|
917
920
|
seq = 0;
|
|
918
921
|
syntheticCounter = 0;
|
|
919
922
|
displayNameResolver;
|
|
@@ -977,6 +980,12 @@ var ClientProjectionBuilder = class {
|
|
|
977
980
|
return null;
|
|
978
981
|
}
|
|
979
982
|
switch (event.type) {
|
|
983
|
+
case "llm:stream:reset":
|
|
984
|
+
state.blocks = [];
|
|
985
|
+
state.toolCalls = [];
|
|
986
|
+
state.usage = null;
|
|
987
|
+
state.responseDone = false;
|
|
988
|
+
return this.syncPatch(state);
|
|
980
989
|
case "llm:thinking:delta":
|
|
981
990
|
return this.onDelta(state, "thinking", "", String(payload.content ?? ""));
|
|
982
991
|
case "llm:content:delta":
|
|
@@ -1013,6 +1022,7 @@ var ClientProjectionBuilder = class {
|
|
|
1013
1022
|
this.pendingChildPauses.clear();
|
|
1014
1023
|
this.pendingMemoryRefs.clear();
|
|
1015
1024
|
this.activeCompactions.clear();
|
|
1025
|
+
this.failedCompactions.clear();
|
|
1016
1026
|
this.seq = 0;
|
|
1017
1027
|
this.syntheticCounter = 0;
|
|
1018
1028
|
}
|
|
@@ -1485,7 +1495,7 @@ var ClientProjectionBuilder = class {
|
|
|
1485
1495
|
onCompaction(eventType, loopId, payload) {
|
|
1486
1496
|
const compactionId = String(payload.compaction_id ?? "");
|
|
1487
1497
|
if (!compactionId) return null;
|
|
1488
|
-
|
|
1498
|
+
let current = {
|
|
1489
1499
|
...this.activeCompactions.get(compactionId) ?? {},
|
|
1490
1500
|
...payload,
|
|
1491
1501
|
loop_id: loopId
|
|
@@ -1495,6 +1505,7 @@ var ClientProjectionBuilder = class {
|
|
|
1495
1505
|
case "compaction:start":
|
|
1496
1506
|
status = "streaming";
|
|
1497
1507
|
this.activeCompactions.set(compactionId, current);
|
|
1508
|
+
this.failedCompactions.delete(compactionId);
|
|
1498
1509
|
break;
|
|
1499
1510
|
case "compaction:end":
|
|
1500
1511
|
status = "completed";
|
|
@@ -1507,11 +1518,17 @@ var ClientProjectionBuilder = class {
|
|
|
1507
1518
|
case "compaction:error":
|
|
1508
1519
|
status = "failed";
|
|
1509
1520
|
this.activeCompactions.delete(compactionId);
|
|
1521
|
+
this.failedCompactions.set(compactionId, { ...current });
|
|
1510
1522
|
break;
|
|
1511
1523
|
default:
|
|
1512
1524
|
status = "streaming";
|
|
1513
1525
|
this.activeCompactions.set(compactionId, current);
|
|
1514
1526
|
}
|
|
1527
|
+
const failed = this.failedCompactions.get(compactionId);
|
|
1528
|
+
if (failed && status !== "failed") {
|
|
1529
|
+
current = { ...failed, ...current };
|
|
1530
|
+
status = "failed";
|
|
1531
|
+
}
|
|
1515
1532
|
const turn = buildCompactionTurn(this.nextSeq(), compactionId, loopId, status, current);
|
|
1516
1533
|
return [{ kind: "upsert", turn }];
|
|
1517
1534
|
}
|
|
@@ -4114,7 +4131,7 @@ function resolveAuthToken(options) {
|
|
|
4114
4131
|
|
|
4115
4132
|
// src/version.ts
|
|
4116
4133
|
var SDK_NAME = "agent-client";
|
|
4117
|
-
var SDK_VERSION = true ? "1.2.1-beta.
|
|
4134
|
+
var SDK_VERSION = true ? "1.2.1-beta.10" : "1.1.1";
|
|
4118
4135
|
|
|
4119
4136
|
// src/socket.ts
|
|
4120
4137
|
function withSdkIdentity(auth) {
|
|
@@ -4462,12 +4479,31 @@ function resolveTokenOption(tokenOption) {
|
|
|
4462
4479
|
const token = typeof tokenOption === "function" ? tokenOption() : tokenOption;
|
|
4463
4480
|
return token ? token : null;
|
|
4464
4481
|
}
|
|
4482
|
+
var SANDBOX_ONLY_HOST = "host.docker.internal";
|
|
4465
4483
|
function normalizeBaseUrl(baseUrl) {
|
|
4466
4484
|
const normalized = baseUrl.trim().replace(/\/+$/, "");
|
|
4467
|
-
if (
|
|
4485
|
+
if (typeof window === "undefined") {
|
|
4468
4486
|
return normalized;
|
|
4469
4487
|
}
|
|
4470
|
-
|
|
4488
|
+
if (!normalized) {
|
|
4489
|
+
return window.location.origin;
|
|
4490
|
+
}
|
|
4491
|
+
assertBrowserReachable(normalized);
|
|
4492
|
+
return normalized;
|
|
4493
|
+
}
|
|
4494
|
+
function assertBrowserReachable(baseUrl) {
|
|
4495
|
+
let hostname;
|
|
4496
|
+
try {
|
|
4497
|
+
hostname = new URL(baseUrl, window.location.href).hostname;
|
|
4498
|
+
} catch {
|
|
4499
|
+
return;
|
|
4500
|
+
}
|
|
4501
|
+
if (hostname !== SANDBOX_ONLY_HOST) {
|
|
4502
|
+
return;
|
|
4503
|
+
}
|
|
4504
|
+
throw new Error(
|
|
4505
|
+
`Blade Agent \u5730\u5740 ${baseUrl} \u53EA\u6709\u6C99\u76D2\u5185\u90E8\u89E3\u6790\u5F97\u5230\uFF0C\u6D4F\u89C8\u5668\u6253\u4E0D\u5F00\u3002\u8BF7\u628A\u5B83\u6539\u6210\u7528\u6237\u6D4F\u89C8\u5668\u80FD\u8BBF\u95EE\u7684\u5730\u5740\uFF08\u901A\u5E38\u662F\u8BBF\u95EE\u8FD9\u4E2A\u5E94\u7528\u65F6\u7528\u7684\u4E3B\u673A\u540D + Blade Server \u7AEF\u53E3\uFF09\u3002`
|
|
4506
|
+
);
|
|
4471
4507
|
}
|
|
4472
4508
|
function isFormData(value) {
|
|
4473
4509
|
return typeof FormData !== "undefined" && value instanceof FormData;
|