@parall/daemon 1.69.0 → 1.70.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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Connect protocol envelope framing (JSON mode), shared by the ProviderStream
3
+ * (clip-provider.ts) and the execution-side hub client (hub-client.ts):
4
+ * [flags:1][length:4 big-endian][JSON payload]
5
+ * flags=0x00 data, flags=0x02 end-of-stream (trailers)
6
+ */
7
+ const ENVELOPE_FLAG_DATA = 0x00;
8
+ export const ENVELOPE_FLAG_TRAILER = 0x02;
9
+ const MAX_FRAME_LENGTH = 16 * 1024 * 1024; // 16 MiB
10
+ export function encodeEnvelope(msg) {
11
+ const json = Buffer.from(JSON.stringify(msg), 'utf-8');
12
+ const header = Buffer.alloc(5);
13
+ header[0] = ENVELOPE_FLAG_DATA;
14
+ header.writeUInt32BE(json.length, 1);
15
+ return Buffer.concat([header, json]);
16
+ }
17
+ /**
18
+ * Incremental envelope decoder. Feed chunks via push(), receive decoded
19
+ * messages from flush(). Handles partial reads across chunk boundaries.
20
+ */
21
+ export class EnvelopeDecoder {
22
+ buf = Buffer.alloc(0);
23
+ push(chunk) {
24
+ this.buf = this.buf.length === 0 ? Buffer.from(chunk) : Buffer.concat([this.buf, chunk]);
25
+ }
26
+ /** Drain all complete envelopes from the internal buffer. */
27
+ *flush() {
28
+ while (this.buf.length >= 5) {
29
+ const flags = this.buf[0];
30
+ const length = this.buf.readUInt32BE(1);
31
+ if (length > MAX_FRAME_LENGTH) {
32
+ this.buf = Buffer.alloc(0);
33
+ throw new Error(`envelope frame too large: ${length} bytes`);
34
+ }
35
+ if (this.buf.length < 5 + length)
36
+ break; // incomplete frame
37
+ const payload = this.buf.subarray(5, 5 + length);
38
+ this.buf = Buffer.from(this.buf.subarray(5 + length));
39
+ yield { flags, payload };
40
+ }
41
+ }
42
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"hub-client.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/hub-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAgDH,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBACX,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAK3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,gBAAgB;IAEnD;;;;OAIG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAOvE;;;;OAIG;IACG,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IAgCnB;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAgEb;;;OAGG;IACH,OAAO,CAAC,YAAY;CAiGrB"}
1
+ {"version":3,"file":"hub-client.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/hub-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAWH,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBACX,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAK3C;AAED,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,gBAAgB;IAEnD;;;;OAIG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAOvE;;;;OAIG;IACG,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IAgCnB;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAgEb;;;OAGG;IACH,OAAO,CAAC,YAAY;CAiGrB"}
@@ -20,41 +20,8 @@
20
20
  * flags=0x00 data, flags=0x02 end-of-stream (trailers)
21
21
  */
22
22
  import * as http2 from 'node:http2';
23
- // ---------------------------------------------------------------------------
24
- // Connect envelope helpers (mirror clip-provider.ts; JSON mode)
25
- // ---------------------------------------------------------------------------
26
- const ENVELOPE_FLAG_DATA = 0x00;
27
- const ENVELOPE_FLAG_TRAILER = 0x02;
28
- const MAX_FRAME_LENGTH = 16 * 1024 * 1024; // 16 MiB
23
+ import { ENVELOPE_FLAG_TRAILER, EnvelopeDecoder, encodeEnvelope } from './connect-envelope.js';
29
24
  const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
