@letta-ai/letta-agent-sdk 0.8.65 → 0.8.66
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/client-entry.js +46 -1
- package/dist/client-entry.js.map +3 -3
- package/dist/index.js +47 -2
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
package/dist/client-entry.js
CHANGED
|
@@ -9488,14 +9488,59 @@ function waitForSocketOpen(socket) {
|
|
|
9488
9488
|
return new Promise((resolve, reject) => {
|
|
9489
9489
|
let detachOpen = () => {};
|
|
9490
9490
|
let detachError = () => {};
|
|
9491
|
+
let detachResponse = () => {};
|
|
9492
|
+
let detachBody = () => {};
|
|
9491
9493
|
const cleanup = () => {
|
|
9492
9494
|
detachOpen();
|
|
9493
9495
|
detachError();
|
|
9496
|
+
detachResponse();
|
|
9497
|
+
detachBody();
|
|
9494
9498
|
};
|
|
9495
9499
|
detachOpen = onceSocketEvent(socket, "open", () => {
|
|
9496
9500
|
cleanup();
|
|
9497
9501
|
resolve();
|
|
9498
9502
|
});
|
|
9503
|
+
if (socket.on) {
|
|
9504
|
+
const onResponse = (_request, response) => {
|
|
9505
|
+
if (!response)
|
|
9506
|
+
return;
|
|
9507
|
+
const request = _request;
|
|
9508
|
+
let body = Buffer.alloc(0);
|
|
9509
|
+
let finished = false;
|
|
9510
|
+
const finish = () => {
|
|
9511
|
+
if (finished)
|
|
9512
|
+
return;
|
|
9513
|
+
detachBody();
|
|
9514
|
+
const detail = body.toString("utf8").trim();
|
|
9515
|
+
reject(new Error(`App-server WebSocket failed to open: HTTP ${response.statusCode}${detail ? `: ${detail}` : ""}`));
|
|
9516
|
+
detachOpen();
|
|
9517
|
+
detachResponse();
|
|
9518
|
+
request.once("close", cleanup);
|
|
9519
|
+
request.abort();
|
|
9520
|
+
};
|
|
9521
|
+
const onData = (chunk) => {
|
|
9522
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
9523
|
+
body = Buffer.concat([body, bytes.subarray(0, 2048 - body.length)]);
|
|
9524
|
+
if (body.length >= 2048)
|
|
9525
|
+
finish();
|
|
9526
|
+
};
|
|
9527
|
+
const timeout = setTimeout(finish, 1000);
|
|
9528
|
+
detachBody = () => {
|
|
9529
|
+
finished = true;
|
|
9530
|
+
clearTimeout(timeout);
|
|
9531
|
+
response.off("data", onData);
|
|
9532
|
+
response.off("end", finish);
|
|
9533
|
+
response.off("error", finish);
|
|
9534
|
+
response.off("close", finish);
|
|
9535
|
+
};
|
|
9536
|
+
response.on("data", onData);
|
|
9537
|
+
response.on("end", finish);
|
|
9538
|
+
response.on("error", finish);
|
|
9539
|
+
response.on("close", finish);
|
|
9540
|
+
};
|
|
9541
|
+
socket.on("unexpected-response", onResponse);
|
|
9542
|
+
detachResponse = () => socket.off?.("unexpected-response", onResponse);
|
|
9543
|
+
}
|
|
9499
9544
|
detachError = onceSocketEvent(socket, "error", (event) => {
|
|
9500
9545
|
cleanup();
|
|
9501
9546
|
reject(new Error(`App-server WebSocket failed to open: ${String(event)}`));
|
|
@@ -17790,4 +17835,4 @@ export {
|
|
|
17790
17835
|
CloudManagedSandboxExpiredError
|
|
17791
17836
|
};
|
|
17792
17837
|
|
|
17793
|
-
//# debugId=
|
|
17838
|
+
//# debugId=F0D49A75FB9DEEBD64756E2164756E21
|