Skip to content

Commit 1481b60

Browse files
committed
fix(cron): adopt registerHeadlessToolSearchCatalog after tool-search symbol localization
Upstream #101831 made registerToolSearchCatalog module-private; fold the headless ref-only catalog registration into one public seam.
1 parent fc7f6ae commit 1481b60

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/agents/code-mode-headless.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { afterEach, describe, expect, it, vi } from "vitest";
22
import { runCodeModeScriptHeadless, testing, type CodeModeHeadlessResult } from "./code-mode.js";
33
import {
4-
buildToolSearchCatalogEntries,
54
createToolSearchCatalogRef,
6-
registerToolSearchCatalog,
5+
registerHeadlessToolSearchCatalog,
76
type ToolSearchToolContext,
87
} from "./tool-search.js";
98
import { jsonResult, type AnyAgentTool } from "./tools/common.js";
@@ -23,10 +22,7 @@ function createHeadlessHarness(tools: AnyAgentTool[] = []): ToolSearchToolContex
2322
tools: { codeMode: { enabled: false, timeoutMs: 60_000 } },
2423
} as never;
2524
const catalogRef = createToolSearchCatalogRef();
26-
registerToolSearchCatalog({
27-
catalogRef,
28-
entries: buildToolSearchCatalogEntries(tools),
29-
});
25+
registerHeadlessToolSearchCatalog({ catalogRef, tools });
3026
return {
3127
config,
3228
runtimeConfig: config,

src/agents/tool-search.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,18 @@ function shouldCatalogTool(tool: AnyAgentTool): boolean {
713713
return true;
714714
}
715715

716-
/** Build policy-wrapped entries for a catalog owned only by an explicit ref. */
717-
export function buildToolSearchCatalogEntries(
718-
tools: readonly AnyAgentTool[],
719-
hookContext?: HookContext,
720-
): ToolSearchCatalogEntry[] {
721-
return tools
716+
/**
717+
* Register a catalog owned only by an explicit ref (no session keys), for
718+
* headless callers like cron trigger evaluation. Registration internals stay
719+
* module-private; this is the single public seam for ref-only catalogs.
720+
*/
721+
export function registerHeadlessToolSearchCatalog(params: {
722+
catalogRef: ToolSearchCatalogRef;
723+
tools: readonly AnyAgentTool[];
724+
hookContext?: HookContext;
725+
}): void {
726+
const { catalogRef, tools, hookContext } = params;
727+
const entries = tools
722728
.filter((tool) => shouldCatalogTool(tool))
723729
.map((tool) => {
724730
const scopedTool =
@@ -727,6 +733,7 @@ export function buildToolSearchCatalogEntries(
727733
: tool;
728734
return toCatalogEntry(scopedTool, undefined, hookContext);
729735
});
736+
registerToolSearchCatalog({ catalogRef, entries });
730737
}
731738

732739
export function collectUniqueCatalogToolNames(tools: readonly AnyAgentTool[]): Set<string> {

src/cron/trigger-script.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import {
2424
import { ensureRuntimePluginsLoaded } from "../agents/runtime-plugins.js";
2525
import { resolveSandboxContext } from "../agents/sandbox.js";
2626
import {
27-
buildToolSearchCatalogEntries,
2827
createToolSearchCatalogRef,
29-
registerToolSearchCatalog,
28+
registerHeadlessToolSearchCatalog,
3029
type ToolSearchToolContext,
3130
} from "../agents/tool-search.js";
3231
import type { AnyAgentTool } from "../agents/tools/common.js";
@@ -404,12 +403,10 @@ export function createCronTriggerEvaluator(deps: CronTriggerEvaluatorDeps) {
404403

405404
const catalogRef = createToolSearchCatalogRef();
406405
const runId = `cron-trigger:${params.jobId}:${crypto.randomUUID()}`;
407-
registerToolSearchCatalog({
406+
registerHeadlessToolSearchCatalog({
408407
catalogRef,
409-
entries: buildToolSearchCatalogEntries(runtime.tools, {
410-
...runtime.hookContext,
411-
runId,
412-
}),
408+
tools: runtime.tools,
409+
hookContext: { ...runtime.hookContext, runId },
413410
});
414411
const remainingWallClockMs = evaluationScope.deadline - Date.now();
415412
if (remainingWallClockMs <= 0) {

0 commit comments

Comments
 (0)