@agent-relay/utils 9.2.1 → 9.2.2

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.
package/dist/cjs/index.js CHANGED
@@ -24,7 +24,6 @@ __reExport(index_exports, require("./update-checker.js"), module.exports);
24
24
  __reExport(index_exports, require("./error-tracking.js"), module.exports);
25
25
  __reExport(index_exports, require("./model-mapping.js"), module.exports);
26
26
  __reExport(index_exports, require("./model-commands.js"), module.exports);
27
- __reExport(index_exports, require("./relay-pty-path.js"), module.exports);
28
27
  __reExport(index_exports, require("./client-helpers.js"), module.exports);
29
28
  // Annotate the CommonJS export names for ESM import in node:
30
29
  0 && (module.exports = {
@@ -37,6 +36,5 @@ __reExport(index_exports, require("./client-helpers.js"), module.exports);
37
36
  ...require("./error-tracking.js"),
38
37
  ...require("./model-mapping.js"),
39
38
  ...require("./model-commands.js"),
40
- ...require("./relay-pty-path.js"),
41
39
  ...require("./client-helpers.js")
42
40
  });
package/dist/index.d.ts CHANGED
@@ -7,6 +7,5 @@ export * from './update-checker.js';
7
7
  export * from './error-tracking.js';
8
8
  export * from './model-mapping.js';
9
9
  export * from './model-commands.js';
10
- export * from './relay-pty-path.js';
11
10
  export * from './client-helpers.js';
12
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -7,6 +7,5 @@ export * from './update-checker.js';
7
7
  export * from './error-tracking.js';
8
8
  export * from './model-mapping.js';
9
9
  export * from './model-commands.js';
10
- export * from './relay-pty-path.js';
11
10
  export * from './client-helpers.js';
12
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/utils",
3
- "version": "9.2.1",
3
+ "version": "9.2.2",
4
4
  "description": "Shared utilities for agent-relay: logging, name generation, command resolution, update checking",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -66,12 +66,6 @@
66
66
  "import": "./dist/model-commands.js",
67
67
  "default": "./dist/cjs/model-commands.js"
68
68
  },
69
- "./relay-pty-path": {
70
- "types": "./dist/relay-pty-path.d.ts",
71
- "require": "./dist/cjs/relay-pty-path.js",
72
- "import": "./dist/relay-pty-path.js",
73
- "default": "./dist/cjs/relay-pty-path.js"
74
- },
75
69
  "./client-helpers": {
76
70
  "types": "./dist/client-helpers.d.ts",
77
71
  "require": "./dist/cjs/client-helpers.js",
@@ -112,7 +106,7 @@
112
106
  "vitest": "^4.1.0"
113
107
  },
114
108
  "dependencies": {
115
- "@agent-relay/config": "9.2.1",
109
+ "@agent-relay/config": "9.2.2",
116
110
  "compare-versions": "^6.1.1"
117
111
  },