30
- function encodeEnvelope(msg) {
31
- const json = Buffer.from(JSON.stringify(msg), 'utf-8');
32
- const header = Buffer.alloc(5);
33
- header[0] = ENVELOPE_FLAG_DATA;
34
- header.writeUInt32BE(json.length, 1);
35
- return Buffer.concat([header, json]);
36
- }
37
- class EnvelopeDecoder {
38
- buf = Buffer.alloc(0);
39
- push(chunk) {
40
- this.buf = this.buf.length === 0 ? Buffer.from(chunk) : Buffer.concat([this.buf, chunk]);
41
- }
42
- *flush() {
43
- while (this.buf.length >= 5) {
44
- const flags = this.buf[0];
45
- const length = this.buf.readUInt32BE(1);
46
- if (length > MAX_FRAME_LENGTH) {
47
- this.buf = Buffer.alloc(0);
48
- throw new Error(`envelope frame too large: ${length} bytes`);
49
- }
50
- if (this.buf.length < 5 + length)
51
- break; // incomplete frame
52
- const payload = this.buf.subarray(5, 5 + length);
53
- this.buf = Buffer.from(this.buf.subarray(5 + length));
54
- yield { flags, payload };
55
- }
56
- }
57
- }
58
25
  /**
59
26
  * Error surfaced by a hub Invoke that the hub flagged as a clip
60
27
  * application-level rejection (errorIsCommand=true). The execution-side IPC
package/dist/config.d.ts CHANGED
@@ -40,6 +40,17 @@ export type ClaudeDaemonConfig = {
40
40
  */
41
41
  bootstrapBackoffMs: number;
42
42
  bootstrapBackoffMaxMs: number;
43
+ /**
44
+ * Retry schedule once the server rejects this machine's key (401): boot
45
+ * identity probe, machine WS, and clip ProviderStream all back off
46
+ * exponentially from `credentialRetryBackoffMs` up to
47
+ * `credentialRetryBackoffMaxMs`. Slow, because the same key keeps failing
48
+ * until someone re-registers; never terminal, because a rejected key can
49
+ * become valid again (owner re-enabled, server-side policy change, a DB
50
+ * error the server reported as 401).
51
+ */
52
+ credentialRetryBackoffMs: number;
53
+ credentialRetryBackoffMaxMs: number;
43
54
  /**
44
55
  * Outer supervisor keepalive: if `supervisor.run()` rejects with an
45
56
  * unexpected error, wait this long and reinstantiate. Same exp-backoff
@@ -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,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC,6BAA6B,EAAE,MAAM,CAAC;IACtC,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,gBAAgB,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,cAAc,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC;AAuBF,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CA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AM,CAAC,UAAwB,GAAG,MAAM,CAElF;AAED,iGAAiG;AACjG,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAIhF;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;mEAEmE;AACnE,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAElF;AAED,+EAA+E;AAC/E,wBAAgB,8BAA8B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,uEAAuE;AACvE,wBAAgB,6BAA6B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,iEAAiE;AACjE,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAElF;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAEzF;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAMR"}
package/dist/config.js CHANGED
@@ -84,6 +84,8 @@ export function resolveClaudeDaemonConfig(env = process.env) {
84
84
  restartBackoffMaxMs: parseMs(env.PRLL_DAEMON_RESTART_BACKOFF_MAX_MS, 5 * 60_000),
85
85
  bootstrapBackoffMs: parseMsAllowZero(env.PRLL_DAEMON_BOOTSTRAP_BACKOFF_MS, 2_000),
86
86
  bootstrapBackoffMaxMs: parseMs(env.PRLL_DAEMON_BOOTSTRAP_BACKOFF_MAX_MS, 60_000),
87
+ credentialRetryBackoffMs: parseMs(env.PRLL_DAEMON_CREDENTIAL_RETRY_BACKOFF_MS, 60_000),
88
+ credentialRetryBackoffMaxMs: parseMs(env.PRLL_DAEMON_CREDENTIAL_RETRY_BACKOFF_MAX_MS, 15 * 60_000),
87
89
  supervisorRestartBackoffMs: parseMsAllowZero(env.PRLL_DAEMON_SUPERVISOR_RESTART_BACKOFF_MS, 5_000),
88
90
  supervisorRestartBackoffMaxMs: parseMs(env.PRLL_DAEMON_SUPERVISOR_RESTART_BACKOFF_MAX_MS, 5 * 60_000),
89
91
  updateCdnUrl: env.PRLL_DAEMON_UPDATE_CDN_URL?.trim() ||
@@ -1 +1 @@
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
+ {"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;AA4NF,wBAAsB,cAAc,CAClC,SAAS,EAAE,oBAAoB,EAC/B,IAAI,WAAwB,GAC3B,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -163,6 +163,7 @@ async function main(bootstrap) {
163
163
  });
164
164
  config.wsUrl = resolveWsUrl(config.apiUrl, config.wsUrl, config.swimlaneName);
165
165
  // --- Self-update: boot check + periodic timer ---
166
+ let restartForUpdate = false;
166
167
  if (updater) {
167
168
  const applied = await updater.checkAndApply().catch((err) => {
168
169
  log.warn(`boot update check failed: ${String(err)}`);
@@ -174,11 +175,21 @@ async function main(bootstrap) {
174
175
  await telemetry.shutdown();
175
176
  process.exit(UPDATE_EXIT_CODE);
176
177
  }
178
+ // Updates installed after boot (periodic check, WS push) restart through
179
+ // here: abort stops the supervisor cleanly, then we exit 42 below.
180
+ updater.setRestartHandler(() => {
181
+ restartForUpdate = true;
182
+ abortController.abort();
183
+ });
177
184
  updater.startPeriodicCheck(config.updateIntervalMs);
178
185
  }
179
186
  await runForever(config, client, log, abortController.signal, updater, healthGate, daemonTelemetry);
180
187
  daemonTelemetry.stop();
181
188
  await telemetry.shutdown();
189
+ if (restartForUpdate) {
190
+ log.info('daemon update applied — exiting for service manager restart');
191
+ process.exit(UPDATE_EXIT_CODE);
192
+ }
182
193
  }
183
194
  export async function runDaemonEntry(bootstrap, args = process.argv.slice(2)) {
184
195
  try {
@@ -38,6 +38,8 @@ export declare class DaemonSupervisor {
38
38
  private readonly pendingConfigRefresh;
39
39
  private readonly restartingStates;
40
40
  private ws;
41
+ private wsAuthRetryTimer;
42
+ private wsAuthRetryAttempt;
41
43
  private running;
42
44
  private machineId;
43
45
  /**
@@ -84,6 +86,15 @@ export declare class DaemonSupervisor {
84
86
  run(signal: AbortSignal): Promise<void>;
85
87
  /** Disconnect WS, cancel timers, SIGTERM all children, await exit. */
