refactor(plugins): decouple bundled plugin runtime loading

This commit is contained in:
Peter Steinberger
2026-03-29 09:08:06 +01:00
parent 1738d540f4
commit 8e0ab35b0e
582 changed files with 8057 additions and 22869 deletions

View File

@@ -2,14 +2,15 @@ import { readFileSync } from "node:fs";
import path from "node:path";
import ts from "typescript";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { loadRuntimeApiExportTypesViaJiti } from "../../../test/helpers/extensions/jiti-runtime-api.ts";
import { bundledPluginRoot } from "../../../test/helpers/bundled-plugin-paths.js";
import { loadRuntimeApiExportTypesViaJiti } from "../../../test/helpers/plugins/jiti-runtime-api.ts";
import {
createPluginSetupWizardConfigure,
createTestWizardPrompter,
runSetupWizardConfigure,
type WizardPrompter,
} from "../../../test/helpers/extensions/setup-wizard.js";
import { createStartAccountContext } from "../../../test/helpers/extensions/start-account-context.js";
} from "../../../test/helpers/plugins/setup-wizard.js";
import { createStartAccountContext } from "../../../test/helpers/plugins/start-account-context.js";
import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "../api.js";
import { linePlugin } from "./channel.js";
import { clearLineRuntime, setLineRuntime } from "./runtime.js";
@@ -28,13 +29,14 @@ vi.mock("@line/bot-sdk", () => ({
const lineConfigure = createPluginSetupWizardConfigure(linePlugin);
let probeLineBot: typeof import("./probe.js").probeLineBot;
const LINE_SRC_PREFIX = `../../${bundledPluginRoot("line")}/src/`;
function normalizeModuleSpecifier(specifier: string): string | null {
if (specifier.startsWith("./src/")) {
return specifier;
}
if (specifier.startsWith("../../extensions/line/src/")) {
return `./src/${specifier.slice("../../extensions/line/src/".length)}`;
if (specifier.startsWith(LINE_SRC_PREFIX)) {
return `./src/${specifier.slice(LINE_SRC_PREFIX.length)}`;
}
return null;
}