relay-companion 0.1.600 → 0.1.602

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ // How macOS names Relay's launch agents.
4
+ //
5
+ // Background Task Management (Login Items & Extensions, and the "App
6
+ // Background Activity" notice it posts when an agent first appears) names a
7
+ // legacy launch agent after the code at ProgramArguments[0]:
8
+ //
9
+ // - When the plist's AssociatedBundleIdentifiers names an installed app
10
+ // signed by the SAME Team ID as that code, the item shows as that app.
11
+ // - Otherwise a Developer ID signed executable shows as its developer.
12
+ // - An ad-hoc signed executable (no Team ID) shows as the executable's own
13
+ // file name.
14
+ //
15
+ // Relay's daemon and recovery agents run the Node that ships inside
16
+ // /Applications/Relay.app (or a byte-identical copy), signed with the same
17
+ // Developer ID team as the app, so associating them with the app shows them as
18
+ // "Relay". The pill runs the runtime's ad-hoc signed Electron, which has no Team
19
+ // ID, so the association cannot apply to it; its main executable is therefore
20
+ // named "Relay" in the runtime artifact. MacOS/Electron stays as a link to it:
21
+ // installers, updaters and recovery engines already in the field locate the
22
+ // runtime by that path and must keep accepting new runtimes.
23
+
24
+ const fs = require("node:fs");
25
+ const path = require("node:path");
26
+ const { APPLICATION_ID } = require("./application-owner.cjs");
27
+
28
+ const RELAY_MAC_ASSOCIATED_BUNDLE_IDENTIFIERS = Object.freeze([APPLICATION_ID]);
29
+ const RELAY_MAC_EXECUTABLE_NAME = "Relay";
30
+ const LEGACY_MAC_EXECUTABLE_NAME = "Electron";
31
+
32
+ function xmlEscape(value) {
33
+ return String(value)
34
+ .replaceAll("&", "&")
35
+ .replaceAll("<", "&lt;")
36
+ .replaceAll(">", "&gt;")
37
+ .replaceAll('"', "&quot;")
38
+ .replaceAll("'", "&apos;");
39
+ }
40
+
41
+ /** The launchd plist fragment that files an agent under Relay.app in Login Items. */
42
+ function associatedBundleIdentifiersPlist(indent = "") {
43
+ const values = RELAY_MAC_ASSOCIATED_BUNDLE_IDENTIFIERS.map((id) => `<string>${xmlEscape(id)}</string>`).join("");
44
+ return `${indent}<key>AssociatedBundleIdentifiers</key><array>${values}</array>`;
45
+ }
46
+
47
+ /**
48
+ * The executable a macOS launch agent should name for an Electron runtime.
49
+ * A Relay-built runtime's bundle executable is MacOS/Relay; MacOS/Electron is
50
+ * only its compatibility link. Stock or older runtimes have MacOS/Electron
51
+ * alone and keep it. Anything that is not a bundle main executable is
52
+ * returned unchanged.
53
+ */
54
+ function preferredMacElectronExecutable(electronPath, { existsSync = fs.existsSync, statSync = fs.statSync } = {}) {
55
+ const value = String(electronPath || "");
56
+ if (!value || path.posix.basename(value) !== LEGACY_MAC_EXECUTABLE_NAME) return electronPath;
57
+ const directory = path.posix.dirname(value);
58
+ if (path.posix.basename(directory) !== "MacOS" || path.posix.basename(path.posix.dirname(directory)) !== "Contents") return electronPath;
59
+ const branded = path.posix.join(directory, RELAY_MAC_EXECUTABLE_NAME);
60
+ try {
61
+ if (existsSync(branded) && statSync(branded).isFile()) return branded;
62
+ } catch {}
63
+ return electronPath;
64
+ }
65
+
66
+ module.exports = {
67
+ LEGACY_MAC_EXECUTABLE_NAME,
68
+ RELAY_MAC_ASSOCIATED_BUNDLE_IDENTIFIERS,
69
+ RELAY_MAC_EXECUTABLE_NAME,
70
+ associatedBundleIdentifiersPlist,
71
+ preferredMacElectronExecutable,
72
+ };
@@ -6,6 +6,7 @@ const crypto = require("node:crypto");
6
6
  const { spawnSync } = require("node:child_process");
7
7
  const { relayOwnedNodePath } = require("./owned-node-runtime.cjs");
8
8
  const { atomicFile } = require("./mac-registration-transaction.cjs");
9
+ const { associatedBundleIdentifiersPlist } = require("./mac-background-identity.cjs");
9
10
  const { read, write, compare } = require("./recovery-runner.cjs");
10
11
  const LABEL = "work.relay.companion.recovery";
11
12
  const TASK = "Relay Companion Recovery";
