mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-05-01 06:36:23 +08:00
perf(cron): lazy-load isolated cli runner runtime
This commit is contained in:
1
src/cron/isolated-agent/run-execution-cli.runtime.ts
Normal file
1
src/cron/isolated-agent/run-execution-cli.runtime.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { getCliSessionId, runCliAgent } from "../../agents/cli-runner.runtime.js";
|
||||
@@ -1,6 +1,5 @@
|
||||
export { resolveEffectiveModelFallbacks } from "../../agents/agent-scope.js";
|
||||
export { resolveBootstrapWarningSignaturesSeen } from "../../agents/bootstrap-budget.js";
|
||||
export { getCliSessionId, runCliAgent } from "../../agents/cli-runner.runtime.js";
|
||||
export { resolveFastModeState } from "../../agents/fast-mode.js";
|
||||
export { resolveNestedAgentLane } from "../../agents/lanes.js";
|
||||
export { LiveSessionModelSwitchError } from "../../agents/live-model-switch.js";
|
||||
@@ -15,3 +14,26 @@ export { normalizeVerboseLevel } from "../../auto-reply/thinking.js";
|
||||
export { resolveSessionTranscriptPath } from "../../config/sessions.js";
|
||||
export { registerAgentRunContext } from "../../infra/agent-events.js";
|
||||
export { logWarn } from "../../logger.js";
|
||||
|
||||
let cronExecutionCliRuntimePromise:
|
||||
| Promise<typeof import("./run-execution-cli.runtime.js")>
|
||||
| undefined;
|
||||
|
||||
async function loadCronExecutionCliRuntime() {
|
||||
cronExecutionCliRuntimePromise ??= import("./run-execution-cli.runtime.js");
|
||||
return await cronExecutionCliRuntimePromise;
|
||||
}
|
||||
|
||||
export async function getCliSessionId(
|
||||
...args: Parameters<typeof import("../../agents/cli-session.js").getCliSessionId>
|
||||
): Promise<ReturnType<typeof import("../../agents/cli-session.js").getCliSessionId>> {
|
||||
const runtime = await loadCronExecutionCliRuntime();
|
||||
return runtime.getCliSessionId(...args);
|
||||
}
|
||||
|
||||
export async function runCliAgent(
|
||||
...args: Parameters<typeof import("../../agents/cli-runner.js").runCliAgent>
|
||||
): ReturnType<typeof import("../../agents/cli-runner.js").runCliAgent> {
|
||||
const runtime = await loadCronExecutionCliRuntime();
|
||||
return runtime.runCliAgent(...args);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import type { CronJob } from "../types.js";
|
||||
import { resolveCronPayloadOutcome } from "./helpers.js";
|
||||
import {
|
||||
countActiveDescendantRuns,
|
||||
listDescendantRunsForRequester,
|
||||
LiveSessionModelSwitchError,
|
||||
getCliSessionId,
|
||||
isCliProvider,
|
||||
listDescendantRunsForRequester,
|
||||
LiveSessionModelSwitchError,
|
||||
logWarn,
|
||||
normalizeVerboseLevel,
|
||||
registerAgentRunContext,
|
||||
@@ -104,7 +104,7 @@ export function createCronPromptExecutor(params: {
|
||||
if (isCliProvider(providerOverride, params.cfgWithAgentDefaults)) {
|
||||
const cliSessionId = params.cronSession.isNewSession
|
||||
? undefined
|
||||
: getCliSessionId(params.cronSession.sessionEntry, providerOverride);
|
||||
: await getCliSessionId(params.cronSession.sessionEntry, providerOverride);
|
||||
const result = await runCliAgent({
|
||||
sessionId: params.cronSession.sessionEntry.sessionId,
|
||||
sessionKey: params.agentSessionKey,
|
||||
|
||||
@@ -31,6 +31,7 @@ export { normalizeThinkLevel, supportsXHighThinking } from "../../auto-reply/thi
|
||||
export { createOutboundSendDeps } from "../../cli/outbound-send-deps.js";
|
||||
export {
|
||||
resolveAgentMainSessionKey,
|
||||
resolveSessionTranscriptPath,
|
||||
setSessionRuntimeModel,
|
||||
updateSessionStore,
|
||||
} from "../../config/sessions.js";
|
||||
|
||||
@@ -121,6 +121,7 @@ vi.mock("./run.runtime.js", () => ({
|
||||
ensureAgentWorkspace: ensureAgentWorkspaceMock,
|
||||
normalizeThinkLevel: normalizeThinkLevelMock,
|
||||
supportsXHighThinking: supportsXHighThinkingMock,
|
||||
resolveSessionTranscriptPath: resolveSessionTranscriptPathMock,
|
||||
setSessionRuntimeModel: setSessionRuntimeModelMock,
|
||||
setCliSessionId: vi.fn(),
|
||||
logWarn: (...args: unknown[]) => logWarnMock(...args),
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
} from "./helpers.js";
|
||||
import { resolveCronModelSelection } from "./model-selection.js";
|
||||
import { buildCronAgentDefaultsConfig } from "./run-config.js";
|
||||
import { resolveSessionTranscriptPath } from "./run-execution.runtime.js";
|
||||
import { executeCronRun, type CronExecutionResult } from "./run-executor.js";
|
||||
import {
|
||||
createPersistCronSessionEntry,
|
||||
@@ -50,6 +49,7 @@ import {
|
||||
resolveCronStyleNow,
|
||||
resolveDefaultAgentId,
|
||||
resolveHookExternalContentSource,
|
||||
resolveSessionTranscriptPath,
|
||||
resolveSessionAuthProfileOverride,
|
||||
resolveThinkingDefault,
|
||||
setSessionRuntimeModel,
|
||||
|
||||
Reference in New Issue
Block a user