dsh-remote-vs 0.29.0 → 0.31.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.
Files changed (58) hide show
  1. package/README.en.md +53 -20
  2. package/README.md +41 -19
  3. package/THIRD-PARTY-NOTICES.md +6 -6
  4. package/cordis.patch.yml +31 -76
  5. package/lib/client.js +319 -91
  6. package/lib/index.js +845 -129
  7. package/lib/p2-router-fs.js +15 -1
  8. package/lib/types/changes/recorder.d.ts +65 -10
  9. package/lib/types/changes/status.d.ts +48 -3
  10. package/lib/types/client/ConnectionsSection.d.ts +73 -0
  11. package/lib/types/client/WorkspacesView.d.ts +2 -0
  12. package/lib/types/client/api.d.ts +41 -2
  13. package/lib/types/client/composer.d.ts +8 -1
  14. package/lib/types/client/scm/actions.d.ts +25 -1
  15. package/lib/types/client/selection-popup.d.ts +1 -1
  16. package/lib/types/client/ui.d.ts +7 -4
  17. package/lib/types/p2/helper-rpc.d.ts +48 -0
  18. package/lib/types/p2/router-fs.d.ts +9 -1
  19. package/lib/types/p2/worlds.d.ts +51 -0
  20. package/lib/types/pool.d.ts +245 -10
  21. package/lib/types/protocol.d.ts +96 -0
  22. package/lib/{worlds-RG8K5eom.js → worlds-BdxLeKul.js} +134 -7
  23. package/package.json +46 -46
  24. package/src/changes/recorder.ts +151 -15
  25. package/src/changes/status.ts +59 -4
  26. package/src/client/ConnectionsSection.tsx +359 -0
  27. package/src/client/DirectoryFlow.tsx +8 -0
  28. package/src/client/EditorPane.tsx +5 -1
  29. package/src/client/HostsView.tsx +2 -0
  30. package/src/client/MonitorView.tsx +14 -0
  31. package/src/client/RemoteExplorer.tsx +11 -2
  32. package/src/client/RemoteRoot.tsx +1 -0
  33. package/src/client/SettingsHosts.tsx +1 -0
  34. package/src/client/WorkspaceWizard.tsx +1 -0
  35. package/src/client/WorkspacesView.tsx +21 -1
  36. package/src/client/api.ts +72 -4
  37. package/src/client/composer.ts +8 -1
  38. package/src/client/i18n.ts +50 -2
  39. package/src/client/scm/DiffView.tsx +5 -2
  40. package/src/client/scm/actions.ts +63 -12
  41. package/src/client/selection-popup.ts +1 -1
  42. package/src/client/ui.tsx +9 -7
  43. package/src/client/vsc/vsc.css +231 -3
  44. package/src/index.ts +31 -0
  45. package/src/p2/helper-rpc.ts +73 -5
  46. package/src/p2/router-fs.ts +29 -1
  47. package/src/p2/worlds.ts +116 -1
  48. package/src/pool.ts +736 -111
  49. package/src/protocol.ts +100 -0
  50. package/src/routes.ts +85 -13
  51. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.helper.json +20 -0
  52. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz +4 -0
  53. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.3-alpha.3-linux-x64.tar.gz.sha256 +1 -0
  54. package/vendor/dsh-remote-helpers/pkg-sea-bare-import.patch +30 -0
  55. package/vendor/dsh-remote-helpers/ssh-helper-runtime-deps.patch +4 -3
  56. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.helper.json +0 -19
  57. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz +0 -4
  58. package/vendor/dsh-remote-helpers/dsh-ssh-helper-0.2.2-rc.4-linux-x64.tar.gz.sha256 +0 -1
@@ -1,4 +1,4 @@
1
- import { S as aliasRoot, r as isWindowsAbsolute } from "./worlds-RG8K5eom.js";
1
+ import { S as aliasRoot, r as isWindowsAbsolute } from "./worlds-BdxLeKul.js";
2
2
  import { FileSystem, FsError } from "@deepseek-ai/dsh-fs";
3
3
  //#region src/p2/router-fs.ts
