perf(cron): lazy-load run executor runtime

This commit is contained in:
Vincent Koc
2026-04-13 18:30:54 +01:00
parent c70be4b4af
commit a5980df101
2 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1 @@
export { executeCronRun, type CronExecutionResult } from "./run-executor.js";

View File

@@ -19,7 +19,6 @@ import {
} from "./helpers.js";
import { resolveCronModelSelection } from "./model-selection.js";
import { buildCronAgentDefaultsConfig } from "./run-config.js";
import { executeCronRun, type CronExecutionResult } from "./run-executor.js";
import {
createPersistCronSessionEntry,
markCronSessionPreRun,
@@ -61,6 +60,7 @@ import { resolveCronSkillsSnapshot } from "./skills-snapshot.js";
let sessionStoreRuntimePromise:
| Promise<typeof import("../../config/sessions/store.runtime.js")>
| undefined;
let cronExecutorRuntimePromise: Promise<typeof import("./run-executor.runtime.js")> | undefined;
let cronAuthProfileRuntimePromise:
| Promise<typeof import("./run-auth-profile.runtime.js")>
| undefined;
@@ -74,6 +74,11 @@ async function loadSessionStoreRuntime() {
return await sessionStoreRuntimePromise;
}
async function loadCronExecutorRuntime() {
cronExecutorRuntimePromise ??= import("./run-executor.runtime.js");
return await cronExecutorRuntimePromise;
}
async function loadCronAuthProfileRuntime() {
cronAuthProfileRuntimePromise ??= import("./run-auth-profile.runtime.js");
return await cronAuthProfileRuntimePromise;
@@ -102,6 +107,8 @@ function resolveNonNegativeNumber(value: number | undefined): number | undefined
export type { RunCronAgentTurnResult } from "./run.types.js";
type CronExecutionRuntime = typeof import("./run-executor.runtime.js");
type CronExecutionResult = Awaited<ReturnType<CronExecutionRuntime["executeCronRun"]>>;
type ResolvedCronDeliveryTarget = Awaited<ReturnType<typeof resolveDeliveryTarget>>;
type CronModelCatalogRuntime = typeof import("./run-model-catalog.runtime.js");
@@ -716,6 +723,7 @@ export async function runCronIsolatedAgentTurn(params: {
}
try {
const { executeCronRun } = await loadCronExecutorRuntime();
const execution = await executeCronRun({
cfg: params.cfg,
cfgWithAgentDefaults: prepared.context.cfgWithAgentDefaults,