86
88
  stop(): Promise<void>;
89
+ /**
90
+ * The SDK stops after its small auth budget; re-arm it on the slow credential
91
+ * schedule (connect() from auth-invalid grants a fresh budget). Running
92
+ * children keep their own agk_ and are left alone; machine.hello on
93
+ * reconnect replays whatever was missed.
94
+ */
95
+ private handleMachineWsAuthInvalid;
96
+ /** Slow schedule shared by every machine-key rejection retry (boot, WS, ProviderStream). */
97
+ private credentialRetryDelay;
87
98
  private bootstrapWithRetry;
88
99
  private fullReconcile;
89
100
  private wipeBeforeRevive;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor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8B,IAAI,OAAO,CAAC,IAAI,CAAC;IAerD,0FAA0F;YAC5E,oBAAoB;IAYlC,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,mBAAmB;YAab,mBAAmB;IAyCjC,OAAO,CAAC,wBAAwB;YAelB,6BAA6B;IAqC3C,OAAO,CAAC,2BAA2B;IAYnC,OAAO,CAAC,wBAAwB;YAUlB,oBAAoB;IAwClC;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;;;;OAQG;YACW,sBAAsB;YA6CtB,kBAAkB;IAahC;;;;;;;;;OASG;YACW,wBAAwB;IAwDtC;;;;;;;OAOG;YACW,qBAAqB;IAcnC,OAAO,CAAC,+BAA+B;IAYvC,OAAO,CAAC,4BAA4B;YAQtB,eAAe;YAiEf,UAAU;IA+BxB;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;YAgBhB,cAAc;IAsE5B,OAAO,CAAC,UAAU;IA+NlB;;;;;OAKG;YACW,cAAc;CAwB7B"}