118
112
  "publishConfig": {
@@ -1,263 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var relay_pty_path_exports = {};
30
- __export(relay_pty_path_exports, {
31
- clearBinaryCache: () => clearBinaryCache,
32
- findRelayPtyBinary: () => findRelayPtyBinary,
33
- getCachedRelayPtyPath: () => getCachedRelayPtyPath,
34
- getLastSearchPaths: () => getLastSearchPaths,
35
- getSupportedPlatforms: () => getSupportedPlatforms,
36
- hasRelayPtyBinary: () => hasRelayPtyBinary,
37
- isPlatformSupported: () => isPlatformSupported
38
- });
39
- module.exports = __toCommonJS(relay_pty_path_exports);
40
- var import_node_fs = __toESM(require("node:fs"), 1);
41
- var import_node_os = __toESM(require("node:os"), 1);
42
- var import_node_path = __toESM(require("node:path"), 1);
43
- const SUPPORTED_PLATFORMS = {
44
- darwin: {
45
- arm64: "relay-pty-darwin-arm64",
46
- x64: "relay-pty-darwin-x64"
47
- },
48
- linux: {
49
- arm64: "relay-pty-linux-arm64",
50
- x64: "relay-pty-linux-x64"
51
- }
52
- };
53
- function getPlatformBinaryName() {
54
- const platform = import_node_os.default.platform();
55
- const arch = import_node_os.default.arch();
56
- return SUPPORTED_PLATFORMS[platform]?.[arch] ?? null;
57
- }
58
- function isPlatformSupported() {
59
- const platform = import_node_os.default.platform();
60
- const arch = import_node_os.default.arch();
61
- return SUPPORTED_PLATFORMS[platform]?.[arch] !== void 0;
62
- }
63
- function getSupportedPlatforms() {
64
- const platforms = [];
65
- for (const [os2, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
66
- for (const arch of Object.keys(archs)) {
67
- platforms.push(`${os2}-${arch}`);
68
- }
69
- }
70
- return platforms.join(", ");
71
- }
72
- let cachedBinaryPath;
73
- let cacheChecked = false;
74
- let lastSearchPaths = [];
75
- function getLastSearchPaths() {
76
- return [...lastSearchPaths];
77
- }
78
- function findRelayPtyBinary(callerDirname) {
79
- const envOverride = process.env.RELAY_PTY_BINARY;
80
- if (envOverride && isExecutable(envOverride) && isPlatformCompatibleBinary(envOverride)) {
81
- lastSearchPaths = [envOverride];
82
- return envOverride;
83
- }
84
- const platformBinary = getPlatformBinaryName();
85
- const normalizedCaller = callerDirname.replace(/\\/g, "/");
86
- const packageRoots = [];
87
- const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
88
- const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
89
- if (scopedMatch) {
90
- packageRoots.push(import_node_path.default.join(scopedMatch[1], "agent-relay"));
91
- }
92
- if (directMatch) {
93
- packageRoots.push(directMatch[1]);
94
- }
95
- const home = process.env.HOME || process.env.USERPROFILE || "";
96
- if (home) {
97
- const npxCacheBase = import_node_path.default.join(home, ".npm", "_npx");
98
- if (import_node_fs.default.existsSync(npxCacheBase)) {
99
- try {
100
- const entries = import_node_fs.default.readdirSync(npxCacheBase);
101
- for (const entry of entries) {
102
- const npxPackage = import_node_path.default.join(npxCacheBase, entry, "node_modules", "agent-relay");
103
- if (import_node_fs.default.existsSync(npxPackage)) {
104
- packageRoots.push(npxPackage);
105
- }
106
- }
107
- } catch {
108
- }
109
- }
110
- }
111
- packageRoots.push(import_node_path.default.join(process.cwd(), "node_modules", "agent-relay"));
112
- if (home) {
113
- packageRoots.push(
114
- import_node_path.default.join(home, ".nvm", "versions", "node", process.version, "lib", "node_modules", "agent-relay")
115
- );
116
- packageRoots.push(
117
- import_node_path.default.join(
118
- home,
119
- ".volta",
120
- "tools",
121
- "image",
122
- "packages",
123
- "agent-relay",
124
- "lib",
125
- "node_modules",
126
- "agent-relay"
127
- )
128
- );
129
- packageRoots.push(
130
- import_node_path.default.join(
131
- home,
132
- ".fnm",
133
- "node-versions",
134
- process.version,
135
- "installation",
136
- "lib",
137
- "node_modules",
138
- "agent-relay"
139
- )
140
- );
141
- packageRoots.push(import_node_path.default.join(home, "n", "lib", "node_modules", "agent-relay"));
142
- packageRoots.push(
143
- import_node_path.default.join(
144
- home,
145
- ".asdf",
146
- "installs",
147
- "nodejs",
148
- process.version.replace("v", ""),
149
- "lib",
150
- "node_modules",
151
- "agent-relay"
152
- )
153
- );
154
- packageRoots.push(import_node_path.default.join(home, ".local", "share", "pnpm", "global", "node_modules", "agent-relay"));
155
- packageRoots.push(import_node_path.default.join(home, ".config", "yarn", "global", "node_modules", "agent-relay"));
156
- packageRoots.push(import_node_path.default.join(home, ".yarn", "global", "node_modules", "agent-relay"));
157
- }
158
- const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR ? import_node_path.default.join(process.env.AGENT_RELAY_INSTALL_DIR, "bin") : home ? import_node_path.default.join(home, ".agentworkforce/relay", "bin") : null;
159
- const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? import_node_path.default.join(home, ".local", "bin") : null);
160
- const nodePrefix = import_node_path.default.resolve(import_node_path.default.dirname(process.execPath), "..");
161
- packageRoots.push(import_node_path.default.join(nodePrefix, "lib", "node_modules", "agent-relay"));
162
- packageRoots.push("/usr/local/lib/node_modules/agent-relay");
163
- packageRoots.push("/opt/homebrew/lib/node_modules/agent-relay");
164
- packageRoots.push("/usr/lib/node_modules/agent-relay");
165
- const candidates = [];
166
- for (const root of packageRoots) {
167
- if (platformBinary) {
168
- candidates.push(import_node_path.default.join(root, "bin", platformBinary));
169
- }
170
- candidates.push(import_node_path.default.join(root, "bin", "relay-pty"));
171
- }
172
- if (bashInstallerDir) {
173
- if (platformBinary) {
174
- candidates.push(import_node_path.default.join(bashInstallerDir, platformBinary));
175
- }
176
- candidates.push(import_node_path.default.join(bashInstallerDir, "relay-pty"));
177
- }
178
- if (bashInstallerBinDir) {
179
- if (platformBinary) {
180
- candidates.push(import_node_path.default.join(bashInstallerBinDir, platformBinary));
181
- }
182
- candidates.push(import_node_path.default.join(bashInstallerBinDir, "relay-pty"));
183
- }
184
- candidates.push("/app/bin/relay-pty");
185
- candidates.push("/usr/local/bin/relay-pty");
186
- candidates.push("/usr/bin/relay-pty");
187
- lastSearchPaths = candidates;
188
- for (const candidate of candidates) {
189
- if (isExecutable(candidate) && isPlatformCompatibleBinary(candidate)) {
190
- return candidate;
191
- }
192
- }
193
- return null;
194
- }
195
- function isExecutable(filePath) {
196
- try {
197
- import_node_fs.default.accessSync(filePath, import_node_fs.default.constants.X_OK);
198
- return true;
199
- } catch {
200
- return false;
201
- }
202
- }
203
- function isPlatformCompatibleBinary(filePath) {
204
- let fd;
205
- try {
206
- fd = import_node_fs.default.openSync(filePath, "r");
207
- const header = Buffer.alloc(4);
208
- const bytesRead = import_node_fs.default.readSync(fd, header, 0, 4, 0);
209
- if (bytesRead < 4) {
210
- return false;
211
- }
212
- const magic = header.readUInt32BE(0);
213
- const platform = import_node_os.default.platform();
214
- if (platform === "darwin") {
215
- return isMachOBinary(magic);
216
- }
217
- if (platform === "linux") {
218
- return magic === 2135247942;
219
- }
220
- return true;
221
- } catch {
222
- return true;
223
- } finally {
224
- if (fd !== void 0) {
225
- try {
226
- import_node_fs.default.closeSync(fd);
227
- } catch {
228
- }
229
- }
230
- }
231
- }
232
- function isMachOBinary(magic) {
233
- return magic === 3489328638 || // MH_CIGAM_64 — 64-bit, byte-swapped (arm64/x64 LE files read as BE)
234
- magic === 4277009103 || // MH_MAGIC_64 — 64-bit, native byte order
235
- magic === 3472551422 || // MH_CIGAM — 32-bit, byte-swapped
236
- magic === 4277009102 || // MH_MAGIC — 32-bit, native byte order
237
- magic === 3405691582 || // FAT_MAGIC — universal/fat binary
238
- magic === 3199925962;
239
- }
240
- function hasRelayPtyBinary(callerDirname) {
241
- if (!cacheChecked) {
242
- cachedBinaryPath = findRelayPtyBinary(callerDirname);
243
- cacheChecked = true;
244
- }
245
- return cachedBinaryPath !== null;
246
- }
247
- function getCachedRelayPtyPath() {
248
- return cachedBinaryPath;
249
- }
250
- function clearBinaryCache() {
251
- cachedBinaryPath = void 0;
252
- cacheChecked = false;
253
- }
254
- // Annotate the CommonJS export names for ESM import in node:
255
- 0 && (module.exports = {
256
- clearBinaryCache,
257
- findRelayPtyBinary,
258
- getCachedRelayPtyPath,
259
- getLastSearchPaths,
260
- getSupportedPlatforms,
261
- hasRelayPtyBinary,
262
- isPlatformSupported
263
- });
@@ -1,54 +0,0 @@
1
- /**
2
- * Shared utility for finding the relay-pty binary path.
3
- *
4
- * This is used by both:
5
- * - packages/bridge/src/spawner.ts (AgentSpawner)
6
- * - packages/wrapper/src/relay-pty-orchestrator.ts (RelayPtyOrchestrator)
7
- *
8
- * Supports all installation scenarios:
9
- * - npx agent-relay (no postinstall, uses platform-specific binary)
10
- * - npm install -g agent-relay (nvm, volta, fnm, n, asdf, Homebrew, system)
11
- * - npm install agent-relay (local project)
12
- * - pnpm/yarn global
13
- * - Docker containers
14
- */
15
- /**
16
- * Check if the current platform is supported.
17
- */
18
- export declare function isPlatformSupported(): boolean;
19
- /**
20
- * Get a human-readable description of supported platforms.
21
- */
22
- export declare function getSupportedPlatforms(): string;
23
- /**
24
- * Get the paths that were checked in the last binary search.
25
- * Useful for debugging when the binary is not found.
26
- */
27
- export declare function getLastSearchPaths(): string[];
28
- /**
29
- * Find the relay-pty binary.
30
- *
31
- * Search order prioritizes platform-specific binaries FIRST because npx doesn't run postinstall.
32
- * This ensures `npx agent-relay up` works without requiring global installation.
33
- *
34
- * @param callerDirname - The __dirname of the calling module (needed to resolve relative paths)
35
- * @returns Path to relay-pty binary, or null if not found
36
- */
37
- export declare function findRelayPtyBinary(callerDirname: string): string | null;
38
- /**
39
- * Check if relay-pty binary is available (cached).
40
- * Returns true if the binary exists, false otherwise.
41
- *
42
- * @param callerDirname - The __dirname of the calling module
43
- */
44
- export declare function hasRelayPtyBinary(callerDirname: string): boolean;
45
- /**
46
- * Get the cached relay-pty binary path.
47
- * Must call hasRelayPtyBinary() or findRelayPtyBinary() first.
48
- */
49
- export declare function getCachedRelayPtyPath(): string | null | undefined;
50
- /**
51
- * Clear the cached binary path (for testing).
52
- */
53
- export declare function clearBinaryCache(): void;
54
- //# sourceMappingURL=relay-pty-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relay-pty-path.d.ts","sourceRoot":"","sources":["../src/relay-pty-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgCH;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAI7C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAQ9C;AASD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6LvE;AAwED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAMhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,CAEjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
@@ -1,301 +0,0 @@
1
- /**
2
- * Shared utility for finding the relay-pty binary path.
3
- *
4
- * This is used by both:
5
- * - packages/bridge/src/spawner.ts (AgentSpawner)
6
- * - packages/wrapper/src/relay-pty-orchestrator.ts (RelayPtyOrchestrator)
7
- *
8
- * Supports all installation scenarios:
9
- * - npx agent-relay (no postinstall, uses platform-specific binary)
10
- * - npm install -g agent-relay (nvm, volta, fnm, n, asdf, Homebrew, system)
11
- * - npm install agent-relay (local project)
12
- * - pnpm/yarn global
13
- * - Docker containers
14
- */
15
- import fs from 'node:fs';
16
- import os from 'node:os';
17
- import path from 'node:path';
18
- /**
19
- * Supported platforms and their binary names.
20
- * Windows is not supported (relay-pty requires PTY which doesn't work on Windows).
21
- */
22
- const SUPPORTED_PLATFORMS = {
23
- darwin: {
24
- arm64: 'relay-pty-darwin-arm64',
25
- x64: 'relay-pty-darwin-x64',
26
- },
27
- linux: {
28
- arm64: 'relay-pty-linux-arm64',
29
- x64: 'relay-pty-linux-x64',
30
- },
31
- };
32
- /**
33
- * Get the platform-specific binary name for the current system.
34
- * Returns null if the platform is not supported.
35
- */
36
- function getPlatformBinaryName() {
37
- const platform = os.platform();
38
- const arch = os.arch();
39
- return SUPPORTED_PLATFORMS[platform]?.[arch] ?? null;
40
- }
41
- /**
42
- * Check if the current platform is supported.
43
- */
44
- export function isPlatformSupported() {
45
- const platform = os.platform();
46
- const arch = os.arch();
47
- return SUPPORTED_PLATFORMS[platform]?.[arch] !== undefined;
48
- }
49
- /**
50
- * Get a human-readable description of supported platforms.
51
- */
52
- export function getSupportedPlatforms() {
53
- const platforms = [];
54
- for (const [os, archs] of Object.entries(SUPPORTED_PLATFORMS)) {
55
- for (const arch of Object.keys(archs)) {
56
- platforms.push(`${os}-${arch}`);
57
- }
58
- }
59
- return platforms.join(', ');
60
- }
61
- /** Cached result of relay-pty binary check */
62
- let cachedBinaryPath;
63
- let cacheChecked = false;
64
- /** Store the last search results for debugging */
65
- let lastSearchPaths = [];
66
- /**
67
- * Get the paths that were checked in the last binary search.
68
- * Useful for debugging when the binary is not found.
69
- */
70
- export function getLastSearchPaths() {
71
- return [...lastSearchPaths];
72
- }
73
- /**
74
- * Find the relay-pty binary.
75
- *
76
- * Search order prioritizes platform-specific binaries FIRST because npx doesn't run postinstall.
77
- * This ensures `npx agent-relay up` works without requiring global installation.
78
- *
79
- * @param callerDirname - The __dirname of the calling module (needed to resolve relative paths)
80
- * @returns Path to relay-pty binary, or null if not found
81
- */
82
- export function findRelayPtyBinary(callerDirname) {
83
- // Check for explicit environment variable override first
84
- const envOverride = process.env.RELAY_PTY_BINARY;
85
- if (envOverride && isExecutable(envOverride) && isPlatformCompatibleBinary(envOverride)) {
86
- lastSearchPaths = [envOverride];
87
- return envOverride;
88
- }
89
- // Get platform-specific binary name (critical for npx where postinstall doesn't run)
90
- const platformBinary = getPlatformBinaryName();
91
- // Normalize path separators for cross-platform regex matching
92
- const normalizedCaller = callerDirname.replace(/\\/g, '/');
93
- // Collect all possible package root locations
94
- const packageRoots = [];
95
- // Find node_modules root from caller path
96
- // Matches: /path/to/node_modules/@agent-relay/sdk/dist/
97
- // Or: /path/to/node_modules/agent-relay/dist/src/cli/
98
- const scopedMatch = normalizedCaller.match(/^(.+?\/node_modules)\/@agent-relay\//);
99
- const directMatch = normalizedCaller.match(/^(.+?\/node_modules\/agent-relay)/);
100
- if (scopedMatch) {
101
- // Running from @agent-relay/* package - binary is in sibling agent-relay package
102
- packageRoots.push(path.join(scopedMatch[1], 'agent-relay'));
103
- }
104
- if (directMatch) {
105
- // Running from agent-relay package directly
106
- packageRoots.push(directMatch[1]);
107
- }
108
- const home = process.env.HOME || process.env.USERPROFILE || '';
109
- // npx cache locations - npm stores packages here when running via npx
110
- if (home) {
111
- const npxCacheBase = path.join(home, '.npm', '_npx');
112
- if (fs.existsSync(npxCacheBase)) {
113
- try {
114
- const entries = fs.readdirSync(npxCacheBase);
115
- for (const entry of entries) {
116
- const npxPackage = path.join(npxCacheBase, entry, 'node_modules', 'agent-relay');
117
- if (fs.existsSync(npxPackage)) {
118
- packageRoots.push(npxPackage);
119
- }
120
- }
121
- }
122
- catch {
123
- // Ignore read errors
124
- }
125
- }
126
- }
127
- // Add cwd-based paths for local installs
128
- packageRoots.push(path.join(process.cwd(), 'node_modules', 'agent-relay'));
129
- // Global install locations - support ALL major Node version managers
130
- if (home) {
131
- // nvm (most common)
132
- packageRoots.push(path.join(home, '.nvm', 'versions', 'node', process.version, 'lib', 'node_modules', 'agent-relay'));
133
- // volta (increasingly popular)
134
- packageRoots.push(path.join(home, '.volta', 'tools', 'image', 'packages', 'agent-relay', 'lib', 'node_modules', 'agent-relay'));
135
- // fnm (fast Node manager)
136
- packageRoots.push(path.join(home, '.fnm', 'node-versions', process.version, 'installation', 'lib', 'node_modules', 'agent-relay'));
137
- // n (simple Node version manager)
138
- packageRoots.push(path.join(home, 'n', 'lib', 'node_modules', 'agent-relay'));
139
- // asdf (universal version manager)
140
- packageRoots.push(path.join(home, '.asdf', 'installs', 'nodejs', process.version.replace('v', ''), 'lib', 'node_modules', 'agent-relay'));
141
- // pnpm global
142
- packageRoots.push(path.join(home, '.local', 'share', 'pnpm', 'global', 'node_modules', 'agent-relay'));
143
- // yarn global (yarn 1.x)
144
- packageRoots.push(path.join(home, '.config', 'yarn', 'global', 'node_modules', 'agent-relay'));
145
- // yarn global (alternative location)
146
- packageRoots.push(path.join(home, '.yarn', 'global', 'node_modules', 'agent-relay'));
147
- }
148
- // Bash installer locations (curl | bash install method)
149
- // install.sh puts relay-pty at $INSTALL_DIR/bin/ (default: ~/.agentworkforce/relay/bin/)
150
- const bashInstallerDir = process.env.AGENT_RELAY_INSTALL_DIR
151
- ? path.join(process.env.AGENT_RELAY_INSTALL_DIR, 'bin')
152
- : home
153
- ? path.join(home, '.agentworkforce/relay', 'bin')
154
- : null;
155
- const bashInstallerBinDir = process.env.AGENT_RELAY_BIN_DIR || (home ? path.join(home, '.local', 'bin') : null);
156
- // Universal: derive global node_modules from Node's own executable path.
157
- // This covers ALL Node installations regardless of version manager
158
- // (nvm, volta, fnm, mise, asdf, n, system, Homebrew, direct download, etc.)
159
- // Node binary is at <prefix>/bin/node, global modules at <prefix>/lib/node_modules/
160
- const nodePrefix = path.resolve(path.dirname(process.execPath), '..');
161
- packageRoots.push(path.join(nodePrefix, 'lib', 'node_modules', 'agent-relay'));
162
- // Homebrew npm (macOS)
163
- packageRoots.push('/usr/local/lib/node_modules/agent-relay');
164
- packageRoots.push('/opt/homebrew/lib/node_modules/agent-relay');
165
- // Linux system-wide npm
166
- packageRoots.push('/usr/lib/node_modules/agent-relay');
167
- // Build candidates list - PRIORITIZE platform-specific binaries
168
- // This is critical for npx since postinstall doesn't run
169
- const candidates = [];
170
- for (const root of packageRoots) {
171
- // Platform-specific binary FIRST (works without postinstall)
172
- if (platformBinary) {
173
- candidates.push(path.join(root, 'bin', platformBinary));
174
- }
175
- // Generic binary (requires postinstall to have run)
176
- candidates.push(path.join(root, 'bin', 'relay-pty'));
177
- }
178
- // Bash installer paths (curl | bash install method)
179
- // install.sh downloads relay-pty to ~/.agentworkforce/relay/bin/relay-pty
180
- if (bashInstallerDir) {
181
- if (platformBinary) {
182
- candidates.push(path.join(bashInstallerDir, platformBinary));
183
- }
184
- candidates.push(path.join(bashInstallerDir, 'relay-pty'));
185
- }
186
- // install.sh also uses ~/.local/bin as the BIN_DIR
187
- if (bashInstallerBinDir) {
188
- if (platformBinary) {
189
- candidates.push(path.join(bashInstallerBinDir, platformBinary));
190
- }
191
- candidates.push(path.join(bashInstallerBinDir, 'relay-pty'));
192
- }
193
- // Docker container (CI tests)
194
- candidates.push('/app/bin/relay-pty');
195
- // System-wide installs
196
- candidates.push('/usr/local/bin/relay-pty');
197
- candidates.push('/usr/bin/relay-pty');
198
- // Store search paths for debugging
199
- lastSearchPaths = candidates;
200
- for (const candidate of candidates) {
201
- if (isExecutable(candidate) && isPlatformCompatibleBinary(candidate)) {
202
- return candidate;
203
- }
204
- }
205
- return null;
206
- }
207
- /**
208
- * Check if a file exists and is executable.
209
- */
210
- function isExecutable(filePath) {
211
- try {
212
- fs.accessSync(filePath, fs.constants.X_OK);
213
- return true;
214
- }
215
- catch {
216
- // File doesn't exist or isn't executable
217
- return false;
218
- }
219
- }
220
- /**
221
- * Check if a binary is compatible with the current platform by reading its magic bytes.
222
- * Prevents using a macOS binary on Linux or vice versa, which would fail at runtime
223
- * with cryptic errors like "Syntax error: word unexpected".
224
- */
225
- function isPlatformCompatibleBinary(filePath) {
226
- let fd;
227
- try {
228
- fd = fs.openSync(filePath, 'r');
229
- const header = Buffer.alloc(4);
230
- const bytesRead = fs.readSync(fd, header, 0, 4, 0);
231
- if (bytesRead < 4) {
232
- return false; // Too small to be a valid binary
233
- }
234
- const magic = header.readUInt32BE(0);
235
- const platform = os.platform();
236
- if (platform === 'darwin') {
237
- return isMachOBinary(magic);
238
- }
239
- if (platform === 'linux') {
240
- // ELF magic: 0x7f 'E' 'L' 'F'
241
- return magic === 0x7f454c46;
242
- }
243
- // Unknown platform — don't block
244
- return true;
245
- }
246
- catch {
247
- // Can't read file (e.g. execute-only permissions) — let execution attempt proceed
248
- return true;
249
- }
250
- finally {
251
- if (fd !== undefined) {
252
- try {
253
- fs.closeSync(fd);
254
- }
255
- catch {
256
- /* ignore close errors */
257
- }
258
- }
259
- }
260
- }
261
- /**
262
- * Check if a magic value corresponds to any valid Mach-O format.
263
- * Handles all variants: 32/64-bit, native/byte-swapped, and fat/universal.
264
- */
265
- function isMachOBinary(magic) {
266
- return (magic === 0xcffaedfe || // MH_CIGAM_64 — 64-bit, byte-swapped (arm64/x64 LE files read as BE)
267
- magic === 0xfeedfacf || // MH_MAGIC_64 — 64-bit, native byte order
268
- magic === 0xcefaedfe || // MH_CIGAM — 32-bit, byte-swapped
269
- magic === 0xfeedface || // MH_MAGIC — 32-bit, native byte order
270
- magic === 0xcafebabe || // FAT_MAGIC — universal/fat binary
271
- magic === 0xbebafeca // FAT_CIGAM — universal/fat binary, byte-swapped
272
- );
273
- }
274
- /**
275
- * Check if relay-pty binary is available (cached).
276
- * Returns true if the binary exists, false otherwise.
277
- *
278
- * @param callerDirname - The __dirname of the calling module
279
- */
280
- export function hasRelayPtyBinary(callerDirname) {
281
- if (!cacheChecked) {
282
- cachedBinaryPath = findRelayPtyBinary(callerDirname);
283
- cacheChecked = true;
284
- }
285
- return cachedBinaryPath !== null;
286
- }
287
- /**
288
- * Get the cached relay-pty binary path.
289
- * Must call hasRelayPtyBinary() or findRelayPtyBinary() first.
290
- */
291
- export function getCachedRelayPtyPath() {
292
- return cachedBinaryPath;
293
- }
294
- /**
295
- * Clear the cached binary path (for testing).
296
- */
297
- export function clearBinaryCache() {
298
- cachedBinaryPath = undefined;
299
- cacheChecked = false;
300
- }
301
- //# sourceMappingURL=relay-pty-path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"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