dsh-remote-vs 0.27.0 → 0.29.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 (67) hide show
  1. package/README.en.md +159 -23
  2. package/README.md +123 -23
  3. package/lib/client.js +6906 -6619
  4. package/lib/index.js +2014 -67
  5. package/lib/types/changes/recorder.d.ts +119 -2
  6. package/lib/types/client/CodeEditor.d.ts +15 -0
  7. package/lib/types/client/HostsView.d.ts +139 -2
  8. package/lib/types/client/api.d.ts +42 -2
  9. package/lib/types/client/changes/apply-failure.d.ts +41 -0
  10. package/lib/types/client/changes/block-confirm.d.ts +97 -0
  11. package/lib/types/client/changes/diff-outcome.d.ts +56 -0
  12. package/lib/types/client/changes/freshness.d.ts +51 -0
  13. package/lib/types/client/changes/model.d.ts +19 -1
  14. package/lib/types/client/changes/session-diff.d.ts +100 -0
  15. package/lib/types/client/changes/staleness.d.ts +98 -0
  16. package/lib/types/client/changes/turn-reverted.d.ts +82 -0
  17. package/lib/types/client/changes/turn-view.d.ts +131 -0
  18. package/lib/types/client/changes/undo-affordance.d.ts +44 -10
  19. package/lib/types/client/changes/undo-target.d.ts +12 -0
  20. package/lib/types/client/connection.d.ts +28 -1
  21. package/lib/types/client/i18n.d.ts +1 -1
  22. package/lib/types/client/store.d.ts +91 -1
  23. package/lib/types/client/vsc/change-marks.d.ts +21 -0
  24. package/lib/types/forward.d.ts +11 -1
  25. package/lib/types/pool.d.ts +95 -1
  26. package/lib/types/protocol.d.ts +221 -1
  27. package/lib/types/proxy.d.ts +136 -0
  28. package/lib/types/store.d.ts +81 -1
  29. package/lib/types/tools.d.ts +3 -0
  30. package/package.json +1 -1
  31. package/src/changes/recorder.ts +851 -8
  32. package/src/client/CodeEditor.tsx +43 -3
  33. package/src/client/ConnectionStatus.tsx +19 -5
  34. package/src/client/EditorPane.tsx +64 -7
  35. package/src/client/HostsView.tsx +552 -11
  36. package/src/client/PortsView.tsx +16 -0
  37. package/src/client/SettingsHosts.tsx +132 -6
  38. package/src/client/api.ts +60 -3
  39. package/src/client/changes/ChangesDock.tsx +539 -54
  40. package/src/client/changes/apply-failure.ts +73 -0
  41. package/src/client/changes/block-confirm.ts +180 -0
  42. package/src/client/changes/changes.css +45 -0
  43. package/src/client/changes/diff-outcome.ts +97 -0
  44. package/src/client/changes/freshness.ts +68 -0
  45. package/src/client/changes/model.ts +56 -1
  46. package/src/client/changes/session-diff.ts +187 -0
  47. package/src/client/changes/staleness.ts +148 -0
  48. package/src/client/changes/turn-reverted.ts +254 -0
  49. package/src/client/changes/turn-view.ts +195 -0
  50. package/src/client/changes/undo-affordance.ts +295 -63
  51. package/src/client/changes/undo-target.ts +12 -0
  52. package/src/client/connection.ts +76 -2
  53. package/src/client/i18n.ts +204 -4
  54. package/src/client/scm/DiffView.tsx +32 -13
  55. package/src/client/store.tsx +392 -16
  56. package/src/client/vsc/change-marks.ts +21 -0
  57. package/src/client/vsc/preview-document.tsx +4 -1
  58. package/src/client/vsc/vsc.css +6747 -6509
  59. package/src/forward.ts +38 -2
  60. package/src/importers.ts +125 -13
  61. package/src/keygen.ts +8 -1
  62. package/src/pool.ts +422 -27
  63. package/src/protocol.ts +229 -1
  64. package/src/proxy.ts +673 -0
  65. package/src/routes.ts +93 -14
  66. package/src/store.ts +335 -0
  67. package/src/tools.ts +47 -2
