@zixt/host 0.0.81 → 0.0.83

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 +85 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { homedir as homedir3 } from "node:os";
31
31
  // package.json
32
32
  var package_default = {
33
33
  name: "@zixt/host",
34
- version: "0.0.81",
34
+ version: "0.0.83",
35
35
  type: "module",
36
36
  exports: {
37
37
  ".": "./src/client.ts",
@@ -14661,6 +14661,8 @@ var ID_PREFIXES = {
14661
14661
  conversationEvent: "cve",
14662
14662
  /** One human-confirmed integration action prepared by the Manager. */
14663
14663
  managerIntegrationAction: "mia",
14664
+ /** One Manager-prepared secure Credential entry card (MG-17). */
14665
+ managerCredentialRequest: "mcr",
14664
14666
  /** One Manager inference call's token-metering row (MG-8). */
14665
14667
  managerUsage: "mgu",
14666
14668
  /** One ordered Manager reply awaiting Slack delivery. */
@@ -14712,6 +14714,10 @@ var ManagerIntegrationActionId = idSchema(
14712
14714
  ID_PREFIXES.managerIntegrationAction,
14713
14715
  "Manager integration action id"
14714
14716
  );
14717
+ var ManagerCredentialRequestId = idSchema(
14718
+ ID_PREFIXES.managerCredentialRequest,
14719
+ "Manager credential request id"
14720
+ );
14715
14721
  var ManagerEmailInboxId = idSchema(
14716
14722
  ID_PREFIXES.managerEmailInbox,
14717
14723
  "Manager email inbox id"
@@ -18331,7 +18337,9 @@ var ConversationEventProjection = external_exports.discriminatedUnion("kind", [
18331
18337
  taskId: TaskId.nullable(),
18332
18338
  agentId: AgentId.nullable(),
18333
18339
  /** Present only for a confirmation card; OAuth authority never appears here. */
18334
- integrationActionId: ManagerIntegrationActionId.nullable().optional()
18340
+ integrationActionId: ManagerIntegrationActionId.nullable().optional(),
18341
+ /** Present only for a secure Credential entry card; never a value (MG-17). */
18342
+ credentialRequestId: ManagerCredentialRequestId.nullable().optional()
18335
18343
  }).strict(),
18336
18344
  /** A mirrored child-Task event: what the teammate wrote or became. */
18337
18345
  external_exports.object({
@@ -18397,6 +18405,48 @@ var ManagerIntegrationActionResponse = external_exports.object({
18397
18405
  action: ManagerIntegrationActionProjection,
18398
18406
  oauth: ManagerIntegrationOAuthStart.nullable()
18399
18407
  }).strict();
18408
+ var ManagerCredentialRequestStatus = external_exports.enum([
18409
+ "awaiting_entry",
18410
+ "storing",
18411
+ "stored",
18412
+ "cancelled",
18413
+ "expired",
18414
+ "failed"
18415
+ ]);
18416
+ var ManagerCredentialRequestProjection = external_exports.object({
18417
+ id: ManagerCredentialRequestId,
18418
+ conversationId: ConversationId,
18419
+ /** The Credential name, exactly as it will appear in Credentials. */
18420
+ name: external_exports.string().min(1).max(120),
18421
+ /** `env` reaches a Task as an environment variable; `web_login` fills a sign-in form. */
18422
+ kind: external_exports.enum(["env", "web_login"]),
18423
+ /** Saved as the Credential's description so teammates know what they hold. */
18424
+ purpose: external_exports.string().max(500).nullable(),
18425
+ scope: external_exports.enum(["organization", "teammates"]),
18426
+ /** Named teammates for a teammate-scoped Credential; empty for organization scope. */
18427
+ teammates: external_exports.array(external_exports.object({ agentId: AgentId, name: external_exports.string().min(1).max(200) }).strict()).max(100),
18428
+ /** Suggested sign-in page for a website login; the person can correct it. */
18429
+ loginUrl: external_exports.url().max(2e3).nullable(),
18430
+ status: ManagerCredentialRequestStatus,
18431
+ outcome: external_exports.string().max(1e3).nullable(),
18432
+ createdAt: external_exports.string(),
18433
+ expiresAt: external_exports.string()
18434
+ }).strict();
18435
+ var SubmitManagerCredentialRequest = external_exports.object({
18436
+ requestId: external_exports.uuid(),
18437
+ /** env kind. */
18438
+ value: external_exports.string().min(1).max(1e4).optional(),
18439
+ /** web_login kind. */
18440
+ webLogin: WebLoginValue.optional()
18441
+ }).strict().superRefine((request, ctx) => {
18442
+ if (request.value === void 0 === (request.webLogin === void 0)) {
18443
+ ctx.addIssue({
18444
+ code: "custom",
18445
+ path: ["value"],
18446
+ message: "submit exactly one of value or webLogin, matching the requested kind"
18447
+ });
18448
+ }
18449
+ });
18400
18450
  var NonEmptyTaskRunnerSelection = TaskRunnerSelection.refine(
18401
18451
  (selection) => selection.type !== void 0 || selection.model !== void 0 || selection.effort !== void 0,
18402
18452
  "choose at least one runtime preference"
@@ -25396,6 +25446,9 @@ var DO_NOT_RESTART_EXIT_CODE = 64;
25396
25446
  var RESTART_BACKOFF_MS = 2e3;
25397
25447
  var MAX_RESTART_BACKOFF_MS = 6e4;
25398
25448
  var CRASH_STREAK_RESET_MS = 6e4;
25449
+ function streakBackoffMs(streak) {
25450
+ return Math.min(MAX_RESTART_BACKOFF_MS, RESTART_BACKOFF_MS * 2 ** Math.min(streak - 1, 10));
25451
+ }
25399
25452
  var RELEASE_PROBATION_MS = 5 * 6e4;
25400
25453
  var FAST_UPDATE_EXIT_MS = 1e4;
25401
25454
  var STOP_GRACE_MS = 3e4;
@@ -25446,6 +25499,23 @@ function versionsRoot() {
25446
25499
  function npmCommand(platform = process.platform) {
25447
25500
  return platform === "win32" ? "npm.cmd" : "npm";
25448
25501
  }
25502
+ async function resolveInstallerCommand(options = {}) {
25503
+ const platform = options.platform ?? process.platform;
25504
+ const command = npmCommand(platform);
25505
+ if (platform !== "win32") return command;
25506
+ const execPath = options.execPath ?? process.execPath;
25507
+ const resolution = {
25508
+ platform,
25509
+ ...options.searchPath !== void 0 ? { searchPath: options.searchPath } : {}
25510
+ };
25511
+ return (
25512
+ // npm ships beside the `node` running this process, and that copy is the
25513
+ // one matching it. A per-user Scheduled Task may carry no npm on PATH.
25514
+ await resolveTrustedCliCommand(join8(dirname4(execPath), command), resolution) ?? await resolveTrustedCliCommand(command, resolution) ?? // Nothing resolved: keep the previous behaviour, so a Machine without npm
25515
+ // fails one install rather than changing how failure is handled.
25516
+ command
25517
+ );
25518
+ }
25449
25519
  function windowsInstallerCommandLine(command, args) {
25450
25520
  return [command, ...args].map(quoteForCmd).join(" ");
25451
25521
  }
@@ -25738,12 +25808,12 @@ var InstallerContainmentError = class extends Error {
25738
25808
  async function installRelease(version2, options = {}) {
25739
25809
  if (!VERSION_DIR.test(version2)) return null;
25740
25810
  const platform = options.platform ?? process.platform;
25741
- const installerCommand = options.installerCommand ?? npmCommand(platform);
25742
25811
  const root = options.root ?? versionsRoot();
25743
25812
  const prefix = join8(root, version2);
25744
25813
  const entry = installedReleaseEntry(version2, root);
25745
25814
  if (await validReleaseAtPrefix(prefix, version2)) return entry;
25746
25815
  if (options.signal?.aborted) return null;
25816
+ const installerCommand = options.installerCommand ?? await resolveInstallerCommand({ platform });
25747
25817
  await mkdir5(root, { recursive: true, mode: 448 });
25748
25818
  const staging = join8(root, `.install-${version2}-${process.pid}-${crypto.randomUUID()}`);
25749
25819
  const quarantine = join8(root, `.invalid-${version2}-${process.pid}-${crypto.randomUUID()}`);
@@ -26552,6 +26622,7 @@ async function superviseHost(options = {}) {
26552
26622
  announceShutdown = resolve18;
26553
26623
  });
26554
26624
  const attempted = /* @__PURE__ */ new Set();
26625
+ let unsatisfiableUpdates = 0;
26555
26626
  const waitOrShutdown = async (ms) => {
26556
26627
  if (shuttingDown2) return false;
26557
26628
  if (!customDelay) {
@@ -26572,11 +26643,7 @@ async function superviseHost(options = {}) {
26572
26643
  const waitAfterCrash = async (runtimeMs) => {
26573
26644
  if (runtimeMs >= CRASH_STREAK_RESET_MS) consecutiveCrashes = 0;
26574
26645
  consecutiveCrashes++;
26575
- const backoff = Math.min(
26576
- MAX_RESTART_BACKOFF_MS,
26577
- RESTART_BACKOFF_MS * 2 ** Math.min(consecutiveCrashes - 1, 10)
26578
- );
26579
- return waitOrShutdown(backoff);
26646
+ return waitOrShutdown(streakBackoffMs(consecutiveCrashes));
26580
26647
  };
26581
26648
  const cleanupExitedWorker = async (exitedChild, childExited, workerBoundary, containment) => {
26582
26649
  for (let attempt = 1; attempt <= CLEANUP_ATTEMPTS2; attempt++) {
@@ -26939,10 +27006,15 @@ async function superviseHost(options = {}) {
26939
27006
  consecutiveCrashes = 0;
26940
27007
  if (orderlyValidatedBoundary) rollbackCandidate = null;
26941
27008
  const target = await published();
27009
+ let updateLanded = false;
26942
27010
  if (target === null) {
26943
27011
  log2(
26944
27012
  "Zixt Host: a newer release was reported but the registry is unreachable; staying on the current version"
26945
27013
  );
27014
+ } else if (target === command.version) {
27015
+ log2(
27016
+ `Zixt Host: this Machine already runs the newest published release (${target}), so an update cannot satisfy the cloud; waiting for a newer one`
27017
+ );
26946
27018
  } else if (attempted.has(target)) {
26947
27019
  log2(`Zixt Host: already running ${target}; ignoring a repeated update request`);
26948
27020
  } else {
@@ -27016,6 +27088,7 @@ async function superviseHost(options = {}) {
27016
27088
  }
27017
27089
  rollbackCandidate = { failedVersion: target, command: fallback };
27018
27090
  command = { entry, version: target };
27091
+ updateLanded = true;
27019
27092
  if (reloadAfterActivation) return SUPERVISOR_RELOAD_EXIT_CODE;
27020
27093
  if (releaseStore) {
27021
27094
  const probation = durableState("probation", target, fallback.version);
@@ -27043,7 +27116,10 @@ async function superviseHost(options = {}) {
27043
27116
  log2(`Zixt Host: could not install ${target}; staying on the current version`);
27044
27117
  }
27045
27118
  }
27046
- if (now() - startedAt < FAST_UPDATE_EXIT_MS && !await waitOrShutdown(RESTART_BACKOFF_MS)) {
27119
+ unsatisfiableUpdates = updateLanded ? 0 : unsatisfiableUpdates + 1;
27120
+ if (unsatisfiableUpdates > 0) {
27121
+ if (!await waitOrShutdown(streakBackoffMs(unsatisfiableUpdates))) return 0;
27122
+ } else if (now() - startedAt < FAST_UPDATE_EXIT_MS && !await waitOrShutdown(RESTART_BACKOFF_MS)) {
27047
27123
  return 0;
27048
27124
  }
27049
27125
  if (shuttingDown2) return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zixt/host",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/client.ts",