























@@ -163,12 +163,25 @@ function createPluginSdkAliasTargetFixture(params?: {
163163distFile: "channel-runtime.js",
164164packageExports: {
165165"./plugin-sdk/channel-runtime": { default: "./dist/plugin-sdk/channel-runtime.js" },
166+"./plugin-sdk/plugin-entry": { default: "./dist/plugin-sdk/plugin-entry.js" },
166167},
167168});
168169const sourceRootAlias = path.join(fixture.root, "src", "plugin-sdk", "root-alias.cjs");
169170const distRootAlias = path.join(fixture.root, "dist", "plugin-sdk", "root-alias.cjs");
171+const sourcePluginEntryPath = path.join(fixture.root, "src", "plugin-sdk", "plugin-entry.ts");
172+const distPluginEntryPath = path.join(fixture.root, "dist", "plugin-sdk", "plugin-entry.js");
170173fs.writeFileSync(sourceRootAlias, "module.exports = {};\n", "utf-8");
171174fs.writeFileSync(distRootAlias, "module.exports = {};\n", "utf-8");
175+fs.writeFileSync(
176+sourcePluginEntryPath,
177+"export const definePluginEntry = (entry) => entry;\n",
178+"utf-8",
179+);
180+fs.writeFileSync(
181+distPluginEntryPath,
182+"export const definePluginEntry = (entry) => entry;\n",
183+"utf-8",
184+);
172185return {
173186 fixture,
174187 sourceRootAlias,
@@ -180,6 +193,8 @@ function createPluginSdkAliasTargetFixture(params?: {
180193`channel-runtime${sourceChannelRuntimeExtension}`,
181194),
182195distChannelRuntimePath: path.join(fixture.root, "dist", "plugin-sdk", "channel-runtime.js"),
196+ sourcePluginEntryPath,
197+ distPluginEntryPath,
183198};
184199}
185200@@ -191,16 +206,25 @@ function writePluginEntry(root: string, relativePath: string) {
191206}
192207193208function createUserInstalledPluginSdkAliasFixture() {
194-const { fixture, sourceRootAlias, sourceChannelRuntimePath } =
209+const { fixture, sourcePluginEntryPath, sourceRootAlias, sourceChannelRuntimePath } =
195210createPluginSdkAliasTargetFixture();
196211const externalPluginRoot = path.join(makeTempDir(), ".openclaw", "extensions", "demo");
197212const externalPluginEntry = path.join(externalPluginRoot, "index.ts");
198213mkdirSafeDir(externalPluginRoot);
199-fs.writeFileSync(externalPluginEntry, 'export const plugin = "demo";\n', "utf-8");
214+fs.writeFileSync(
215+externalPluginEntry,
216+[
217+'import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";',
218+'export default definePluginEntry({ id: "demo", register() {} });',
219+"",
220+].join("\n"),
221+"utf-8",
222+);
200223return {
201224 externalPluginEntry,
202225 externalPluginRoot,
203226 fixture,
227+ sourcePluginEntryPath,
204228 sourceRootAlias,
205229 sourceChannelRuntimePath,
206230};
@@ -251,6 +275,7 @@ function expectPluginSdkAliasTargets(
251275params: {
252276rootAliasPath: string;
253277channelRuntimePath?: string;
278+pluginEntryPath?: string;
254279},
255280) {
256281expect(fs.realpathSync(aliases["openclaw/plugin-sdk"] ?? "")).toBe(
@@ -267,6 +292,14 @@ function expectPluginSdkAliasTargets(
267292fs.realpathSync(params.channelRuntimePath),
268293);
269294}
295+if (params.pluginEntryPath) {
296+expect(fs.realpathSync(aliases["openclaw/plugin-sdk/plugin-entry"] ?? "")).toBe(
297+fs.realpathSync(params.pluginEntryPath),
298+);
299+expect(fs.realpathSync(aliases["@openclaw/plugin-sdk/plugin-entry"] ?? "")).toBe(
300+fs.realpathSync(params.pluginEntryPath),
301+);
302+}
270303}
271304272305function expectPluginSdkAliasResolution(params: {
@@ -798,6 +831,7 @@ describe("plugin sdk alias helpers", () => {
798831 externalPluginEntry,
799832 externalPluginRoot,
800833 fixture,
834+ sourcePluginEntryPath,
801835 sourceRootAlias,
802836 sourceChannelRuntimePath,
803837} = createUserInstalledPluginSdkAliasFixture();
@@ -811,6 +845,7 @@ describe("plugin sdk alias helpers", () => {
811845expectPluginSdkAliasTargets(aliases, {
812846rootAliasPath: sourceRootAlias,
813847channelRuntimePath: sourceChannelRuntimePath,
848+pluginEntryPath: sourcePluginEntryPath,
814849});
815850});
816851@@ -819,6 +854,7 @@ describe("plugin sdk alias helpers", () => {
819854 externalPluginEntry,
820855 externalPluginRoot,
821856 fixture,
857+ sourcePluginEntryPath,
822858 sourceRootAlias,
823859 sourceChannelRuntimePath,
824860} = createUserInstalledPluginSdkAliasFixture();
@@ -850,6 +886,7 @@ describe("plugin sdk alias helpers", () => {
850886expectPluginSdkAliasTargets(aliases, {
851887rootAliasPath: sourceRootAlias,
852888channelRuntimePath: sourceChannelRuntimePath,
889+pluginEntryPath: sourcePluginEntryPath,
853890});
854891});
855892此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。