dsh-remote-vs 0.11.1 → 0.12.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/src/protocol.ts CHANGED
@@ -1,474 +1,492 @@
1
- /**
2
- * Wire contract between the host half (routes.ts) and the browser half
3
- * (client/api.ts). Pure types + path constants only — imported by both
4
- * halves, bundled into each, no runtime identity to share.
5
- */
6
-
7
- /** API route table (all loopback-only). */
8
- export const REMOTE_API = {
9
- hosts: '/api/dsh-remote/hosts',
10
- test: '/api/dsh-remote/test',
11
- keygen: '/api/dsh-remote/keygen',
12
- exec: '/api/dsh-remote/exec',
13
- /** Streaming exec (server-sent events) for the long network verbs. */
14
- execStream: '/api/dsh-remote/exec-stream',
15
- files: '/api/dsh-remote/files',
16
- /** Streaming binary upload: raw request body, host and path in the query. */
17
- upload: '/api/dsh-remote/upload',
18
- workspaces: '/api/dsh-remote/workspaces',
19
- deploy: '/api/dsh-remote/deploy',
20
- importSshConfig: '/api/dsh-remote/import-ssh-config',
21
- importDshSsh: '/api/dsh-remote/import-dsh-ssh',
22
- terminal: '/api/dsh-remote/terminal',
23
- terminalClose: '/api/dsh-remote/terminal-close',
24
- routing: '/api/dsh-remote/routing',
25
- /** Current working directory of one live session (click resolution helper). */
26
- sessionCwd: '/api/dsh-remote/session-cwd',
27
- /** What one live session changed on its remote host (the review panel). */
28
- changes: '/api/dsh-remote/changes',
29
- } as const
30
-
31
- /** Authentication flavors a host entry may carry (P0: direct only, no jump/agent). */
32
- export type RemoteAuthKind = 'key' | 'password'
33
-
34
- /** One stored host entry (the $DSH_HOME/dsh-remote.json store shape). */
35
- export interface RemoteHostEntry {
36
- /** Stable, user-chosen identifier used by every operation. */
37
- alias: string
38
- /** Hostname or IP of the target. */
39
- host: string
40
- /** SSH port (default 22). */
41
- port: number
42
- /** Login user. */
43
- user: string
44
- /** Authentication. */
45
- auth: {
46
- kind: RemoteAuthKind
47
- /** Absolute path to the private key for 'key' auth. */
48
- keyPath?: string
49
- /** Passphrase for an encrypted key. */
50
- passphrase?: string
51
- /** Password for 'password' auth. */
52
- password?: string
53
- }
54
- /** Free-form note. */
55
- description?: string
56
- /** Free-form tags. */
57
- tags: string[]
58
- /** Last deploy pipeline outcome for this host. */
59
- deploy?: RemoteDeployState | undefined
60
- createdAt: number
61
- updatedAt: number
62
- }
63
-
64
- /** Public (secret-free) projection of an entry, safe for the browser/agent. */
65
- export interface RemoteHostSummary {
66
- alias: string
67
- host: string
68
- port: number
69
- user: string
70
- auth: RemoteAuthKind
71
- /** Whether the key path exists on this machine (key auth only). */
72
- keyReady: boolean
73
- /** True when the entry was bootstrapped by this plugin (managed keypair). */
74
- managedKey: boolean
75
- description?: string
76
- tags: string[]
77
- deploy?: RemoteDeployState | undefined
78
- createdAt: number
79
- updatedAt: number
80
- }
81
-
82
- /** One remote workspace binding: a host plus a remote directory. */
83
- export interface RemoteWorkspaceBinding {
84
- /** Stable id ( cuid-ish ). */
85
- id: string
86
- /** Display name. */
87
- name: string
88
- /** Host alias this workspace lives on. */
89
- alias: string
90
- /** Absolute POSIX path on the remote host. */
91
- remotePath: string
92
- createdAt: number
93
- }
94
-
95
- /** P2 routing status (Phase 4 workspaces GET extension). */
96
- export interface RemoteRoutingStatus {
97
- /** Live kill-switch position. */
98
- mode: 'off' | 'shadow' | 'enforce'
99
- /** Binding id -> materialized local alias dir. */
100
- aliasPaths: Record<string, string>
101
- /** Removed alias dirs that fail closed (history kept). */
102
- tombstones: string[]
103
- }
104
-
105
- /** Plugin identity (workspaces GET extension for the Settings display). */
106
- export interface RemotePluginMeta {
107
- /** Version from the shipped package.json ('unknown' when unreadable). */
108
- version: string
109
- /**
110
- * Effective per-operation timeouts, in milliseconds. Served so the browser
111
- * can apply the same numbers the Host enforces; an older Host omits it and
112
- * the client keeps its own (identical) defaults.
113
- */
114
- timeouts?: RemoteTimeouts
115
- }
116
-
117
- /** One timeout per kind of remote round trip. */
118
- export interface RemoteTimeouts {
119
- /** One git command (status/log/branches/diff over the exec route). */
120
- gitMs: number
121
- /** One SFTP file read (editor, diff sides, document preview). */
122
- readMs: number
123
- }
124
-
125
- /** Remote OS probe outcome. */
126
- export interface RemoteProbe {
127
- alias: string
128
- ok: boolean
129
- /** Raw `uname -m` (x86_64 / aarch64 / ...). */
130
- arch: string
131
- /** Mapped helper platform (linux-x64 / linux-arm64 / macos-x64 / macos-arm64 / unknown). */
132
- platform: string
133
- /** `uname -s`. */
134
- os: string
135
- /** glibc version when detectable (linux). */
136
- libc?: string | undefined
137
- /** Remote node version when installed (`node --version`), else undefined. */
138
- node?: string | undefined
139
- /** Remote home directory. */
140
- home?: string | undefined
141
- durationMs: number
142
- error?: string | undefined
143
- }
144
-
145
- /** Helper provider kinds the deploy pipeline knows. */
146
- export type HelperKind = 'executable' | 'node-script'
147
-
148
- /** Availability of one helper provider. */
149
- export interface HelperAvailability {
150
- kind: HelperKind
151
- available: boolean
152
- reason: string
153
- /** Locally cached builds (executable only). */
154
- cached?: { version: string; platform: string }[]
155
- }
156
-
157
- /** Last deploy pipeline outcome stored per host. */
158
- export interface RemoteDeployState {
159
- status: 'ok' | 'skipped-same' | 'failed' | 'not-deployed'
160
- /** What was pushed (P0: probe-bundle marker; P1: helper kind+version). */
161
- artifact: string
162
- /** sha256 of the installed artifact manifest. */
163
- manifestHash?: string | undefined
164
- detail?: string | undefined
165
- /** Remote $HOME observed at push time (locates the install without re-probing). */
166
- home?: string | undefined
167
- /** Installed helper identity (P1+ artifacts). */
168
- helper?: { kind: HelperKind; version: string; sha256: string; platform?: string } | undefined
169
- at: number
170
- }
171
-
172
- /** Remote manifest installed at ~/.dsh-helpers/manifest.json. */
173
- export interface RemoteManifest {
174
- version: 1
175
- artifact: string
176
- manifestHash: string
177
- helper?: { kind: HelperKind; version: string; sha256: string; platform?: string } | undefined
178
- installedAt: number
179
- }
180
-
181
- /** One remote directory row (SFTP). */
182
- export interface RemoteFileEntry {
183
- name: string
184
- /** Absolute POSIX path. */
185
- path: string
186
- isDir: boolean
187
- size: number
188
- /** mtime in ms. */
189
- mtime: number
190
- /** POSIX mode bits. */
191
- mode: number
192
- isSymlink: boolean
193
- }
194
-
195
- /** Result of one remote file read (SFTP window). */
196
- export interface RemoteRead {
197
- /** File size in bytes. */
198
- size: number
199
- /** True when the content is not UTF-8 text (base64 holds the bytes). */
200
- binary: boolean
201
- text?: string | undefined
202
- base64?: string | undefined
203
- /** True when size exceeded READ_CAP (content holds the first window). */
204
- truncated: boolean
205
- }
206
-
207
- /** Result of one non-interactive command execution. */
208
- export interface RemoteExecResult {
209
- success: boolean
210
- /** Remote exit code, or null when the channel died without one. */
211
- exitCode: number | null
212
- timedOut: boolean
213
- stdout: string
214
- stderr: string
215
- /** Wall-clock duration of the round trip in ms. */
216
- durationMs: number
217
- /** Connection error message when the command never ran. */
218
- error?: string | undefined
219
- }
220
-
221
- /**
222
- * One server-sent event of the streaming exec route.
223
- *
224
- * Used by the long network verbs (fetch / pull / push / sync) so the live git
225
- * output can be shown while the command is still running; the unary exec route
226
- * keeps serving everything that only needs the result.
227
- */
228
- export type ExecStreamEvent =
229
- | { t: 'out'; d: string }
230
- | { t: 'err'; d: string }
231
- | { t: 'exit'; success: boolean; exitCode: number | null; timedOut: boolean; durationMs: number; error?: string }
232
-
233
- /** Client -> server terminal frames (JSON text). */
234
- export type TerminalClientFrame =
235
- | { t: 'in'; d: string }
236
- | { t: 'resize'; cols: number; rows: number }
237
-
238
- /** Server -> client terminal frames (JSON text). */
239
- export type TerminalServerFrame =
240
- | { t: 'ready'; id: string }
241
- | { t: 'out'; d: string }
242
- | { t: 'exit'; code: number | null }
243
- | { t: 'error'; message: string }
244
-
245
- /** Import outcome (ssh_config / dsh-ssh.json). */
246
- export interface ImportReport {
247
- imported: string[]
248
- skipped: { alias: string; reason: string }[]
249
- }
250
-
251
- /** One parsed commit for the git graph. */
252
- export interface GitCommit {
253
- hash: string
254
- parents: string[]
255
- author: string
256
- email: string
257
- /** Author date, unix seconds. */
258
- date: number
259
- /** Raw ref list, e.g. ["HEAD -> main", "origin/main", "tag: v1.2"]. */
260
- refs: string[]
261
- subject: string
262
- }
263
-
264
- /** One changed file in git status. */
265
- export interface GitStatusFile {
266
- path: string
267
- /** Staged (index) status char. */
268
- staged: string
269
- /** Unstaged (worktree) status char. */
270
- unstaged: string
271
- }
272
-
273
- /** Parsed git status. */
274
- export interface GitStatus {
275
- branch: string
276
- detached: boolean
277
- ahead: number
278
- behind: number
279
- staged: GitStatusFile[]
280
- unstaged: GitStatusFile[]
281
- untracked: string[]
282
- truncated: boolean
283
- }
284
-
285
- /** One local branch. */
286
- export interface GitBranch {
287
- name: string
288
- short: string
289
- upstream: string
290
- /** True when this is the current HEAD. */
291
- head: boolean
292
- /** True for a remote-tracking branch (`refs/remotes/...`). */
293
- remote?: boolean
294
- }
295
-
296
- /** One path row of the detailed (NUL-separated) porcelain status. */
297
- export interface GitPathStatus {
298
- /** Repo-relative path (the destination for renames). */
299
- path: string
300
- /** Staged (index) status column. */
301
- x: string
302
- /** Unstaged (worktree) status column. */
303
- y: string
304
- /** Rename/copy source. */
305
- origPath?: string
306
- }
307
-
308
- /** Detailed status: every entry plus the ignored half (drives tree greying). */
309
- export interface GitStatusDetail {
310
- entries: GitPathStatus[]
311
- /** Ignored paths, as `git status --ignored=matching` reports them. */
312
- ignored: string[]
313
- /** True when the byte cap cut the listing short. */
314
- truncated: boolean
315
- }
316
-
317
- /** One configured remote URL. */
318
- export interface GitRemote {
319
- name: string
320
- url: string
321
- kind: 'fetch' | 'push'
322
- }
323
-
324
- /** One stash entry. */
325
- export interface GitStash {
326
- /** `stash@{0}`. */
327
- ref: string
328
- message: string
329
- /** Unix seconds. */
330
- date: number
331
- }
332
-
333
- /** One file row of a commit (`--name-status`). */
334
- export interface GitCommitFile {
335
- /** Single letter (`R`/`C` for renames/copies); the similarity score is dropped. */
336
- status: string
337
- path: string
338
- origPath?: string
339
- }
340
-
341
- /** One hunk of a unified diff, with a ready-to-apply patch body. */
342
- export interface UnifiedHunk {
343
- oldStart: number
344
- oldCount: number
345
- newStart: number
346
- newCount: number
347
- /** Text after the `@@` marker. */
348
- heading: string
349
- /** Raw hunk lines (leading ' ', '-', '+', '\'). */
350
- lines: string[]
351
- /** File header + hunk header + lines: exactly what `git apply` needs. */
352
- patch: string
353
- }
354
-
355
- /** One file block of a unified diff. */
356
- export interface UnifiedDiffFile {
357
- /** Destination path (source path for deletions). */
358
- path: string
359
- oldPath: string
360
- status: 'M' | 'A' | 'D' | 'R' | 'C' | 'U'
361
- binary: boolean
362
- hunks: UnifiedHunk[]
363
- }
364
-
365
- /** One file the session changed, as the review panel lists it. */
366
- export interface RemoteChangedFile {
367
- /** Remote absolute POSIX path — the editor opens exactly this. */
368
- path: string
369
- /** Path relative to the session root (what the row shows), '' for an external file. */
370
- display: string
371
- added: number
372
- deleted: number
373
- /** Git reported the pair as binary (`-` in --numstat). */
374
- binary?: true
375
- /**
376
- * Too large to compare line by line, so the counts are unknown (0/0).
377
- *
378
- * The row still earns its place: time and size proved it moved since the
379
- * session baseline. Clicking it opens the file, but no hunks can be painted.
380
- */
381
- oversized?: true
382
- /** Change kind from --name-status; undefined when git gave none. */
383
- status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
384
- }
385
-
386
- /**
387
- * What one session changed on its remote host since the session's baseline.
388
- *
389
- * The baseline is the content of every file git already reported as dirty when
390
- * the ledger first looked, so the list answers "what did this session touch"
391
- * rather than "what is uncommitted" — the difference matters when the working
392
- * tree already carried user edits before the session started.
393
- */
394
- export interface RemoteChangesSummary {
395
- /** Remote host alias the session is routed to. */
396
- alias: string
397
- /** Remote absolute root the `display` paths are relative to. */
398
- root: string
399
- /** Highest turn recorded (0 while only the baseline exists). */
400
- turn: number
401
- files: RemoteChangedFile[]
402
- added: number
403
- deleted: number
404
- /** Wall-clock ms when this summary was last recomputed. */
405
- at: number
406
- /** More files than the cap: `files` is truncated but the totals are whole. */
407
- truncated?: true
408
- /** A scan is running right now (the slow one counts); the list will refresh. */
409
- pending: boolean
410
- /** Why this session has no ledger (local session, no git, timeout, …). */
411
- unavailable?: string
412
- }
413
-
414
- /** One file's whole-session comparison, ready for editor decorations. */
415
- export interface RemoteChangesDiff {
416
- kind: 'text' | 'binary' | 'missing'
417
- /** Remote absolute POSIX path. */
418
- path: string
419
- display: string
420
- /** Text hunks (empty for binary/missing). */
421
- hunks: UnifiedHunk[]
422
- /** File status at turn end (A/M/D/…), when git reported one. */
423
- status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
424
- /** The diff was cut at the byte cap: `hunks` is a prefix. */
425
- truncated?: true
426
- }
427
-
428
- /** One row of the side-by-side diff projection. */
429
- export interface DiffRow {
430
- id: number
431
- /** Left (before) text; '' when the row has no left counterpart. */
432
- old: string
433
- /** Right (after) text; '' when the row has no right counterpart. */
434
- new: string
435
- oldNum: number | null
436
- newNum: number | null
437
- /** False when the row does not exist on the right side at all. */
438
- inNew: boolean
439
- oldDel: boolean
440
- newAdd: boolean
441
- /** Index into the model's hunk list, or -1 outside every hunk. */
442
- hunk: number
443
- }
444
-
445
- /** One hunk as the view needs it (numbers + the patch to stage/revert). */
446
- export interface DiffHunkView {
447
- index: number
448
- oldStart: number
449
- newStart: number
450
- oldCount: number
451
- newCount: number
452
- heading: string
453
- /** Row index of the hunk's first changed line. */
454
- startRow: number
455
- patch: string
456
- }
457
-
458
- /** The full side-by-side model for one file. */
459
- export interface DiffModel {
460
- rows: DiffRow[]
461
- hunks: DiffHunkView[]
462
- /** True when git reported a binary diff (no rows). */
463
- binary: boolean
464
- /** True when the two sides are byte-identical. */
465
- empty: boolean
466
- }
467
-
468
- /** Commit detail. */
469
- export interface GitShow {
470
- hash: string
471
- subject: string
472
- body: string
473
- stat: string
474
- }
1
+ /**
2
+ * Wire contract between the host half (routes.ts) and the browser half
3
+ * (client/api.ts). Pure types + path constants only — imported by both
4
+ * halves, bundled into each, no runtime identity to share.
5
+ */
6
+
7
+ /** API route table (all loopback-only). */
8
+ export const REMOTE_API = {
9
+ hosts: '/api/dsh-remote/hosts',
10
+ test: '/api/dsh-remote/test',
11
+ keygen: '/api/dsh-remote/keygen',
12
+ exec: '/api/dsh-remote/exec',
13
+ /** Streaming exec (server-sent events) for the long network verbs. */
14
+ execStream: '/api/dsh-remote/exec-stream',
15
+ files: '/api/dsh-remote/files',
16
+ /** Streaming binary upload: raw request body, host and path in the query. */
17
+ upload: '/api/dsh-remote/upload',
18
+ /** Streaming binary download: raw response body, host and path in the query. */
19
+ download: '/api/dsh-remote/download',
20
+ /** Streaming directory download: a remote `tar -czf -` of the directory. */
21
+ downloadDir: '/api/dsh-remote/download-dir',
22
+ /** Streaming multi-selection download: one remote tar of repeated `path` params. */
23
+ downloadMany: '/api/dsh-remote/download-many',
24
+ workspaces: '/api/dsh-remote/workspaces',
25
+ deploy: '/api/dsh-remote/deploy',
26
+ importSshConfig: '/api/dsh-remote/import-ssh-config',
27
+ importDshSsh: '/api/dsh-remote/import-dsh-ssh',
28
+ terminal: '/api/dsh-remote/terminal',
29
+ terminalClose: '/api/dsh-remote/terminal-close',
30
+ routing: '/api/dsh-remote/routing',
31
+ /** Current working directory of one live session (click resolution helper). */
32
+ sessionCwd: '/api/dsh-remote/session-cwd',
33
+ /** What one live session changed on its remote host (the review panel). */
34
+ changes: '/api/dsh-remote/changes',
35
+ } as const
36
+
37
+ /**
38
+ * Most entries one multi-selection download may archive. The selection rides in
39
+ * the request URL (one `path` param per entry), so this bounds both the archive
40
+ * and the request line; a larger selection should download its folder instead.
41
+ */
42
+ export const MAX_SELECTION_DOWNLOAD = 100
43
+
44
+ /** Suggested/attachment file name for one multi-selection archive. */
45
+ export function selectionDownloadName(count: number): string {
46
+ return `selection-${count}.tar.gz`
47
+ }
48
+
49
+ /** Authentication flavors a host entry may carry (P0: direct only, no jump/agent). */
50
+ export type RemoteAuthKind = 'key' | 'password'
51
+
52
+ /** One stored host entry (the $DSH_HOME/dsh-remote.json store shape). */
53
+ export interface RemoteHostEntry {
54
+ /** Stable, user-chosen identifier used by every operation. */
55
+ alias: string
56
+ /** Hostname or IP of the target. */
57
+ host: string
58
+ /** SSH port (default 22). */
59
+ port: number
60
+ /** Login user. */
61
+ user: string
62
+ /** Authentication. */
63
+ auth: {
64
+ kind: RemoteAuthKind
65
+ /** Absolute path to the private key for 'key' auth. */
66
+ keyPath?: string
67
+ /** Passphrase for an encrypted key. */
68
+ passphrase?: string
69
+ /** Password for 'password' auth. */
70
+ password?: string
71
+ }
72
+ /** Free-form note. */
73
+ description?: string
74
+ /** Free-form tags. */
75
+ tags: string[]
76
+ /** Last deploy pipeline outcome for this host. */
77
+ deploy?: RemoteDeployState | undefined
78
+ createdAt: number
79
+ updatedAt: number
80
+ }
81
+
82
+ /** Public (secret-free) projection of an entry, safe for the browser/agent. */
83
+ export interface RemoteHostSummary {
84
+ alias: string
85
+ host: string
86
+ port: number
87
+ user: string
88
+ auth: RemoteAuthKind
89
+ /** Whether the key path exists on this machine (key auth only). */
90
+ keyReady: boolean
91
+ /** True when the entry was bootstrapped by this plugin (managed keypair). */
92
+ managedKey: boolean
93
+ description?: string
94
+ tags: string[]
95
+ deploy?: RemoteDeployState | undefined
96
+ createdAt: number
97
+ updatedAt: number
98
+ }
99
+
100
+ /** One remote workspace binding: a host plus a remote directory. */
101
+ export interface RemoteWorkspaceBinding {
102
+ /** Stable id ( cuid-ish ). */
103
+ id: string
104
+ /** Display name. */
105
+ name: string
106
+ /** Host alias this workspace lives on. */
107
+ alias: string
108
+ /** Absolute POSIX path on the remote host. */
109
+ remotePath: string
110
+ createdAt: number
111
+ }
112
+
113
+ /** P2 routing status (Phase 4 workspaces GET extension). */
114
+ export interface RemoteRoutingStatus {
115
+ /** Live kill-switch position. */
116
+ mode: 'off' | 'shadow' | 'enforce'
117
+ /** Binding id -> materialized local alias dir. */
118
+ aliasPaths: Record<string, string>
119
+ /** Removed alias dirs that fail closed (history kept). */
120
+ tombstones: string[]
121
+ }
122
+
123
+ /** Plugin identity (workspaces GET extension for the Settings display). */
124
+ export interface RemotePluginMeta {
125
+ /** Version from the shipped package.json ('unknown' when unreadable). */
126
+ version: string
127
+ /**
128
+ * Effective per-operation timeouts, in milliseconds. Served so the browser
129
+ * can apply the same numbers the Host enforces; an older Host omits it and
130
+ * the client keeps its own (identical) defaults.
131
+ */
132
+ timeouts?: RemoteTimeouts
133
+ }
134
+
135
+ /** One timeout per kind of remote round trip. */
136
+ export interface RemoteTimeouts {
137
+ /** One git command (status/log/branches/diff over the exec route). */
138
+ gitMs: number
139
+ /** One SFTP file read (editor, diff sides, document preview). */
140
+ readMs: number
141
+ }
142
+
143
+ /** Remote OS probe outcome. */
144
+ export interface RemoteProbe {
145
+ alias: string
146
+ ok: boolean
147
+ /** Raw `uname -m` (x86_64 / aarch64 / ...). */
148
+ arch: string
149
+ /** Mapped helper platform (linux-x64 / linux-arm64 / macos-x64 / macos-arm64 / unknown). */
150
+ platform: string
151
+ /** `uname -s`. */
152
+ os: string
153
+ /** glibc version when detectable (linux). */
154
+ libc?: string | undefined
155
+ /** Remote node version when installed (`node --version`), else undefined. */
156
+ node?: string | undefined
157
+ /** Remote home directory. */
158
+ home?: string | undefined
159
+ durationMs: number
160
+ error?: string | undefined
161
+ }
162
+
163
+ /** Helper provider kinds the deploy pipeline knows. */
164
+ export type HelperKind = 'executable' | 'node-script'
165
+
166
+ /** Availability of one helper provider. */
167
+ export interface HelperAvailability {
168
+ kind: HelperKind
169
+ available: boolean
170
+ reason: string
171
+ /** Locally cached builds (executable only). */
172
+ cached?: { version: string; platform: string }[]
173
+ }
174
+
175
+ /** Last deploy pipeline outcome stored per host. */
176
+ export interface RemoteDeployState {
177
+ status: 'ok' | 'skipped-same' | 'failed' | 'not-deployed'
178
+ /** What was pushed (P0: probe-bundle marker; P1: helper kind+version). */
179
+ artifact: string
180
+ /** sha256 of the installed artifact manifest. */
181
+ manifestHash?: string | undefined
182
+ detail?: string | undefined
183
+ /** Remote $HOME observed at push time (locates the install without re-probing). */
184
+ home?: string | undefined
185
+ /** Installed helper identity (P1+ artifacts). */
186
+ helper?: { kind: HelperKind; version: string; sha256: string; platform?: string } | undefined
187
+ at: number
188
+ }
189
+
190
+ /** Remote manifest installed at ~/.dsh-helpers/manifest.json. */
191
+ export interface RemoteManifest {
192
+ version: 1
193
+ artifact: string
194
+ manifestHash: string
195
+ helper?: { kind: HelperKind; version: string; sha256: string; platform?: string } | undefined
196
+ installedAt: number
197
+ }
198
+
199
+ /** One remote directory row (SFTP). */
200
+ export interface RemoteFileEntry {
201
+ name: string
202
+ /** Absolute POSIX path. */
203
+ path: string
204
+ isDir: boolean
205
+ size: number
206
+ /** mtime in ms. */
207
+ mtime: number
208
+ /** POSIX mode bits. */
209
+ mode: number
210
+ isSymlink: boolean
211
+ }
212
+
213
+ /** Result of one remote file read (SFTP window). */
214
+ export interface RemoteRead {
215
+ /** File size in bytes. */
216
+ size: number
217
+ /** True when the content is not UTF-8 text (base64 holds the bytes). */
218
+ binary: boolean
219
+ text?: string | undefined
220
+ base64?: string | undefined
221
+ /** True when size exceeded READ_CAP (content holds the first window). */
222
+ truncated: boolean
223
+ }
224
+
225
+ /** Result of one non-interactive command execution. */
226
+ export interface RemoteExecResult {
227
+ success: boolean
228
+ /** Remote exit code, or null when the channel died without one. */
229
+ exitCode: number | null
230
+ timedOut: boolean
231
+ stdout: string
232
+ stderr: string
233
+ /** Wall-clock duration of the round trip in ms. */
234
+ durationMs: number
235
+ /** Connection error message when the command never ran. */
236
+ error?: string | undefined
237
+ }
238
+
239
+ /**
240
+ * One server-sent event of the streaming exec route.
241
+ *
242
+ * Used by the long network verbs (fetch / pull / push / sync) so the live git
243
+ * output can be shown while the command is still running; the unary exec route
244
+ * keeps serving everything that only needs the result.
245
+ */
246
+ export type ExecStreamEvent =
247
+ | { t: 'out'; d: string }
248
+ | { t: 'err'; d: string }
249
+ | { t: 'exit'; success: boolean; exitCode: number | null; timedOut: boolean; durationMs: number; error?: string }
250
+
251
+ /** Client -> server terminal frames (JSON text). */
252
+ export type TerminalClientFrame =
253
+ | { t: 'in'; d: string }
254
+ | { t: 'resize'; cols: number; rows: number }
255
+
256
+ /** Server -> client terminal frames (JSON text). */
257
+ export type TerminalServerFrame =
258
+ | { t: 'ready'; id: string }
259
+ | { t: 'out'; d: string }
260
+ | { t: 'exit'; code: number | null }
261
+ | { t: 'error'; message: string }
262
+
263
+ /** Import outcome (ssh_config / dsh-ssh.json). */
264
+ export interface ImportReport {
265
+ imported: string[]
266
+ skipped: { alias: string; reason: string }[]
267
+ }
268
+
269
+ /** One parsed commit for the git graph. */
270
+ export interface GitCommit {
271
+ hash: string
272
+ parents: string[]
273
+ author: string
274
+ email: string
275
+ /** Author date, unix seconds. */
276
+ date: number
277
+ /** Raw ref list, e.g. ["HEAD -> main", "origin/main", "tag: v1.2"]. */
278
+ refs: string[]
279
+ subject: string
280
+ }
281
+
282
+ /** One changed file in git status. */
283
+ export interface GitStatusFile {
284
+ path: string
285
+ /** Staged (index) status char. */
286
+ staged: string
287
+ /** Unstaged (worktree) status char. */
288
+ unstaged: string
289
+ }
290
+
291
+ /** Parsed git status. */
292
+ export interface GitStatus {
293
+ branch: string
294
+ detached: boolean
295
+ ahead: number
296
+ behind: number
297
+ staged: GitStatusFile[]
298
+ unstaged: GitStatusFile[]
299
+ untracked: string[]
300
+ truncated: boolean
301
+ }
302
+
303
+ /** One local branch. */
304
+ export interface GitBranch {
305
+ name: string
306
+ short: string
307
+ upstream: string
308
+ /** True when this is the current HEAD. */
309
+ head: boolean
310
+ /** True for a remote-tracking branch (`refs/remotes/...`). */
311
+ remote?: boolean
312
+ }
313
+
314
+ /** One path row of the detailed (NUL-separated) porcelain status. */
315
+ export interface GitPathStatus {
316
+ /** Repo-relative path (the destination for renames). */
317
+ path: string
318
+ /** Staged (index) status column. */
319
+ x: string
320
+ /** Unstaged (worktree) status column. */
321
+ y: string
322
+ /** Rename/copy source. */
323
+ origPath?: string
324
+ }
325
+
326
+ /** Detailed status: every entry plus the ignored half (drives tree greying). */
327
+ export interface GitStatusDetail {
328
+ entries: GitPathStatus[]
329
+ /** Ignored paths, as `git status --ignored=matching` reports them. */
330
+ ignored: string[]
331
+ /** True when the byte cap cut the listing short. */
332
+ truncated: boolean
333
+ }
334
+
335
+ /** One configured remote URL. */
336
+ export interface GitRemote {
337
+ name: string
338
+ url: string
339
+ kind: 'fetch' | 'push'
340
+ }
341
+
342
+ /** One stash entry. */
343
+ export interface GitStash {
344
+ /** `stash@{0}`. */
345
+ ref: string
346
+ message: string
347
+ /** Unix seconds. */
348
+ date: number
349
+ }
350
+
351
+ /** One file row of a commit (`--name-status`). */
352
+ export interface GitCommitFile {
353
+ /** Single letter (`R`/`C` for renames/copies); the similarity score is dropped. */
354
+ status: string
355
+ path: string
356
+ origPath?: string
357
+ }
358
+
359
+ /** One hunk of a unified diff, with a ready-to-apply patch body. */
360
+ export interface UnifiedHunk {
361
+ oldStart: number
362
+ oldCount: number
363
+ newStart: number
364
+ newCount: number
365
+ /** Text after the `@@` marker. */
366
+ heading: string
367
+ /** Raw hunk lines (leading ' ', '-', '+', '\'). */
368
+ lines: string[]
369
+ /** File header + hunk header + lines: exactly what `git apply` needs. */
370
+ patch: string
371
+ }
372
+
373
+ /** One file block of a unified diff. */
374
+ export interface UnifiedDiffFile {
375
+ /** Destination path (source path for deletions). */
376
+ path: string
377
+ oldPath: string
378
+ status: 'M' | 'A' | 'D' | 'R' | 'C' | 'U'
379
+ binary: boolean
380
+ hunks: UnifiedHunk[]
381
+ }
382
+
383
+ /** One file the session changed, as the review panel lists it. */
384
+ export interface RemoteChangedFile {
385
+ /** Remote absolute POSIX path — the editor opens exactly this. */
386
+ path: string
387
+ /** Path relative to the session root (what the row shows), '' for an external file. */
388
+ display: string
389
+ added: number
390
+ deleted: number
391
+ /** Git reported the pair as binary (`-` in --numstat). */
392
+ binary?: true
393
+ /**
394
+ * Too large to compare line by line, so the counts are unknown (0/0).
395
+ *
396
+ * The row still earns its place: time and size proved it moved since the
397
+ * session baseline. Clicking it opens the file, but no hunks can be painted.
398
+ */
399
+ oversized?: true
400
+ /** Change kind from --name-status; undefined when git gave none. */
401
+ status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
402
+ }
403
+
404
+ /**
405
+ * What one session changed on its remote host since the session's baseline.
406
+ *
407
+ * The baseline is the content of every file git already reported as dirty when
408
+ * the ledger first looked, so the list answers "what did this session touch"
409
+ * rather than "what is uncommitted" — the difference matters when the working
410
+ * tree already carried user edits before the session started.
411
+ */
412
+ export interface RemoteChangesSummary {
413
+ /** Remote host alias the session is routed to. */
414
+ alias: string
415
+ /** Remote absolute root the `display` paths are relative to. */
416
+ root: string
417
+ /** Highest turn recorded (0 while only the baseline exists). */
418
+ turn: number
419
+ files: RemoteChangedFile[]
420
+ added: number
421
+ deleted: number
422
+ /** Wall-clock ms when this summary was last recomputed. */
423
+ at: number
424
+ /** More files than the cap: `files` is truncated but the totals are whole. */
425
+ truncated?: true
426
+ /** A scan is running right now (the slow one counts); the list will refresh. */
427
+ pending: boolean
428
+ /** Why this session has no ledger (local session, no git, timeout, …). */
429
+ unavailable?: string
430
+ }
431
+
432
+ /** One file's whole-session comparison, ready for editor decorations. */
433
+ export interface RemoteChangesDiff {
434
+ kind: 'text' | 'binary' | 'missing'
435
+ /** Remote absolute POSIX path. */
436
+ path: string
437
+ display: string
438
+ /** Text hunks (empty for binary/missing). */
439
+ hunks: UnifiedHunk[]
440
+ /** File status at turn end (A/M/D/…), when git reported one. */
441
+ status?: 'A' | 'M' | 'D' | 'R' | 'C' | 'T' | 'U'
442
+ /** The diff was cut at the byte cap: `hunks` is a prefix. */
443
+ truncated?: true
444
+ }
445
+
446
+ /** One row of the side-by-side diff projection. */
447
+ export interface DiffRow {
448
+ id: number
449
+ /** Left (before) text; '' when the row has no left counterpart. */
450
+ old: string
451
+ /** Right (after) text; '' when the row has no right counterpart. */
452
+ new: string
453
+ oldNum: number | null
454
+ newNum: number | null
455
+ /** False when the row does not exist on the right side at all. */
456
+ inNew: boolean
457
+ oldDel: boolean
458
+ newAdd: boolean
459
+ /** Index into the model's hunk list, or -1 outside every hunk. */
460
+ hunk: number
461
+ }
462
+
463
+ /** One hunk as the view needs it (numbers + the patch to stage/revert). */
464
+ export interface DiffHunkView {
465
+ index: number
466
+ oldStart: number
467
+ newStart: number
468
+ oldCount: number
469
+ newCount: number
470
+ heading: string
471
+ /** Row index of the hunk's first changed line. */
472
+ startRow: number
473
+ patch: string
474
+ }
475
+
476
+ /** The full side-by-side model for one file. */
477
+ export interface DiffModel {
478
+ rows: DiffRow[]
479
+ hunks: DiffHunkView[]
480
+ /** True when git reported a binary diff (no rows). */
481
+ binary: boolean
482
+ /** True when the two sides are byte-identical. */
483
+ empty: boolean
484
+ }
485
+
486
+ /** Commit detail. */
487
+ export interface GitShow {
488
+ hash: string
489
+ subject: string
490
+ body: string
491
+ stat: string
492
+ }