@hearsay-tools/squawk 0.19.0-pr4591.9107 → 0.19.0-pr4593.9115
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/dist/ci-wait/errors.js +1 -1
- package/dist/ci-wait/errors.js.map +1 -1
- package/dist/contract/hosts.d.ts +47 -5
- package/dist/contract/index.js +19 -1
- package/dist/{delegation/input.js → core/agent-input-queue.js} +2 -2
- package/dist/core/agent-input-queue.js.map +1 -0
- package/dist/core/agent-runner.d.ts +1 -1
- package/dist/core/delegation-error.d.ts +13 -0
- package/dist/core/delegation-error.js +18 -0
- package/dist/core/delegation-error.js.map +1 -0
- package/dist/core/retry-backoff.js.map +1 -0
- package/dist/core/session-process.d.ts +1 -1
- package/dist/core/spawn-scope.d.ts +10 -0
- package/dist/core/spawn-scope.js +2 -0
- package/dist/core/spawn-scope.js.map +1 -0
- package/dist/delegation/cli.js +1 -1
- package/dist/delegation/cli.js.map +1 -1
- package/dist/delegation/context.d.ts +1 -1
- package/dist/delegation/context.js +1 -1
- package/dist/delegation/context.js.map +1 -1
- package/dist/delegation/conversation-send.js +1 -1
- package/dist/delegation/conversation-send.js.map +1 -1
- package/dist/delegation/conversations.js +1 -1
- package/dist/delegation/conversations.js.map +1 -1
- package/dist/delegation/effort.js +1 -1
- package/dist/delegation/effort.js.map +1 -1
- package/dist/delegation/execution-settings.js +1 -1
- package/dist/delegation/execution-settings.js.map +1 -1
- package/dist/delegation/policy.d.ts +1 -12
- package/dist/delegation/policy.js +1 -16
- package/dist/delegation/policy.js.map +1 -1
- package/dist/delegation/routes.d.ts +15 -15
- package/dist/delegation/routes.js +1 -1
- package/dist/delegation/routes.js.map +1 -1
- package/dist/delegation/scratch-cleanup.js +1 -1
- package/dist/delegation/scratch-cleanup.js.map +1 -1
- package/dist/delegation/service.js +2 -1
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/task-discovery.js +2 -1
- package/dist/delegation/task-discovery.js.map +1 -1
- package/dist/delegation/transport.d.ts +88 -88
- package/dist/delegation/wait-kinds.js +2 -1
- package/dist/delegation/wait-kinds.js.map +1 -1
- package/dist/delegation/worker-cleanup.d.ts +1 -1
- package/dist/delegation/worker-cleanup.js +2 -2
- package/dist/delegation/worker-cleanup.js.map +1 -1
- package/dist/delegation/worker-executions.d.ts +2 -1
- package/dist/delegation/worker-executions.js.map +1 -1
- package/dist/delegation/workspace-kinds.js +1 -1
- package/dist/delegation/workspace-kinds.js.map +1 -1
- package/dist/delegation/workspace.js +1 -1
- package/dist/delegation/workspace.js.map +1 -1
- package/dist/features/automations/automations-routes.d.ts +150 -150
- package/dist/features/hosts/bootstrap.d.ts +120 -0
- package/dist/features/hosts/bootstrap.js +469 -0
- package/dist/features/hosts/bootstrap.js.map +1 -0
- package/dist/features/hosts/cli.d.ts +13 -3
- package/dist/features/hosts/cli.js +199 -27
- package/dist/features/hosts/cli.js.map +1 -1
- package/dist/features/hosts/host-actions.d.ts +56 -0
- package/dist/features/hosts/host-actions.js +367 -0
- package/dist/features/hosts/host-actions.js.map +1 -0
- package/dist/features/hosts/host-server-cli.js +21 -3
- package/dist/features/hosts/host-server-cli.js.map +1 -1
- package/dist/features/hosts/host-server.d.ts +10 -1
- package/dist/features/hosts/host-server.js +74 -0
- package/dist/features/hosts/host-server.js.map +1 -1
- package/dist/features/hosts/index.d.ts +4 -2
- package/dist/features/hosts/index.js +14 -2
- package/dist/features/hosts/index.js.map +1 -1
- package/dist/features/hosts/registry.d.ts +28 -0
- package/dist/features/hosts/registry.js +42 -1
- package/dist/features/hosts/registry.js.map +1 -1
- package/dist/features/hosts/routes.d.ts +5 -3
- package/dist/features/hosts/routes.js +14 -7
- package/dist/features/hosts/routes.js.map +1 -1
- package/dist/features/hosts/ssh.d.ts +85 -0
- package/dist/features/hosts/ssh.js +271 -0
- package/dist/features/hosts/ssh.js.map +1 -0
- package/dist/features/hosts/supervisor.d.ts +191 -0
- package/dist/features/hosts/supervisor.js +620 -0
- package/dist/features/hosts/supervisor.js.map +1 -0
- package/dist/features/hosts/tunnel.d.ts +46 -0
- package/dist/features/hosts/tunnel.js +244 -0
- package/dist/features/hosts/tunnel.js.map +1 -0
- package/dist/features/webhooks/routes.d.ts +13 -13
- package/dist/plugin/runner-kit.d.ts +1 -1
- package/dist/preview/dev-server.d.ts +1 -1
- package/dist/preview/host.d.ts +1 -1
- package/dist/runs/run-archive.d.ts +72 -72
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/project-run-files.js +1 -1
- package/dist/server/project-run-files.js.map +1 -1
- package/dist/server/repo-routes.d.ts +52 -52
- package/dist/server/runs-routes.d.ts +666 -666
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/worker-scope/scope.d.ts +0 -10
- package/dist/worker-scope/worker-scopes.d.ts +2 -1
- package/dist/worker-scope/worker-scopes.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +72 -72
- package/dist/workflows/grouped-command.d.ts +1 -1
- package/dist/workflows/run/auto-resume.js +1 -1
- package/dist/workflows/run/auto-resume.js.map +1 -1
- package/dist/workflows/run/inbox-claims.js +1 -1
- package/dist/workflows/run/inbox-claims.js.map +1 -1
- package/dist/workflows/run/input-batch.js +1 -1
- package/dist/workflows/run/input-batch.js.map +1 -1
- package/dist/workflows/run/input-delivery.js +2 -2
- package/dist/workflows/run/input-delivery.js.map +1 -1
- package/dist/workflows/run/launch-read-resolver.js +1 -1
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/resolved-wait-input-batch.js +1 -1
- package/dist/workflows/run/resolved-wait-input-batch.js.map +1 -1
- package/dist/workflows/run/run-cancel.js +1 -1
- package/dist/workflows/run/run-cancel.js.map +1 -1
- package/dist/workflows/run/run-recovery.js +1 -1
- package/dist/workflows/run/run-recovery.js.map +1 -1
- package/dist/workflows/run/run-start.js +1 -1
- package/dist/workflows/run/run-start.js.map +1 -1
- package/dist/workflows/run/turn-nudges.js +1 -1
- package/dist/workflows/run/turn-nudges.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +72 -72
- package/dist/workflows/run/wake-admission.js +1 -1
- package/dist/workflows/run/wake-admission.js.map +1 -1
- package/dist/workflows/run/wake-ledger.js +1 -1
- package/dist/workflows/run/wake-ledger.js.map +1 -1
- package/dist/workflows/run/wake-retries.d.ts +1 -1
- package/dist/workflows/run/wake-retries.js +1 -1
- package/dist/workflows/run/wake-retries.js.map +1 -1
- package/dist/workflows/run/worker-orphans.d.ts +1 -1
- package/dist/workflows/run/worker-orphans.js +1 -1
- package/dist/workflows/run/worker-orphans.js.map +1 -1
- package/dist/workflows/run/worker-questions.js +1 -1
- package/dist/workflows/run/worker-questions.js.map +1 -1
- package/dist/workflows/wait-scope.d.ts +1 -1
- package/dist/workflows/wait-scope.js +2 -2
- package/dist/workflows/wait-scope.js.map +1 -1
- package/dist/worktree-setup.d.ts +1 -1
- package/package.json +4 -4
- package/dist/delegation/input.js.map +0 -1
- package/dist/delegation/retry-backoff.js.map +0 -1
- /package/dist/{delegation/input.d.ts → core/agent-input-queue.d.ts} +0 -0
- /package/dist/{delegation → core}/retry-backoff.d.ts +0 -0
- /package/dist/{delegation → core}/retry-backoff.js +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type WorkspaceIdentityResponse } from '../../contract/index.js';
|
|
2
|
+
import { type SshTransportDeps } from './ssh.ts';
|
|
3
|
+
export interface TunnelExitInfo {
|
|
4
|
+
readonly code: number | null;
|
|
5
|
+
readonly signal: NodeJS.Signals | null;
|
|
6
|
+
readonly reason: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HostTunnel {
|
|
9
|
+
readonly localPort: number;
|
|
10
|
+
readonly remotePort: number;
|
|
11
|
+
readonly pid: number | undefined;
|
|
12
|
+
readonly exited: Promise<TunnelExitInfo>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export interface TunnelDeps extends SshTransportDeps {
|
|
16
|
+
pickLocalPort?: (() => Promise<number>) | undefined;
|
|
17
|
+
fetch?: typeof fetch | undefined;
|
|
18
|
+
nowMs?: (() => number) | undefined;
|
|
19
|
+
waitMs?: ((ms: number) => Promise<void>) | undefined;
|
|
20
|
+
}
|
|
21
|
+
export type OpenTunnelResult = {
|
|
22
|
+
ok: true;
|
|
23
|
+
tunnel: HostTunnel;
|
|
24
|
+
identity: WorkspaceIdentityResponse;
|
|
25
|
+
localHandoff: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
state: 'unreachable' | 'not-hosted';
|
|
29
|
+
reason: string;
|
|
30
|
+
};
|
|
31
|
+
/** Ask the operating system for an ephemeral loopback TCP port. Never stored on disk. */
|
|
32
|
+
export declare function pickFreeLoopbackPort(): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Open an SSH loopback tunnel to `127.0.0.1:<remotePort>` on `sshAlias` and verify it via
|
|
35
|
+
* `GET /api/v1/workspace/identity` (requiring an exact match with `expectedInstallId` from
|
|
36
|
+
* `ensure` over SSH while the SSH child stays alive) and `GET /api/v1/health`. Retries on a
|
|
37
|
+
* fresh ephemeral port if another local process claimed the port first.
|
|
38
|
+
*/
|
|
39
|
+
export declare function openSshTunnel(input: {
|
|
40
|
+
sshAlias: string;
|
|
41
|
+
remotePort: number;
|
|
42
|
+
expectedInstallId: string;
|
|
43
|
+
timeoutMs?: number | undefined;
|
|
44
|
+
signal?: AbortSignal | undefined;
|
|
45
|
+
deps?: TunnelDeps | undefined;
|
|
46
|
+
}): Promise<OpenTunnelResult>;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed SSH loopback tunnel (`ssh -N -L 127.0.0.1:<local>:127.0.0.1:<remote>`) and remote
|
|
3
|
+
* server verification (`GET /api/v1/workspace/identity` + `GET /api/v1/health`,
|
|
4
|
+
* spec § Architecture 2 steps 4–5, hearsay-tools/squawk#4539).
|
|
5
|
+
*
|
|
6
|
+
* The local port is picked by the operating system and never persisted to disk. The tunnel runs
|
|
7
|
+
* as a direct child of the main server and terminates when the supervisor or server stops.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import { createServer } from 'node:net';
|
|
11
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
12
|
+
import { workspaceIdentityResponseSchema } from '../../contract/index.js';
|
|
13
|
+
import { SSH_TUNNEL_READY_TIMEOUT_MS, buildSshLocalEnv, buildSshTunnelArgv, firstStderrLine, resolveIsolatedSshConfigPath, terminateSshChild, } from './ssh.js';
|
|
14
|
+
const TUNNEL_POLL_INTERVAL_MS = 50;
|
|
15
|
+
const TUNNEL_VERIFY_FETCH_TIMEOUT_MS = 4_000;
|
|
16
|
+
const MAX_TUNNEL_STDERR_BYTES = 32 * 1024;
|
|
17
|
+
const MAX_BIND_ATTEMPTS = 2;
|
|
18
|
+
/** Ask the operating system for an ephemeral loopback TCP port. Never stored on disk. */
|
|
19
|
+
export function pickFreeLoopbackPort() {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const server = createServer();
|
|
22
|
+
server.once('error', reject);
|
|
23
|
+
server.listen(0, '127.0.0.1', () => {
|
|
24
|
+
const address = server.address();
|
|
25
|
+
if (!address || typeof address === 'string') {
|
|
26
|
+
server.close(() => reject(new Error('Could not allocate an ephemeral loopback port.')));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const { port } = address;
|
|
30
|
+
server.close((error) => {
|
|
31
|
+
if (error)
|
|
32
|
+
reject(error);
|
|
33
|
+
else
|
|
34
|
+
resolve(port);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function readHealthHostedFlag(localPort, fetchFn, signal) {
|
|
40
|
+
const fetchSignal = signal
|
|
41
|
+
? AbortSignal.any([signal, AbortSignal.timeout(TUNNEL_VERIFY_FETCH_TIMEOUT_MS)])
|
|
42
|
+
: AbortSignal.timeout(TUNNEL_VERIFY_FETCH_TIMEOUT_MS);
|
|
43
|
+
let res;
|
|
44
|
+
try {
|
|
45
|
+
res = await fetchFn(`http://127.0.0.1:${localPort}/api/v1/health`, { signal: fetchSignal });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
state: 'unreachable',
|
|
51
|
+
reason: `Could not verify remote server health through tunnel: ${error instanceof Error ? error.message : String(error)}`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
return { ok: false, state: 'unreachable', reason: `Remote /api/v1/health answered HTTP ${res.status}` };
|
|
56
|
+
}
|
|
57
|
+
let body;
|
|
58
|
+
try {
|
|
59
|
+
body = await res.json();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return { ok: false, state: 'not-hosted', reason: 'Remote /api/v1/health did not return valid JSON; cannot verify hosted mode.' };
|
|
63
|
+
}
|
|
64
|
+
const caps = body?.capabilities;
|
|
65
|
+
if (typeof caps?.localHandoff !== 'boolean') {
|
|
66
|
+
return { ok: false, state: 'not-hosted', reason: 'Remote /api/v1/health omitted capabilities.localHandoff; refusing non-hosted server.' };
|
|
67
|
+
}
|
|
68
|
+
return { ok: true, localHandoff: caps.localHandoff };
|
|
69
|
+
}
|
|
70
|
+
async function probeTunnelIdentity(localPort, fetchFn, signal) {
|
|
71
|
+
const fetchSignal = signal
|
|
72
|
+
? AbortSignal.any([signal, AbortSignal.timeout(TUNNEL_VERIFY_FETCH_TIMEOUT_MS)])
|
|
73
|
+
: AbortSignal.timeout(TUNNEL_VERIFY_FETCH_TIMEOUT_MS);
|
|
74
|
+
let res;
|
|
75
|
+
try {
|
|
76
|
+
res = await fetchFn(`http://127.0.0.1:${localPort}/api/v1/workspace/identity`, { signal: fetchSignal });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return { status: 'retry' };
|
|
80
|
+
}
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
return {
|
|
83
|
+
status: 'failed',
|
|
84
|
+
state: 'unreachable',
|
|
85
|
+
reason: `Remote /api/v1/workspace/identity answered HTTP ${res.status}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let raw;
|
|
89
|
+
try {
|
|
90
|
+
raw = await res.json();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return {
|
|
94
|
+
status: 'failed',
|
|
95
|
+
state: 'unreachable',
|
|
96
|
+
reason: 'Remote /api/v1/workspace/identity returned invalid JSON.',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const parsed = workspaceIdentityResponseSchema.safeParse(raw);
|
|
100
|
+
if (!parsed.success) {
|
|
101
|
+
return {
|
|
102
|
+
status: 'failed',
|
|
103
|
+
state: 'unreachable',
|
|
104
|
+
reason: 'Remote /api/v1/workspace/identity returned an unexpected shape.',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const health = await readHealthHostedFlag(localPort, fetchFn, signal);
|
|
108
|
+
if (!health.ok) {
|
|
109
|
+
return { status: 'failed', state: health.state, reason: health.reason };
|
|
110
|
+
}
|
|
111
|
+
return { status: 'ready', identity: parsed.data, localHandoff: health.localHandoff };
|
|
112
|
+
}
|
|
113
|
+
function spawnTunnelChild(sshAlias, localPort, remotePort, deps) {
|
|
114
|
+
const spawnFn = deps.spawn ?? spawn;
|
|
115
|
+
const argv = buildSshTunnelArgv(sshAlias, localPort, remotePort, {
|
|
116
|
+
connectTimeoutSeconds: deps.connectTimeoutSeconds,
|
|
117
|
+
sshConfigPath: resolveIsolatedSshConfigPath(deps.env),
|
|
118
|
+
});
|
|
119
|
+
const child = spawnFn(deps.sshBin ?? 'ssh', argv, {
|
|
120
|
+
env: buildSshLocalEnv(deps.env),
|
|
121
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
122
|
+
});
|
|
123
|
+
let stderr = '';
|
|
124
|
+
child.stderr?.on('data', (chunk) => {
|
|
125
|
+
if (stderr.length < MAX_TUNNEL_STDERR_BYTES) {
|
|
126
|
+
stderr += chunk.toString('utf8');
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
let exitInfo;
|
|
130
|
+
const exited = new Promise((resolve) => {
|
|
131
|
+
const finish = (info) => {
|
|
132
|
+
if (exitInfo)
|
|
133
|
+
return;
|
|
134
|
+
exitInfo = info;
|
|
135
|
+
resolve(info);
|
|
136
|
+
};
|
|
137
|
+
child.once('error', (error) => {
|
|
138
|
+
finish({ code: null, signal: null, reason: firstStderrLine(stderr, error.message) });
|
|
139
|
+
});
|
|
140
|
+
child.once('close', (code, signal) => {
|
|
141
|
+
const fallback = signal
|
|
142
|
+
? `SSH tunnel exited with signal ${signal}`
|
|
143
|
+
: `SSH tunnel exited with code ${String(code ?? 'unknown')}`;
|
|
144
|
+
finish({ code, signal, reason: firstStderrLine(stderr, fallback) });
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const tunnel = {
|
|
148
|
+
localPort,
|
|
149
|
+
remotePort,
|
|
150
|
+
pid: child.pid,
|
|
151
|
+
exited,
|
|
152
|
+
close: async () => {
|
|
153
|
+
await terminateSshChild(child);
|
|
154
|
+
await exited;
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
tunnel,
|
|
159
|
+
exitedNow: () => exitInfo,
|
|
160
|
+
isAlive: () => exitInfo === undefined && child.exitCode === null && child.signalCode === null,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function isBindRaceReason(reason) {
|
|
164
|
+
return /address already in use|could not request local forwarding/i.test(reason);
|
|
165
|
+
}
|
|
166
|
+
async function openTunnelOnce(input) {
|
|
167
|
+
const { sshAlias, remotePort, expectedInstallId, timeoutMs, signal, deps } = input;
|
|
168
|
+
const pickPort = deps.pickLocalPort ?? pickFreeLoopbackPort;
|
|
169
|
+
const fetchFn = deps.fetch ?? fetch;
|
|
170
|
+
const nowMs = deps.nowMs ?? Date.now;
|
|
171
|
+
const waitMs = deps.waitMs ?? ((ms) => delay(ms));
|
|
172
|
+
const localPort = await pickPort();
|
|
173
|
+
const { tunnel, exitedNow, isAlive } = spawnTunnelChild(sshAlias, localPort, remotePort, deps);
|
|
174
|
+
const deadline = nowMs() + timeoutMs;
|
|
175
|
+
while (true) {
|
|
176
|
+
if (signal?.aborted) {
|
|
177
|
+
await tunnel.close();
|
|
178
|
+
return { ok: false, state: 'unreachable', reason: 'Tunnel setup aborted' };
|
|
179
|
+
}
|
|
180
|
+
const earlyExit = exitedNow();
|
|
181
|
+
if (earlyExit) {
|
|
182
|
+
return { ok: false, state: 'unreachable', reason: earlyExit.reason, bindRace: isBindRaceReason(earlyExit.reason) };
|
|
183
|
+
}
|
|
184
|
+
const probe = await probeTunnelIdentity(localPort, fetchFn, signal);
|
|
185
|
+
if (probe.status === 'ready') {
|
|
186
|
+
const exitAfterProbe = exitedNow();
|
|
187
|
+
if (exitAfterProbe || !isAlive()) {
|
|
188
|
+
const reason = exitAfterProbe?.reason ?? 'SSH tunnel exited during identity verification.';
|
|
189
|
+
await tunnel.close();
|
|
190
|
+
return { ok: false, state: 'unreachable', reason, bindRace: isBindRaceReason(reason) };
|
|
191
|
+
}
|
|
192
|
+
if (probe.identity.installId !== expectedInstallId) {
|
|
193
|
+
await tunnel.close();
|
|
194
|
+
return {
|
|
195
|
+
ok: false,
|
|
196
|
+
state: 'unreachable',
|
|
197
|
+
reason: 'Local tunnel port answered with an unexpected install id (port collision).',
|
|
198
|
+
bindRace: true,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return { ok: true, tunnel, identity: probe.identity, localHandoff: probe.localHandoff };
|
|
202
|
+
}
|
|
203
|
+
if (probe.status === 'failed') {
|
|
204
|
+
const exitAfterFail = exitedNow();
|
|
205
|
+
await tunnel.close();
|
|
206
|
+
if (exitAfterFail) {
|
|
207
|
+
return { ok: false, state: 'unreachable', reason: exitAfterFail.reason, bindRace: isBindRaceReason(exitAfterFail.reason) };
|
|
208
|
+
}
|
|
209
|
+
return { ok: false, state: probe.state, reason: probe.reason };
|
|
210
|
+
}
|
|
211
|
+
if (nowMs() >= deadline) {
|
|
212
|
+
await tunnel.close();
|
|
213
|
+
return { ok: false, state: 'unreachable', reason: `SSH tunnel timed out after ${timeoutMs}ms` };
|
|
214
|
+
}
|
|
215
|
+
await waitMs(TUNNEL_POLL_INTERVAL_MS);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Open an SSH loopback tunnel to `127.0.0.1:<remotePort>` on `sshAlias` and verify it via
|
|
220
|
+
* `GET /api/v1/workspace/identity` (requiring an exact match with `expectedInstallId` from
|
|
221
|
+
* `ensure` over SSH while the SSH child stays alive) and `GET /api/v1/health`. Retries on a
|
|
222
|
+
* fresh ephemeral port if another local process claimed the port first.
|
|
223
|
+
*/
|
|
224
|
+
export async function openSshTunnel(input) {
|
|
225
|
+
const timeoutMs = input.timeoutMs ?? SSH_TUNNEL_READY_TIMEOUT_MS;
|
|
226
|
+
const deps = input.deps ?? {};
|
|
227
|
+
for (let attempt = 0; attempt < MAX_BIND_ATTEMPTS; attempt++) {
|
|
228
|
+
const result = await openTunnelOnce({
|
|
229
|
+
sshAlias: input.sshAlias,
|
|
230
|
+
remotePort: input.remotePort,
|
|
231
|
+
expectedInstallId: input.expectedInstallId,
|
|
232
|
+
timeoutMs,
|
|
233
|
+
signal: input.signal,
|
|
234
|
+
deps,
|
|
235
|
+
});
|
|
236
|
+
if (result.ok || !result.bindRace || attempt + 1 >= MAX_BIND_ATTEMPTS) {
|
|
237
|
+
return result.ok
|
|
238
|
+
? { ok: true, tunnel: result.tunnel, identity: result.identity, localHandoff: result.localHandoff }
|
|
239
|
+
: { ok: false, state: result.state, reason: result.reason };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return { ok: false, state: 'unreachable', reason: 'SSH tunnel failed to bind a local loopback port.' };
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=tunnel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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AE,KAAK,CAAC,iBAAiB;YAC1C,SAAS;YACT,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI;SACL,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,IAAI,iBAAiB,EAAE,CAAC;YACtE,OAAO,MAAM,CAAC,EAAE;gBACd,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE;gBACnG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,kDAAkD,EAAE,CAAC;AACzG,CAAC"}
|
|
@@ -348,19 +348,6 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
348
348
|
webhookId: string;
|
|
349
349
|
};
|
|
350
350
|
};
|
|
351
|
-
} | {
|
|
352
|
-
output: {
|
|
353
|
-
error: string;
|
|
354
|
-
code?: "no-boot-project" | undefined;
|
|
355
|
-
};
|
|
356
|
-
outputFormat: "json";
|
|
357
|
-
status: 400 | 404 | 409 | 500;
|
|
358
|
-
input: {
|
|
359
|
-
param: {
|
|
360
|
-
projectId: string;
|
|
361
|
-
webhookId: string;
|
|
362
|
-
};
|
|
363
|
-
};
|
|
364
351
|
} | {
|
|
365
352
|
output: {
|
|
366
353
|
project: {
|
|
@@ -401,6 +388,19 @@ export declare function createProjectWebhooksRoutes(deps: ProjectWebhooksRouteDe
|
|
|
401
388
|
webhookId: string;
|
|
402
389
|
};
|
|
403
390
|
};
|
|
391
|
+
} | {
|
|
392
|
+
output: {
|
|
393
|
+
error: string;
|
|
394
|
+
code?: "no-boot-project" | undefined;
|
|
395
|
+
};
|
|
396
|
+
outputFormat: "json";
|
|
397
|
+
status: 400 | 404 | 409 | 500;
|
|
398
|
+
input: {
|
|
399
|
+
param: {
|
|
400
|
+
projectId: string;
|
|
401
|
+
webhookId: string;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
404
|
};
|
|
405
405
|
};
|
|
406
406
|
} & {
|
|
@@ -20,7 +20,7 @@ export { productEnv } from '../core/product-env.ts';
|
|
|
20
20
|
export { agentHomeDir, agentUserHome } from '../paths.ts';
|
|
21
21
|
export type { LeaderState } from '../core/session-process.ts';
|
|
22
22
|
export type { RunnerTimings } from '../core/runner-runtime.ts';
|
|
23
|
-
export type { SpawnScope } from '../
|
|
23
|
+
export type { SpawnScope } from '../core/spawn-scope.ts';
|
|
24
24
|
export type { FileDiff, HookEntryKind, HookStatus, PermissionOption, PlanEntry, PlanStatus, SkillInputIdentity, StopReason, TokenUsage, ToolLocation, ToolStatus, UiAskQuestion, UiAskRequestedEvent, UiEvent, UiHookItem, UiItem, UiMessageItem, UiPermissionRequestedEvent, UiReasoningItem, UiSessionStartedEvent, UiToolItem, UiTurnCompletedEvent, UiUsageUpdatedEvent, } from '../core/ui-events.ts';
|
|
25
25
|
export type { AskQuestion } from '../core/ask.ts';
|
|
26
26
|
export type { RawUsage } from '../core/usage.ts';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import type { PreviewServer } from '../contract/index.js';
|
|
3
|
-
import type { SpawnScope } from '../
|
|
3
|
+
import type { SpawnScope } from '../core/spawn-scope.ts';
|
|
4
4
|
/**
|
|
5
5
|
* Supervisor for one cezar-owned dev server (#781, spec 2026-10-02-live-preview-v1): spawn the
|
|
6
6
|
* registered command in its own process group, TCP-probe until the port answers, and kill the
|
package/dist/preview/host.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AgentCdpLink, type AgentClient } from './cdp-proxy.ts';
|
|
|
6
6
|
import { DevServer, type DevServerState } from './dev-server.ts';
|
|
7
7
|
import { type PreviewHostLike } from './registration.ts';
|
|
8
8
|
import { type Viewer } from './session.ts';
|
|
9
|
-
import type { SpawnScope } from '../
|
|
9
|
+
import type { SpawnScope } from '../core/spawn-scope.ts';
|
|
10
10
|
/**
|
|
11
11
|
* The workspace-wide preview host (#781, spec 2026-10-02-live-preview-v1): one per server process,
|
|
12
12
|
* because ports are host-global. Keyed by run id, it owns every cezar-started dev server and every
|
|
@@ -233,30 +233,6 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
233
233
|
deadline: string;
|
|
234
234
|
seconds: number;
|
|
235
235
|
note?: string | undefined;
|
|
236
|
-
} | {
|
|
237
|
-
id: string;
|
|
238
|
-
source: "agent" | "cezar";
|
|
239
|
-
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
240
|
-
registeredAt: string;
|
|
241
|
-
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
242
|
-
resolvedAt?: string | undefined;
|
|
243
|
-
deliveredAt?: string | undefined;
|
|
244
|
-
cancelledAt?: string | undefined;
|
|
245
|
-
turnId: string;
|
|
246
|
-
kind: "process";
|
|
247
|
-
deadline: string;
|
|
248
|
-
timeoutSeconds: number;
|
|
249
|
-
pid: number;
|
|
250
|
-
startToken?: string | undefined;
|
|
251
|
-
exitFile?: string | undefined;
|
|
252
|
-
note?: string | undefined;
|
|
253
|
-
result?: {
|
|
254
|
-
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
255
|
-
observedAt: string;
|
|
256
|
-
exitCode?: number | undefined;
|
|
257
|
-
exitFileNote?: "not-an-exit-code" | undefined;
|
|
258
|
-
diagnostic?: string | undefined;
|
|
259
|
-
} | undefined;
|
|
260
236
|
} | {
|
|
261
237
|
id: string;
|
|
262
238
|
source: "agent" | "cezar";
|
|
@@ -318,6 +294,30 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
318
294
|
reason: "outcome" | "timeout";
|
|
319
295
|
} | undefined;
|
|
320
296
|
wakeInputId?: string | undefined;
|
|
297
|
+
} | {
|
|
298
|
+
id: string;
|
|
299
|
+
source: "agent" | "cezar";
|
|
300
|
+
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
301
|
+
registeredAt: string;
|
|
302
|
+
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
303
|
+
resolvedAt?: string | undefined;
|
|
304
|
+
deliveredAt?: string | undefined;
|
|
305
|
+
cancelledAt?: string | undefined;
|
|
306
|
+
turnId: string;
|
|
307
|
+
kind: "process";
|
|
308
|
+
deadline: string;
|
|
309
|
+
timeoutSeconds: number;
|
|
310
|
+
pid: number;
|
|
311
|
+
startToken?: string | undefined;
|
|
312
|
+
exitFile?: string | undefined;
|
|
313
|
+
note?: string | undefined;
|
|
314
|
+
result?: {
|
|
315
|
+
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
316
|
+
observedAt: string;
|
|
317
|
+
exitCode?: number | undefined;
|
|
318
|
+
exitFileNote?: "not-an-exit-code" | undefined;
|
|
319
|
+
diagnostic?: string | undefined;
|
|
320
|
+
} | undefined;
|
|
321
321
|
} | {
|
|
322
322
|
id: string;
|
|
323
323
|
source: "agent" | "cezar";
|
|
@@ -446,30 +446,6 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
446
446
|
deadline: string;
|
|
447
447
|
seconds: number;
|
|
448
448
|
note?: string | undefined;
|
|
449
|
-
} | {
|
|
450
|
-
id: string;
|
|
451
|
-
source: "agent" | "cezar";
|
|
452
|
-
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
453
|
-
registeredAt: string;
|
|
454
|
-
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
455
|
-
resolvedAt?: string | undefined;
|
|
456
|
-
deliveredAt?: string | undefined;
|
|
457
|
-
cancelledAt?: string | undefined;
|
|
458
|
-
turnId: string;
|
|
459
|
-
kind: "process";
|
|
460
|
-
deadline: string;
|
|
461
|
-
timeoutSeconds: number;
|
|
462
|
-
pid: number;
|
|
463
|
-
startToken?: string | undefined;
|
|
464
|
-
exitFile?: string | undefined;
|
|
465
|
-
note?: string | undefined;
|
|
466
|
-
result?: {
|
|
467
|
-
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
468
|
-
observedAt: string;
|
|
469
|
-
exitCode?: number | undefined;
|
|
470
|
-
exitFileNote?: "not-an-exit-code" | undefined;
|
|
471
|
-
diagnostic?: string | undefined;
|
|
472
|
-
} | undefined;
|
|
473
449
|
} | {
|
|
474
450
|
id: string;
|
|
475
451
|
source: "agent" | "cezar";
|
|
@@ -531,6 +507,30 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
531
507
|
reason: "outcome" | "timeout";
|
|
532
508
|
} | undefined;
|
|
533
509
|
wakeInputId?: string | undefined;
|
|
510
|
+
} | {
|
|
511
|
+
id: string;
|
|
512
|
+
source: "agent" | "cezar";
|
|
513
|
+
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
514
|
+
registeredAt: string;
|
|
515
|
+
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
516
|
+
resolvedAt?: string | undefined;
|
|
517
|
+
deliveredAt?: string | undefined;
|
|
518
|
+
cancelledAt?: string | undefined;
|
|
519
|
+
turnId: string;
|
|
520
|
+
kind: "process";
|
|
521
|
+
deadline: string;
|
|
522
|
+
timeoutSeconds: number;
|
|
523
|
+
pid: number;
|
|
524
|
+
startToken?: string | undefined;
|
|
525
|
+
exitFile?: string | undefined;
|
|
526
|
+
note?: string | undefined;
|
|
527
|
+
result?: {
|
|
528
|
+
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
529
|
+
observedAt: string;
|
|
530
|
+
exitCode?: number | undefined;
|
|
531
|
+
exitFileNote?: "not-an-exit-code" | undefined;
|
|
532
|
+
diagnostic?: string | undefined;
|
|
533
|
+
} | undefined;
|
|
534
534
|
} | {
|
|
535
535
|
id: string;
|
|
536
536
|
source: "agent" | "cezar";
|
|
@@ -658,30 +658,6 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
658
658
|
deadline: string;
|
|
659
659
|
seconds: number;
|
|
660
660
|
note?: string | undefined;
|
|
661
|
-
} | {
|
|
662
|
-
id: string;
|
|
663
|
-
source: "agent" | "cezar";
|
|
664
|
-
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
665
|
-
registeredAt: string;
|
|
666
|
-
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
667
|
-
resolvedAt?: string | undefined;
|
|
668
|
-
deliveredAt?: string | undefined;
|
|
669
|
-
cancelledAt?: string | undefined;
|
|
670
|
-
turnId: string;
|
|
671
|
-
kind: "process";
|
|
672
|
-
deadline: string;
|
|
673
|
-
timeoutSeconds: number;
|
|
674
|
-
pid: number;
|
|
675
|
-
startToken?: string | undefined;
|
|
676
|
-
exitFile?: string | undefined;
|
|
677
|
-
note?: string | undefined;
|
|
678
|
-
result?: {
|
|
679
|
-
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
680
|
-
observedAt: string;
|
|
681
|
-
exitCode?: number | undefined;
|
|
682
|
-
exitFileNote?: "not-an-exit-code" | undefined;
|
|
683
|
-
diagnostic?: string | undefined;
|
|
684
|
-
} | undefined;
|
|
685
661
|
} | {
|
|
686
662
|
id: string;
|
|
687
663
|
source: "agent" | "cezar";
|
|
@@ -743,6 +719,30 @@ export declare class RunArchiveTopic implements RunArchive, RunCompletionActions
|
|
|
743
719
|
reason: "outcome" | "timeout";
|
|
744
720
|
} | undefined;
|
|
745
721
|
wakeInputId?: string | undefined;
|
|
722
|
+
} | {
|
|
723
|
+
id: string;
|
|
724
|
+
source: "agent" | "cezar";
|
|
725
|
+
via: "ask-line" | "budget" | "cez-message-wait" | "cez-worker-wait" | "cezar_ask" | "cezar_wait" | "cezar_wait_for_ci" | "completion" | "monitoring-line" | "native-ask" | "native-subagents" | "no-wait" | "schedule-wakeup";
|
|
726
|
+
registeredAt: string;
|
|
727
|
+
phase: "cancelled" | "delivered" | "open" | "resolved";
|
|
728
|
+
resolvedAt?: string | undefined;
|
|
729
|
+
deliveredAt?: string | undefined;
|
|
730
|
+
cancelledAt?: string | undefined;
|
|
731
|
+
turnId: string;
|
|
732
|
+
kind: "process";
|
|
733
|
+
deadline: string;
|
|
734
|
+
timeoutSeconds: number;
|
|
735
|
+
pid: number;
|
|
736
|
+
startToken?: string | undefined;
|
|
737
|
+
exitFile?: string | undefined;
|
|
738
|
+
note?: string | undefined;
|
|
739
|
+
result?: {
|
|
740
|
+
outcome: "deadline" | "error" | "exit_file" | "exited";
|
|
741
|
+
observedAt: string;
|
|
742
|
+
exitCode?: number | undefined;
|
|
743
|
+
exitFileNote?: "not-an-exit-code" | undefined;
|
|
744
|
+
diagnostic?: string | undefined;
|
|
745
|
+
} | undefined;
|
|
746
746
|
} | {
|
|
747
747
|
id: string;
|
|
748
748
|
source: "agent" | "cezar";
|
|
@@ -17,6 +17,12 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
17
17
|
output: {
|
|
18
18
|
generation: string;
|
|
19
19
|
results: ({
|
|
20
|
+
projectId: string;
|
|
21
|
+
runId: string;
|
|
22
|
+
type: "error" | "reset";
|
|
23
|
+
status: 400 | 404 | 409 | 413 | 503;
|
|
24
|
+
error: string;
|
|
25
|
+
} | {
|
|
20
26
|
projectId: string;
|
|
21
27
|
runId: string;
|
|
22
28
|
type: "batch";
|
|
@@ -37,12 +43,6 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
37
43
|
cursor: string;
|
|
38
44
|
afterSeq: number;
|
|
39
45
|
hasMore: boolean;
|
|
40
|
-
} | {
|
|
41
|
-
projectId: string;
|
|
42
|
-
runId: string;
|
|
43
|
-
type: "error" | "reset";
|
|
44
|
-
status: 400 | 404 | 409 | 413 | 503;
|
|
45
|
-
error: string;
|
|
46
46
|
})[];
|
|
47
47
|
};
|
|
48
48
|
outputFormat: "json";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { artifactDirectory } from '../task-files/artifact-kind.js';
|
|
2
2
|
import { matchedRoutes } from 'hono/route';
|
|
3
3
|
import { delegationFailure } from '../delegation/routes.js';
|
|
4
|
-
import { DelegationPolicyError } from '../delegation
|
|
4
|
+
import { DelegationPolicyError } from '../core/delegation-error.js';
|
|
5
5
|
/** Logical deletion cannot expose a fallback copy. Legacy-only resource cleanup remains allowed. */
|
|
6
6
|
export function protectFallbackRun(kind) {
|
|
7
7
|
return async (context, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-run-files.js","sourceRoot":"","sources":["../../src/server/project-run-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"project-run-files.js","sourceRoot":"","sources":["../../src/server/project-run-files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