

























@@ -1,9 +1,6 @@
11import { mkdirSync, statSync } from "node:fs";
22import { afterEach, describe, expect, it, vi } from "vitest";
33import { requireNodeSqlite } from "../infra/node-sqlite.js";
4-import type { PluginRecord } from "../plugins/registry-types.js";
5-import { createPluginRegistry } from "../plugins/registry.js";
6-import { createPluginRuntime } from "../plugins/runtime/index.js";
74import { withOpenClawTestState } from "../test-utils/openclaw-test-state.js";
85import {
96closePluginStateSqliteStore,
@@ -16,42 +13,6 @@ import {
1613} from "./plugin-state-store.js";
1714import { resolvePluginStateDir, resolvePluginStateSqlitePath } from "./plugin-state-store.paths.js";
181519-function createPluginRecord(id: string, origin: PluginRecord["origin"] = "bundled"): PluginRecord {
20-return {
21- id,
22-name: id,
23-source: `/plugins/${id}/index.ts`,
24- origin,
25-enabled: true,
26-status: "loaded",
27-toolNames: [],
28-hookNames: [],
29-channelIds: [],
30-cliBackendIds: [],
31-providerIds: [],
32-speechProviderIds: [],
33-realtimeTranscriptionProviderIds: [],
34-realtimeVoiceProviderIds: [],
35-mediaUnderstandingProviderIds: [],
36-imageGenerationProviderIds: [],
37-videoGenerationProviderIds: [],
38-musicGenerationProviderIds: [],
39-webFetchProviderIds: [],
40-webSearchProviderIds: [],
41-migrationProviderIds: [],
42-memoryEmbeddingProviderIds: [],
43-agentHarnessIds: [],
44-gatewayMethods: [],
45-cliCommands: [],
46-services: [],
47-gatewayDiscoveryServiceIds: [],
48-commands: [],
49-httpRoutes: 0,
50-hookCount: 0,
51-configSchema: false,
52-} as PluginRecord;
53-}
54-5516afterEach(() => {
5617vi.useRealTimers();
5718resetPluginStateStoreForTests();
@@ -332,48 +293,3 @@ describe("plugin state keyed store", () => {
332293});
333294});
334295});
335-336-describe("plugin runtime state proxy", () => {
337-it("binds openKeyedStore to the bundled plugin id and keeps resolveStateDir", async () => {
338-await withOpenClawTestState({ label: "plugin-state-runtime" }, async (state) => {
339-const registry = createPluginRegistry({
340-logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
341-runtime: createPluginRuntime(),
342-});
343-const record = createPluginRecord("discord", "bundled");
344-registry.registry.plugins.push(record);
345-const api = registry.createApi(record, { config: {} });
346-347-expect(api.runtime.state.resolveStateDir()).toBe(state.stateDir);
348-const store = api.runtime.state.openKeyedStore<{ plugin: string }>({
349-namespace: "runtime",
350-maxEntries: 10,
351-});
352-await store.register("k", { plugin: "discord" });
353-354-const telegram = createPluginRecord("telegram", "bundled");
355-registry.registry.plugins.push(telegram);
356-const telegramApi = registry.createApi(telegram, { config: {} });
357-const telegramStore = telegramApi.runtime.state.openKeyedStore<{ plugin: string }>({
358-namespace: "runtime",
359-maxEntries: 10,
360-});
361-await expect(telegramStore.lookup("k")).resolves.toBeUndefined();
362-await expect(store.lookup("k")).resolves.toEqual({ plugin: "discord" });
363-});
364-});
365-366-it("rejects external plugins in this release", () => {
367-const registry = createPluginRegistry({
368-logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
369-runtime: createPluginRuntime(),
370-});
371-const record = createPluginRecord("external-plugin", "workspace");
372-registry.registry.plugins.push(record);
373-const api = registry.createApi(record, { config: {} });
374-375-expect(() =>
376-api.runtime.state.openKeyedStore({ namespace: "runtime", maxEntries: 10 }),
377-).toThrow("openKeyedStore is only available for bundled plugins");
378-});
379-});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。