@standardagents/builder 0.40.3 → 0.40.4
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 +6 -3
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +41 -29
- package/dist/index.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
|
@@ -34832,7 +34832,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34832
34832
|
void 0,
|
|
34833
34833
|
INTERNAL_TOOL_DELIVERY
|
|
34834
34834
|
);
|
|
34835
|
-
if (delivered) sides.add(delivered.side);
|
|
34835
|
+
if (delivered?.resume) sides.add(delivered.side);
|
|
34836
34836
|
}
|
|
34837
34837
|
if (threadId) {
|
|
34838
34838
|
for (const side of sides) {
|
|
@@ -35134,14 +35134,17 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35134
35134
|
deliveredResultWaiters = /* @__PURE__ */ new Map();
|
|
35135
35135
|
notifyDeliveredResultWaiters(toolCallId) {
|
|
35136
35136
|
const waiters = this.deliveredResultWaiters?.get(toolCallId);
|
|
35137
|
-
if (!waiters) return;
|
|
35137
|
+
if (!waiters || waiters.size === 0) return false;
|
|
35138
35138
|
this.deliveredResultWaiters.delete(toolCallId);
|
|
35139
|
+
let notified = false;
|
|
35139
35140
|
for (const wake of waiters) {
|
|
35140
35141
|
try {
|
|
35141
35142
|
wake();
|
|
35143
|
+
notified = true;
|
|
35142
35144
|
} catch {
|
|
35143
35145
|
}
|
|
35144
35146
|
}
|
|
35147
|
+
return notified;
|
|
35145
35148
|
}
|
|
35146
35149
|
/**
|
|
35147
35150
|
* Await a parked forwarded call's delivered result: one immediate read,
|
|
@@ -35286,37 +35289,46 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35286
35289
|
const side = pending.side === "b" ? "b" : "a";
|
|
35287
35290
|
const content = ok ? result ?? "" : `Error: ${error ?? "tool failed"}`;
|
|
35288
35291
|
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`,
|
|
35292
|
+
const resultMessageId = crypto.randomUUID();
|
|
35293
|
+
const resultCreatedAt = Date.now() * TIMESTAMP_MULTIPLIER;
|
|
35294
|
+
const accepted = this.ctx.storage.transactionSync(() => {
|
|
35295
|
+
const claimed = this.ctx.storage.sql.exec(
|
|
35296
|
+
`UPDATE pending_client_calls
|
|
35297
|
+
SET status = 'resolved'
|
|
35298
|
+
WHERE tool_call_id = ? AND status = 'pending'`,
|
|
35302
35299
|
toolCallId
|
|
35303
35300
|
);
|
|
35304
|
-
|
|
35305
|
-
|
|
35306
|
-
|
|
35307
|
-
crypto.randomUUID(),
|
|
35301
|
+
if (claimed.rowsWritten !== 1) return false;
|
|
35302
|
+
this.ctx.storage.sql.exec(
|
|
35303
|
+
`UPDATE messages SET content = ?, tool_status = ? WHERE tool_call_id = ? AND role = 'tool'`,
|
|
35308
35304
|
content,
|
|
35309
|
-
toolRow.toArray()[0]?.tool ?? null,
|
|
35310
|
-
toolCallId,
|
|
35311
35305
|
toolStatus,
|
|
35312
|
-
|
|
35306
|
+
toolCallId
|
|
35313
35307
|
);
|
|
35314
|
-
|
|
35315
|
-
|
|
35316
|
-
|
|
35317
|
-
|
|
35318
|
-
|
|
35319
|
-
|
|
35308
|
+
const updated = this.ctx.storage.sql.exec(
|
|
35309
|
+
`SELECT COUNT(*) AS total FROM messages WHERE tool_call_id = ? AND role = 'tool'`,
|
|
35310
|
+
toolCallId
|
|
35311
|
+
);
|
|
35312
|
+
if (Number(updated.toArray()[0]?.total ?? 0) === 0) {
|
|
35313
|
+
const toolRow = this.ctx.storage.sql.exec(
|
|
35314
|
+
`SELECT tool FROM pending_client_calls WHERE tool_call_id = ? LIMIT 1`,
|
|
35315
|
+
toolCallId
|
|
35316
|
+
);
|
|
35317
|
+
this.ctx.storage.sql.exec(
|
|
35318
|
+
`INSERT INTO messages (id, role, content, name, tool_call_id, tool_status, created_at, status, prompt)
|
|
35319
|
+
VALUES (?, 'tool', ?, ?, ?, ?, ?, 'completed', NULL)`,
|
|
35320
|
+
resultMessageId,
|
|
35321
|
+
content,
|
|
35322
|
+
toolRow.toArray()[0]?.tool ?? null,
|
|
35323
|
+
toolCallId,
|
|
35324
|
+
toolStatus,
|
|
35325
|
+
resultCreatedAt
|
|
35326
|
+
);
|
|
35327
|
+
}
|
|
35328
|
+
return true;
|
|
35329
|
+
});
|
|
35330
|
+
if (!accepted) return null;
|
|
35331
|
+
const resumedInline = this.notifyDeliveredResultWaiters(toolCallId);
|
|
35320
35332
|
try {
|
|
35321
35333
|
const msgCursor = await this.ctx.storage.sql.exec(
|
|
35322
35334
|
`SELECT id, role, content, name, tool_call_id, tool_status, created_at, depth
|
|
@@ -35327,7 +35339,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
35327
35339
|
if (msg) this.broadcastMessage(msg);
|
|
35328
35340
|
} catch {
|
|
35329
35341
|
}
|
|
35330
|
-
return { side };
|
|
35342
|
+
return { side, resume: !resumedInline };
|
|
35331
35343
|
}
|
|
35332
35344
|
// ─── Runtime byte streams ──────────────────────────────────────────────────
|
|
35333
35345
|
// The existing bridge frames carry opaque capability metadata and bytes
|