Skip to content

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

fix(scheduler): translate permission labels

hairyfd9f0247d023b
diff --git a/docs/AGENTS.desktop.md b/docs/AGENTS.desktop.md
index 8cde55df..a08d57f1 100644
--- a/docs/AGENTS.desktop.md
+++ b/docs/AGENTS.desktop.md
@@ -5,6 +5,7 @@ DeepSeek Harness desktop (Tauri 2 + React 19), embeds the Harness UI served at `
- **端口隔离**:release 默认 `3080`,debug(`pnpm tauri dev` / `cargo build`)默认 `3081`,由 `config::setting::default_port()` 用 `cfg!(debug_assertions)` 区分,避免开发时与已运行的桌面端争用端口。
- **数据隔离(核心共用、数据不共用)**:node/`dependencies/dsh`/`dependencies/pnpm` 为共用核心(AppData);debug 构建的 `$DSH_HOME` 默认为 `~/.dsh.dev`(`config::runtime::get_dsh_data_path` 用 `cfg!(debug_assertions)` 区分)且 store 用独立文件 `.store.dev.dat`(`config::setting::store_dat_file_name`),避免开发版与生产版会话/档案/端口状态互相污染,也防止 dev 版热重启把 release 的服务进程杀掉(`service/workflow::terminate_stale_harness_processes` 在 debug 下为 no-op,改由 `.dsh.dev/.harness.pid` 精确回收)。debug 构建不迁移旧数据(`service/migrate`)、不注册/注销 PATH、不写烘焙 DSH_HOME 的 `dsh` shim(`service/cli`)。
- **Windows 极简模式**:预装插件流程(`service/plugin`)对 Windows 用户列出「修复」项(`dsh-win-terminal-inspector`,黄色 chip 默认勾选),确认后 `dsh plugin add github:clearkurt/dsh-win-terminal-inspector` 从 GitHub 安装(桌面端**不内置**插件源码);随后 `service/workflow/win_inspector.rs`(仅 Windows,幂等)写入 profile `cordis.patch.yml` 挂载行并创作 `$DSH_HOME/.agent-presets/minimal-win/` 用户 preset(Git Bash + danger-full-access,因为 agent preset 组成不受 profile patch 管辖)。
+- **内置插件 host 依赖边界**:`packages/*/src/host/` 运行在独立的 `resources/node_modules` 中,禁止直接静态引用任何 `@deepseek-ai/*` 运行时包(包括 `import`、`export ... from` 和 `require`);必须通过宿主上下文的 `loader.import()` 解析 DSH-owned 模块,并按需处理 `loader.unwrapExports()` 的导出形状。`@deepseek-ai/*` 仅可作为 host 的 type-only import,不能产生运行时依赖。
- Prioritize using customized components from src/components, hero-ui.
- This will help minimize the need for writing custom classes.
diff --git a/packages/dsh-tauri-panel-scheduler/src/client/components/task-create-dialog.tsx b/packages/dsh-tauri-panel-scheduler/src/client/components/task-create-dialog.tsx
index ebe00c48..dc75ec45 100644
--- a/packages/dsh-tauri-panel-scheduler/src/client/components/task-create-dialog.tsx
+++ b/packages/dsh-tauri-panel-scheduler/src/client/components/task-create-dialog.tsx
@@ -31,6 +31,11 @@ export interface TaskCreateDialogProps {
}
const WEEKDAYS: Weekday[] = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']
+const PERMISSION_LABEL_KEYS: Record<string, string> = {
+ 'read-only': 'permissionReadOnly',
+ 'workspace-write': 'permissionWrite',
+ 'danger-full-access': 'permissionFullAccess',
+}
const WEEKDAY_KEYS: Record<Weekday, string> = {
MO: 'dayMon',
TU: 'dayTue',
@@ -155,7 +160,10 @@ export function TaskCreateDialog({ t, options, onClose, taskId, initial }: TaskC
{ id: 'danger-full-access', label: t('permissionFullAccess') },
]
const permissionOptions = (options.permissions ?? []).length > 0
- ? options.permissions.map(option => ({ id: option.value, label: option.name }))
+ ? options.permissions.map(option => ({
+ id: option.value,
+ label: PERMISSION_LABEL_KEYS[option.value] ? t(PERMISSION_LABEL_KEYS[option.value]) : option.name,
+ }))
: fallbackPermissions
// 编辑旧任务:当前值不在选项里时补一项,避免显示空值。
if (form.permission && !permissionOptions.some(option => option.id === form.permission))
diff --git a/packages/dsh-tauri-panel-scheduler/src/client/locales/index.ts b/packages/dsh-tauri-panel-scheduler/src/client/locales/index.ts
index a97aa0de..ffdbd173 100644
--- a/packages/dsh-tauri-panel-scheduler/src/client/locales/index.ts
+++ b/packages/dsh-tauri-panel-scheduler/src/client/locales/index.ts
@@ -42,9 +42,9 @@ const zh: Record<string, string> = {
'workspaceDefault': '未分组',
'workspaceDaily': '默认分组',
'permission': '权限',
- 'permissionReadOnly': '只读',
- 'permissionWrite': '工作区写入',
- 'permissionFullAccess': '完全访问',
+ 'permissionReadOnly': '仅可查看',
+ 'permissionWrite': '工作区内修改',
+ 'permissionFullAccess': '完全权限',
'reasoningEffort': '推理等级',
'module': '模块',
'moduleDefault': '默认模型',
@@ -148,8 +148,8 @@ const en: Record<string, string> = {
'workspaceDefault': 'Ungrouped',
'workspaceDaily': 'Default group',
'permission': 'Permission',
- 'permissionReadOnly': 'Read-only',
- 'permissionWrite': 'Workspace write',
+ 'permissionReadOnly': 'View only',
+ 'permissionWrite': 'Modify within workspace',
'permissionFullAccess': 'Full access',
'reasoningEffort': 'Reasoning',
'module': 'Module',
diff --git a/scripts/build-plugins.ts b/scripts/build-plugins.ts
index f49b871b..f0437b2b 100644
--- a/scripts/build-plugins.ts
+++ b/scripts/build-plugins.ts
@@ -9,8 +9,6 @@ const BUNDLE_PACKAGE = join(PACKAGES_ROOT, 'dsh-tauri-bundle', 'package.json')
const RESOURCE_ROOT = join(REPO_ROOT, 'src-tauri', 'resources')
/** 运行期实际依赖的部署产物:`resources/node_modules/<name>`(Tauri 只捆绑 `resources/**`) */
const DEPLOYED_NODE_MODULES = join(RESOURCE_ROOT, 'node_modules')
-const FORBIDDEN_PRODUCTION_PACKAGES = ['date-fns'] as const
-const DSH_STATIC_HOST_IMPORT = /\b(?:from|import)\s*['"](@deepseek-ai\/[^'"]+)['"]|\brequire\s*\(\s*['"](@deepseek-ai\/[^'"]+)['"]\s*\)/g
function run(args: readonly string[]): void {
console.log(`[build:plugins] $ pnpm ${args.join(' ')}`)
@@ -41,53 +39,6 @@ function bundledPackageNames(): string[] {
return names
}
-function verifyForbiddenProductionPackages(nodeModulesRoot: string): void {
- const forbidden = new Set<string>(FORBIDDEN_PRODUCTION_PACKAGES)
- for (const entry of readdirSync(nodeModulesRoot, { withFileTypes: true, recursive: true })) {
- if (!entry.isFile() || entry.name !== 'package.json')
- continue
-
- const packageJson = join(entry.parentPath, entry.name)
- const manifest = JSON.parse(readFileSync(packageJson, 'utf8')) as { name?: unknown }
- if (typeof manifest.name === 'string' && forbidden.has(manifest.name)) {
- throw new Error(`PLUGIN_DEPLOY_FORBIDDEN_PACKAGE: ${packageJson}`)
- }
- }
-}
-
-function verifyDeployedPackages(names: readonly string[], nodeModulesRoot: string): void {
- verifyForbiddenProductionPackages(nodeModulesRoot)
-
- for (const name of names) {
- const packageJson = join(nodeModulesRoot, name, 'package.json')
- if (!existsSync(packageJson)) {
- throw new Error(`PLUGIN_DEPLOY_MISSING: ${packageJson}`)
- }
- const manifest = JSON.parse(readFileSync(packageJson, 'utf8')) as {
- main?: unknown
- dsh?: unknown
- }
- if (typeof manifest.dsh !== 'object' || manifest.dsh === null || Array.isArray(manifest.dsh)) {
- throw new Error(`PLUGIN_DEPLOY_INVALID_DSH: ${packageJson}`)
- }
- if (typeof manifest.main !== 'string')
- continue
-
- const hostEntry = join(nodeModulesRoot, name, manifest.main)
- if (!existsSync(hostEntry)) {
- throw new Error(`PLUGIN_DEPLOY_MISSING_ENTRY: ${hostEntry}`)
- }
-
- // 内置插件与 DSH 安装目录分离,宿主模块必须经平台 loader 解析,不能依赖 Node 裸导入。
- const source = readFileSync(hostEntry, 'utf8')
- DSH_STATIC_HOST_IMPORT.lastIndex = 0
- const match = DSH_STATIC_HOST_IMPORT.exec(source)
- if (match !== null) {
- throw new Error(`PLUGIN_DEPLOY_STATIC_DSH_IMPORT: ${hostEntry} -> ${match[1] ?? match[2]}`)
- }
- }
-}
-
/**
* 把 `pnpm deploy` 产物解引用复制到目标目录:pnpm 虚拟仓库(`.pnpm` 下的依赖入口)
* 全是符号链接,必须逐条按「链接目标」的真实类型落成实体目录/文件。
@@ -185,7 +136,6 @@ function main(): void {
}
materializeTree(deployed, DEPLOYED_NODE_MODULES)
verifyMaterialized(DEPLOYED_NODE_MODULES)
- verifyDeployedPackages(names, DEPLOYED_NODE_MODULES)
console.log(`[build:plugins] deployed ${names.length} plugins to ${RESOURCE_ROOT}`)
}
catch (error) {
diff --git a/test/plugin-resource-closure.test.ts b/test/plugin-resource-closure.test.ts
new file mode 100644
index 00000000..6213571d
--- /dev/null
+++ b/test/plugin-resource-closure.test.ts
@@ -0,0 +1,65 @@
+import { readdirSync, readFileSync, statSync } from 'node:fs'
+import { join } from 'node:path'
+import { pathToFileURL } from 'node:url'
+import { describe, expect, it } from 'vitest'
+
+const BUNDLE_MANIFEST = new URL('../packages/dsh-tauri-bundle/package.json', import.meta.url)
+const RESOURCE_NODE_MODULES = new URL('../src-tauri/resources/node_modules/', import.meta.url)
+const DSH_STATIC_IMPORT = /\b(?:from|import)\s*['"]@deepseek-ai\/[^'"]+['"]|\brequire\s*\(\s*['"]@deepseek-ai\/[^'"]+['"]\s*\)/
+
+interface PluginManifest {
+ name?: unknown
+ dependencies?: Record<string, unknown>
+ dsh?: unknown
+ main?: unknown
+}
+
+function readJson(url: URL | string): PluginManifest {
+ return JSON.parse(readFileSync(url, 'utf8')) as PluginManifest
+}
+
+function bundledPluginNames(): string[] {
+ return Object.keys(readJson(BUNDLE_MANIFEST).dependencies ?? {})
+}
+
+function packageJsonFiles(root: URL): string[] {
+ const files: string[] = []
+ for (const entry of readdirSync(root, { withFileTypes: true, recursive: true })) {
+ if (entry.isFile() && entry.name === 'package.json')
+ files.push(join(entry.parentPath, entry.name))
+ }
+ return files
+}
+
+describe('bundled plugin resource closure', () => {
+ it('contains every bundled plugin with a valid entry', () => {
+ for (const name of bundledPluginNames()) {
+ const manifestUrl = new URL(`../src-tauri/resources/node_modules/${name}/package.json`, import.meta.url)
+ expect(() => readJson(manifestUrl)).not.toThrow()
+ const manifest = readJson(manifestUrl)
+ expect(typeof manifest.dsh === 'object' && manifest.dsh !== null && !Array.isArray(manifest.dsh)).toBe(true)
+ if (typeof manifest.main === 'string')
+ expect(statSync(new URL(`../src-tauri/resources/node_modules/${name}/${manifest.main}`, import.meta.url)).isFile()).toBe(true)
+ }
+ })
+
+ it('does not ship build-only date-fns or any nested copy', () => {
+ const dateFnsPackages = packageJsonFiles(RESOURCE_NODE_MODULES)
+ .filter(file => readJson(pathToFileURL(file)).name === 'date-fns')
+
+ expect(dateFnsPackages).toEqual([])
+ })
+
+ it('keeps DSH-owned host modules loader-resolved', () => {
+ for (const name of bundledPluginNames()) {
+ const manifestUrl = new URL(`../src-tauri/resources/node_modules/${name}/package.json`, import.meta.url)
+ const manifest = readJson(manifestUrl)
+ if (typeof manifest.main !== 'string')
+ continue
+
+ const entryUrl = new URL(`../src-tauri/resources/node_modules/${name}/${manifest.main}`, import.meta.url)
+ expect(statSync(entryUrl).isFile()).toBe(true)
+ expect(readFileSync(entryUrl, 'utf8')).not.toMatch(DSH_STATIC_IMPORT)
+ }
+ })
+})