@parall/daemon 1.61.0 → 1.63.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.
Files changed (40) hide show
  1. package/bundle/manifest.json +11 -11
  2. package/bundle/parall-browser-pod.js +1690 -642
  3. package/bundle/parall-claude-agent.js +3617 -1937
  4. package/bundle/parall-codex-agent.js +3515 -1845
  5. package/bundle/parall-daemon.js +5099 -2284
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +75 -2
  8. package/dist/config.d.ts +4 -2
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +10 -3
  11. package/dist/daemon-main.d.ts.map +1 -1
  12. package/dist/daemon-main.js +25 -5
  13. package/dist/daemon-telemetry.d.ts +83 -0
  14. package/dist/daemon-telemetry.d.ts.map +1 -0
  15. package/dist/daemon-telemetry.js +143 -0
  16. package/dist/diagnostics.d.ts +127 -0
  17. package/dist/diagnostics.d.ts.map +1 -0
  18. package/dist/diagnostics.js +358 -0
  19. package/dist/launch-lifecycle.d.ts +49 -0
  20. package/dist/launch-lifecycle.d.ts.map +1 -0
  21. package/dist/launch-lifecycle.js +64 -0
  22. package/dist/launch-state.d.ts +72 -0
  23. package/dist/launch-state.d.ts.map +1 -0
  24. package/dist/launch-state.js +168 -0
  25. package/dist/runtime-bin-resolver.d.ts.map +1 -1
  26. package/dist/runtime-bin-resolver.js +2 -0
  27. package/dist/runtime-detector.d.ts.map +1 -1
  28. package/dist/runtime-detector.js +42 -5
  29. package/dist/runtime-report.d.ts +21 -0
  30. package/dist/runtime-report.d.ts.map +1 -0
  31. package/dist/runtime-report.js +41 -0
  32. package/dist/runtimes.d.ts.map +1 -1
  33. package/dist/runtimes.js +6 -1
  34. package/dist/supervisor.d.ts +32 -6
  35. package/dist/supervisor.d.ts.map +1 -1
  36. package/dist/supervisor.js +131 -17
  37. package/dist/updater.d.ts +19 -0
  38. package/dist/updater.d.ts.map +1 -1
  39. package/dist/updater.js +43 -15
  40. package/package.json +7 -6
@@ -1,4 +1,6 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { childExitReport, launchingReport, mintFailedReport, missingCredentialReport, restartMintFailedReport, runningReport, workspaceFailedReport, } from './launch-lifecycle.js';
3
+ import { LAUNCH_FAILED_ATTEMPTS, LAUNCH_REPLAY_INTERVAL_MS, LaunchStateReporter, OutputTail, } from './launch-state.js';
2
4
  import * as fs from 'node:fs';
3
5
  import * as os from 'node:os';
4
6
  import * as path from 'node:path';
@@ -7,6 +9,7 @@ import { describeWsStateDetail, ParallWs, } from '@parall/sdk';
7
9
  import { reconcileBrowserProfiles as runBrowserProfileReconcile } from './browser-profile-reconcile.js';
8
10
  import { handleBrowserProfileViewerCommand } from './browser-profile-viewer-control.js';
9
11
  import { PUBLIC_PROXY_PROBE_FALLBACK_URL } from './clip-runtime/browser-readiness.js';
12
+ import { classifyChildExit, computeClockSkewMs } from './daemon-telemetry.js';
10
13
  import { installClip, parseSource } from './clip-runtime/clip-installer.js';
11
14
  import { parseIpcCommands } from './clip-runtime/manifest.js';
12
15
  import { BrowserProfilePool, ClipProcessManager, ClipProvider, HubClient, } from './clip-runtime/index.js';
@@ -15,8 +18,9 @@ import { listDirectory } from './filesystem.js';
15
18
  import { startLocalProfileControl, } from './local-profile-control.js';
16
19
  import { ensureIsolatedHome, ensureSharedCredentialLink, } from './home-isolation.js';
17
20
  import { assertAgentKey, getRuntimeAdapter } from './runtimes.js';
