@hearsay-tools/squawk 0.19.0-pr4579.9094 → 0.19.0-pr4580.9099

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 (37) hide show
  1. package/dist/contract/hosts.d.ts +5 -47
  2. package/dist/contract/index.js +1 -19
  3. package/dist/features/hosts/cli.d.ts +3 -13
  4. package/dist/features/hosts/cli.js +27 -199
  5. package/dist/features/hosts/cli.js.map +1 -1
  6. package/dist/features/hosts/host-server-cli.js +3 -21
  7. package/dist/features/hosts/host-server-cli.js.map +1 -1
  8. package/dist/features/hosts/host-server.d.ts +1 -10
  9. package/dist/features/hosts/host-server.js +0 -74
  10. package/dist/features/hosts/host-server.js.map +1 -1
  11. package/dist/features/hosts/index.d.ts +2 -4
  12. package/dist/features/hosts/index.js +2 -14
  13. package/dist/features/hosts/index.js.map +1 -1
  14. package/dist/features/hosts/registry.d.ts +0 -19
  15. package/dist/features/hosts/registry.js +1 -33
  16. package/dist/features/hosts/registry.js.map +1 -1
  17. package/dist/features/hosts/routes.d.ts +3 -5
  18. package/dist/features/hosts/routes.js +7 -14
  19. package/dist/features/hosts/routes.js.map +1 -1
  20. package/dist/features/webhooks/routes.d.ts +13 -13
  21. package/dist/server/server.d.ts +58 -58
  22. package/package.json +4 -4
  23. package/dist/features/hosts/bootstrap.d.ts +0 -120
  24. package/dist/features/hosts/bootstrap.js +0 -446
  25. package/dist/features/hosts/bootstrap.js.map +0 -1
  26. package/dist/features/hosts/host-actions.d.ts +0 -56
  27. package/dist/features/hosts/host-actions.js +0 -367
  28. package/dist/features/hosts/host-actions.js.map +0 -1
  29. package/dist/features/hosts/ssh.d.ts +0 -85
  30. package/dist/features/hosts/ssh.js +0 -271
  31. package/dist/features/hosts/ssh.js.map +0 -1
  32. package/dist/features/hosts/supervisor.d.ts +0 -191
  33. package/dist/features/hosts/supervisor.js +0 -620
  34. package/dist/features/hosts/supervisor.js.map +0 -1
  35. package/dist/features/hosts/tunnel.d.ts +0 -46
  36. package/dist/features/hosts/tunnel.js +0 -244
  37. package/dist/features/hosts/tunnel.js.map +0 -1