@@ -28,15 +28,16 @@ const RUNTIME_PACKAGES = {
28
28
  openclaw: '@parall/openclaw-agent',
29
29
  };
30
30
  const WORKSPACE_SETUP_RETRY_DELAY_MS = 5_000;
31
- /** Idle interval that keeps a machine-key-rejected (parked) daemon on the event loop. */
32
- const PARK_KEEPALIVE_MS = 60_000;
33
31
  /**
34
32
  * Recovery guidance logged whenever the server rejects this machine's key.
35
- * Machine keys do not expire; a rejected key was revoked, rotated away, its
36
- * Machine was deleted, or its owner left the org, and the only way back is a
37
- * new registration.
33
+ * Machine keys do not expire. A rejection can clear on its own (owner
34
+ * re-enabled, server-side change), so the daemon keeps retrying on the slow
35
+ * credential schedule; a key that was revoked, rotated away, or whose Machine
36
+ * was deleted or owner left the org never recovers without a new registration.
38
37
  */
39
- const MACHINE_KEY_RECOVERY = 'Re-register this machine to get a new key — Desktop app: "Disable daemon", then ' +
38
+ const MACHINE_KEY_RECOVERY = 'The daemon keeps retrying and reconnects by itself if the key becomes valid again. ' +
39
+ 'If it keeps failing, the key was revoked or rotated, this machine was deleted, or its ' +
40
+ 'owner left the org: re-register this machine to get a new key — Desktop app: "Disable daemon", then ' +
40
41
  '"Enable daemon" (this registers a new machine and tries to delete the old one; ' +
41
42
  're-attach its agents); CLI or server: ' +
42
43
  'create a machine under Compute in Parall and run `parall-daemon init` with its key — ' +
