Files
openclaw/src/plugins/loader-sdk-import-guardrails.test.ts
Peter Steinberger 1507a9701b refactor: centralize inbound supplemental context
* refactor: centralize inbound supplemental context

* refactor: trim supplemental finalizer typing

* docs: clarify supplemental context projection

* refactor: move inbound finalization into core

* refactor: simplify channel inbound facts

* refactor: fold supplemental media into inbound finalizer

* refactor: migrate channel inbound callers to builder

* docs: mark inbound finalizer compat types deprecated

* refactor: wire runtime turn context builder

* refactor: replace channel turn runtime API

* fix: respect discord quote visibility

* fix: avoid deprecated line dispatch helper

* refactor: deprecate channel message SDK seams

* docs: trim channel outbound SDK page

* test: migrate irc inbound assertion

* refactor: deprecate outbound SDK facades

* refactor: deprecate channel helper SDK facades

* refactor: deprecate channel streaming SDK facade

* refactor: move direct dm helpers into inbound SDK

* chore: mark legacy test-utils SDK alias deprecated

* refactor: remove unused allow-from read helper

* refactor: route remaining channel dispatch through core

* refactor: enforce modern extension SDK imports

* test: give slow image root tests more time

* ci: support node fallback on windows

* fix: add transcripts tool display metadata

* refactor: trim legacy channel test seams

* fix: preserve channel compat after rebase

* fix: keep deprecated channel inbound aliases

* fix: preserve discord thread context visibility

* fix: clean final rebase conflicts

* fix: preserve channel message dispatch aliases

* fix: sync channel refactor after rebase

* fix: sync channel refactor after latest main

* fix: dedupe memory-core subagent mock

* test: align clickclack inbound dispatch assertions

* fix: sync plugin sdk api hash after rebase

* fix: sync channel refactor after latest main

* fix: sync plugin sdk api hash after rebase

* fix: sync plugin sdk api hash after latest main

* test: remove stale inbound context awaits
2026-05-27 09:26:06 +01:00

48 lines
1.9 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
const ALLOWED_PLUGIN_SDK_FIXTURE_IMPORTS = new Set([
// Intentional legacy SDK-root compatibility smoke tests.
'src/plugins/loader.test.ts:configSchema: (require("openclaw/plugin-sdk").emptyPluginConfigSchema)(),',
'src/plugins/loader.test.ts:const { onDiagnosticEvent } = require("openclaw/plugin-sdk");',
// Intentional jiti alias regression test.
'src/plugins/loader.git-path-regression.test.ts:`import { resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";',
'src/plugins/loader.git-path-regression.test.ts: "openclaw/plugin-sdk/channel-outbound": ${JSON.stringify(copiedChannelRuntimeShim)},',
// Intentional packaged bundled-plugin SDK alias regression tests.
'src/plugins/loader.test.ts:`import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";`,',
]);
const LOADER_FIXTURE_TEST_FILES = [
"src/plugins/loader.cli-metadata.test.ts",
"src/plugins/loader.git-path-regression.test.ts",
"src/plugins/loader.test.ts",
];
function findLoaderFixtureSdkImports(): string[] {
const repoRoot = process.cwd();
const matches: string[] = [];
for (const file of LOADER_FIXTURE_TEST_FILES) {
const source = fs.readFileSync(path.join(repoRoot, file), "utf-8");
for (const line of source.split("\n")) {
if (
line.includes('require("openclaw/plugin-sdk') ||
(line.includes("import ") && line.includes('"openclaw/plugin-sdk'))
) {
matches.push(`${file}:${line.trim()}`);
}
}
}
return matches;
}
describe("plugin loader fixture SDK imports", () => {
it("keeps generated jiti plugin fixtures off the SDK except explicit compatibility smokes", () => {
const unexpected = findLoaderFixtureSdkImports().filter(
(entry) => !ALLOWED_PLUGIN_SDK_FIXTURE_IMPORTS.has(entry),
);
expect(unexpected).toStrictEqual([]);
});
});