@zixt/host 0.0.123 → 0.0.125

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 (2) hide show
  1. package/dist/index.js +306 -266
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import { homedir as homedir4 } from "node:os";
28
28
  // package.json
29
29
  var package_default = {
30
30
  name: "@zixt/host",
31
- version: "0.0.123",
31
+ version: "0.0.125",
32
32
  type: "module",
33
33
  exports: {
34
34
  ".": "./src/client.ts",
@@ -22010,7 +22010,7 @@ var SetupGuideReplyRequest = external_exports.object({
22010
22010
  page: SetupGuidePageContext,
22011
22011
  onboarding: SetupGuideOnboardingState,
22012
22012
  actions: external_exports.array(SetupGuideAvailableAction).max(128),
22013
- toolResults: external_exports.array(SetupGuideToolResult).max(8).default([])
22013
+ toolResults: external_exports.array(SetupGuideToolResult).max(12).default([])
22014
22014
  });
22015
22015
  var SetupGuideProposedAction = external_exports.object({
22016
22016
  actionId: external_exports.string().regex(/^[a-z][a-z0-9_.-]{0,79}$/),
@@ -22475,7 +22475,7 @@ function runnerCommandCandidates(type, options = {}) {
22475
22475
  return platform === "win32" ? [join3(toolsRoot, "codex")] : [join3(toolsRoot, "bin", "codex")];
22476
22476
  }
22477
22477
  async function commandRuns(path) {
22478
- return new Promise((resolve18) => {
22478
+ return new Promise((resolve19) => {
22479
22479
  let child;
22480
22480
  try {
22481
22481
  child = spawnCli(path, ["--version"], {
@@ -22483,21 +22483,21 @@ async function commandRuns(path) {
22483
22483
  windowsHide: true
22484
22484
  });
22485
22485
  } catch {
22486
- resolve18(false);
22486
+ resolve19(false);
22487
22487
  return;
22488
22488
  }
22489
22489
  const timer = setTimeout(() => {
22490
22490
  child.kill();
22491
- resolve18(false);
22491
+ resolve19(false);
22492
22492
  }, 1e4);
22493
22493
  timer.unref?.();
22494
22494
  child.once("error", () => {
22495
22495
  clearTimeout(timer);
22496
- resolve18(false);
22496
+ resolve19(false);
22497
22497
  });
22498
22498
  child.once("exit", (code) => {
22499
22499
  clearTimeout(timer);
22500
- resolve18(code === 0);
22500
+ resolve19(code === 0);
22501
22501
  });
22502
22502
  });
22503
22503
  }
@@ -22703,7 +22703,7 @@ async function generateTaskTitle(instructions, runner) {
22703
22703
  instructions.slice(0, INSTRUCTIONS_BUDGET),
22704
22704
  "</task_request>"
22705
22705
  ].join("\n");
22706
- return new Promise((resolve18) => {
22706
+ return new Promise((resolve19) => {
22707
22707
  const child = spawnCli(
22708
22708
  command,
22709
22709
  [
@@ -22726,7 +22726,7 @@ async function generateTaskTitle(instructions, runner) {
22726
22726
  if (settled) return;
22727
22727
  settled = true;
22728
22728
  clearTimeout(timer);
22729
- resolve18(value);
22729
+ resolve19(value);
22730
22730
  };
22731
22731
  const timer = setTimeout(() => {
22732
22732
  child.kill();
@@ -23055,11 +23055,11 @@ function createWorkerWatchdogSendDrain() {
23055
23055
  if (completed) return;
23056
23056
  completed = true;
23057
23057
  pending--;
23058
- if (pending === 0) drained.splice(0).forEach((resolve18) => resolve18());
23058
+ if (pending === 0) drained.splice(0).forEach((resolve19) => resolve19());
23059
23059
  };
23060
23060
  },
23061
23061
  drain: async () => {
23062
- if (pending > 0) await new Promise((resolve18) => drained.push(resolve18));
23062
+ if (pending > 0) await new Promise((resolve19) => drained.push(resolve19));
23063
23063
  }
23064
23064
  };
23065
23065
  }
@@ -23576,7 +23576,7 @@ async function waitForOperationGrantRetry(retryAt, signal) {
23576
23576
  const deadline = Date.parse(retryAt);
23577
23577
  if (!Number.isFinite(deadline) || signal.aborted) return false;
23578
23578
  if (deadline <= Date.now()) return true;
23579
- return await new Promise((resolve18) => {
23579
+ return await new Promise((resolve19) => {
23580
23580
  let settled = false;
23581
23581
  let timer;
23582
23582
  const finish = (ready) => {
@@ -23584,7 +23584,7 @@ async function waitForOperationGrantRetry(retryAt, signal) {
23584
23584
  settled = true;
23585
23585
  if (timer) clearTimeout(timer);
23586
23586
  signal.removeEventListener("abort", onAbort);
23587
- resolve18(ready);
23587
+ resolve19(ready);
23588
23588
  };
23589
23589
  const onAbort = () => finish(false);
23590
23590
  const schedule = () => {
@@ -23865,27 +23865,27 @@ var HostClient = class _HostClient {
23865
23865
  const unwindingAssignments = [...this.activeAssignments.values()];
23866
23866
  for (const cancel of this.cancels.values()) cancel(stopReason);
23867
23867
  for (const entry of this.secretGrants.values()) {
23868
- for (const resolve18 of entry.resolvers) resolve18({});
23868
+ for (const resolve19 of entry.resolvers) resolve19({});
23869
23869
  entry.resolvers = [];
23870
23870
  delete entry.value;
23871
23871
  }
23872
23872
  for (const entry of this.connectionGrants.values()) {
23873
- for (const resolve18 of entry.resolvers) resolve18([]);
23873
+ for (const resolve19 of entry.resolvers) resolve19([]);
23874
23874
  entry.resolvers = [];
23875
23875
  delete entry.value;
23876
23876
  }
23877
23877
  for (const entry of this.providerGrants.values()) {
23878
- for (const resolve18 of entry.resolvers) resolve18([]);
23878
+ for (const resolve19 of entry.resolvers) resolve19([]);
23879
23879
  entry.resolvers = [];
23880
23880
  delete entry.value;
23881
23881
  }
23882
23882
  for (const entry of this.integrationToolServerGrants.values()) {
23883
- for (const resolve18 of entry.resolvers) resolve18([]);
23883
+ for (const resolve19 of entry.resolvers) resolve19([]);
23884
23884
  entry.resolvers = [];
23885
23885
  delete entry.value;
23886
23886
  }
23887
23887
  for (const waiters of this.approvalWaiters.values()) {
23888
- for (const resolve18 of waiters.values()) resolve18({ approved: false, guidance: reason });
23888
+ for (const resolve19 of waiters.values()) resolve19({ approved: false, guidance: reason });
23889
23889
  }
23890
23890
  for (const waiters of this.agentOpWaiters.values()) {
23891
23891
  for (const waiter of waiters.values()) {
@@ -23912,9 +23912,9 @@ var HostClient = class _HostClient {
23912
23912
  let drainTimer;
23913
23913
  const drained = await Promise.race([
23914
23914
  Promise.allSettled(runs).then(() => true),
23915
- new Promise((resolve18) => {
23915
+ new Promise((resolve19) => {
23916
23916
  drainTimer = setTimeout(
23917
- () => resolve18(false),
23917
+ () => resolve19(false),
23918
23918
  this.opts.unwindTimeoutMs ?? _HostClient.DEFAULT_UNWIND_TIMEOUT_MS
23919
23919
  );
23920
23920
  drainTimer.unref?.();
@@ -24062,9 +24062,9 @@ var HostClient = class _HostClient {
24062
24062
  let frameDrainTimer;
24063
24063
  const framesDrained = await Promise.race([
24064
24064
  frameTail.then(() => true),
24065
- new Promise((resolve18) => {
24065
+ new Promise((resolve19) => {
24066
24066
  frameDrainTimer = setTimeout(
24067
- () => resolve18(false),
24067
+ () => resolve19(false),
24068
24068
  this.opts.unwindTimeoutMs ?? _HostClient.DEFAULT_UNWIND_TIMEOUT_MS
24069
24069
  );
24070
24070
  frameDrainTimer.unref?.();
@@ -24640,7 +24640,7 @@ var HostClient = class _HostClient {
24640
24640
  const entry = this.secretGrants.get(key) ?? { resolvers: [] };
24641
24641
  entry.value = message.secrets;
24642
24642
  entry.expiresAt = expiresAt;
24643
- for (const resolve18 of entry.resolvers) resolve18(message.secrets);
24643
+ for (const resolve19 of entry.resolvers) resolve19(message.secrets);
24644
24644
  entry.resolvers = [];
24645
24645
  this.secretGrants.set(key, entry);
24646
24646
  return;
@@ -24671,19 +24671,19 @@ var HostClient = class _HostClient {
24671
24671
  const entry = this.connectionGrants.get(key) ?? { resolvers: [] };
24672
24672
  entry.value = message.connections;
24673
24673
  entry.expiresAt = expiresAt;
24674
- for (const resolve18 of entry.resolvers) resolve18(message.connections);
24674
+ for (const resolve19 of entry.resolvers) resolve19(message.connections);
24675
24675
  entry.resolvers = [];
24676
24676
  this.connectionGrants.set(key, entry);
24677
24677
  const providerEntry = this.providerGrants.get(key) ?? { resolvers: [] };
24678
24678
  providerEntry.value = providers;
24679
24679
  providerEntry.expiresAt = authorityExpiresAt;
24680
- for (const resolve18 of providerEntry.resolvers) resolve18(providers);
24680
+ for (const resolve19 of providerEntry.resolvers) resolve19(providers);
24681
24681
  providerEntry.resolvers = [];
24682
24682
  this.providerGrants.set(key, providerEntry);
24683
24683
  const toolServerEntry = this.integrationToolServerGrants.get(key) ?? { resolvers: [] };
24684
24684
  const toolServers = [...message.toolServers ?? []];
24685
24685
  toolServerEntry.value = toolServers;
24686
- for (const resolve18 of toolServerEntry.resolvers) resolve18(toolServers);
24686
+ for (const resolve19 of toolServerEntry.resolvers) resolve19(toolServers);
24687
24687
  toolServerEntry.resolvers = [];
24688
24688
  this.integrationToolServerGrants.set(key, toolServerEntry);
24689
24689
  return;
@@ -24822,8 +24822,8 @@ var HostClient = class _HostClient {
24822
24822
  return redactCredentialText(text, sensitiveSnapshot()).slice(0, maxLength);
24823
24823
  };
24824
24824
  let resolveCancelled;
24825
- const cancelledPromise = new Promise((resolve18) => {
24826
- resolveCancelled = resolve18;
24825
+ const cancelledPromise = new Promise((resolve19) => {
24826
+ resolveCancelled = resolve19;
24827
24827
  });
24828
24828
  const endAuthority = (reason = "cloud_cancel") => {
24829
24829
  if (stopReason) return;
@@ -24832,28 +24832,28 @@ var HostClient = class _HostClient {
24832
24832
  authorityController.abort(reason);
24833
24833
  const secretEntry = this.secretGrants.get(cancelKey);
24834
24834
  if (secretEntry) {
24835
- for (const resolve18 of secretEntry.resolvers) resolve18({});
24835
+ for (const resolve19 of secretEntry.resolvers) resolve19({});
24836
24836
  secretEntry.resolvers = [];
24837
24837
  delete secretEntry.value;
24838
24838
  }
24839
24839
  this.secretGrants.delete(cancelKey);
24840
24840
  const connectionEntry = this.connectionGrants.get(cancelKey);
24841
24841
  if (connectionEntry) {
24842
- for (const resolve18 of connectionEntry.resolvers) resolve18([]);
24842
+ for (const resolve19 of connectionEntry.resolvers) resolve19([]);
24843
24843
  connectionEntry.resolvers = [];
24844
24844
  delete connectionEntry.value;
24845
24845
  }
24846
24846
  this.connectionGrants.delete(cancelKey);
24847
24847
  const providerEntry = this.providerGrants.get(cancelKey);
24848
24848
  if (providerEntry) {
24849
- for (const resolve18 of providerEntry.resolvers) resolve18([]);
24849
+ for (const resolve19 of providerEntry.resolvers) resolve19([]);
24850
24850
  providerEntry.resolvers = [];
24851
24851
  delete providerEntry.value;
24852
24852
  }
24853
24853
  this.providerGrants.delete(cancelKey);
24854
24854
  const toolServerEntry = this.integrationToolServerGrants.get(cancelKey);
24855
24855
  if (toolServerEntry) {
24856
- for (const resolve18 of toolServerEntry.resolvers) resolve18([]);
24856
+ for (const resolve19 of toolServerEntry.resolvers) resolve19([]);
24857
24857
  toolServerEntry.resolvers = [];
24858
24858
  delete toolServerEntry.value;
24859
24859
  }
@@ -24861,8 +24861,8 @@ var HostClient = class _HostClient {
24861
24861
  this.clearAuthorityExpiry(cancelKey);
24862
24862
  const approvalWaiters = this.approvalWaiters.get(cancelKey);
24863
24863
  if (approvalWaiters) {
24864
- for (const resolve18 of approvalWaiters.values()) {
24865
- resolve18({ approved: false, guidance: "task was cancelled" });
24864
+ for (const resolve19 of approvalWaiters.values()) {
24865
+ resolve19({ approved: false, guidance: "task was cancelled" });
24866
24866
  }
24867
24867
  approvalWaiters.clear();
24868
24868
  }
@@ -24988,9 +24988,9 @@ var HostClient = class _HostClient {
24988
24988
  return value;
24989
24989
  };
24990
24990
  if (entry.value) return Promise.resolve(capture(entry.value));
24991
- return new Promise((resolve18) => {
24992
- entry.resolvers.push((value) => resolve18(capture(value)));
24993
- setTimeout(() => resolve18(capture(entry.value ?? {})), _HostClient.SECRETS_WAIT_MS);
24991
+ return new Promise((resolve19) => {
24992
+ entry.resolvers.push((value) => resolve19(capture(value)));
24993
+ setTimeout(() => resolve19(capture(entry.value ?? {})), _HostClient.SECRETS_WAIT_MS);
24994
24994
  });
24995
24995
  };
24996
24996
  const connections = () => {
@@ -25007,9 +25007,9 @@ var HostClient = class _HostClient {
25007
25007
  return value;
25008
25008
  };
25009
25009
  if (entry.value) return Promise.resolve(capture(entry.value));
25010
- return new Promise((resolve18) => {
25011
- entry.resolvers.push((value) => resolve18(capture(value)));
25012
- setTimeout(() => resolve18(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25010
+ return new Promise((resolve19) => {
25011
+ entry.resolvers.push((value) => resolve19(capture(value)));
25012
+ setTimeout(() => resolve19(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25013
25013
  });
25014
25014
  };
25015
25015
  const providers = () => {
@@ -25026,9 +25026,9 @@ var HostClient = class _HostClient {
25026
25026
  return value;
25027
25027
  };
25028
25028
  if (entry.value !== void 0) return Promise.resolve(capture(entry.value));
25029
- return new Promise((resolve18) => {
25030
- entry.resolvers.push((value) => resolve18(capture(value)));
25031
- setTimeout(() => resolve18(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25029
+ return new Promise((resolve19) => {
25030
+ entry.resolvers.push((value) => resolve19(capture(value)));
25031
+ setTimeout(() => resolve19(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25032
25032
  });
25033
25033
  };
25034
25034
  const integrationToolServers = () => {
@@ -25037,9 +25037,9 @@ var HostClient = class _HostClient {
25037
25037
  this.integrationToolServerGrants.set(cancelKey, entry);
25038
25038
  const capture = (value) => authorityController.signal.aborted ? [] : value;
25039
25039
  if (entry.value !== void 0) return Promise.resolve(capture(entry.value));
25040
- return new Promise((resolve18) => {
25041
- entry.resolvers.push((value) => resolve18(capture(value)));
25042
- setTimeout(() => resolve18(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25040
+ return new Promise((resolve19) => {
25041
+ entry.resolvers.push((value) => resolve19(capture(value)));
25042
+ setTimeout(() => resolve19(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
25043
25043
  });
25044
25044
  };
25045
25045
  const linear = async () => {
@@ -25066,13 +25066,13 @@ var HostClient = class _HostClient {
25066
25066
  ...questionChoices ? { questionChoices: [...questionChoices] } : {},
25067
25067
  ...questionnaire ? { questionnaire } : {}
25068
25068
  });
25069
- return new Promise((resolve18) => {
25069
+ return new Promise((resolve19) => {
25070
25070
  const waiters = this.approvalWaiters.get(cancelKey) ?? /* @__PURE__ */ new Map();
25071
25071
  this.approvalWaiters.set(cancelKey, waiters);
25072
- waiters.set(requestId, resolve18);
25072
+ waiters.set(requestId, resolve19);
25073
25073
  void cancelledPromise.then(() => {
25074
25074
  if (waiters.delete(requestId)) {
25075
- resolve18({ approved: false, guidance: "task was cancelled" });
25075
+ resolve19({ approved: false, guidance: "task was cancelled" });
25076
25076
  }
25077
25077
  });
25078
25078
  });
@@ -25118,11 +25118,11 @@ var HostClient = class _HostClient {
25118
25118
  if (existing) message = existing;
25119
25119
  else terminalMessages.set(requestId, message);
25120
25120
  }
25121
- return new Promise((resolve18) => {
25121
+ return new Promise((resolve19) => {
25122
25122
  const waiters = this.agentOpWaiters.get(cancelKey) ?? /* @__PURE__ */ new Map();
25123
25123
  this.agentOpWaiters.set(cancelKey, waiters);
25124
25124
  if (waiters.has(requestId)) {
25125
- resolve18({ ok: false, error: "provider settlement request is already in flight" });
25125
+ resolve19({ ok: false, error: "provider settlement request is already in flight" });
25126
25126
  return;
25127
25127
  }
25128
25128
  const timer = setTimeout(() => {
@@ -25133,7 +25133,7 @@ var HostClient = class _HostClient {
25133
25133
  (pending) => !(pending.type === "agent.op" && pending.requestId === requestId)
25134
25134
  );
25135
25135
  }
25136
- resolve18({
25136
+ resolve19({
25137
25137
  ok: false,
25138
25138
  error: terminal ? "The provider call completed, but Zixt could not record its outcome. Do not retry; wait for reconciliation." : "the platform did not answer in time; verify with a list_* tool before retrying a mutating call"
25139
25139
  });
@@ -25141,7 +25141,7 @@ var HostClient = class _HostClient {
25141
25141
  }, _HostClient.AGENT_OP_TIMEOUT_MS);
25142
25142
  timer.unref?.();
25143
25143
  waiters.set(requestId, {
25144
- resolve: resolve18,
25144
+ resolve: resolve19,
25145
25145
  timer,
25146
25146
  ...terminal ? { terminalMessage: message } : {}
25147
25147
  });
@@ -25187,12 +25187,12 @@ var HostClient = class _HostClient {
25187
25187
  "No GitHub change was attempted; the authority grant request was invalid."
25188
25188
  );
25189
25189
  }
25190
- const outcome = await new Promise((resolve18) => {
25190
+ const outcome = await new Promise((resolve19) => {
25191
25191
  const timer = setTimeout(() => {
25192
25192
  const waiter = this.operationGrantWaiters.get(requestId);
25193
25193
  if (!waiter) return;
25194
25194
  this.operationGrantWaiters.delete(requestId);
25195
- resolve18({ grant: null, retryable: true, reason: "no_reply_from_zixt" });
25195
+ resolve19({ grant: null, retryable: true, reason: "no_reply_from_zixt" });
25196
25196
  }, this.operationGrantTimeoutMs);
25197
25197
  timer.unref?.();
25198
25198
  this.operationGrantWaiters.set(requestId, {
@@ -25205,9 +25205,9 @@ var HostClient = class _HostClient {
25205
25205
  timer,
25206
25206
  accept: (grant) => {
25207
25207
  addSensitiveValues(providerGrantSensitiveValues(grant));
25208
- resolve18({ grant });
25208
+ resolve19({ grant });
25209
25209
  },
25210
- deny: (retryable, reason, detail, retryAt, retryCode) => resolve18({
25210
+ deny: (retryable, reason, detail, retryAt, retryCode) => resolve19({
25211
25211
  grant: null,
25212
25212
  retryable,
25213
25213
  reason,
@@ -25221,7 +25221,7 @@ var HostClient = class _HostClient {
25221
25221
  } catch {
25222
25222
  clearTimeout(timer);
25223
25223
  this.operationGrantWaiters.delete(requestId);
25224
- resolve18({ grant: null, retryable: false, reason: "connection_unavailable" });
25224
+ resolve19({ grant: null, retryable: false, reason: "connection_unavailable" });
25225
25225
  }
25226
25226
  });
25227
25227
  if (outcome.grant) {
@@ -25277,7 +25277,7 @@ var HostClient = class _HostClient {
25277
25277
  )
25278
25278
  );
25279
25279
  }
25280
- return new Promise((resolve18, reject3) => {
25280
+ return new Promise((resolve19, reject3) => {
25281
25281
  const timer = setTimeout(() => {
25282
25282
  if (this.browserCredentialWaiters.delete(requestId)) {
25283
25283
  reject3(
@@ -25296,7 +25296,7 @@ var HostClient = class _HostClient {
25296
25296
  timer,
25297
25297
  accept: (credential) => {
25298
25298
  addSensitiveValues(webLoginSensitiveValues(credential));
25299
- resolve18(credential);
25299
+ resolve19(credential);
25300
25300
  },
25301
25301
  deny: (reason) => reject3(new Error(reason))
25302
25302
  });
@@ -25619,14 +25619,14 @@ async function observeWindowsGuardianNonce(pid, nonce) {
25619
25619
  "Windows runner identity could not be observed"
25620
25620
  );
25621
25621
  }
25622
- return new Promise((resolve18, reject3) => {
25622
+ return new Promise((resolve19, reject3) => {
25623
25623
  let done = false;
25624
25624
  const finish = (result) => {
25625
25625
  if (done) return;
25626
25626
  done = true;
25627
25627
  clearTimeout(timeout);
25628
25628
  if (result instanceof Error) reject3(result);
25629
- else resolve18(result);
25629
+ else resolve19(result);
25630
25630
  };
25631
25631
  const timeout = setTimeout(
25632
25632
  () => finish(
@@ -25671,7 +25671,7 @@ async function observePosixGuardianNonce(pid, nonce) {
25671
25671
  );
25672
25672
  }
25673
25673
  }
25674
- return new Promise((resolve18, reject3) => {
25674
+ return new Promise((resolve19, reject3) => {
25675
25675
  const observer = spawn3("/bin/ps", ["-ww", "-o", "command=", "-p", String(pid)], {
25676
25676
  stdio: ["ignore", "pipe", "ignore"]
25677
25677
  });
@@ -25682,7 +25682,7 @@ async function observePosixGuardianNonce(pid, nonce) {
25682
25682
  done = true;
25683
25683
  clearTimeout(timeout);
25684
25684
  if (result instanceof Error) reject3(result);
25685
- else resolve18(result);
25685
+ else resolve19(result);
25686
25686
  };
25687
25687
  const timeout = setTimeout(() => {
25688
25688
  observer.kill("SIGKILL");
@@ -25729,7 +25729,7 @@ async function observeGuardianIdentity(pid, identity) {
25729
25729
  return process.platform === "win32" ? observeWindowsGuardianNonce(pid, identity.nonce) : observePosixGuardianNonce(pid, identity.nonce);
25730
25730
  }
25731
25731
  function delay(ms) {
25732
- return new Promise((resolve18) => setTimeout(resolve18, ms));
25732
+ return new Promise((resolve19) => setTimeout(resolve19, ms));
25733
25733
  }
25734
25734
  function posixProcessRecordsFromPs(output) {
25735
25735
  const records = [];
@@ -25762,7 +25762,7 @@ function posixProcessRecordsFromPs(output) {
25762
25762
  return records;
25763
25763
  }
25764
25764
  async function snapshotPosixProcesses() {
25765
- return new Promise((resolve18, reject3) => {
25765
+ return new Promise((resolve19, reject3) => {
25766
25766
  const observer = spawn3("/bin/ps", ["-axo", "uid=,pid=,ppid=,pgid=,stat="], {
25767
25767
  stdio: ["ignore", "pipe", "ignore"]
25768
25768
  });
@@ -25775,7 +25775,7 @@ async function snapshotPosixProcesses() {
25775
25775
  if (error52) reject3(error52);
25776
25776
  else {
25777
25777
  try {
25778
- resolve18(posixProcessRecordsFromPs(output));
25778
+ resolve19(posixProcessRecordsFromPs(output));
25779
25779
  } catch (caught) {
25780
25780
  reject3(caught);
25781
25781
  }
@@ -26110,7 +26110,7 @@ async function snapshotWindowsDescendants(rootPid) {
26110
26110
  "Windows process-tree observation could not start"
26111
26111
  );
26112
26112
  }
26113
- return new Promise((resolve18, reject3) => {
26113
+ return new Promise((resolve19, reject3) => {
26114
26114
  let done = false;
26115
26115
  const timeout = setTimeout(() => {
26116
26116
  if (done) return;
@@ -26137,7 +26137,7 @@ async function snapshotWindowsDescendants(rootPid) {
26137
26137
  return;
26138
26138
  }
26139
26139
  try {
26140
- resolve18(completeWindowsDescendantPids(rootPid, processes));
26140
+ resolve19(completeWindowsDescendantPids(rootPid, processes));
26141
26141
  } catch (caught) {
26142
26142
  reject3(caught);
26143
26143
  }
@@ -26184,7 +26184,7 @@ async function waitForProcessesExit(pids, timeoutMs) {
26184
26184
  }
26185
26185
  async function runTaskkill(pid, command, timeoutMs = TASKKILL_TIMEOUT_MS, independentlyTrackedPids = []) {
26186
26186
  const trustedCommand = command ?? defaultTaskkillCommand();
26187
- const result = await new Promise((resolve18, reject3) => {
26187
+ const result = await new Promise((resolve19, reject3) => {
26188
26188
  const killer = spawn3(trustedCommand, ["/PID", String(pid), "/T", "/F"], {
26189
26189
  stdio: ["ignore", "pipe", "pipe"],
26190
26190
  windowsHide: true
@@ -26219,7 +26219,7 @@ async function runTaskkill(pid, command, timeoutMs = TASKKILL_TIMEOUT_MS, indepe
26219
26219
  done = true;
26220
26220
  clearTimeout(timeout);
26221
26221
  if (error52) reject3(error52);
26222
- else resolve18({ code: killer.exitCode, output, outputTruncated });
26222
+ else resolve19({ code: killer.exitCode, output, outputTruncated });
26223
26223
  };
26224
26224
  killer.once(
26225
26225
  "error",
@@ -27021,12 +27021,12 @@ async function createWindowsJobContainment(pid, options) {
27021
27021
  stderr = `${stderr}${String(chunk)}`.slice(-HELPER_OUTPUT_LIMIT);
27022
27022
  });
27023
27023
  const helperEvents = helper;
27024
- const exited = new Promise((resolve18) => {
27024
+ const exited = new Promise((resolve19) => {
27025
27025
  let completed = false;
27026
27026
  const complete = (code, signal) => {
27027
27027
  if (completed) return;
27028
27028
  completed = true;
27029
- resolve18({ code, signal });
27029
+ resolve19({ code, signal });
27030
27030
  };
27031
27031
  helperEvents.once("error", () => {
27032
27032
  failProtocol(new Error("Windows Job Object helper could not start"));
@@ -27039,7 +27039,7 @@ async function createWindowsJobContainment(pid, options) {
27039
27039
  });
27040
27040
  const nextLine = async (expected) => {
27041
27041
  if (protocolFailure) throw protocolFailure;
27042
- const line = lines.shift() ?? await new Promise((resolve18, reject3) => {
27042
+ const line = lines.shift() ?? await new Promise((resolve19, reject3) => {
27043
27043
  const timer = setTimeout(
27044
27044
  () => reject3(timeoutError("Windows Job Object helper did not answer in time")),
27045
27045
  timeoutMs
@@ -27047,7 +27047,7 @@ async function createWindowsJobContainment(pid, options) {
27047
27047
  timer.unref?.();
27048
27048
  lineWaiters.push((value) => {
27049
27049
  clearTimeout(timer);
27050
- resolve18(value);
27050
+ resolve19(value);
27051
27051
  });
27052
27052
  });
27053
27053
  if (protocolFailure) throw protocolFailure;
@@ -27060,8 +27060,8 @@ async function createWindowsJobContainment(pid, options) {
27060
27060
  }
27061
27061
  const stopped = await Promise.race([
27062
27062
  exited.then(() => true),
27063
- new Promise((resolve18) => {
27064
- const timer = setTimeout(() => resolve18(false), timeoutMs);
27063
+ new Promise((resolve19) => {
27064
+ const timer = setTimeout(() => resolve19(false), timeoutMs);
27065
27065
  timer.unref?.();
27066
27066
  })
27067
27067
  ]);
@@ -27120,7 +27120,7 @@ async function awaitWindowsContainmentGate(env = process.env, input = process.st
27120
27120
  if (nonce === void 0) return true;
27121
27121
  if (!SAFE_NONCE2.test(nonce)) return false;
27122
27122
  const expected = windowsContainmentGate(nonce).trimEnd();
27123
- return new Promise((resolve18) => {
27123
+ return new Promise((resolve19) => {
27124
27124
  let pending = Buffer.alloc(0);
27125
27125
  let settled = false;
27126
27126
  const finish = (result) => {
@@ -27131,7 +27131,7 @@ async function awaitWindowsContainmentGate(env = process.env, input = process.st
27131
27131
  input.off("end", onEnd);
27132
27132
  input.off("error", onEnd);
27133
27133
  if (result) input.pause();
27134
- resolve18(result);
27134
+ resolve19(result);
27135
27135
  };
27136
27136
  const onData = (chunk) => {
27137
27137
  pending = Buffer.concat([pending, chunk]);
@@ -28236,7 +28236,7 @@ async function installRelease(version2, options = {}) {
28236
28236
  }) : Promise.resolve(null);
28237
28237
  const timeoutMs = options.timeoutMs ?? INSTALL_TIMEOUT_MS2;
28238
28238
  const outcome = { code: null, signal: null, timedOut: false, spawnError: null };
28239
- const installed = await new Promise((resolve18, reject3) => {
28239
+ const installed = await new Promise((resolve19, reject3) => {
28240
28240
  let finished = false;
28241
28241
  let cleanupStarted = false;
28242
28242
  let exitObserved = false;
@@ -28252,7 +28252,7 @@ async function installRelease(version2, options = {}) {
28252
28252
  finished = true;
28253
28253
  clearTimeout(timer);
28254
28254
  options.signal?.removeEventListener("abort", requestCleanup);
28255
- resolve18(result);
28255
+ resolve19(result);
28256
28256
  };
28257
28257
  const requestCleanup = () => {
28258
28258
  if (cleanupStarted || finished) return;
@@ -28617,11 +28617,11 @@ async function runWorkerCompatibilityProxy(env = process.env, argv = process.arg
28617
28617
  child.stdin?.on("error", () => {
28618
28618
  });
28619
28619
  process.stdin.pipe(child.stdin);
28620
- return new Promise((resolve18) => {
28621
- child.once("error", () => resolve18(1));
28620
+ return new Promise((resolve19) => {
28621
+ child.once("error", () => resolve19(1));
28622
28622
  child.once("exit", (code) => {
28623
28623
  process.stdin.unpipe(child.stdin);
28624
- resolve18(code ?? 1);
28624
+ resolve19(code ?? 1);
28625
28625
  });
28626
28626
  });
28627
28627
  }
@@ -28701,11 +28701,11 @@ async function launchHostSupervisor(options = {}) {
28701
28701
  const waitOrStop = async (ms) => {
28702
28702
  if (stopping) return false;
28703
28703
  if (!customDelay) {
28704
- await new Promise((resolve18) => {
28704
+ await new Promise((resolve19) => {
28705
28705
  const finish = () => {
28706
28706
  clearTimeout(timer);
28707
28707
  stopController.signal.removeEventListener("abort", finish);
28708
- resolve18();
28708
+ resolve19();
28709
28709
  };
28710
28710
  const timer = setTimeout(finish, ms);
28711
28711
  stopController.signal.addEventListener("abort", finish, { once: true });
@@ -28713,8 +28713,8 @@ async function launchHostSupervisor(options = {}) {
28713
28713
  return !stopping;
28714
28714
  }
28715
28715
  let finishStop;
28716
- const stopped = new Promise((resolve18) => {
28717
- finishStop = () => resolve18();
28716
+ const stopped = new Promise((resolve19) => {
28717
+ finishStop = () => resolve19();
28718
28718
  stopController.signal.addEventListener("abort", finishStop, { once: true });
28719
28719
  });
28720
28720
  await Promise.race([customDelay(ms), stopped]);
@@ -28844,19 +28844,19 @@ async function launchHostSupervisor(options = {}) {
28844
28844
  child = spawnSupervisor(entry, version2, ownershipDirectory, containmentGateNonce);
28845
28845
  const launchedSupervisor = child;
28846
28846
  let resolveChildExited;
28847
- const childExited = new Promise((resolve18) => {
28848
- resolveChildExited = resolve18;
28847
+ const childExited = new Promise((resolve19) => {
28848
+ resolveChildExited = resolve19;
28849
28849
  });
28850
28850
  const supervisorContainmentAbort = new AbortController();
28851
28851
  void childExited.then(() => supervisorContainmentAbort.abort());
28852
28852
  const outcomePromise = new Promise(
28853
- (resolve18) => {
28853
+ (resolve19) => {
28854
28854
  let observed = false;
28855
28855
  const finish = (code, signal) => {
28856
28856
  if (observed) return;
28857
28857
  observed = true;
28858
28858
  resolveChildExited();
28859
- resolve18({ code, signal });
28859
+ resolve19({ code, signal });
28860
28860
  };
28861
28861
  child.once("error", () => finish(1, null));
28862
28862
  child.once("exit", finish);
@@ -28877,12 +28877,12 @@ async function launchHostSupervisor(options = {}) {
28877
28877
  if (!supervisorContainment || !launchedSupervisor.stdin) {
28878
28878
  throw new Error("supervisor Job Object gate is unavailable");
28879
28879
  }
28880
- await new Promise((resolve18, reject3) => {
28880
+ await new Promise((resolve19, reject3) => {
28881
28881
  launchedSupervisor.stdin.write(
28882
28882
  windowsContainmentGate(containmentGateNonce),
28883
28883
  (error52) => {
28884
28884
  if (error52) reject3(error52);
28885
- else resolve18();
28885
+ else resolve19();
28886
28886
  }
28887
28887
  );
28888
28888
  });
@@ -29030,19 +29030,19 @@ async function superviseHost(options = {}) {
29030
29030
  }
29031
29031
  }
29032
29032
  let announceShutdown;
29033
- const shutdownAnnounced = new Promise((resolve18) => {
29034
- announceShutdown = resolve18;
29033
+ const shutdownAnnounced = new Promise((resolve19) => {
29034
+ announceShutdown = resolve19;
29035
29035
  });
29036
29036
  const attempted = /* @__PURE__ */ new Set();
29037
29037
  let unsatisfiableUpdates = 0;
29038
29038
  const waitOrShutdown = async (ms) => {
29039
29039
  if (shuttingDown2) return false;
29040
29040
  if (!customDelay) {
29041
- await new Promise((resolve18) => {
29041
+ await new Promise((resolve19) => {
29042
29042
  const finish = () => {
29043
29043
  clearTimeout(timer);
29044
29044
  shutdownController.signal.removeEventListener("abort", finish);
29045
- resolve18();
29045
+ resolve19();
29046
29046
  };
29047
29047
  const timer = setTimeout(finish, ms);
29048
29048
  shutdownController.signal.addEventListener("abort", finish, { once: true });
@@ -29192,19 +29192,19 @@ async function superviseHost(options = {}) {
29192
29192
  const watchedChild = child;
29193
29193
  const workerStderr = captureWorkerStderr(watchedChild);
29194
29194
  let resolveChildExited;
29195
- const childExited = new Promise((resolve18) => {
29196
- resolveChildExited = resolve18;
29195
+ const childExited = new Promise((resolve19) => {
29196
+ resolveChildExited = resolve19;
29197
29197
  });
29198
29198
  const workerContainmentAbort = new AbortController();
29199
29199
  void childExited.then(() => workerContainmentAbort.abort());
29200
29200
  const outcomePromise = new Promise(
29201
- (resolve18) => {
29201
+ (resolve19) => {
29202
29202
  let observed = false;
29203
29203
  const finish = (result) => {
29204
29204
  if (observed) return;
29205
29205
  observed = true;
29206
29206
  resolveChildExited();
29207
- resolve18(result);
29207
+ resolve19(result);
29208
29208
  };
29209
29209
  watchedChild.once("error", () => finish({ code: 1, signal: null }));
29210
29210
  watchedChild.once(
@@ -29226,10 +29226,10 @@ async function superviseHost(options = {}) {
29226
29226
  if (!workerContainment || !watchedChild.stdin) {
29227
29227
  throw new Error("worker Job Object gate is unavailable");
29228
29228
  }
29229
- await new Promise((resolve18, reject3) => {
29229
+ await new Promise((resolve19, reject3) => {
29230
29230
  watchedChild.stdin.write(windowsContainmentGate(containmentGateNonce), (error52) => {
29231
29231
  if (error52) reject3(error52);
29232
- else resolve18();
29232
+ else resolve19();
29233
29233
  });
29234
29234
  });
29235
29235
  }
@@ -29636,7 +29636,7 @@ function watchParentPipe(pipe2, onStop) {
29636
29636
  }
29637
29637
 
29638
29638
  // src/index.ts
29639
- import { homedir as homedir16, hostname as hostname3 } from "node:os";
29639
+ import { homedir as homedir17, hostname as hostname3 } from "node:os";
29640
29640
 
29641
29641
  // src/hardware.ts
29642
29642
  import { existsSync } from "node:fs";
@@ -30407,7 +30407,7 @@ async function loadPlaywright() {
30407
30407
  }
30408
30408
  async function installChromium() {
30409
30409
  const cliPath = join12(playwrightCoreRoot, "cli.js");
30410
- await new Promise((resolve18, reject3) => {
30410
+ await new Promise((resolve19, reject3) => {
30411
30411
  const child = spawn7(process.execPath, [cliPath, "install", "chromium"], {
30412
30412
  env: process.env,
30413
30413
  stdio: ["ignore", "inherit", "inherit"],
@@ -30422,7 +30422,7 @@ async function installChromium() {
30422
30422
  settled = true;
30423
30423
  clearTimeout(timeout);
30424
30424
  if (error52) reject3(error52);
30425
- else resolve18();
30425
+ else resolve19();
30426
30426
  };
30427
30427
  const timeout = setTimeout(() => {
30428
30428
  child.kill();
@@ -34226,8 +34226,8 @@ async function runGit(input, args, env) {
34226
34226
  let settled = false;
34227
34227
  let stopping = false;
34228
34228
  let resolveExited;
34229
- const exited = new Promise((resolve18) => {
34230
- resolveExited = resolve18;
34229
+ const exited = new Promise((resolve19) => {
34230
+ resolveExited = resolve19;
34231
34231
  });
34232
34232
  child.once("exit", resolveExited);
34233
34233
  const cleanup = () => {
@@ -37037,8 +37037,8 @@ var linearToolPackFactory = {
37037
37037
  async create(grant, context) {
37038
37038
  let resolveCancelled;
37039
37039
  let closed = false;
37040
- const cancelled = new Promise((resolve18) => {
37041
- resolveCancelled = resolve18;
37040
+ const cancelled = new Promise((resolve19) => {
37041
+ resolveCancelled = resolve19;
37042
37042
  });
37043
37043
  const cancel = () => {
37044
37044
  if (closed) return;
@@ -38074,7 +38074,7 @@ function createAskUserServer() {
38074
38074
  let server;
38075
38075
  let listening;
38076
38076
  function ensureListening() {
38077
- listening ??= new Promise((resolve18, reject3) => {
38077
+ listening ??= new Promise((resolve19, reject3) => {
38078
38078
  server = createServer2((req, res) => {
38079
38079
  res.on("error", () => {
38080
38080
  });
@@ -38090,7 +38090,7 @@ function createAskUserServer() {
38090
38090
  server.on("error", reject3);
38091
38091
  server.listen(0, "127.0.0.1", () => {
38092
38092
  const address = server.address();
38093
- if (address && typeof address === "object") resolve18(address.port);
38093
+ if (address && typeof address === "object") resolve19(address.port);
38094
38094
  else reject3(new Error("ask_user server failed to bind"));
38095
38095
  });
38096
38096
  server.unref();
@@ -40646,7 +40646,7 @@ function runCliProcess(options) {
40646
40646
  usage: { inputTokens: 0, outputTokens: 0 }
40647
40647
  });
40648
40648
  }
40649
- return new Promise((resolve18) => {
40649
+ return new Promise((resolve19) => {
40650
40650
  const platform = options.platform ?? process.platform;
40651
40651
  const containmentGateNonce = options.guardian && platform === "win32" ? randomUUID11() : void 0;
40652
40652
  const child = options.guardian ? spawn10(
@@ -40708,7 +40708,7 @@ function runCliProcess(options) {
40708
40708
  clearInterval(timer);
40709
40709
  unregisterFollowUps?.();
40710
40710
  parser.stop?.();
40711
- resolve18(result);
40711
+ resolve19(result);
40712
40712
  };
40713
40713
  const terminate = (result) => {
40714
40714
  if (settled || forcedResult) return;
@@ -41054,7 +41054,7 @@ async function readCodexSessionRuntime(input) {
41054
41054
  }
41055
41055
  var codexCatalogCache = /* @__PURE__ */ new Map();
41056
41056
  async function loadCodexModelCatalog(command, prefixArgs, env) {
41057
- const output = await new Promise((resolve18) => {
41057
+ const output = await new Promise((resolve19) => {
41058
41058
  const child = spawnCli(command, [...prefixArgs, "debug", "models"], {
41059
41059
  stdio: ["ignore", "pipe", "ignore"],
41060
41060
  windowsHide: true,
@@ -41069,7 +41069,7 @@ async function loadCodexModelCatalog(command, prefixArgs, env) {
41069
41069
  if (settled) return;
41070
41070
  settled = true;
41071
41071
  clearTimeout(timer);
41072
- resolve18(value);
41072
+ resolve19(value);
41073
41073
  };
41074
41074
  const timer = setTimeout(() => {
41075
41075
  child.kill();
@@ -41174,8 +41174,8 @@ function createRuntimeReporter(input, sessionId) {
41174
41174
  var EFFORT_READ_ATTEMPTS = 5;
41175
41175
  var EFFORT_READ_INTERVAL_MS = 3e3;
41176
41176
  function delay2(ms) {
41177
- return new Promise((resolve18) => {
41178
- const timer = setTimeout(resolve18, ms);
41177
+ return new Promise((resolve19) => {
41178
+ const timer = setTimeout(resolve19, ms);
41179
41179
  timer.unref?.();
41180
41180
  });
41181
41181
  }
@@ -41262,10 +41262,10 @@ function createClaudeLiveParser(onStream, onSessionModel) {
41262
41262
  },
41263
41263
  async steer(followUp) {
41264
41264
  if (!write) return false;
41265
- return await new Promise((resolve18) => {
41266
- acknowledgements.set(followUp.inputId, resolve18);
41265
+ return await new Promise((resolve19) => {
41266
+ acknowledgements.set(followUp.inputId, resolve19);
41267
41267
  void write(input(followUp.inputId, followUp.text)).catch(() => {
41268
- if (acknowledgements.delete(followUp.inputId)) resolve18(false);
41268
+ if (acknowledgements.delete(followUp.inputId)) resolve19(false);
41269
41269
  });
41270
41270
  });
41271
41271
  },
@@ -41581,8 +41581,8 @@ ${value}` : value;
41581
41581
  var RUNTIME_READ_ATTEMPTS = 5;
41582
41582
  var RUNTIME_READ_INTERVAL_MS = 2e3;
41583
41583
  function delay3(ms) {
41584
- return new Promise((resolve18) => {
41585
- const timer = setTimeout(resolve18, ms);
41584
+ return new Promise((resolve19) => {
41585
+ const timer = setTimeout(resolve19, ms);
41586
41586
  timer.unref?.();
41587
41587
  });
41588
41588
  }
@@ -41621,7 +41621,7 @@ function createCodexAppServerParser(onStream, options) {
41621
41621
  const turnReadyWaiters = /* @__PURE__ */ new Set();
41622
41622
  const usage = () => ({ inputTokens, outputTokens });
41623
41623
  const settleTurnReadiness = (ready) => {
41624
- for (const resolve18 of turnReadyWaiters) resolve18(ready);
41624
+ for (const resolve19 of turnReadyWaiters) resolve19(ready);
41625
41625
  turnReadyWaiters.clear();
41626
41626
  };
41627
41627
  const send = async (message) => {
@@ -41802,12 +41802,12 @@ function createCodexAppServerParser(onStream, options) {
41802
41802
  async steer(input) {
41803
41803
  if (stopped) return false;
41804
41804
  if (!activeTurnId) {
41805
- const ready = await new Promise((resolve18) => turnReadyWaiters.add(resolve18));
41805
+ const ready = await new Promise((resolve19) => turnReadyWaiters.add(resolve19));
41806
41806
  if (!ready || stopped) return false;
41807
41807
  }
41808
41808
  if (!threadId || !activeTurnId) return false;
41809
- return await new Promise((resolve18) => {
41810
- steerWaiters.set(input.inputId, resolve18);
41809
+ return await new Promise((resolve19) => {
41810
+ steerWaiters.set(input.inputId, resolve19);
41811
41811
  void send({
41812
41812
  id: `steer:${input.inputId}`,
41813
41813
  method: "turn/steer",
@@ -41818,7 +41818,7 @@ function createCodexAppServerParser(onStream, options) {
41818
41818
  clientUserMessageId: input.inputId
41819
41819
  }
41820
41820
  }).catch(() => {
41821
- if (steerWaiters.delete(input.inputId)) resolve18(false);
41821
+ if (steerWaiters.delete(input.inputId)) resolve19(false);
41822
41822
  });
41823
41823
  });
41824
41824
  },
@@ -41826,7 +41826,7 @@ function createCodexAppServerParser(onStream, options) {
41826
41826
  stopped = true;
41827
41827
  write = null;
41828
41828
  settleTurnReadiness(false);
41829
- for (const resolve18 of steerWaiters.values()) resolve18(false);
41829
+ for (const resolve19 of steerWaiters.values()) resolve19(false);
41830
41830
  steerWaiters.clear();
41831
41831
  },
41832
41832
  push(chunk) {
@@ -42246,7 +42246,7 @@ function parseAuth(result) {
42246
42246
  return "unknown";
42247
42247
  }
42248
42248
  function run2(command, args) {
42249
- return new Promise((resolve18) => {
42249
+ return new Promise((resolve19) => {
42250
42250
  const child = spawnCli(command, args, {
42251
42251
  stdio: ["ignore", "pipe", "pipe"],
42252
42252
  windowsHide: true
@@ -42262,7 +42262,7 @@ function run2(command, args) {
42262
42262
  if (settled) return;
42263
42263
  settled = true;
42264
42264
  clearTimeout(timeout);
42265
- resolve18(result);
42265
+ resolve19(result);
42266
42266
  };
42267
42267
  const timeout = setTimeout(() => {
42268
42268
  child.kill();
@@ -42276,9 +42276,46 @@ function run2(command, args) {
42276
42276
  // src/linux-service.ts
42277
42277
  import { spawn as spawn12 } from "node:child_process";
42278
42278
  import { constants as constants2 } from "node:fs";
42279
- import { access as access4, chmod as chmod7, mkdir as mkdir14, open as open7, rename as rename6, rm as rm10 } from "node:fs/promises";
42280
- import { homedir as homedir10, userInfo } from "node:os";
42281
- import { basename as basename4, dirname as dirname11, join as join21, relative as relative9, resolve as resolve12, sep as sep5 } from "node:path";
42279
+ import { access as access5, chmod as chmod8, mkdir as mkdir15, open as open7, rename as rename7, rm as rm11 } from "node:fs/promises";
42280
+ import { homedir as homedir11, userInfo } from "node:os";
42281
+ import { basename as basename4, dirname as dirname11, join as join22, relative as relative9, resolve as resolve13, sep as sep6 } from "node:path";
42282
+
42283
+ // src/service-runtime.ts
42284
+ import { access as access4, chmod as chmod7, copyFile, mkdir as mkdir14, rename as rename6, rm as rm10 } from "node:fs/promises";
42285
+ import { homedir as homedir10 } from "node:os";
42286
+ import { join as join21, resolve as resolve12, sep as sep5 } from "node:path";
42287
+ async function ensureDurableServiceNode(options = {}) {
42288
+ const execPath = resolve12(options.execPath ?? process.execPath);
42289
+ const home = options.home ?? homedir10();
42290
+ const platform = options.platform ?? process.platform;
42291
+ const version2 = options.nodeVersion ?? process.version;
42292
+ if (!/^v?[0-9A-Za-z.-]+$/.test(version2)) {
42293
+ throw new Error("the Node runtime version is not a safe directory name");
42294
+ }
42295
+ const zixtRoot = resolve12(home, ".zixt");
42296
+ if (execPath === zixtRoot || execPath.startsWith(zixtRoot + sep5)) return execPath;
42297
+ const directory = join21(zixtRoot, "runtime", `node-${version2}`);
42298
+ const destination = join21(directory, platform === "win32" ? "node.exe" : "node");
42299
+ const alreadyCopied = await access4(destination).then(
42300
+ () => true,
42301
+ () => false
42302
+ );
42303
+ if (alreadyCopied) return destination;
42304
+ await mkdir14(directory, { recursive: true, mode: 448 });
42305
+ const temporary = `${destination}.${process.pid}.${crypto.randomUUID()}.tmp`;
42306
+ try {
42307
+ await copyFile(execPath, temporary);
42308
+ await chmod7(temporary, 493);
42309
+ await rename6(temporary, destination);
42310
+ } catch (error52) {
42311
+ await rm10(temporary, { force: true }).catch(() => void 0);
42312
+ throw error52;
42313
+ }
42314
+ await options.syncDirectory?.(directory);
42315
+ return destination;
42316
+ }
42317
+
42318
+ // src/linux-service.ts
42282
42319
  var SERVICE_NAME = "zixt-host.service";
42283
42320
  var SYSTEM_SERVICE_COMMAND_TIMEOUT_MS = 7e4;
42284
42321
  var SERVICE_STABILITY_DELAY_MS = 2e3;
@@ -42306,7 +42343,7 @@ function boundedAppend(current, chunk) {
42306
42343
  }
42307
42344
  async function defaultRunCommand(command, args) {
42308
42345
  const commandEnvironment3 = systemServiceCommandEnvironment();
42309
- return new Promise((resolve18) => {
42346
+ return new Promise((resolve19) => {
42310
42347
  const child = spawn12(command, [...args], {
42311
42348
  stdio: ["ignore", "pipe", "pipe"],
42312
42349
  env: commandEnvironment3,
@@ -42320,7 +42357,7 @@ async function defaultRunCommand(command, args) {
42320
42357
  if (settled) return;
42321
42358
  settled = true;
42322
42359
  if (timer) clearTimeout(timer);
42323
- resolve18(result);
42360
+ resolve19(result);
42324
42361
  };
42325
42362
  child.stdout?.on("data", (chunk) => {
42326
42363
  stdout = boundedAppend(stdout, chunk);
@@ -42340,7 +42377,7 @@ async function defaultRunCommand(command, args) {
42340
42377
  }
42341
42378
  async function defaultResolveCommand(name) {
42342
42379
  for (const candidate of [`/usr/bin/${name}`, `/bin/${name}`]) {
42343
- if (await access4(candidate, constants2.X_OK).then(
42380
+ if (await access5(candidate, constants2.X_OK).then(
42344
42381
  () => true,
42345
42382
  () => false
42346
42383
  )) {
@@ -42379,33 +42416,33 @@ async function defaultSyncDirectory(path) {
42379
42416
  }
42380
42417
  }
42381
42418
  async function ensureDirectory(path, mode, syncDirectory8) {
42382
- const firstCreated = await mkdir14(path, { recursive: true, mode });
42419
+ const firstCreated = await mkdir15(path, { recursive: true, mode });
42383
42420
  if (!firstCreated) return;
42384
- const first = resolve12(firstCreated);
42385
- const target = resolve12(path);
42421
+ const first = resolve13(firstCreated);
42422
+ const target = resolve13(path);
42386
42423
  await syncDirectory8(dirname11(first));
42387
42424
  let current = first;
42388
42425
  const descendants = relative9(first, target);
42389
- for (const part of descendants ? descendants.split(sep5) : []) {
42426
+ for (const part of descendants ? descendants.split(sep6) : []) {
42390
42427
  await syncDirectory8(current);
42391
- current = join21(current, part);
42428
+ current = join22(current, part);
42392
42429
  }
42393
42430
  }
42394
42431
  async function replacePrivateFile(path, contents, mode, syncDirectory8) {
42395
42432
  const parent = dirname11(path);
42396
42433
  await ensureDirectory(parent, 448, syncDirectory8);
42397
- const temporary = join21(parent, `.${basename4(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42434
+ const temporary = join22(parent, `.${basename4(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42398
42435
  const handle = await open7(temporary, "wx", mode);
42399
42436
  try {
42400
42437
  await handle.writeFile(contents, "utf8");
42401
42438
  await handle.sync();
42402
42439
  await handle.close();
42403
- await rename6(temporary, path);
42404
- await chmod7(path, mode);
42440
+ await rename7(temporary, path);
42441
+ await chmod8(path, mode);
42405
42442
  await syncDirectory8(parent);
42406
42443
  } catch (error52) {
42407
42444
  await handle.close().catch(() => void 0);
42408
- await rm10(temporary, { force: true }).catch(() => void 0);
42445
+ await rm11(temporary, { force: true }).catch(() => void 0);
42409
42446
  throw error52;
42410
42447
  }
42411
42448
  }
@@ -42438,7 +42475,7 @@ async function installLinuxService(options) {
42438
42475
  throw new Error("Linux automatic startup is available only on Linux.");
42439
42476
  }
42440
42477
  const env = options.env ?? process.env;
42441
- const home = options.home ?? homedir10();
42478
+ const home = options.home ?? homedir11();
42442
42479
  const username = oneLine(options.username ?? userInfo().username, "user name");
42443
42480
  const token2 = oneLine(options.token, "pairing code");
42444
42481
  const path = oneLine(
@@ -42446,17 +42483,17 @@ async function installLinuxService(options) {
42446
42483
  "command search path"
42447
42484
  );
42448
42485
  const cloudUrl = options.cloudUrl ? oneLine(options.cloudUrl, "Zixt Cloud address") : void 0;
42449
- const xdgConfigHome = env.XDG_CONFIG_HOME ? oneLine(env.XDG_CONFIG_HOME, "Linux configuration path") : join21(home, ".config");
42450
- const configRoot = options.serviceConfigRoot ?? join21(xdgConfigHome, "zixt");
42451
- const unitRoot = options.userUnitRoot ?? join21(xdgConfigHome, "systemd", "user");
42452
- const environmentPath = join21(configRoot, "host.env");
42453
- const unitPath = join21(unitRoot, SERVICE_NAME);
42486
+ const xdgConfigHome = env.XDG_CONFIG_HOME ? oneLine(env.XDG_CONFIG_HOME, "Linux configuration path") : join22(home, ".config");
42487
+ const configRoot = options.serviceConfigRoot ?? join22(xdgConfigHome, "zixt");
42488
+ const unitRoot = options.userUnitRoot ?? join22(xdgConfigHome, "systemd", "user");
42489
+ const environmentPath = join22(configRoot, "host.env");
42490
+ const unitPath = join22(unitRoot, SERVICE_NAME);
42454
42491
  const installVersion = options.installVersion ?? ((version2, onFailure) => installRelease(version2, onFailure ? { onFailure } : {}));
42455
42492
  const activateVersion = options.activateVersion ?? (options.installVersion ? async (entry) => entry : activateInstalledRelease);
42456
42493
  const resolveCommand = options.resolveCommand ?? defaultResolveCommand;
42457
42494
  const run3 = options.runCommand ?? defaultRunCommand;
42458
42495
  const syncDirectory8 = options.syncDirectory ?? defaultSyncDirectory;
42459
- const stabilityDelay = options.delay ?? ((ms) => new Promise((resolve18) => setTimeout(resolve18, ms)));
42496
+ const stabilityDelay = options.delay ?? ((ms) => new Promise((resolve19) => setTimeout(resolve19, ms)));
42460
42497
  const [systemctl, loginctl] = await Promise.all([
42461
42498
  resolveCommand("systemctl"),
42462
42499
  resolveCommand("loginctl")
@@ -42490,7 +42527,7 @@ async function installLinuxService(options) {
42490
42527
  }
42491
42528
  }
42492
42529
  await ensureDirectory(configRoot, 448, syncDirectory8);
42493
- await chmod7(configRoot, 448);
42530
+ await chmod8(configRoot, 448);
42494
42531
  const serviceEnvironment = [
42495
42532
  `ZIXT_HOST_TOKEN=${systemdEnvironmentValue(token2)}`,
42496
42533
  ...cloudUrl ? [`ZIXT_CLOUD_URL=${systemdEnvironmentValue(cloudUrl)}`] : [],
@@ -42505,6 +42542,7 @@ async function installLinuxService(options) {
42505
42542
  ""
42506
42543
  ].join("\n");
42507
42544
  await replacePrivateFile(environmentPath, serviceEnvironment, 384, syncDirectory8);
42545
+ const serviceNode = options.serviceNode ?? await ensureDurableServiceNode({ home, syncDirectory: syncDirectory8 });
42508
42546
  const unit = [
42509
42547
  "[Unit]",
42510
42548
  "Description=Zixt Host",
@@ -42514,7 +42552,7 @@ async function installLinuxService(options) {
42514
42552
  // Node, so a missing/corrupt release cannot masquerade as an active Host.
42515
42553
  "Type=exec",
42516
42554
  `EnvironmentFile=${systemdDirectivePath(environmentPath)}`,
42517
- `ExecStart=${systemdUnitValue(process.execPath)} ${systemdUnitValue(currentEntry)}`,
42555
+ `ExecStart=${systemdUnitValue(serviceNode)} ${systemdUnitValue(currentEntry)}`,
42518
42556
  "Restart=on-failure",
42519
42557
  "RestartPreventExitStatus=64",
42520
42558
  "RestartSec=5s",
@@ -42579,9 +42617,9 @@ async function installLinuxService(options) {
42579
42617
  // src/macos-service.ts
42580
42618
  import { spawn as spawn13 } from "node:child_process";
42581
42619
  import { constants as constants3 } from "node:fs";
42582
- import { access as access5, chmod as chmod8, mkdir as mkdir15, open as open8, rename as rename7, rm as rm11 } from "node:fs/promises";
42583
- import { homedir as homedir11, userInfo as userInfo2 } from "node:os";
42584
- import { basename as basename5, dirname as dirname12, join as join22, relative as relative10, resolve as resolve13, sep as sep6 } from "node:path";
42620
+ import { access as access6, chmod as chmod9, mkdir as mkdir16, open as open8, rename as rename8, rm as rm12 } from "node:fs/promises";
42621
+ import { homedir as homedir12, userInfo as userInfo2 } from "node:os";
42622
+ import { basename as basename5, dirname as dirname12, join as join23, relative as relative10, resolve as resolve14, sep as sep7 } from "node:path";
42585
42623
  var LAUNCH_AGENT_LABEL = "ai.zixt.host";
42586
42624
  var SERVICE_STABILITY_DELAY_MS2 = 2e3;
42587
42625
  var COMMAND_TIMEOUT_MS2 = 7e4;
@@ -42605,32 +42643,32 @@ async function syncDirectory4(path) {
42605
42643
  }
42606
42644
  }
42607
42645
  async function ensureDirectory2(path, sync) {
42608
- const firstCreated = await mkdir15(path, { recursive: true, mode: 448 });
42646
+ const firstCreated = await mkdir16(path, { recursive: true, mode: 448 });
42609
42647
  if (!firstCreated) return;
42610
- const first = resolve13(firstCreated);
42611
- const target = resolve13(path);
42648
+ const first = resolve14(firstCreated);
42649
+ const target = resolve14(path);
42612
42650
  await sync(dirname12(first));
42613
42651
  let current = first;
42614
- for (const part of relative10(first, target).split(sep6).filter(Boolean)) {
42652
+ for (const part of relative10(first, target).split(sep7).filter(Boolean)) {
42615
42653
  await sync(current);
42616
- current = join22(current, part);
42654
+ current = join23(current, part);
42617
42655
  }
42618
42656
  }
42619
42657
  async function replacePrivateFile2(path, contents, mode, sync) {
42620
42658
  const parent = dirname12(path);
42621
42659
  await ensureDirectory2(parent, sync);
42622
- const temporary = join22(parent, `.${basename5(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42660
+ const temporary = join23(parent, `.${basename5(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42623
42661
  const handle = await open8(temporary, "wx", mode);
42624
42662
  try {
42625
42663
  await handle.writeFile(contents, "utf8");
42626
42664
  await handle.sync();
42627
42665
  await handle.close();
42628
- await rename7(temporary, path);
42629
- await chmod8(path, mode);
42666
+ await rename8(temporary, path);
42667
+ await chmod9(path, mode);
42630
42668
  await sync(parent);
42631
42669
  } catch (error52) {
42632
42670
  await handle.close().catch(() => void 0);
42633
- await rm11(temporary, { force: true }).catch(() => void 0);
42671
+ await rm12(temporary, { force: true }).catch(() => void 0);
42634
42672
  throw error52;
42635
42673
  }
42636
42674
  }
@@ -42673,7 +42711,7 @@ async function defaultRunCommand2(command, args, env) {
42673
42711
  }
42674
42712
  async function defaultResolveCommand2() {
42675
42713
  for (const candidate of ["/bin/launchctl", "/usr/bin/launchctl"]) {
42676
- if (await access5(candidate, constants3.X_OK).then(
42714
+ if (await access6(candidate, constants3.X_OK).then(
42677
42715
  () => true,
42678
42716
  () => false
42679
42717
  ))
@@ -42685,13 +42723,13 @@ function commandFailure2(label, result) {
42685
42723
  const detail = (result.stderr || result.stdout).trim().slice(-240);
42686
42724
  return new Error(`${label} failed${detail ? `: ${detail}` : ""}`);
42687
42725
  }
42688
- function launcherSource(configPath, home, entry) {
42726
+ function launcherSource(configPath, home, node, entry) {
42689
42727
  return `#!/bin/sh
42690
42728
  set -a
42691
42729
  . ${shellValue(configPath)}
42692
42730
  set +a
42693
42731
  cd ${shellValue(home)} || exit 64
42694
- exec ${shellValue(process.execPath)} ${shellValue(entry)}
42732
+ exec ${shellValue(node)} ${shellValue(entry)}
42695
42733
  `;
42696
42734
  }
42697
42735
  function parseLaunchdStatus(output) {
@@ -42707,7 +42745,7 @@ async function installMacosService(options) {
42707
42745
  throw new Error("macOS automatic startup is available only on macOS.");
42708
42746
  }
42709
42747
  const env = options.env ?? process.env;
42710
- const home = options.home ?? homedir11();
42748
+ const home = options.home ?? homedir12();
42711
42749
  const uid = options.uid ?? userInfo2().uid;
42712
42750
  if (!Number.isSafeInteger(uid) || uid < 0) throw new Error("macOS user id is invalid.");
42713
42751
  const token2 = oneLine2(options.token, "pairing code");
@@ -42716,14 +42754,14 @@ async function installMacosService(options) {
42716
42754
  options.path ?? env.PATH ?? "/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin",
42717
42755
  "command search path"
42718
42756
  );
42719
- const configRoot = options.configRoot ?? join22(home, "Library", "Application Support", "Zixt");
42720
- const launchAgentsRoot = options.launchAgentsRoot ?? join22(home, "Library", "LaunchAgents");
42721
- const logRoot = options.logRoot ?? join22(home, "Library", "Logs", "Zixt");
42722
- const configPath = join22(configRoot, "host.env");
42723
- const launcherPath = join22(configRoot, "host-launcher.sh");
42724
- const plistPath = join22(launchAgentsRoot, `${LAUNCH_AGENT_LABEL}.plist`);
42725
- const stdoutPath = join22(logRoot, "host.log");
42726
- const stderrPath = join22(logRoot, "host-error.log");
42757
+ const configRoot = options.configRoot ?? join23(home, "Library", "Application Support", "Zixt");
42758
+ const launchAgentsRoot = options.launchAgentsRoot ?? join23(home, "Library", "LaunchAgents");
42759
+ const logRoot = options.logRoot ?? join23(home, "Library", "Logs", "Zixt");
42760
+ const configPath = join23(configRoot, "host.env");
42761
+ const launcherPath = join23(configRoot, "host-launcher.sh");
42762
+ const plistPath = join23(launchAgentsRoot, `${LAUNCH_AGENT_LABEL}.plist`);
42763
+ const stdoutPath = join23(logRoot, "host.log");
42764
+ const stderrPath = join23(logRoot, "host-error.log");
42727
42765
  const installVersion = options.installVersion ?? ((version2, onFailure) => installRelease(version2, onFailure ? { onFailure } : {}));
42728
42766
  const activateVersion = options.activateVersion ?? (options.installVersion ? async (entry) => entry : (entry) => activateInstalledRelease(entry));
42729
42767
  const resolveCommand = options.resolveCommand ?? (async () => defaultResolveCommand2());
@@ -42746,7 +42784,7 @@ async function installMacosService(options) {
42746
42784
  await ensureDirectory2(configRoot, sync);
42747
42785
  await ensureDirectory2(launchAgentsRoot, sync);
42748
42786
  await ensureDirectory2(logRoot, sync);
42749
- await chmod8(configRoot, 448);
42787
+ await chmod9(configRoot, 448);
42750
42788
  const serviceEnvironment = [
42751
42789
  `ZIXT_HOST_TOKEN=${shellValue(token2)}`,
42752
42790
  ...cloudUrl ? [`ZIXT_CLOUD_URL=${shellValue(cloudUrl)}`] : [],
@@ -42762,9 +42800,10 @@ async function installMacosService(options) {
42762
42800
  ""
42763
42801
  ].join("\n");
42764
42802
  await replacePrivateFile2(configPath, serviceEnvironment, 384, sync);
42803
+ const serviceNode = options.serviceNode ?? await ensureDurableServiceNode({ home, syncDirectory: sync });
42765
42804
  await replacePrivateFile2(
42766
42805
  launcherPath,
42767
- launcherSource(configPath, home, currentEntry),
42806
+ launcherSource(configPath, home, serviceNode, currentEntry),
42768
42807
  448,
42769
42808
  sync
42770
42809
  );
@@ -42820,9 +42859,9 @@ async function installMacosService(options) {
42820
42859
  // src/windows-service.ts
42821
42860
  import { spawn as spawn14 } from "node:child_process";
42822
42861
  import { constants as constants4 } from "node:fs";
42823
- import { access as access6, mkdir as mkdir16, open as open9, readFile as readFile11, rename as rename8, rm as rm12 } from "node:fs/promises";
42824
- import { homedir as homedir12 } from "node:os";
42825
- import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute18, join as join23, relative as relative11, resolve as resolve14, sep as sep7 } from "node:path";
42862
+ import { access as access7, mkdir as mkdir17, open as open9, readFile as readFile11, rename as rename9, rm as rm13 } from "node:fs/promises";
42863
+ import { homedir as homedir13 } from "node:os";
42864
+ import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute18, join as join24, relative as relative11, resolve as resolve15, sep as sep8 } from "node:path";
42826
42865
  var TASK_NAME = "Zixt Host";
42827
42866
  var COMMAND_TIMEOUT_MS3 = 7e4;
42828
42867
  var SERVICE_STABILITY_DELAY_MS3 = 2e3;
@@ -42848,31 +42887,31 @@ async function syncDirectory5(path) {
42848
42887
  }
42849
42888
  }
42850
42889
  async function ensureDirectory3(path, sync) {
42851
- const firstCreated = await mkdir16(path, { recursive: true, mode: 448 });
42890
+ const firstCreated = await mkdir17(path, { recursive: true, mode: 448 });
42852
42891
  if (!firstCreated) return;
42853
- const first = resolve14(firstCreated);
42854
- const target = resolve14(path);
42892
+ const first = resolve15(firstCreated);
42893
+ const target = resolve15(path);
42855
42894
  await sync(dirname13(first));
42856
42895
  let current = first;
42857
- for (const part of relative11(first, target).split(sep7).filter(Boolean)) {
42896
+ for (const part of relative11(first, target).split(sep8).filter(Boolean)) {
42858
42897
  await sync(current);
42859
- current = join23(current, part);
42898
+ current = join24(current, part);
42860
42899
  }
42861
42900
  }
42862
42901
  async function replacePrivateFile3(path, contents, sync, encoding = "utf8") {
42863
42902
  const parent = dirname13(path);
42864
42903
  await ensureDirectory3(parent, sync);
42865
- const temporary = join23(parent, `.${basename6(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42904
+ const temporary = join24(parent, `.${basename6(path)}.${process.pid}.${crypto.randomUUID()}.tmp`);
42866
42905
  const handle = await open9(temporary, "wx", 384);
42867
42906
  try {
42868
42907
  await handle.writeFile(encoding === "utf16le" ? `\uFEFF${contents}` : contents, encoding);
42869
42908
  await handle.sync();
42870
42909
  await handle.close();
42871
- await rename8(temporary, path);
42910
+ await rename9(temporary, path);
42872
42911
  await sync(parent);
42873
42912
  } catch (error52) {
42874
42913
  await handle.close().catch(() => void 0);
42875
- await rm12(temporary, { force: true }).catch(() => void 0);
42914
+ await rm13(temporary, { force: true }).catch(() => void 0);
42876
42915
  throw error52;
42877
42916
  }
42878
42917
  }
@@ -42917,8 +42956,8 @@ async function runChild(command, args, env, input) {
42917
42956
  async function defaultResolveCommand3(name, env) {
42918
42957
  const root = env.SYSTEMROOT ?? env.WINDIR;
42919
42958
  if (!root || !isAbsolute18(root)) return null;
42920
- const candidate = name === "powershell" ? join23(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") : join23(root, "System32", `${name}.exe`);
42921
- return access6(candidate, constants4.X_OK).then(
42959
+ const candidate = name === "powershell" ? join24(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") : join24(root, "System32", `${name}.exe`);
42960
+ return access7(candidate, constants4.X_OK).then(
42922
42961
  () => candidate,
42923
42962
  () => null
42924
42963
  );
@@ -43060,7 +43099,7 @@ async function installWindowsService(options) {
43060
43099
  throw new Error("Windows automatic startup is available only on Windows.");
43061
43100
  }
43062
43101
  const env = options.env ?? process.env;
43063
- const home = options.home ?? homedir12();
43102
+ const home = options.home ?? homedir13();
43064
43103
  const localAppData = options.localAppData ?? env.LOCALAPPDATA;
43065
43104
  if (!localAppData || !isAbsolute18(localAppData)) {
43066
43105
  throw new Error("Windows local application data path is unavailable.");
@@ -43068,12 +43107,12 @@ async function installWindowsService(options) {
43068
43107
  const token2 = oneLine3(options.token, "pairing code");
43069
43108
  const cloudUrl = options.cloudUrl ? oneLine3(options.cloudUrl, "Zixt Cloud address") : void 0;
43070
43109
  const path = oneLine3(options.path ?? env.PATH ?? "", "command search path");
43071
- const configRoot = options.configRoot ?? join23(localAppData, "Zixt", "Host");
43072
- const configPath = join23(configRoot, "host.json");
43073
- const launcherPath = join23(configRoot, "host-launcher.ps1");
43074
- const launchShimPath = join23(configRoot, "host-launch.vbs");
43075
- const taskXmlPath = join23(configRoot, "host-task.xml");
43076
- const statusPath = join23(configRoot, "host-status.json");
43110
+ const configRoot = options.configRoot ?? join24(localAppData, "Zixt", "Host");
43111
+ const configPath = join24(configRoot, "host.json");
43112
+ const launcherPath = join24(configRoot, "host-launcher.ps1");
43113
+ const launchShimPath = join24(configRoot, "host-launch.vbs");
43114
+ const taskXmlPath = join24(configRoot, "host-task.xml");
43115
+ const statusPath = join24(configRoot, "host-status.json");
43077
43116
  const installVersion = options.installVersion ?? ((version2, onFailure) => installRelease(version2, onFailure ? { onFailure } : {}));
43078
43117
  const activateVersion = options.activateVersion ?? (options.installVersion ? async (entry) => entry : (entry) => activateInstalledRelease(entry));
43079
43118
  const resolveCommand = options.resolveCommand ?? ((name) => defaultResolveCommand3(name, env));
@@ -43108,13 +43147,14 @@ async function installWindowsService(options) {
43108
43147
  throw new Error("Windows did not return a protected Machine pairing credential.");
43109
43148
  }
43110
43149
  const generation = crypto.randomUUID();
43150
+ const serviceNode = options.serviceNode ?? await ensureDurableServiceNode({ home, syncDirectory: sync });
43111
43151
  await ensureDirectory3(configRoot, sync);
43112
43152
  await replacePrivateFile3(
43113
43153
  configPath,
43114
43154
  `${JSON.stringify({
43115
43155
  schema: 1,
43116
43156
  generation,
43117
- node: process.execPath,
43157
+ node: serviceNode,
43118
43158
  entry: currentEntry,
43119
43159
  cwd: home,
43120
43160
  protectedToken,
@@ -43139,7 +43179,7 @@ async function installWindowsService(options) {
43139
43179
  sync,
43140
43180
  "utf16le"
43141
43181
  );
43142
- await rm12(statusPath, { force: true });
43182
+ await rm13(statusPath, { force: true });
43143
43183
  const acl = await run3(icacls, [
43144
43184
  configRoot,
43145
43185
  "/inheritance:r",
@@ -43199,23 +43239,23 @@ async function installSystemService(options) {
43199
43239
  }
43200
43240
 
43201
43241
  // src/terminal-outcomes.ts
43202
- import { chmod as chmod9, lstat as lstat12, mkdir as mkdir17, open as open10, readdir as readdir6, readFile as readFile12, rename as rename9, rm as rm13 } from "node:fs/promises";
43203
- import { homedir as homedir13 } from "node:os";
43204
- import { dirname as dirname14, join as join24, relative as relative12, resolve as resolve15, sep as sep8 } from "node:path";
43242
+ import { chmod as chmod10, lstat as lstat12, mkdir as mkdir18, open as open10, readdir as readdir6, readFile as readFile12, rename as rename10, rm as rm14 } from "node:fs/promises";
43243
+ import { homedir as homedir14 } from "node:os";
43244
+ import { dirname as dirname14, join as join25, relative as relative12, resolve as resolve16, sep as sep9 } from "node:path";
43205
43245
  var DIRECTORY_MODE5 = 448;
43206
43246
  var FILE_MODE4 = 384;
43207
43247
  var MAX_OUTCOME_BYTES = 4 * 1024 * 1024;
43208
43248
  var HOST_DIRECTORY = /^hst_[0-9a-f]{32}$/;
43209
43249
  var OUTCOME_FILE = /^(tsk_[0-9a-f]{32})\.([1-9][0-9]*)\.json$/;
43210
43250
  function defaultTerminalOutcomeRoot() {
43211
- return join24(homedir13(), ".zixt", "terminal-outcomes");
43251
+ return join25(homedir14(), ".zixt", "terminal-outcomes");
43212
43252
  }
43213
43253
  function hostOutcomeRoot(root, hostId) {
43214
43254
  if (!HOST_DIRECTORY.test(hostId)) throw new Error("terminal outcome Host identity is malformed");
43215
- return join24(root, hostId);
43255
+ return join25(root, hostId);
43216
43256
  }
43217
43257
  function outcomePath(root, hostId, taskId, epoch) {
43218
- return join24(hostOutcomeRoot(root, hostId), `${taskId}.${epoch}.json`);
43258
+ return join25(hostOutcomeRoot(root, hostId), `${taskId}.${epoch}.json`);
43219
43259
  }
43220
43260
  async function syncDirectory6(root) {
43221
43261
  if (process.platform === "win32") return;
@@ -43227,22 +43267,22 @@ async function syncDirectory6(root) {
43227
43267
  }
43228
43268
  }
43229
43269
  async function requirePrivateRoot(root, sync = syncDirectory6) {
43230
- const firstCreated = await mkdir17(root, { recursive: true, mode: DIRECTORY_MODE5 });
43270
+ const firstCreated = await mkdir18(root, { recursive: true, mode: DIRECTORY_MODE5 });
43231
43271
  if (firstCreated) {
43232
- const first = resolve15(firstCreated);
43233
- const target = resolve15(root);
43272
+ const first = resolve16(firstCreated);
43273
+ const target = resolve16(root);
43234
43274
  await sync(dirname14(first));
43235
43275
  let current = first;
43236
- for (const part of relative12(first, target).split(sep8).filter(Boolean)) {
43276
+ for (const part of relative12(first, target).split(sep9).filter(Boolean)) {
43237
43277
  await sync(current);
43238
- current = join24(current, part);
43278
+ current = join25(current, part);
43239
43279
  }
43240
43280
  }
43241
43281
  const stat4 = await lstat12(root);
43242
43282
  if (stat4.isSymbolicLink() || !stat4.isDirectory()) {
43243
43283
  throw new Error("terminal outcome journal root is not a trusted directory");
43244
43284
  }
43245
- await chmod9(root, DIRECTORY_MODE5);
43285
+ await chmod10(root, DIRECTORY_MODE5);
43246
43286
  }
43247
43287
  function parseCommittedOutcome(text, taskId, epoch) {
43248
43288
  let json2;
@@ -43275,7 +43315,7 @@ async function recordTerminalOutcome(hostId, input, root = defaultTerminalOutcom
43275
43315
  } catch (error52) {
43276
43316
  if (error52.code !== "ENOENT") throw error52;
43277
43317
  }
43278
- const temporary = join24(
43318
+ const temporary = join25(
43279
43319
  scopedRoot,
43280
43320
  `.${outcome.taskId}.${outcome.epoch}.${process.pid}.${Date.now()}.${outcome.resultId}.tmp`
43281
43321
  );
@@ -43286,13 +43326,13 @@ async function recordTerminalOutcome(hostId, input, root = defaultTerminalOutcom
43286
43326
  await handle.sync();
43287
43327
  await handle.close();
43288
43328
  handle = void 0;
43289
- await rename9(temporary, destination);
43329
+ await rename10(temporary, destination);
43290
43330
  await sync(scopedRoot);
43291
43331
  await sync(root);
43292
43332
  } finally {
43293
43333
  await handle?.close().catch(() => {
43294
43334
  });
43295
- await rm13(temporary, { force: true }).catch(() => {
43335
+ await rm14(temporary, { force: true }).catch(() => {
43296
43336
  });
43297
43337
  }
43298
43338
  }
@@ -43307,7 +43347,7 @@ async function readTerminalOutcomesStrict(root = defaultTerminalOutcomeRoot()) {
43307
43347
  if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
43308
43348
  throw new Error("terminal outcome journal root is not a trusted directory");
43309
43349
  }
43310
- await chmod9(root, DIRECTORY_MODE5);
43350
+ await chmod10(root, DIRECTORY_MODE5);
43311
43351
  const hostEntries = await readdir6(root, { withFileTypes: true });
43312
43352
  const outcomes = [];
43313
43353
  const resultIds = /* @__PURE__ */ new Set();
@@ -43320,7 +43360,7 @@ async function readTerminalOutcomesStrict(root = defaultTerminalOutcomeRoot()) {
43320
43360
  if (scopedStat.isSymbolicLink() || !scopedStat.isDirectory()) {
43321
43361
  throw new Error("terminal outcome Host scope is not a trusted directory");
43322
43362
  }
43323
- await chmod9(scopedRoot, DIRECTORY_MODE5);
43363
+ await chmod10(scopedRoot, DIRECTORY_MODE5);
43324
43364
  const entries = await readdir6(scopedRoot, { withFileTypes: true });
43325
43365
  for (const entry of entries) {
43326
43366
  if (!entry.name.endsWith(".json")) continue;
@@ -43328,7 +43368,7 @@ async function readTerminalOutcomesStrict(root = defaultTerminalOutcomeRoot()) {
43328
43368
  if (!match || !entry.isFile() || entry.isSymbolicLink()) {
43329
43369
  throw new Error("committed terminal outcome is not a trusted regular file");
43330
43370
  }
43331
- const path = join24(scopedRoot, entry.name);
43371
+ const path = join25(scopedRoot, entry.name);
43332
43372
  const stat4 = await lstat12(path);
43333
43373
  if (!stat4.isFile() || stat4.isSymbolicLink() || stat4.size > MAX_OUTCOME_BYTES) {
43334
43374
  throw new Error("committed terminal outcome is not a trusted regular file");
@@ -43361,7 +43401,7 @@ async function forgetAcknowledgedTerminalOutcomes(refs, root = defaultTerminalOu
43361
43401
  if (acknowledged.get(`${hostId}:${outcome.taskId}:${outcome.epoch}`) !== outcome.resultId) {
43362
43402
  continue;
43363
43403
  }
43364
- await rm13(outcomePath(root, hostId, outcome.taskId, outcome.epoch), { force: true });
43404
+ await rm14(outcomePath(root, hostId, outcome.taskId, outcome.epoch), { force: true });
43365
43405
  changedHostRoots.add(hostOutcomeRoot(root, hostId));
43366
43406
  }
43367
43407
  for (const scopedRoot of changedHostRoots) await syncDirectory6(scopedRoot);
@@ -43373,22 +43413,22 @@ async function forgetSupersededTerminalOutcomes(hostId, taskId, epoch, root = de
43373
43413
  if (scoped.hostId !== hostId) continue;
43374
43414
  const { outcome } = scoped;
43375
43415
  if (outcome.taskId !== taskId || outcome.epoch >= epoch) continue;
43376
- await rm13(outcomePath(root, hostId, outcome.taskId, outcome.epoch), { force: true });
43416
+ await rm14(outcomePath(root, hostId, outcome.taskId, outcome.epoch), { force: true });
43377
43417
  removed = true;
43378
43418
  }
43379
43419
  if (removed) await syncDirectory6(hostOutcomeRoot(root, hostId));
43380
43420
  }
43381
43421
 
43382
43422
  // src/accepted-assignments.ts
43383
- import { chmod as chmod10, lstat as lstat13, mkdir as mkdir18, open as open11, readdir as readdir7, rename as rename10, rm as rm14 } from "node:fs/promises";
43384
- import { homedir as homedir14 } from "node:os";
43385
- import { dirname as dirname15, join as join25, relative as relative13, resolve as resolve16, sep as sep9 } from "node:path";
43423
+ import { chmod as chmod11, lstat as lstat13, mkdir as mkdir19, open as open11, readdir as readdir7, rename as rename11, rm as rm15 } from "node:fs/promises";
43424
+ import { homedir as homedir15 } from "node:os";
43425
+ import { dirname as dirname15, join as join26, relative as relative13, resolve as resolve17, sep as sep10 } from "node:path";
43386
43426
  var DIRECTORY_MODE6 = 448;
43387
43427
  var FILE_MODE5 = 384;
43388
43428
  var CLAIM_FILE = /^(tsk_[0-9a-f]{32})\.([1-9][0-9]*)\.json$/;
43389
43429
  var TASK_ID = /^tsk_[0-9a-f]{32}$/;
43390
43430
  function defaultAcceptedAssignmentRoot() {
43391
- return join25(homedir14(), ".zixt", "accepted-assignments");
43431
+ return join26(homedir15(), ".zixt", "accepted-assignments");
43392
43432
  }
43393
43433
  async function syncDirectory7(root) {
43394
43434
  if (process.platform === "win32") return;
@@ -43400,29 +43440,29 @@ async function syncDirectory7(root) {
43400
43440
  }
43401
43441
  }
43402
43442
  async function requirePrivateRoot2(root, sync = syncDirectory7) {
43403
- const firstCreated = await mkdir18(root, { recursive: true, mode: DIRECTORY_MODE6 });
43443
+ const firstCreated = await mkdir19(root, { recursive: true, mode: DIRECTORY_MODE6 });
43404
43444
  if (firstCreated) {
43405
- const first = resolve16(firstCreated);
43406
- const target = resolve16(root);
43445
+ const first = resolve17(firstCreated);
43446
+ const target = resolve17(root);
43407
43447
  await sync(dirname15(first));
43408
43448
  let current = first;
43409
- for (const part of relative13(first, target).split(sep9).filter(Boolean)) {
43449
+ for (const part of relative13(first, target).split(sep10).filter(Boolean)) {
43410
43450
  await sync(current);
43411
- current = join25(current, part);
43451
+ current = join26(current, part);
43412
43452
  }
43413
43453
  }
43414
43454
  const stat4 = await lstat13(root);
43415
43455
  if (stat4.isSymbolicLink() || !stat4.isDirectory()) {
43416
43456
  throw new Error("accepted assignment journal root is not a trusted directory");
43417
43457
  }
43418
- await chmod10(root, DIRECTORY_MODE6);
43458
+ await chmod11(root, DIRECTORY_MODE6);
43419
43459
  }
43420
43460
  function claimPath(root, taskId, epoch) {
43421
43461
  if (!TASK_ID.test(taskId)) throw new Error("accepted assignment Task identity is malformed");
43422
43462
  if (!Number.isSafeInteger(epoch) || epoch < 1) {
43423
43463
  throw new Error("accepted assignment epoch is malformed");
43424
43464
  }
43425
- return join25(root, `${taskId}.${epoch}.json`);
43465
+ return join26(root, `${taskId}.${epoch}.json`);
43426
43466
  }
43427
43467
  async function recordAcceptedAssignment(assignment, root = defaultAcceptedAssignmentRoot(), options = {}) {
43428
43468
  const sync = options.syncDirectory ?? syncDirectory7;
@@ -43432,7 +43472,7 @@ async function recordAcceptedAssignment(assignment, root = defaultAcceptedAssign
43432
43472
  } catch {
43433
43473
  return false;
43434
43474
  }
43435
- const temporary = join25(
43475
+ const temporary = join26(
43436
43476
  root,
43437
43477
  `.${assignment.taskId}.${assignment.epoch}.${process.pid}.${Date.now()}.tmp`
43438
43478
  );
@@ -43444,7 +43484,7 @@ async function recordAcceptedAssignment(assignment, root = defaultAcceptedAssign
43444
43484
  await handle.sync();
43445
43485
  await handle.close();
43446
43486
  handle = void 0;
43447
- await rename10(temporary, destination);
43487
+ await rename11(temporary, destination);
43448
43488
  if (process.platform !== "win32") await sync(root);
43449
43489
  return true;
43450
43490
  } catch {
@@ -43452,7 +43492,7 @@ async function recordAcceptedAssignment(assignment, root = defaultAcceptedAssign
43452
43492
  } finally {
43453
43493
  await handle?.close().catch(() => {
43454
43494
  });
43455
- await rm14(temporary, { force: true }).catch(() => {
43495
+ await rm15(temporary, { force: true }).catch(() => {
43456
43496
  });
43457
43497
  }
43458
43498
  }
@@ -43467,7 +43507,7 @@ async function recoverAcceptedAssignments(root = defaultAcceptedAssignmentRoot()
43467
43507
  if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
43468
43508
  throw new Error("accepted assignment journal root is not a trusted directory");
43469
43509
  }
43470
- await chmod10(root, DIRECTORY_MODE6);
43510
+ await chmod11(root, DIRECTORY_MODE6);
43471
43511
  const claims = [];
43472
43512
  for (const entry of await readdir7(root, { withFileTypes: true })) {
43473
43513
  if (!entry.isFile()) continue;
@@ -43486,7 +43526,7 @@ async function forgetAcceptedAssignment(assignment, root = defaultAcceptedAssign
43486
43526
  } catch {
43487
43527
  return;
43488
43528
  }
43489
- await rm14(path, { force: true }).catch(() => {
43529
+ await rm15(path, { force: true }).catch(() => {
43490
43530
  });
43491
43531
  }
43492
43532
  async function forgetAcknowledgedAcceptedAssignments(assignments, root = defaultAcceptedAssignmentRoot()) {
@@ -43494,9 +43534,9 @@ async function forgetAcknowledgedAcceptedAssignments(assignments, root = default
43494
43534
  }
43495
43535
 
43496
43536
  // src/local-observability.ts
43497
- import { appendFile, mkdir as mkdir19, open as open12, readdir as readdir8, rename as rename11, rm as rm15, stat as stat3 } from "node:fs/promises";
43498
- import { homedir as homedir15 } from "node:os";
43499
- import { basename as basename7, dirname as dirname16, join as join26 } from "node:path";
43537
+ import { appendFile, mkdir as mkdir20, open as open12, readdir as readdir8, rename as rename12, rm as rm16, stat as stat3 } from "node:fs/promises";
43538
+ import { homedir as homedir16 } from "node:os";
43539
+ import { basename as basename7, dirname as dirname16, join as join27 } from "node:path";
43500
43540
 
43501
43541
  // src/logger.ts
43502
43542
  var ANSI = {
@@ -43608,11 +43648,11 @@ var LOCAL_STATUS_FILE = "status.json";
43608
43648
  var LOCAL_REQUESTS_DIR = "requests";
43609
43649
  var DEFAULT_CONSOLE_ROTATE_BYTES = 2 * 1024 * 1024;
43610
43650
  function defaultLocalObservabilityRoot() {
43611
- return join26(homedir15(), ".zixt", "observability");
43651
+ return join27(homedir16(), ".zixt", "observability");
43612
43652
  }
43613
43653
  function createLocalConsoleSink(options = {}) {
43614
43654
  const root = options.root ?? defaultLocalObservabilityRoot();
43615
- const consolePath = join26(root, LOCAL_CONSOLE_FILE);
43655
+ const consolePath = join27(root, LOCAL_CONSOLE_FILE);
43616
43656
  const rotateBytes = options.rotateBytes ?? DEFAULT_CONSOLE_ROTATE_BYTES;
43617
43657
  let disabled = false;
43618
43658
  let prepared = false;
@@ -43622,7 +43662,7 @@ function createLocalConsoleSink(options = {}) {
43622
43662
  if (disabled) return;
43623
43663
  try {
43624
43664
  if (!prepared) {
43625
- await mkdir19(root, { recursive: true, mode: 448 });
43665
+ await mkdir20(root, { recursive: true, mode: 448 });
43626
43666
  approximateBytes = await stat3(consolePath).then(
43627
43667
  (existing) => existing.size,
43628
43668
  () => 0
@@ -43630,8 +43670,8 @@ function createLocalConsoleSink(options = {}) {
43630
43670
  prepared = true;
43631
43671
  }
43632
43672
  if (approximateBytes >= rotateBytes) {
43633
- await rm15(join26(root, LOCAL_CONSOLE_PREVIOUS_FILE), { force: true });
43634
- await rename11(consolePath, join26(root, LOCAL_CONSOLE_PREVIOUS_FILE)).catch(
43673
+ await rm16(join27(root, LOCAL_CONSOLE_PREVIOUS_FILE), { force: true });
43674
+ await rename12(consolePath, join27(root, LOCAL_CONSOLE_PREVIOUS_FILE)).catch(
43635
43675
  (error52) => {
43636
43676
  if (error52.code !== "ENOENT") throw error52;
43637
43677
  }
@@ -43662,7 +43702,7 @@ function createLocalConsoleSink(options = {}) {
43662
43702
  };
43663
43703
  }
43664
43704
  async function consumeRunnerInstallRequests(root = defaultLocalObservabilityRoot()) {
43665
- const directory = join26(root, LOCAL_REQUESTS_DIR);
43705
+ const directory = join27(root, LOCAL_REQUESTS_DIR);
43666
43706
  const requested = /* @__PURE__ */ new Set();
43667
43707
  let names;
43668
43708
  try {
@@ -43674,7 +43714,7 @@ async function consumeRunnerInstallRequests(root = defaultLocalObservabilityRoot
43674
43714
  const name = `install-runner-${type}.json`;
43675
43715
  if (!names.includes(name)) continue;
43676
43716
  try {
43677
- await rm15(join26(directory, name), { force: true });
43717
+ await rm16(join27(directory, name), { force: true });
43678
43718
  requested.add(type);
43679
43719
  } catch {
43680
43720
  }
@@ -43682,13 +43722,13 @@ async function consumeRunnerInstallRequests(root = defaultLocalObservabilityRoot
43682
43722
  return requested;
43683
43723
  }
43684
43724
  async function writeLocalStatus(status, root = defaultLocalObservabilityRoot()) {
43685
- const destination = join26(root, LOCAL_STATUS_FILE);
43686
- const temporary = join26(
43725
+ const destination = join27(root, LOCAL_STATUS_FILE);
43726
+ const temporary = join27(
43687
43727
  dirname16(destination),
43688
43728
  `.${basename7(destination)}.${process.pid}.${crypto.randomUUID()}.tmp`
43689
43729
  );
43690
43730
  try {
43691
- await mkdir19(root, { recursive: true, mode: 448 });
43731
+ await mkdir20(root, { recursive: true, mode: 448 });
43692
43732
  const handle = await open12(temporary, "wx", 384);
43693
43733
  try {
43694
43734
  await handle.writeFile(`${JSON.stringify(status)}
@@ -43696,31 +43736,31 @@ async function writeLocalStatus(status, root = defaultLocalObservabilityRoot())
43696
43736
  } finally {
43697
43737
  await handle.close();
43698
43738
  }
43699
- await rename11(temporary, destination);
43739
+ await rename12(temporary, destination);
43700
43740
  } catch {
43701
- await rm15(temporary, { force: true }).catch(() => void 0);
43741
+ await rm16(temporary, { force: true }).catch(() => void 0);
43702
43742
  }
43703
43743
  }
43704
43744
 
43705
43745
  // src/demo-state.ts
43706
- import { isAbsolute as isAbsolute19, join as join27, parse as parse3, resolve as resolve17 } from "node:path";
43746
+ import { isAbsolute as isAbsolute19, join as join28, parse as parse3, resolve as resolve18 } from "node:path";
43707
43747
  var DEMO_STATE_ROOT_ENV = "ZIXT_DEMO_STATE_ROOT";
43708
43748
  function resolveDemoHostStatePaths(env = process.env) {
43709
43749
  const configured = env.ZIXT_RUNNER === "demo" ? env[DEMO_STATE_ROOT_ENV] : void 0;
43710
43750
  if (!configured) return null;
43711
- const root = resolve17(configured);
43751
+ const root = resolve18(configured);
43712
43752
  if (!isAbsolute19(configured) || root === parse3(root).root) {
43713
43753
  throw new Error(`${DEMO_STATE_ROOT_ENV} must be a dedicated absolute directory`);
43714
43754
  }
43715
43755
  return {
43716
- runRegistryRoot: join27(root, "run-registry"),
43717
- terminalOutcomeRoot: join27(root, "terminal-outcomes"),
43718
- acceptedAssignmentRoot: join27(root, "accepted-assignments"),
43719
- runArtifactRoot: join27(root, "run-artifacts"),
43720
- browserProfileRoot: join27(root, "browser-profiles"),
43721
- runnerWorkspaceRoot: join27(root, "workspaces"),
43722
- codexThreadIndexRoot: join27(root, "codex-threads"),
43723
- localObservabilityRoot: join27(root, "local-observability")
43756
+ runRegistryRoot: join28(root, "run-registry"),
43757
+ terminalOutcomeRoot: join28(root, "terminal-outcomes"),
43758
+ acceptedAssignmentRoot: join28(root, "accepted-assignments"),
43759
+ runArtifactRoot: join28(root, "run-artifacts"),
43760
+ browserProfileRoot: join28(root, "browser-profiles"),
43761
+ runnerWorkspaceRoot: join28(root, "workspaces"),
43762
+ codexThreadIndexRoot: join28(root, "codex-threads"),
43763
+ localObservabilityRoot: join28(root, "local-observability")
43724
43764
  };
43725
43765
  }
43726
43766
 
@@ -44248,7 +44288,7 @@ async function telemetry() {
44248
44288
  // Measured per heartbeat: free memory and free disk are only useful while
44249
44289
  // they are current, and a demo Host reports its own private root so the
44250
44290
  // number describes the filesystem its Tasks would really write to.
44251
- hardware: await machineHardware(runnerWorkspaceRoot ?? homedir16()),
44291
+ hardware: await machineHardware(runnerWorkspaceRoot ?? homedir17()),
44252
44292
  capabilities: {
44253
44293
  linearToolPack: providerToolPacks.some(
44254
44294
  (pack) => pack.provider === "linear" && pack.health === "ready"