From aac7a31599f906eaddea6c54c630dd02740989e1 Mon Sep 17 00:00:00 2001 From: Ryanba <92616678+Gujiassh@users.noreply.github.com> Date: Sun, 15 Mar 2026 01:57:07 +0800 Subject: [PATCH] fix(plugin-sdk): preserve absolute plugin entrypoints (#1323) Authored-by: Sisyphus --- packages/plugin-sdk/src/plugin-host/core.test.ts | 16 ++++++++++++++++ packages/plugin-sdk/src/plugin-host/core.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/plugin-sdk/src/plugin-host/core.test.ts b/packages/plugin-sdk/src/plugin-host/core.test.ts index 62b5c1e52..ed1c3daa5 100644 --- a/packages/plugin-sdk/src/plugin-host/core.test.ts +++ b/packages/plugin-sdk/src/plugin-host/core.test.ts @@ -116,6 +116,22 @@ describe('for FileSystemPluginHost', () => { })).toBe('/tmp/plugin/electron-entry.ts') }) + it('should preserve absolute runtime entrypoints', () => { + const host = new FileSystemLoader() + + expect(host.resolveEntrypointFor({ + apiVersion: 'v1', + kind: 'manifest.plugin.airi.moeru.ai', + name: 'test-plugin', + entrypoints: { + node: '/opt/plugins/entry.ts', + }, + }, { + cwd: '/tmp/plugin', + runtime: 'node', + })).toBe('/opt/plugins/entry.ts') + }) + it('should throw deterministic error when no runtime entrypoint exists', () => { const host = new FileSystemLoader() diff --git a/packages/plugin-sdk/src/plugin-host/core.ts b/packages/plugin-sdk/src/plugin-host/core.ts index 15d2167eb..87e3a42bf 100644 --- a/packages/plugin-sdk/src/plugin-host/core.ts +++ b/packages/plugin-sdk/src/plugin-host/core.ts @@ -13,7 +13,7 @@ import type { CapabilityDescriptor } from '../plugin/apis/protocol' import type { Plugin } from '../plugin/shared' import type { PluginTransport } from './transports' -import { join } from 'node:path' +import { isAbsolute, join } from 'node:path' import { cwd } from 'node:process' import { defineInvokeHandler } from '@moeru/eventa' @@ -1080,7 +1080,7 @@ export class FileSystemLoader { ) } - return join(root, entrypoint) + return isAbsolute(entrypoint) ? entrypoint : join(root, entrypoint) } /**