fix(plugins): share public surface source extensions

This commit is contained in:
Vincent Koc
2026-04-14 17:29:16 +01:00
parent 1b73ce9193
commit f12d6bf3bb
7 changed files with 31 additions and 8 deletions

View File

@@ -16,7 +16,10 @@ import {
loadPluginManifestRegistry,
type PluginManifestRecord,
} from "../plugins/manifest-registry.js";
import { normalizeBundledPluginArtifactSubpath } from "../plugins/public-surface-runtime.js";
import {
PUBLIC_SURFACE_SOURCE_EXTENSIONS,
normalizeBundledPluginArtifactSubpath,
} from "../plugins/public-surface-runtime.js";
const ALWAYS_ALLOWED_RUNTIME_DIR_NAMES = new Set([
"image-generation-core",
@@ -60,7 +63,6 @@ type FacadeModuleLocation = {
modulePath: string;
boundaryRoot: string;
};
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
function readFacadeBoundaryConfigSafely(): {
rawConfig: OpenClawConfig;

View File

@@ -10,13 +10,13 @@ import {
type PluginJitiLoaderFactory,
} from "../plugins/jiti-loader-cache.js";
import {
PUBLIC_SURFACE_SOURCE_EXTENSIONS,
normalizeBundledPluginArtifactSubpath,
resolveBundledPluginPublicSurfacePath,
} from "../plugins/public-surface-runtime.js";
import { resolveLoaderPackageRoot } from "../plugins/sdk-alias.js";
const CURRENT_MODULE_PATH = fileURLToPath(import.meta.url);
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
const nodeRequire = createRequire(import.meta.url);
const jitiLoaders: PluginJitiLoaderCache = new Map();

View File

@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
import { resolveBundledPluginsDir } from "../plugins/bundled-dir.js";
import type { PluginManifestRecord } from "../plugins/manifest-registry.js";
import {
PUBLIC_SURFACE_SOURCE_EXTENSIONS,
normalizeBundledPluginArtifactSubpath,
resolveBundledPluginPublicSurfacePath,
} from "../plugins/public-surface-runtime.js";
@@ -27,7 +28,6 @@ const OPENCLAW_PACKAGE_ROOT =
moduleUrl: import.meta.url,
}) ?? fileURLToPath(new URL("../..", import.meta.url));
const CURRENT_MODULE_PATH = fileURLToPath(import.meta.url);
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
const OPENCLAW_SOURCE_EXTENSIONS_ROOT = path.resolve(OPENCLAW_PACKAGE_ROOT, "extensions");
const cachedFacadeModuleLocationsByKey = new Map<
string,

View File

@@ -13,8 +13,8 @@ import type {
PluginManifest,
PluginManifestChannelConfig,
} from "./manifest.js";
import { PUBLIC_SURFACE_SOURCE_EXTENSIONS } from "./public-surface-runtime.js";
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
const SOURCE_CONFIG_SCHEMA_CANDIDATES = [
path.join("src", "config-schema.ts"),
path.join("src", "config-schema.js"),

View File

@@ -2,8 +2,8 @@ import fs from "node:fs";
import path from "node:path";
import { normalizeOptionalString } from "../shared/string-coerce.js";
import { normalizeTrimmedStringList } from "../shared/string-normalization.js";
import { PUBLIC_SURFACE_SOURCE_EXTENSIONS } from "./public-surface-runtime.js";
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
const RUNTIME_SIDECAR_ARTIFACTS = new Set([
"helper-api.js",
"light-runtime-api.js",

View File

@@ -1,7 +1,21 @@
import { describe, expect, it } from "vitest";
import { normalizeBundledPluginArtifactSubpath } from "./public-surface-runtime.js";
import {
PUBLIC_SURFACE_SOURCE_EXTENSIONS,
normalizeBundledPluginArtifactSubpath,
} from "./public-surface-runtime.js";
describe("bundled plugin public surface runtime", () => {
it("exports the canonical public surface source extension list", () => {
expect(PUBLIC_SURFACE_SOURCE_EXTENSIONS).toEqual([
".ts",
".mts",
".js",
".mjs",
".cts",
".cjs",
]);
});
it("allows plugin-local nested artifact paths", () => {
expect(normalizeBundledPluginArtifactSubpath("src/outbound-adapter.js")).toBe(
"src/outbound-adapter.js",

View File

@@ -2,7 +2,14 @@ import fs from "node:fs";
import path from "node:path";
import { resolveBundledPluginsDir } from "./bundled-dir.js";
const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [".ts", ".mts", ".js", ".mjs", ".cts", ".cjs"] as const;
export const PUBLIC_SURFACE_SOURCE_EXTENSIONS = [
".ts",
".mts",
".js",
".mjs",
".cts",
".cjs",
] as const;
export function normalizeBundledPluginArtifactSubpath(artifactBasename: string): string {
if (