@standardagents/builder 0.40.3 → 0.40.5-next.3b25e2a
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 +31 -8
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +56 -31
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +15 -2
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +41 -29
- package/dist/runtime.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -24040,6 +24040,18 @@ ${validUserProviders.map((p) => ` "${p.name}": async () => (await import("${p.i
|
|
|
24040
24040
|
}
|
|
24041
24041
|
}
|
|
24042
24042
|
var DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE = "2025-08-13";
|
|
24043
|
+
var REQUIRED_AGENTBUILDER_COMPATIBILITY_FLAGS = [
|
|
24044
|
+
"nodejs_compat",
|
|
24045
|
+
"enable_ctx_exports"
|
|
24046
|
+
];
|
|
24047
|
+
function compatibilityFlagsWithBuilderRequirements(flags = []) {
|
|
24048
|
+
if (flags.some((flag) => typeof flag !== "string" || flag.trim().length === 0)) {
|
|
24049
|
+
throw new Error(
|
|
24050
|
+
"compatibilityFlags must contain non-empty Cloudflare compatibility flag names"
|
|
24051
|
+
);
|
|
24052
|
+
}
|
|
24053
|
+
return [.../* @__PURE__ */ new Set([...REQUIRED_AGENTBUILDER_COMPATIBILITY_FLAGS, ...flags])];
|
|
24054
|
+
}
|
|
24043
24055
|
var depsToExclude = [
|
|
24044
24056
|
"@standardagents/builder",
|
|
24045
24057
|
"@standardagents/builder/runtime",
|
|
@@ -24148,7 +24160,7 @@ function createAgentBuilderWorkerConfig(options) {
|
|
|
24148
24160
|
// in vite.config.ts plus their agents/ source tree.
|
|
24149
24161
|
main: options.workerEntry,
|
|
24150
24162
|
compatibility_date: compatibilityDate,
|
|
24151
|
-
compatibility_flags:
|
|
24163
|
+
compatibility_flags: compatibilityFlagsWithBuilderRequirements(options.compatibilityFlags),
|
|
24152
24164
|
observability: {
|
|
24153
24165
|
enabled: true
|
|
24154
24166
|
},
|
|
@@ -24539,7 +24551,8 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
|
|
|
24539
24551
|
corePlugin,
|
|
24540
24552
|
...createAgentBuilderCloudflarePlugins({
|
|
24541
24553
|
workerEntry,
|
|
24542
|
-
compatibilityDate: options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE
|
|
24554
|
+
compatibilityDate: options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE,
|
|
24555
|
+
compatibilityFlags: options.compatibilityFlags
|
|
24543
24556
|
})
|
|
24544
24557
|
];
|
|
24545
24558
|
}
|
|
@@ -34832,7 +34845,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34832
34845
|
void 0,
|
|
34833
34846
|
INTERNAL_TOOL_DELIVERY
|
|
34834
34847
|
);
|
|
34835
|
-
if (delivered) sides.add(delivered.side);
|
|
34848
|
+
if (delivered?.resume) sides.add(delivered.side);
|
|
34836
34849
|
}
|
|
34837
34850
|
if (threadId) {
|
|
34838
34851
|
for (const side of sides) {
|
|
@@ -35134,14 +35147,17 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35134
35147
|
deliveredResultWaiters = /* @__PURE__ */ new Map();
|
|
35135
35148
|
notifyDeliveredResultWaiters(toolCallId) {
|
|
35136
35149
|
const waiters = this.deliveredResultWaiters?.get(toolCallId);
|
|
35137
|
-
if (!waiters) return;
|
|
35150
|
+
if (!waiters || waiters.size === 0) return false;
|
|
35138
35151
|
this.deliveredResultWaiters.delete(toolCallId);
|
|
35152
|
+
let notified = false;
|
|
35139
35153
|
for (const wake of waiters) {
|
|
35140
35154
|
try {
|
|
35141
35155
|
wake();
|
|
35156
|
+
notified = true;
|
|
35142
35157
|
} catch {
|
|
35143
35158
|
}
|
|
35144
35159
|
}
|
|
35160
|
+
return notified;
|
|
35145
35161
|
}
|
|
35146
35162
|
/**
|
|
35147
35163
|
* Await a parked forwarded call's delivered result: one immediate read,
|
|
@@ -35286,37 +35302,46 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35286
35302
|
const side = pending.side === "b" ? "b" : "a";
|
|
35287
35303
|
const content = ok ? result ?? "" : `Error: ${error ?? "tool failed"}`;
|
|
35288
35304
|
const toolStatus = ok ? "success" : "error";
|
|
35289
|
-
|
|
35290
|
-
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
|
|
35294
|
-
|
|
35295
|
-
|
|
35296
|
-
`SELECT COUNT(*) AS total FROM messages WHERE tool_call_id = ? AND role = 'tool'`,
|
|
35297
|
-
toolCallId
|
|
35298
|
-
);
|
|
35299
|
-
if (Number(updated.toArray()[0]?.total ?? 0) === 0) {
|
|
35300
|
-
const toolRow = await this.ctx.storage.sql.exec(
|
|
35301
|
-
`SELECT tool FROM pending_client_calls WHERE tool_call_id = ? LIMIT 1`,
|
|
35305
|
+
const resultMessageId = crypto.randomUUID();
|
|
35306
|
+
const resultCreatedAt = Date.now() * TIMESTAMP_MULTIPLIER;
|
|
35307
|
+
const accepted = this.ctx.storage.transactionSync(() => {
|
|
35308
|
+
const claimed = this.ctx.storage.sql.exec(
|
|
35309
|
+
`UPDATE pending_client_calls
|
|
35310
|
+
SET status = 'resolved'
|
|
35311
|
+
WHERE tool_call_id = ? AND status = 'pending'`,
|
|
35302
35312
|
toolCallId
|
|
35303
35313
|
);
|
|
35304
|
-
|
|
35305
|
-
|
|
35306
|
-
|
|
35307
|
-
crypto.randomUUID(),
|
|
35314
|
+
if (claimed.rowsWritten !== 1) return false;
|
|
35315
|
+
this.ctx.storage.sql.exec(
|
|
35316
|
+
`UPDATE messages SET content = ?, tool_status = ? WHERE tool_call_id = ? AND role = 'tool'`,
|
|
35308
35317
|
content,
|
|
35309
|
-
toolRow.toArray()[0]?.tool ?? null,
|
|
35310
|
-
toolCallId,
|
|
35311
35318
|
toolStatus,
|
|
35312
|
-
|
|
35319
|
+
toolCallId
|
|
35313
35320
|
);
|
|
35314
|
-
|
|
35315
|
-
|
|
35316
|
-
|
|
35317
|
-
|
|
35318
|
-
|
|
35319
|
-
|
|
35321
|
+
const updated = this.ctx.storage.sql.exec(
|
|
35322
|
+
`SELECT COUNT(*) AS total FROM messages WHERE tool_call_id = ? AND role = 'tool'`,
|
|
35323
|
+
toolCallId
|
|
35324
|
+
);
|
|
35325
|
+
if (Number(updated.toArray()[0]?.total ?? 0) === 0) {
|
|
35326
|
+
const toolRow = this.ctx.storage.sql.exec(
|
|
35327
|
+
`SELECT tool FROM pending_client_calls WHERE tool_call_id = ? LIMIT 1`,
|
|
35328
|
+
toolCallId
|
|
35329
|
+
);
|
|
35330
|
+
this.ctx.storage.sql.exec(
|
|
35331
|
+
`INSERT INTO messages (id, role, content, name, tool_call_id, tool_status, created_at, status, prompt)
|
|
35332
|
+
VALUES (?, 'tool', ?, ?, ?, ?, ?, 'completed', NULL)`,
|
|
35333
|
+
resultMessageId,
|
|
35334
|
+
content,
|
|
35335
|
+
toolRow.toArray()[0]?.tool ?? null,
|
|
35336
|
+
toolCallId,
|
|
35337
|
+
toolStatus,
|
|
35338
|
+
resultCreatedAt
|
|
35339
|
+
);
|
|
35340
|
+
}
|
|
35341
|
+
return true;
|
|
35342
|
+
});
|
|
35343
|
+
if (!accepted) return null;
|
|
35344
|
+
const resumedInline = this.notifyDeliveredResultWaiters(toolCallId);
|
|
35320
35345
|
try {
|
|
35321
35346
|
const msgCursor = await this.ctx.storage.sql.exec(
|
|
35322
35347
|
`SELECT id, role, content, name, tool_call_id, tool_status, created_at, depth
|
|
@@ -35327,7 +35352,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35327
35352
|
if (msg) this.broadcastMessage(msg);
|
|
35328
35353
|
} catch {
|
|
35329
35354
|
}
|
|
35330
|
-
return { side };
|
|
35355
|
+
return { side, resume: !resumedInline };
|
|
35331
35356
|
}
|
|
35332
35357
|
// ─── Runtime byte streams ──────────────────────────────────────────────────
|
|
35333
35358
|
// The existing bridge frames carry opaque capability metadata and bytes
|