DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(host|client): shared HostContext and runtime types, focused vitest
hairyff27f94264e12
diff --git a/packages/dsh-tauri-panel-extension/src/host/apply.ts b/packages/dsh-tauri-panel-extension/src/host/apply.tsindex 1810dfb7..b986d4a1 100644--- a/packages/dsh-tauri-panel-extension/src/host/apply.ts+++ b/packages/dsh-tauri-panel-extension/src/host/apply.ts@@ -11,7 +11,7 @@* providerHooks(hookable)暴露,供诊断与第三方联动。*/-import type { Context } from '@deepseek-ai/cordis'+import type { HostContext } from 'dsh-tauri'import type { PanelExtensionHost } from './types'import { existsSync } from 'node:fs'import { fileURLToPath } from 'node:url'@@ -46,7 +46,7 @@ export const inject = ['webServer', 'skills', 'connection']/** The provider plugin's structural shape (name/apply export). */interface FilesystemSkillPlugin {name: string- apply: (context: Context, config?: unknown) => void+ apply: (context: unknown, config?: unknown) => void}/** Platform loader subset used to resolve DSH-owned packages from its base URL. */@@ -66,14 +66,6 @@ interface PluginFiber {dispose: () => Promise<void>}-/** cordis Context 类型发布缺陷兜底:apply 依赖的注册表/日志成员。 */-interface HostContext {- effect: (callback: () => void | (() => void), id?: string) => void- inject: (services: readonly string[], setup: (hostCtx: HostContext) => void) => void- plugin: (plugin: unknown, config?: unknown) => PluginFiber- logger: { error: (message: string) => void }-}-export function apply(ctx: HostContext, config?: Config): void {const profile = config?.profile ?? argvProfile() ?? 'web'ctx.inject(['webServer', 'skills', 'connection'], (hostCtx: HostContext) => {diff --git a/packages/dsh-tauri-session/src/client/types/runtime.ts b/packages/dsh-tauri-session/src/client/types/runtime.tsindex cd92642c..d3462a95 100644--- a/packages/dsh-tauri-session/src/client/types/runtime.ts+++ b/packages/dsh-tauri-session/src/client/types/runtime.ts@@ -1,57 +1,3 @@-/** types/runtime.ts — 宿主运行时快照类型(ctx.sessions / ctx.workspaces 投影)。 */+/** types/runtime.ts — 宿主运行时快照类型(ctx.sessions / ctx.workspaces 投影)。共享面见 dsh-tauri/client。 */-/** Minimal `ctx.sessions` face the archive page subscribes to. */-export interface SessionsRuntimeLike {- list: {- subscribe: (listener: () => void) => () => void- getSnapshot: () => SessionListSnapshot- }- /** Rebuild the in-memory session list after deleting persisted sessions. */- refresh?: () => Promise<void>-}--export interface SessionSummaryLike {- id: string- title?: string- displayTitle?: string- cwd?: string- updatedAt?: number- blank?: boolean- /** Session provenance; official sidebar hides subagent sessions. */- origin?: string-}--export interface SessionListSnapshot {- ids: string[]- byId: Record<string, SessionSummaryLike>- current?: string- phase?: 'pending' | 'ready'-}--/** Minimal `ctx.workspaces` face the archive page subscribes to. */-export interface WorkspacesRuntimeLike {- list: {- subscribe: (listener: () => void) => () => void- getSnapshot: () => WorkspaceListSnapshot- }- /**- * Wire-truth owner behind the `list` projection. The plugin's unarchive/- * delete/clear mutations bypass the official unary actions (no changed- * frames are emitted), so callers re-sync the archive mirror via `refresh`.- */- manager?: {- refresh?: () => Promise<void>- }-}--export interface WorkspaceViewLike {- workspaceId: string- path: string- title?: string- sessionIds: string[]-}--export interface WorkspaceListSnapshot {- items: readonly WorkspaceViewLike[]- archivedSessionIds?: readonly string[]-}+export type { SessionListSnapshot, SessionsRuntimeLike, SessionSummaryLike, WorkspaceListSnapshot, WorkspacesRuntimeLike, WorkspaceViewLike } from 'dsh-tauri/client'diff --git a/packages/dsh-tauri/src/client/types/runtime.ts b/packages/dsh-tauri/src/client/types/runtime.tsindex 70a53aa4..1d10254d 100644--- a/packages/dsh-tauri/src/client/types/runtime.ts+++ b/packages/dsh-tauri/src/client/types/runtime.ts@@ -13,3 +13,71 @@ import type { WorkspaceId as WorkspaceIdType } from './json'export type { ISessions, IWorkspaces, SessionListState, SessionSummary, SlotRegistry, WorkspaceSnapshot, WorkspaceSource, WorkspaceView }export type SessionsRuntime = ISessionsexport type WorkspacesRuntime = IWorkspaces & { startSession?: (workspaceId?: WorkspaceIdType) => void }++/**+ * workspace 共享的宽松运行时面(ctx.sessions / ctx.workspaces 投影)。+ * 消费插件(dsh-tauri-session / dsh-tauri-rightclick / dsh-tauri-pet)统一从+ * `dsh-tauri/client` 引用,不再各自声明重复面,也不重复 `as unknown as` 断言+ * (断言目标统一为此处类型)。未知成员用宽松签名,需要官方精确面时用上面的+ * SessionsRuntime / WorkspacesRuntime Pick。+ */++/** 会话列表快照(list.subscribe/getSnapshot 投影)。 */+export interface SessionSummaryLike {+ id: string+ title?: string+ displayTitle?: string+ cwd?: string+ updatedAt?: number+ blank?: boolean+ /** Session provenance; official sidebar hides subagent sessions. */+ origin?: string+}++export interface SessionListSnapshot {+ ids: string[]+ byId: Record<string, SessionSummaryLike>+ current?: string+ phase?: 'pending' | 'ready'+}++/** Minimal `ctx.sessions` face the plugins subscribe to. */+export interface SessionsRuntimeLike {+ list: {+ subscribe: (listener: () => void) => () => void+ getSnapshot: () => SessionListSnapshot+ }+ /** Rebuild the in-memory session list after deleting persisted sessions. */+ refresh?: () => Promise<void>+ open?: (sessionId: string) => unknown+ binding?: (sessionId: string) => unknown+ fork?: (...args: unknown[]) => unknown+}++/** 工作区视图快照(list 投影)。 */+export interface WorkspaceViewLike {+ workspaceId: string+ path: string+ title?: string+ sessionIds: string[]+}++export interface WorkspaceListSnapshot {+ items: readonly WorkspaceViewLike[]+ archivedSessionIds?: readonly string[]+}++/** Minimal `ctx.workspaces` face the plugins subscribe to. */+export interface WorkspacesRuntimeLike {+ list: {+ subscribe: (listener: () => void) => () => void+ getSnapshot: () => WorkspaceListSnapshot+ }+ /** Wire-truth owner behind the `list` projection. */+ manager?: {+ refresh?: () => Promise<void>+ }+ archiveSession?: (...args: unknown[]) => unknown+ delete?: (...args: unknown[]) => unknown+ startSession?: (workspaceId: string) => unknown+}diff --git a/packages/dsh-tauri/src/host/types/index.ts b/packages/dsh-tauri/src/host/types/index.tsindex c43f0044..8e303138 100644--- a/packages/dsh-tauri/src/host/types/index.ts+++ b/packages/dsh-tauri/src/host/types/index.ts@@ -23,5 +23,13 @@ export interface AgentPresetsService { mount?: (agentCtx: unknown, presetId: strexport interface PermissionPresetsService { names: readonly string[], defaultPreset: string, optionOf: (name: string) => { value: string, name: string, description?: string }, set: (session: unknown, name: string) => void }export interface WebServerService { register: (route: HostRoute) => () => void }export interface ToolRegistrationService { register: (definition: ToolDefinition | unknown) => () => void | undefined }-export type HostContext = Context & { agents: AgentRegistry, sessions: SessionStore, workspaceRegistry: WorkspaceRegistry, tools: ToolRuntime & ToolRegistrationService, webServer: WebServerService, connection?: ConnectionGate, llm?: LlmRuntime, agentDefaultModel?: AgentDefaultModelService, agentPresets?: AgentPresetsService, permissionPresets?: PermissionPresetsService, loader: { import: (name: string) => Promise<unknown>, unwrapExports: (exports: unknown) => unknown } }+export type HostContext = Context & { agents: AgentRegistry, sessions: SessionStore, workspaceRegistry: WorkspaceRegistry, tools: ToolRuntime & ToolRegistrationService, webServer: WebServerService, connection?: ConnectionGate, llm?: LlmRuntime, agentDefaultModel?: AgentDefaultModelService, agentPresets?: AgentPresetsService, permissionPresets?: PermissionPresetsService, loader: { import: (name: string) => Promise<unknown>, unwrapExports: (exports: unknown) => unknown } } & HostLifecycle++/** 宿主生命周期/注册表面(cordis Context 类型发布缺陷兜底:各插件 host/apply 共享)。 */+export interface HostLifecycle {+ effect: (callback: () => void | (() => void), id?: string) => void+ inject: (services: readonly string[], setup: (hostCtx: HostContext) => void) => void+ plugin: (plugin: unknown, config?: unknown) => unknown+ logger: { error: (message: string) => void }+}export type { AgentRegistry, ContentBlock, LlmRuntime, ModelSelection, SessionStore, ToolDefinition, ToolRuntime, WorkspaceRegistry }diff --git a/vitest.config.ts b/vitest.config.tsnew file mode 100644index 00000000..03c540c2--- /dev/null+++ b/vitest.config.ts@@ -0,0 +1,20 @@+import { defineConfig } from 'vitest/config'++/**+ * 根测试配置:只跑内置插件(packages/**)的测试,限制并发 worker 数与放宽超时。+ *+ * 仓库根还 vendored 了 dsh 核心源码(src/、source/、test/),其测试依赖 dsh 核心+ * 的 `@/` paths 解析(在插件 workspace 的 vitest 下不可用),故 exclude 出本范围。+ *+ * dsh-tauri-worktree 的 operation.test 会创建真实 git 仓库(clone/checkout/+ * discard),全量并行(默认 cpu-1 个 worker)时与其他文件的 git 操作竞争系统+ * 资源,偶发 5s 超时 flake;限制 maxWorkers 后单独复跑稳定通过。+ */+export default defineConfig({+ test: {+ include: ['packages/**/*.{test,spec}.{ts,tsx,js,mjs,cjs}'],+ maxWorkers: 4,+ testTimeout: 30_000,+ hookTimeout: 30_000,+ },+})