@almyty/runner 1.2.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/README.md +72 -0
- package/dist/binaries.d.ts +30 -0
- package/dist/binaries.js +99 -0
- package/dist/binaries.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.js +128 -0
- package/dist/cli.js.map +1 -0
- package/dist/coding-agents/detect.d.ts +12 -0
- package/dist/coding-agents/detect.js +35 -0
- package/dist/coding-agents/detect.js.map +1 -0
- package/dist/coding-agents/index.d.ts +15 -0
- package/dist/coding-agents/index.js +15 -0
- package/dist/coding-agents/index.js.map +1 -0
- package/dist/coding-agents/registry.d.ts +9 -0
- package/dist/coding-agents/registry.js +260 -0
- package/dist/coding-agents/registry.js.map +1 -0
- package/dist/coding-agents/spawn-spec.d.ts +47 -0
- package/dist/coding-agents/spawn-spec.js +58 -0
- package/dist/coding-agents/spawn-spec.js.map +1 -0
- package/dist/coding-agents/status.d.ts +38 -0
- package/dist/coding-agents/status.js +111 -0
- package/dist/coding-agents/status.js.map +1 -0
- package/dist/coding-agents/types.d.ts +104 -0
- package/dist/coding-agents/types.js +18 -0
- package/dist/coding-agents/types.js.map +1 -0
- package/dist/coding-sessions.d.ts +80 -0
- package/dist/coding-sessions.js +121 -0
- package/dist/coding-sessions.js.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.js +180 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon.d.ts +71 -0
- package/dist/daemon.js +353 -0
- package/dist/daemon.js.map +1 -0
- package/dist/handlers.d.ts +39 -0
- package/dist/handlers.js +299 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/policy.d.ts +16 -0
- package/dist/policy.js +134 -0
- package/dist/policy.js.map +1 -0
- package/dist/process-manager.d.ts +107 -0
- package/dist/process-manager.js +334 -0
- package/dist/process-manager.js.map +1 -0
- package/dist/protocol.d.ts +53 -0
- package/dist/protocol.js +39 -0
- package/dist/protocol.js.map +1 -0
- package/dist/runtime-info.d.ts +23 -0
- package/dist/runtime-info.js +35 -0
- package/dist/runtime-info.js.map +1 -0
- package/dist/streamable-client.d.ts +69 -0
- package/dist/streamable-client.js +204 -0
- package/dist/streamable-client.js.map +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
package/dist/daemon.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync, chmodSync } from 'fs';
|
|
2
|
+
import { homedir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { resolveCredentialsOrExit } from '@almyty/client';
|
|
5
|
+
import { loadConfig } from './config.js';
|
|
6
|
+
import { detectRuntimeInfo, RUNNER_VERSION } from './runtime-info.js';
|
|
7
|
+
import { createDefaultAdapterFactory, ProcessManager } from './process-manager.js';
|
|
8
|
+
import { StreamableClient, envelope } from './streamable-client.js';
|
|
9
|
+
import { dispatchHandler } from './handlers.js';
|
|
10
|
+
import { CodingSessionManager } from './coding-sessions.js';
|
|
11
|
+
const STATE_DIR = join(homedir(), '.almyty', 'runner');
|
|
12
|
+
const PID_FILE = join(STATE_DIR, 'daemon.pid');
|
|
13
|
+
const STATUS_FILE = join(STATE_DIR, 'status.json');
|
|
14
|
+
const HEARTBEAT_INTERVAL_MS = 30_000;
|
|
15
|
+
/** Backoff between session re-establish attempts after a 404 session-lost. */
|
|
16
|
+
const SESSION_LOST_BACKOFF_MS = [500, 1_000, 2_000, 5_000, 10_000];
|
|
17
|
+
/** Consecutive session-lost failures tolerated before exiting fatal. */
|
|
18
|
+
const MAX_SESSION_LOST_STREAK = 8;
|
|
19
|
+
/**
|
|
20
|
+
* Runner daemon. Responsibilities, in order:
|
|
21
|
+
*
|
|
22
|
+
* 1. Resolve config (defaults <- files <- env <- flags).
|
|
23
|
+
* 2. Resolve credentials (env <- ~/.almyty/credentials.json).
|
|
24
|
+
* 3. Detect runtime info + probe binaries.
|
|
25
|
+
* 4. POST /runners/register with the snapshot.
|
|
26
|
+
* 5. Open the Streamable HTTP stream and start dispatching incoming
|
|
27
|
+
* envelopes to handlers.
|
|
28
|
+
* 6. Heartbeat every 30s.
|
|
29
|
+
* 7. On SIGTERM / SIGINT: send a final shutdown envelope, wait
|
|
30
|
+
* briefly for in-flight responses, then exit.
|
|
31
|
+
*
|
|
32
|
+
* The daemon writes its PID and a status snapshot to ~/.almyty/runner/
|
|
33
|
+
* so `almyty runner status` and `almyty runner stop` can find it.
|
|
34
|
+
*/
|
|
35
|
+
export class RunnerDaemon {
|
|
36
|
+
resolved = null;
|
|
37
|
+
client = null;
|
|
38
|
+
processes = null;
|
|
39
|
+
coding = null;
|
|
40
|
+
runnerId = null;
|
|
41
|
+
heartbeatTimer = null;
|
|
42
|
+
status = null;
|
|
43
|
+
/** Guards against overlapping re-establish attempts. */
|
|
44
|
+
reestablishing = false;
|
|
45
|
+
/** Consecutive failed re-establish attempts; bounds the retry loop. */
|
|
46
|
+
sessionLostStreak = 0;
|
|
47
|
+
/**
|
|
48
|
+
* Bootstraps the daemon. Returns when the runner has registered and
|
|
49
|
+
* the stream is open. Errors here exit the process; caller is the
|
|
50
|
+
* CLI's `start` command, which doesn't try to recover from a failed
|
|
51
|
+
* register/connect — just prints and dies.
|
|
52
|
+
*/
|
|
53
|
+
async start(flags) {
|
|
54
|
+
const resolved = loadConfig({ flags });
|
|
55
|
+
this.resolved = resolved;
|
|
56
|
+
const credentials = resolveCredentialsOrExit();
|
|
57
|
+
const backendUrl = resolved.backendUrl || credentials.url;
|
|
58
|
+
process.stdout.write(`almyty-runner v${RUNNER_VERSION} starting\n`);
|
|
59
|
+
process.stdout.write(`name=${resolved.name} url=${backendUrl}\n`);
|
|
60
|
+
// Detect runtime info before anything else; if a probe hangs (e.g.
|
|
61
|
+
// a misbehaving node-pty install) we want to fail fast here rather
|
|
62
|
+
// than after registration has succeeded.
|
|
63
|
+
const runtime = await detectRuntimeInfo({ binaries: resolved.binaryProbeList });
|
|
64
|
+
process.stdout.write(`detected ${Object.values(runtime.binaries).filter(v => v).length}/${resolved.binaryProbeList.length} binaries on PATH\n`);
|
|
65
|
+
// Register over the existing REST endpoint (POST /runners/register).
|
|
66
|
+
// Streamable HTTP isn't used for registration itself — registration
|
|
67
|
+
// is a one-shot HTTP exchange that returns the runner row plus the
|
|
68
|
+
// effective config, which we use to confirm what limits the backend
|
|
69
|
+
// applied. After registration we switch to Streamable HTTP for the
|
|
70
|
+
// long-lived connection.
|
|
71
|
+
const regResp = await fetch(`${backendUrl}/runners/register`, {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
'Authorization': `Bearer ${credentials.token}`,
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
name: resolved.name,
|
|
79
|
+
labels: resolved.labels,
|
|
80
|
+
runtimeInfo: runtime,
|
|
81
|
+
config: resolved.config,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
if (!regResp.ok) {
|
|
85
|
+
const text = await regResp.text();
|
|
86
|
+
throw new Error(`register failed: ${regResp.status} ${text}`);
|
|
87
|
+
}
|
|
88
|
+
const regBody = await regResp.json();
|
|
89
|
+
this.runnerId = regBody.data.runner.id;
|
|
90
|
+
process.stdout.write(`registered as ${this.runnerId}\n`);
|
|
91
|
+
// Construct the process manager with the effective config (backend
|
|
92
|
+
// may have constrained max_concurrent below what we requested).
|
|
93
|
+
const effective = regBody.data.effectiveConfig;
|
|
94
|
+
this.processes = new ProcessManager(createDefaultAdapterFactory(), effective.maxConcurrent);
|
|
95
|
+
// Coding-session registry for the chat bridge. Output events are sent
|
|
96
|
+
// through the same streamable client the heartbeats ride; the client is
|
|
97
|
+
// captured lazily so construction order doesn't matter.
|
|
98
|
+
this.coding = new CodingSessionManager(this.processes, (payload) => {
|
|
99
|
+
void this.client?.send(envelope('event', payload)).catch((err) => {
|
|
100
|
+
process.stderr.write(`coding event send failed: ${err?.message ?? err}\n`);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
// Open the Streamable HTTP stream.
|
|
104
|
+
this.client = new StreamableClient({ baseUrl: backendUrl, token: credentials.token });
|
|
105
|
+
this.wireClient();
|
|
106
|
+
// First POST mints the session id; send a hello envelope so the
|
|
107
|
+
// backend's StreamableHttpTransport assigns one.
|
|
108
|
+
await this.client.send(envelope('event', { kind: 'runner.hello', runnerId: this.runnerId }));
|
|
109
|
+
await this.client.openStream();
|
|
110
|
+
// Heartbeat loop. This timer is deliberately REF'd: it is the daemon's
|
|
111
|
+
// keep-alive. The GET command stream can briefly drop (e.g. a reconnect
|
|
112
|
+
// after a wrong-replica 404), and during that gap the fetch handle is
|
|
113
|
+
// gone; if the heartbeat timer were unref'd, the event loop would drain
|
|
114
|
+
// and the process would exit(0) BEFORE the first heartbeat ever fired —
|
|
115
|
+
// so the runner could never report online. Keeping it ref'd holds the
|
|
116
|
+
// process up across stream gaps; SIGINT/SIGTERM clears it for a clean exit.
|
|
117
|
+
this.heartbeatTimer = setInterval(() => this.heartbeat().catch(err => {
|
|
118
|
+
process.stderr.write(`heartbeat failed: ${err.message}\n`);
|
|
119
|
+
}), HEARTBEAT_INTERVAL_MS);
|
|
120
|
+
// Send one immediately so the runner reports online within seconds rather
|
|
121
|
+
// than waiting a full interval for the first beat.
|
|
122
|
+
void this.heartbeat().catch(err => {
|
|
123
|
+
process.stderr.write(`initial heartbeat failed: ${err.message}\n`);
|
|
124
|
+
});
|
|
125
|
+
this.installSignalHandlers();
|
|
126
|
+
this.writeState({
|
|
127
|
+
pid: process.pid,
|
|
128
|
+
startedAt: new Date().toISOString(),
|
|
129
|
+
runnerName: resolved.name,
|
|
130
|
+
backendUrl,
|
|
131
|
+
runnerId: this.runnerId,
|
|
132
|
+
sessionId: this.client.getSessionId(),
|
|
133
|
+
inUseProcesses: 0,
|
|
134
|
+
connectionState: 'online',
|
|
135
|
+
});
|
|
136
|
+
process.stdout.write(`runner online; press ctrl-c to exit\n`);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Exit signal flow. On the first SIGINT/SIGTERM, transition to
|
|
140
|
+
* draining and inform the backend; on the second, hard exit.
|
|
141
|
+
*/
|
|
142
|
+
installSignalHandlers() {
|
|
143
|
+
let drainingSent = false;
|
|
144
|
+
const handle = (sig) => {
|
|
145
|
+
if (drainingSent) {
|
|
146
|
+
process.stderr.write(`\nsecond ${sig}; force exit\n`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
drainingSent = true;
|
|
150
|
+
process.stderr.write(`\n${sig} received; draining...\n`);
|
|
151
|
+
this.gracefulShutdown().finally(() => process.exit(0));
|
|
152
|
+
};
|
|
153
|
+
process.on('SIGINT', () => handle('SIGINT'));
|
|
154
|
+
process.on('SIGTERM', () => handle('SIGTERM'));
|
|
155
|
+
}
|
|
156
|
+
async gracefulShutdown() {
|
|
157
|
+
try {
|
|
158
|
+
if (this.heartbeatTimer)
|
|
159
|
+
clearInterval(this.heartbeatTimer);
|
|
160
|
+
if (this.client) {
|
|
161
|
+
await this.client.send(envelope('event', { kind: 'runner.draining' })).catch(() => { });
|
|
162
|
+
this.client.stop();
|
|
163
|
+
}
|
|
164
|
+
this.deleteState();
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
process.stderr.write(`shutdown error: ${err.message}\n`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
wireClient() {
|
|
171
|
+
if (!this.client)
|
|
172
|
+
return;
|
|
173
|
+
this.client.on('envelope', (env) => {
|
|
174
|
+
if (env.type === 'request') {
|
|
175
|
+
this.handleRequest(env).catch(err => {
|
|
176
|
+
process.stderr.write(`request handling error: ${err.message}\n`);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// Heartbeat / event envelopes from the server are observational;
|
|
180
|
+
// the runner doesn't react to them in v1.0.
|
|
181
|
+
});
|
|
182
|
+
this.client.on('reconnect', info => {
|
|
183
|
+
process.stderr.write(`reconnecting (attempt ${info.attempt}, delay ${info.delayMs}ms): ${info.reason}\n`);
|
|
184
|
+
this.updateState({ connectionState: 'reconnecting' });
|
|
185
|
+
});
|
|
186
|
+
this.client.on('open', () => {
|
|
187
|
+
this.updateState({ connectionState: 'online', sessionId: this.client?.getSessionId() ?? null });
|
|
188
|
+
});
|
|
189
|
+
this.client.on('session-lost', () => {
|
|
190
|
+
// The backend forgot our session (404 UNKNOWN_SESSION). The common
|
|
191
|
+
// cause is a multi-replica backend with pod-local streamable sessions:
|
|
192
|
+
// our mint-POST landed on one pod and the GET stream load-balanced to
|
|
193
|
+
// another that never saw the session. Exiting here was too fragile —
|
|
194
|
+
// a single wrong-replica hit killed the runner permanently. Instead,
|
|
195
|
+
// re-establish a fresh session (re-mint + reopen the stream). The
|
|
196
|
+
// client already cleared its session id, so the next send mints a new
|
|
197
|
+
// one; with backoff this lands on a consistent pod and stays online.
|
|
198
|
+
void this.reestablishSession();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async handleRequest(req) {
|
|
202
|
+
// Trust model: inbound requests are trusted at the CHANNEL level. The
|
|
203
|
+
// runner authenticates itself to the backend at registration, the
|
|
204
|
+
// command stream rides the resulting authenticated session, and the
|
|
205
|
+
// backend URL is required to be https for any non-loopback host (see
|
|
206
|
+
// config.ts), which closes the MITM / stream-injection vectors. We do
|
|
207
|
+
// NOT additionally verify a per-request signature here — that would
|
|
208
|
+
// defend against a *compromised backend* and needs a coordinated
|
|
209
|
+
// backend signing scheme (tracked separately). Each command is still
|
|
210
|
+
// gated by the execution policy (isolation/deny/cwd/env) before it runs.
|
|
211
|
+
if (!this.processes || !this.client || !this.resolved)
|
|
212
|
+
return;
|
|
213
|
+
const ctx = {
|
|
214
|
+
processes: this.processes,
|
|
215
|
+
runnerName: this.resolved.name,
|
|
216
|
+
labels: this.resolved.labels,
|
|
217
|
+
maxConcurrent: this.resolved.config.maxConcurrent,
|
|
218
|
+
config: this.resolved.config,
|
|
219
|
+
coding: this.coding ?? undefined,
|
|
220
|
+
};
|
|
221
|
+
const response = await dispatchHandler(ctx, req.payload);
|
|
222
|
+
await this.client.send(envelope('response', response, req.id));
|
|
223
|
+
}
|
|
224
|
+
async heartbeat() {
|
|
225
|
+
if (!this.client || !this.processes)
|
|
226
|
+
return;
|
|
227
|
+
const inUse = this.processes.inUse();
|
|
228
|
+
await this.client.send(envelope('heartbeat', { ts: Date.now(), inUse }));
|
|
229
|
+
this.updateState({ inUseProcesses: inUse });
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Re-establish the command stream after a session-lost (404). Re-mints a
|
|
233
|
+
* session (hello envelope) and reopens the GET stream, with backoff. Only
|
|
234
|
+
* gives up — exiting fatal — after MAX_SESSION_LOST_STREAK consecutive
|
|
235
|
+
* failures, so a transient wrong-replica hit recovers transparently while a
|
|
236
|
+
* genuinely-down backend still terminates rather than spinning forever.
|
|
237
|
+
*/
|
|
238
|
+
async reestablishSession() {
|
|
239
|
+
if (this.reestablishing || !this.client)
|
|
240
|
+
return;
|
|
241
|
+
this.reestablishing = true;
|
|
242
|
+
this.updateState({ connectionState: 'reconnecting' });
|
|
243
|
+
try {
|
|
244
|
+
this.sessionLostStreak++;
|
|
245
|
+
if (this.sessionLostStreak > MAX_SESSION_LOST_STREAK) {
|
|
246
|
+
process.stderr.write(`backend session lost ${this.sessionLostStreak}x in a row; giving up\n`);
|
|
247
|
+
this.updateState({ connectionState: 'fatal' });
|
|
248
|
+
process.exit(2);
|
|
249
|
+
}
|
|
250
|
+
const delay = SESSION_LOST_BACKOFF_MS[Math.min(this.sessionLostStreak - 1, SESSION_LOST_BACKOFF_MS.length - 1)];
|
|
251
|
+
process.stderr.write(`backend session lost; re-establishing in ${delay}ms (attempt ${this.sessionLostStreak})\n`);
|
|
252
|
+
await new Promise(r => setTimeout(r, delay));
|
|
253
|
+
// Re-mint a session (client already cleared the stale id) and reopen.
|
|
254
|
+
await this.client.send(envelope('event', { kind: 'runner.hello', runnerId: this.runnerId }));
|
|
255
|
+
await this.client.openStream();
|
|
256
|
+
// openStream's 'open' event resets connectionState to 'online'; a clean
|
|
257
|
+
// reopen means the streak is broken.
|
|
258
|
+
this.sessionLostStreak = 0;
|
|
259
|
+
this.updateState({ connectionState: 'online', sessionId: this.client.getSessionId() });
|
|
260
|
+
process.stdout.write('backend session re-established\n');
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
process.stderr.write(`re-establish failed: ${err?.message ?? err}\n`);
|
|
264
|
+
// Retry: openStream/send failures schedule the client's own reconnect,
|
|
265
|
+
// and another session-lost will re-enter here; release the guard so it can.
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
this.reestablishing = false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
writeState(s) {
|
|
272
|
+
// status.json holds the sessionId (bearer-equivalent for the command
|
|
273
|
+
// channel) — keep the dir and file owner-only.
|
|
274
|
+
mkdirSync(STATE_DIR, { recursive: true, mode: 0o700 });
|
|
275
|
+
try {
|
|
276
|
+
chmodSync(STATE_DIR, 0o700);
|
|
277
|
+
}
|
|
278
|
+
catch { /* best-effort */ }
|
|
279
|
+
writeFileSync(PID_FILE, String(s.pid));
|
|
280
|
+
writeFileSync(STATUS_FILE, JSON.stringify(s, null, 2), { mode: 0o600 });
|
|
281
|
+
try {
|
|
282
|
+
chmodSync(STATUS_FILE, 0o600);
|
|
283
|
+
}
|
|
284
|
+
catch { /* best-effort */ }
|
|
285
|
+
this.status = s;
|
|
286
|
+
}
|
|
287
|
+
updateState(patch) {
|
|
288
|
+
if (!this.status)
|
|
289
|
+
return;
|
|
290
|
+
this.status = { ...this.status, ...patch };
|
|
291
|
+
try {
|
|
292
|
+
writeFileSync(STATUS_FILE, JSON.stringify(this.status, null, 2));
|
|
293
|
+
}
|
|
294
|
+
catch { /* */ }
|
|
295
|
+
}
|
|
296
|
+
deleteState() {
|
|
297
|
+
try {
|
|
298
|
+
unlinkSync(PID_FILE);
|
|
299
|
+
}
|
|
300
|
+
catch { /* */ }
|
|
301
|
+
try {
|
|
302
|
+
unlinkSync(STATUS_FILE);
|
|
303
|
+
}
|
|
304
|
+
catch { /* */ }
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// ── status / stop helpers (used by CLI subcommands) ─────────────────
|
|
308
|
+
export function readStatus() {
|
|
309
|
+
try {
|
|
310
|
+
if (!existsSync(STATUS_FILE))
|
|
311
|
+
return null;
|
|
312
|
+
const raw = readFileSync(STATUS_FILE, 'utf-8');
|
|
313
|
+
const status = JSON.parse(raw);
|
|
314
|
+
if (!isAlive(status.pid)) {
|
|
315
|
+
// Stale state file: PID's gone.
|
|
316
|
+
try {
|
|
317
|
+
unlinkSync(STATUS_FILE);
|
|
318
|
+
}
|
|
319
|
+
catch { /* */ }
|
|
320
|
+
try {
|
|
321
|
+
unlinkSync(PID_FILE);
|
|
322
|
+
}
|
|
323
|
+
catch { /* */ }
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
return status;
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
export function stopDaemon() {
|
|
333
|
+
const status = readStatus();
|
|
334
|
+
if (!status)
|
|
335
|
+
return false;
|
|
336
|
+
try {
|
|
337
|
+
process.kill(status.pid, 'SIGTERM');
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function isAlive(pid) {
|
|
345
|
+
try {
|
|
346
|
+
process.kill(pid, 0);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=daemon.js.map
|
|
@@ -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B,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,gCAAgC;YAChC,IAAI,CAAC;gBAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,CAAC;gBAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1B,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ProcessManager } from './process-manager.js';
|
|
2
|
+
import { detectRuntimeInfo } from './runtime-info.js';
|
|
3
|
+
import { RequestPayload, ResponsePayload } from './protocol.js';
|
|
4
|
+
import { type ProbeExec } from './binaries.js';
|
|
5
|
+
import { CodingSessionManager } from './coding-sessions.js';
|
|
6
|
+
import { RunnerConfig } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Runner-side method dispatch. The protocol surface is the public
|
|
9
|
+
* v1.0 contract documented in the runner spec; method names are
|
|
10
|
+
* dotted strings ("process.spawn", "shell.exec", "runner.info").
|
|
11
|
+
*
|
|
12
|
+
* Every handler:
|
|
13
|
+
* - Pulls workspaceId out of the request payload (required for
|
|
14
|
+
* process.* and shell.*; optional for runner.info).
|
|
15
|
+
* - Validates params just enough to surface a typed error
|
|
16
|
+
* (RunnerError with a code) rather than crashing.
|
|
17
|
+
* - Returns a ResponsePayload with ok=true|false; the daemon wraps
|
|
18
|
+
* it in a `response` envelope and posts it back over the
|
|
19
|
+
* Streamable HTTP transport.
|
|
20
|
+
*
|
|
21
|
+
* Error mapping: unhandled exceptions become INTERNAL responses; any
|
|
22
|
+
* RunnerError surfaces with its own code intact so the agent can
|
|
23
|
+
* reason about retryability.
|
|
24
|
+
*/
|
|
25
|
+
export interface HandlerContext {
|
|
26
|
+
processes: ProcessManager;
|
|
27
|
+
runnerName: string;
|
|
28
|
+
labels: Record<string, string>;
|
|
29
|
+
maxConcurrent: number;
|
|
30
|
+
/** Runner execution policy (isolation, denyPatterns, cwd roots, …). */
|
|
31
|
+
config: RunnerConfig;
|
|
32
|
+
/** Test injection point for runner.info; returns the cached probe map. */
|
|
33
|
+
cachedRuntimeInfo?: Awaited<ReturnType<typeof detectRuntimeInfo>>;
|
|
34
|
+
/** Coding-session registry (chat-to-runner bridge); wired by the daemon. */
|
|
35
|
+
coding?: CodingSessionManager;
|
|
36
|
+
/** Test injection for coding.list's binary probing. */
|
|
37
|
+
probeExec?: ProbeExec;
|
|
38
|
+
}
|
|
39
|
+
export declare function dispatchHandler(ctx: HandlerContext, req: RequestPayload): Promise<ResponsePayload>;
|