mirror of https://github.com/openclaw/openclaw.git
perf(reply): lazy-load media path normalization
This commit is contained in:
parent
462d7ad9c0
commit
7bfa261c42
|
|
@ -47,9 +47,17 @@ import {
|
|||
import { type BlockReplyPipeline } from "./block-reply-pipeline.js";
|
||||
import type { FollowupRun } from "./queue.js";
|
||||
import { createBlockReplyDeliveryHandler } from "./reply-delivery.js";
|
||||
import { createReplyMediaPathNormalizer } from "./reply-media-paths.js";
|
||||
import type { TypingSignaler } from "./typing-mode.js";
|
||||
|
||||
let replyMediaPathsRuntimePromise: Promise<
|
||||
typeof import("./reply-media-paths.runtime.js")
|
||||
> | null = null;
|
||||
|
||||
function loadReplyMediaPathsRuntime() {
|
||||
replyMediaPathsRuntimePromise ??= import("./reply-media-paths.runtime.js");
|
||||
return replyMediaPathsRuntimePromise;
|
||||
}
|
||||
|
||||
export type RuntimeFallbackAttempt = {
|
||||
provider: string;
|
||||
model: string;
|
||||
|
|
@ -109,6 +117,7 @@ export async function runAgentTurnWithFallback(params: {
|
|||
const directlySentBlockKeys = new Set<string>();
|
||||
|
||||
const runId = params.opts?.runId ?? crypto.randomUUID();
|
||||
const { createReplyMediaPathNormalizer } = await loadReplyMediaPathsRuntime();
|
||||
const normalizeReplyMediaPaths = createReplyMediaPathNormalizer({
|
||||
cfg: params.followupRun.run.config,
|
||||
sessionKey: params.sessionKey,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ import { readPostCompactionContext } from "./post-compaction-context.js";
|
|||
import { resolveActiveRunQueueAction } from "./queue-policy.js";
|
||||
import { enqueueFollowupRun } from "./queue/enqueue.js";
|
||||
import type { FollowupRun, QueueSettings } from "./queue/types.js";
|
||||
import { createReplyMediaPathNormalizer } from "./reply-media-paths.js";
|
||||
import { createReplyToModeFilterForChannel, resolveReplyToMode } from "./reply-threading.js";
|
||||
import { incrementRunCompactionCount, persistRunSessionUsage } from "./session-run-accounting.js";
|
||||
import { createTypingSignaler } from "./typing-mode.js";
|
||||
|
|
@ -68,6 +67,9 @@ let usageCostRuntimePromise: Promise<typeof import("./usage-cost.runtime.js")> |
|
|||
let contextTokensRuntimePromise: Promise<
|
||||
typeof import("../../agents/context-tokens.runtime.js")
|
||||
> | null = null;
|
||||
let replyMediaPathsRuntimePromise: Promise<
|
||||
typeof import("./reply-media-paths.runtime.js")
|
||||
> | null = null;
|
||||
|
||||
function loadPiEmbeddedQueueRuntime() {
|
||||
piEmbeddedQueueRuntimePromise ??= import("../../agents/pi-embedded-queue.runtime.js");
|
||||
|
|
@ -94,6 +96,11 @@ function loadContextTokensRuntime() {
|
|||
return contextTokensRuntimePromise;
|
||||
}
|
||||
|
||||
function loadReplyMediaPathsRuntime() {
|
||||
replyMediaPathsRuntimePromise ??= import("./reply-media-paths.runtime.js");
|
||||
return replyMediaPathsRuntimePromise;
|
||||
}
|
||||
|
||||
export async function runReplyAgent(params: {
|
||||
commandBody: string;
|
||||
followupRun: FollowupRun;
|
||||
|
|
@ -189,6 +196,7 @@ export async function runReplyAgent(params: {
|
|||
);
|
||||
const applyReplyToMode = createReplyToModeFilterForChannel(replyToMode, replyToChannel);
|
||||
const cfg = followupRun.run.config;
|
||||
const { createReplyMediaPathNormalizer } = await loadReplyMediaPathsRuntime();
|
||||
const normalizeReplyMediaPaths = createReplyMediaPathNormalizer({
|
||||
cfg,
|
||||
sessionKey,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export { createReplyMediaPathNormalizer } from "./reply-media-paths.js";
|
||||
Loading…
Reference in New Issue