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:
@@ -1307,6 +1307,147 @@ describe('OpenCodeRuntime embedded launcher', () => {
|
||||
})
|
||||
|
||||
describe('OpenCodeRuntime embedded permission mediation', () => {
|
||||
it('shares assigned custom MCP only with embedded Execute through a scoped loopback token', async () => {
|
||||
const setup = runClient([
|
||||
{
|
||||
id: 'idle',
|
||||
type: 'session.idle',
|
||||
properties: { sessionID: 'session-1' }
|
||||
}
|
||||
])
|
||||
const gateway = {
|
||||
getEndpoint: vi.fn(() => 'http://127.0.0.1:4567/mcp'),
|
||||
grantCustomMcp: vi.fn(() => 'custom-capability'),
|
||||
prepareCustomMcpTools: vi.fn(async () => [
|
||||
{
|
||||
name: 'mcp_12345678_abcdef01_private_tool',
|
||||
inputSchema: { type: 'object' }
|
||||
}
|
||||
]),
|
||||
revoke: vi.fn()
|
||||
} as unknown as KnowledgeMcpGateway
|
||||
const runtime = embeddedRuntime(setup.client, {
|
||||
knowledgeGateway: gateway,
|
||||
mcpServers: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000092',
|
||||
name: 'Private MCP',
|
||||
description: '',
|
||||
enabled: true,
|
||||
allowDynamicTools: false,
|
||||
assignments: ['opencode'],
|
||||
secretConfigured: true,
|
||||
secret: 'must-stay-in-main',
|
||||
transport: 'http',
|
||||
url: 'https://private.example/mcp'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await collectRun(runtime, 'execute')
|
||||
|
||||
expect(gateway.grantCustomMcp).toHaveBeenCalledWith(
|
||||
'3f496642-f47d-4e0a-8944-a32c77b0d6ef',
|
||||
expect.any(Array),
|
||||
expect.any(AbortSignal)
|
||||
)
|
||||
expect(setup.client.mcp.add).toHaveBeenCalledWith({
|
||||
directory: process.cwd(),
|
||||
name: expect.stringMatching(/^goodbuddy-custom-[a-f0-9]{20}$/u),
|
||||
config: {
|
||||
type: 'remote',
|
||||
url: 'http://127.0.0.1:4567/mcp',
|
||||
enabled: true,
|
||||
headers: {
|
||||
Authorization: 'Bearer custom-capability'
|
||||
},
|
||||
oauth: false
|
||||
}
|
||||
})
|
||||
expect(JSON.stringify(
|
||||
(setup.client.mcp.add as unknown as ReturnType<typeof vi.fn>)
|
||||
.mock.calls
|
||||
)).not.toContain('must-stay-in-main')
|
||||
expect(JSON.stringify(
|
||||
(setup.client.mcp.add as unknown as ReturnType<typeof vi.fn>)
|
||||
.mock.calls
|
||||
)).not.toContain('private.example')
|
||||
expect(gateway.revoke).toHaveBeenCalledWith('custom-capability')
|
||||
await runtime.dispose()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['ask', true] as const,
|
||||
['execute', false] as const
|
||||
])(
|
||||
'does not share custom MCP with OpenCode in %s mode when embedded is %s',
|
||||
async (workMode, embedded) => {
|
||||
const setup = runClient([
|
||||
{
|
||||
id: 'idle',
|
||||
type: 'session.idle',
|
||||
properties: { sessionID: 'session-1' }
|
||||
}
|
||||
])
|
||||
const gateway = {
|
||||
getEndpoint: vi.fn(() => 'http://127.0.0.1:4567/mcp'),
|
||||
grantCustomMcp: vi.fn(() => 'custom-capability'),
|
||||
prepareCustomMcpTools: vi.fn(async () => []),
|
||||
revoke: vi.fn()
|
||||
} as unknown as KnowledgeMcpGateway
|
||||
const runtime = embedded
|
||||
? embeddedRuntime(setup.client, {
|
||||
knowledgeGateway: gateway,
|
||||
mcpServers: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000093',
|
||||
name: 'Private MCP',
|
||||
description: '',
|
||||
enabled: true,
|
||||
allowDynamicTools: false,
|
||||
assignments: ['opencode'],
|
||||
secretConfigured: false,
|
||||
transport: 'stdio',
|
||||
command: 'private-command',
|
||||
args: []
|
||||
}
|
||||
]
|
||||
})
|
||||
: new OpenCodeRuntime(
|
||||
options({
|
||||
baseUrl: 'http://127.0.0.1:4096',
|
||||
embedded: false,
|
||||
knowledgeGateway: gateway,
|
||||
mcpServers: [
|
||||
{
|
||||
id: '00000000-0000-4000-8000-000000000093',
|
||||
name: 'Private MCP',
|
||||
description: '',
|
||||
enabled: true,
|
||||
allowDynamicTools: false,
|
||||
assignments: ['opencode'],
|
||||
secretConfigured: false,
|
||||
transport: 'stdio',
|
||||
command: 'private-command',
|
||||
args: []
|
||||
}
|
||||
]
|
||||
}),
|
||||
dependencies(fakeChild(), {
|
||||
createClient: vi.fn(
|
||||
() => setup.client
|
||||
) as unknown as typeof createOpencodeClient
|
||||
}).deps
|
||||
)
|
||||
|
||||
await collectRun(runtime, workMode)
|
||||
|
||||
expect(gateway.grantCustomMcp).not.toHaveBeenCalled()
|
||||
expect(setup.client.mcp.add).not.toHaveBeenCalled()
|
||||
await runtime.dispose()
|
||||
}
|
||||
)
|
||||
|
||||
it('parses OpenCode questions and sends the selected answers back', async () => {
|
||||
const setup = runClient([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user