Files
openclaw/src/config/runtime-schema.ts
Peter Steinberger 4314674054 perf: reuse plugin metadata snapshots (#85843)
* perf: reuse plugin metadata snapshots

* test: update plugin metadata snapshot mocks
2026-05-23 23:34:19 +01:00

39 lines
1.5 KiB
TypeScript

import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { resolvePluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
import {
collectChannelSchemaMetadata,
collectPluginSchemaMetadata,
} from "./channel-config-metadata.js";
import { getRuntimeConfig, readConfigFileSnapshot } from "./config.js";
import type { OpenClawConfig } from "./config.js";
import { buildConfigSchema, type ConfigSchemaResponse } from "./schema.js";
function loadManifestRegistry(config: OpenClawConfig, env?: NodeJS.ProcessEnv) {
const workspaceDir = resolveAgentWorkspaceDir(config, resolveDefaultAgentId(config));
return resolvePluginMetadataSnapshot({
config,
env: env ?? process.env,
workspaceDir,
allowWorkspaceScopedCurrent: true,
}).manifestRegistry;
}
export function loadGatewayRuntimeConfigSchema(): ConfigSchemaResponse {
const config = getRuntimeConfig();
const registry = loadManifestRegistry(config);
return buildConfigSchema({
plugins: collectPluginSchemaMetadata(registry),
channels: collectChannelSchemaMetadata(registry),
});
}
export async function readBestEffortRuntimeConfigSchema(): Promise<ConfigSchemaResponse> {
const snapshot = await readConfigFileSnapshot();
const config = snapshot.valid ? snapshot.config : { plugins: { enabled: true } };
const registry = loadManifestRegistry(config);
return buildConfigSchema({
plugins: snapshot.valid ? collectPluginSchemaMetadata(registry) : [],
channels: collectChannelSchemaMetadata(registry),
});
}