18
- import { applyRuntimeBinaryEnv } from './runtime-bin-resolver.js';
21
+ import { applyRuntimeBinaryEnv, DETECTABLE_RUNTIME_TYPES } from './runtime-bin-resolver.js';
19
22
  import { detectedRuntimesEqual, detectRuntimes, summarizeDetectedRuntimes, } from './runtime-detector.js';
23
+ import { buildMachineRuntimeReport } from './runtime-report.js';
20
24
  import { prepareWorkspace } from './workspace.js';
21
25
  const RUNTIME_PACKAGES = {
22
26
  'claude-code': '@parall/claude-agent',
@@ -100,6 +104,23 @@ export class DaemonSupervisor {
100
104
  ws = null;
101
105
  running = false;
102
106
  machineId = null;
107
+ /**
108
+ * Per-agent launch lifecycle reporter (agent-health-alerting-design.md
109
+ * §4.6). Created lazily: parameter properties (client, log) are not
110
+ * assigned yet when field initializers run.
111
+ */
112
+ launchStates = null;
113
+ launchReplayTimer = null;
114
+ /** Process spawner — a seam so tests can drive the child lifecycle without real processes. */
115
+ spawnProcess = spawn;
116
+ get launch() {
117
+ if (!this.launchStates) {
118
+ this.launchStates = new LaunchStateReporter(this.client, this.log, {
119
+ redactValues: [this.config.apiKey],
120
+ });
121
+ }
122
+ return this.launchStates;
123
+ }
103
124
  machineOrgId = null;
104
125
  // machines.created_by — the machine owner. The local control socket's profile
105
126
  // commands are authorized against it (requester must BE the owner); kept
@@ -123,6 +144,7 @@ export class DaemonSupervisor {
123
144
  // adjacent fields — keep both. healthGate replaces the old healthConfirmed flag;
124
145
  // browserProfilePool replaces the old single browserProfileManager.
125
146
  healthGate = null;
147
+ daemonTelemetry = null;
126
148
  browserProfilePool = null;
127
149
  localControl = null;
128
150
  clipManager = null;
@@ -133,6 +155,9 @@ export class DaemonSupervisor {
133
155
  // periodically; only a CHANGED result re-posts the heartbeat so steady state
134
156
  // stays write-free server-side.
135
157
  detectedRuntimes = null;
158
+ // True when the last report reached the server through the legacy heartbeat
159
+ // face (old server); a reconnect then re-sends it in case the server rolled.
160
+ runtimeReportViaLegacy = false;
136
161
  runtimeDetectTimer = null;
137
162
  runtimeDetectInFlight = null;
138
163
  // Injectable for tests (real detection spawns --version subprocesses).
@@ -155,6 +180,10 @@ export class DaemonSupervisor {
155
180
  setHealthGate(gate) {
156
181
  this.healthGate = gate;
157
182
  }
183
+ /** Inject the process-level daemon metrics; the supervisor only reports facts into it. */
184
+ setDaemonTelemetry(telemetry) {
185
+ this.daemonTelemetry = telemetry;
186
+ }
158
187
  /** Start the supervisor. Returns a promise that resolves on `stop()`. */
159
188
  async run(signal) {
160
189
  if (this.running)
@@ -239,20 +268,33 @@ export class DaemonSupervisor {
239
268
  void this.detectAndReportRuntimes(false);
240
269
  }, RUNTIME_DETECT_INTERVAL_MS);
241
270
  this.runtimeDetectTimer.unref?.();
271
+ // Launch-state replay: a lost change report must not leave the server on
272
+ // a stale state for long (§4.6 — change-driven sends + periodic replay).
273
+ this.launchReplayTimer = setInterval(() => {
274
+ void this.launch.replayAll();
275
+ }, LAUNCH_REPLAY_INTERVAL_MS);
276
+ this.launchReplayTimer.unref?.();
242
277
  await this.fullReconcile();
243
278
  this.ws = new ParallWs({
244
279
  getTicket: () => this.client.getMachineWsTicket(),
245
280
  wsUrl: this.config.wsUrl,
246
281
  reconnect: true,
247
282
  });
248
- this.ws.on('machine.hello', (_data) => {
249
- this.log.info('machine WS connected (machine.hello)');
283
+ this.ws.on('machine.hello', (data) => {
284
+ const skewMs = computeClockSkewMs(data.server_time, Date.now());
285
+ this.log.info(`machine WS connected (machine.hello)${skewMs === null ? '' : ` skew=${skewMs}ms`}`);
286
+ if (skewMs !== null)
287
+ this.daemonTelemetry?.recordClockSkew(skewMs);
250
288
  // Control-plane handshake fact — the health gate (process-level) owns the
251
289
  // confirm / stability-window policy; the supervisor just reports the event.
252
290
  this.healthGate?.onMachineHello();
291
+ // Reconnect replay (§4.6): reports sent while the control plane was
292
+ // unreachable may have been lost — resend every current launch state.
293
+ void this.launch.replayAll();
253
294
  void (async () => {
254
295
  await this.refreshMachineConfig();
255
296
  await this.fullReconcile();
297
+ await this.reportCachedRuntimeOnReconnect();
256
298
  })();
257
299
  });
258
300
  this.ws.on('machine.update', (data) => {
@@ -326,6 +368,9 @@ export class DaemonSupervisor {
326
368
  if (state === 'disconnected' || state === 'reconnecting') {
327
369
  this.log.warn(`machine WS state: ${state}${describeWsStateDetail(detail)}`);
328
370
  }
371
+ if (state === 'reconnecting') {
372
+ this.daemonTelemetry?.recordWsReconnect({ cause: detail?.cause, closeCode: detail?.code });
373
+ }
329
374
  });
330
375
  await this.ws.connect();
331
376
  await new Promise((resolve) => {
@@ -363,6 +408,10 @@ export class DaemonSupervisor {
363
408
  clearInterval(this.runtimeDetectTimer);
364
409
  this.runtimeDetectTimer = null;
365
410
  }
411
+ if (this.launchReplayTimer) {
412
+ clearInterval(this.launchReplayTimer);
413
+ this.launchReplayTimer = null;
414
+ }
366
415
  for (const state of this.children.values()) {
367
416
  state.shuttingDown = true;
368
417
  if (state.restartTimer) {
@@ -968,12 +1017,12 @@ export class DaemonSupervisor {
968
1017
  this.clipReconcileTimer = null;
969
1018
  }
970
1019
  /**
971
- * Detect runtime CLIs on this host and heartbeat the result. `initial`
972
- * always reports (it also carries daemon version + self-update capability,
973
- * replacing the old version-only startup heartbeat); periodic runs report
974
- * only when the detection result changed, keeping steady state write-free.
975
- * Serialized via `runtimeDetectInFlight` so a slow probe can't overlap the
976
- * next interval tick and race the change comparison.
1020
+ * Detect runtime CLIs on this host and report the machine's runtime report
1021
+ * (daemon / node / os / CLIs + self-update capability). `initial` always
1022
+ * reports; periodic runs report only when the detection result changed,
1023
+ * keeping steady state write-free (the server also skips unchanged
1024
+ * content). Serialized via `runtimeDetectInFlight` so a slow probe can't
1025
+ * overlap the next interval tick and race the change comparison.
977
1026
  */
978
1027
  detectAndReportRuntimes(initial) {
979
1028
  if (this.runtimeDetectInFlight)
@@ -984,11 +1033,7 @@ export class DaemonSupervisor {
984
1033
  if (!initial && !changed)
985
1034
  return;
986
1035
  this.log.info(`runtime detection: ${summarizeDetectedRuntimes(detected)}`);
987
- await this.client.postMachineHeartbeat({
988
- daemonVersion: this.updater?.getLocalVersion(),
989
- selfUpdateCapable: this.updater != null,
990
- detectedRuntimes: detected,
991
- });
1036
+ await this.reportMachineRuntime(detected);
992
1037
  // Commit the comparison baseline only after a successful post — a failed
993
1038
  // report must stay "changed" so the next tick retries it instead of
994
1039
  // silently dropping the result until the CLI set happens to change again.
@@ -1001,6 +1046,37 @@ export class DaemonSupervisor {
1001
1046
  });
1002
1047
  return this.runtimeDetectInFlight;
1003
1048
  }
1049
+ /**
1050
+ * Re-send the last detection result after the machine WS reconnects, but
1051
+ * only when the previous report was taken by the legacy face: that is the
1052
+ * one case where the server side may not hold the report (an old pod during
1053
+ * a rolling deploy wrote the legacy columns). A reconnect usually means the
1054
+ * server rolled, so the new pods get the report now; no re-probe, and the
1055
+ * server skips the write when nothing changed.
1056
+ */
1057
+ async reportCachedRuntimeOnReconnect() {
1058
+ if (!this.runtimeReportViaLegacy ||
1059
+ this.detectedRuntimes == null ||
1060
+ this.runtimeDetectInFlight) {
1061
+ return;
1062
+ }
1063
+ try {
1064
+ await this.reportMachineRuntime(this.detectedRuntimes);
1065
+ }
1066
+ catch (err) {
1067
+ this.log.warn(`runtime report on reconnect failed: ${String(err)}`);
1068
+ }
1069
+ }
1070
+ /** Send the runtime report; the SDK falls back to the legacy heartbeat on old servers. */
1071
+ async reportMachineRuntime(detected) {
1072
+ const via = await this.client.putMachineRuntimeReport(buildMachineRuntimeReport({
1073
+ daemonVersion: this.updater?.getLocalVersion(),
1074
+ selfUpdateCapable: this.updater != null,
1075
+ detected,
1076
+ runtimeTypes: DETECTABLE_RUNTIME_TYPES,
1077
+ }));
1078
+ this.runtimeReportViaLegacy = via === 'legacy';
1079
+ }
1004
1080
  machineClipToConfig(clip) {
1005
1081
  const clipPath = path.join(this.config.rootStateDir, 'clips', clip.alias);
1006
1082
  return {
@@ -1425,6 +1501,7 @@ export class DaemonSupervisor {
1425
1501
  }
1426
1502
  catch (err) {
1427
1503
  this.log.warn(`agent ${state.agentId}: restart mint failed (${reason}): ${String(err)}`);
1504
+ let retrying = false;
1428
1505
  // The old child is already terminated and no crash-backoff timer exists
1429
1506
  // here — without a retry the agent stays down until the next reconcile
1430
1507
  // or event. Re-enter through restartChildNow (re-mints the credential)
@@ -1436,12 +1513,14 @@ export class DaemonSupervisor {
1436
1513
  !state.restartTimer) {
1437
1514
  const delay = Math.min(this.config.restartBackoffMs * 2 ** state.restartAttempts, this.config.restartBackoffMaxMs);
1438
1515
  state.restartAttempts += 1;
1516
+ retrying = true;
1439
1517
  this.log.warn(`agent ${state.agentId}: will retry restart in ${delay}ms`);
1440
1518
  state.restartTimer = setTimeout(() => {
1441
1519
  state.restartTimer = null;
1442
1520
  void this.restartChildNow(state, reason);
1443
1521
  }, delay);
1444
1522
  }
1523
+ void this.launch.update(state.agentId, restartMintFailedReport(err, state.restartAttempts, retrying));
1445
1524
  }
1446
1525
  finally {
1447
1526
  this.restartingStates.delete(state);
@@ -1508,6 +1587,7 @@ export class DaemonSupervisor {
1508
1587
  }
1509
1588
  catch (err) {
1510
1589
  this.log.error(`mintLaunchCredential ${agentId} failed: ${String(err)}`);
1590
+ void this.launch.update(agentId, mintFailedReport(err));
1511
1591
  return;
1512
1592
  }
1513
1593
  const stateDir = agentStateDirFor(this.config.rootStateDir, agentId);
@@ -1540,6 +1620,7 @@ export class DaemonSupervisor {
1540
1620
  }
1541
1621
  catch (err) {
1542
1622
  this.log.error(`agent ${agentId}: workspace setup failed: ${String(err)}`);
1623
+ void this.launch.update(agentId, workspaceFailedReport(err));
1543
1624
  return;
1544
1625
  }
1545
1626
  if (this.cancelledSpawns.delete(agentId)) {
@@ -1579,6 +1660,7 @@ export class DaemonSupervisor {
1579
1660
  return;
1580
1661
  if (!state.credential) {
1581
1662
  this.log.error(`startChild ${state.agentId}: no credential — bug`);
1663
+ void this.launch.update(state.agentId, missingCredentialReport(state.restartAttempts));
1582
1664
  return;
1583
1665
  }
1584
1666
  assertAgentKey(state.credential.api_key);
@@ -1639,11 +1721,21 @@ export class DaemonSupervisor {
1639
1721
  const env = adapter.buildEnv(baseEnv, state.agentId, state.orgId, state.credential.api_key, dirs, effectiveProviderConfig);
1640
1722
  const spawnCmd = adapter.args.length > 0 ? `${adapter.bin} ${adapter.args.join(' ')}` : adapter.bin;
1641
1723
  this.log.info(`spawning agent ${state.agentId} runtime=${state.runtimeType} cmd=${spawnCmd} (attempt ${state.restartAttempts + 1})`);
1642
- const child = spawn(adapter.bin, adapter.args, {
1724
+ void this.launch.update(state.agentId, launchingReport(state.restartAttempts));
1725
+ // stderr is piped (not inherited) so a crash's last lines can travel with
1726
+ // the backoff / failed report; every chunk is still echoed to the daemon's
1727
+ // own stderr, and the pipe is drained continuously so the child never
1728
+ // blocks on it. stdout stays inherited — the bridges log there.
1729
+ const stderrTail = new OutputTail();
1730
+ const child = this.spawnProcess(adapter.bin, adapter.args, {
1643
1731
  env,
1644
- stdio: ['ignore', 'inherit', 'inherit'],
1732
+ stdio: ['ignore', 'inherit', 'pipe'],
1645
1733
  detached: false,
1646
1734
  });
1735
+ child.stderr?.on('data', (chunk) => {
1736
+ stderrTail.push(chunk);
1737
+ process.stderr.write(chunk);
1738
+ });
1647
1739
  state.child = child;
1648
1740
  let childSettled = false;
1649
1741
  const settleChild = (event, code, signal, err) => {
@@ -1660,11 +1752,30 @@ export class DaemonSupervisor {
1660
1752
  else {
1661
1753
  this.log.info(`agent ${state.agentId} exited code=${code ?? 'null'} signal=${signal ?? 'null'}${wasShutting ? ' (shutting down)' : ''}`);
1662
1754
  }
1663
- if (wasShutting || !this.running)
1755
+ const restart = !(wasShutting || !this.running);
1756
+ this.daemonTelemetry?.recordChildExit({
1757
+ runtimeType: state.runtimeType,
1758
+ exitKind: classifyChildExit(code, signal, err),
1759
+ restart,
1760
+ });
1761
+ if (!restart) {
1762
+ // Deliberate stop (detach, respawn, shutdown): the next spawn reports
1763
+ // `launching` again, so drop the entry from the replay set now.
1764
+ this.launch.forget(state.agentId);
1664
1765
  return;
1766
+ }
1665
1767
  const delay = Math.min(this.config.restartBackoffMs * 2 ** state.restartAttempts, this.config.restartBackoffMaxMs);
1666
1768
  state.restartAttempts += 1;
1667
1769
  this.log.warn(`agent ${state.agentId} will restart in ${delay}ms`);
1770
+ // The restart loop itself is unchanged — the report only makes it visible.
1771
+ void this.launch.update(state.agentId, childExitReport({
1772
+ err,
1773
+ attempts: state.restartAttempts,
1774
+ failedAttempts: LAUNCH_FAILED_ATTEMPTS,
1775
+ code,
1776
+ signal,
1777
+ outputTail: stderrTail.text(),
1778
+ }));
1668
1779
  state.restartTimer = setTimeout(() => {
1669
1780
  state.restartTimer = null;
1670
1781
  this.startChild(state);
@@ -1696,6 +1807,9 @@ export class DaemonSupervisor {
1696
1807
  const stableTimer = setTimeout(() => {
1697
1808
  if (state.child === child) {
1698
1809
  state.restartAttempts = 0;
1810
+ // Alive for the stability window; the bridge's own WS presence is
1811
+ // the authoritative "connected" fact.
1812
+ void this.launch.update(state.agentId, runningReport());
1699
1813
  }
1700
1814
  }, Math.max(this.config.restartBackoffMs, 30_000));
1701
1815
  stableTimer.unref?.();
package/dist/updater.d.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  import type { GatewayLogger } from '@parall/agent-core';
2
+ import type { UpdateOutcome, UpdateReason } from './daemon-telemetry.js';
2
3
  import { type LocalManifest } from './updater-manifest.js';
4
+ export interface UpdateState {
5
+ confirmed_version?: string;
6
+ confirmed_at?: string;
7
+ previous_version?: string;
8
+ pending_version?: string;
9
+ pending_at?: string;
10
+ boot_count?: number;
11
+ rollback_from?: string;
12
+ rollback_at?: string;
13
+ }
3
14
  export declare class DaemonUpdater {
4
15
  private readonly bundleDir;
5
16
  private readonly cdnBaseUrl;
@@ -7,7 +18,11 @@ export declare class DaemonUpdater {
7
18
  private readonly signingEnabled;
8
19
  private updating;
9
20
  private periodicTimer;
21
+ private reportOutcome;
10
22
  constructor(bundleDir: string, cdnBaseUrl: string, log: GatewayLogger, signingEnabled: boolean);
23
+ /** Receive every update outcome (applied / failed / skipped / rolled_back / confirmed) as it happens. */
24
+ setOutcomeReporter(fn: (outcome: UpdateOutcome, reason?: UpdateReason) => void): void;
25
+ private report;
11
26
  /**
12
27
  * Start periodic update checks. Call once after supervisor bootstrap.
13
28
  */
@@ -68,4 +83,8 @@ export declare class DaemonUpdater {
68
83
  private downloadFile;
69
84
  private cleanDir;
70
85
  }
86
+ /** `<bundleDir>/current/manifest.json`, or null when absent or unreadable. */
87
+ export declare function loadLocalManifest(bundleDir: string): LocalManifest | null;
88
+ /** `<bundleDir>/update-state.json`, or null when absent or unreadable. */
89
+ export declare function loadUpdateState(bundleDir: string): UpdateState | null;
71
90
  //# sourceMappingURL=updater.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAC;AA2B/B,qBAAa,aAAa;IAKtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAPjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA+B;gBAGjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,OAAO;IAK1C;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAU5C,iBAAiB,IAAI,IAAI;IAOzB;;;OAGG;IACG,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAa7D;;OAEG;IACG,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQhF;;;;;;OAMG;IACH,aAAa,CAAC,eAAe,EAAE,OAAO,GAAG,OAAO;IAqDhD;;;OAGG;IACH,cAAc,IAAI,IAAI;IAYtB;;OAEG;IACH,eAAe,IAAI,MAAM,GAAG,SAAS;IAIrC;;;;OAIG;IACH,oBAAoB,IAAI,OAAO;IAM/B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,SAAS,EAAE,OAAO,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,a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Q;CAKjB;AAID,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAEzE;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAErE"}
package/dist/updater.js CHANGED
@@ -22,6 +22,7 @@ export class DaemonUpdater {
22
22
  signingEnabled;
23
23
  updating = false;
24
24
  periodicTimer = null;
25
+ reportOutcome = null;
25
26
  constructor(bundleDir, cdnBaseUrl, log, signingEnabled) {
26
27
  this.bundleDir = bundleDir;
27
28
  this.cdnBaseUrl = cdnBaseUrl;
@@ -29,6 +30,13 @@ export class DaemonUpdater {
29
30
  this.signingEnabled = signingEnabled;
30
31
  }
31
32
  // --- Public API ---
33
+ /** Receive every update outcome (applied / failed / skipped / rolled_back / confirmed) as it happens. */
34
+ setOutcomeReporter(fn) {
35
+ this.reportOutcome = fn;
36
+ }
37
+ report(outcome, reason) {
38
+ this.reportOutcome?.(outcome, reason);
39
+ }
32
40
  /**
33
41
  * Start periodic update checks. Call once after supervisor bootstrap.
34
42
  */
@@ -61,6 +69,7 @@ export class DaemonUpdater {
61
69
  }
62
70
  catch (err) {
63
71
  this.log.warn(`update check failed: ${String(err)}`);
72
+ this.report('failed', 'exception');
64
73
  return false;
65
74
  }
66
75
  finally {
@@ -131,6 +140,8 @@ export class DaemonUpdater {
131
140
  state.rollback_from = current.version;
132
141
  state.rollback_at = new Date().toISOString();
133
142
  this.saveUpdateState(state);
143
+ // Only once the swap and the state write both landed.
144
+ this.report('rolled_back', 'boot_threshold');
134
145
  return true;
135
146
  }
136
147
  /**
@@ -148,6 +159,7 @@ export class DaemonUpdater {
148
159
  state.boot_count = 0;
149
160
  this.saveUpdateState(state);
150
161
  this.log.info(`update: confirmed version ${current.version}`);
162
+ this.report('confirmed');
151
163
  }
152
164
  /**
153
165
  * Get the current local manifest version (for heartbeat reporting).
@@ -200,6 +212,7 @@ export class DaemonUpdater {
200
212
  // an unconfirmed intermediate bundle.
201
213
  if (state?.pending_version && local?.version === state.pending_version) {
202
214
  this.log.info(`update: ${local.version} is still pending activation — skipping new update until confirmed`);
215
+ this.report('skipped', 'pending_activation');
203
216
  return false;
204
217
  }
205
218
  const manifestUrl = targetVersion
@@ -211,6 +224,7 @@ export class DaemonUpdater {
211
224
  }
212
225
  catch (err) {
213
226
  this.log.warn(`update: failed to fetch manifest from ${manifestUrl}: ${String(err)}`);
227
+ this.report('failed', 'manifest_fetch');
214
228
  return false;
215
229
  }
216
230
  let remote;
@@ -219,6 +233,7 @@ export class DaemonUpdater {
219
233
  }
220
234
  catch {
221
235
  this.log.warn('update: failed to parse remote manifest');
236
+ this.report('failed', 'manifest_parse');
222
237
  return false;
223
238
  }
224
239
  // Reject same or older versions (downgrade protection)
@@ -230,16 +245,19 @@ export class DaemonUpdater {
230
245
  // Skip versions we already rolled back from
231
246
  if (state?.rollback_from === remote.version) {
232
247
  this.log.info(`update: skipping ${remote.version} (previously rolled back)`);
248
+ this.report('skipped', 'previously_rolled_back');
233
249
  return false;
234
250
  }
235
251
  // Verify Ed25519 signature (fail-closed: reject when key is missing)
236
252
  if (this.signingEnabled) {
237
253
  if (!SIGNING_PUBLIC_KEY) {
238
254
  this.log.error('update: signing enabled but PRLL_DAEMON_SIGNING_PUBLIC_KEY is empty — rejecting update');
255
+ this.report('failed', 'signing_key_missing');
239
256
  return false;
240
257
  }
241
258
  if (!verifyManifestSignature(remote, SIGNING_PUBLIC_KEY)) {
242
259
  this.log.error(`update: signature verification failed for ${remote.version}`);
260
+ this.report('failed', 'signature');
243
261
  return false;
244
262
  }
245
263
  }
@@ -248,10 +266,12 @@ export class DaemonUpdater {
248
266
  const cmp = semverCompare(process.versions.node, remote.min_node_version);
249
267
  if (cmp === null) {
250
268
  this.log.warn(`update: invalid min_node_version "${remote.min_node_version}" in manifest for ${remote.version} — skipping`);
269
+ this.report('failed', 'node_version_invalid');
251
270
  return false;
252
271
  }
253
272
  if (cmp < 0) {
254
273
  this.log.warn(`update: ${remote.version} requires Node >= ${remote.min_node_version}, running ${process.versions.node} — skipping`);
274
+ this.report('skipped', 'node_version');
255
275
  return false;
256
276
  }
257
277
  }
@@ -268,6 +288,7 @@ export class DaemonUpdater {
268
288
  catch (err) {
269
289
  this.log.error(`update: download failed for ${filename}: ${String(err)}`);
270
290
  this.cleanDir(stagingDir);
291
+ this.report('failed', 'download');
271
292
  return false;
272
293
  }
273
294
  // Verify sha256
@@ -276,12 +297,14 @@ export class DaemonUpdater {
276
297
  if (hash !== meta.sha256) {
277
298
  this.log.error(`update: sha256 mismatch for ${filename} (expected ${meta.sha256}, got ${hash})`);
278
299
  this.cleanDir(stagingDir);
300
+ this.report('failed', 'sha256_mismatch');
279
301
  return false;
280
302
  }
281
303
  // Verify size
282
304
  if (content.length !== meta.size) {
283
305
  this.log.error(`update: size mismatch for ${filename} (expected ${meta.size}, got ${content.length})`);
284
306
  this.cleanDir(stagingDir);
307
+ this.report('failed', 'size_mismatch');
285
308
  return false;
286
309
  }
287
310
  }
@@ -311,6 +334,7 @@ export class DaemonUpdater {
311
334
  // Atomic swap — only after the pending state is durably recorded.
312
335
  this.atomicSwap(stagingDir, remote.version);
313
336
  this.log.info(`update: ${local?.version ?? 'unknown'} → ${remote.version} applied, restarting`);
337
+ this.report('applied');
314
338
  return true;
315
339
  }
316
340
  atomicSwap(stagingDir, newVersion) {
@@ -374,23 +398,10 @@ export class DaemonUpdater {
374
398
  }
375
399
  // --- Manifest & State I/O ---
376
400
  loadLocalManifest() {
377
- const currentDir = path.join(this.bundleDir, 'current');
378
- const manifestPath = path.join(currentDir, 'manifest.json');
379
- try {
380
- return JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
381
- }
382
- catch {
383
- return null;
384
- }
401
+ return loadLocalManifest(this.bundleDir);
385
402
  }
386
403
  loadUpdateState() {
387
- const statePath = path.join(this.bundleDir, 'update-state.json');
388
- try {
389
- return JSON.parse(fs.readFileSync(statePath, 'utf-8'));
390
- }
391
- catch {
392
- return null;
393
- }
404
+ return loadUpdateState(this.bundleDir);
394
405
  }
395
406
  saveUpdateState(state) {
396
407
  const statePath = path.join(this.bundleDir, 'update-state.json');
@@ -534,3 +545,20 @@ export class DaemonUpdater {
534
545
  catch { }
535
546
  }
536
547
  }
548
+ // --- Bundle-dir layout readers (shared with the diagnostics collector) ---
549
+ /** `<bundleDir>/current/manifest.json`, or null when absent or unreadable. */
550
+ export function loadLocalManifest(bundleDir) {
551
+ return readJsonFile(path.join(bundleDir, 'current', 'manifest.json'));
552
+ }
553
+ /** `<bundleDir>/update-state.json`, or null when absent or unreadable. */
554
+ export function loadUpdateState(bundleDir) {
555
+ return readJsonFile(path.join(bundleDir, 'update-state.json'));
556
+ }
557
+ function readJsonFile(file) {
558
+ try {
559
+ return JSON.parse(fs.readFileSync(file, 'utf-8'));
560
+ }
561
+ catch {
562
+ return null;
563
+ }
564
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parall/daemon",
3
- "version": "1.61.0",
3
+ "version": "1.63.0",
4
4
  "description": "Parall local agent runtime — daemon supervisor + bridge runtimes, bundled as standalone JS files",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,13 +31,14 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@aws-sdk/client-s3": "3.984.0",
34
+ "@opentelemetry/api": "^1.9.0",
34
35
  "@pinixai/bb-browser-pro": "0.15.0",
35
36
  "ws": "^8.18.0",
36
- "@parall/agent-core": "1.61.0",
37
- "@parall/claude-agent": "1.61.0",
38
- "@parall/codex-agent": "1.61.0",
39
- "@parall/openclaw-agent": "1.61.0",
40
- "@parall/sdk": "1.61.0"
37
+ "@parall/claude-agent": "1.63.0",
38
+ "@parall/sdk": "1.63.0",
39
+ "@parall/codex-agent": "1.63.0",
40
+ "@parall/agent-core": "1.63.0",
41
+ "@parall/openclaw-agent": "1.63.0"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/node": "^22.0.0",