dsh-remote-vs 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remote-vs",
3
3
  "description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
4
- "version": "0.22.0",
4
+ "version": "0.23.0",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
7
7
  "dsh",
@@ -59,7 +59,7 @@
59
59
  "./locale/*.json": "./locale/*.json"
60
60
  },
61
61
  "engines": {
62
- "dsh": ">=0.2.2-rc.2 <0.3.0"
62
+ "dsh": ">=0.2.2-rc.4 <0.3.0"
63
63
  },
64
64
  "dsh": {
65
65
  "bundle": {
@@ -120,54 +120,54 @@
120
120
  "@codemirror/search": "6.5.11",
121
121
  "@codemirror/state": "^6.7.6",
122
122
  "@codemirror/view": "^6.43.14",
123
- "@deepseek-ai/dsh-fs-ssh": "0.2.1-rc.2",
124
- "@deepseek-ai/dsh-ssh": "0.2.1-rc.2",
123
+ "@deepseek-ai/dsh-fs-ssh": "0.2.2-rc.4",
124
+ "@deepseek-ai/dsh-ssh": "0.2.2-rc.4",
125
125
  "@deepseek-ai/schemastery": "3.19.0",
126
126
  "@lezer/highlight": "1.2.3",
127
127
  "@xterm/addon-fit": "^0.11.0",
128
128
  "@xterm/xterm": "^6.0.0",
129
129
  "ws": "^8.18.0",
130
- "zod": "4.4.3"
130
+ "zod": "4.6.6"
131
131
  },
132
132
  "peerDependencies": {
133
133
  "@deepseek-ai/cordis": "^4.1.0",
134
- "@deepseek-ai/dsh-agent-preset": "^0.2.2-rc.2",
135
- "@deepseek-ai/dsh-bash-local": "^0.2.2-rc.2",
136
- "@deepseek-ai/dsh-file-reference": "^0.2.2-rc.2",
137
- "@deepseek-ai/dsh-fs": "^0.2.2-rc.2",
138
- "@deepseek-ai/dsh-shell": "^0.2.2-rc.2",
139
- "@deepseek-ai/dsh-spill": "^0.2.2-rc.2",
140
- "@deepseek-ai/dsh-subprocess": "^0.2.2-rc.2",
141
- "@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
134
+ "@deepseek-ai/dsh-agent-preset": "^0.2.2-rc.4",
135
+ "@deepseek-ai/dsh-bash-local": "^0.2.2-rc.4",
136
+ "@deepseek-ai/dsh-file-reference": "^0.2.2-rc.4",
137
+ "@deepseek-ai/dsh-fs": "^0.2.2-rc.4",
138
+ "@deepseek-ai/dsh-shell": "^0.2.2-rc.4",
139
+ "@deepseek-ai/dsh-spill": "^0.2.2-rc.4",
140
+ "@deepseek-ai/dsh-subprocess": "^0.2.2-rc.4",
141
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.4",
142
142
  "react": "^18.2.0",
143
143
  "react-dom": "^18.2.0"
144
144
  },
145
145
  "devDependencies": {
146
146
  "@deepseek-ai/cordis": "^4.1.0",
147
- "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
148
- "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.2",
149
- "@deepseek-ai/dsh-api-remotes": "0.2.2-rc.2",
150
- "@deepseek-ai/dsh-bash-local": "0.2.2-rc.2",
151
- "@deepseek-ai/dsh-client-locale": "0.2.2-rc.2",
152
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.2",
153
- "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.2",
154
- "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.2",
155
- "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.2",
156
- "@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.2",
157
- "@deepseek-ai/dsh-file-reference": "0.2.2-rc.2",
158
- "@deepseek-ai/dsh-fs": "0.2.2-rc.2",
159
- "@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.2",
160
- "@deepseek-ai/dsh-host-webserver": "0.2.2-rc.2",
161
- "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
162
- "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
163
- "@deepseek-ai/dsh-session": "0.2.2-rc.2",
164
- "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
165
- "@deepseek-ai/dsh-spill": "0.2.2-rc.2",
166
- "@deepseek-ai/dsh-subprocess": "0.2.2-rc.2",
167
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
168
- "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
169
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.2",
170
- "@deepseek-ai/dsh-workspace": "0.2.2-rc.2",
147
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.4",
148
+ "@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.4",
149
+ "@deepseek-ai/dsh-api-remotes": "0.2.2-rc.4",
150
+ "@deepseek-ai/dsh-bash-local": "0.2.2-rc.4",
151
+ "@deepseek-ai/dsh-client-locale": "0.2.2-rc.4",
152
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.4",
153
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.4",
154
+ "@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.4",
155
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.4",
156
+ "@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.4",
157
+ "@deepseek-ai/dsh-file-reference": "0.2.2-rc.4",
158
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.4",
159
+ "@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.4",
160
+ "@deepseek-ai/dsh-host-webserver": "0.2.2-rc.4",
161
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.4",
162
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.4",
163
+ "@deepseek-ai/dsh-session": "0.2.2-rc.4",
164
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.4",
165
+ "@deepseek-ai/dsh-spill": "0.2.2-rc.4",
166
+ "@deepseek-ai/dsh-subprocess": "0.2.2-rc.4",
167
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.4",
168
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.4",
169
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.4",
170
+ "@deepseek-ai/dsh-workspace": "0.2.2-rc.4",
171
171
  "@types/node": "^22.20.0",
172
172
  "@types/react": "~18.3.1",
173
173
  "@types/react-dom": "^18.3.5",
@@ -27,6 +27,24 @@ import { WorkspaceWizard } from './WorkspaceWizard.tsx'
27
27
  import { detectLang, makeT } from './i18n.ts'
28
28
  import { Btn, Notice } from './ui.tsx'
29
29
 
30
+ /**
31
+ * Opt-in trace for the directory flow, silent unless the operator sets
32
+ * `localStorage['dsh-remote-vs.debug'] = '1'` and reopens the dialog.
33
+ *
34
+ * The native-chooser interaction crosses three parties — this dialog, the stock
35
+ * owner that adopts the path, and the host-side OS chooser — so "the dialog did
36
+ * not close" needs to say WHICH stage was reached before it can be diagnosed.
37
+ * Without this the only observable is the symptom.
38
+ */
39
+ function traceFlow(...parts: unknown[]): void {
40
+ try {
41
+ if (typeof localStorage === 'undefined' || localStorage.getItem('dsh-remote-vs.debug') !== '1') return
42
+ } catch {
43
+ return
44
+ }
45
+ console.info('[rvs-flow]', ...parts)
46
+ }
47
+
30
48
  /** Injected face: uiWorkspace directory primitives (bound in apply's closure). */
31
49
  export interface DirectoryFlowInjected {
32
50
  listDirectory: (path?: string, signal?: AbortSignal) => Promise<DirectoryListing>
@@ -62,6 +80,8 @@ function LocalLeg(props: {
62
80
  t: (k: string) => string
63
81
  busy: boolean
64
82
  injected: DirectoryFlowInjected
83
+ /** Monotonic id of the open request this leg belongs to (shared across remounts). */
84
+ flowEpoch: { current: number }
65
85
  onPicked: (path: string) => void
66
86
  }): ReactNode {
67
87
  const { t, busy, injected } = props
@@ -88,8 +108,10 @@ function LocalLeg(props: {
88
108
  } catch (e) {
89
109
  if (gen !== generation.current) return
90
110
  if (isUnavailable(e)) {
111
+ traceFlow('browse unavailable -> native')
91
112
  setMode('native')
92
113
  } else {
114
+ traceFlow('browse failed', errText(e))
93
115
  setMode(mode === 'browse' ? 'browse' : 'failed')
94
116
  setError(errText(e))
95
117
  }
@@ -128,12 +150,23 @@ function LocalLeg(props: {
128
150
 
129
151
  const nativePick = (): void => {
130
152
  const gen = ++generation.current
153
+ // The open request this pick belongs to. A REMOUNT (same request) must still
154
+ // deliver its result — the OS chooser can take long enough for an unrelated
155
+ // re-render to replace this instance — while a result from a PREVIOUS open
156
+ // must be dropped. `generation` cannot tell those apart; the flow epoch can.
157
+ const epoch = props.flowEpoch.current
131
158
  setLoading(true)
132
159
  setError(undefined)
133
160
  setNotice(undefined)
161
+ traceFlow('native chooser requested')
134
162
  injected.pickDirectory().then(
135
163
  (picked) => {
136
- if (gen !== generation.current) return
164
+ if (props.flowEpoch.current !== epoch) {
165
+ traceFlow('native chooser result dropped (another open request)', picked)
166
+ return
167
+ }
168
+ if (gen !== generation.current) traceFlow('native chooser result adopted after remount', picked)
169
+ traceFlow('native chooser returned', picked === null ? 'cancelled' : picked)
137
170
  setLoading(false)
138
171
  if (picked === null) {
139
172
  setNotice(t('flow.nativeCancelled'))
@@ -142,7 +175,8 @@ function LocalLeg(props: {
142
175
  }
143
176
  },
144
177
  (e: unknown) => {
145
- if (gen !== generation.current) return
178
+ if (props.flowEpoch.current !== epoch) return
179
+ traceFlow('native chooser failed', errText(e))
146
180
  setLoading(false)
147
181
  setError(errText(e))
148
182
  },
@@ -327,6 +361,7 @@ function RemoteLeg(props: {
327
361
  onCancel={props.onCancel}
328
362
  onSaved={(_workspace, aliasPath) => {
329
363
  setDone(true)
364
+ traceFlow('remote wizard saved', aliasPath)
330
365
  props.onPicked(aliasPath)
331
366
  }}
332
367
  />
@@ -338,13 +373,38 @@ export function RemoteDirectoryFlow(props: DirectoryFlowOwnerProps & DirectoryFl
338
373
  const [t] = useState(() => makeT(detectLang()))
339
374
  const [tab, setTab] = useState<'local' | 'remote'>('local')
340
375
  const [epoch, setEpoch] = useState(0)
376
+ /** Mirrors `epoch` without a render lag; the local leg compares it on resolve. */
377
+ const epochRef = useRef(0)
378
+
379
+ /**
380
+ * Hand the picked path to the owner and close the dialog in one step.
381
+ *
382
+ * The owner adopts a picked path asynchronously (`createWorkspace`), and only
383
+ * then flips `open` back to false. For the in-app browser that round trip is
384
+ * a local listing, but the native chooser makes the operator wait for the OS
385
+ * dialog to return and for the host to create the Workspace — and until the
386
+ * owner's state lands, this dialog sits on screen. Operators reported it as
387
+ * "the dialog only disappears after I click or press a key": that next input
388
+ * is what re-rendered the owner's surface. `onCancel` is the same owner's
389
+ * "withdraw the request / just close the flow" signal, so sending it with the
390
+ * path closes immediately and independently of adoption timing; the owner's
391
+ * own close is then a no-op. Cancel goes first so the dialog closes even if
392
+ * the owner's picked-handler throws.
393
+ */
394
+ const finish = (path: string): void => {
395
+ traceFlow('finish', path)
396
+ props.onCancel()
397
+ props.onPicked(path)
398
+ }
341
399
 
342
400
  const wasOpen = useRef(false)
343
401
  useEffect(() => {
344
402
  if (props.open && !wasOpen.current) {
345
403
  setTab('local')
346
- setEpoch((n) => n + 1)
404
+ epochRef.current += 1
405
+ setEpoch(epochRef.current)
347
406
  }
407
+ traceFlow('open', props.open)
348
408
  wasOpen.current = props.open
349
409
  }, [props.open])
350
410
 
@@ -454,8 +514,8 @@ export function RemoteDirectoryFlow(props: DirectoryFlowOwnerProps & DirectoryFl
454
514
  </div>
455
515
  <div style={{ flex: 1, minHeight: 0, overflowY: 'auto' }}>
456
516
  {tab === 'local'
457
- ? <LocalLeg key={`local-${epoch}`} t={t} busy={props.busy} injected={injected} onPicked={props.onPicked} />
458
- : <RemoteLeg key={`remote-${epoch}`} t={t} busy={props.busy} onPicked={props.onPicked} onCancel={props.onCancel} />}
517
+ ? <LocalLeg key={`local-${epoch}`} t={t} busy={props.busy} injected={injected} flowEpoch={epochRef} onPicked={finish} />
518
+ : <RemoteLeg key={`remote-${epoch}`} t={t} busy={props.busy} onPicked={finish} onCancel={props.onCancel} />}
459
519
  </div>
460
520
  <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 12 }}>
461
521
  <Btn onClick={props.onCancel} disabled={props.busy}>{t('hosts.cancel')}</Btn>
package/src/client/api.ts CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  import { DEFAULT_TIMEOUTS, normalizeTimeouts, timeoutSeconds } from '../timeouts.ts'
34
34
  import { activeConnectionAlias, currentConnection, isConnectionFailure, noteConnectionFailure } from './connection.ts'
35
35
  import { detectLang, makeT } from './i18n.ts'
36
+ import { dispatchHostNotices } from './notices.ts'
36
37
  import { parseSseFrame, takeSseFrames } from './exec-output.ts'
37
38
  import {
38
39
  branchesCommand,
@@ -141,6 +142,10 @@ async function call<T>(path: string, init?: RequestInit): Promise<T> {
141
142
  }
142
143
  throw failure
143
144
  }
145
+ // One-shot Host notices (an automatic helper push that THIS request
146
+ // triggered) ride the response; render them here so the surface that needed
147
+ // the helper reports it without the user opening Settings.
148
+ dispatchHostNotices(data)
144
149
  return data as T
145
150
  }
146
151
 
@@ -100,6 +100,7 @@ const zh: Record<string, string> = {
100
100
  'hosts.unknownError': '未知错误',
101
101
  'hosts.deleted': '{alias}:已删除',
102
102
  'hosts.saved': '{alias}:已保存',
103
+ 'hosts.helperPushed': '{alias}:已自动推送远端 helper {version}',
103
104
  'hosts.imported': '已导入 {count} 个主机',
104
105
  'hosts.importedSkipped': ';跳过:{list}',
105
106
  'form.alias': '别名',
@@ -591,7 +592,7 @@ const zh: Record<string, string> = {
591
592
  'changes.revertCreationOk': '删除该文件',
592
593
  'changes.revertCreationTitle': '撤回这个新建文件?',
593
594
  'changes.revertCreationText': '会删除 {path}。git 索引里还留着内容,可以用 git checkout 恢复。',
594
- 'changes.revertedFile': '已撤销该文件的改动',
595
+ 'changes.revertedFile': '已撤销该文件的改动',
595
596
  'changes.revertFailed': '撤销失败',
596
597
  'changes.deletedCreation': '已删除新建文件',
597
598
  'changes.prev': '上一个修改点',
@@ -737,6 +738,7 @@ const en: Record<string, string> = {
737
738
  'hosts.unknownError': 'unknown error',
738
739
  'hosts.deleted': '{alias}: deleted',
739
740
  'hosts.saved': '{alias}: saved',
741
+ 'hosts.helperPushed': '{alias}: pushed remote helper {version} automatically',
740
742
  'hosts.imported': 'Imported {count} host(s)',
741
743
  'hosts.importedSkipped': '; skipped: {list}',
742
744
  'form.alias': 'Alias',
@@ -1228,7 +1230,7 @@ const en: Record<string, string> = {
1228
1230
  'changes.revertCreationOk': 'Delete the file',
1229
1231
  'changes.revertCreationTitle': 'Undo this new file?',
1230
1232
  'changes.revertCreationText': 'It deletes {path}. git keeps the bytes in its index, so git checkout can bring it back.',
1231
- 'changes.revertedFile': 'Reverted this file',
1233
+ 'changes.revertedFile': 'Reverted this file',
1232
1234
  'changes.revertFailed': 'Revert failed',
1233
1235
  'changes.deletedCreation': 'Deleted the new file',
1234
1236
  'changes.prev': 'Previous change',
@@ -29,7 +29,8 @@ import { ChangesDock, type ChangesDockProps } from './changes/ChangesDock.tsx'
29
29
  import { SettingsHostsSection, SettingsWorkspacesSection } from './SettingsHosts.tsx'
30
30
  import { openFloatingEditor, setEditorSurface } from './store.tsx'
31
31
  import { detectLang, makeT } from './i18n.ts'
32
- import { setIconService, type IconServiceLike } from './vsc/kit.tsx'
32
+ import { DialogHost, setIconService, toast, type IconServiceLike } from './vsc/kit.tsx'
33
+ import { setHostNoticeEmitter } from './notices.ts'
33
34
 
34
35
  /** Services required before mounting (slots/uiWorkspace are core web services). */
35
36
  export const inject = ['slots', 'uiWorkspace']
@@ -310,6 +311,7 @@ export function apply(ctx: Context): void {
310
311
  // the menu entry can never point at a window that cannot paint.
311
312
  ctx.effect(() => {
312
313
  let dispose: (() => void) | undefined
314
+ let disposeNotices: (() => void) | undefined
313
315
  try {
314
316
  const slots = ctx.slots as unknown as {
315
317
  inject(slot: string, register: () => () => void): () => void
@@ -323,16 +325,33 @@ export function apply(ctx: Context): void {
323
325
  id: 'remote-vs:floating-editor',
324
326
  order: 40,
325
327
  }, () => <FloatingEditorWindow ctx={ctx} />))
328
+ // A frame-wide toast/confirm host. DialogHost arbitrates a single portal
329
+ // (the first mounted host renders), so this seat only guarantees one exists
330
+ // while the Web app runs: an automatic helper push is announced even when
331
+ // no remote-workspace surface — RemoteRoot, the editor view — is mounted.
332
+ disposeNotices = slots.inject('shell.overlay', () => slots.register({
333
+ name: 'shell.overlay',
334
+ id: 'remote-vs:toast-host',
335
+ order: 41,
336
+ }, () => <DialogHost />))
326
337
  } catch (error) {
327
338
  console.warn('[dsh-remote-vs] shell.overlay registration failed (floating editor unavailable):', error)
328
339
  return () => {}
329
340
  }
330
341
  return () => {
331
- try {
332
- dispose?.()
333
- } catch {
334
- // Ignore.
342
+ for (const teardown of [dispose, disposeNotices]) {
343
+ try {
344
+ teardown?.()
345
+ } catch {
346
+ // Ignore.
347
+ }
335
348
  }
336
349
  }
337
350
  }, 'dsh-remote-vs: floating editor window')
351
+ // Host notices (an automatic helper push) become the plugin's toast; the
352
+ // emitter lives here because the API layer must stay JSX-free.
353
+ ctx.effect(() => {
354
+ setHostNoticeEmitter(toast)
355
+ return () => setHostNoticeEmitter(undefined)
356
+ }, 'dsh-remote-vs: host notice toasts')
338
357
  }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Client side of the Host's one-shot notices (`src/notices.ts`).
3
+ *
4
+ * The Host attaches notices to a JSON response when an automatic helper push ran
5
+ * during that request; the API wrapper calls {@link dispatchHostNotices} after
6
+ * parsing, and the message goes through the plugin's toast layer (bottom-right,
7
+ * auto-dismiss) so the event is visible wherever the user is — including the
8
+ * conversation view, where no remote-workspace surface is mounted.
9
+ *
10
+ * The emitter is REGISTERED by the client entry instead of imported here: this
11
+ * module sits on the API path, which several offline gates load with a
12
+ * TypeScript-only loader. Importing the JSX widget kit from `api.ts` would drag
13
+ * React components into those loaders (they cannot transpile JSX) for a message
14
+ * that only needs a string.
15
+ */
16
+ import type { HostNotice } from '../notices.ts'
17
+ import { detectLang, makeT } from './i18n.ts'
18
+
19
+ /** How the toast layer receives one rendered message. */
20
+ export type HostNoticeEmitter = (text: string) => void
21
+
22
+ const MAX_QUEUED = 8
23
+ let emitter: HostNoticeEmitter | undefined
24
+ let queued: string[] = []
25
+
26
+ /**
27
+ * Install (or remove) the toast emitter; the client entry owns the lifetime.
28
+ *
29
+ * Messages that arrived before the entry registered are flushed, so a notice
30
+ * produced during the first remote operation of a page load cannot be lost.
31
+ */
32
+ export function setHostNoticeEmitter(next: HostNoticeEmitter | undefined): void {
33
+ emitter = next
34
+ if (next === undefined) return
35
+ const pending = queued
36
+ queued = []
37
+ for (const text of pending) next(text)
38
+ }
39
+
40
+ /** Render one notice in the page language. */
41
+ export function formatHostNotice(notice: HostNotice, lang = detectLang()): string {
42
+ const t = makeT(lang)
43
+ if (notice.kind === 'helper-pushed') {
44
+ return t('hosts.helperPushed')
45
+ .replace('{alias}', notice.alias)
46
+ .replace('{version}', notice.version)
47
+ }
48
+ // Unknown kinds are dropped by the dispatcher before reaching here.
49
+ return ''
50
+ }
51
+
52
+ /** Deliver one rendered message: to the emitter when present, else queue it. */
53
+ function deliver(text: string, emit?: HostNoticeEmitter): void {
54
+ const target = emit ?? emitter
55
+ if (target !== undefined) {
56
+ target(text)
57
+ return
58
+ }
59
+ if (queued.length < MAX_QUEUED) queued = [...queued, text]
60
+ }
61
+
62
+ /**
63
+ * Show every valid notice carried by one API response.
64
+ *
65
+ * `emit` is injectable so a gate can drive this without React or a DOM. A
66
+ * malformed payload is ignored: a newer/older peer must never turn a successful
67
+ * remote operation into a client exception.
68
+ */
69
+ export function dispatchHostNotices(payload: unknown, emit?: HostNoticeEmitter): number {
70
+ if (typeof payload !== 'object' || payload === null) return 0
71
+ const raw = (payload as { notices?: unknown }).notices
72
+ if (!Array.isArray(raw)) return 0
73
+ let shown = 0
74
+ for (const entry of raw) {
75
+ if (typeof entry !== 'object' || entry === null) continue
76
+ const notice = entry as Partial<HostNotice>
77
+ if (notice.kind !== 'helper-pushed') continue
78
+ if (typeof notice.alias !== 'string' || typeof notice.version !== 'string') continue
79
+ if (notice.alias === '' || notice.version === '') continue
80
+ const text = formatHostNotice({ kind: 'helper-pushed', alias: notice.alias, version: notice.version })
81
+ if (text === '') continue
82
+ deliver(text, emit)
83
+ shown += 1
84
+ }
85
+ return shown
86
+ }
package/src/deploy.ts CHANGED
@@ -12,6 +12,7 @@ import { createHash } from 'node:crypto'
12
12
  import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync } from 'node:fs'
13
13
  import { dirname, join, posix, resolve, sep } from 'node:path'
14
14
  import { fileURLToPath } from 'node:url'
15
+ import { SSH_PROTOCOL_VERSION } from '@deepseek-ai/dsh-ssh/protocol'
15
16
  import type { RemotePool } from './pool.ts'
16
17
  import { RemoteFiles } from './sftp.ts'
17
18
  import type { RemoteStore } from './store.ts'
@@ -123,8 +124,16 @@ const HELPER_VERSION_RE = /^[0-9A-Za-z][0-9A-Za-z._-]{0,63}$/
123
124
  /** Platforms `mapPlatform()` can produce; a cache entry must name one of them. */
124
125
  const HELPER_PLATFORMS = new Set(['linux-x64', 'linux-arm64', 'macos-x64', 'macos-arm64'])
125
126
 
126
- /** Wire protocol this plugin's `dsh-ssh` generation speaks (see MAINTENANCE §2.7). */
127
- export const EXPECTED_HELPER_PROTOCOL = 2
127
+ /**
128
+ * Wire protocol this plugin's `dsh-ssh` generation speaks (see MAINTENANCE §2.7).
129
+ *
130
+ * Derived from the installed package instead of hardcoded: helper and client
131
+ * handshake on a strict literal, so a constant that drifts from the package
132
+ * silently selects a helper the handshake will reject. Before 0.23.0 this was a
133
+ * hand-maintained `2`; the protocol-3 move (MAINTENANCE §2.51) is why it can no
134
+ * longer be a second source of truth.
135
+ */
136
+ export const EXPECTED_HELPER_PROTOCOL = SSH_PROTOCOL_VERSION
128
137
 
129
138
  /** Resolve one cached tarball, or `undefined` when the name escapes the cache dir. */
130
139
  function safeHelperTarball(dir: string, tarball: unknown): string | undefined {
@@ -247,6 +256,33 @@ export function pickCached(platform: string, version?: string, expectedProtocol:
247
256
  return matches[0]
248
257
  }
249
258
 
259
+ /**
260
+ * Wire protocol of the helper build a deploy record points at, when this machine
261
+ * still has that build cached.
262
+ *
263
+ * Upgrade-day support for `createRpc`: it re-runs the deploy pipeline only when
264
+ * the record carries NO helper, so a host deployed by an older plugin keeps
265
+ * dialing a binary from another protocol generation — both sides pin a literal,
266
+ * so the handshake can only fail and nothing self-heals. The local cache is the
267
+ * one place that still knows that build's protocol, so the record is classified
268
+ * here:
269
+ * - unknown build (not cached here, e.g. deployed from another machine) →
270
+ * `undefined`: keep the record and let the handshake report the real error;
271
+ * - cached build of THIS protocol → returns the expected value, so a deliberate
272
+ * rollback pin (an older build of the same generation) stays pinned;
273
+ * - cached build of ANOTHER protocol → returns the foreign value; the caller
274
+ * re-deploys instead of dialing a doomed handshake.
275
+ */
276
+ export function protocolOfStoredHelper(
277
+ binarySha256: string,
278
+ platform: string | undefined,
279
+ entries: HelperCacheEntry[] = listCachedHelpers(),
280
+ ): number | undefined {
281
+ return entries
282
+ .find(entry => entry.binarySha256 === binarySha256 && (platform === undefined || entry.platform === platform))
283
+ ?.protocol
284
+ }
285
+
250
286
  /** Honest availability of the helper channels. */
251
287
  export function helperAvailability(): HelperAvailability[] {
252
288
  const cached = listCachedHelpers()
package/src/http.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * Small JSON body/response helpers for the /api/dsh-remote route family.
3
3
  */
4
4
  import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'node:http'
5
+ import { drainHostNotices } from './notices.ts'
5
6
  import { DeadlineError } from './timeouts.ts'
6
7
 
7
8
  const JSON_HEADERS = {
@@ -102,8 +103,18 @@ export function writeJson(
102
103
  body: unknown,
103
104
  headers: OutgoingHttpHeaders = {},
104
105
  ): void {
106
+ // Piggyback Host notices (an automatic helper push happened during this
107
+ // request) on any plain-object body: the browser's API wrapper renders them
108
+ // after parsing, so the user learns about the push without opening Settings.
109
+ // Arrays and scalars cannot carry extra keys — their notices stay queued for
110
+ // the next object response instead of being silently dropped.
111
+ const attachable = typeof body === 'object' && body !== null && !Array.isArray(body)
112
+ const notices = attachable ? drainHostNotices() : []
113
+ const payload = notices.length > 0
114
+ ? { ...body as Record<string, unknown>, notices }
115
+ : body
105
116
  res.writeHead(status, { ...JSON_HEADERS, ...headers })
106
- res.end(JSON.stringify(body))
117
+ res.end(JSON.stringify(payload))
107
118
  }
108
119
 
109
120
  /**
package/src/notices.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * One-shot notices the Host hands to the browser on the next JSON response.
3
+ *
4
+ * Why a queue instead of a push channel: the Host half is request/response, and
5
+ * an event that matters (an automatic helper push) is produced *inside* a
6
+ * request the browser already made — the remote operation that needed a dial.
7
+ * Attaching the notice to that response reaches the surface that caused it with
8
+ * no extra connection, and a queue means a push during a streaming response or
9
+ * a failed request still arrives on the next successful one.
10
+ */
11
+ export interface HostNotice {
12
+ /** What happened. Only kinds the client knows how to render belong here. */
13
+ kind: 'helper-pushed'
14
+ /** Host alias the helper was pushed to. */
15
+ alias: string
16
+ /** Helper version that was installed. */
17
+ version: string
18
+ }
19
+
20
+ /** Bounded so an unreachable client cannot grow Host memory without limit. */
21
+ const MAX_PENDING = 8
22
+
23
+ let pending: HostNotice[] = []
24
+
25
+ /** Queue one notice for the next JSON response. */
26
+ export function pushHostNotice(notice: HostNotice): void {
27
+ if (pending.length >= MAX_PENDING) return
28
+ pending = [...pending, notice]
29
+ }
30
+
31
+ /** Take everything queued; the caller attaches it and the queue starts over. */
32
+ export function drainHostNotices(): HostNotice[] {
33
+ if (pending.length === 0) return []
34
+ const drained = pending
35
+ pending = []
36
+ return drained
37
+ }
@@ -324,15 +324,14 @@ export default class TransparentFileSystem extends FileSystem {
324
324
 
325
325
  /**
326
326
  * alpha.3 added patch/delete/move to the FileSystem contract for the
327
- * apply_patch tool. Local providers implement all three; the deliberately
328
- * pinned protocol-2 remote backend (dsh-fs-ssh 0.2.1-rc.2) predates them, so
329
- * remote targets get a typed error instead of a TypeError. The apply_patch
330
- * tool is off by default in every stock preset (alpha.3 dsh-base and presets
331
- * pin `applyPatch: false`), so this only matters when it is enabled.
327
+ * apply_patch tool. As of 0.23.0 every provider this plugin mounts implements
328
+ * all three — fs-ssh 0.2.2 talks the protocol-3 helper, which serves
329
+ * `fs.patch`/`fs.delete`/`fs.move` — so the guards below are defensive: they
330
+ * turn a thinner provider into a typed FsError instead of a TypeError.
332
331
  */
333
332
  private unsupportedRemote(what: string): FsError {
334
333
  return new FsError(
335
- `${what} is not supported on remote workspaces yet (fs-ssh protocol 2); run it in a local workspace`,
334
+ `${what} is not supported by the remote fs provider mounted for this world; run it in a local workspace`,
336
335
  'FS_IO_ERROR',
337
336
  )
338
337
  }