@@ -1,367 +0,0 @@
1
- /**
2
- * Main-side remote host lifecycle actions (`stop`, `start`, `update`) over SSH
3
- * (spec § 6, hearsay-tools/squawk#4539).
4
- *
5
- * Every action verifies the remote `installId` against the saved entry FIRST before installing
6
- * anything, changing a pause record, or signalling any remote process.
7
- */
8
- import { hostServerActiveTasksResultSchema, hostServerResumeResultSchema, hostServerStopResultSchema, } from '../../contract/index.js';
9
- import { productIdentity } from '../../home/identity.js';
10
- import { bootstrapHost, buildHostServerCliCommand, checkRemoteHostStatus, formatIdentityChangedReason, installRemoteRuntime, parseJsonStdout, probeRemoteHost, readMainInstallId, resolveMeta, } from './bootstrap.js';
11
- import { getHostById } from './registry.js';
12
- import { SSH_CONTROL_TIMEOUT_MS, SSH_STATUS_TIMEOUT_MS, runSshCommand } from './ssh.js';
13
- import { openSshTunnel } from './tunnel.js';
14
- /**
15
- * Shared pre-flight for `stop`, `start`, and `update`:
16
- * 1. Re-read entry fresh.
17
- * 2. Probe over SSH (if unreachable, change nothing).
18
- * 3. Compare remote install id BEFORE installing anything or running any control command.
19
- * 4. Ensure runtime is installed, then read `host-server status` and re-verify install id.
20
- */
21
- async function verifyRemoteIdentityForControl(home, hostId, deps, signal) {
22
- const loaded = getHostById(home, hostId);
23
- if (!loaded.host) {
24
- return { ok: false, code: 'not_found', reason: loaded.warning ?? `Host "${hostId}" was not found.` };
25
- }
26
- const entry = loaded.host;
27
- const mainInstallId = readMainInstallId(home);
28
- const probed = await probeRemoteHost(entry.sshAlias, deps, signal);
29
- if (!probed.ok) {
30
- return { ok: false, code: probed.state, state: probed.state, reason: probed.reason };
31
- }
32
- let probe = probed.probe;
33
- // When `entry.installId` is unset (host has never connected yet), there is no recorded id to
34
- // compare against: `stop` may write this home's pause record, and `host-server stop` signals
35
- // ONLY a live claim whose `starterInstallId` matches this home.
36
- if (entry.installId !== undefined && probe.installId !== entry.installId) {
37
- return {
38
- ok: false,
39
- code: 'identity-changed',
40
- state: 'identity-changed',
41
- reason: formatIdentityChangedReason(entry, entry.installId, probe.installId),
42
- };
43
- }
44
- if (!probe.runtimeInstalled) {
45
- const installed = await installRemoteRuntime(entry.sshAlias, probe, deps, signal);
46
- if (!installed.ok) {
47
- return { ok: false, code: 'unreachable', state: 'unreachable', reason: installed.reason };
48
- }
49
- probe = { ...probe, runtimeInstalled: true };
50
- }
51
- const statusRes = await checkRemoteHostStatus(entry.sshAlias, probe, mainInstallId, entry.port, deps, signal);
52
- if (!statusRes.ok) {
53
- return { ok: false, code: 'unreachable', state: 'unreachable', reason: statusRes.reason };
54
- }
55
- if (entry.installId !== undefined && statusRes.status.installId !== entry.installId) {
56
- return {
57
- ok: false,
58
- code: 'identity-changed',
59
- state: 'identity-changed',
60
- reason: formatIdentityChangedReason(entry, entry.installId, statusRes.status.installId),
61
- };
62
- }
63
- return { ok: true, entry, mainInstallId, probe, status: statusRes.status };
64
- }
65
- /**
66
- * `hsq host stop <id>`: verify install id first, write the remote pause record and signal ONLY a
67
- * managed server owned by this home, leaving unmanaged servers and unreachable machines untouched.
68
- */
69
- export async function stopRemoteHost(home, hostId, deps = {}, signal) {
70
- const checked = await verifyRemoteIdentityForControl(home, hostId, deps, signal);
71
- if (!checked.ok) {
72
- return { ok: false, code: checked.code, state: checked.state, reason: checked.reason, stopped: false };
73
- }
74
- const cmd = buildHostServerCliCommand(checked.probe.nodePath, checked.probe.runtimeEntry, [
75
- 'stop', '--starter-id', checked.mainInstallId, '--json',
76
- ]);
77
- const res = await runSshCommand(checked.entry.sshAlias, cmd, {
78
- timeoutMs: deps.controlTimeoutMs ?? SSH_CONTROL_TIMEOUT_MS,
79
- signal,
80
- deps,
81
- });
82
- const parsed = parseJsonStdout(res.stdout, hostServerStopResultSchema, 'host-server stop');
83
- if (!parsed.ok) {
84
- return {
85
- ok: false,
86
- code: 'unreachable',
87
- state: 'unreachable',
88
- reason: res.reason ?? parsed.reason,
89
- stopped: false,
90
- };
91
- }
92
- const stopData = parsed.data;
93
- if (stopData.reason === 'signal-failed' || stopData.reason === 'unverifiable-process') {
94
- return {
95
- ok: false,
96
- code: stopData.reason,
97
- state: 'paused',
98
- reason: `Host "${hostId}" is paused, but stopping its managed process failed (${stopData.reason}).`,
99
- stopped: false,
100
- remoteResult: stopData,
101
- };
102
- }
103
- const detail = stopData.stopped
104
- ? `Stopped managed server on ${checked.entry.sshAlias} and paused host "${hostId}".`
105
- : `Paused host "${hostId}" (${stopData.reason ?? 'no managed server running'}).`;
106
- return {
107
- ok: true,
108
- code: stopData.stopped ? 'stopped' : 'paused',
109
- state: 'paused',
110
- reason: detail,
111
- stopped: stopData.stopped,
112
- remoteResult: stopData,
113
- };
114
- }
115
- /**
116
- * Explicit start (`hsq host start <id>`, spec § 6 + hearsay-tools/squawk#4539 open point 6b):
117
- * compare remote install id FIRST (mismatch -> `identity-changed`, pause record untouched), then
118
- * run `hsq host-server resume` and connect.
119
- */
120
- export async function startRemoteHost(home, hostId, deps = {}, signal) {
121
- const checked = await verifyRemoteIdentityForControl(home, hostId, deps, signal);
122
- if (!checked.ok) {
123
- return {
124
- ok: false,
125
- code: checked.code,
126
- state: checked.state ?? 'unreachable',
127
- reason: checked.reason,
128
- };
129
- }
130
- const resumeCmd = buildHostServerCliCommand(checked.probe.nodePath, checked.probe.runtimeEntry, [
131
- 'resume', '--starter-id', checked.mainInstallId, '--json',
132
- ]);
133
- const res = await runSshCommand(checked.entry.sshAlias, resumeCmd, {
134
- timeoutMs: deps.controlTimeoutMs ?? SSH_CONTROL_TIMEOUT_MS,
135
- signal,
136
- deps,
137
- });
138
- if (!res.ok) {
139
- return { ok: false, code: 'unreachable', state: 'unreachable', reason: res.reason ?? 'Remote host-server resume failed' };
140
- }
141
- const parsed = parseJsonStdout(res.stdout, hostServerResumeResultSchema, 'host-server resume');
142
- if (!parsed.ok) {
143
- return { ok: false, code: 'unreachable', state: 'unreachable', reason: parsed.reason };
144
- }
145
- const bootstrap = await bootstrapHost(home, hostId, deps, { signal, preProbed: checked.probe });
146
- return {
147
- ok: bootstrap.state === 'connected',
148
- code: bootstrap.state,
149
- state: bootstrap.state,
150
- reason: bootstrap.reason,
151
- wasPaused: parsed.data.wasPaused,
152
- bootstrap,
153
- };
154
- }
155
- async function queryRemoteActiveTasks(sshAlias, probe, port, deps, signal) {
156
- const cmd = buildHostServerCliCommand(probe.nodePath, probe.runtimeEntry, [
157
- 'active-tasks', '--port', String(port), '--json',
158
- ]);
159
- const res = await runSshCommand(sshAlias, cmd, {
160
- timeoutMs: deps.statusTimeoutMs ?? SSH_STATUS_TIMEOUT_MS,
161
- signal,
162
- deps,
163
- });
164
- if (!res.ok) {
165
- return { ok: false, reason: res.reason ?? 'Could not query active tasks on remote server.' };
166
- }
167
- const parsed = parseJsonStdout(res.stdout, hostServerActiveTasksResultSchema, 'host-server active-tasks');
168
- return parsed.ok ? { ok: true, activeCount: parsed.data.activeCount } : { ok: false, reason: parsed.reason };
169
- }
170
- async function probeUnmanagedRemoteVersion(sshAlias, remotePort, expectedInstallId, deps, signal) {
171
- if (remotePort === undefined || !expectedInstallId)
172
- return undefined;
173
- const opened = await openSshTunnel({
174
- sshAlias,
175
- remotePort,
176
- expectedInstallId,
177
- timeoutMs: deps.tunnelTimeoutMs,
178
- signal,
179
- deps,
180
- });
181
- if (!opened.ok)
182
- return undefined;
183
- const version = opened.identity.version;
184
- await opened.tunnel.close();
185
- return version;
186
- }
187
- async function checkActiveTasksBeforeUpdate(input) {
188
- if (input.now || input.port === null)
189
- return undefined;
190
- const active = await queryRemoteActiveTasks(input.sshAlias, input.probe, input.port, input.deps, input.signal);
191
- if (!active.ok) {
192
- return {
193
- ok: false,
194
- code: 'active_tasks_check_failed',
195
- reason: `Refusing to update host "${input.hostId}": could not check running tasks (${active.reason}). Re-run with --now to force.`,
196
- };
197
- }
198
- if (active.activeCount > 0) {
199
- return {
200
- ok: false,
201
- code: 'active_tasks',
202
- activeCount: active.activeCount,
203
- reason: `Refusing to update host "${input.hostId}": ${active.activeCount} task(s) are still running. Wait for them to finish or re-run with --now.`,
204
- };
205
- }
206
- return undefined;
207
- }
208
- async function stopForUpdate(hostId, sshAlias, probe, mainInstallId, deps, signal) {
209
- const stopCmd = buildHostServerCliCommand(probe.nodePath, probe.runtimeEntry, ['stop', '--starter-id', mainInstallId, '--json']);
210
- const stopRes = await runSshCommand(sshAlias, stopCmd, {
211
- timeoutMs: deps.controlTimeoutMs ?? SSH_CONTROL_TIMEOUT_MS,
212
- signal,
213
- deps,
214
- });
215
- const parsed = parseJsonStdout(stopRes.stdout, hostServerStopResultSchema, 'host-server stop');
216
- if (!parsed.ok) {
217
- return { ok: false, code: 'unreachable', state: 'unreachable', reason: stopRes.reason ?? parsed.reason };
218
- }
219
- if (parsed.data.reason === 'signal-failed' || parsed.data.reason === 'unverifiable-process') {
220
- return {
221
- ok: false,
222
- code: 'signal-failed',
223
- reason: `Could not stop managed server on host "${hostId}" (${parsed.data.reason}).`,
224
- };
225
- }
226
- return undefined;
227
- }
228
- async function resumeAfterUpdateStop(input) {
229
- const { hostId, sshAlias, probe, mainInstallId, previousVersion, mainVersion, deps, signal } = input;
230
- const resumeCmd = buildHostServerCliCommand(probe.nodePath, probe.runtimeEntry, ['resume', '--starter-id', mainInstallId, '--json']);
231
- const resumeRes = await runSshCommand(sshAlias, resumeCmd, {
232
- timeoutMs: deps.controlTimeoutMs ?? SSH_CONTROL_TIMEOUT_MS,
233
- signal,
234
- deps,
235
- });
236
- if (!resumeRes.ok || !parseJsonStdout(resumeRes.stdout, hostServerResumeResultSchema, 'host-server resume').ok) {
237
- const cmd = productIdentity().command;
238
- const detail = resumeRes.reason ?? 'Failed to clear update pause on remote host.';
239
- return {
240
- ok: false,
241
- code: 'stopped_paused',
242
- state: 'paused',
243
- previousVersion,
244
- version: mainVersion,
245
- reason: `Stopped old server (${previousVersion}) on host "${hostId}", but could not clear the pause record (${detail}). The server remains stopped and paused; run \`${cmd} host start ${hostId}\` to resume it.`,
246
- };
247
- }
248
- return undefined;
249
- }
250
- function updateResultFromBootstrap(bootstrap, codeOnConnected, successReason, version, previousVersion) {
251
- const ok = bootstrap.state === 'connected';
252
- return {
253
- ok,
254
- code: ok ? codeOnConnected : 'error',
255
- state: bootstrap.state,
256
- ...(previousVersion !== undefined ? { previousVersion } : {}),
257
- version,
258
- reason: ok ? successReason : (bootstrap.reason ?? 'Failed to start updated remote server.'),
259
- bootstrap,
260
- };
261
- }
262
- async function updateManagedServer(input) {
263
- const { home, hostId, entry, mainInstallId, mainVersion, probe, status, claim, now, deps, signal } = input;
264
- if (claim.version === mainVersion && !status.paused) {
265
- const bootstrap = await bootstrapHost(home, hostId, deps, { signal, preProbed: probe });
266
- return updateResultFromBootstrap(bootstrap, 'up_to_date', `Host "${hostId}" already runs version ${mainVersion}.`, mainVersion, claim.version);
267
- }
268
- const blocked = await checkActiveTasksBeforeUpdate({ hostId, sshAlias: entry.sshAlias, probe, port: claim.port, now, deps, signal });
269
- if (blocked)
270
- return blocked;
271
- const stopErr = await stopForUpdate(hostId, entry.sshAlias, probe, mainInstallId, deps, signal);
272
- if (stopErr)
273
- return stopErr;
274
- if (status.paused) {
275
- return {
276
- ok: true,
277
- code: 'paused',
278
- state: 'paused',
279
- previousVersion: claim.version,
280
- version: mainVersion,
281
- reason: `Stopped old server (${claim.version}) and installed runtime ${mainVersion}; host "${hostId}" remains paused.`,
282
- };
283
- }
284
- const resumeErr = await resumeAfterUpdateStop({
285
- hostId,
286
- sshAlias: entry.sshAlias,
287
- probe,
288
- mainInstallId,
289
- previousVersion: claim.version,
290
- mainVersion,
291
- deps,
292
- signal,
293
- });
294
- if (resumeErr)
295
- return resumeErr;
296
- const bootstrap = await bootstrapHost(home, hostId, deps, { signal, preProbed: probe });
297
- return updateResultFromBootstrap(bootstrap, 'updated', `Updated host "${hostId}" from ${claim.version} to ${mainVersion}.`, mainVersion, claim.version);
298
- }
299
- function ownedManagedClaimOf(entry, status) {
300
- if (!status.claim || status.claim.managedByStarter !== true)
301
- return undefined;
302
- if (entry.port !== undefined && status.claim.port !== entry.port)
303
- return undefined;
304
- return status.claim;
305
- }
306
- function hasUnmanagedRemoteServer(entry, status) {
307
- return (status.claim !== null && !status.claim.managedByStarter)
308
- || status.leases.length > 0
309
- || (entry.port !== undefined && status.state === 'ready');
310
- }
311
- async function refuseUnmanagedUpdate(hostId, entry, status, mainVersion, deps, signal) {
312
- const unmanagedPort = entry.port ?? status.claim?.port ?? status.leases[0]?.port;
313
- const remoteVersion = status.claim?.version
314
- ?? (await probeUnmanagedRemoteVersion(entry.sshAlias, unmanagedPort, status.installId, deps, signal))
315
- ?? 'unknown';
316
- return {
317
- ok: false,
318
- code: 'unmanaged_server',
319
- state: remoteVersion !== mainVersion ? 'version-mismatch' : undefined,
320
- previousVersion: remoteVersion,
321
- version: mainVersion,
322
- reason: `Host "${hostId}" runs an unmanaged server (remote version ${remoteVersion}, main version ${mainVersion}); unmanaged servers are never replaced automatically.`,
323
- };
324
- }
325
- /**
326
- * `hsq host update <id> [--now]`: verify install id first, install main's runtime, check running
327
- * tasks via the remote CLI (unless `--now`), stop ONLY a managed server owned by this home, and
328
- * start main's version. Never stops or replaces an unmanaged server.
329
- */
330
- export async function updateRemoteHost(home, hostId, options = {}, deps = {}) {
331
- const checked = await verifyRemoteIdentityForControl(home, hostId, deps, options.signal);
332
- if (!checked.ok) {
333
- return { ok: false, code: checked.code, state: checked.state, reason: checked.reason };
334
- }
335
- const { entry, mainInstallId, probe, status } = checked;
336
- const { mainVersion } = resolveMeta(deps);
337
- const ownedManagedClaim = ownedManagedClaimOf(entry, status);
338
- if (ownedManagedClaim) {
339
- return updateManagedServer({
340
- home, hostId, entry, mainInstallId, mainVersion, probe, status,
341
- claim: ownedManagedClaim, now: Boolean(options.now), deps, signal: options.signal,
342
- });
343
- }
344
- if (hasUnmanagedRemoteServer(entry, status)) {
345
- return refuseUnmanagedUpdate(hostId, entry, status, mainVersion, deps, options.signal);
346
- }
347
- if (status.paused) {
348
- return {
349
- ok: true,
350
- code: 'paused',
351
- state: 'paused',
352
- version: mainVersion,
353
- reason: `Installed runtime ${mainVersion} on "${hostId}"; host is paused (run \`${productIdentity().command} host start ${hostId}\` to start it).`,
354
- };
355
- }
356
- if (entry.port !== undefined) {
357
- return {
358
- ok: false,
359
- code: 'unreachable',
360
- state: 'unreachable',
361
- reason: `No server on pinned port ${entry.port}; a pinned host entry never starts a server.`,
362
- };
363
- }
364
- const bootstrap = await bootstrapHost(home, hostId, deps, { signal: options.signal, preProbed: probe });
365
- return updateResultFromBootstrap(bootstrap, 'updated', `Installed and started version ${mainVersion} on host "${hostId}".`, mainVersion);
366
- }
367
- //# sourceMappingURL=host-actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host-actions.js","sourceRoot":"","sources":["../../../src/features/hosts/host-actions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,iCAAiC,EACjC,4BAA4B,EAC5B,0BAA0B,GAK3B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,WAAW,GAIZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyD5C;;;;;;GAMG;AACH,KAAK,UAAU,8BAA8B,CAC3C,IAAU,EACV,MAAc,EACd,IAAuB,EACvB,MAAoB;IAEpB,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,IAA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AG,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM;SAClF,CAAC,CAAC;IACL,CAAC;IACD,IAAI,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;QAC5C,OAAO,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO;YACL,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,qBAAqB,WAAW,QAAQ,MAAM,4BAA4B,eAAe,EAAE,CAAC,OAAO,eAAe,MAAM,kBAAkB;SACnJ,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,4BAA4B,KAAK,CAAC,IAAI,8CAA8C;SAC7F,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IACxG,OAAO,yBAAyB,CAAC,SAAS,EAAE,SAAS,EAAE,iCAAiC,WAAW,aAAa,MAAM,IAAI,EAAE,WAAW,CAAC,CAAC;AAC3I,CAAC"}
@@ -1,85 +0,0 @@
1
- /**
2
- * Safe OpenSSH command runner and argv/environment builders for remote hosts
3
- * (spec § Architecture 2, hearsay-tools/squawk#4539).
4
- *
5
- * Security boundary (owner rule 2026-11-30: nothing is sent from one host to another):
6
- * - Every SSH call passes `BatchMode=yes`, `ForwardAgent=no`, `ForwardX11=no`, `RequestTTY=no`,
7
- * `SetEnv=_=` (OpenSSH first-match-wins clears any config `SetEnv`), `ControlMaster=no`,
8
- * `ControlPath=none`, `ControlPersist=no`, `ForkAfterAuthentication=no`, and `--`.
9
- * - Every SSH child runs with a minimal allowlisted local environment (`PATH`, `HOME`, `USER`,
10
- * `LOGNAME`, `SSH_AUTH_SOCK`, `TMPDIR`). That scrubbed local environment is what blocks config
11
- * `SendEnv` directives from transmitting main-host variables or credentials; a config `SendEnv`
12
- * naming one of the six kept variables would still send it, which is acceptable because none is
13
- * a credential (`SSH_AUTH_SOCK` is a local socket path and `ForwardAgent=no` blocks forwarding).
14
- * - Every call has both an OpenSSH `ConnectTimeout` and a hard process deadline that kills the
15
- * child on expiry or abort.
16
- */
17
- import { type ChildProcess, type SpawnOptions } from 'node:child_process';
18
- import type { Writable } from 'node:stream';
19
- export declare const SSH_CONNECT_TIMEOUT_SECONDS = 15;
20
- export declare const SSH_KEEPALIVE_INTERVAL_SECONDS = 15;
21
- export declare const SSH_KEEPALIVE_COUNT_MAX = 3;
22
- export declare const SSH_PROBE_TIMEOUT_MS = 20000;
23
- export declare const SSH_INSTALL_TIMEOUT_MS = 180000;
24
- export declare const SSH_ENSURE_TIMEOUT_MS = 45000;
25
- export declare const SSH_STATUS_TIMEOUT_MS = 10000;
26
- export declare const SSH_CONTROL_TIMEOUT_MS = 30000;
27
- export declare const SSH_TUNNEL_READY_TIMEOUT_MS = 20000;
28
- /**
29
- * Only local variables required for `ssh` itself to resolve binaries, `~/.ssh/config`, and local
30
- * agent keys (`ForwardAgent=no` ensures the agent socket is never forwarded).
31
- */
32
- export declare const SSH_ALLOWED_LOCAL_ENV_KEYS: readonly ['PATH', 'HOME', 'USER', 'LOGNAME', 'SSH_AUTH_SOCK', 'TMPDIR'];
33
- export type SshSpawnFn = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
34
- export interface SshTransportDeps {
35
- /** Override the `ssh` binary path (used by fake-`ssh` unit tests). */
36
- sshBin?: string | undefined;
37
- /** Override `child_process.spawn` (for unit tests). */
38
- spawn?: SshSpawnFn | undefined;
39
- /** Override source environment for `buildSshLocalEnv`. */
40
- env?: NodeJS.ProcessEnv | undefined;
41
- /** Override OpenSSH `ConnectTimeout` in seconds. */
42
- connectTimeoutSeconds?: number | undefined;
43
- }
44
- export interface RunSshCommandOptions {
45
- timeoutMs: number;
46
- signal?: AbortSignal | undefined;
47
- /** Optional producer writing to the SSH child's stdin (e.g. runtime archive stream). */
48
- streamStdin?: ((stdin: Writable, child: ChildProcess) => Promise<void>) | undefined;
49
- deps?: SshTransportDeps | undefined;
50
- }
51
- export interface SshCommandResult {
52
- ok: boolean;
53
- code: number | null;
54
- signal: NodeJS.Signals | null;
55
- stdout: string;
56
- stderr: string;
57
- timedOut: boolean;
58
- aborted: boolean;
59
- reason?: string | undefined;
60
- }
61
- /** Build the scrubbed local environment passed to every `ssh` child process. */
62
- export declare function buildSshLocalEnv(baseEnv?: NodeJS.ProcessEnv): Record<string, string>;
63
- /**
64
- * OpenSSH reads `/etc/passwd`'s `pw_dir/.ssh/config` rather than `$HOME/.ssh/config`. When the
65
- * caller explicitly overrides `HOME` to a different directory (compared by real path so a
66
- * symlinked home is not treated as overridden) that holds `.ssh/config`, pass
67
- * `-F <HOME>/.ssh/config` so `ssh` reads the same config file that `ssh-config.ts` reads.
68
- */
69
- export declare function resolveIsolatedSshConfigPath(baseEnv?: NodeJS.ProcessEnv): string | undefined;
70
- /** Build the OpenSSH argv for a single non-interactive remote command call. */
71
- export declare function buildSshCommandArgv(sshAlias: string, remoteCommand: string, options?: {
72
- connectTimeoutSeconds?: number | undefined;
73
- sshConfigPath?: string | undefined;
74
- }): string[];
75
- /** Build the OpenSSH argv for a loopback port-forwarding tunnel (`-N -L`). */
76
- export declare function buildSshTunnelArgv(sshAlias: string, localPort: number, remotePort: number, options?: {
77
- connectTimeoutSeconds?: number | undefined;
78
- sshConfigPath?: string | undefined;
79
- }): string[];
80
- /** Return the first non-empty line of `stderr` (bounded), or `fallback` when stderr is empty. */
81
- export declare function firstStderrLine(stderr: string, fallback: string): string;
82
- /** Terminate an SSH child cleanly (SIGTERM, then SIGKILL after a short grace). */
83
- export declare function terminateSshChild(child: ChildProcess, graceMs?: number): Promise<void>;
84
- /** Execute one remote command over SSH with strict env isolation, deadline, and abort support. */
85
- export declare function runSshCommand(sshAlias: string, remoteCommand: string, options: RunSshCommandOptions): Promise<SshCommandResult>;