From 26df54758cde8d961fc4721e7d97724fe91f695c Mon Sep 17 00:00:00 2001 From: Bek Date: Wed, 12 Aug 2026 21:05:22 -0400 Subject: [PATCH] fix(plugins): authorize installed Codex relay runtime --- src/plugins/sdk-alias.test.ts | 58 +++++++++++++++++++++++++++++++++-- src/plugins/sdk-alias.ts | 3 ++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/plugins/sdk-alias.test.ts b/src/plugins/sdk-alias.test.ts index 83c90946cda6..46ed66671a12 100644 --- a/src/plugins/sdk-alias.test.ts +++ b/src/plugins/sdk-alias.test.ts @@ -605,6 +605,11 @@ describe("plugin sdk alias helpers", () => { "export const codexMcpProjection = true;\n", "utf-8", ); + fs.writeFileSync( + path.join(fixture.root, "src", "plugin-sdk", "native-hook-relay-runtime.ts"), + "export const nativeHookRelayRuntime = true;\n", + "utf-8", + ); fs.writeFileSync( path.join(fixture.root, "src", "plugin-sdk", "qa-runtime.ts"), "export const qaRuntime = true;\n", @@ -673,8 +678,12 @@ describe("plugin sdk alias helpers", () => { ), ); - expect(codexSubpaths).toEqual(["codex-mcp-projection", "core"]); - expect(installedCodexSubpaths).toEqual(["codex-mcp-projection", "core"]); + expect(codexSubpaths).toEqual(["codex-mcp-projection", "core", "native-hook-relay-runtime"]); + expect(installedCodexSubpaths).toEqual([ + "codex-mcp-projection", + "core", + "native-hook-relay-runtime", + ]); expect(otherSubpaths).toEqual(["core"]); expect(installedOtherSubpaths).toEqual(["core"]); expect(shadowCodexSubpaths).toEqual(["core"]); @@ -860,6 +869,18 @@ describe("plugin sdk alias helpers", () => { "plugin-sdk", "codex-mcp-projection.js", ); + const sourceNativeHookRelayRuntimePath = path.join( + fixture.root, + "src", + "plugin-sdk", + "native-hook-relay-runtime.ts", + ); + const distNativeHookRelayRuntimePath = path.join( + fixture.root, + "dist", + "plugin-sdk", + "native-hook-relay-runtime.js", + ); const sourceQaRuntimePath = path.join(fixture.root, "src", "plugin-sdk", "qa-runtime.ts"); fs.rmSync( path.join(fixture.root, "scripts", "lib", "plugin-sdk-private-local-only-subpaths.json"), @@ -875,6 +896,16 @@ describe("plugin sdk alias helpers", () => { "export const codexMcpProjection = true;\n", "utf-8", ); + fs.writeFileSync( + sourceNativeHookRelayRuntimePath, + "export const nativeHookRelayRuntime = true;\n", + "utf-8", + ); + fs.writeFileSync( + distNativeHookRelayRuntimePath, + "export const nativeHookRelayRuntime = true;\n", + "utf-8", + ); fs.writeFileSync(sourceQaRuntimePath, "export const qaRuntime = true;\n", "utf-8"); const sourcePluginEntry = writePluginEntry( fixture.root, @@ -899,12 +930,23 @@ describe("plugin sdk alias helpers", () => { "plugin-sdk", "codex-mcp-projection.js", ); + const devNativeHookRelayRuntimePath = path.join( + devFixture.root, + "dist", + "plugin-sdk", + "native-hook-relay-runtime.js", + ); mkdirSafeDir(path.join(devFixture.root, "extensions")); fs.writeFileSync( devCodexMcpProjectionPath, "export const devCodexMcpProjection = true;\n", "utf-8", ); + fs.writeFileSync( + devNativeHookRelayRuntimePath, + "export const devNativeHookRelayRuntime = true;\n", + "utf-8", + ); const { packageRoot: installedCodexRoot, pluginEntry: installedCodexEntry } = writeInstalledPluginEntry({ installRoot: path.join(makeTempDir(), ".openclaw", "npm"), @@ -984,10 +1026,22 @@ describe("plugin sdk alias helpers", () => { expect(fs.realpathSync(devRootAliases["openclaw/plugin-sdk/codex-mcp-projection"] ?? "")).toBe( fs.realpathSync(devCodexMcpProjectionPath), ); + expect(fs.realpathSync(aliases["openclaw/plugin-sdk/native-hook-relay-runtime"] ?? "")).toBe( + fs.realpathSync(sourceNativeHookRelayRuntimePath), + ); + expect( + fs.realpathSync(installedAliases["openclaw/plugin-sdk/native-hook-relay-runtime"] ?? ""), + ).toBe(fs.realpathSync(distNativeHookRelayRuntimePath)); + expect( + fs.realpathSync(devRootAliases["openclaw/plugin-sdk/native-hook-relay-runtime"] ?? ""), + ).toBe(fs.realpathSync(devNativeHookRelayRuntimePath)); expect(aliases["openclaw/plugin-sdk/qa-runtime"]).toBeUndefined(); expect(otherAliases["openclaw/plugin-sdk/codex-mcp-projection"]).toBeUndefined(); + expect(otherAliases["openclaw/plugin-sdk/native-hook-relay-runtime"]).toBeUndefined(); expect(installedOtherAliases["openclaw/plugin-sdk/codex-mcp-projection"]).toBeUndefined(); + expect(installedOtherAliases["openclaw/plugin-sdk/native-hook-relay-runtime"]).toBeUndefined(); expect(shadowCodexAliases["openclaw/plugin-sdk/codex-mcp-projection"]).toBeUndefined(); + expect(shadowCodexAliases["openclaw/plugin-sdk/native-hook-relay-runtime"]).toBeUndefined(); }); it("aliases the SSRF internal helper only for bundled local IPC owner plugins", async () => { diff --git a/src/plugins/sdk-alias.ts b/src/plugins/sdk-alias.ts index 84b871140c0a..a8a732d1b849 100644 --- a/src/plugins/sdk-alias.ts +++ b/src/plugins/sdk-alias.ts @@ -419,6 +419,7 @@ const cachedWorkspacePackageAliasMaps = new PluginLruCache isSafePluginSdkSubpathSegment(subpath))