@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
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAmkBA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAuD9E"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AA+oBA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CA0D9E"}
package/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import * as os from 'node:os';
4
4
  import * as path from 'node:path';
5
5
  import * as readline from 'node:readline';
6
6
  import { daemonConfigDir, daemonConfigPath } from './config.js';
7
+ import { DIAGNOSTICS_NOTE_MAX_CHARS, collectDiagnostics, resolveDaemonLogPath, serializeBundle, uploadDiagnostics, } from './diagnostics.js';
7
8
  import { WIN_TASK_NAME, buildLauncherCjs, buildLauncherVbs, buildTaskXml, encodeUtf16LeBom, winServicePaths, } from './win-service.js';
8
9
  import { probePidIdentity, queryTaskDisabled, queryTaskExists, readTrackedPid, stopDaemonWindows, uninstallDaemonWindows, } from './win-lifecycle.js';
9
10
  const CONFIG_DIR = daemonConfigDir();
@@ -414,8 +415,10 @@ function cmdLogs(lines) {
414
415
  child.on('exit', (code) => process.exit(code ?? 0));
415
416
  return;
416
417
  }
417
- const logPath = path.join(os.homedir(), 'Library', 'Logs', 'parall-daemon.log');
418
- if (!fs.existsSync(logPath)) {
418
+ // Desktop-managed daemons log to an env-suffixed file (parall-daemon-staging.log);
419
+ // the shell passes that path so `logs` and `diagnostics` read the right one.
420
+ const logPath = resolveDaemonLogPath();
421
+ if (!logPath || !fs.existsSync(logPath)) {
419
422
  console.log('No log file found at', logPath);
420
423
  return;
421
424
  }
@@ -485,6 +488,69 @@ async function cmdUpdate(checkOnly) {
485
488
  console.log('Already up to date.');
486
489
  }
487
490
  }
