Files
openclaw/src/plugins/plugin-metadata-snapshot.types.ts
WhatsSkiLL 22b8e1cf4f fix(plugins): scope startup metadata manifest reads
Limit plugin metadata snapshots to the channel, provider, and startup surfaces that need them, while preserving unscoped fallback for incomplete index data and provider runtime resolution.

Refs #70533.
Refs #84628.

Co-authored-by: IWhatsskill <IWhatsskill@users.noreply.github.com>
2026-05-31 11:58:56 +01:00

80 lines
2.8 KiB
TypeScript

import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { PluginDiscoveryResult } from "./discovery.js";
import type { InstalledPluginIndex } from "./installed-plugin-index-types.js";
import type { PluginManifestRecord, PluginManifestRegistry } from "./manifest-registry.js";
import type { PluginDiagnostic } from "./manifest-types.js";
import type { PluginRegistrySnapshotSource } from "./plugin-registry-snapshot.types.js";
export type PluginMetadataSnapshotPluginIdScope = {
key: string;
resolve: (params: { index: InstalledPluginIndex }) => readonly string[] | undefined;
};
export type PluginMetadataSnapshotOwnerMaps = {
channels: ReadonlyMap<string, readonly string[]>;
channelConfigs: ReadonlyMap<string, readonly string[]>;
providers: ReadonlyMap<string, readonly string[]>;
modelCatalogProviders: ReadonlyMap<string, readonly string[]>;
cliBackends: ReadonlyMap<string, readonly string[]>;
setupProviders: ReadonlyMap<string, readonly string[]>;
commandAliases: ReadonlyMap<string, readonly string[]>;
contracts: ReadonlyMap<string, readonly string[]>;
};
export type PluginMetadataSnapshotMetrics = {
registrySnapshotMs: number;
manifestRegistryMs: number;
ownerMapsMs: number;
totalMs: number;
indexPluginCount: number;
manifestPluginCount: number;
};
export type PluginMetadataSnapshotRegistryDiagnostic = {
level: "info" | "warn";
code:
| "persisted-registry-disabled"
| "persisted-registry-missing"
| "persisted-registry-stale-policy"
| "persisted-registry-stale-source";
message: string;
};
export type PluginMetadataSnapshot = {
policyHash: string;
configFingerprint?: string;
pluginIds?: readonly string[];
registrySource?: PluginRegistrySnapshotSource;
workspaceDir?: string;
index: InstalledPluginIndex;
registryDiagnostics: readonly PluginMetadataSnapshotRegistryDiagnostic[];
manifestRegistry: PluginManifestRegistry;
plugins: readonly PluginManifestRecord[];
diagnostics: readonly PluginDiagnostic[];
byPluginId: ReadonlyMap<string, PluginManifestRecord>;
normalizePluginId: (pluginId: string) => string;
owners: PluginMetadataSnapshotOwnerMaps;
metrics: PluginMetadataSnapshotMetrics;
discovery?: PluginDiscoveryResult;
};
export type PluginMetadataRegistryView = Pick<PluginMetadataSnapshot, "index" | "manifestRegistry">;
export type PluginMetadataManifestView = Pick<PluginMetadataSnapshot, "index" | "plugins">;
export type LoadPluginMetadataSnapshotParams = {
config?: OpenClawConfig;
workspaceDir?: string;
stateDir?: string;
env?: NodeJS.ProcessEnv;
index?: InstalledPluginIndex;
pluginIds?: readonly string[];
pluginIdScope?: PluginMetadataSnapshotPluginIdScope;
preferPersisted?: boolean;
};
export type ResolvePluginMetadataSnapshotParams = LoadPluginMetadataSnapshotParams & {
allowCurrent?: boolean;
allowWorkspaceScopedCurrent?: boolean;
};