perf(memory): lazy-load matrix secret config input

This commit is contained in:
Vincent Koc
2026-04-02 13:46:06 +09:00
parent a398520ac8
commit bfa561b1a7
2 changed files with 16 additions and 5 deletions

View File

@@ -0,0 +1 @@
export { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/config-runtime";

View File

@@ -1,15 +1,12 @@
import {
coerceSecretRef,
resolveConfiguredSecretInputString,
} from "openclaw/plugin-sdk/config-runtime";
import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/infra-runtime";
import { coerceSecretRef } from "openclaw/plugin-sdk/provider-auth";
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
import {
requiresExplicitMatrixDefaultAccount,
resolveMatrixDefaultOrOnlyAccountId,
} from "../../account-selection.js";
import { resolveMatrixAccountStringValues } from "../../auth-precedence.js";
import { getMatrixScopedEnvVarNames } from "../../env-vars.js";
import { normalizeResolvedSecretInputString } from "../../runtime-api.js";
import { getMatrixRuntime } from "../../runtime.js";
import type { CoreConfig } from "../../types.js";
import {
@@ -39,8 +36,13 @@ type MatrixCredentialsReadDeps = {
credentialsMatchConfig: typeof import("../credentials-read.js").credentialsMatchConfig;
};
type MatrixSecretInputDeps = {
resolveConfiguredSecretInputString: typeof import("./config-secret-input.runtime.js").resolveConfiguredSecretInputString;
};
let matrixAuthClientDepsPromise: Promise<MatrixAuthClientDeps> | undefined;
let matrixCredentialsReadDepsPromise: Promise<MatrixCredentialsReadDeps> | undefined;
let matrixSecretInputDepsPromise: Promise<MatrixSecretInputDeps> | undefined;
let matrixAuthClientDepsForTest: MatrixAuthClientDeps | undefined;
export function setMatrixAuthClientDepsForTest(
@@ -77,6 +79,13 @@ async function loadMatrixCredentialsReadDeps(): Promise<MatrixCredentialsReadDep
return await matrixCredentialsReadDepsPromise;
}
async function loadMatrixSecretInputDeps(): Promise<MatrixSecretInputDeps> {
matrixSecretInputDepsPromise ??= import("./config-secret-input.runtime.js").then((runtime) => ({
resolveConfiguredSecretInputString: runtime.resolveConfiguredSecretInputString,
}));
return await matrixSecretInputDepsPromise;
}
function readEnvSecretRefFallback(params: {
value: unknown;
env?: NodeJS.ProcessEnv;
@@ -273,6 +282,7 @@ async function resolveConfiguredMatrixAuthSecretInput(params: {
return undefined;
}
const { resolveConfiguredSecretInputString } = await loadMatrixSecretInputDeps();
const resolved = await resolveConfiguredSecretInputString({
config: params.cfg,
env: params.env,