4
4
  /**
@@ -179,6 +179,8 @@ var TransparentFileSystem = class extends FileSystem {
179
179
  if (pw.kind === "local") return this.localFs.contains(parent, child);
180
180
  if (pw.id !== cw.id) return false;
181
181
  try {
182
+ const remoteFs = this.remote.cachedFs(pw.alias);
183
+ if (remoteFs !== void 0) return remoteFs.contains(parent, child);
182
184
  const left = this.processPath(parent);
183
185
  const right = this.processPath(child);
184
186
  return right === left || right.startsWith(left.endsWith("/") ? left : `${left}/`);
@@ -239,6 +241,18 @@ var TransparentFileSystem = class extends FileSystem {
239
241
  const { fs, world } = await this.backendOf(target);
240
242
  return fs.writeText(target, content, expected, signal, this.remote.rewritePolicy(sandboxPolicy, world));
241
243
  }
244
+ /**
245
+ * alpha.3's `FileSystem` gained verbatim byte writes. The base class rejects
246
+ * them, so a router that only forwards text silently turned every remote byte
247
+ * write (document-preview renders, attachment materialization) into a
248
+ * capability regression. Delegate like `writeText`; a provider from an older
249
+ * generation still fails as a typed `FsError` instead of a `TypeError`.
250
+ */
251
+ async writeBytes(target, data, expected, signal, sandboxPolicy) {
252
+ const { fs, world } = await this.backendOf(target);
253
+ if (typeof fs.writeBytes !== "function") throw this.unsupportedRemote("writing bytes");
254
+ return fs.writeBytes(target, data, expected, signal, this.remote.rewritePolicy(sandboxPolicy, world));
255
+ }
242
256
  async editText(target, edit, expected, signal, sandboxPolicy) {
243
257
  const { fs, world } = await this.backendOf(target);
244
258
  return fs.editText(target, edit, expected, signal, this.remote.rewritePolicy(sandboxPolicy, world));
@@ -32,6 +32,18 @@
32
32
  import type { RemoteChangesDiff, RemoteChangesSummary, RemoteTimeouts } from '../protocol.ts';
33
33
  import type { RemotePool } from '../pool.ts';
34
34
  import type { RemoteWorlds } from '../p2/worlds.ts';
35
+ /**
36
+ * How many collapsed directories one untracked scan will expand.
37
+ *
38
+ * The fast walk (`--directory`) answers in one command no matter how many
39
+ * untracked directories there are; expanding each one is another `git ls-files`
40
+ * on the SAME shared connection, so the count has to be bounded. Twenty is the
41
+ * budget that keeps a normal monorepo complete (a session creates a handful of
42
+ * directories) while a checkout full of un-ignored build output stops early and
43
+ * says so (`truncated`), instead of turning one background scan into hundreds of
44
+ * exec channels.
45
+ */
46
+ export declare const UNTRACKED_EXPAND_DIRS = 20;
35
47
  /** The two facts a turn boundary needs from a Session, kept cordis-free. */
36
48
  export interface LedgerTarget {
37
49
  sessionId: string;
@@ -343,8 +355,36 @@ export declare class SessionChanges {
343
355
  * runs twice at once, and only runs again after {@link untrackedCadence}. A
344
356
  * repository that cannot answer inside {@link untrackedBudget} is written off
345
357
  * for the session (`untrackedGivenUp`) rather than retried every turn.
358
+ *
359
+ * Two phases since the scan learned `--directory`: one fast walk that collapses
360
+ * untracked directories (`build/` instead of 3000 paths) and then a BOUNDED
361
+ * expansion of the collapsed entries, because the panel's contract is a list of
362
+ * FILES. A walk that already answered with files expands nothing at all.
346
363
  */
347
364
  private kickUntracked;
365
+ /**
366
+ * Turn the fast walk's collapsed directories back into files, within bounds.
367
+ *
368
+ * Bounded THREE ways, because every expansion is another `git ls-files` on the
369
+ * same shared connection and the scan runs in the background where nobody is
370
+ * watching:
371
+ *
372
+ * - at most {@link UNTRACKED_EXPAND_DIRS} directories, sorted first so the
373
+ * choice is deterministic (a rescan of an unchanged tree expands the same
374
+ * ones, and the gate can pin exactly which);
375
+ * - the same file cap the panel lists (`maxFiles`, 500 by default), so one
376
+ * huge directory cannot push the list past what is displayable;
377
+ * - the fast walk's own deadline: when it runs out the phase stops.
378
+ *
379
+ * Hitting any of them — or an expansion that fails — marks the result
380
+ * `truncated` instead of returning a short list silently. A failed expansion is
381
+ * NOT `untrackedGivenUp`: the fast walk answered, so new-file detection still
382
+ * works; only part of it is missing.
383
+ *
384
+ * @returns the file entries (walk files + expanded ones) and whether the list
385
+ * is incomplete.
386
+ */
387
+ private expandUntracked;
348
388
  /**
349
389
  * How long before the untracked scan may run again.
350
390
  *
@@ -380,22 +420,37 @@ export declare class SessionChanges {
380
420
  private withWatchdog;
381
421
  /** Read a batch of files, capped per file and in total. */
382
422
  private readPaths;
383
- /** Run one command on the host, normalizing failure into a reason string. */
423
+ /**
424
+ * Run one command on the host, normalizing failure into a reason string.
425
+ *
426
+ * Every command this ledger issues is a git command (a repository read: `git
427
+ * status`, the untracked walk, its expansion, the file-content reads — the
428
+ * recorder never mutates). So they all spend the host's git-command budget
429
+ * (`lane: 'git'`) instead of a shared exec slot: these scans run in the HOST
430
+ * process while the user is working, and a 300-second `git status` must not be
431
+ * the reason a monitor sample, the process panel or an agent tool answers
432
+ * "host is busy".
433
+ */
384
434
  private run;
385
435
  /** Turn a failed scan into something a user can act on. */
386
436
  private reasonOf;
387
437
  /** One exec's budget: the git setting, clamped so a hung host cannot pile up work. */
388
438
  private execBudget;
389
- /** The untracked scan gets its own, more generous budget. */
390
439
  /**
391
- * The untracked scan gets its own, much more generous budget.
392
- *
393
- * Three minutes is a deliberate choice for a monorepo: the walk is proportional
394
- * to the whole checkout, not to the session, and the reference AOSP tree has
395
- * been measured past a minute cold. Waiting is acceptable here because the
396
- * scan runs in the background and the tracked changes are already on screen;
397
- * giving up early is not, because the files a session creates with a shell
398
- * command are visible ONLY through this scan.
440
+ * The untracked scan gets its own, more generous budget — one minute.
441
+ *
442
+ * The walk is proportional to the whole checkout, not to the session, so it
443
+ * cannot use the ordinary git budget. It used to be three minutes; that ceiling
444
+ * was set before the scan learned `--directory`, when a monorepo's answer really
445
+ * could take that long. Now the fast walk collapses whole directories, so a
446
+ * minute is already several times the useful wait, and every second past it is
447
+ * spent holding an exec channel on the SHARED connection while the tree is
448
+ * still being walked for nothing. Past a minute the honest answer is "this host
449
+ * cannot enumerate new files quickly enough" — `untrackedFailure` says so and the
450
+ * panel offers a retry, which is the same contract as before, just cut shorter.
451
+ *
452
+ * The floor (10s) is untouched: a small repository must never be cut off by a
453
+ * tiny configured `gitMs`.
399
454
  */
400
455
  private untrackedBudget;
401
456
  /**
@@ -143,19 +143,64 @@ export declare function excludeDirNames(dirs: readonly string[] | undefined): st
143
143
  /**
144
144
  * New files git is not tracking yet (the ones a session usually creates).
145
145
  *
146
+ * `--directory` is the load-bearing flag. Without it git descends into every
147
+ * untracked directory and prints one path per FILE: measured on the reference
148
+ * monorepo that is 11.25s warm, and on a cold AOSP checkout past a minute. With
149
+ * it, an untracked directory is reported ONCE as `dir/` (trailing slash) and git
150
+ * stops descending — a build tree or an un-ignored dependency tree costs one
151
+ * record instead of thousands of `stat`s. The scan still has to walk the tracked
152
+ * part of the tree, but the expensive half is exactly the part that is skipped.
153
+ *
154
+ * The semantic cost is that the answer now names directories; the caller expands
155
+ * the ones it still wants files for with {@link untrackedExpandCommand}, within
156
+ * bounds of its own (see `UNTRACKED_EXPAND_DIRS` in `recorder.ts`). A file that
157
+ * git reports directly is already the final answer.
158
+ *
146
159
  * The exclusions are pushed down as pathspecs (`:(exclude)out`) rather than
147
160
  * filtered after the fact, so those paths never cross the wire and never enter
148
161
  * the 500-row cap. Measured on a tree with 3000 build outputs + 300 sources:
149
162
  * 3300 records / 61.5 KB unfiltered versus 300 records / 6.8 KB with two
150
- * exclusions — the walk itself costs the same either way (git still descends
151
- * those directories), so the win is wire bytes, parse time and the read budget,
152
- * not scan latency.
163
+ * exclusions.
153
164
  *
154
165
  * @param root - remote absolute POSIX directory (the session cwd).
155
166
  * @param excludeDirs - directory names to leave out (see {@link excludeDirNames}).
156
167
  * @returns a `sh` script printing NUL-separated paths.
157
168
  */
158
169
  export declare function untrackedCommand(root: string, excludeDirs?: readonly string[]): string;
170
+ /**
171
+ * Whether a `--directory` record names a collapsed DIRECTORY.
172
+ *
173
+ * git marks one with a trailing slash; a record without it is a file, which is
174
+ * already the final answer and must not be expanded again.
175
+ */
176
+ export declare function isUntrackedDirectoryPath(path: string): boolean;
177
+ /**
178
+ * List the files inside EVERY directory a {@link untrackedCommand} walk
179
+ * collapsed, in ONE command.
180
+ *
181
+ * Same walk, same exclusions, minus `--directory`: the caller gets file paths
182
+ * again. One command for all of them on purpose — git also collapses directories
183
+ * that hold nothing but IGNORED files (`build/` full of gitignored output) and
184
+ * empty ones, so a per-directory loop would spend a whole round trip (and one of
185
+ * the expansion slots) proving that such a directory has no visible file inside.
186
+ * Batched, an empty directory costs nothing and cannot push a real one out of
187
+ * the slot budget.
188
+ *
189
+ * Every directory comes from git's own output, but each still crosses a shell, so
190
+ * each goes through {@link shq} — a directory named `it's a 目录` is one quoted
191
+ * argument, never a second command or a flag.
192
+ *
193
+ * The trailing slash the fast walk adds is dropped: the pathspec names the
194
+ * directory either way, and a bare path keeps this builder from ever emitting
195
+ * `-- ''` (which would mean "the whole repository").
196
+ *
197
+ * @param root - remote absolute POSIX directory (the session cwd).
198
+ * @param dirs - collapsed directories from {@link untrackedCommand}, with or
199
+ * without their trailing slashes.
200
+ * @param excludeDirs - the same exclusions the fast walk used (nested build
201
+ * output inside a collapsed directory must stay out too).
202
+ */
203
+ export declare function untrackedExpandCommand(root: string, dirs: readonly string[], excludeDirs?: readonly string[]): string;
159
204
  /**
160
205
  * Parse `git status --porcelain -z -uno` output.
161
206
  *
@@ -0,0 +1,73 @@
1
+ /**
2
+ * SSH connection-pool section shown on the monitor page, right under the
3
+ * process table.
4
+ *
5
+ * The pool is where "why is this slow" has an actual answer: one shared TCP
6
+ * connection per host carries exec/git/monitor traffic, terminals and port
7
+ * forwards dial their own, file operations ride a third, and each lane has a
8
+ * channel budget. When a budget is full the work QUEUES — and that is invisible
9
+ * from the file tree, where a slow listing just looks like a slow remote. So
10
+ * the page prints the four lanes, their channel counts, the slot occupancy and
11
+ * the route the shared connection took.
12
+ *
13
+ * Cost rules, the same ones the process section above follows:
14
+ * - collapsed by default; a collapsed section issues ZERO requests, because a
15
+ * closed diagnostic panel must not become the plugin's traffic source;
16
+ * - sampling happens only while the section is EXPANDED, the monitor panel is
17
+ * the visible view AND the page is in the foreground. There is no second
18
+ * throttle: the panel's own interval (and its pause control) is the cadence.
19
+ *
20
+ * Degradation: a Host that predates the route answers 404. That is not an error
21
+ * — the section keeps its header and prints ONE muted line saying so, instead of
22
+ * an error banner or an empty pool that would read as "nothing is connected".
23
+ * After it has said that it stops asking: the answer cannot change without an
24
+ * upgrade and a page reload.
25
+ */
26
+ import { type ReactNode } from 'react';
27
+ import type { RemoteHostPoolStats, RemoteHostSummary } from '../protocol.ts';
28
+ /** Fallback cadence when the panel has no interval of its own. */
29
+ export declare const POOL_POLL_MS = 5000;
30
+ /**
31
+ * Rounds waiting for a channel on ANY budget of one host.
32
+ *
33
+ * All three budgets are queues the user can be stuck behind, so the badge, the
34
+ * summary and the "a queue sorts first" rank count them together; which budget
35
+ * is full is the per-line detail below the lanes.
36
+ */
37
+ export declare function queuedOf(host: RemoteHostPoolStats): number;
38
+ /**
39
+ * Channels riding that host's lanes (the header summary's "N connections").
40
+ *
41
+ * The helper counts too: it is its own SSH connection with one channel, and a
42
+ * summary that said "0 connections" while a helper session was up would be the
43
+ * one number on the page that lies. Its lane is absent when the Host cannot
44
+ * report it, and then it contributes nothing.
45
+ */
46
+ export declare function channelsOf(host: RemoteHostPoolStats): number;
47
+ /**
48
+ * Host order: the CURRENT host first, then a queue, then alias.
49
+ *
50
+ * The current host is the one the workspace is bound to, so its numbers are the
51
+ * answer to "why is what I am doing slow" — it belongs at the top even when it
52
+ * has nothing queued. Everything below keeps the rules this list was built on:
53
+ * a queued host outranks an idle one, and the rest is alias order.
54
+ *
55
+ * The host with work waiting behind a full budget is the one the user is
56
+ * looking for, so "has a queue" is the only promotion. The rank is a BOOLEAN on
57
+ * purpose: ranking by the queue DEPTH made rows swap places between polls (a
58
+ * host draining from 3 queued to 1 slid under a host at 2 — the same two hosts,
59
+ * a different order, nothing the user could have come to read). Everything else
60
+ * keeps a fixed order; the number itself is on the row's badge and in the
61
+ * summary. Aliases compare by code unit, not `localeCompare`: the order must
62
+ * not depend on the browser's locale.
63
+ */
64
+ export declare function sortPoolHosts(hosts: readonly RemoteHostPoolStats[], currentAlias?: string): RemoteHostPoolStats[];
65
+ export declare function ConnectionsSection(props: {
66
+ t: (key: string) => string;
67
+ hosts: RemoteHostSummary[];
68
+ visible: boolean;
69
+ paused: boolean;
70
+ intervalMs: number;
71
+ /** Alias of the host this workspace is bound to (sorted first). */
72
+ currentAlias?: string;
73
+ }): ReactNode;
@@ -9,6 +9,8 @@ export declare function WorkspacesView(props: {
9
9
  workspaces: RemoteWorkspaceBinding[];
10
10
  routing: RemoteRoutingStatus;
11
11
  onChanged: () => void;
12
+ /** False while the panel is off screen: the live poll below only runs on screen. */
13
+ visible?: boolean;
12
14
  /** Open the files view for a binding; omitted where no files view exists (settings section hides the button). */
13
15
  onOpenFiles?: (workspaceId: string) => void;
14
16
  }): ReactNode;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Typed fetch wrapper over the /api/dsh-remote JSON API (full P0 surface).
3
3
  */
4
- import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteConnectionStatus, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteForwardRequest, type RemoteForwardState, type RemoteHostProxySetting, type RemoteHostSummary, type RemoteListenPortsResult, type RemoteProcessKillResult, type RemoteProcessesResult, type RemotePluginMeta, type RemoteProbe, type RemoteProxySettingsPatch, type RemoteProxySettingsView, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteViewSettings, type RemoteWorkspaceBinding, type RemoteWriteConflict, type RemoteWriteResult } from '../protocol.ts';
4
+ import { type GitBranch, type GitCommit, type GitShow, type GitStatus, type HelperAvailability, type ImportReport, type RemoteChangesDiff, type RemoteChangesSummary, type RemoteConnectionStatus, type RemoteDeployState, type RemoteExecResult, type RemoteFileEntry, type RemoteForwardRequest, type RemoteForwardState, type RemoteHostProxySetting, type RemoteHostSummary, type RemoteListenPortsResult, type RemoteProcessKillResult, type RemoteProcessesResult, type RemotePluginMeta, type RemotePoolStatsResult, type RemoteProbe, type RemoteProxySettingsPatch, type RemoteProxySettingsView, type RemoteRead, type RemoteRoutingStatus, type RemoteTimeouts, type RemoteViewSettings, type RemoteWorkspaceBinding, type RemoteWriteConflict, type RemoteWriteResult } from '../protocol.ts';
5
5
  export declare class RemoteApiError extends Error {
6
6
  readonly status: number;
7
7
  /**
@@ -161,6 +161,18 @@ export declare function remoteWriteSequence(): number;
161
161
  * stash invalidate the quick-open index at all.
162
162
  */
163
163
  export declare function execChangesWorktree(command: string): boolean;
164
+ /**
165
+ * Which HOST channel budget a command spends (see `api.exec`).
166
+ *
167
+ * The host keeps three budgets on the shared connection: the default exec one,
168
+ * `network` for `git fetch/pull/push/sync` (they can hold a channel for the whole
169
+ * 20-minute network timeout) and `git` for git commands — the reads
170
+ * (`git status/diff/log` and the ledger's scans, 300 s by default) and the local
171
+ * writes (commit / stage / discard / branch verbs). Both of those used to park an
172
+ * exec slot for minutes, which is what starved the monitor, the process panel and
173
+ * the agent tools.
174
+ */
175
+ export type ExecLane = 'exec' | 'network' | 'git';
164
176
  export declare const api: {
165
177
  getHosts: () => Promise<RemoteHostSummary[]>;
166
178
  createHost: (payload: HostForm) => Promise<RemoteHostSummary>;
@@ -211,8 +223,15 @@ export declare const api: {
211
223
  * One remote command (`/exec`), foreground unless `opts.background` asks for
212
224
  * the git channel. Reads the SCM panel builds stay foreground; the
213
225
  * repository-wide walks pass `{ background: true }` (see `scm/actions.ts`).
226
+ *
227
+ * `lane` picks the HOST's channel budget, and it is a separate argument on
228
+ * purpose: `opts` is scheduling (request gate, abort) and never reaches the
229
+ * body, while this one is a body field the pool reads. `'network'` is for
230
+ * `git fetch/pull/push/sync` only — those can hold a channel for 20 minutes and
231
+ * must not spend the slots every other command waits on. Omitted means the
232
+ * shared exec budget, i.e. what all existing callers get.
214
233
  */
215
- exec: (alias: string, command: string, timeoutMs?: number, opts?: RequestOptions) => Promise<RemoteExecResult>;
234
+ exec: (alias: string, command: string, timeoutMs?: number, opts?: RequestOptions, lane?: ExecLane) => Promise<RemoteExecResult>;
216
235
  /**
217
236
  * Streaming exec: the network verbs' live log.
218
237
  *
@@ -220,10 +239,20 @@ export declare const api: {
220
239
  * command runs, and the promise settles on the `exit` frame. An aborted
221
240
  * `signal` cancels the remote process group on the host side (the route acts
222
241
  * on the closed response), so a cancel button can actually stop a push.
242
+ *
243
+ * `lane` marks the HOST budget exactly like `api.exec`'s fifth argument
244
+ * (`'network'` for fetch/pull/push, `'git'` for git commands). It is a body
245
+ * field, kept in this handlers bag because that bag IS the options object this
246
+ * call already has (a fifth positional would read as `timeoutMs`). The older
247
+ * `network: true` spelling is still accepted and means `lane: 'network'`, so a
248
+ * caller written before the third budget keeps working.
223
249
  */
224
250
  execStream: (alias: string, command: string, timeoutMs: number, handlers: {
225
251
  onData?: (stream: "out" | "err", text: string) => void;
226
252
  signal?: AbortSignal;
253
+ lane?: ExecLane;
254
+ /** @deprecated use `lane: 'network'` */
255
+ network?: boolean;
227
256
  }) => Promise<RemoteExecResult>;
228
257
  getWorkspaces: () => Promise<{
229
258
  workspaces: RemoteWorkspaceBinding[];
@@ -347,6 +376,16 @@ export declare const api: {
347
376
  * between the panel's host list and this call is a normal 404.
348
377
  */
349
378
  hostMetrics: (alias: string, refresh?: boolean) => Promise<import("../protocol.ts").RemoteHostMetrics>;
379
+ /**
380
+ * Live SSH pool shape of every host (connections, channels, slot occupancy).
381
+ *
382
+ * A purely LOCAL read of the Host's own pool — no remote command rides it, so
383
+ * the monitor page can poll it while a section is open without spending a
384
+ * channel. `undefined` means the Host does not know the route (404, an older
385
+ * plugin): the caller degrades quietly instead of painting an error, the same
386
+ * rule `proc.hostTooOld` follows for the process panel.
387
+ */
388
+ getPoolStats: () => Promise<RemotePoolStatsResult | undefined>;
350
389
  git: {
351
390
  status(alias: string, path: string): Promise<GitStatus>;
352
391
  log(alias: string, path: string, max: number, branch?: string): Promise<GitCommit[]>;
@@ -37,10 +37,17 @@
37
37
  * - `remoteRelativePath`: POSIX-only prefix strip against `remoteRoot`
38
38
  * (case-sensitive; outside/traversal refuses with `undefined`, never an
39
39
  * absolute mention — the local `workspaceRelativePath` policy).
40
+ * **`remoteRoot` is always the BINDING's workspace root, never the SCM
41
+ * repo root.** The model resolves mentions against the session workspace
42
+ * root, so rooting them at a selected repository would both drop every file
43
+ * outside that repository and shift every file inside it by the repository
44
+ * prefix (the repository may be a subdirectory of the workspace, or enclose
45
+ * it).
40
46
  * - `insertRemoteReference`: the caller passes `remoteRoot` directly; there is
41
47
  * no workspaces-membership lookup here because the binding gate lives in
42
48
  * `use-remote-chat-target.ts` (current session must belong to the viewed
43
- * binding, else the button is disabled).
49
+ * binding, else the button is disabled). Callers must pass the workspace
50
+ * root — `store.root`/the explorer's `root` — not `repoRoot`.
44
51
  * - `sameLocalDir`: Windows-tolerant alias-dir comparison for that gate.
45
52
  *
46
53
  * No ctx reads at module scope (explicit `ctx` params only) so every function
@@ -10,6 +10,7 @@
10
10
  import { REMOTE_API } from '../../protocol.ts';
11
11
  import type { GitBranch, GitCommit, GitCommitFile, GitRemote, GitStash, GitStatusDetail, RemoteExecResult, RemoteRead } from '../../protocol.ts';
12
12
  import { type BlameLine, type FileHistoryCommit } from '../blame-model.ts';
13
+ import { type ExecLane } from '../api.ts';
13
14
  import { type PushTarget } from '../exec-output.ts';
14
15
  /** Error carrying a message already fit for the UI. */
15
16
  export declare class GitOpError extends Error {
@@ -34,6 +35,23 @@ export declare function joinRemote(dir: string, rel: string): string;
34
35
  export interface RunOptions {
35
36
  background?: boolean;
36
37
  signal?: AbortSignal;
38
+ /**
39
+ * Which HOST channel budget this command spends.
40
+ *
41
+ * The default for everything in this file is `'git'` — the git-command budget,
42
+ * where a big tree's `git status` is allowed 300 s and a git command used to
43
+ * park one of the shared exec slots for that whole time. It covers the local
44
+ * writes too (`commit`, `stage`, `discard`, branch verbs): they are git commands
45
+ * with a git timeout, and they must not compete with the monitor and the agent
46
+ * tools for the exec slots either. `'network'` is for the fetch/pull/push family,
47
+ * whose budget is even longer (20 minutes). Omitted means "the default above",
48
+ * and only a command that is NOT a git command may ask for `'exec'` — there is
49
+ * none in this module today.
50
+ *
51
+ * Deliberately NOT part of {@link RequestOptions}: that bag drives the local
52
+ * request gate and the fetch, while this is a body field the host's pool reads.
53
+ */
54
+ lane?: ExecLane;
37
55
  }
38
56
  /** The repository that encloses a workspace directory (undefined when none). */
39
57
  export declare function resolveRepoRoot(alias: string, workspaceRoot: string): Promise<string | undefined>;
@@ -202,7 +220,13 @@ export declare function applyHunk(alias: string, root: string, patch: string, mo
202
220
  export declare function commitAll(alias: string, root: string, message: string, amend?: boolean): Promise<string>;
203
221
  /** Last commit message (drives the amend flow). */
204
222
  export declare function lastCommitMessage(alias: string, root: string): Promise<string>;
205
- /** fetch / pull / push / sync. */
223
+ /**
224
+ * fetch / pull / push / sync.
225
+ *
226
+ * Every branch here is a NETWORK verb (`{ lane: 'network' }`): each one can hold a
227
+ * channel for `networkBudgetMs`, so it spends the host's small network budget
228
+ * rather than the repository-read one the rest of this module uses.
229
+ */
206
230
  export declare function syncRepo(alias: string, root: string, kind: 'fetch' | 'pull' | 'push' | 'sync'): Promise<string>;
207
231
  /**
208
232
  * Push to an explicit remote with an explicit refspec (Gerrit review flow:
@@ -50,7 +50,7 @@ export interface SelectionPopupControls<T> {
50
50
  /** The current popup (null = hidden). */
51
51
  popup: SelectionPopup<T> | null;
52
52
  /** Attach to the portaled button element. */
53
- buttonRef: RefObject<HTMLButtonElement>;
53
+ buttonRef: RefObject<HTMLButtonElement | null>;
54
54
  /** Anchor the popup above a selection (viewport-clamped). */
55
55
  show(insert: T, left: number, top: number): void;
56
56
  /** Hide the popup (idempotent). */
@@ -8,12 +8,15 @@ export declare const hairline: CSSProperties;
8
8
  export declare const inputStyle: CSSProperties;
9
9
  /**
10
10
  * Native dropdown that follows the DSH theme in BOTH states: the closed box
11
- * uses the translucent surface, while the open option popup (which Chrome
12
- * renders from `color-scheme`, ignoring translucent backgrounds) gets
13
- * explicit Canvas colors + a declared scheme so dark theme stays readable.
11
+ * uses the translucent surface, while the open option popup is painted by the
12
+ * browser from each option's own colors. Themed through the `.rvs-dropdown`
13
+ * class (vsc.css) — `Canvas`/`CanvasText` used to resolve against the page
14
+ * scheme, which DSH never switches, so the dark theme kept a white list.
15
+ * `color-scheme` is deliberately NOT set here: an inline `light dark` would
16
+ * override the class's per-theme value.
14
17
  */
15
18
  export declare const selectStyle: CSSProperties;
16
- /** Option rows of the open popup: explicit theme-following colors. */
19
+ /** Option rows of the open popup: opaque, theme-following, measured ≥7:1. */
17
20
  export declare const optionStyle: CSSProperties;
18
21
  export declare const btnStyle: CSSProperties;
19
22
  export declare const btnPrimaryStyle: CSSProperties;
@@ -1,5 +1,13 @@
1
+ /**
2
+ * Helper RPC over an ssh2 exec channel: the Windows-native transport for the
3
+ * official helper wire protocol. Speaks stdio RPC (SshRpcPeer + official
4
+ * schemas) to the deployed `dsh-ssh-helper` binary — no OpenSSH CLI, no POSIX
5
+ * gates. One connection per host alias; heartbeats keep the helper lease alive.
6
+ */
7
+ import { Client } from 'ssh2';
1
8
  import { z } from 'zod';
2
9
  import type { RemoteHostEntry } from '../protocol.ts';
10
+ import type { RoutedDial } from '../pool.ts';
3
11
  export interface RpcDialOpts {
4
12
  entry: RemoteHostEntry;
5
13
  /** Absolute remote path of the helper executable. */
@@ -9,6 +17,26 @@ export interface RpcDialOpts {
9
17
  /** Remote default workspace for the hello handshake. */
10
18
  workspace: string;
11
19
  leaseMs?: number;
20
+ /**
21
+ * The HOST's routed transport for this alias (proxy tunnel / jump-host channel),
22
+ * optional so a caller without a pool still dials directly.
23
+ *
24
+ * Without it this transport is a BARE direct connection: a host reachable only
25
+ * through a proxy or jump host would answer exec/SFTP (the pool honours the
26
+ * route) and fail every file/Git fast path — the "some features work, some do
27
+ * not" report. The pool supplies it via `openRoutedSocket`; the returned
28
+ * `release` is called here (once) on failure, close, reconnect and dispose.
29
+ */
30
+ openSocket?: () => Promise<RoutedDial>;
31
+ /**
32
+ * The ssh2 client factory.
33
+ *
34
+ * A seam, not a preference — the same one `RemotePool.makeClient` has: the only
35
+ * way a self-check can observe what this transport hands ssh2 (`{sock}` with no
36
+ * `host`/`port` for a routed dial, the reverse for a direct one) without a real
37
+ * server. Production never overrides it.
38
+ */
39
+ makeClient?: () => Client;
12
40
  }
13
41
  export interface RpcHello {
14
42
  protocol: number;
@@ -63,6 +91,17 @@ export declare class RpcConnection {
63
91
  * grow host memory.
64
92
  */
65
93
  private stderrTail;
94
+ /**
95
+ * Teardown of the ROUTED transport this attempt rides (proxy socket / jump-host
96
+ * tunnel), or undefined for a direct dial.
97
+ *
98
+ * It lives on the instance because the release has to outlive the handshake: the
99
+ * tunnel must stay open exactly as long as the SSH connection rides it, so the
100
+ * call belongs in `teardownTransport` (dispose, reconnect, failed open) rather
101
+ * than in the dial promise. The pool's release is idempotent, so calling it from
102
+ * a failure path AND from the teardown is safe.
103
+ */
104
+ private releaseRoute;
66
105
  /** Per-connection in-flight cap; see MAX_IN_FLIGHT. */
67
106
  private readonly gate;
68
107
  constructor(opts: RpcDialOpts);
@@ -70,6 +109,15 @@ export declare class RpcConnection {
70
109
  get alive(): boolean;
71
110
  /** Whatever the helper last wrote to stderr — empty when it said nothing. */
72
111
  get diagnostics(): string;
112
+ /**
113
+ * How many helper calls are in flight right now.
114
+ *
115
+ * Read-only diagnostics for the monitor: the helper caps itself at its own
116
+ * gate, so a saturated helper shows up as a number here instead of looking
117
+ * like an idle connection. It is NOT a queue — a call waits inside the gate
118
+ * before it counts, so this number never exceeds the gate's ceiling.
119
+ */
120
+ get inFlight(): number;
73
121
  get ready(): Promise<RpcHello>;
74
122
  /** Send one helper operation (mirrors SshConnection.request for fs-ssh). */
75
123
  request<T>(method: string, params: unknown, schema: z.ZodType<T>, signal?: AbortSignal): Promise<T>;
@@ -5,7 +5,7 @@
5
5
  * extra fields); unknown targets fail closed.
6
6
  */
7
7
  import { FileSystem } from '@deepseek-ai/dsh-fs';
8
- import type { FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteIntent, FsWriteOutcome } from '@deepseek-ai/dsh-fs';
8
+ import type { FsDeleteOutcome, FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsMoveOutcome, FsPathInfo, FsTarget, FsVersion, FsWriteBytesOutcome, FsWriteIntent, FsWriteOutcome } from '@deepseek-ai/dsh-fs';
9
9
  import type { SandboxExecutionPolicy, SandboxMode } from '@deepseek-ai/dsh-sandbox';
10
10
  export default class TransparentFileSystem extends FileSystem {
11
11
  static inject: string[];
@@ -85,6 +85,14 @@ export default class TransparentFileSystem extends FileSystem {
85
85
  }, signal?: AbortSignal): Promise<Uint8Array>;
86
86
  listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]>;
87
87
  writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteOutcome>;
88
+ /**
89
+ * alpha.3's `FileSystem` gained verbatim byte writes. The base class rejects
90
+ * them, so a router that only forwards text silently turned every remote byte
91
+ * write (document-preview renders, attachment materialization) into a
92
+ * capability regression. Delegate like `writeText`; a provider from an older
93
+ * generation still fails as a typed `FsError` instead of a `TypeError`.
94
+ */
95
+ writeBytes(target: FsTarget, data: Uint8Array, expected?: FsWriteIntent, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsWriteBytesOutcome>;
88
96
  editText(target: FsTarget, edit: FsEditRequest, expected?: {
89
97
  version: FsVersion;
90
98
  }, signal?: AbortSignal, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsEditOutcome>;
@@ -36,7 +36,24 @@ export declare class RemoteWorlds {
36
36
  private readonly ctx;
37
37
  private readonly deps;
38
38
  private readonly rpcs;
39
+ /**
40
+ * Aliases whose helper connection is still being dialed.
41
+ *
42
+ * `rpcs` holds the PROMISE, so a caller that awaits it waits for the whole
43
+ * dial (up to `CONNECT_READY_TIMEOUT_MS`, 45 s through a proxy or a jump host).
44
+ * The monitor polls `helperLane` every few seconds and must never inherit that
45
+ * wait — the route is read-only and would report the previous sample for the
46
+ * whole dial, or hold the client's single-flight guard. A name in this set is
47
+ * therefore "cannot say yet", which the client already renders as no row.
48
+ */
49
+ private readonly dialingRpc;
39
50
  private readonly fsViews;
51
+ /**
52
+ * Native Workspace registration id -> alias dir, refreshed by every
53
+ * `syncWorkspaces()`. DSH reports a sidebar workspace deletion by its own id,
54
+ * which carries no path, so this is the only way back to the binding.
55
+ */
56
+ private readonly nativeWorkspaces;
40
57
  private readonly fsReady;
41
58
  private readonly procs;
42
59
  /** Consecutive dial failures per alias; while the cooldown is set, no dial is attempted. */
@@ -120,6 +137,8 @@ export declare class RemoteWorlds {
120
137
  toSessionPath(route: Extract<WorldRoute, {
121
138
  kind: 'remote';
122
139
  }>, remoteAbsPath: string): string;
140
+ /** One binding's remote root, without a trailing slash (except `/` itself). */
141
+ private remoteRoot;
123
142
  /** Inverse of {@link toRemotePath}: the alias spelling of a remote path. */
124
143
  toAliasPath(route: Extract<WorldRoute, {
125
144
  kind: 'remote';
@@ -147,6 +166,21 @@ export declare class RemoteWorlds {
147
166
  note(route: WorldRoute, what: string): void;
148
167
  /** Ensure alias dirs + native registry entries for every binding. */
149
168
  syncWorkspaces(): Promise<void>;
169
+ /**
170
+ * A native Workspace under the alias root was deleted by the user (DSH's own
171
+ * sidebar): its binding follows — unbind + tombstone.
172
+ *
173
+ * The reverse direction is deliberately NOT symmetric: unbinding from this
174
+ * plugin keeps the native Workspace record (the user asked for exactly that —
175
+ * the workspace stays listed and only a fail-closed tombstone is added), while
176
+ * deleting the Workspace in DSH's sidebar is the user removing it outright, so
177
+ * the binding that named it goes with it. Without this, a deleted native
178
+ * workspace left a binding routing into an alias dir nobody can reach.
179
+ *
180
+ * @param nativeId - DSH's Workspace registration id.
181
+ * @returns the binding id that was removed, when one matched.
182
+ */
183
+ forgetNativeWorkspace(nativeId: string): string | undefined;
150
184
  /** Remote $HOME for one host alias (deploy record, else one probe). */
151
185
  homeFor(alias: string): Promise<string>;
152
186
  /** Best-effort remote mkdir -p (for paths the fs seam cannot create). */
@@ -162,6 +196,23 @@ export declare class RemoteWorlds {
162
196
  sweepSpillRoot(alias: string, home: string, ttlDays: number): Promise<void>;
163
197
  /** Remove one session's spill directory when it is older than the TTL (best effort). */
164
198
  sweepSpillDir(alias: string, dir: string, ttlDays: number): Promise<void>;
199
+ /**
200
+ * The helper connection of one alias, for the monitor's fifth lane.
201
+ *
202
+ * The helper dials its OWN SSH connection (see `RpcConnection`), so the pool
203
+ * cannot report it — this is the only place that knows. Read-only by
204
+ * contract: it awaits a record that already exists and never starts a dial, a
205
+ * deploy or a reconnect, because the monitor polls this every few seconds and
206
+ * a diagnostic must not be able to bring a helper up (or keep a dead one
207
+ * alive). `undefined` means "cannot say": no record, a record still dialing, or
208
+ * a record the router is about to replace — the client then omits the row
209
+ * rather than claiming the helper is closed.
210
+ */
211
+ helperLane(alias: string): Promise<{
212
+ open: boolean;
213
+ channels: number;
214
+ held: number;
215
+ } | undefined>;
165
216
  /** Drop one host's RPC + fs view + proc runtime (call after host update/delete). */
166
217
  dropHost(alias: string): Promise<void>;
167
218
  dispose(): Promise<void>;