DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(ssh): 每机器远端档案名,默认 remote
Menghuan19187c1209e00372
diff --git a/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx b/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsxindex 6311dff1..2433fb80 100644--- a/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx+++ b/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx@@ -167,6 +167,9 @@ function EditPanel({ draft, t, secretSet, dirty, saving, onChange, onSecret, onS<Field label={t('field.remotePort')}><Input className={cls.fieldInput} type="number" value={row.remotePort} disabled={saving} onChange={event => onChange(draft.key, { remotePort: numberOf(event.target.value, DEFAULT_REMOTE_PORT) })} /></Field>+ <Field label={t('field.profileName')}>+ <Input className={cls.fieldInput} value={row.profileName ?? ''} placeholder="remote" disabled={saving || (row.startCommand ?? '') !== ''} onChange={event => onChange(draft.key, { profileName: event.target.value })} />+ </Field><Field label={t('field.startCommand')}><Input className={cls.fieldInput} value={row.startCommand ?? ''} disabled={saving} onChange={event => onChange(draft.key, { startCommand: event.target.value })} /></Field>@@ -556,6 +559,7 @@ function AddMachineDialog({ t, saving, takenIds, onSubmit, onClose }: {const [port, setPort] = useState(String(DEFAULT_PORT))const [user, setUser] = useState('')const [remotePort, setRemotePort] = useState(String(DEFAULT_REMOTE_PORT))+ const [profileName, setProfileName] = useState('')const slug = slugOf(host)const effectiveId = idTouched ? id.trim() : (slug === '' ? '' : freeIdOf(slug, takenIds))@@ -581,6 +585,7 @@ function AddMachineDialog({ t, saving, takenIds, onSubmit, onClose }: {hasPassword: false,hasPassphrase: false,remotePort: numberOf(remotePort, DEFAULT_REMOTE_PORT),+ ...(profileName.trim() === '' ? {} : { profileName: profileName.trim() }),})}@@ -631,6 +636,9 @@ function AddMachineDialog({ t, saving, takenIds, onSubmit, onClose }: {<Field label={t('field.remotePort')}><Input className={cls.fieldInput} value={remotePort} disabled={saving} onChange={event => setRemotePort(event.target.value)} /></Field>+ <Field label={t('field.profileName')}>+ <Input className={cls.fieldInput} value={profileName} placeholder="remote" disabled={saving} onChange={event => setProfileName(event.target.value)} />+ </Field></div>{errorKey === null? <p className={cls.hint}>{t('add.id_auto')}</p>diff --git a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts b/packages/dsh-tauri-ssh-ui/src/client/locales/index.tsindex a9a470a9..57107504 100644--- a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts+++ b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts@@ -32,6 +32,7 @@ export const zh = {'field.port': '端口','field.user': '用户(可选)','field.remotePort': '远端端口',+ 'field.profileName': '远端档案(默认 remote)','field.startCommand': '启动命令(可选)','field.password': '密码(可选)','field.passphrase': '私钥口令(可选)',@@ -131,6 +132,7 @@ export const en = {'field.port': 'Port','field.user': 'User (optional)','field.remotePort': 'Remote port',+ 'field.profileName': 'Remote profile (default remote)','field.startCommand': 'Start command (optional)','field.password': 'Password (optional)','field.passphrase': 'Key passphrase (optional)',diff --git a/packages/dsh-tauri-ssh-ui/src/client/store/index.ts b/packages/dsh-tauri-ssh-ui/src/client/store/index.tsindex 68c7341b..974e8f6a 100644--- a/packages/dsh-tauri-ssh-ui/src/client/store/index.ts+++ b/packages/dsh-tauri-ssh-ui/src/client/store/index.ts@@ -33,6 +33,7 @@ export interface MachineRow {hasPassword: booleanhasPassphrase: booleanremotePort: number+ profileName?: stringstartCommand?: string/** Optional identity color (any CSS color) shown as the machine's pip. */color?: string@@ -283,6 +284,8 @@ export function machineRowOf(value: unknown): MachineRow | undefined {const startCommand = typeof row.startCommand === 'string' && row.startCommand !== ''? row.startCommand: undefined+ const rawProfileName = typeof row.profileName === 'string' ? row.profileName.trim() : ''+ const profileName = /^[\w-]+$/.test(rawProfileName) ? rawProfileName : undefinedconst color = typeof row.color === 'string' && row.color !== '' ? row.color : undefinedreturn {id: row.id,@@ -293,6 +296,7 @@ export function machineRowOf(value: unknown): MachineRow | undefined {hasPassword: row.hasPassword === true,hasPassphrase: row.hasPassphrase === true,remotePort,+ ...profileName === undefined ? {} : { profileName },...startCommand === undefined ? {} : { startCommand },...color === undefined ? {} : { color },...row.tintBorder === true ? { tintBorder: true } : {},@@ -306,6 +310,7 @@ export interface MachineSaveRow {port: numberuser: stringremotePort: number+ profileName?: stringstartCommand?: stringcolor?: stringtintBorder?: boolean@@ -319,6 +324,7 @@ export function savePayloadOf(machine: MachineRow, secrets: SecretValues): { macport: machine.port,user: machine.user,remotePort: machine.remotePort,+ ...machine.profileName === undefined || machine.profileName === '' ? {} : { profileName: machine.profileName },...machine.startCommand === undefined || machine.startCommand === '' ? {} : { startCommand: machine.startCommand },...machine.color === undefined || machine.color === '' ? {} : { color: machine.color },...machine.tintBorder === true ? { tintBorder: true } : {},diff --git a/packages/dsh-tauri-ssh/src/host/routes/index.ts b/packages/dsh-tauri-ssh/src/host/routes/index.tsindex 14934521..1476861a 100644--- a/packages/dsh-tauri-ssh/src/host/routes/index.ts+++ b/packages/dsh-tauri-ssh/src/host/routes/index.ts@@ -298,6 +298,8 @@ function saveRowOf(payload: Record<string, unknown>): MachineSaveRow {const startCommand = typeof value.startCommand === 'string' && value.startCommand !== ''? value.startCommand: undefined+ const rawProfileName = typeof value.profileName === 'string' ? value.profileName.trim() : ''+ const profileName = /^[\w-]+$/.test(rawProfileName) ? rawProfileName : undefinedconst color = typeof value.color === 'string' && value.color !== '' ? value.color : undefinedreturn {name: value.name,@@ -305,6 +307,7 @@ function saveRowOf(payload: Record<string, unknown>): MachineSaveRow {port,user: value.user,remotePort,+ ...profileName === undefined ? {} : { profileName },...startCommand === undefined ? {} : { startCommand },...color === undefined ? {} : { color },...value.tintBorder === true ? { tintBorder: true } : {},diff --git a/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts b/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.tsindex e6d28d66..019f357e 100644--- a/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts+++ b/packages/dsh-tauri-ssh/src/host/service/bootstrap.test.ts@@ -556,6 +556,16 @@ describe('component probe and launch commands', () => {expect(command).toContain('dsh-remote-web.log')})+ it('launches with the machine profile flag and falls back to remote', async () => {+ const plan = await planRemoteInstall('Linux 6.8 x86_64', {}, healthyFetchers())+ const named = startCommandFor({ ...profile, profileName: 'work' }, plan)+ expect(named).toContain(`--profile "$5"`)+ expect(named).toContain('work')+ expect(named).toContain('档案: work')+ expect(startCommandFor(profile, plan)).toContain('档案: remote')+ expect(startCommandFor({ ...profile, profileName: 'a b;rm' }, plan)).toContain('档案: remote')+ })+it('keeps the profile startCommand override untouched', () => {const overridden: MachineProfile = { ...profile, startCommand: 'my-launcher web --port 4000' }expect(startCommandFor(overridden))diff --git a/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts b/packages/dsh-tauri-ssh/src/host/service/bootstrap.tsindex 22cf7fde..cbf283b2 100644--- a/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts+++ b/packages/dsh-tauri-ssh/src/host/service/bootstrap.ts@@ -19,6 +19,7 @@ import type { RemoteArch, RemoteAssetMatrix, RemoteOs } from './assets'import type { SshSession } from './transport'import { Buffer } from 'node:buffer'import { readFileSync } from 'node:fs'+import { DEFAULT_REMOTE_PROFILE } from '../storage/index'import { assetMatrixFor, dshNpmTarballUrls, dshZipDownloadUrls, nodeDownloadUrls, nodeFilenameFor, nodeShasumUrls, parsePlatform, PNPM_SHA256, PNPM_VERSION, pnpmDownloadUrls } from './assets'import { clientUrlsFromBootHtml, looksLikePluginBundle } from './boot-html'import { shQuote } from './transport'@@ -544,11 +545,17 @@ export function remoteWebTokenCommand(): string {return `grep -oE 'token=[A-Za-z0-9._~-]+' "$HOME/${REMOTE_WEB_LOG}" 2>/dev/null | tail -n 1 | cut -d= -f2`}+/** Shell- and path-safe profile names only (`^[A-Za-z0-9_-]+$`); anything else falls back to the default. */+export function safeProfileName(raw: string | undefined): string {+ return raw !== undefined && /^[\w-]+$/.test(raw) ? raw : DEFAULT_REMOTE_PROFILE+}+export function startCommandFor(profile: MachineProfile, plan?: RemoteInstallPlan): string {if (profile.startCommand !== undefined)return `mkdir -p "$HOME/.dsh" && ( ${profile.startCommand} >>"$HOME/${REMOTE_WEB_LOG}" 2>&1 < /dev/null & ) &`const node = `$HOME/${REMOTE_ROOT}/runtime/bin/node`const dshBin = layoutDshEntry(plan)+ const profileName = safeProfileName(profile.profileName)return [`ROOT="$HOME/${REMOTE_ROOT}"`,`NODE=${node}`,@@ -559,8 +566,8 @@ export function startCommandFor(profile: MachineProfile, plan?: RemoteInstallPla`mkdir -p "$LOG_DIR"`,`export PATH="$ROOT/runtime/bin:$PATH"`,`export DSH_TELEMETRY_DISABLED=1 NO_COLOR=1 DSH_WEB_PORT=${profile.remotePort}`,- `( sh -c 'echo $$ > "$1/.dsh-remote.pid"; exec "$2" "$3" web --host 127.0.0.1 --port "$4" --no-open' dsh-remote "$LOG_DIR" "$NODE" "$DSH_BIN" ${profile.remotePort} </dev/null >>"$LOG" 2>&1 & )`,- `echo "远端实例已拉起(日志: $LOG)"`,+ `( sh -c 'echo $$ > "$1/.dsh-remote.pid"; exec "$2" "$3" --profile "$5" web --host 127.0.0.1 --port "$4" --no-open' dsh-remote "$LOG_DIR" "$NODE" "$DSH_BIN" ${profile.remotePort} ${profileName} </dev/null >>"$LOG" 2>&1 & )`,+ `echo "远端实例已拉起(档案: ${profileName}, 日志: $LOG)"`,].join('\n')}diff --git a/packages/dsh-tauri-ssh/src/host/service/manager.test.ts b/packages/dsh-tauri-ssh/src/host/service/manager.test.tsindex c3b16744..9433f8f0 100644--- a/packages/dsh-tauri-ssh/src/host/service/manager.test.ts+++ b/packages/dsh-tauri-ssh/src/host/service/manager.test.ts@@ -269,7 +269,7 @@ function boot(overrides: Partial<{config: typeof configplanInstall: () => Promise<RemoteInstallPlan>mintCookie: (authenticatedUrl: string) => Promise<string | undefined>- syncPlugins: (session: import('./transport').SshSession, hooks: { onEvent?: (stage: import('../types/index').SshMachineStage, line: string) => void }) => Promise<boolean>+ syncPlugins: (session: import('./transport').SshSession, profileName: string, hooks: { onEvent?: (stage: import('../types/index').SshMachineStage, line: string) => void }) => Promise<boolean>}> = {}) {const transport = new FakeTransport(overrides.sessionFactory ?? (() => new FakeSession(() => true)))transport.rejectKeys = overrides.rejectKeys ?? falsediff --git a/packages/dsh-tauri-ssh/src/host/service/manager.ts b/packages/dsh-tauri-ssh/src/host/service/manager.tsindex 2e9cf000..37692acf 100644--- a/packages/dsh-tauri-ssh/src/host/service/manager.ts+++ b/packages/dsh-tauri-ssh/src/host/service/manager.ts@@ -19,7 +19,7 @@ import { homedir } from 'node:os'import process from 'node:process'import { join } from 'pathe'import { MachineId, SshError } from '../types/index'-import { checkMissingCommand, credentialsCopyCommand, describeError, describeExecFailure, ensureRemoteInstance, firstLineOf, missingComponentsOf, planRemoteInstall, readEnvCredentials, REMOTE_ROOT, remoteWebTokenCommand, runInstallScript, skippedVerificationSummary } from './bootstrap'+import { checkMissingCommand, credentialsCopyCommand, describeError, describeExecFailure, ensureRemoteInstance, firstLineOf, missingComponentsOf, planRemoteInstall, readEnvCredentials, REMOTE_ROOT, remoteWebTokenCommand, runInstallScript, safeProfileName, skippedVerificationSummary } from './bootstrap'import { fingerprintHostKey } from './host-keys'import { syncBundledPlugins } from './plugins-sync'import { mintTunnelCookie } from './transport'@@ -92,7 +92,7 @@ export interface SshManagerDeps {* tarball pipeline; tests stub it to stay offline). Returns whether the* remote was modified (a running instance gets restarted by the sync).*/- syncPlugins?: (session: SshSession, hooks: { onEvent?: (stage: SshMachineStage, line: string) => void }) => Promise<boolean>+ syncPlugins?: (session: SshSession, profileName: string, hooks: { onEvent?: (stage: SshMachineStage, line: string) => void }) => Promise<boolean>}/** The sentinel rethrown when an in-flight attempt loses to a disconnect. */@@ -412,7 +412,7 @@ export class SshManager {// 上传并重启实例,随后的 ensure 按新 profile 拉起。best-effort:同步// 失败降级为原生远端 UI,连接本身不受影响。try {- await (this.deps.syncPlugins ?? syncBundledPlugins)(session, {+ await (this.deps.syncPlugins ?? syncBundledPlugins)(session, safeProfileName(profile.profileName), {onEvent: (stage, line) => {if (generation === state.generation)this.deps.events.append(machineId, stage, line)@@ -906,6 +906,7 @@ export function profileView(profile: MachineProfile): MachineView {hasPassword: profile.password !== undefined,hasPassphrase: profile.passphrase !== undefined,remotePort: profile.remotePort,+ ...profile.profileName === undefined ? {} : { profileName: profile.profileName },...profile.startCommand === undefined ? {} : { startCommand: profile.startCommand },...profile.color === undefined ? {} : { color: profile.color },...profile.tintBorder === true ? { tintBorder: true } : {},diff --git a/packages/dsh-tauri-ssh/src/host/service/plugins-sync.test.ts b/packages/dsh-tauri-ssh/src/host/service/plugins-sync.test.tsindex 31fad6fe..b0685b3f 100644--- a/packages/dsh-tauri-ssh/src/host/service/plugins-sync.test.ts+++ b/packages/dsh-tauri-ssh/src/host/service/plugins-sync.test.ts@@ -58,7 +58,7 @@ describe('plugin sync commands', () => {})it('apply command: atomic swap + hash marker + profile wiring + instance restart', () => {- const command = pluginSyncApplyCommand(tree, 'abc123')+ const command = pluginSyncApplyCommand(tree, 'abc123', 'remote')// 原子交换:staging → 正式位expect(command).toContain('$BASE.new')expect(command).toContain('mv "$BASE.new" "$BASE"')@@ -66,7 +66,7 @@ describe('plugin sync commands', () => {expect(command).toContain('echo "abc123" > "$HOME/.dsh-desktop/plugins/.sync-sha256"')// profile 接线走上传的 _wire.js(deps link + bundles + symlink)expect(command).toContain('_wire.js')- expect(command).toContain('.dsh/profiles/web/package.json')+ expect(command).toContain('.dsh/profiles/remote/package.json')expect(command).toContain('dsh-tauri dsh-tauri-ssh')// 实例在跑则按 pidfile 重启(ensure 探测落空后按新 profile 拉起);// pidfile 之外按安装路径精确清场,并等 3080 释放避免新实例 EADDRINUSEdiff --git a/packages/dsh-tauri-ssh/src/host/service/plugins-sync.ts b/packages/dsh-tauri-ssh/src/host/service/plugins-sync.tsindex ee55eca8..dce6bcd0 100644--- a/packages/dsh-tauri-ssh/src/host/service/plugins-sync.ts+++ b/packages/dsh-tauri-ssh/src/host/service/plugins-sync.ts@@ -41,8 +41,6 @@ const REMOTE_PLUGINS_DIR = `${REMOTE_ROOT}/plugins`const SYNC_MARKER = `${REMOTE_PLUGINS_DIR}/.sync-sha256`/** Remote pidfile written by the instance start command (bootstrap.ts). */const REMOTE_PIDFILE = '.dsh/dsh-remote.pid'-/** The dsh profile every remote web instance runs. */-const REMOTE_PROFILE = '.dsh/profiles/web'/** The wiring helper uploaded alongside the tree (keeps shell quoting trivial). */export const WIRE_SCRIPT = `const fs = require('fs')@@ -177,8 +175,9 @@ export function pluginSyncMarkerCommand(): string {* restart a running instance so the ensure-launch flow relaunches it onto* the new profile.*/-export function pluginSyncApplyCommand(tree: BundledPluginsTree, hash: string): string {+export function pluginSyncApplyCommand(tree: BundledPluginsTree, hash: string, profileName: string): string {const names = tree.pluginNames.join(' ')+ const profile = `.dsh/profiles/${profileName}`return ['set -e',`BASE="$HOME/${REMOTE_PLUGINS_DIR}"`,@@ -189,7 +188,8 @@ export function pluginSyncApplyCommand(tree: BundledPluginsTree, hash: string):`mv "$BASE.new" "$BASE"`,`rm -rf "$BASE.old"`,`echo "${hash}" > "$HOME/${SYNC_MARKER}"`,- `"$HOME/${REMOTE_ROOT}/runtime/bin/node" "$BASE/node_modules/_wire.js" "$HOME/${REMOTE_PROFILE}/package.json" "$BASE/node_modules" ${names}`,+ `mkdir -p "$HOME/${profile}"`,+ `"$HOME/${REMOTE_ROOT}/runtime/bin/node" "$BASE/node_modules/_wire.js" "$HOME/${profile}/package.json" "$BASE/node_modules" ${names}`,// 实例在跑则重启:pidfile 之外还按安装路径精确清场(pidfile 可能因上次崩溃// 指向已死进程),并等 3080 释放后再交还 ensure 拉起,避免新实例 EADDRINUSE`[ -f "$HOME/${REMOTE_PIDFILE}" ] && kill "$(cat "$HOME/${REMOTE_PIDFILE}")" 2>/dev/null || true`,@@ -205,6 +205,7 @@ export function pluginSyncApplyCommand(tree: BundledPluginsTree, hash: string):*/export async function syncBundledPlugins(session: SshSession,+ profileName: string,hooks: { onEvent?: (stage: SshMachineStage, line: string) => void } = {},): Promise<boolean> {const tree = findBundledPluginsTree()@@ -218,9 +219,9 @@ export async function syncBundledPlugins(return falseconst sizeMb = (tar.length / 1024 / 1024).toFixed(1)hooks.onEvent?.('install', `同步桌面捆绑插件到远端(${tree.pluginNames.length} 个, ${sizeMb} MB)`)- const applied = await session.exec(pluginSyncApplyCommand(tree, hash), { stdinData: tar })+ const applied = await session.exec(pluginSyncApplyCommand(tree, hash, profileName), { stdinData: tar })if (applied.code !== 0 || !applied.stdout.includes('PLUGINS_SYNCED'))throw new Error(`远端插件同步失败: ${applied.stderr.trim() || `exit ${applied.code}`}`)- hooks.onEvent?.('install', '桌面捆绑插件已同步,远端实例按新 profile 重启')+ hooks.onEvent?.('install', `桌面捆绑插件已同步,远端实例按新 profile 重启`)return true}diff --git a/packages/dsh-tauri-ssh/src/host/storage/index.ts b/packages/dsh-tauri-ssh/src/host/storage/index.tsindex b53d7197..dfaa9fd1 100644--- a/packages/dsh-tauri-ssh/src/host/storage/index.ts+++ b/packages/dsh-tauri-ssh/src/host/storage/index.ts@@ -28,6 +28,9 @@ export const DEFAULT_REMOTE_PORT = 3080/** Default SSH transport port. */export const DEFAULT_SSH_PORT = 22+/** Default remote dsh profile name (`dsh --profile <name> web`). */+export const DEFAULT_REMOTE_PROFILE = 'remote'+/*** One machine profile schema: the settings-namespace member shape. Credential* fields are `role('secret')` positions — redacted from every wire surface,@@ -43,6 +46,7 @@ export const MachineSchema = z.object({password: z.string().role('secret'),passphrase: z.string().role('secret'),remotePort: z.number().default(DEFAULT_REMOTE_PORT),+ profileName: z.string(),startCommand: z.string(),color: z.string(),tintBorder: z.boolean(),diff --git a/packages/dsh-tauri-ssh/src/host/types/index.ts b/packages/dsh-tauri-ssh/src/host/types/index.tsindex 9d293d68..1243bc62 100644--- a/packages/dsh-tauri-ssh/src/host/types/index.ts+++ b/packages/dsh-tauri-ssh/src/host/types/index.ts@@ -48,6 +48,11 @@ export interface MachineProfile {passphrase?: string/** TCP port the remote `dsh web` instance listens on (loopback). */remotePort: number+ /**+ * Remote dsh profile name (`dsh --profile <name> web`); defaults to+ * `remote`. Ignored when the machine carries its own `startCommand`.+ */+ profileName?: string/** Command that starts the remote instance; defaults to `dsh web --host 127.0.0.1 --port <remotePort>`. */startCommand?: string/** Optional identity color (any CSS color) shown as the machine's pip in the UI. */@@ -71,6 +76,7 @@ export interface MachineView {/** Whether the profile currently holds a key passphrase (the value itself never rides). */hasPassphrase: booleanremotePort: number+ profileName?: stringstartCommand?: stringcolor?: stringtintBorder?: boolean@@ -83,6 +89,7 @@ export interface MachineSaveRow {port: numberuser: stringremotePort: number+ profileName?: stringstartCommand?: stringcolor?: stringtintBorder?: boolean