Files
goodbuddy/src/main/deepseek-harness-host-bootstrap.ts
T
mesalogo ff61b5f81d 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;安装第三方插件前会明确提示当前用户权限边界。
2026-08-16 11:47:11 +08:00

108 lines
2.6 KiB
TypeScript

import {
DEEPSEEK_HARNESS_CONTROL_PROTOCOL,
DEEPSEEK_HARNESS_CONTROL_VERSION,
parseHarnessControlMessage,
type DeepSeekHarnessControlMessage
} from './agent/deepseek-harness-control-protocol'
import { createDeepSeekHarnessHostTransport } from './agent/deepseek-harness-utility-transport'
import {
createBoundedNdJsonStream,
ControlledHarnessHostStartupError,
installHarnessDiagnosticGuard,
startControlledDeepSeekHarnessHost,
type ControlledHarnessHost
} from './deepseek-harness-host'
const parentPort = process.parentPort
const restoreDiagnostics = installHarnessDiagnosticGuard()
let host: ControlledHarnessHost | undefined
let transport:
| ReturnType<typeof createDeepSeekHarnessHostTransport>
| undefined
let starting = false
let closed = false
function post(message: DeepSeekHarnessControlMessage): void {
if (!closed) {
parentPort.postMessage(message)
}
}
async function close(): Promise<void> {
if (closed) {
return
}
closed = true
await host?.dispose().catch(() => undefined)
transport?.dispose()
restoreDiagnostics()
}
function fatal(code: string): void {
post({
protocol: DEEPSEEK_HARNESS_CONTROL_PROTOCOL,
version: DEEPSEEK_HARNESS_CONTROL_VERSION,
type: 'fatal',
code
})
void close().finally(() => {
process.exitCode = 1
})
}
parentPort.on('message', (event) => {
const message = parseHarnessControlMessage(event.data)
if (!message) {
// Once the byte transport is installed, non-control messages belong to
// that transport's listener on the shared UtilityProcess port.
if (transport) {
return
}
fatal('INVALID_START')
return
}
if (message.type !== 'start') {
fatal('INVALID_START')
return
}
if (starting || host || closed) {
fatal('DUPLICATE_START')
return
}
starting = true
transport = createDeepSeekHarnessHostTransport(parentPort)
void startControlledDeepSeekHarnessHost({
...message.config,
stream: createBoundedNdJsonStream(
transport.stdout,
transport.stdin,
message.config.maxFrameBytes
)
})
.then((startedHost) => {
host = startedHost
starting = false
post({
protocol: DEEPSEEK_HARNESS_CONTROL_PROTOCOL,
version: DEEPSEEK_HARNESS_CONTROL_VERSION,
type: 'ready',
failedExtensionIds: host.failedExtensionIds
})
})
.catch((error: unknown) => {
transport?.dispose()
fatal(
error instanceof ControlledHarnessHostStartupError
? error.code
: 'HOST_START_FAILED'
)
})
})
process.once('disconnect', () => {
void close()
})
process.once('SIGTERM', () => {
void close()
})