@standardagents/builder 0.27.4 → 0.27.6

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.
@@ -66192,7 +66192,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
66192
66192
  });
66193
66193
 
66194
66194
  // src/version.ts
66195
- var BUILDER_VERSION = "0.27.4".length > 0 ? "0.27.4" : "dev";
66195
+ var BUILDER_VERSION = "0.27.6".length > 0 ? "0.27.6" : "dev";
66196
66196
 
66197
66197
  // src/api/diagnostics.get.ts
66198
66198
  init_LLMRequest();
package/dist/index.js CHANGED
@@ -24412,6 +24412,11 @@ var DurableThread = class _DurableThread extends DurableObject {
24412
24412
  codeExecutionBridges = /* @__PURE__ */ new Map();
24413
24413
  constructor(ctx, env) {
24414
24414
  super(ctx, env);
24415
+ if (typeof WebSocketRequestResponsePair !== "undefined") {
24416
+ ctx.setWebSocketAutoResponse(
24417
+ new WebSocketRequestResponsePair("stream_ping", "stream_pong")
24418
+ );
24419
+ }
24415
24420
  this.alarmQueue = new AlarmQueue(ctx);
24416
24421
  this.alarmQueue.setExecutor(
24417
24422
  async (method, args, itemId) => {
@@ -27776,14 +27781,13 @@ ${resultContent}${attachmentSummary}`;
27776
27781
  async setExecutionOwner(owner) {
27777
27782
  await this.setValue(EXECUTION_OWNER_KEY, owner);
27778
27783
  }
27779
- /** Whether the given client id has a live bridge socket (excluding `except`). */
27784
+ /** Whether the given client id has an open bridge socket (excluding `except`).
27785
+ * Idle bridge heartbeats are handled by Cloudflare without waking this object,
27786
+ * so timestamp liveness is intentionally enforced only for an in-flight call. */
27780
27787
  hasLiveBridgeSocketForClient(clientId, except) {
27781
- const now = Date.now();
27782
27788
  for (const ws of this.bridgeSockets) {
27783
27789
  if (ws === except) continue;
27784
27790
  if (ws.readyState !== WebSocket.OPEN) continue;
27785
- const lastSeen = this.bridgeLastSeen.get(ws) ?? 0;
27786
- if (now - lastSeen > BRIDGE_LIVENESS_TIMEOUT_MS) continue;
27787
27791
  if ((this.bridgeClientInfo.get(ws)?.clientId ?? null) === clientId) return true;
27788
27792
  }
27789
27793
  return false;
@@ -27944,22 +27948,19 @@ ${resultContent}${attachmentSummary}`;
27944
27948
  }
27945
27949
  /**
27946
27950
  * Return the bridge socket a forwarded call should be dispatched to, pruning
27947
- * dead ones. A half-open client (idle NAT/proxy drop) keeps a
27948
- * `readyState === OPEN` socket that never fires close/error, so we also treat
27949
- * a socket we haven't heard from within {@link BRIDGE_LIVENESS_TIMEOUT_MS} as
27950
- * dead. The CLI heartbeats every few seconds, so this only trips on a truly
27951
- * gone client — and it means we won't dispatch a forwarded call into the void.
27951
+ * closed ones. Idle clients use Cloudflare's hibernation auto-response, so
27952
+ * their frames deliberately do not update `bridgeLastSeen`. Once a call is
27953
+ * dispatched, the client switches to application-visible pings and the
27954
+ * in-flight liveness timer above detects a half-open connection.
27952
27955
  *
27953
27956
  * With an execution owner recorded, only the owner's socket (or, as a
27954
27957
  * back-compat fallback, an unidentified legacy socket) is eligible; with no
27955
27958
  * owner, the first live socket wins as it always has.
27956
27959
  */
27957
27960
  getOpenBridgeSocket(ownerClientId) {
27958
- const now = Date.now();
27959
27961
  const live = [];
27960
27962
  for (const ws of Array.from(this.bridgeSockets)) {
27961
- const lastSeen = this.bridgeLastSeen.get(ws) ?? 0;
27962
- if (ws.readyState === WebSocket.OPEN && now - lastSeen <= BRIDGE_LIVENESS_TIMEOUT_MS) {
27963
+ if (ws.readyState === WebSocket.OPEN) {
27963
27964
  live.push({ socket: ws, clientId: this.bridgeClientInfo.get(ws)?.clientId ?? null });
27964
27965
  continue;
27965
27966
  }
@@ -30633,6 +30634,11 @@ var DurableAgentBuilder = class extends DurableObject {
30633
30634
  eventSockets = /* @__PURE__ */ new Set();
30634
30635
  constructor(ctx, env) {
30635
30636
  super(ctx, env);
30637
+ if (typeof WebSocketRequestResponsePair !== "undefined") {
30638
+ ctx.setWebSocketAutoResponse(
30639
+ new WebSocketRequestResponsePair("stream_ping", "stream_pong")
30640
+ );
30641
+ }
30636
30642
  const sockets = ctx.getWebSockets();
30637
30643
  for (const ws of sockets) {
30638
30644
  const attachment = ws.deserializeAttachment();