feat: add DSH plugin marketplace and shared MCP
GoodBuddy could share Skills across runtimes, but custom MCP remained limited and DeepSeek Harness could not manage third-party extensions. The app now provides a default-off DSH npm marketplace with managed installation, configuration, failure isolation, and packaged npm support, while assigned custom MCP is available to managed OpenCode, Continue Agent, and DeepSeek Harness in Execute. Third-party DSH install scripts, initialization, and tools run with the current user's permissions. Ask remains read-only at dispatch, and turning off the marketplace hides management without disabling installed plugins. Release note: 新增默认关闭的 DSH 插件市场,并让自定义 MCP 可分配给 OpenCode、Continue 和 DeepSeek Harness;安装第三方插件前会明确提示当前用户权限边界。
This commit is contained in:
@@ -357,6 +357,149 @@ vi.mock('./channels/channel-env', () => ({
|
||||
)
|
||||
}))
|
||||
|
||||
describe('registerIpcHandlers DSH runtime extensions', () => {
|
||||
afterEach(() => {
|
||||
electronMocks.handlers.clear()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('validates extension actions, reloads the Runtime, and trusts only the renderer', async () => {
|
||||
const webContents = {
|
||||
mainFrame: { url: 'file:///goodbuddy/index.html' },
|
||||
getURL: vi.fn(() => 'file:///goodbuddy/index.html'),
|
||||
isDestroyed: vi.fn(() => false),
|
||||
send: vi.fn()
|
||||
}
|
||||
const window = {
|
||||
webContents,
|
||||
isDestroyed: vi.fn(() => false),
|
||||
isMaximized: vi.fn(() => false),
|
||||
on: vi.fn(),
|
||||
removeListener: vi.fn()
|
||||
}
|
||||
const snapshot = {
|
||||
marketplaceEnabled: true,
|
||||
catalog: [],
|
||||
installed: []
|
||||
}
|
||||
const runtimeExtensionStore = {
|
||||
getSnapshot: vi.fn(async () => snapshot),
|
||||
applyWithResult: vi.fn(async () => ({
|
||||
snapshot,
|
||||
changed: true
|
||||
}))
|
||||
}
|
||||
const onRuntimeSettingsChanged = vi.fn(async () => undefined)
|
||||
const dispose = registerIpcHandlers(
|
||||
window as never,
|
||||
{ capability: 'text' } as never,
|
||||
'CommandOrControl+Shift+Space',
|
||||
{} as never,
|
||||
{} as never,
|
||||
{ clear: vi.fn() } as never,
|
||||
{} as never,
|
||||
{ claimDueSchedules: vi.fn(() => []) } as never,
|
||||
{ clear: vi.fn() } as never,
|
||||
{} as never,
|
||||
onRuntimeSettingsChanged,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
runtimeExtensionStore as never
|
||||
)
|
||||
const event = {
|
||||
sender: webContents,
|
||||
senderFrame: webContents.mainFrame
|
||||
}
|
||||
const action = {
|
||||
type: 'set-enabled',
|
||||
extensionId: 'dsh-plugin-greet',
|
||||
enabled: true
|
||||
}
|
||||
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsSnapshot
|
||||
)?.(event)
|
||||
).resolves.toEqual(snapshot)
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsApply
|
||||
)?.(event, action)
|
||||
).resolves.toEqual(snapshot)
|
||||
expect(
|
||||
runtimeExtensionStore.applyWithResult
|
||||
).toHaveBeenCalledWith(action)
|
||||
expect(onRuntimeSettingsChanged).toHaveBeenCalledOnce()
|
||||
const marketplaceAction = {
|
||||
type: 'set-marketplace-enabled',
|
||||
enabled: false
|
||||
}
|
||||
runtimeExtensionStore.applyWithResult.mockResolvedValueOnce({
|
||||
snapshot: {
|
||||
...snapshot,
|
||||
marketplaceEnabled: false
|
||||
},
|
||||
changed: true
|
||||
})
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsApply
|
||||
)?.(event, marketplaceAction)
|
||||
).resolves.toEqual({
|
||||
...snapshot,
|
||||
marketplaceEnabled: false
|
||||
})
|
||||
expect(
|
||||
runtimeExtensionStore.applyWithResult
|
||||
).toHaveBeenLastCalledWith(marketplaceAction)
|
||||
expect(onRuntimeSettingsChanged).toHaveBeenCalledOnce()
|
||||
runtimeExtensionStore.applyWithResult.mockResolvedValueOnce({
|
||||
snapshot,
|
||||
changed: false
|
||||
})
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsApply
|
||||
)?.(event, action)
|
||||
).resolves.toEqual(snapshot)
|
||||
expect(onRuntimeSettingsChanged).toHaveBeenCalledOnce()
|
||||
|
||||
await expect(
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsApply
|
||||
)?.(event, {
|
||||
...action,
|
||||
extensionId: 'Invalid Extension'
|
||||
})
|
||||
).rejects.toThrow()
|
||||
expect(() =>
|
||||
electronMocks.handlers.get(
|
||||
ipcChannels.runtimeExtensionsSnapshot
|
||||
)?.({
|
||||
sender: {},
|
||||
senderFrame: webContents.mainFrame
|
||||
})
|
||||
).toThrow('拒绝来自未知窗口的 IPC 请求')
|
||||
|
||||
await dispose()
|
||||
})
|
||||
})
|
||||
|
||||
describe('registerIpcHandlers lifecycle tracking', () => {
|
||||
afterEach(() => {
|
||||
electronMocks.handlers.clear()
|
||||
|
||||
Reference in New Issue
Block a user