mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 21:55:18 +00:00
perf: reuse plugin metadata snapshots (#85843)
* perf: reuse plugin metadata snapshots * test: update plugin metadata snapshot mocks
This commit is contained in:
committed by
GitHub
parent
45fbf2d81a
commit
4314674054
@@ -45,6 +45,7 @@ vi.mock("../../agents/agent-scope.js", () => ({
|
||||
|
||||
vi.mock("../plugin-metadata-snapshot.js", () => ({
|
||||
loadPluginMetadataSnapshot: loadPluginMetadataSnapshotMock,
|
||||
resolvePluginMetadataSnapshot: loadPluginMetadataSnapshotMock,
|
||||
}));
|
||||
|
||||
vi.mock("../current-plugin-metadata-snapshot.js", () => ({
|
||||
@@ -121,6 +122,7 @@ describe("resolvePluginRuntimeLoadContext", () => {
|
||||
installRecords: {},
|
||||
});
|
||||
expect(loadPluginMetadataSnapshotMock).toHaveBeenCalledWith({
|
||||
allowWorkspaceScopedCurrent: true,
|
||||
config: rawConfig,
|
||||
env,
|
||||
workspaceDir: "/resolved-workspace",
|
||||
|
||||
@@ -7,14 +7,13 @@ import { createSubsystemLogger } from "../../logging.js";
|
||||
import { resolvePluginActivationSourceConfig } from "../activation-source-config.js";
|
||||
import {
|
||||
clearCurrentPluginMetadataSnapshot,
|
||||
getCurrentPluginMetadataSnapshot,
|
||||
isReusableCurrentPluginMetadataSnapshot,
|
||||
setCurrentPluginMetadataSnapshot,
|
||||
} from "../current-plugin-metadata-snapshot.js";
|
||||
import { extractPluginInstallRecordsFromInstalledPluginIndex } from "../installed-plugin-index-install-records.js";
|
||||
import type { PluginLoadOptions } from "../loader.js";
|
||||
import type { PluginManifestRegistry } from "../manifest-registry.js";
|
||||
import { loadPluginMetadataSnapshot } from "../plugin-metadata-snapshot.js";
|
||||
import { resolvePluginMetadataSnapshot } from "../plugin-metadata-snapshot.js";
|
||||
import type { PluginLogger } from "../types.js";
|
||||
|
||||
const log = createSubsystemLogger("plugins");
|
||||
@@ -70,16 +69,12 @@ export function resolvePluginRuntimeLoadContext(
|
||||
options?.workspaceDir ?? resolveAgentWorkspaceDir(rawConfig, resolveDefaultAgentId(rawConfig));
|
||||
const metadataSnapshot = options?.manifestRegistry
|
||||
? undefined
|
||||
: (getCurrentPluginMetadataSnapshot({
|
||||
: resolvePluginMetadataSnapshot({
|
||||
config: rawConfig,
|
||||
env,
|
||||
workspaceDir: rawWorkspaceDir,
|
||||
}) ??
|
||||
loadPluginMetadataSnapshot({
|
||||
config: rawConfig,
|
||||
env,
|
||||
workspaceDir: rawWorkspaceDir,
|
||||
}));
|
||||
allowWorkspaceScopedCurrent: true,
|
||||
});
|
||||
const manifestRegistry = options?.manifestRegistry ?? metadataSnapshot?.manifestRegistry;
|
||||
const installRecords = metadataSnapshot
|
||||
? extractPluginInstallRecordsFromInstalledPluginIndex(metadataSnapshot.index)
|
||||
|
||||
Reference in New Issue
Block a user