relay-companion 0.1.635 → 0.1.638

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.
@@ -61,20 +61,25 @@ async function runBridge({ activationEnabled = false, transactionId, target, ada
61
61
  await step("stability-observed", adapters.observeStability);
62
62
  await save({ state: "committed" });
63
63
  } catch (error) {
64
+ // The step and a closed error code are safe to report from the fleet;
65
+ // the free-text failure stays on this computer. Two Dev Macs reported
66
+ // only "rolled-back" for their launcher updates (Oct 2026), and nobody
67
+ // could tell which step had failed.
68
+ const failed = { failure: String(error.message).slice(0, 500), failedStep: journal.pending, failureCode: failureCode(error) };
64
69
  if (error.preserveCurrent === true) {
65
- await save({ state: "deferred", failure: String(error.message).slice(0, 500) });
70
+ await save({ state: "deferred", ...failed });
66
71
  return journal;
67
72
  }
68
73
  // A pending transfer may have taken effect before the process died. Do
69
74
  // not assume only a completed journal entry means ownership changed.
70
75
  const needsRestore = journal.transferAttempted === true || journal.completed.includes("ownership-transferred") || journal.pending === "ownership-transferred";
71
76
  if (needsRestore) {
72
- await save({ state: "rollback-required", failure: String(error.message).slice(0, 500) });
77
+ await save({ state: "rollback-required", ...failed });
73
78
  const restored = await adapters.restorePrevious({ transactionId, target, journal });
74
79
  if (restored?.ok !== true) return journal;
75
80
  await save({ state: "rolled-back", pending: null });
76
81
  } else {
77
- await save({ state: "preparing", failure: String(error.message).slice(0, 500) });
82
+ await save({ state: "preparing", ...failed });
78
83
  }
79
84
  return journal;
80
85
  }
@@ -91,4 +96,19 @@ async function runBridge({ activationEnabled = false, transactionId, target, ada
91
96
  } finally { await release(); }
92
97
  }
93
98
 
94
- module.exports = { runBridge };
99
+ // Node's own errno words (EPERM, EACCES, ENOENT...) or a word the adapter set
100
+ // itself (the native installer names the command that failed). Never text.
101
+ function failureCode(error) {
102
+ if (typeof error?.code === "string" && /^E[A-Z0-9]{2,30}$/.test(error.code)) return error.code.toLowerCase();
103
+ if (typeof error?.failureCode === "string" && /^[a-z0-9-]{1,40}$/.test(error.failureCode)) return error.failureCode;
104
+ return null;
105
+ }
106
+
107
+ // One telemetry word for a failed handoff: the step, then the code when known,
108
+ // e.g. "ownership-transferred-eperm" or "application-healthy".
109
+ function failureReason(journal) {
110
+ if (typeof journal?.failedStep !== "string" || !/^[a-z-]{1,40}$/.test(journal.failedStep)) return null;
111
+ return journal.failureCode ? `${journal.failedStep}-${journal.failureCode}` : journal.failedStep;
112
+ }
113
+
114
+ module.exports = { runBridge, failureReason };
@@ -11,7 +11,10 @@ function inside(root, file) {
11
11
  }
12
12
  function command(run, file, args, options = {}) {
13
13
  const result = run(file, args, { encoding: "utf8", windowsHide: true, timeout: 10 * 60_000, ...options });
14
- if (result.error || result.status !== 0) throw new Error(`Native installer failed: ${result.error?.message || result.stderr || result.status}`);
14
+ // The failure code names the command (codesign, xcrun, spctl, ditto, unzip,
15
+ // or the downloaded installer), which the fleet may see; stderr stays local.
16
+ const name = /^(codesign|xcrun|spctl|ditto|unzip)$/.test(path.basename(file)) ? path.basename(file) : "installer";
17
+ if (result.error || result.status !== 0) throw Object.assign(new Error(`Native installer failed: ${result.error?.message || result.stderr || result.status}`), { failureCode: name });
15
18
  return result.stdout || "";
16
19
  }
17
20
  function packageLocation({ platform = process.platform, homeDir = os.homedir(), env = process.env } = {}) {
@@ -27,8 +27,12 @@ function validateApplicationRelease(payload, { version, sourceSha, channel } = {
27
27
  if (!targets.length || Object.keys(payload.artifacts || {}).some(key => !PLATFORMS.includes(key))) throw new Error("Invalid native platform selection");
28
28
  if (payload.schema === 2) {
29
29
  const policy = payload.rollout;
30
- if (!policy || typeof policy.nativeUpdates !== "boolean" || !Array.isArray(policy.migrateDeviceIds)
31
- || policy.migrateDeviceIds.length > 50 || policy.migrateDeviceIds.some(id => typeof id !== "string" || !/^[A-Za-z0-9_-]{8,160}$/.test(id))
30
+ const deviceIds = ids => Array.isArray(ids) && ids.length <= 50 && ids.every(id => typeof id === "string" && /^[A-Za-z0-9_-]{8,160}$/.test(id));
31
+ // nativeUpdateDeviceIds is optional: a cohort of installed apps that update
32
+ // while nativeUpdates stays false. Runtimes without cohort support see only
33
+ // nativeUpdates:false and stay paused, so a cohort never reaches them.
34
+ if (!policy || typeof policy.nativeUpdates !== "boolean" || !deviceIds(policy.migrateDeviceIds)
35
+ || (policy.nativeUpdateDeviceIds !== undefined && !deviceIds(policy.nativeUpdateDeviceIds))
32
36
  || !Number.isSafeInteger(policy.expiresAt) || policy.expiresAt <= 0) throw new Error("Invalid native rollout policy");
33
37
  }
34
38
  for (const platform of targets) {
@@ -10,6 +10,7 @@ const { handoffApplication, updateConsent, read, write } = require("./applicatio
10
10
  const { versionCompare } = require("./application-install.cjs");
11
11
  const bootstrap = require("./relay-setup.cjs");
12
12
  const rollout = require("./application-rollout.cjs");
13
+ const { failureReason } = require("./application-bridge.cjs");
13
14
  const CHECK_MS = 6 * 60 * 60_000;
14
15
 
15
16
  async function readOffer({ fetchImpl = globalThis.fetch, trustStore = trust, channel = "stable" } = {}) {
@@ -29,7 +30,9 @@ function rolloutDecision(payload, { owner, deviceId, now = Date.now() }) {
29
30
  const policy = payload.rollout;
30
31
  if (payload.schema !== 2 || !policy) return "rollout-policy-required";
31
32
  if (policy.expiresAt <= now || policy.expiresAt > now + 31 * 86400_000) return "rollout-policy-expired";
32
- if (owner) return policy.nativeUpdates ? null : "native-updates-paused";
33
+ // An installed app updates when the offer is open to every app, or when this
34
+ // device is in the offer's cohort (production starts with internal devices).
35
+ if (owner) return policy.nativeUpdates || (deviceId && policy.nativeUpdateDeviceIds?.includes(deviceId)) ? null : "native-updates-paused";
33
36
  return deviceId && policy.migrateDeviceIds.includes(deviceId) ? null : "migration-not-selected";
34
37
  }
35
38
 
@@ -72,7 +75,15 @@ async function checkApplicationUpdate({ activationEnabled = rollout.enabled, hom
72
75
  const kind = platform === "darwin" ? "zip" : platform === "win32" ? "exe"
73
76
  : fs.existsSync("/usr/bin/dpkg") ? "deb" : "rpm";
74
77
  const artifact = payload.artifacts[platformKey]?.find(item => item.kind === kind);
75
- if (!artifact) throw new Error("No native package for this host");
78
+ // A channel offer without this platform's package is the release's
79
+ // fault, not this computer's: say so in a word telemetry and doctor can
80
+ // carry, and check again on the normal schedule instead of every five
81
+ // minutes (Dev's launcher offer went Mac-only for six days, Oct 2026).
82
+ if (!artifact) {
83
+ const missing = { schema: 1, at: now(), nextCheckAt: now() + CHECK_MS, state: "no-package-for-platform", channel: consent.channel,
84
+ version: payload.version, sourceSha: payload.sourceSha, platform: platformKey, packageKind: kind, changed: false };
85
+ write(statusFile, missing); return missing;
86
+ }
76
87
  const directory = path.join(root, "application-packages", `${payload.version}-${payload.sourceSha}-${platformKey}`);
77
88
  fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
78
89
  const file = path.join(directory, `installer.${kind}`);
@@ -90,8 +101,9 @@ async function checkApplicationUpdate({ activationEnabled = rollout.enabled, hom
90
101
  const action = read(path.join(directory, "action.json"));
91
102
  if (action?.state === "installer-action-required" && result.state !== "complete") result = { ...action, bridgeState: result.state };
92
103
  }
104
+ const reason = failureReason(result);
93
105
  write(statusFile, { schema: 1, at: now(), nextCheckAt: now() + CHECK_MS,
94
- version: payload.version, sourceSha: payload.sourceSha, ...result });
106
+ version: payload.version, sourceSha: payload.sourceSha, ...result, ...(reason ? { reason } : {}) });
95
107
  return result;
96
108
  } catch (error) {
97
109
  write(statusFile, { schema: 1, at: now(), nextCheckAt: now() + 5 * 60_000, state: "failed", detail: String(error.message).slice(0, 500) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relay-companion",
3
- "version": "0.1.635",
3
+ "version": "0.1.638",
4
4
  "description": "Install Relay for Claude Code, Cowork, and Codex, then sign in from the Relay pill.",
5
5
  "homepage": "https://sendrelays.com/get-started",
6
6
  "repository": {