package/src/protocol.ts CHANGED
@@ -32,6 +32,8 @@ export const REMOTE_API = {
32
32
  routing: '/api/dsh-remote/routing',
33
33
  /** Client view preferences (auto-open the remote page + its width share). */
34
34
  viewSettings: '/api/dsh-remote/view-settings',
35
+ /** Profile-wide proxy default (per-host overrides live on the host rows). */
36
+ proxySettings: '/api/dsh-remote/proxy-settings',
35
37
  /** Current working directory of one live session (click resolution helper). */
36
38
  sessionCwd: '/api/dsh-remote/session-cwd',
37
39
  /** What one live session changed on its remote host (the review panel). */
@@ -61,6 +63,75 @@ export function selectionDownloadName(count: number): string {
61
63
  /** Authentication flavors a host entry may carry (P0: direct only, no jump/agent). */
62
64
  export type RemoteAuthKind = 'key' | 'password'
63
65
 
66
+ /**
67
+ * How one host reaches the network.
68
+ *
69
+ * Two levels exist on purpose: a profile-wide default (`RemoteProxySettingsView`)
70
+ * and a per-host override. `inherit` is the default state of every existing
71
+ * host, and the default default is `direct`, so an upgrade changes nothing.
72
+ */
73
+ export type RemoteProxyMode = 'inherit' | 'direct' | 'proxy' | 'jump'
74
+
75
+ /** One stored proxy endpoint (secrets included: host-side only). */
76
+ export interface RemoteProxySetting {
77
+ kind: 'http' | 'socks5'
78
+ /** Proxy hostname or IP. */
79
+ host: string
80
+ /** Proxy port. */
81
+ port: number
82
+ /** Basic auth (http) / user+password (socks5). */
83
+ username?: string
84
+ password?: string
85
+ }
86
+
87
+ /** A host's proxy decision, as stored. */
88
+ export interface RemoteHostProxySetting {
89
+ mode: RemoteProxyMode
90
+ /** The endpoint for `mode: 'proxy'`. */
91
+ proxy?: RemoteProxySetting
92
+ /** The jump host for `mode: 'jump'` — an alias of another stored host. */
93
+ jump?: { viaAlias: string }
94
+ }
95
+
96
+ /** Secret-free proxy endpoint for the browser. */
97
+ export interface RemoteProxyTargetView {
98
+ kind: 'http' | 'socks5'
99
+ host: string
100
+ port: number
101
+ username?: string
102
+ /** True when a password is stored (never echoed back). */
103
+ hasPassword: boolean
104
+ }
105
+
106
+ /** Secret-free proxy decision of one host. */
107
+ export interface RemoteHostProxyView {
108
+ mode: RemoteProxyMode
109
+ target?: RemoteProxyTargetView
110
+ /** Alias of the jump host, for `mode: 'jump'`. */
111
+ jumpVia?: string
112
+ /**
113
+ * Why this setting cannot be used, when it cannot.
114
+ *
115
+ * A jump host that names itself, a chain longer than one hop, or a jump host
116
+ * that is itself reached through a jump is refused at dial time; saying so in
117
+ * the host's own row beats a generic "connection failed".
118
+ */
119
+ problem?: string
120
+ }
121
+
122
+ /** Profile-wide proxy default (the "upper" of the two levels). */
123
+ export interface RemoteProxySettingsView {
124
+ defaultMode: 'direct' | 'proxy'
125
+ target?: RemoteProxyTargetView
126
+ }
127
+
128
+ /** Patch shape for the profile-wide proxy default. */
129
+ export interface RemoteProxySettingsPatch {
130
+ defaultMode?: 'direct' | 'proxy'
131
+ /** `null` clears the stored endpoint; omitted keeps it. */
132
+ target?: RemoteProxySetting | null
133
+ }
134
+
64
135
  /** One stored host entry (the $DSH_HOME/dsh-remote.json store shape). */
65
136
  export interface RemoteHostEntry {
66
137
  /** Stable, user-chosen identifier used by every operation. */
@@ -85,6 +156,8 @@ export interface RemoteHostEntry {
85
156
  description?: string
86
157
  /** Free-form tags. */
87
158
  tags: string[]
159
+ /** How this host is reached (absent = `inherit`). */
160
+ proxy?: RemoteHostProxySetting
88
161
  /** Last deploy pipeline outcome for this host. */
89
162
  deploy?: RemoteDeployState | undefined
90
163
  createdAt: number
@@ -104,6 +177,8 @@ export interface RemoteHostSummary {
104
177
  managedKey: boolean
105
178
  description?: string
106
179
  tags: string[]
180
+ /** Secret-free proxy decision; always present (mode `inherit` when unset). */
181
+ proxy: RemoteHostProxyView
107
182
  deploy?: RemoteDeployState | undefined
108
183
  createdAt: number
109
184
  updatedAt: number
@@ -195,6 +270,37 @@ export interface RemoteTimeouts {
195
270
  readMs: number
196
271
  }
197
272
 
273
+ /**
274
+ * Where one SSH connection ACTUALLY left this machine.
275
+ *
276
+ * The user's question ("did this really go through the jump host?") cannot be
277
+ * answered by the stored configuration: a host can be configured for a jump host
278
+ * while a connection established BEFORE that edit is still serving. So the pool
279
+ * reports the route of the connection it is holding, and the browser shows it on
280
+ * the connection chip.
281
+ *
282
+ * `detail` is the hop itself (the target `host:port`, the proxy `host:port`, or
283
+ * the jump host alias) and NOT a formatted sentence: the wording is UI copy and
284
+ * therefore belongs to the localized client.
285
+ */
286
+ export interface EgressInfo {
287
+ kind: 'direct' | 'proxy' | 'jump'
288
+ /** The hop: the target endpoint, the proxy endpoint, or the jump host alias. */
289
+ detail: string
290
+ /** Jump route only: the alias of the host whose connection carries the tunnel. */
291
+ viaAlias?: string
292
+ /** Proxy route only: whether this host or the profile default chose the proxy. */
293
+ source?: 'host' | 'default'
294
+ /** Proxy route only: the protocol, so the UI can name it (HTTP / SOCKS5). */
295
+ proxyKind?: 'http' | 'socks5'
296
+ /**
297
+ * Set only on a CONFIGURED route whose resolution failed (a jump host that is
298
+ * gone, a self-jump, a half-configured proxy): the reason, so the chip can say
299
+ * why the route cannot work instead of silently reading as healthy.
300
+ */
301
+ problem?: string
302
+ }
303
+
198
304
  /**
199
305
  * Connection health for one host alias, as the Host's pool sees it.
200
306
  *
@@ -215,6 +321,18 @@ export interface RemoteConnectionStatus {
215
321
  errorAt?: number
216
322
  /** Human-readable failure the client can show in the status chip. */
217
323
  error?: string
324
+ /**
325
+ * The route the connection this pool HOLDS was actually opened through.
326
+ * Present only while such a connection exists: it is evidence about a live
327
+ * link, not about the current configuration.
328
+ */
329
+ egress?: EgressInfo
330
+ /**
331
+ * The route the stored configuration resolves to, for an alias with no live
332
+ * connection (what the NEXT connection would use, and the honest answer while
333
+ * nothing is dialed). Carries `problem` when the configuration is unusable.
334
+ */
335
+ configured?: EgressInfo
218
336
  }
219
337
 
220
338
  /** Remote OS probe outcome. */
@@ -532,6 +650,84 @@ export interface RemoteChangedFile {
532
650
  revert?: 'patch' | 'delete'
533
651
  }
534
652
 
653
+ /**
654
+ * The most recent COMPLETED turn, as the review panel switches to it.
655
+ *
656
+ * "This turn" is answered from the ledger's own turn boundaries: the host keeps
657
+ * every listed path's text at each turn close and compares the next close
658
+ * against it. Deliberately ONE turn deep — a per-turn history would need the
659
+ * full text of every file at every boundary, and the panel's job is "what did
660
+ * the turn I just ran change", not a time machine.
661
+ */
662
+ export interface RemoteChangesTurnView {
663
+ /** Turn number the delta describes (0 = no turn has closed yet). */
664
+ turn: number
665
+ /** Files this turn changed, with THIS TURN's counts (not the session total). */
666
+ files: RemoteChangedFile[]
667
+ added: number
668
+ deleted: number
669
+ /** Wall-clock ms when the delta was computed. */
670
+ at: number
671
+ /**
672
+ * Whether the per-file hunks behind `turnDiff` are cached.
673
+ *
674
+ * `false` = the turn's contents were too large for the memory budget (or the
675
+ * file cap made attribution unreliable): the counts above are still real, but
676
+ * clicking a row cannot paint hunks or revert. Honest degradation — the
677
+ * alternative would be comparing the next turn against a half-updated
678
+ * snapshot and attributing old changes to it.
679
+ */
680
+ cached: boolean
681
+ /** Why `cached` is false (shown to the user, never swallowed). */
682
+ reason?: string
683
+ /**
684
+ * This view is INCOMPLETE — and it is not "a prefix of a longer list".
685
+ *
686
+ * Three ways rows go missing:
687
+ * - the file cap cut the list (`files` is the first N of the scanned paths);
688
+ * - the previous turn's snapshot was cut by that cap, or a previous side was
689
+ * withheld (binary / over the read cap), so a path that cannot be compared is
690
+ * DROPPED instead of being guessed as a whole-file creation;
691
+ * - the previous turn's slow scan never landed before this turn closed, so a
692
+ * file missing from that snapshot cannot be proven new either.
693
+ *
694
+ * A partial view must say so: "these rows are what this turn provably changed",
695
+ * not "this is everything the turn changed".
696
+ */
697
+ truncated?: true
698
+ /**
699
+ * The turn's slow scan (`git ls-files --others`) has not landed yet.
700
+ *
701
+ * The same turn is REBUILT when it does (`correctTurn`), so this list may still
702
+ * grow — it is never relabelled as the next turn. When a newer turn closes
703
+ * first, the view stops waiting and `truncated` records that it never caught
704
+ * up.
705
+ */
706
+ pending?: true
707
+ }
708
+
709
+ /**
710
+ * Body of `op: 'list'` on the changes route (the request half of
711
+ * {@link RemoteChangesSummary}).
712
+ *
713
+ * The two refresh intents are separated because they cost very different things
714
+ * on the remote:
715
+ * - {@link RemoteChangesListRequest.force} (`⟳`) — tracked scan NOW and re-arm the
716
+ * slow `git ls-files --others` walk (clears its write-off). Deliberate click.
717
+ * - {@link RemoteChangesListRequest.trackedOnly} — "the user came back to the
718
+ * page": tracked files now, but the slow walk keeps its cadence and its
719
+ * written-off verdict. Focus events repeat every few seconds; re-arming an 11s
720
+ * (cold: minutes) walk on each one would multiply the remote load.
721
+ */
722
+ export interface RemoteChangesListRequest {
723
+ op: 'list'
724
+ sessionId: string
725
+ force?: true
726
+ trackedOnly?: true
727
+ /** Repository directory from the Source Control panel ('' = the session root). */
728
+ repoSubdir?: string
729
+ }
730
+
535
731
  /**
536
732
  * What one session changed on its remote host since the session's baseline.
537
733
  *
@@ -573,11 +769,31 @@ export interface RemoteChangesSummary {
573
769
  pending: boolean
574
770
  /** Why this session has no ledger (local session, no git, timeout, …). */
575
771
  unavailable?: string
772
+ /**
773
+ * The last completed turn's delta, when the host computed one.
774
+ *
775
+ * Optional on purpose: an older host (or a session with no closed turn yet)
776
+ * omits it and the panel stays on the session-cumulative view it has always
777
+ * shown. A client that does not know the field ignores it.
778
+ */
779
+ turnView?: RemoteChangesTurnView
576
780
  }
577
781
 
578
782
  /** One file's whole-session comparison, ready for editor decorations. */
579
783
  export interface RemoteChangesDiff {
580
- kind: 'text' | 'binary' | 'missing'
784
+ /**
785
+ * `unavailable` / `stale` belong to the per-turn comparison only.
786
+ *
787
+ * - `unavailable`: the host has no cached per-turn hunks for this session
788
+ * (memory budget, file cap, or no completed turn) — `reason` says which;
789
+ * - `stale`: the file changed after the turn closed, so the cached comparison
790
+ * no longer describes what is on disk; the client falls back to the
791
+ * session-cumulative view instead of painting wrong lines.
792
+ *
793
+ * The whole-session `diff` never returns them, so a client that switches on
794
+ * the old three kinds keeps working unchanged.
795
+ */
796
+ kind: 'text' | 'binary' | 'missing' | 'unavailable' | 'stale'
581
797
  /** Remote absolute POSIX path. */
582
798
  path: string
583
799
  display: string
@@ -596,6 +812,8 @@ export interface RemoteChangesDiff {
596
812
  status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
597
813
  /** The diff was cut at the byte cap: `hunks` is a prefix. */
598
814
  truncated?: true
815
+ /** For `unavailable` / `stale`: what happened, in words the panel can show. */
816
+ reason?: string
599
817
  }
600
818
 
601
819
  /** One row of the side-by-side diff projection. */
@@ -691,6 +909,16 @@ export interface RemoteForwardState {
691
909
  bytesOut: number
692
910
  /** Last connect/bind failure, human-readable. */
693
911
  lastError?: string
912
+ /**
913
+ * Which SSH connection the last successful channel used.
914
+ *
915
+ * `dedicated` = the host's own port-forward connection (the normal case);
916
+ * `shared` = the server refused the extra connection, so the channel rode the
917
+ * shared one (the forward still works, only the isolation is lost). Absent
918
+ * until a connection has succeeded at least once — older hosts omit it too, so
919
+ * a client must treat it as optional.
920
+ */
921
+ transport?: 'dedicated' | 'shared'
694
922
  startedAt: number
695
923
  }
696
924