mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
perf(agents): lazy-load delivery runtime
This commit is contained in:
@@ -30,7 +30,7 @@ vi.mock("./command/attempt-execution.runtime.js", () => ({
|
||||
sessionFileHasContent: vi.fn(async () => false),
|
||||
}));
|
||||
|
||||
vi.mock("./command/delivery.js", () => ({
|
||||
vi.mock("./command/delivery.runtime.js", () => ({
|
||||
deliverAgentCommandResult: (...args: unknown[]) => state.deliverAgentCommandResultMock(...args),
|
||||
}));
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ import {
|
||||
persistSessionEntry as persistSessionEntryBase,
|
||||
prependInternalEventContext,
|
||||
} from "./command/attempt-execution.shared.js";
|
||||
import { deliverAgentCommandResult } from "./command/delivery.js";
|
||||
import { resolveAgentRunContext } from "./command/run-context.js";
|
||||
import { updateSessionStoreAfterAgentRun } from "./command/session-store.js";
|
||||
import { resolveSession } from "./command/session.js";
|
||||
@@ -79,9 +78,11 @@ import { ensureAgentWorkspace } from "./workspace.js";
|
||||
|
||||
const log = createSubsystemLogger("agents/agent-command");
|
||||
type AttemptExecutionRuntime = typeof import("./command/attempt-execution.runtime.js");
|
||||
type DeliveryRuntime = typeof import("./command/delivery.runtime.js");
|
||||
type TranscriptResolveRuntime = typeof import("../config/sessions/transcript-resolve.runtime.js");
|
||||
|
||||
let attemptExecutionRuntimePromise: Promise<AttemptExecutionRuntime> | undefined;
|
||||
let deliveryRuntimePromise: Promise<DeliveryRuntime> | undefined;
|
||||
let transcriptResolveRuntimePromise: Promise<TranscriptResolveRuntime> | undefined;
|
||||
|
||||
function loadAttemptExecutionRuntime(): Promise<AttemptExecutionRuntime> {
|
||||
@@ -89,6 +90,11 @@ function loadAttemptExecutionRuntime(): Promise<AttemptExecutionRuntime> {
|
||||
return attemptExecutionRuntimePromise;
|
||||
}
|
||||
|
||||
function loadDeliveryRuntime(): Promise<DeliveryRuntime> {
|
||||
deliveryRuntimePromise ??= import("./command/delivery.runtime.js");
|
||||
return deliveryRuntimePromise;
|
||||
}
|
||||
|
||||
function loadTranscriptResolveRuntime(): Promise<TranscriptResolveRuntime> {
|
||||
transcriptResolveRuntimePromise ??= import("../config/sessions/transcript-resolve.runtime.js");
|
||||
return transcriptResolveRuntimePromise;
|
||||
@@ -557,6 +563,7 @@ async function agentCommandInternal(
|
||||
abortSignal: opts.abortSignal,
|
||||
});
|
||||
const payloads = result.payloads;
|
||||
const { deliverAgentCommandResult } = await loadDeliveryRuntime();
|
||||
|
||||
return await deliverAgentCommandResult({
|
||||
cfg,
|
||||
@@ -1031,6 +1038,7 @@ async function agentCommandInternal(
|
||||
}
|
||||
|
||||
const payloads = result.payloads ?? [];
|
||||
const { deliverAgentCommandResult } = await loadDeliveryRuntime();
|
||||
return await deliverAgentCommandResult({
|
||||
cfg,
|
||||
deps,
|
||||
|
||||
1
src/agents/command/delivery.runtime.ts
Normal file
1
src/agents/command/delivery.runtime.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { deliverAgentCommandResult } from "./delivery.js";
|
||||
Reference in New Issue
Block a user