@@ -116,6 +117,9 @@ export class DaemonSupervisor {
116
117
  // registration check already keeps the stale state from ever spawning.
117
118
  restartingStates = new Set();
118
119
  ws = null;
120
+ // Slow re-arm of the machine WS after the server rejected this machine's key.
121
+ wsAuthRetryTimer = null;
122
+ wsAuthRetryAttempt = 0;
119
123
  running = false;
120
124
  machineId = null;
121
125
  /**
@@ -319,20 +323,9 @@ export class DaemonSupervisor {
319
323
  });
320
324
  this.ws.on('machine.update', (data) => {
321
325
  this.log.info(`WS: daemon update available — version=${data.new_version} mandatory=${data.mandatory}`);
322
- if (this.updater) {
323
- void this.updater
324
- .triggerUpdate(data.new_version, data.mandatory)
325
- .then(async (applied) => {
326
- if (applied) {
327
- this.log.info('daemon update applied — stopping supervisor before restart');
328
- await this.stop();
329
- process.exit(42);
330
- }
331
- })
332
- .catch((err) => {
333
- this.log.warn(`daemon update failed: ${String(err)}`);
334
- });
335
- }
326
+ // An applied update restarts through the updater's restart handler
327
+ // (daemon-main), the same path the periodic check takes.
328
+ void this.updater?.triggerUpdate(data.new_version, data.mandatory);
336
329
  });
337
330
  this.ws.on('machine.agent.attached', (data) => {
338
331
  this.log.info(`WS: agent ${data.agent_id} attached`);
@@ -391,17 +384,10 @@ export class DaemonSupervisor {
391
384
  if (state === 'reconnecting') {
392
385
  this.daemonTelemetry?.recordWsReconnect({ cause: detail?.cause, closeCode: detail?.code });
393
386
  }
387
+ if (state === 'connected')
388
+ this.wsAuthRetryAttempt = 0;
394
389
  });
395
- this.ws.onAuthInvalid((event) => {
396
- // No automated recovery exists for the machine key: it is issued once
397
- // at machine registration (config file / env) and there is no refresh
398
- // flow the daemon can drive itself. Loud and actionable is the best
399
- // this process can do — the operator must re-register.
400
- this.log.error(`machine WS auth-invalid: the server rejected this machine's key ` +
401
- `(status ${event.status}${event.code ? `, code ${event.code}` : ''}) — ` +
402
- `${event.message}. Control-plane events (attach/detach, config updates, ` +
403
- `update signals) are OFFLINE and reconnects are stopped. ${MACHINE_KEY_RECOVERY}`);
404
- });
390
+ this.ws.onAuthInvalid((event) => this.handleMachineWsAuthInvalid(event));
405
391
  await this.ws.connect();
406
392
  await new Promise((resolve) => {
407
393
  this.stopResolve = resolve;
@@ -420,6 +406,10 @@ export class DaemonSupervisor {
420
406
  // failures come only from process-level unclean exits (the daemon-running
421
407
  // marker in index.ts).
422
408
  this.healthGate?.onSupervisorEnded();
409
+ if (this.wsAuthRetryTimer) {
410
+ clearTimeout(this.wsAuthRetryTimer);
411
+ this.wsAuthRetryTimer = null;
412
+ }
423
413
  if (this.ws) {
424
414
  this.ws.disconnect();
425
415
  this.ws = null;
@@ -474,9 +464,35 @@ export class DaemonSupervisor {
474
464
  this.stopResolve = null;
475
465
  }
476
466
  }
467
+ /**
468
+ * The SDK stops after its small auth budget; re-arm it on the slow credential
469
+ * schedule (connect() from auth-invalid grants a fresh budget). Running
470
+ * children keep their own agk_ and are left alone; machine.hello on
471
+ * reconnect replays whatever was missed.
472
+ */
473
+ handleMachineWsAuthInvalid(event) {
474
+ if (!this.running)
475
+ return; // a ticket in flight across stop() can 401 late; no timer then
476
+ const delay = this.credentialRetryDelay(this.wsAuthRetryAttempt++);
477
+ this.log.error(`machine WS auth-invalid: the server rejected this machine's key ` +
478
+ `(status ${event.status}${event.code ? `, code ${event.code}` : ''}) — ` +
479
+ `${event.message}. Control-plane events (attach/detach, config updates, ` +
480
+ `update signals) are OFFLINE; retrying in ${Math.round(delay / 1000)}s. ` +
481
+ MACHINE_KEY_RECOVERY);
482
+ this.wsAuthRetryTimer = setTimeout(() => {
483
+ this.wsAuthRetryTimer = null;
484
+ if (this.running)
485
+ void this.ws?.connect();
486
+ }, delay);
487
+ }
477
488
  // ---- Bootstrap (resilient identity probe) ----
489
+ /** Slow schedule shared by every machine-key rejection retry (boot, WS, ProviderStream). */
490
+ credentialRetryDelay(attempt) {
491
+ return Math.min(this.config.credentialRetryBackoffMs * 2 ** attempt, this.config.credentialRetryBackoffMaxMs);
492
+ }
478
493
  async bootstrapWithRetry(signal) {
479
494
  let attempt = 0;
495
+ let credentialAttempt = 0;
480
496
  while (this.running && !signal.aborted) {
481
497
  try {
482
498
  const machine = await this.client.getMachineSelf();
@@ -490,42 +506,21 @@ export class DaemonSupervisor {
490
506
  return true;
491
507
  }
492
508
  catch (err) {
493
- // A 401 on the machine-key bootstrap is terminal, not transient:
494
- // retrying the same rejected mck_ cannot succeed and there is no
495
- // self-serve machine-key refresh flow. Same treatment as the
496
- // machine-WS auth-invalid state: actionable guidance, no retry loop.
509
+ // A rejected machine key (401) is not a network blip, but it is not
510
+ // final either: an owner re-enabled, a server-side change, or a DB
511
+ // error the server reported as 401 make the same key valid again.
512
+ // Retry on the slow credential schedule and stay resident — exiting
513
+ // lets launchd/systemd relaunch us every few seconds with the same key
514
+ // (seen on staging: 13 rejections a minute). The sleep's timer is the
515
+ // live handle that keeps the process up; a bare pending Promise is not.
497
516
  if (err instanceof ApiError && err.status === 401) {
517
+ const delay = this.credentialRetryDelay(credentialAttempt++);
498
518
  this.log.error(`machine key rejected by the server ` +
499
519
  `(status 401${err.code ? `, code ${err.code}` : ''}): ${err.message}. ` +
500
- `The daemon cannot start with this machine key. ${MACHINE_KEY_RECOVERY}`);
501
- // Park instead of exiting: managed installations (launchd KeepAlive,
502
- // systemd Restart=always) relaunch a normally-exited daemon every
503
- // few seconds with the same rejected key — a process-level restart
504
- // loop that recreates the hammering this branch exists to stop. The
505
- // parked process must therefore hold an ACTIVE handle: a pending
506
- // Promise with only an abort listener keeps nothing on the event
507
- // loop, Node exits 0 the moment nothing else is running, and the
508
- // service manager relaunches it (observed on staging: one boot every
509
- // ThrottleInterval, 13 rejections a minute). An idle interval is that
510
- // handle; it does no work and is cleared when the operator sends
511
- // SIGTERM/SIGINT after re-registering the machine.
512
- const parked = setInterval(() => { }, PARK_KEEPALIVE_MS);
513
- try {
514
- await new Promise((resolve) => {
515
- // The abort may have landed while getMachineSelf() was still in
516
- // flight and the 401 raced it here — an addEventListener on an
517
- // already-aborted signal never fires and would hang shutdown.
518
- if (signal.aborted) {
519
- resolve();
520
- return;
521
- }
522
- signal.addEventListener('abort', () => resolve(), { once: true });
523
- });
524
- }
525
- finally {
526
- clearInterval(parked);
527
- }
528
- return false;
520
+ `Retrying in ${Math.round(delay / 1000)}s. ${MACHINE_KEY_RECOVERY}`);
521
+ if (!(await sleepCancellable(delay, signal)))
522
+ return false;
523
+ continue;
529
524
  }
530
525
  if (this.config.bootstrapBackoffMs === 0) {
531
526
  this.log.error(`getMachineSelf failed: ${String(err)} (fail-fast mode)`);
@@ -1418,6 +1413,7 @@ export class DaemonSupervisor {
1418
1413
  // (our ws-gateway WS never bounced to re-trigger machine.hello). Refetch
1419
1414
  // machine config; applyClipProviderState rebuilds us if the URL moved.
1420
1415
  onPersistentFailure: () => void this.refreshMachineConfig(),
1416
+ rejectedRetryDelayMs: (attempt) => this.credentialRetryDelay(attempt),
1421
1417
  });
1422
1418
  this.clipProvider
1423
1419
  .connect()
package/dist/updater.d.ts CHANGED
@@ -19,10 +19,18 @@ export declare class DaemonUpdater {
19
19
  private updating;
20
20
  private periodicTimer;
21
21
  private reportOutcome;
22
+ private restartHandler;
22
23
  constructor(bundleDir: string, cdnBaseUrl: string, log: GatewayLogger, signingEnabled: boolean);
23
24
  /** Receive every update outcome (applied / failed / skipped / rolled_back / confirmed) as it happens. */
24
25
  setOutcomeReporter(fn: (outcome: UpdateOutcome, reason?: UpdateReason) => void): void;
25
26
  private report;
27
+ /**
28
+ * Restart the daemon onto an update installed after boot (periodic check or
29
+ * WS push). Installed-but-not-running is not an update: the old process
30
+ * would keep its bugs, and a later push for the same version is skipped
31
+ * because the disk is already current.
32
+ */
33
+ setRestartHandler(fn: () => void): void;
26
34
  /**
27
35
  * Start periodic update checks. Call once after supervisor bootstrap.
28
36
  */
@@ -37,6 +45,7 @@ export declare class DaemonUpdater {
37
45
  * Handle WS-triggered update. Adds jitter for non-mandatory updates.
38
46
  */
39
47
  triggerUpdate(targetVersion: string, mandatory: boolean): Promise<boolean>;
48
+ private applyAndRestart;
40
49
  /**
41
50
  * Check if we need to roll back from a failed update.
42
51
  * Call on every daemon startup, before bootstrap. `uncleanPrevExit` is true
@@ -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,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAC;AAgB/B,MAAM,WAAW,WAAW;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAa;IAMtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,cAAc;IARjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,C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,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
@@ -23,6 +23,7 @@ export class DaemonUpdater {
23
23
  updating = false;
24
24
  periodicTimer = null;
25
25
  reportOutcome = null;
26
+ restartHandler = null;
26
27
  constructor(bundleDir, cdnBaseUrl, log, signingEnabled) {
27
28
  this.bundleDir = bundleDir;
28
29
  this.cdnBaseUrl = cdnBaseUrl;
@@ -37,6 +38,15 @@ export class DaemonUpdater {
37
38
  report(outcome, reason) {
38
39
  this.reportOutcome?.(outcome, reason);
39
40
  }
41
+ /**
42
+ * Restart the daemon onto an update installed after boot (periodic check or
43
+ * WS push). Installed-but-not-running is not an update: the old process
44
+ * would keep its bugs, and a later push for the same version is skipped
45
+ * because the disk is already current.
46
+ */
47
+ setRestartHandler(fn) {
48
+ this.restartHandler = fn;
49
+ }
40
50
  /**
41
51
  * Start periodic update checks. Call once after supervisor bootstrap.
42
52
  */
@@ -44,9 +54,7 @@ export class DaemonUpdater {
44
54
  if (intervalMs <= 0 || this.periodicTimer)
45
55
  return;
46
56
  this.periodicTimer = setInterval(() => {
47
- this.checkAndApply().catch((err) => {
48
- this.log.warn(`periodic update check failed: ${String(err)}`);
49
- });
57
+ void this.applyAndRestart();
50
58
  }, intervalMs);
51
59
  this.periodicTimer.unref?.();
52
60
  }
@@ -84,7 +92,13 @@ export class DaemonUpdater {
84
92
  const jitter = Math.random() * 180_000;
85
93
  await new Promise((r) => setTimeout(r, jitter));
86
94
  }
87
- return this.checkAndApply(targetVersion);
95
+ return this.applyAndRestart(targetVersion);
96
+ }
97
+ async applyAndRestart(targetVersion) {
98
+ const applied = await this.checkAndApply(targetVersion);
99
+ if (applied)
100
+ this.restartHandler?.();
101
+ return applied;
88
102
  }
89
103
  /**
90
104
  * Check if we need to roll back from a failed update.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parall/daemon",
3
- "version": "1.69.0",
3
+ "version": "1.70.0",
4
4
  "description": "Parall local agent runtime — daemon supervisor + bridge runtimes, bundled as standalone JS files",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -34,11 +34,11 @@
34
34
  "@opentelemetry/api": "^1.9.0",
35
35
  "@pinixai/bb-browser-pro": "0.15.0",
36
36
  "ws": "^8.18.0",
37
- "@parall/agent-core": "1.69.0",
38
- "@parall/sdk": "1.69.0",
39
- "@parall/claude-agent": "1.69.0",
40
- "@parall/codex-agent": "1.69.0",
41
- "@parall/openclaw-agent": "1.69.0"
37
+ "@parall/codex-agent": "1.70.0",
38
+ "@parall/sdk": "1.70.0",
39
+ "@parall/openclaw-agent": "1.70.0",
40
+ "@parall/agent-core": "1.70.0",
41
+ "@parall/claude-agent": "1.70.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.0.0",