Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(mcp): 连接检查注入 credentials 服务 (#1111)

Bssn5206bbe37416e78
diff --git a/packages/dsh-tauri-extension/src/host/apply.test.ts b/packages/dsh-tauri-extension/src/host/apply.test.ts
index 9cffd5e8..bb1c9329 100644
--- a/packages/dsh-tauri-extension/src/host/apply.test.ts
+++ b/packages/dsh-tauri-extension/src/host/apply.test.ts
@@ -20,9 +20,25 @@ afterEach(() => {
describe('apply provider lifecycle', () => {
it('activates the server before starting packaged skills and cleans both lifecycles', async () => {
const effects = new Map<string, () => (() => void)>()
- const host = { marker: 'host', webServer: { register: vi.fn(() => () => {}) } }
+ const host = {
+ marker: 'host',
+ webServer: { register: vi.fn(() => () => {}) },
+ credentials: { readRecord: async () => undefined },
+ }
const ctx = {
- inject: vi.fn((_names: string[], callback: (context: unknown) => unknown) => callback(host)),
+ inject: vi.fn((names: string[], callback: (context: unknown) => unknown) => {
+ const granted = Object.create(host) as typeof host
+ for (const key of Object.keys(host)) {
+ if (names.includes(key))
+ continue
+ Object.defineProperty(granted, key, {
+ get() {
+ throw new Error(`cannot get property "${key}" without inject`)
+ },
+ })
+ }
+ return callback(granted)
+ }),
effect: vi.fn((effect: () => (() => void), label: string) => effects.set(label, effect)),
}
apply(ctx as unknown as HostContext, { profile: 'chosen' })
@@ -33,7 +49,8 @@ describe('apply provider lifecycle', () => {
expect(() => getServerContext(server)).toThrow()
const unmount = effects.get('dsh-tauri-extension: routes')!()
disposers.push(unmount)
- expect(getServerContext(server)).toBe(host)
+ const mounted = getServerContext(server) as unknown as typeof host
+ expect(mounted.credentials.readRecord).toEqual(expect.any(Function))
const dispose = effects.get('dsh-tauri-extension: skill provider')!()
expect(provider.start).toHaveBeenCalledExactlyOnceWith(packagedSkillsDir())
expect(dispose).toBe(disposeProviderRuntime)
diff --git a/packages/dsh-tauri-extension/src/host/apply.ts b/packages/dsh-tauri-extension/src/host/apply.ts
index 548fa9f5..71f45ff0 100644
--- a/packages/dsh-tauri-extension/src/host/apply.ts
+++ b/packages/dsh-tauri-extension/src/host/apply.ts
@@ -14,7 +14,7 @@ export type { Config } from './apply.types'
export const name = PLUGIN_ID
-export const inject = ['webServer', 'skills', 'connection']
+export const inject = ['webServer', 'skills', 'connection', 'credentials']
export { loadFilesystemSkillPlugin } from './service/provider.utils'
diff --git a/packages/dsh-tauri-extension/src/index.ts b/packages/dsh-tauri-extension/src/index.ts
index be18cf34..18355767 100644
--- a/packages/dsh-tauri-extension/src/index.ts
+++ b/packages/dsh-tauri-extension/src/index.ts
@@ -2,9 +2,7 @@ import { PLUGIN_ID } from './shared/constants'
export const name = PLUGIN_ID
-export const inject = ['webServer', 'skills', 'connection']
-
-export { apply, loadFilesystemSkillPlugin, packagedSkillsDir } from './host/apply'
+export { apply, inject, loadFilesystemSkillPlugin, packagedSkillsDir } from './host/apply'
export type { Config } from './host/apply'
export { providerHooks } from './host/events'
export type { ProviderLifecycleHooks } from './host/events'