@@ -185,7 +186,7 @@ function installRecovery({ packageRoot, node = process.execPath, homeDir = os.ho
185
186
  const plist = path.join(homeDir, "Library", "LaunchAgents", `${LABEL}.plist`);
186
187
  fs.mkdirSync(path.dirname(plist), { recursive: true });
187
188
  const priorSchedule = fs.existsSync(plist) ? fs.readFileSync(plist) : null;
188
- const nextSchedule = `<?xml version="1.0"?><plist version="1.0"><dict><key>Label</key><string>${LABEL}</string><key>ProgramArguments</key><array><string>${xml(launcherNode)}</string><string>${xml(launcher)}</string></array><key>EnvironmentVariables</key><dict><key>HOME</key><string>${xml(homeDir)}</string></dict><key>StartInterval</key><integer>60</integer><key>RunAtLoad</key><true/><key>ProcessType</key><string>Background</string><key>StandardOutPath</key><string>${xml(log)}</string><key>StandardErrorPath</key><string>${xml(log)}</string></dict></plist>`;
189
+ const nextSchedule = `<?xml version="1.0"?><plist version="1.0"><dict><key>Label</key><string>${LABEL}</string><key>ProgramArguments</key><array><string>${xml(launcherNode)}</string><string>${xml(launcher)}</string></array><key>EnvironmentVariables</key><dict><key>HOME</key><string>${xml(homeDir)}</string></dict><key>StartInterval</key><integer>60</integer><key>RunAtLoad</key><true/><key>ProcessType</key><string>Background</string>${associatedBundleIdentifiersPlist()}<key>StandardOutPath</key><string>${xml(log)}</string><key>StandardErrorPath</key><string>${xml(log)}</string></dict></plist>`;
189
190
  atomicFile(plist, nextSchedule);
190
191
  // The job dispatches through the stable host. Do not unload it on update.
191
192
  const observed = runCommand("launchctl", ["print", `gui/${userId}/${LABEL}`]);
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require("node:fs");
4
4
  const path = require("node:path");
5
+ const { LEGACY_MAC_EXECUTABLE_NAME, RELAY_MAC_EXECUTABLE_NAME } = require("./mac-background-identity.cjs");
5
6
 
6
7
  const MAC_HELPER_EXECUTABLES = [
7
8
  ["Electron Helper.app", "Electron Helper"],
@@ -18,6 +19,21 @@ function pathsFor(platform) {
18
19
  return platformName(platform) === "win32" ? path.win32 : path.posix;
19
20
  }
20
21
 
22
+ // Electron's main executable inside its npm package, most preferred first.
23
+ // Relay-built macOS runtimes name the bundle executable MacOS/Relay so macOS
24
+ // shows the pill's launch agent as "Relay" (see mac-background-identity.cjs);
25
+ // stock and older runtimes have only MacOS/Electron.
26
+ function electronMainCandidates(platform = process.platform) {
27
+ const name = platformName(platform);
28
+ const api = pathsFor(name);
29
+ if (name === "win32") return [api.join("dist", "electron.exe")];
30
+ if (name === "darwin") {
31
+ return [RELAY_MAC_EXECUTABLE_NAME, LEGACY_MAC_EXECUTABLE_NAME]
32
+ .map((executable) => api.join("dist", "Electron.app", "Contents", "MacOS", executable));
33
+ }
34
+ return [api.join("dist", "electron")];
35
+ }
36
+
21
37
  function runtimeExecutableInventory(packageRoot, {
22
38
  platform = process.platform,
23
39
  existsSync = fs.existsSync,
@@ -25,14 +41,14 @@ function runtimeExecutableInventory(packageRoot, {
25
41
  const name = platformName(platform);
26
42
  const api = pathsFor(name);
27
43
  const roots = [api.join(packageRoot, "node_modules", "electron"), api.join(api.dirname(packageRoot), "electron")];
28
- const mainRelative = name === "win32"
29
- ? api.join("dist", "electron.exe")
30
- : name === "darwin"
31
- ? api.join("dist", "Electron.app", "Contents", "MacOS", "Electron")
32
- : api.join("dist", "electron");
33
- const electronRoot = roots.find((root) => {
34
- try { return existsSync(api.join(root, mainRelative)); } catch { return false; }
35
- });
44
+ let electronRoot = null;
45
+ let mainRelative = null;
46
+ for (const root of roots) {
47
+ mainRelative = electronMainCandidates(name).find((relative) => {
48
+ try { return existsSync(api.join(root, relative)); } catch { return false; }
49
+ }) || null;
50
+ if (mainRelative) { electronRoot = root; break; }
51
+ }
36
52
  if (!electronRoot) return { ok: false, reason: "candidate-electron-missing", paths: [] };
37
53
 
38
54
  const entries = [{ role: "electron", path: api.join(electronRoot, mainRelative) }];
@@ -130,6 +146,7 @@ function repairRuntimeExecutablePermissions(packageRoot, {
130
146
 
131
147
  module.exports = {
132
148
  MAC_HELPER_EXECUTABLES,
149
+ electronMainCandidates,
133
150
  repairRuntimeExecutablePermissions,
134
151
  runtimeExecutableInventory,
135
152
  verifyRuntimeExecutables,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relay-companion",
3
- "version": "0.1.600",
3
+ "version": "0.1.602",
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": {
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "relay",
4
- "version": "1.1.78",
4
+ "version": "1.1.79",
5
5
  "consentVersion": 2,
6
- "baseUrl": "https://sendrelays.com/skills/relay/v1.1.78",
6
+ "baseUrl": "https://sendrelays.com/skills/relay/v1.1.79",
7
7
  "files": [
8
8
  {
9
9
  "path": "SKILL.md",
10
- "sha256": "3242e11ecf00beb820140cdb311eea3174f03a8667198855ec90f184a2d0f689",
10
+ "sha256": "2403c1b8c7230ee65074298e8c63a1d9869fe60a6892eddad5934edb4f24eeda",
11
11
  "variants": {
12
12
  "dev": {
13
13
  "source": "SKILL.dev.md",
14
- "sha256": "83d0e513fdd44e9f36fdb198ed984022acfc7df07cdd9e2aacdf835537afd359"
14
+ "sha256": "03c50d1e37fe2632c9623c18044de986488a395bef62b85da3efe8f573670c2e"
15
15
  }
16
16
  }
17
17
  },
@@ -21,7 +21,7 @@
21
21
  },
22
22
  {
23
23
  "path": "scripts/relay-protocol.mjs",
24
- "sha256": "4f47d8e5fbdebc3f6edef52acea14b51d970b5978c036fac1825b56f35df2778"
24
+ "sha256": "8bffaadcb0e066b1a800068827994693f01062227e6f05db968e0a28efcfa0a4"
25
25
  },
26
26
  {
27
27
  "path": "scripts/relay-local.mjs",
@@ -580,7 +580,9 @@ The tutorial activation event is the approved first Relay, not app installation.
580
580
  ## Reading a Relay
581
581
 
582
582
  Fetch only the context the request needs. For a recent inbound Relay, find its
583
- metadata with relay_inbox_list and open its exact relayIds. For conversation
583
+ metadata with relay_inbox_list and open its exact relayIds. An opened Relay
584
+ may carry threadReplies: the replies people made in its thread, oldest first.
585
+ Read them with the Relay; a later reply can answer, correct or change it. For conversation
584
586
  context, relay_chat_fetch defaults to the newest 25 messages, oldest first;
585
587
  limit accepts 1–200. Continue with nextBeforeCursor for older messages or
586
588
  nextAfterCursor for newer ones, keeping the same chat and surface. Never call
@@ -31,7 +31,7 @@ const SAFE_GET = [
31
31
  /^\/v1\/inbox(?:\?.*)?$/,
32
32
  /^\/v1\/sent(?:\?.*)?$/,
33
33
  /^\/v1\/contacts\/search\?q=.+$/,
34
- /^\/v1\/relays\/[A-Za-z0-9_-]+$/,
34
+ /^\/v1\/relays\/[A-Za-z0-9_-]+(?:\?include=replies)?$/,
35
35
  /^\/v1\/threads\/[A-Za-z0-9_-]+$/,
36
36
  /^\/v1\/share-links\/[A-Za-z0-9_-]+$/,
37
37
  ];
@@ -786,7 +786,7 @@ async function directToolCommand(command, body, config) {
786
786
  else if (name === "relay_inbox_list") {
787
787
  if (args.relayIds) {
788
788
  const items = [];
789
- for (const relayId of new Set(args.relayIds)) items.push({ relayId, ...await request("GET", `/v1/relays/${relayId}`) });
789
+ for (const relayId of new Set(args.relayIds)) items.push({ relayId, ...await request("GET", `/v1/relays/${relayId}?include=replies`) });
790
790
  value = { items, readStateChanged: false, readReceiptsSent: false };
791
791
  } else value = await request("GET", "/v1/inbox?view=summary");
792
792
  } else if (name === "relay_share_stats") {
@@ -666,7 +666,9 @@ Choose every clearly applicable label; sentence-level attribution still matters.
666
666
  ## Reading a Relay
667
667
 
668
668
  Fetch only the context the request needs. For a recent inbound Relay, find its
669
- metadata with relay_inbox_list and open its exact relayIds. For conversation
669
+ metadata with relay_inbox_list and open its exact relayIds. An opened Relay
670
+ may carry threadReplies: the replies people made in its thread, oldest first.
671
+ Read them with the Relay; a later reply can answer, correct or change it. For conversation
670
672
  context, relay_chat_fetch defaults to the newest 25 messages, oldest first;
671
673
  limit accepts 1–200. Continue with nextBeforeCursor for older messages or
672
674
  nextAfterCursor for newer ones, keeping the same chat and surface. Never call