fix: avoid ineffective dynamic imports

This commit is contained in:
Peter Steinberger
2026-03-13 01:33:29 +00:00
parent b14a5c6713
commit 268a8592de
7 changed files with 13 additions and 6 deletions

View File

@@ -0,0 +1 @@
export { ensureAuthProfileStore } from "./auth-profiles.js";

View File

@@ -157,7 +157,8 @@ function ensureContextWindowCacheLoaded(): Promise<void> {
}
try {
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery.js");
const { discoverAuthStorage, discoverModels } =
await import("./pi-model-discovery-runtime.js");
const agentDir = resolveOpenClawAgentDir();
const authStorage = discoverAuthStorage(agentDir);
const modelRegistry = discoverModels(authStorage, agentDir) as unknown as ModelRegistryLike;

View File

@@ -30,7 +30,7 @@ type PiSdkModule = typeof import("./pi-model-discovery.js");
let modelCatalogPromise: Promise<ModelCatalogEntry[]> | null = null;
let hasLoggedModelCatalogError = false;
const defaultImportPiSdk = () => import("./pi-model-discovery.js");
const defaultImportPiSdk = () => import("./pi-model-discovery-runtime.js");
let importPiSdk = defaultImportPiSdk;
const CODEX_PROVIDER = "openai-codex";

View File

@@ -1 +1,6 @@
export { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js";
export {
AuthStorage,
discoverAuthStorage,
discoverModels,
ModelRegistry,
} from "./pi-model-discovery.js";

View File

@@ -365,7 +365,7 @@ export async function createModelSelectionState(params: {
}
if (sessionEntry && sessionStore && sessionKey && sessionEntry.authProfileOverride) {
const { ensureAuthProfileStore } = await import("../../agents/auth-profiles.js");
const { ensureAuthProfileStore } = await import("../../agents/auth-profiles.runtime.js");
const store = ensureAuthProfileStore(undefined, {
allowKeychainPrompt: false,
});

View File

@@ -25,7 +25,7 @@ export async function modelsListCommand(
runtime: RuntimeEnv,
) {
ensureFlagCompatibility(opts);
const { ensureAuthProfileStore } = await import("../../agents/auth-profiles.js");
const { ensureAuthProfileStore } = await import("../../agents/auth-profiles.runtime.js");
const { ensureOpenClawModelsJson } = await import("../../agents/models-config.js");
const { sourceConfig, resolvedConfig: cfg } = await loadModelsConfigWithSource({
commandName: "models list",

View File

@@ -409,7 +409,7 @@ export async function runOnboardingWizard(
const { applyOnboardingLocalWorkspaceConfig } = await import("../commands/onboard-config.js");
let nextConfig: OpenClawConfig = applyOnboardingLocalWorkspaceConfig(baseConfig, workspaceDir);
const { ensureAuthProfileStore } = await import("../agents/auth-profiles.js");
const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js");
const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js");
const { promptCustomApiConfig } = await import("../commands/onboard-custom.js");
const { applyAuthChoice, resolvePreferredProviderForAuthChoice, warnIfModelConfigLooksOff } =