491
+ /**
492
+ * `diagnostics upload|dry-run`: assemble the redacted bundle from disk and
493
+ * either POST it with the machine key or write it next to the user for
494
+ * inspection. Out of process on purpose — works while the daemon is wedged.
495
+ */
496
+ async function cmdDiagnostics(args) {
497
+ const sub = args[0];
498
+ const json = args.includes('--json');
499
+ let note;
500
+ let dryRunPath;
501
+ for (let i = 1; i < args.length; i++) {
502
+ if (args[i] === '--note')
503
+ note = args[++i];
504
+ else if (args[i] === '--out')
505
+ dryRunPath = args[++i];
506
+ }
507
+ if (sub !== 'upload' && sub !== 'dry-run') {
508
+ console.error(`Unknown diagnostics command: ${sub ?? '(none)'}`);
509
+ console.log('Usage: parall-daemon diagnostics upload [--note TEXT] [--json]');
510
+ console.log(' parall-daemon diagnostics dry-run [--out FILE]');
511
+ process.exit(1);
512
+ }
513
+ if (note && [...note].length > DIAGNOSTICS_NOTE_MAX_CHARS) {
514
+ console.error(`Error: --note must be at most ${DIAGNOSTICS_NOTE_MAX_CHARS} characters`);
515
+ process.exit(1);
516
+ }
517
+ // Upload needs a configured daemon; say so before the multi-second collect.
518
+ const config = sub === 'upload' ? readConfig() : null;
519
+ if (sub === 'upload' && (!config?.api_url || !config.api_key)) {
520
+ console.error('Error: daemon is not configured (no config.json). Run `parall-daemon init` first.');
521
+ process.exit(1);
522
+ }
523
+ const bundle = await collectDiagnostics();
524
+ if (sub === 'dry-run' || !config) {
525
+ const out = dryRunPath ?? path.join(process.cwd(), `parall-diagnostics-${Date.now()}.json.gz`);
526
+ fs.writeFileSync(out, serializeBundle(bundle), { mode: 0o600 });
527
+ fs.chmodSync(out, 0o600); // mode above does not tighten an existing file
528
+ const summary = { path: out, bytes: fs.statSync(out).size, log_bytes: bundle.log.bytes };
529
+ console.log(json ? JSON.stringify(summary) : `Wrote ${summary.bytes} bytes to ${out} (not uploaded)`);
530
+ return;
531
+ }
532
+ const { ParallClient } = await import('@parall/sdk');
533
+ const client = new ParallClient({ baseUrl: config.api_url, token: config.api_key });
534
+ try {
535
+ const receipt = await uploadDiagnostics(client, bundle, note);
536
+ if (json) {
537
+ console.log(JSON.stringify(receipt));
538
+ }
539
+ else {
540
+ console.log(`Uploaded diagnostics bundle ${receipt.id} (${receipt.size_bytes} bytes).`);
541
+ console.log('Share the bundle id with Parall support.');
542
+ }
543
+ }
544
+ catch (err) {
545
+ if (json) {
546
+ console.log(JSON.stringify({ error: String(err) }));
547
+ }
548
+ else {
549
+ console.error(`Upload failed: ${String(err)}`);
550
+ }
551
+ process.exit(1);
552
+ }
553
+ }
488
554
  function printUsage() {
489
555
  console.log(`
490
556
  parall-daemon — Parall local agent runtime
@@ -496,6 +562,10 @@ Usage:
496
562
  parall-daemon stop Stop the background service
497
563
  parall-daemon update [--check] Check for / apply daemon updates
498
564
  parall-daemon logs [-n LINES] Tail daemon logs
565
+ parall-daemon diagnostics upload [--note TEXT] [--json]
566
+ Upload a redacted diagnostics bundle for Parall support
567
+ parall-daemon diagnostics dry-run [--out FILE]
568
+ Write the bundle locally to inspect it (nothing is sent)
499
569
  parall-daemon service install Install as background service (launchd/systemd/Task Scheduler)
500
570
  parall-daemon service uninstall Uninstall background service
501
571
  parall-daemon help Show this help
@@ -529,6 +599,9 @@ export async function runCLI(args) {
529
599
  case 'update':
530
600
  await cmdUpdate(args.includes('--check'));
531
601
  return 'handled';
602
+ case 'diagnostics':
603
+ await cmdDiagnostics(args.slice(1));
604
+ return 'handled';
532
605
  case 'service': {
533
606
  const sub = args[1];
534
607
  if (sub === 'install') {
package/dist/config.d.ts CHANGED
@@ -28,8 +28,6 @@ export type ClaudeDaemonConfig = {
28
28
  swimlaneName?: string;
29
29
  /** @deprecated Superseded by WS event-driven model; kept for backward compat. */
30
30
  pollIntervalMs: number;
31
- /** @deprecated Superseded by WS event-driven model; kept for backward compat. */
32
- heartbeatIntervalMs: number;
33
31
  /** Backoff base after a subprocess crash, in ms. */
34
32
  restartBackoffMs: number;
35
33
  /** Hard cap on parallel restart attempts per agent before giving up for a cycle. */
@@ -73,6 +71,10 @@ export type ClaudeDaemonConfig = {
73
71
  };
74
72
  export declare function daemonConfigPath(env?: NodeJS.ProcessEnv): string;
75
73
  export declare function resolveClaudeDaemonConfig(env?: NodeJS.ProcessEnv): ClaudeDaemonConfig;
74
+ /** The operator's real HOME (or PRLL_CLAUDE_HOME) that per-agent homes hang off. */
75
+ export declare function resolveRootClaudeHome(env?: NodeJS.ProcessEnv): string;
76
+ /** Root of all per-agent state (`agents/<id>/…`): PRLL_CLAUDE_STATE_DIR or `~/.parall-agent`. */
77
+ export declare function resolveRootStateDir(env?: NodeJS.ProcessEnv): string;
76
78
  /** Per-agent state dir under the shared host volume. */
77
79
  export declare function agentStateDirFor(rootStateDir: string, agentId: string): string;
78
80
  /** Per-agent HOME dir. Claude Code stores project/session state under
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAe,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,cAAc,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,cAAc,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;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
69
69
  throw new Error(`PRLL_API_KEY does not look like a Machine bearer (expected prefix "mck_"). ` +
70
70
  `Daemon mode requires a machine-scoped key issued via POST /machines/{id}/keys.`);
71
71
  }
72
- const rootClaudeHome = resolvePath(env.PRLL_CLAUDE_HOME?.trim() || env.HOME || os.homedir());
73
- const rootStateDir = resolvePath(env.PRLL_CLAUDE_STATE_DIR?.trim() || path.join(rootClaudeHome, '.parall-agent'));
72
+ const rootClaudeHome = resolveRootClaudeHome(env);
73
+ const rootStateDir = resolveRootStateDir(env);
74
74
  return {
75
75
  apiUrl,
76
76
  apiKey,
@@ -80,7 +80,6 @@ export function resolveClaudeDaemonConfig(env = process.env) {
80
80
  wsUrl: env.PRLL_WS_URL?.trim() || undefined,
81
81
  swimlaneName: env.PRLL_SWIMLANE_NAME?.trim() || undefined,
82
82
  pollIntervalMs: parseMs(env.PRLL_DAEMON_POLL_INTERVAL_MS, 30_000),
83
- heartbeatIntervalMs: parseMs(env.PRLL_DAEMON_HEARTBEAT_INTERVAL_MS, 30_000),
84
83
  restartBackoffMs: parseMs(env.PRLL_DAEMON_RESTART_BACKOFF_MS, 5_000),
85
84
  restartBackoffMaxMs: parseMs(env.PRLL_DAEMON_RESTART_BACKOFF_MAX_MS, 5 * 60_000),
86
85
  bootstrapBackoffMs: parseMsAllowZero(env.PRLL_DAEMON_BOOTSTRAP_BACKOFF_MS, 2_000),
@@ -103,6 +102,14 @@ function assertSafeAgentId(agentId) {
103
102
  }
104
103
  return agentId;
105
104
  }
105
+ /** The operator's real HOME (or PRLL_CLAUDE_HOME) that per-agent homes hang off. */
106
+ export function resolveRootClaudeHome(env = process.env) {
107
+ return resolvePath(env.PRLL_CLAUDE_HOME?.trim() || env.HOME || os.homedir());
108
+ }
109
+ /** Root of all per-agent state (`agents/<id>/…`): PRLL_CLAUDE_STATE_DIR or `~/.parall-agent`. */
110
+ export function resolveRootStateDir(env = process.env) {
111
+ return resolvePath(env.PRLL_CLAUDE_STATE_DIR?.trim() || path.join(resolveRootClaudeHome(env), '.parall-agent'));
112
+ }
106
113
  /** Per-agent state dir under the shared host volume. */
107
114
  export function agentStateDirFor(rootStateDir, agentId) {
108
115
  return path.join(rootStateDir, 'agents', assertSafeAgentId(agentId));
@@ -1 +1 @@
1
- {"version":3,"file":"daemon-main.d.ts","sourceRoot":"","sources":["../src/daemon-main.ts"],"names":[],"mappings":";AA2BA,MAAM,MAAM,oBAAoB,GAAG;IACjC,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAqLF,wBAAsB,cAAc,CAClC,SAAS,EAAE,oBAAoB,EAC/B,IAAI,WAAwB,GAC3B,OAAO,CAAC,IAAI,CAAC,CASf"}
1
+ {"version":3,"file":"daemon-main.d.ts","sourceRoot":"","sources":["../src/daemon-main.ts"],"names":[],"mappings":";AA+BA,MAAM,MAAM,oBAAoB,GAAG;IACjC,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAiNF,wBAAsB,cAAc,CAClC,SAAS,EAAE,oBAAoB,EAC/B,IAAI,WAAwB,GAC3B,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { configureHttpKeepAlive, createLogger, createOtelLogger, initAgentTelemetry, resolveServiceVersion, } from '@parall/agent-core';
2
+ import { configureHttpKeepAlive, createLogger, createOtelLogger, initAgentTelemetry, resolveServiceVersion, traceContextHeaders, } from '@parall/agent-core';
3
3
  import { ParallClient } from '@parall/sdk';
4
4
  import { runCLI } from './cli.js';
5
- import { resolveBundleDir, resolveClaudeDaemonConfig, resolveWsUrl, } from './config.js';
5
+ import * as path from 'node:path';
6
+ import { daemonConfigDir, resolveBundleDir, resolveClaudeDaemonConfig, resolveWsUrl, } from './config.js';
7
+ import { DaemonTelemetry, proxyEnvNames } from './daemon-telemetry.js';
6
8
  import { isSelfUpdateManaged } from './daemon-update-mode.js';
7
9
  import { DaemonSupervisor, sleepCancellable } from './supervisor.js';
8
10
  import { DaemonUpdater } from './updater.js';
@@ -34,7 +36,7 @@ function formatError(reason) {
34
36
  * any supervisor.run() rejection and rely entirely on the shell wrapper +
35
37
  * K8s for restart.
36
38
  */
37
- async function runForever(config, client, log, signal, updater, gate) {
39
+ async function runForever(config, client, log, signal, updater, gate, daemonTelemetry) {
38
40
  let attempt = 0;
39
41
  while (!signal.aborted) {
40
42
  const supervisor = new DaemonSupervisor(config, client, log);
@@ -42,6 +44,8 @@ async function runForever(config, client, log, signal, updater, gate) {
42
44
  supervisor.setUpdater(updater);
43
45
  if (gate)
44
46
  supervisor.setHealthGate(gate);
47
+ if (daemonTelemetry)
48
+ supervisor.setDaemonTelemetry(daemonTelemetry);
45
49
  try {
46
50
  await supervisor.run(signal);
47
51
  // Clean exit (signal aborted) — done.
@@ -85,10 +89,21 @@ async function main(bootstrap) {
85
89
  apiUrl: config.apiUrl,
86
90
  apiKey: config.apiKey,
87
91
  serviceVersion: resolveServiceVersion(import.meta.url),
92
+ // Batches that fail to export while the machine is offline wait here
93
+ // and replay later; the bridges get their own directory via env.
94
+ spoolDir: path.join(daemonConfigDir(process.env), 'otel-spool', 'daemon'),
88
95
  });
89
96
  log = createOtelLogger('daemon', 'daemon');
90
- log.info(`boot: api=${config.apiUrl} pollMs=${config.pollIntervalMs} heartbeatMs=${config.heartbeatIntervalMs} agentBin=${config.agentBin}`);
97
+ // Process-level (survives supervisor in-process restarts); constructed only
98
+ // now because the metrics API resolves its provider at getMeter time.
99
+ const daemonTelemetry = new DaemonTelemetry({ log });
100
+ daemonTelemetry.start();
101
+ log.info(`boot: api=${config.apiUrl} pollMs=${config.pollIntervalMs} agentBin=${config.agentBin}`);
91
102
  log.info(`keepalive: bootstrapBackoffMs=${config.bootstrapBackoffMs} supervisorRestartBackoffMs=${config.supervisorRestartBackoffMs}`);
103
+ // Names only — a proxy URL carries credentials. The daemon's own egress
104
+ // does not honor these; knowing they exist explains a machine that can
105
+ // reach the API only through a corporate proxy.
106
+ log.info(`proxy env: ${proxyEnvNames(process.env).join(',') || 'none'}`);
92
107
  // --- Self-update: rollback check (before any network calls) ---
93
108
  // Only run when a service manager supervises us (see isSelfUpdateManaged):
94
109
  // a bare `npx` foreground run can't load the overlay and won't be restarted
@@ -100,6 +115,7 @@ async function main(bootstrap) {
100
115
  if (selfUpdateEnabled) {
101
116
  const signingEnabled = true;
102
117
  updater = new DaemonUpdater(bundleDir, config.updateCdnUrl, log, signingEnabled);
118
+ updater.setOutcomeReporter((outcome, reason) => daemonTelemetry.recordUpdateOutcome(outcome, reason));
103
119
  // Process-level canary gate: machine.hello arms a stability window; the
104
120
  // version is confirmed only if the process stays up through it. Owned here
105
121
  // (not in the supervisor) so it survives supervisor in-process restarts.
@@ -109,6 +125,7 @@ async function main(bootstrap) {
109
125
  // daemon app startup path while still letting updater.ts stay mechanism-only.
110
126
  if (updater.checkRollback(bootstrap.uncleanPrevExit)) {
111
127
  log.info('rollback applied — exiting for service manager restart');
128
+ daemonTelemetry.stop();
112
129
  await telemetry.shutdown();
113
130
  process.exit(UPDATE_EXIT_CODE);
114
131
  }
@@ -124,6 +141,7 @@ async function main(bootstrap) {
124
141
  baseUrl: config.apiUrl,
125
142
  token: config.apiKey,
126
143
  swimlaneName: config.swimlaneName,
144
+ getRequestHeaders: traceContextHeaders,
127
145
  });
128
146
  const abortController = new AbortController();
129
147
  const onSignal = (sig) => {
@@ -152,12 +170,14 @@ async function main(bootstrap) {
152
170
  });
153
171
  if (applied) {
154
172
  log.info('boot update applied — exiting for restart');
173
+ daemonTelemetry.stop();
155
174
  await telemetry.shutdown();
156
175
  process.exit(UPDATE_EXIT_CODE);
157
176
  }
158
177
  updater.startPeriodicCheck(config.updateIntervalMs);
159
178
  }
160
- await runForever(config, client, log, abortController.signal, updater, healthGate);
179
+ await runForever(config, client, log, abortController.signal, updater, healthGate, daemonTelemetry);
180
+ daemonTelemetry.stop();
161
181
  await telemetry.shutdown();
162
182
  }
163
183
  export async function runDaemonEntry(bootstrap, args = process.argv.slice(2)) {
@@ -0,0 +1,83 @@
1
+ import { type Meter } from '@opentelemetry/api';
2
+ import type { GatewayLogger } from '@parall/agent-core';
3
+ /**
4
+ * The daemon's own runtime facts as OpenTelemetry metrics (SigNoz is the
5
+ * consumer; nothing here is sent to the api-server or persisted). Every
6
+ * attribute value is drawn from a closed set defined in this file.
7
+ */
8
+ export type ChildExitKind = 'clean' | 'crash' | 'signal' | 'spawn_error';
9
+ export type UpdateOutcome = 'applied' | 'failed' | 'skipped' | 'rolled_back' | 'confirmed';
10
+ export type UpdateReason = 'pending_activation' | 'previously_rolled_back' | 'node_version' | 'node_version_invalid' | 'manifest_fetch' | 'manifest_parse' | 'signing_key_missing' | 'signature' | 'download' | 'sha256_mismatch' | 'size_mismatch' | 'exception' | 'boot_threshold';
11
+ export type ClockGapKind = 'sleep' | 'stall';
12
+ /** Which proxy variables are set — names only; the values are never logged. */
13
+ export declare function proxyEnvNames(env: NodeJS.ProcessEnv): string[];
14
+ /** `server_time` from machine.hello minus the local clock at receipt; null when unparseable. */
15
+ export declare function computeClockSkewMs(serverTime: string, nowMs: number): number | null;
16
+ export declare function classifyChildExit(code: number | null, signal: NodeJS.Signals | null, err?: Error): ChildExitKind;
17
+ export interface ClockSample {
18
+ wall: number;
19
+ mono: number;
20
+ }
21
+ /**
22
+ * Compare two consecutive ticks of a wall clock and a monotonic clock. The
23
+ * monotonic clock pauses while the machine sleeps, so wall advancing far
24
+ * beyond it is a sleep (or an NTP step — advisory, not proof); both
25
+ * advancing far beyond the interval is an event-loop stall.
26
+ */
27
+ export declare function classifyTick(prev: ClockSample, cur: ClockSample, intervalMs: number): {
28
+ kind: ClockGapKind;
29
+ gapMs: number;
30
+ } | null;
31
+ type TimerHandle = {
32
+ unref?: () => void;
33
+ };
34
+ export interface TimerApi {
35
+ setInterval(callback: () => void, ms: number): TimerHandle;
36
+ clearInterval(handle: TimerHandle): void;
37
+ }
38
+ export interface DaemonTelemetryDeps {
39
+ log: GatewayLogger;
40
+ /**
41
+ * Defaults to the global `parall.daemon` meter. The metrics API has no
42
+ * lazy proxy: construct this after `initAgentTelemetry`, or every
43
+ * instrument stays a no-op for the life of the process.
44
+ */
45
+ meter?: Meter;
46
+ now?: () => number;
47
+ mono?: () => number;
48
+ uptimeSeconds?: () => number;
49
+ timers?: TimerApi;
50
+ tickMs?: number;
51
+ }
52
+ export declare class DaemonTelemetry {
53
+ private readonly log;
54
+ private readonly now;
55
+ private readonly mono;
56
+ private readonly timers;
57
+ private readonly tickMs;
58
+ private readonly childExit;
59
+ private readonly update;
60
+ private readonly wsReconnect;
61
+ private readonly wakeGap;
62
+ private lastSkewMs;
63
+ private lastTick;
64
+ private timer;
65
+ constructor(deps: DaemonTelemetryDeps);
66
+ /** Start the sleep/stall detector. */
67
+ start(): void;
68
+ stop(): void;
69
+ recordChildExit(a: {
70
+ runtimeType: string;
71
+ exitKind: ChildExitKind;
72
+ restart: boolean;
73
+ }): void;
74
+ recordUpdateOutcome(outcome: UpdateOutcome, reason?: UpdateReason): void;
75
+ recordWsReconnect(a: {
76
+ cause?: string;
77
+ closeCode?: number;
78
+ }): void;
79
+ recordClockSkew(ms: number): void;
80
+ private tick;
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=daemon-telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon-telemetry.d.ts","sourceRoot":"","sources":["../src/daemon-telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,KAAK,EAAW,MAAM,oBAAoB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,G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I;IAOlE,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,IAAI;CAeb"}
@@ -0,0 +1,143 @@
1
+ import { metrics } from '@opentelemetry/api';
2
+ const PROXY_ENV_NAMES = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY'];
3
+ const DEFAULT_TICK_MS = 30_000;
4
+ /** Which proxy variables are set — names only; the values are never logged. */
5
+ export function proxyEnvNames(env) {
6
+ const names = [];
7
+ for (const upper of PROXY_ENV_NAMES) {
8
+ for (const name of [upper, upper.toLowerCase()]) {
9
+ if (env[name]?.trim())
10
+ names.push(name);
11
+ }
12
+ }
13
+ return names;
14
+ }
15
+ /** `server_time` from machine.hello minus the local clock at receipt; null when unparseable. */
16
+ export function computeClockSkewMs(serverTime, nowMs) {
17
+ const parsed = Date.parse(serverTime);
18
+ return Number.isFinite(parsed) ? parsed - nowMs : null;
19
+ }
20
+ export function classifyChildExit(code, signal, err) {
21
+ if (err)
22
+ return 'spawn_error';
23
+ if (signal)
24
+ return 'signal';
25
+ return code === 0 ? 'clean' : 'crash';
26
+ }
27
+ /**
28
+ * Compare two consecutive ticks of a wall clock and a monotonic clock. The
29
+ * monotonic clock pauses while the machine sleeps, so wall advancing far
30
+ * beyond it is a sleep (or an NTP step — advisory, not proof); both
31
+ * advancing far beyond the interval is an event-loop stall.
32
+ */
33
+ export function classifyTick(prev, cur, intervalMs) {
34
+ const wallDelta = cur.wall - prev.wall;
35
+ const monoDelta = cur.mono - prev.mono;
36
+ if (wallDelta - monoDelta > intervalMs)
37
+ return { kind: 'sleep', gapMs: wallDelta - monoDelta };
38
+ if (monoDelta > 2 * intervalMs)
39
+ return { kind: 'stall', gapMs: monoDelta - intervalMs };
40
+ return null;
41
+ }
42
+ const realTimers = {
43
+ setInterval: (callback, ms) => setInterval(callback, ms),
44
+ clearInterval: (handle) => clearInterval(handle),
45
+ };
46
+ export class DaemonTelemetry {
47
+ log;
48
+ now;
49
+ mono;
50
+ timers;
51
+ tickMs;
52
+ childExit;
53
+ update;
54
+ wsReconnect;
55
+ wakeGap;
56
+ lastSkewMs = null;
57
+ lastTick = null;
58
+ timer = null;
59
+ constructor(deps) {
60
+ this.log = deps.log;
61
+ this.now = deps.now ?? Date.now;
62
+ this.mono = deps.mono ?? (() => performance.now());
63
+ this.timers = deps.timers ?? realTimers;
64
+ this.tickMs = deps.tickMs ?? DEFAULT_TICK_MS;
65
+ const meter = deps.meter ?? metrics.getMeter('parall.daemon');
66
+ const uptimeSeconds = deps.uptimeSeconds ?? (() => process.uptime());
67
+ this.childExit = meter.createCounter('parall.daemon.child_exit', {
68
+ description: 'Bridge child process exits, by kind and whether the daemon restarts it',
69
+ });
70
+ this.update = meter.createCounter('parall.daemon.update', {
71
+ description: 'Self-update outcomes, by outcome and reason',
72
+ });
73
+ this.wsReconnect = meter.createCounter('parall.daemon.ws_reconnect', {
74
+ description: 'Machine WebSocket reconnect attempts, by disconnect cause',
75
+ });
76
+ this.wakeGap = meter.createHistogram('parall.daemon.wake_gap', {
77
+ description: 'Gaps between daemon ticks: machine sleep or event-loop stall',
78
+ unit: 's',
79
+ });
80
+ meter
81
+ .createObservableGauge('parall.daemon.uptime', {
82
+ description: 'Seconds since the daemon process started',
83
+ unit: 's',
84
+ })
85
+ .addCallback((result) => result.observe(uptimeSeconds()));
86
+ meter
87
+ .createObservableGauge('parall.daemon.clock_skew_ms', {
88
+ description: 'Server time minus local time at the last machine.hello',
89
+ unit: 'ms',
90
+ })
91
+ .addCallback((result) => {
92
+ if (this.lastSkewMs !== null)
93
+ result.observe(this.lastSkewMs);
94
+ });
95
+ }
96
+ /** Start the sleep/stall detector. */
97
+ start() {
98
+ if (this.timer)
99
+ return;
100
+ this.lastTick = { wall: this.now(), mono: this.mono() };
101
+ this.timer = this.timers.setInterval(() => this.tick(), this.tickMs);
102
+ this.timer.unref?.();
103
+ }
104
+ stop() {
105
+ if (this.timer)
106
+ this.timers.clearInterval(this.timer);
107
+ this.timer = null;
108
+ }
109
+ recordChildExit(a) {
110
+ this.childExit.add(1, {
111
+ runtime_type: a.runtimeType,
112
+ exit_kind: a.exitKind,
113
+ restart: a.restart,
114
+ });
115
+ }
116
+ recordUpdateOutcome(outcome, reason) {
117
+ this.update.add(1, { outcome, ...(reason ? { reason } : {}) });
118
+ }
119
+ recordWsReconnect(a) {
120
+ this.wsReconnect.add(1, {
121
+ cause: a.cause ?? 'unknown',
122
+ ...(a.closeCode !== undefined ? { close_code: String(a.closeCode) } : {}),
123
+ });
124
+ }
125
+ recordClockSkew(ms) {
126
+ this.lastSkewMs = ms;
127
+ }
128
+ tick() {
129
+ const cur = { wall: this.now(), mono: this.mono() };
130
+ const prev = this.lastTick;
131
+ this.lastTick = cur;
132
+ if (!prev)
133
+ return;
134
+ const gap = classifyTick(prev, cur, this.tickMs);
135
+ if (!gap)
136
+ return;
137
+ const seconds = Math.round(gap.gapMs / 1000);
138
+ this.wakeGap.record(gap.gapMs / 1000, { kind: gap.kind });
139
+ this.log.warn(gap.kind === 'sleep'
140
+ ? `clock gap: ~${seconds}s while the process was not running (machine asleep, or the clock stepped)`
141
+ : `clock gap: ~${seconds}s event-loop stall`);
142
+ }
143
+ }
@@ -0,0 +1,127 @@
1
+ import { type DetectedRuntime, type MachineDiagnosticsUploadResponse, type ParallClient } from '@parall/sdk';
2
+ import { buildMachineRuntimeReport } from './runtime-report.js';
3
+ import { type UpdateState } from './updater.js';
4
+ /**
5
+ * Diagnostics bundle (daemon-diagnostics-bundle-design.md): what a
6
+ * self-hosted machine's owner sends the platform to get a problem looked at.
7
+ * Assembled OUT of process from files on disk — the CLI (and the Desktop
8
+ * button, which runs the CLI) never talks to the running daemon.
9
+ *
10
+ * Everything in the bundle comes from the ALLOWLIST below; nothing is read
11
+ * from anywhere else. The one credential this process can see, config.json's
12
+ * `api_key`, is dropped from the config copy and used as an exact value for
13
+ * redacting the log tail. Credentials the daemon keeps in memory (per-agent
14
+ * agk_ launch keys, PRLL_PROVIDER_CONFIG) are not on disk and can only be
15
+ * caught by redactSecrets' prefix rules — the log tail is the bridges' raw
16
+ * stdout/stderr, so that rule set is the floor, not a guarantee.
17
+ */
18
+ export declare const DIAGNOSTICS_SCHEMA_VERSION = 1;
19
+ /** Bytes of the log file's tail that travel; well under the server's 16 MB body cap. */
20
+ export declare const DIAGNOSTICS_LOG_TAIL_BYTES: number;
21
+ /** Runtime probes spawn `--version` (and maybe a login shell); bound the whole step. */
22
+ export declare const DIAGNOSTICS_DETECT_BUDGET_MS = 20000;
23
+ export declare const DIAGNOSTICS_NOTE_MAX_CHARS = 500;
24
+ /**
25
+ * A URL as it may appear in the bundle: userinfo, query and fragment are the
26
+ * places a credential usually rides along (`https://u:p@host/?token=…`), so
27
+ * they are dropped outright; what remains (and an unparseable value) still
28
+ * goes through `redactSecrets`, so a credential-shaped path segment is masked
29
+ * like it would be in the log. The daemon's own config is never rewritten.
30
+ */
31
+ export declare function sanitizeUrlValue(value: string, knownSecrets: string[]): string;
32
+ export interface DiagnosticsBundle {
33
+ schema_version: number;
34
+ created_at: string;
35
+ manifest: {
36
+ daemon_version: string;
37
+ bundle_manifest_version: string | null;
38
+ platform: string;
39
+ arch: string;
40
+ node_version: string;
41
+ os_release: string;
42
+ hostname_length: number;
43
+ config_dir: string;
44
+ bundle_dir: string;
45
+ state_dir: string;
46
+ };
47
+ /** config.json without api_key. */
48
+ config: Record<string, unknown>;
49
+ update_state: UpdateState | null;
50
+ bundle_versions: string[];
51
+ runtime_report: {
52
+ skipped: string;
53
+ } | ReturnType<typeof buildMachineRuntimeReport>;
54
+ spool: SpoolStats[];
55
+ agents: AgentDirStats[];
56
+ env: {
57
+ present: string[];
58
+ values: Record<string, string>;
59
+ proxy: string[];
60
+ };
61
+ log: {
62
+ source: string;
63
+ truncated: boolean;
64
+ bytes: number;
65
+ text: string;
66
+ };
67
+ }
68
+ export interface SpoolStats {
69
+ dir: string;
70
+ signal: string;
71
+ files: number;
72
+ bytes: number;
73
+ oldest_at: string | null;
74
+ }
75
+ export interface AgentDirStats {
76
+ agent_id: string;
77
+ workspace: boolean;
78
+ home: boolean;
79
+ }
80
+ export interface CollectOptions {
81
+ env?: NodeJS.ProcessEnv;
82
+ now?: () => Date;
83
+ /** Reads the log tail; defaults to the platform's daemon log. */
84
+ logSource?: () => Promise<{
85
+ source: string;
86
+ text: string;
87
+ truncated: boolean;
88
+ }>;
89
+ /** Runtime probing; defaults to detectRuntimes. Either way the budget below applies. */
90
+ detect?: () => Promise<DetectedRuntime[]>;
91
+ detectBudgetMs?: number;
92
+ importMetaUrl?: string;
93
+ }
94
+ /**
95
+ * The last `maxBytes` of a buffer as text. `total` is the size of the whole
96
+ * source (the buffer may already be its trailing window); when anything was
97
+ * cut, the text restarts at the next line so no partial line or split UTF-8
98
+ * sequence leads the tail. A window with no newline at all (one line longer
99
+ * than the window) is kept as the partial line: a huge bridge line is still
100
+ * evidence, and `truncated` says it was cut.
101
+ */
102
+ export declare function tailBuffer(buf: Buffer, maxBytes: number, total?: number): {
103
+ text: string;
104
+ truncated: boolean;
105
+ };
106
+ /** Last maxBytes of a file, cut to a line boundary; empty when the file is absent. */
107
+ export declare function tailFile(file: string, maxBytes: number): {
108
+ text: string;
109
+ truncated: boolean;
110
+ };
111
+ /** Where this platform's daemon log lives for the CLI; Desktop passes its env-suffixed path. */
112
+ export declare function resolveDaemonLogPath(env?: NodeJS.ProcessEnv): string | null;
113
+ /**
114
+ * Run a command and keep only the trailing `maxBytes` of its stdout, however
115
+ * much it prints: the buffer is trimmed as chunks arrive, so a verbose journal
116
+ * never hits a fixed maxBuffer and loses the useful end. Rejects when the
117
+ * command cannot start or exits non-zero without printing anything.
118
+ */
119
+ export declare function commandTail(cmd: string, args: string[], maxBytes: number): Promise<{
120
+ text: string;
121
+ truncated: boolean;
122
+ }>;
123
+ export declare function collectDiagnostics(opts?: CollectOptions): Promise<DiagnosticsBundle>;
124
+ /** The wire form: gzip of the JSON document. */
125
+ export declare function serializeBundle(bundle: DiagnosticsBundle): Buffer;
126
+ export declare function uploadDiagnostics(client: Pick<ParallClient, 'uploadMachineDiagnostics'>, bundle: DiagnosticsBundle, note?: string): Promise<MachineDiagnosticsUploadResponse>;
127
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,gCAAgC,EACrC,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,cAAc,CAAC;AAGpF;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,QAAU,CAAC;AAClD,wFAAwF;AACxF,eAAO,MAAM,4BAA4B,QAAS,CAAC;AACnD,eAAO,MAAM,0BAA0B,MAAqC,CAAC;AAqB7E;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAc9E;AAUD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;QACvC,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,mCAAmC;IACnC,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