@parall/daemon 1.60.0 → 1.62.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/bundle/manifest.json +11 -11
- package/bundle/parall-browser-pod.js +1960 -944
- package/bundle/parall-claude-agent.js +3753 -2072
- package/bundle/parall-codex-agent.js +3797 -2116
- package/bundle/parall-daemon.js +3770 -1773
- package/dist/config.d.ts +0 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -1
- package/dist/daemon-main.d.ts.map +1 -1
- package/dist/daemon-main.js +25 -5
- package/dist/daemon-telemetry.d.ts +83 -0
- package/dist/daemon-telemetry.d.ts.map +1 -0
- package/dist/daemon-telemetry.js +143 -0
- package/dist/launch-lifecycle.d.ts +49 -0
- package/dist/launch-lifecycle.d.ts.map +1 -0
- package/dist/launch-lifecycle.js +64 -0
- package/dist/launch-state.d.ts +72 -0
- package/dist/launch-state.d.ts.map +1 -0
- package/dist/launch-state.js +168 -0
- package/dist/runtime-bin-resolver.d.ts.map +1 -1
- package/dist/runtime-bin-resolver.js +2 -0
- package/dist/runtime-detector.d.ts.map +1 -1
- package/dist/runtime-detector.js +42 -5
- package/dist/runtime-report.d.ts +21 -0
- package/dist/runtime-report.d.ts.map +1 -0
- package/dist/runtime-report.js +41 -0
- package/dist/runtimes.d.ts.map +1 -1
- package/dist/runtimes.js +6 -1
- package/dist/supervisor.d.ts +32 -6
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +134 -20
- package/dist/updater.d.ts +5 -0
- package/dist/updater.d.ts.map +1 -1
- package/dist/updater.js +24 -0
- package/package.json +7 -6
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-agent launch lifecycle reporting (agent-health-alerting-design.md §4.6).
|
|
3
|
+
*
|
|
4
|
+
* The daemon is the only place that can see WHY an agent process failed to
|
|
5
|
+
* come up (spawn ENOENT, exit code, crash loop). It reports one row per
|
|
6
|
+
* (machine, agent) to `PUT /machines/me/agents/{agentId}/launch-state`:
|
|
7
|
+
*
|
|
8
|
+
* - only when the state CHANGES (spawn → launching, stable → running,
|
|
9
|
+
* exit → backoff / failed), plus
|
|
10
|
+
* - a replay of every current state on boot, on WS reconnect and every
|
|
11
|
+
* REPLAY_INTERVAL_MS, so a lost report never leaves the server on a
|
|
12
|
+
* stale state for long.
|
|
13
|
+
*
|
|
14
|
+
* Ordering on the server is (daemon_instance_id, seq): the instance id is a
|
|
15
|
+
* ULID minted at daemon start (its timestamp fences a restarted daemon's
|
|
16
|
+
* reports over a stale instance's late arrivals), seq is process-monotonic.
|
|
17
|
+
* Everything free-text (last_error, output_tail) is redacted before it
|
|
18
|
+
* leaves the process — stderr can echo env and provider error bodies.
|
|
19
|
+
*/
|
|
20
|
+
import { redactSecrets } from '@parall/agent-core';
|
|
21
|
+
export const LAUNCH_REPLAY_INTERVAL_MS = 10 * 60_000;
|
|
22
|
+
/** How much stderr tail travels with a backoff / failed report. */
|
|
23
|
+
export const LAUNCH_OUTPUT_TAIL_BYTES = 4096;
|
|
24
|
+
/**
|
|
25
|
+
* Backoff depth at which a still-restarting launch is reported as failed.
|
|
26
|
+
* Deliberately higher than the server's `model.LaunchFailedAttempts` (3),
|
|
27
|
+
* which already treats a backoff that deep as failed for readiness and
|
|
28
|
+
* alerting: the user is warned while the daemon is still retrying. Changing
|
|
29
|
+
* one without the other widens or collapses that early-warning window.
|
|
30
|
+
*/
|
|
31
|
+
export const LAUNCH_FAILED_ATTEMPTS = 5;
|
|
32
|
+
const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
33
|
+
function encodeBase32(value, length) {
|
|
34
|
+
let out = '';
|
|
35
|
+
let v = value;
|
|
36
|
+
for (let i = 0; i < length; i++) {
|
|
37
|
+
out = CROCKFORD[v % 32] + out;
|
|
38
|
+
v = Math.floor(v / 32);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A ULID (26 chars, Crockford base32): 48-bit millisecond timestamp + 80
|
|
44
|
+
* random bits. The server compares two daemon instances by the timestamp
|
|
45
|
+
* component, so the time prefix is the contract — not just uniqueness.
|
|
46
|
+
*/
|
|
47
|
+
export function newDaemonInstanceId(now = Date.now(), random) {
|
|
48
|
+
const rnd = random ?? Math.random;
|
|
49
|
+
const time = encodeBase32(now, 10);
|
|
50
|
+
let tail = '';
|
|
51
|
+
for (let i = 0; i < 16; i++)
|
|
52
|
+
tail += CROCKFORD[Math.floor(rnd() * 32)];
|
|
53
|
+
return time + tail;
|
|
54
|
+
}
|
|
55
|
+
/** Decode the millisecond timestamp of a ULID minted by newDaemonInstanceId. */
|
|
56
|
+
export function daemonInstanceTimestamp(id) {
|
|
57
|
+
let v = 0;
|
|
58
|
+
for (const ch of id.slice(0, 10))
|
|
59
|
+
v = v * 32 + CROCKFORD.indexOf(ch);
|
|
60
|
+
return v;
|
|
61
|
+
}
|
|
62
|
+
/** Fixed-size tail buffer for a child's stderr — never blocks the child. */
|
|
63
|
+
export class OutputTail {
|
|
64
|
+
limit;
|
|
65
|
+
chunks = [];
|
|
66
|
+
size = 0;
|
|
67
|
+
constructor(limit = LAUNCH_OUTPUT_TAIL_BYTES) {
|
|
68
|
+
this.limit = limit;
|
|
69
|
+
}
|
|
70
|
+
push(chunk) {
|
|
71
|
+
const buf = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
|
|
72
|
+
this.chunks.push(buf);
|
|
73
|
+
this.size += buf.length;
|
|
74
|
+
while (this.size > this.limit && this.chunks.length > 0) {
|
|
75
|
+
const head = this.chunks[0];
|
|
76
|
+
const excess = this.size - this.limit;
|
|
77
|
+
if (head.length <= excess) {
|
|
78
|
+
this.chunks.shift();
|
|
79
|
+
this.size -= head.length;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.chunks[0] = head.subarray(excess);
|
|
83
|
+
this.size -= excess;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
text() {
|
|
88
|
+
return Buffer.concat(this.chunks).toString('utf8');
|
|
89
|
+
}
|
|
90
|
+
reset() {
|
|
91
|
+
this.chunks = [];
|
|
92
|
+
this.size = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Tracks the last reported state per agent, sends on change, replays on
|
|
97
|
+
* demand. Reports are best-effort: a failed send is logged and the next
|
|
98
|
+
* change (or replay) carries the current truth.
|
|
99
|
+
*/
|
|
100
|
+
export class LaunchStateReporter {
|
|
101
|
+
client;
|
|
102
|
+
log;
|
|
103
|
+
instanceId;
|
|
104
|
+
seq = 0;
|
|
105
|
+
current = new Map();
|
|
106
|
+
redactValues;
|
|
107
|
+
constructor(client, log, opts = {}) {
|
|
108
|
+
this.client = client;
|
|
109
|
+
this.log = log;
|
|
110
|
+
this.instanceId = opts.instanceId ?? newDaemonInstanceId();
|
|
111
|
+
this.redactValues = opts.redactValues ?? [];
|
|
112
|
+
}
|
|
113
|
+
/** Report a state; a no-op when nothing changed since the last report. */
|
|
114
|
+
async update(agentId, next) {
|
|
115
|
+
const prev = this.current.get(agentId);
|
|
116
|
+
if (prev && sameState(prev, next))
|
|
117
|
+
return;
|
|
118
|
+
this.current.set(agentId, next);
|
|
119
|
+
await this.send(agentId, next);
|
|
120
|
+
}
|
|
121
|
+
/** Forget an agent (detached / shut down) so replays stop mentioning it. */
|
|
122
|
+
forget(agentId) {
|
|
123
|
+
this.current.delete(agentId);
|
|
124
|
+
}
|
|
125
|
+
/** Re-send every current state (boot, reconnect, periodic). */
|
|
126
|
+
async replayAll() {
|
|
127
|
+
for (const [agentId, state] of this.current) {
|
|
128
|
+
await this.send(agentId, state);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Current in-memory view (tests, diagnostics). */
|
|
132
|
+
snapshot(agentId) {
|
|
133
|
+
return this.current.get(agentId);
|
|
134
|
+
}
|
|
135
|
+
async send(agentId, state) {
|
|
136
|
+
this.seq += 1;
|
|
137
|
+
const report = {
|
|
138
|
+
status: state.status,
|
|
139
|
+
attempts: state.attempts,
|
|
140
|
+
last_exit_code: state.lastExitCode ?? null,
|
|
141
|
+
last_signal: state.lastSignal ?? null,
|
|
142
|
+
last_error: state.lastError ? this.clean(state.lastError, 500) : null,
|
|
143
|
+
output_tail: state.outputTail ? this.clean(state.outputTail, LAUNCH_OUTPUT_TAIL_BYTES) : null,
|
|
144
|
+
daemon_instance_id: this.instanceId,
|
|
145
|
+
seq: this.seq,
|
|
146
|
+
reported_at: new Date().toISOString(),
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
await this.client.reportAgentLaunchState(agentId, report);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
this.log.warn(`launch state report failed for ${agentId} (${state.status}): ${String(err)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
clean(text, limit) {
|
|
156
|
+
const redacted = redactSecrets(text, this.redactValues);
|
|
157
|
+
// Keep the END of the text: for a stderr tail the last lines are the
|
|
158
|
+
// ones that explain the exit.
|
|
159
|
+
return redacted.length > limit ? redacted.slice(redacted.length - limit) : redacted;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function sameState(a, b) {
|
|
163
|
+
return (a.status === b.status &&
|
|
164
|
+
a.attempts === b.attempts &&
|
|
165
|
+
(a.lastExitCode ?? null) === (b.lastExitCode ?? null) &&
|
|
166
|
+
(a.lastSignal ?? null) === (b.lastSignal ?? null) &&
|
|
167
|
+
(a.lastError ?? null) === (b.lastError ?? null));
|
|
168
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-bin-resolver.d.ts","sourceRoot":"","sources":["../src/runtime-bin-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-bin-resolver.d.ts","sourceRoot":"","sources":["../src/runtime-bin-resolver.ts"],"names":[],"mappings":"AAWA,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC,CAAC;AA6BF,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAkC,CAAC;AAEzF,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3E;AAKD,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,GAAG,EAAE,gBAAgB,EACrB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAAC,UAAU,CAiDnB;AAuJD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,eAAe,CA6DjB;AAyED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,EAAE,CAcV"}
|
|
@@ -2,6 +2,8 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as os from 'node:os';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
|
+
// Keyed by the SDK's closed CLI runtime set so the daemon cannot detect a
|
|
6
|
+
// runtime the report shape has no component for (and vice versa).
|
|
5
7
|
const RUNTIME_BINARIES = {
|
|
6
8
|
'claude-code': { command: 'claude', envVar: 'PRLL_CLAUDE_BIN' },
|
|
7
9
|
codex: { command: 'codex', envVar: 'PRLL_CODEX_BIN' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-detector.d.ts","sourceRoot":"","sources":["../src/runtime-detector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-detector.d.ts","sourceRoot":"","sources":["../src/runtime-detector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAOnD,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAuBF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,UAAU,GACzB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GAAG,IAAI,CAMvD;AAqDD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,GAAG,EAAE,cAAc,EACnB,UAAU,GAAE,OAAO,oBAA2C,GAC7D,OAAO,CAAC,eAAe,EAAE,CAAC,CAuC5B;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,OAAO,CASzF;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAK7E"}
|
package/dist/runtime-detector.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
+
import { redactSecrets } from '@parall/agent-core';
|
|
2
3
|
import { applyRuntimeBinaryEnv, DETECTABLE_RUNTIME_TYPES, runtimeBinaryEnvVar, } from './runtime-bin-resolver.js';
|
|
3
4
|
// The resolver logs per-runtime resolution lines meant for spawn time; during
|
|
4
5
|
// periodic detection they would repeat every interval, so detection summarizes
|
|
@@ -28,14 +29,38 @@ export function resolveRuntimeBinary(runtimeType, baseEnv) {
|
|
|
28
29
|
const binaryPath = env[envVar];
|
|
29
30
|
return binaryPath ? { binaryPath, env } : null;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* A short, human-first reason a `--version` probe failed: the spawn error
|
|
34
|
+
* code when the binary is unusable (ENOENT / EACCES), the exit status when
|
|
35
|
+
* it ran and refused, or the first line of stderr when that says more.
|
|
36
|
+
*/
|
|
37
|
+
function probeFailureReason(err, stderr) {
|
|
38
|
+
const firstLine = String(stderr ?? '')
|
|
39
|
+
.split(/\r?\n/)
|
|
40
|
+
.map((l) => l.trim())
|
|
41
|
+
.find((l) => l.length > 0);
|
|
42
|
+
const code = err.code;
|
|
43
|
+
if (typeof code === 'string' && code) {
|
|
44
|
+
return firstLine ? `${code}: ${firstLine}` : code;
|
|
45
|
+
}
|
|
46
|
+
if (typeof code === 'number') {
|
|
47
|
+
return firstLine ? `exit ${code}: ${firstLine}` : `exit ${code}`;
|
|
48
|
+
}
|
|
49
|
+
if (err.killed)
|
|
50
|
+
return 'timed out';
|
|
51
|
+
return firstLine || String(err.message ?? err);
|
|
52
|
+
}
|
|
31
53
|
function probeVersion(binaryPath, env) {
|
|
32
54
|
return new Promise((resolve) => {
|
|
33
55
|
execFile(IS_WIN32 ? quoteWin32Arg(binaryPath) : binaryPath, ['--version'],
|
|
34
56
|
// shell on Windows: same as the bridge spawn path — a `.cmd` shim can't
|
|
35
57
|
// be exec'd directly, and without it a healthy install probes 'broken'.
|
|
36
|
-
{ env, timeout: VERSION_PROBE_TIMEOUT_MS, windowsHide: true, shell: IS_WIN32 }, (err, stdout) => {
|
|
58
|
+
{ env, timeout: VERSION_PROBE_TIMEOUT_MS, windowsHide: true, shell: IS_WIN32 }, (err, stdout, stderr) => {
|
|
37
59
|
if (err) {
|
|
38
|
-
|
|
60
|
+
// The reason the probe failed is the whole point of the alert:
|
|
61
|
+
// "the CLI can't run" without it sends the reader to the machine
|
|
62
|
+
// page to find out what we already knew.
|
|
63
|
+
resolve({ ok: false, reason: probeFailureReason(err, stderr) });
|
|
39
64
|
return;
|
|
40
65
|
}
|
|
41
66
|
const line = String(stdout)
|
|
@@ -78,8 +103,19 @@ export async function detectRuntimes(baseEnv, log, resolveBin = resolveRuntimeBi
|
|
|
78
103
|
status: 'ok',
|
|
79
104
|
};
|
|
80
105
|
}
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
const reason = probe.reason ? `${probe.reason} (${bin.binaryPath})` : bin.binaryPath;
|
|
107
|
+
// The detail travels to the platform so the alert can say WHY, not
|
|
108
|
+
// just "it can't run". stderr can echo env, so redact ONCE here and
|
|
109
|
+
// use that same value for the local log too — the daemon log is a file
|
|
110
|
+
// on the user's disk and must not keep a credential the probe echoed.
|
|
111
|
+
// The server redacts again on the way in.
|
|
112
|
+
const detail = redactSecrets(reason, [baseEnv.PRLL_API_KEY ?? '']).slice(0, 300);
|
|
113
|
+
log.warn(`runtime detection: ${runtimeType} resolved at ${bin.binaryPath} but --version failed: ${detail}`);
|
|
114
|
+
return {
|
|
115
|
+
runtime_type: runtimeType,
|
|
116
|
+
status: 'broken',
|
|
117
|
+
detail,
|
|
118
|
+
};
|
|
83
119
|
}));
|
|
84
120
|
return entries.filter((e) => e !== null);
|
|
85
121
|
}
|
|
@@ -89,7 +125,8 @@ export function detectedRuntimesEqual(a, b) {
|
|
|
89
125
|
return false;
|
|
90
126
|
return a.every((x, i) => x.runtime_type === b[i].runtime_type &&
|
|
91
127
|
x.version === b[i].version &&
|
|
92
|
-
x.status === b[i].status
|
|
128
|
+
x.status === b[i].status &&
|
|
129
|
+
x.detail === b[i].detail);
|
|
93
130
|
}
|
|
94
131
|
export function summarizeDetectedRuntimes(detected) {
|
|
95
132
|
if (detected.length === 0)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DetectedRuntime, MachineRuntimeReportRequest } from '@parall/sdk';
|
|
2
|
+
export interface MachineRuntimeReportInput {
|
|
3
|
+
/** Running bundle / launcher version (undefined for bare npx runs). */
|
|
4
|
+
daemonVersion?: string;
|
|
5
|
+
/** Whether a service manager supervises the daemon (it can self-update). */
|
|
6
|
+
selfUpdateCapable: boolean;
|
|
7
|
+
/** Detection result — present CLIs only, as `detectRuntimes` returns it. */
|
|
8
|
+
detected: DetectedRuntime[];
|
|
9
|
+
/** The closed set of runtime types detection probes, in stable order. */
|
|
10
|
+
runtimeTypes: readonly string[];
|
|
11
|
+
nodeVersion?: string;
|
|
12
|
+
platform?: string;
|
|
13
|
+
osRelease?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the report body. Every probed runtime type yields a `cli:*` entry —
|
|
17
|
+
* `missing` when detection found nothing — so "detection ran, found nothing"
|
|
18
|
+
* stays distinguishable from "never ran" on the server.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildMachineRuntimeReport(input: MachineRuntimeReportInput): MachineRuntimeReportRequest;
|
|
21
|
+
//# sourceMappingURL=runtime-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-report.d.ts","sourceRoot":"","sources":["../src/runtime-report.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,2BAA2B,EAG5B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,yBAAyB;IACxC,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,iBAAiB,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,yEAAyE;IACzE,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,yBAAyB,GAC/B,2BAA2B,CA8B7B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Machine runtime report assembly (runtime-report-design.md): the daemon is
|
|
2
|
+
// the reporter for its Machine — its own version, the Node it runs on, the
|
|
3
|
+
// host OS, and every runtime CLI it can spawn. The server owns the closed
|
|
4
|
+
// sets and the version normalization; this module only shapes the facts.
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
/**
|
|
7
|
+
* Build the report body. Every probed runtime type yields a `cli:*` entry —
|
|
8
|
+
* `missing` when detection found nothing — so "detection ran, found nothing"
|
|
9
|
+
* stays distinguishable from "never ran" on the server.
|
|
10
|
+
*/
|
|
11
|
+
export function buildMachineRuntimeReport(input) {
|
|
12
|
+
const components = [];
|
|
13
|
+
if (input.daemonVersion) {
|
|
14
|
+
components.push({ component: 'daemon', version_raw: input.daemonVersion, status: 'ok' });
|
|
15
|
+
}
|
|
16
|
+
const nodeVersion = input.nodeVersion ?? process.versions.node;
|
|
17
|
+
if (nodeVersion) {
|
|
18
|
+
components.push({ component: 'node', version_raw: nodeVersion, status: 'ok' });
|
|
19
|
+
}
|
|
20
|
+
const platform = input.platform ?? process.platform;
|
|
21
|
+
const release = input.osRelease ?? os.release();
|
|
22
|
+
components.push({ component: 'os', version_raw: `${platform} ${release}`.trim(), status: 'ok' });
|
|
23
|
+
for (const runtimeType of input.runtimeTypes) {
|
|
24
|
+
const component = `cli:${runtimeType}`;
|
|
25
|
+
const found = input.detected.find((d) => d.runtime_type === runtimeType);
|
|
26
|
+
if (!found) {
|
|
27
|
+
components.push({ component, status: 'missing' });
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
components.push({
|
|
31
|
+
component,
|
|
32
|
+
...(found.version ? { version_raw: found.version } : {}),
|
|
33
|
+
...(found.detail ? { detail: found.detail } : {}),
|
|
34
|
+
status: found.status === 'ok' ? 'ok' : 'broken',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
components,
|
|
39
|
+
features: input.selfUpdateCapable ? ['self_update'] : [],
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/runtimes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../src/runtimes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAa,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,YAAY,EAAE,cAAc,EAAE,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,CACN,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,EAAE,CAAC,EAAE,cAAc,GAClB,MAAM,CAAC,UAAU,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../src/runtimes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAa,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,YAAY,EAAE,cAAc,EAAE,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,CACN,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,EAAE,CAAC,EAAE,cAAc,GAClB,MAAM,CAAC,UAAU,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA8GD,sEAAsE;AACtE,MAAM,WAAW,4BAA4B;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2CD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,4BAA4B,GAClC,cAAc,CAoBhB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAInD"}
|
package/dist/runtimes.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as os from 'node:os';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { clearAllProviderCreds, llmSource } from '@parall/agent-core';
|
|
6
|
-
import { resolveBundleDir } from './config.js';
|
|
6
|
+
import { daemonConfigDir, resolveBundleDir } from './config.js';
|
|
7
7
|
export { clearAllProviderCreds };
|
|
8
8
|
function buildStandardEnv(baseEnv, agentId, orgId, apiKey, dirs, pc) {
|
|
9
9
|
const env = { ...baseEnv };
|
|
@@ -16,6 +16,11 @@ function buildStandardEnv(baseEnv, agentId, orgId, apiKey, dirs, pc) {
|
|
|
16
16
|
env.PRLL_WORKSPACE_DIR = dirs.workspaceDir;
|
|
17
17
|
if (pc)
|
|
18
18
|
env.PRLL_PROVIDER_CONFIG = JSON.stringify(pc);
|
|
19
|
+
// Telemetry spool for the bridge (BYOC only — hosted pods never run this
|
|
20
|
+
// function), one directory per agent so two bridges never share one.
|
|
21
|
+
// Derived from the operator's real HOME / PRLL_DAEMON_CONFIG_DIR, i.e.
|
|
22
|
+
// before the fake HOME below would redirect it.
|
|
23
|
+
env.PRLL_OTEL_SPOOL_DIR = path.join(daemonConfigDir(baseEnv), 'otel-spool', `agent-${agentId}`);
|
|
19
24
|
// HOME isolation happens HERE and nowhere earlier: runtime binary
|
|
20
25
|
// resolution (applyRuntimeBinaryEnv) must see the operator's real HOME to
|
|
21
26
|
// derive nvm/Homebrew/pnpm paths, so the supervisor applies it to baseEnv
|
package/dist/supervisor.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type GatewayLogger } from '@parall/agent-core';
|
|
2
2
|
import { type ParallClient } from '@parall/sdk';
|
|
3
|
+
import { type DaemonTelemetry } from './daemon-telemetry.js';
|
|
3
4
|
import { type ClaudeDaemonConfig } from './config.js';
|
|
4
5
|
import { type LocalProfileControlPlaneDeps } from './local-profile-control.js';
|
|
5
6
|
import type { DaemonUpdater } from './updater.js';
|
|
@@ -39,6 +40,16 @@ export declare class DaemonSupervisor {
|
|
|
39
40
|
private ws;
|
|
40
41
|
private running;
|
|
41
42
|
private machineId;
|
|
43
|
+
/**
|
|
44
|
+
* Per-agent launch lifecycle reporter (agent-health-alerting-design.md
|
|
45
|
+
* §4.6). Created lazily: parameter properties (client, log) are not
|
|
46
|
+
* assigned yet when field initializers run.
|
|
47
|
+
*/
|
|
48
|
+
private launchStates;
|
|
49
|
+
private launchReplayTimer;
|
|
50
|
+
/** Process spawner — a seam so tests can drive the child lifecycle without real processes. */
|
|
51
|
+
private spawnProcess;
|
|
52
|
+
private get launch();
|
|
42
53
|
private machineOrgId;
|
|
43
54
|
private machineCreatedBy;
|
|
44
55
|
private machineLlmSource;
|
|
@@ -48,6 +59,7 @@ export declare class DaemonSupervisor {
|
|
|
48
59
|
private stopResolve;
|
|
49
60
|
private updater;
|
|
50
61
|
private healthGate;
|
|
62
|
+
private daemonTelemetry;
|
|
51
63
|
private browserProfilePool;
|
|
52
64
|
private localControl;
|
|
53
65
|
private clipManager;
|
|
@@ -55,6 +67,7 @@ export declare class DaemonSupervisor {
|
|
|
55
67
|
private clipReconcileTimer;
|
|
56
68
|
private clipReconcileInFlight;
|
|
57
69
|
private detectedRuntimes;
|
|
70
|
+
private runtimeReportViaLegacy;
|
|
58
71
|
private runtimeDetectTimer;
|
|
59
72
|
private runtimeDetectInFlight;
|
|
60
73
|
private detectRuntimesFn;
|
|
@@ -65,6 +78,8 @@ export declare class DaemonSupervisor {
|
|
|
65
78
|
/** Inject the process-level update health gate. The supervisor only feeds it
|
|
66
79
|
* fact signals (machine.hello, supervisor-ended); the gate owns confirm policy. */
|
|
67
80
|
setHealthGate(gate: PendingUpdateHealthGate): void;
|
|
81
|
+
/** Inject the process-level daemon metrics; the supervisor only reports facts into it. */
|
|
82
|
+
setDaemonTelemetry(telemetry: DaemonTelemetry): void;
|
|
68
83
|
/** Start the supervisor. Returns a promise that resolves on `stop()`. */
|
|
69
84
|
run(signal: AbortSignal): Promise<void>;
|
|
70
85
|
/** Disconnect WS, cancel timers, SIGTERM all children, await exit. */
|
|
@@ -120,14 +135,25 @@ export declare class DaemonSupervisor {
|
|
|
120
135
|
private startClipReconcileTimer;
|
|
121
136
|
private stopClipReconcileTimer;
|
|
122
137
|
/**
|
|
123
|
-
* Detect runtime CLIs on this host and
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* Serialized via `runtimeDetectInFlight` so a slow probe can't
|
|
128
|
-
* next interval tick and race the change comparison.
|
|
138
|
+
* Detect runtime CLIs on this host and report the machine's runtime report
|
|
139
|
+
* (daemon / node / os / CLIs + self-update capability). `initial` always
|
|
140
|
+
* reports; periodic runs report only when the detection result changed,
|
|
141
|
+
* keeping steady state write-free (the server also skips unchanged
|
|
142
|
+
* content). Serialized via `runtimeDetectInFlight` so a slow probe can't
|
|
143
|
+
* overlap the next interval tick and race the change comparison.
|
|
129
144
|
*/
|
|
130
145
|
private detectAndReportRuntimes;
|
|
146
|
+
/**
|
|
147
|
+
* Re-send the last detection result after the machine WS reconnects, but
|
|
148
|
+
* only when the previous report was taken by the legacy face: that is the
|
|
149
|
+
* one case where the server side may not hold the report (an old pod during
|
|
150
|
+
* a rolling deploy wrote the legacy columns). A reconnect usually means the
|
|
151
|
+
* server rolled, so the new pods get the report now; no re-probe, and the
|
|
152
|
+
* server skips the write when nothing changed.
|
|
153
|
+
*/
|
|
154
|
+
reportCachedRuntimeOnReconnect(): Promise<void>;
|
|
155
|
+
/** Send the runtime report; the SDK falls back to the legacy heartbeat on old servers. */
|
|
156
|
+
private reportMachineRuntime;
|
|
131
157
|
private machineClipToConfig;
|
|
132
158
|
private manifestFromMachineClip;
|
|
133
159
|
private dependencyMap;
|
package/dist/supervisor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAiBL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,KAAK,eAAe,EAAyC,MAAM,uBAAuB,CAAC;AAUpG,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,4BAA4B,EAElC,MAAM,4BAA4B,CAAC;AAepC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAs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