@letta-ai/letta-agent-sdk 0.8.65 → 0.8.67

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.
@@ -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)}`));
@@ -9695,6 +9740,13 @@ class AppServerClient {
9695
9740
  predicate: (message) => message.type === "subagent_message_response"
9696
9741
  });
9697
9742
  }
9743
+ readSubagentEvents(command, options = {}) {
9744
+ const requestId = command.request_id ?? this.nextRequestId("read-subagent-events");
9745
+ return this.request({ ...command, type: "read_subagent_events", request_id: requestId }, {
9746
+ ...options,
9747
+ predicate: (message) => message.type === "read_subagent_events_response" && message.request_id === requestId
9748
+ });
9749
+ }
9698
9750
  stopSubagent(command, options = {}) {
9699
9751
  return this.request({
9700
9752
  ...command,
@@ -17790,4 +17842,4 @@ export {
17790
17842
  CloudManagedSandboxExpiredError
17791
17843
  };
17792
17844
 
17793
- //# debugId=5BE83359F2AB3C2064756E2164756E21
17845
+ //# debugId=BA20E4AEDDBBE08B64756E2164756E21