@standardagents/builder 0.40.5-next.3b25e2a → 0.40.5

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/index.js CHANGED
@@ -5083,9 +5083,7 @@ Message one with subagent_message(referenceId, message).`
5083
5083
  if (resumable) {
5084
5084
  await this.settleResumableChildAfterRun(
5085
5085
  state,
5086
- stub,
5087
- childThreadId,
5088
- childResult
5086
+ childThreadId
5089
5087
  );
5090
5088
  } else if (stub.terminateThread) {
5091
5089
  await stub.terminateThread(childThreadId);
@@ -5097,7 +5095,7 @@ Message one with subagent_message(referenceId, message).`
5097
5095
  attachments: copiedAttachments,
5098
5096
  subagent_id: childThreadId
5099
5097
  };
5100
- return resumable && !this.isTerminalSubagentResult(childResult) ? this.withReferenceInToolResult(toolResult, childThreadId) : toolResult;
5098
+ return resumable ? this.withReferenceInToolResult(toolResult, childThreadId) : toolResult;
5101
5099
  }
5102
5100
  const backgroundRun = (async () => {
5103
5101
  try {
@@ -5132,9 +5130,7 @@ Message one with subagent_message(referenceId, message).`
5132
5130
  if (resumable) {
5133
5131
  await this.settleResumableChildAfterRun(
5134
5132
  state,
5135
- stub,
5136
- childThreadId,
5137
- childResult
5133
+ childThreadId
5138
5134
  );
5139
5135
  } else if (stub.terminateThread) {
5140
5136
  await stub.terminateThread(childThreadId);
@@ -5529,18 +5525,8 @@ Message one with subagent_message(referenceId, message).`
5529
5525
  JSON.stringify(next)
5530
5526
  );
5531
5527
  }
5532
- static isTerminalSubagentResult(result) {
5533
- return result.terminal === true;
5534
- }
5535
- static async settleResumableChildAfterRun(state, childThread, reference, result) {
5536
- if (!this.isTerminalSubagentResult(result)) {
5537
- await this.updateChildStatus(state, reference, "idle");
5538
- return;
5539
- }
5540
- await this.updateChildStatus(state, reference, "terminated");
5541
- if (typeof childThread.terminateThread === "function") {
5542
- await childThread.terminateThread(reference);
5543
- }
5528
+ static async settleResumableChildAfterRun(state, reference) {
5529
+ await this.updateChildStatus(state, reference, "idle");
5544
5530
  }
5545
5531
  static async buildChildInvocationMessages(state, childThread, content, receivesMessages, parentAttachments, initialArguments) {
5546
5532
  const copiedAttachments = await this.copyAttachmentsBetweenThreads(
@@ -16819,7 +16805,7 @@ function createHmrReloader() {
16819
16805
  const isConfigFile = isModelFile || isProviderFile || isPromptFile || isAgentFile || isEffectFile;
16820
16806
  if (!isToolFile && !isThreadApiFile && !isHookFile && !isConfigFile && !isUserEndpointFile) return;
16821
16807
  reloader.invalidateSourceFileModule(server, file);
16822
- if (isConfigFile || isToolFile) regenerateTypes();
16808
+ if (isConfigFile || isToolFile || isHookFile) regenerateTypes();
16823
16809
  if (isToolFile) await reloader.reloadToolsModule(server);
16824
16810
  if (isModelFile) await reloader.reloadModelsModule(server);
16825
16811
  if (isProviderFile) await reloader.reloadProvidersModule(server);
@@ -18947,6 +18933,29 @@ async function scanPromptsDirectory(dir) {
18947
18933
  async function scanAgentsDirectory(dir) {
18948
18934
  return scanConfigDirectory(dir, /export\s+default\s+defineAgent/);
18949
18935
  }
18936
+ function findLegacyRootAgentFiles(agentsDir) {
18937
+ const agentsRoot = path9__default.dirname(agentsDir);
18938
+ if (path9__default.basename(agentsDir) !== "agents" || path9__default.basename(agentsRoot) !== "agents") {
18939
+ return [];
18940
+ }
18941
+ if (!fs9__default.existsSync(agentsRoot)) return [];
18942
+ return fs9__default.readdirSync(agentsRoot, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".ts")).map((entry) => path9__default.join(agentsRoot, entry.name)).filter((filePath) => {
18943
+ try {
18944
+ return /export\s+default\s+defineAgent/.test(fs9__default.readFileSync(filePath, "utf8"));
18945
+ } catch {
18946
+ return false;
18947
+ }
18948
+ }).sort();
18949
+ }
18950
+ function warnLegacyRootAgentFiles(agentsDir) {
18951
+ const expectedDir = path9__default.relative(process.cwd(), agentsDir).replace(/\\/g, "/");
18952
+ for (const filePath of findLegacyRootAgentFiles(agentsDir)) {
18953
+ const source = path9__default.relative(process.cwd(), filePath).replace(/\\/g, "/");
18954
+ console.warn(
18955
+ `[agentbuilder] Agent definition "${source}" is outside the scanned agent directory. Move it to "${expectedDir}/" so it is registered.`
18956
+ );
18957
+ }
18958
+ }
18950
18959
  async function scanEffectsDirectory(dir) {
18951
18960
  const effects = [];
18952
18961
  if (!fs9__default.existsSync(dir)) {
@@ -22657,7 +22666,32 @@ function isHostedInstance(env) {
22657
22666
  }
22658
22667
  return Boolean(value);
22659
22668
  }
22660
- function isTrustedLocalDevelopmentRequest(request, env) {
22669
+ function normalizeTrustedDevHosts(hosts) {
22670
+ const normalized = /* @__PURE__ */ new Set();
22671
+ for (const rawHost of hosts ?? []) {
22672
+ const candidate = rawHost.trim().toLowerCase().replace(/\.$/, "");
22673
+ try {
22674
+ const parsed = new URL(`http://${candidate}`);
22675
+ if (!candidate || candidate.includes("*") || parsed.hostname.toLowerCase().replace(/\.$/, "") !== candidate || parsed.port || parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash) {
22676
+ throw new Error("invalid hostname");
22677
+ }
22678
+ } catch {
22679
+ throw new Error(
22680
+ `Invalid trusted development hostname "${rawHost}". Use an exact hostname without a scheme, port, path, or wildcard.`
22681
+ );
22682
+ }
22683
+ normalized.add(candidate);
22684
+ }
22685
+ return [...normalized];
22686
+ }
22687
+ function compiledTrustedDevHosts() {
22688
+ try {
22689
+ return typeof __STANDARD_AGENTS_TRUSTED_DEV_HOSTS__ !== "undefined" && Array.isArray(__STANDARD_AGENTS_TRUSTED_DEV_HOSTS__) ? __STANDARD_AGENTS_TRUSTED_DEV_HOSTS__ : [];
22690
+ } catch {
22691
+ return [];
22692
+ }
22693
+ }
22694
+ function isTrustedLocalDevelopmentRequest(request, env, trustedDevHosts = compiledTrustedDevHosts()) {
22661
22695
  if (isHostedInstance(env)) return false;
22662
22696
  let hostname;
22663
22697
  try {
@@ -22665,7 +22699,7 @@ function isTrustedLocalDevelopmentRequest(request, env) {
22665
22699
  } catch {
22666
22700
  return false;
22667
22701
  }
22668
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.endsWith(".localhost") || hostname.endsWith(".orb.local");
22702
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.endsWith(".localhost") || hostname.endsWith(".orb.local") || trustedDevHosts.some((trusted) => trusted.trim().toLowerCase() === hostname);
22669
22703
  }
22670
22704
  function isPublicApiRoute(routePath, request, env) {
22671
22705
  if (PUBLIC_ROUTES.has(routePath)) return true;
@@ -22814,7 +22848,8 @@ function createDevMiddleware(server, context) {
22814
22848
  installedProviderPackageMap,
22815
22849
  hmr,
22816
22850
  sourceDirs,
22817
- regenerateTypes
22851
+ regenerateTypes,
22852
+ trustedDevHosts
22818
22853
  } = context;
22819
22854
  server.watcher.on("add", async (file) => {
22820
22855
  await hmr.handleFileChange(file, server, sourceDirs, regenerateTypes);
@@ -22848,7 +22883,8 @@ function createDevMiddleware(server, context) {
22848
22883
  try {
22849
22884
  trustedLocalHost = isTrustedLocalDevelopmentRequest(
22850
22885
  new Request(`http://${req.headers.host || "invalid.remote"}${routePath}`),
22851
- {}
22886
+ {},
22887
+ trustedDevHosts
22852
22888
  );
22853
22889
  } catch {
22854
22890
  }
@@ -24082,7 +24118,7 @@ var firstPartyProviderPackages = [
24082
24118
  "@standardagents/openrouter",
24083
24119
  "@standardagents/xai"
24084
24120
  ];
24085
- var depsToInclude = [
24121
+ var baseDepsToInclude = [
24086
24122
  "zod",
24087
24123
  "zod/v3",
24088
24124
  "zod/v4",
@@ -24093,17 +24129,24 @@ var depsToInclude = [
24093
24129
  // a root dep). The `parent > child` form pre-bundles it at startup so Vite
24094
24130
  // doesn't discover it mid-request and reload the worker (which would destroy
24095
24131
  // an in-flight Durable Object execution and drop the client bridge).
24096
- "@standardagents/openrouter > @openrouter/sdk",
24097
24132
  "magic-string",
24098
24133
  "@standardagents/spec",
24099
24134
  // Incremental JSON reader used by the runtime to surface a tool's progress
24100
24135
  // argument from partial streamed tool-call arguments (tool_call_started).
24101
- "@formkit/jsonreader",
24102
- // Pre-bundle the provider packages themselves so their whole subtree (SDKs,
24103
- // pricing tables) lands in the initial optimized bundle and nothing is
24104
- // discovered lazily by workerd.
24105
- ...firstPartyProviderPackages
24136
+ "@formkit/jsonreader"
24106
24137
  ];
24138
+ function depsToInclude(options = {}) {
24139
+ const installedProviders = options.isPackageInstalled ? firstPartyProviderPackages.filter(options.isPackageInstalled) : firstPartyProviderPackages;
24140
+ const openRouterTransitive = installedProviders.includes("@standardagents/openrouter") ? ["@standardagents/openrouter > @openrouter/sdk"] : [];
24141
+ return [...baseDepsToInclude, ...openRouterTransitive, ...installedProviders];
24142
+ }
24143
+ function trustedDevHostDefines(options) {
24144
+ return {
24145
+ __STANDARD_AGENTS_TRUSTED_DEV_HOSTS__: JSON.stringify(
24146
+ normalizeTrustedDevHosts(options.trustedDevHosts)
24147
+ )
24148
+ };
24149
+ }
24107
24150
  var packingDeps = [
24108
24151
  "rollup",
24109
24152
  "@rollup/plugin-commonjs",
@@ -24112,7 +24155,7 @@ var packingDeps = [
24112
24155
  "fsevents",
24113
24156
  "typescript"
24114
24157
  ];
24115
- function createPluginViteConfig(pluginModuleUrl) {
24158
+ function createPluginViteConfig(pluginModuleUrl, options = {}) {
24116
24159
  const currentDir = path9__default.dirname(fileURLToPath(pluginModuleUrl));
24117
24160
  const isInDist = currentDir.endsWith("dist");
24118
24161
  const builderClientDir = path9__default.resolve(
@@ -24120,6 +24163,7 @@ function createPluginViteConfig(pluginModuleUrl) {
24120
24163
  isInDist ? "./client" : "../dist/client"
24121
24164
  );
24122
24165
  return {
24166
+ define: trustedDevHostDefines(options),
24123
24167
  publicDir: fs9__default.existsSync(builderClientDir) ? builderClientDir : void 0,
24124
24168
  build: {
24125
24169
  rollupOptions: {
@@ -24135,7 +24179,7 @@ function createPluginViteConfig(pluginModuleUrl) {
24135
24179
  // `npm run dev` ("There is a new version of the pre-bundle for X").
24136
24180
  holdUntilCrawlEnd: true,
24137
24181
  exclude: depsToExclude,
24138
- include: depsToInclude.filter((dep) => dep !== "zod/v3" && dep !== "zod/v4" && dep !== "zod/v4/core")
24182
+ include: depsToInclude(options).filter((dep) => dep !== "zod/v3" && dep !== "zod/v4" && dep !== "zod/v4/core")
24139
24183
  },
24140
24184
  ssr: {
24141
24185
  noExternal: [
@@ -24240,7 +24284,11 @@ function createAgentBuilderCloudflarePlugins(options) {
24240
24284
  }
24241
24285
  });
24242
24286
  }
24243
- function applyPluginEnvironmentConfig(config) {
24287
+ function applyPluginEnvironmentConfig(config, options = {}) {
24288
+ config.define = {
24289
+ ...config.define || {},
24290
+ ...trustedDevHostDefines(options)
24291
+ };
24244
24292
  config.optimizeDeps = config.optimizeDeps || {};
24245
24293
  config.optimizeDeps.holdUntilCrawlEnd = true;
24246
24294
  config.optimizeDeps.exclude = [
@@ -24249,7 +24297,7 @@ function applyPluginEnvironmentConfig(config) {
24249
24297
  ];
24250
24298
  config.optimizeDeps.include = [
24251
24299
  ...config.optimizeDeps.include || [],
24252
- ...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
24300
+ ...depsToInclude(options).filter((dep) => !config.optimizeDeps?.include?.includes(dep))
24253
24301
  ];
24254
24302
  config.build = config.build || {};
24255
24303
  config.build.rollupOptions = config.build.rollupOptions || {};
@@ -24309,6 +24357,7 @@ function normalizeDeviceApprovalBrand(value) {
24309
24357
  // src/plugin.ts
24310
24358
  function agentbuilder(options = {}) {
24311
24359
  const deviceApproval = normalizeDeviceApprovalBrand(options.deviceApproval);
24360
+ const trustedDevHosts = normalizeTrustedDevHosts(options.trustedDevHosts);
24312
24361
  const toolsDir = options.toolsDir ? path9__default.resolve(process.cwd(), options.toolsDir) : path9__default.resolve(process.cwd(), "agents/tools");
24313
24362
  const hooksDir = options.hooksDir ? path9__default.resolve(process.cwd(), options.hooksDir) : path9__default.resolve(process.cwd(), "agents/hooks");
24314
24363
  const threadApiDir = options.apiDir ? path9__default.resolve(process.cwd(), options.apiDir) : path9__default.resolve(process.cwd(), "agents/api");
@@ -24413,7 +24462,8 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
24413
24462
  installedProviderPackageMap,
24414
24463
  hmr,
24415
24464
  sourceDirs,
24416
- regenerateTypes
24465
+ regenerateTypes,
24466
+ trustedDevHosts
24417
24467
  };
24418
24468
  const workerEntry = path9__default.relative(process.cwd(), generatedWorkerEntry).split(path9__default.sep).join("/");
24419
24469
  const corePlugin = {
@@ -24421,12 +24471,18 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
24421
24471
  enforce: "pre",
24422
24472
  config() {
24423
24473
  writeGeneratedWorkerEntry();
24424
- const viteConfig = createPluginViteConfig(import.meta.url);
24474
+ const viteConfig = createPluginViteConfig(import.meta.url, {
24475
+ isPackageInstalled: isProviderPackageInstalled,
24476
+ trustedDevHosts
24477
+ });
24425
24478
  return viteConfig;
24426
24479
  },
24427
24480
  // Apply exclusions and inclusions to ALL environments including Cloudflare worker
24428
24481
  configEnvironment(_name, config) {
24429
- applyPluginEnvironmentConfig(config);
24482
+ applyPluginEnvironmentConfig(config, {
24483
+ isPackageInstalled: isProviderPackageInstalled,
24484
+ trustedDevHosts
24485
+ });
24430
24486
  },
24431
24487
  resolveId(id) {
24432
24488
  if (id === VIRTUAL_TOOLS_ID) {
@@ -24471,6 +24527,7 @@ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, ThreadWatchdog
24471
24527
  },
24472
24528
  buildStart() {
24473
24529
  writeGeneratedWorkerEntry();
24530
+ warnLegacyRootAgentFiles(agentsDir);
24474
24531
  regenerateTypes();
24475
24532
  this.addWatchFile(toolsDir);
24476
24533
  this.addWatchFile(threadApiDir);
@@ -29242,12 +29299,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
29242
29299
  await parentThread.updateChildRegistryStatus(
29243
29300
  params.parent_thread_id,
29244
29301
  childThread.id,
29245
- childResult.terminal ? "terminated" : "idle"
29302
+ "idle"
29246
29303
  );
29247
29304
  }
29248
- if (childResult.terminal && typeof childThreadStub.terminateThread === "function") {
29249
- await childThreadStub.terminateThread(childThread.id);
29250
- }
29251
29305
  } else if (typeof childThreadStub.terminateThread === "function") {
29252
29306
  await childThreadStub.terminateThread(childThread.id);
29253
29307
  }
@@ -33243,11 +33297,13 @@ ${paths.join("\n")}`;
33243
33297
  try {
33244
33298
  const parentId = this.env.AGENT_BUILDER_THREAD.idFromName(parentThreadId);
33245
33299
  const parentStub = this.env.AGENT_BUILDER_THREAD.get(parentId);
33246
- const parentCommunication = await this.getParentCommunicationModeForChild(
33300
+ const childRegistryEntry = await this.getParentRegistryEntryForChild(
33247
33301
  parentStub,
33248
33302
  parentThreadId,
33249
33303
  threadId
33250
33304
  );
33305
+ const parentCommunication = childRegistryEntry?.parentCommunication === "explicit" ? "explicit" : "implicit";
33306
+ const resumableChild = childRegistryEntry?.resumable === true;
33251
33307
  const copiedRefs = await this.copyAttachmentRefsToThread(
33252
33308
  refs,
33253
33309
  parentStub,
@@ -33270,10 +33326,11 @@ ${resultContent}${attachmentSummary}`;
33270
33326
  });
33271
33327
  }
33272
33328
  const terminalChildRun = sessionStopped || hasTerminalSessionTools;
33329
+ const terminateChildThread = terminalChildRun && !resumableChild;
33273
33330
  await parentStub.updateChildRegistryStatus(
33274
33331
  parentThreadId,
33275
33332
  threadId,
33276
- terminalChildRun ? "terminated" : "idle"
33333
+ terminateChildThread ? "terminated" : "idle"
33277
33334
  );
33278
33335
  if (parentCommunication !== "explicit") {
33279
33336
  await this.persistParentHandoffStatusMessage(
@@ -33281,23 +33338,22 @@ ${resultContent}${attachmentSummary}`;
33281
33338
  isErrorTerminal ? "failure" : "result"
33282
33339
  );
33283
33340
  }
33284
- if (terminalChildRun) {
33341
+ if (terminateChildThread) {
33285
33342
  await this.terminateThread(threadId);
33286
33343
  }
33287
33344
  } catch (error) {
33288
33345
  console.error("[DurableThread] Failed to deliver subagent completion to parent:", error);
33289
33346
  }
33290
33347
  }
33291
- async getParentCommunicationModeForChild(parentStub, parentThreadId, childThreadId) {
33348
+ async getParentRegistryEntryForChild(parentStub, parentThreadId, childThreadId) {
33292
33349
  if (typeof parentStub.getChildrenRegistry !== "function") {
33293
- return "implicit";
33350
+ return void 0;
33294
33351
  }
33295
33352
  try {
33296
33353
  const entries = await parentStub.getChildrenRegistry(parentThreadId);
33297
- const childEntry = entries.find((entry) => entry.reference === childThreadId);
33298
- return childEntry?.parentCommunication === "explicit" ? "explicit" : "implicit";
33354
+ return entries.find((entry) => entry.reference === childThreadId);
33299
33355
  } catch {
33300
- return "implicit";
33356
+ return void 0;
33301
33357
  }
33302
33358
  }
33303
33359
  /**
@@ -34845,7 +34901,7 @@ ${resultContent}${attachmentSummary}`;
34845
34901
  void 0,
34846
34902
  INTERNAL_TOOL_DELIVERY
34847
34903
  );
34848
- if (delivered?.resume) sides.add(delivered.side);
34904
+ if (delivered) sides.add(delivered.side);
34849
34905
  }
34850
34906
  if (threadId) {
34851
34907
  for (const side of sides) {
@@ -35147,17 +35203,14 @@ ${resultContent}${attachmentSummary}`;
35147
35203
  deliveredResultWaiters = /* @__PURE__ */ new Map();
35148
35204
  notifyDeliveredResultWaiters(toolCallId) {
35149
35205
  const waiters = this.deliveredResultWaiters?.get(toolCallId);
35150
- if (!waiters || waiters.size === 0) return false;
35206
+ if (!waiters) return;
35151
35207
  this.deliveredResultWaiters.delete(toolCallId);
35152
- let notified = false;
35153
35208
  for (const wake of waiters) {
35154
35209
  try {
35155
35210
  wake();
35156
- notified = true;
35157
35211
  } catch {
35158
35212
  }
35159
35213
  }
35160
- return notified;
35161
35214
  }
35162
35215
  /**
35163
35216
  * Await a parked forwarded call's delivered result: one immediate read,
@@ -35302,46 +35355,37 @@ ${resultContent}${attachmentSummary}`;
35302
35355
  const side = pending.side === "b" ? "b" : "a";
35303
35356
  const content = ok ? result ?? "" : `Error: ${error ?? "tool failed"}`;
35304
35357
  const toolStatus = ok ? "success" : "error";
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'`,
35358
+ await this.ctx.storage.sql.exec(
35359
+ `UPDATE messages SET content = ?, tool_status = ? WHERE tool_call_id = ? AND role = 'tool'`,
35360
+ content,
35361
+ toolStatus,
35362
+ toolCallId
35363
+ );
35364
+ const updated = await this.ctx.storage.sql.exec(
35365
+ `SELECT COUNT(*) AS total FROM messages WHERE tool_call_id = ? AND role = 'tool'`,
35366
+ toolCallId
35367
+ );
35368
+ if (Number(updated.toArray()[0]?.total ?? 0) === 0) {
35369
+ const toolRow = await this.ctx.storage.sql.exec(
35370
+ `SELECT tool FROM pending_client_calls WHERE tool_call_id = ? LIMIT 1`,
35312
35371
  toolCallId
35313
35372
  );
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'`,
35373
+ await this.ctx.storage.sql.exec(
35374
+ `INSERT INTO messages (id, role, content, name, tool_call_id, tool_status, created_at, status, prompt)
35375
+ VALUES (?, 'tool', ?, ?, ?, ?, ?, 'completed', NULL)`,
35376
+ crypto.randomUUID(),
35317
35377
  content,
35378
+ toolRow.toArray()[0]?.tool ?? null,
35379
+ toolCallId,
35318
35380
  toolStatus,
35319
- toolCallId
35320
- );
35321
- const updated = this.ctx.storage.sql.exec(
35322
- `SELECT COUNT(*) AS total FROM messages WHERE tool_call_id = ? AND role = 'tool'`,
35323
- toolCallId
35381
+ Date.now() * TIMESTAMP_MULTIPLIER
35324
35382
  );
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);
35383
+ }
35384
+ await this.ctx.storage.sql.exec(
35385
+ `UPDATE pending_client_calls SET status = 'resolved' WHERE tool_call_id = ?`,
35386
+ toolCallId
35387
+ );
35388
+ this.notifyDeliveredResultWaiters(toolCallId);
35345
35389
  try {
35346
35390
  const msgCursor = await this.ctx.storage.sql.exec(
35347
35391
  `SELECT id, role, content, name, tool_call_id, tool_status, created_at, depth
@@ -35352,7 +35396,7 @@ ${resultContent}${attachmentSummary}`;
35352
35396
  if (msg) this.broadcastMessage(msg);
35353
35397
  } catch {
35354
35398
  }
35355
- return { side, resume: !resumedInline };
35399
+ return { side };
35356
35400
  }
35357
35401
  // ─── Runtime byte streams ──────────────────────────────────────────────────
35358
35402
  // The existing bridge frames carry opaque capability metadata and bytes
@@ -36526,11 +36570,12 @@ ${resultContent}${attachmentSummary}`;
36526
36570
  if (!parentThreadId) return;
36527
36571
  const parentId = this.env.AGENT_BUILDER_THREAD.idFromName(parentThreadId);
36528
36572
  const parentStub = this.env.AGENT_BUILDER_THREAD.get(parentId);
36529
- const parentCommunication = await this.getParentCommunicationModeForChild(
36573
+ const childRegistryEntry = await this.getParentRegistryEntryForChild(
36530
36574
  parentStub,
36531
36575
  parentThreadId,
36532
36576
  threadId
36533
36577
  );
36578
+ const parentCommunication = childRegistryEntry?.parentCommunication === "explicit" ? "explicit" : "implicit";
36534
36579
  if (parentCommunication !== "explicit") {
36535
36580
  await parentStub.queueMessage(parentThreadId, {
36536
36581
  role: "user",