mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:40:43 +00:00
refactor: cache reply understanding imports
This commit is contained in:
@@ -47,6 +47,13 @@ let sessionResetModelRuntimePromise: Promise<
|
|||||||
let stageSandboxMediaRuntimePromise: Promise<
|
let stageSandboxMediaRuntimePromise: Promise<
|
||||||
typeof import("./stage-sandbox-media.runtime.js")
|
typeof import("./stage-sandbox-media.runtime.js")
|
||||||
> | null = null;
|
> | null = null;
|
||||||
|
let mediaUnderstandingApplyRuntimePromise: Promise<
|
||||||
|
typeof import("../../media-understanding/apply.runtime.js")
|
||||||
|
> | null = null;
|
||||||
|
let linkUnderstandingApplyRuntimePromise: Promise<
|
||||||
|
typeof import("../../link-understanding/apply.runtime.js")
|
||||||
|
> | null = null;
|
||||||
|
let commandsCoreRuntimePromise: Promise<typeof import("./commands-core.runtime.js")> | null = null;
|
||||||
|
|
||||||
function loadSessionResetModelRuntime() {
|
function loadSessionResetModelRuntime() {
|
||||||
sessionResetModelRuntimePromise ??= import("./session-reset-model.runtime.js");
|
sessionResetModelRuntimePromise ??= import("./session-reset-model.runtime.js");
|
||||||
@@ -58,6 +65,21 @@ function loadStageSandboxMediaRuntime() {
|
|||||||
return stageSandboxMediaRuntimePromise;
|
return stageSandboxMediaRuntimePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadMediaUnderstandingApplyRuntime() {
|
||||||
|
mediaUnderstandingApplyRuntimePromise ??= import("../../media-understanding/apply.runtime.js");
|
||||||
|
return mediaUnderstandingApplyRuntimePromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadLinkUnderstandingApplyRuntime() {
|
||||||
|
linkUnderstandingApplyRuntimePromise ??= import("../../link-understanding/apply.runtime.js");
|
||||||
|
return linkUnderstandingApplyRuntimePromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadCommandsCoreRuntime() {
|
||||||
|
commandsCoreRuntimePromise ??= import("./commands-core.runtime.js");
|
||||||
|
return commandsCoreRuntimePromise;
|
||||||
|
}
|
||||||
|
|
||||||
let hookRunnerGlobalPromise: Promise<typeof import("../../plugins/hook-runner-global.js")> | null =
|
let hookRunnerGlobalPromise: Promise<typeof import("../../plugins/hook-runner-global.js")> | null =
|
||||||
null;
|
null;
|
||||||
let originRoutingPromise: Promise<typeof import("./origin-routing.js")> | null = null;
|
let originRoutingPromise: Promise<typeof import("./origin-routing.js")> | null = null;
|
||||||
@@ -126,7 +148,7 @@ async function applyMediaUnderstandingIfNeeded(params: {
|
|||||||
if (!hasInboundMedia(params.ctx)) {
|
if (!hasInboundMedia(params.ctx)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const { applyMediaUnderstanding } = await import("../../media-understanding/apply.runtime.js");
|
const { applyMediaUnderstanding } = await loadMediaUnderstandingApplyRuntime();
|
||||||
await applyMediaUnderstanding(params);
|
await applyMediaUnderstanding(params);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -138,7 +160,7 @@ async function applyLinkUnderstandingIfNeeded(params: {
|
|||||||
if (!hasLinkCandidate(params.ctx)) {
|
if (!hasLinkCandidate(params.ctx)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const { applyLinkUnderstanding } = await import("../../link-understanding/apply.runtime.js");
|
const { applyLinkUnderstanding } = await loadLinkUnderstandingApplyRuntime();
|
||||||
await applyLinkUnderstanding(params);
|
await applyLinkUnderstanding(params);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -488,7 +510,7 @@ export async function getReplyFromConfig(
|
|||||||
if (!resetMatch) {
|
if (!resetMatch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { emitResetCommandHooks } = await import("./commands-core.runtime.js");
|
const { emitResetCommandHooks } = await loadCommandsCoreRuntime();
|
||||||
const action: ResetCommandAction = resetMatch[1] === "reset" ? "reset" : "new";
|
const action: ResetCommandAction = resetMatch[1] === "reset" ? "reset" : "new";
|
||||||
await emitResetCommandHooks({
|
await emitResetCommandHooks({
|
||||||
action,
|
action,
|
||||||
|
|||||||
Reference in New Issue
Block a user