@standardagents/builder 0.27.5 → 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.
- package/dist/built-in-routes.js +1 -1
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +7 -6
- package/dist/runtime.js +18 -18
- package/dist/runtime.js.map +1 -1
- package/package.json +5 -5
package/dist/runtime.d.ts
CHANGED
|
@@ -1003,7 +1003,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1003
1003
|
private currentExecutionOwnerId;
|
|
1004
1004
|
/** Persist + cache the execution-owner record (null releases ownership). */
|
|
1005
1005
|
private setExecutionOwner;
|
|
1006
|
-
/** Whether the given client id has
|
|
1006
|
+
/** Whether the given client id has an open bridge socket (excluding `except`).
|
|
1007
|
+
* Idle bridge heartbeats are handled by Cloudflare without waking this object,
|
|
1008
|
+
* so timestamp liveness is intentionally enforced only for an in-flight call. */
|
|
1007
1009
|
private hasLiveBridgeSocketForClient;
|
|
1008
1010
|
/** Tell every other bridge socket that execution ownership moved. */
|
|
1009
1011
|
private broadcastOwnerChanged;
|
|
@@ -1031,11 +1033,10 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1031
1033
|
private markBridgeDead;
|
|
1032
1034
|
/**
|
|
1033
1035
|
* Return the bridge socket a forwarded call should be dispatched to, pruning
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
* gone client — and it means we won't dispatch a forwarded call into the void.
|
|
1036
|
+
* closed ones. Idle clients use Cloudflare's hibernation auto-response, so
|
|
1037
|
+
* their frames deliberately do not update `bridgeLastSeen`. Once a call is
|
|
1038
|
+
* dispatched, the client switches to application-visible pings and the
|
|
1039
|
+
* in-flight liveness timer above detects a half-open connection.
|
|
1039
1040
|
*
|
|
1040
1041
|
* With an execution owner recorded, only the owner's socket (or, as a
|
|
1041
1042
|
* back-compat fallback, an unidentified legacy socket) is eligible; with no
|
package/dist/runtime.js
CHANGED
|
@@ -16093,9 +16093,11 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
16093
16093
|
codeExecutionBridges = /* @__PURE__ */ new Map();
|
|
16094
16094
|
constructor(ctx, env) {
|
|
16095
16095
|
super(ctx, env);
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16096
|
+
if (typeof WebSocketRequestResponsePair !== "undefined") {
|
|
16097
|
+
ctx.setWebSocketAutoResponse(
|
|
16098
|
+
new WebSocketRequestResponsePair("stream_ping", "stream_pong")
|
|
16099
|
+
);
|
|
16100
|
+
}
|
|
16099
16101
|
this.alarmQueue = new AlarmQueue(ctx);
|
|
16100
16102
|
this.alarmQueue.setExecutor(
|
|
16101
16103
|
async (method, args, itemId) => {
|
|
@@ -19460,14 +19462,13 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19460
19462
|
async setExecutionOwner(owner) {
|
|
19461
19463
|
await this.setValue(EXECUTION_OWNER_KEY, owner);
|
|
19462
19464
|
}
|
|
19463
|
-
/** Whether the given client id has
|
|
19465
|
+
/** Whether the given client id has an open bridge socket (excluding `except`).
|
|
19466
|
+
* Idle bridge heartbeats are handled by Cloudflare without waking this object,
|
|
19467
|
+
* so timestamp liveness is intentionally enforced only for an in-flight call. */
|
|
19464
19468
|
hasLiveBridgeSocketForClient(clientId, except) {
|
|
19465
|
-
const now = Date.now();
|
|
19466
19469
|
for (const ws of this.bridgeSockets) {
|
|
19467
19470
|
if (ws === except) continue;
|
|
19468
19471
|
if (ws.readyState !== WebSocket.OPEN) continue;
|
|
19469
|
-
const lastSeen = this.bridgeLastSeen.get(ws) ?? 0;
|
|
19470
|
-
if (now - lastSeen > BRIDGE_LIVENESS_TIMEOUT_MS) continue;
|
|
19471
19472
|
if ((this.bridgeClientInfo.get(ws)?.clientId ?? null) === clientId) return true;
|
|
19472
19473
|
}
|
|
19473
19474
|
return false;
|
|
@@ -19628,22 +19629,19 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19628
19629
|
}
|
|
19629
19630
|
/**
|
|
19630
19631
|
* Return the bridge socket a forwarded call should be dispatched to, pruning
|
|
19631
|
-
*
|
|
19632
|
-
*
|
|
19633
|
-
*
|
|
19634
|
-
*
|
|
19635
|
-
* gone client — and it means we won't dispatch a forwarded call into the void.
|
|
19632
|
+
* closed ones. Idle clients use Cloudflare's hibernation auto-response, so
|
|
19633
|
+
* their frames deliberately do not update `bridgeLastSeen`. Once a call is
|
|
19634
|
+
* dispatched, the client switches to application-visible pings and the
|
|
19635
|
+
* in-flight liveness timer above detects a half-open connection.
|
|
19636
19636
|
*
|
|
19637
19637
|
* With an execution owner recorded, only the owner's socket (or, as a
|
|
19638
19638
|
* back-compat fallback, an unidentified legacy socket) is eligible; with no
|
|
19639
19639
|
* owner, the first live socket wins as it always has.
|
|
19640
19640
|
*/
|
|
19641
19641
|
getOpenBridgeSocket(ownerClientId) {
|
|
19642
|
-
const now = Date.now();
|
|
19643
19642
|
const live = [];
|
|
19644
19643
|
for (const ws of Array.from(this.bridgeSockets)) {
|
|
19645
|
-
|
|
19646
|
-
if (ws.readyState === WebSocket.OPEN && now - lastSeen <= BRIDGE_LIVENESS_TIMEOUT_MS) {
|
|
19644
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
19647
19645
|
live.push({ socket: ws, clientId: this.bridgeClientInfo.get(ws)?.clientId ?? null });
|
|
19648
19646
|
continue;
|
|
19649
19647
|
}
|
|
@@ -22317,9 +22315,11 @@ var DurableAgentBuilder = class extends DurableObject {
|
|
|
22317
22315
|
eventSockets = /* @__PURE__ */ new Set();
|
|
22318
22316
|
constructor(ctx, env) {
|
|
22319
22317
|
super(ctx, env);
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22318
|
+
if (typeof WebSocketRequestResponsePair !== "undefined") {
|
|
22319
|
+
ctx.setWebSocketAutoResponse(
|
|
22320
|
+
new WebSocketRequestResponsePair("stream_ping", "stream_pong")
|
|
22321
|
+
);
|
|
22322
|
+
}
|
|
22323
22323
|
const sockets = ctx.getWebSockets();
|
|
22324
22324
|
for (const ws of sockets) {
|
|
22325
22325
|
const attachment = ws.deserializeAttachment();
|