mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
perf(cron): lazy-load embedded runtime branch
This commit is contained in:
3
src/cron/isolated-agent/run-embedded.runtime.ts
Normal file
3
src/cron/isolated-agent/run-embedded.runtime.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { resolveFastModeState } from "../../agents/fast-mode.js";
|
||||
export { resolveNestedAgentLane } from "../../agents/lanes.js";
|
||||
export { runEmbeddedPiAgent } from "../../agents/pi-embedded.js";
|
||||
@@ -1,11 +1,8 @@
|
||||
export { resolveEffectiveModelFallbacks } from "../../agents/agent-scope.js";
|
||||
export { resolveBootstrapWarningSignaturesSeen } from "../../agents/bootstrap-budget.js";
|
||||
export { resolveFastModeState } from "../../agents/fast-mode.js";
|
||||
export { resolveNestedAgentLane } from "../../agents/lanes.js";
|
||||
export { LiveSessionModelSwitchError } from "../../agents/live-model-switch.js";
|
||||
export { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
export { isCliProvider } from "../../agents/model-selection.js";
|
||||
export { runEmbeddedPiAgent } from "../../agents/pi-embedded.js";
|
||||
export { normalizeVerboseLevel } from "../../auto-reply/thinking.js";
|
||||
export { resolveSessionTranscriptPath } from "../../config/sessions/paths.js";
|
||||
export { registerAgentRunContext } from "../../infra/agent-events.js";
|
||||
|
||||
@@ -12,11 +12,8 @@ import {
|
||||
normalizeVerboseLevel,
|
||||
registerAgentRunContext,
|
||||
resolveBootstrapWarningSignaturesSeen,
|
||||
resolveFastModeState,
|
||||
resolveNestedAgentLane,
|
||||
resolveSessionTranscriptPath,
|
||||
runCliAgent,
|
||||
runEmbeddedPiAgent,
|
||||
runWithModelFallback,
|
||||
} from "./run-execution.runtime.js";
|
||||
import { resolveCronFallbacksOverride } from "./run-fallback-policy.js";
|
||||
@@ -30,10 +27,17 @@ import { isLikelyInterimCronMessage } from "./subagent-followup-hints.js";
|
||||
|
||||
type AgentTurnPayload = Extract<CronJob["payload"], { kind: "agentTurn" }> | null;
|
||||
type CronPromptRunResult = Awaited<ReturnType<typeof runCliAgent>>;
|
||||
type CronEmbeddedRuntime = typeof import("./run-embedded.runtime.js");
|
||||
type CronSubagentRegistryRuntime = typeof import("./run-subagent-registry.runtime.js");
|
||||
|
||||
let cronEmbeddedRuntimePromise: Promise<CronEmbeddedRuntime> | undefined;
|
||||
let cronSubagentRegistryRuntimePromise: Promise<CronSubagentRegistryRuntime> | undefined;
|
||||
|
||||
async function loadCronEmbeddedRuntime() {
|
||||
cronEmbeddedRuntimePromise ??= import("./run-embedded.runtime.js");
|
||||
return await cronEmbeddedRuntimePromise;
|
||||
}
|
||||
|
||||
async function loadCronSubagentRegistryRuntime() {
|
||||
cronSubagentRegistryRuntimePromise ??= import("./run-subagent-registry.runtime.js");
|
||||
return await cronSubagentRegistryRuntimePromise;
|
||||
@@ -135,6 +139,8 @@ export function createCronPromptExecutor(params: {
|
||||
);
|
||||
return result;
|
||||
}
|
||||
const { resolveFastModeState, resolveNestedAgentLane, runEmbeddedPiAgent } =
|
||||
await loadCronEmbeddedRuntime();
|
||||
const result = await runEmbeddedPiAgent({
|
||||
sessionId: params.cronSession.sessionEntry.sessionId,
|
||||
sessionKey: params.agentSessionKey,
|
||||
|
||||
@@ -160,6 +160,12 @@ vi.mock("./run-auth-profile.runtime.js", () => ({
|
||||
resolveSessionAuthProfileOverride: resolveSessionAuthProfileOverrideMock,
|
||||
}));
|
||||
|
||||
vi.mock("./run-embedded.runtime.js", () => ({
|
||||
resolveFastModeState: resolveFastModeStateMock,
|
||||
resolveNestedAgentLane: resolveNestedAgentLaneMock,
|
||||
runEmbeddedPiAgent: runEmbeddedPiAgentMock,
|
||||
}));
|
||||
|
||||
vi.mock("./run-subagent-registry.runtime.js", () => ({
|
||||
countActiveDescendantRuns: countActiveDescendantRunsMock,
|
||||
listDescendantRunsForRequester: listDescendantRunsForRequesterMock,
|
||||
|
||||
Reference in New Issue
Block a user