@agent-relay/harness-driver 14.0.0 → 15.0.0-next.1

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.
@@ -5,19 +5,62 @@
5
5
  * import { getBrokerBinaryPath } from '@agent-relay/harness-driver/broker-path';
6
6
  * const binPath = getBrokerBinaryPath();
7
7
  */
8
+ /**
9
+ * npm package name of the platform broker, e.g. `@agent-relay/broker-linux-x64`.
10
+ * @param platform - Target platform
11
+ * @param arch - Target architecture
12
+ * @returns The optional-dependency package name
13
+ */
8
14
  export declare function getOptionalDepPackageName(platform?: NodeJS.Platform, arch?: string): string;
15
+ /** Where {@link resolveBrokerBinary} found the broker. */
16
+ export type BrokerBinarySource = 'env' | 'source-checkout' | 'canonical' | 'standalone' | 'npm-optional-dependency' | 'cargo-dev' | 'path' | 'legacy-install';
17
+ /** A resolved broker binary and where it was found. */
18
+ export interface ResolvedBrokerBinary {
19
+ path: string;
20
+ source: BrokerBinarySource;
21
+ }
22
+ export interface OptionalDepBrokerPathOptions {
23
+ /**
24
+ * Also resolve through `<cwd>/package.json` (default true). The CLI passes
25
+ * false when choosing a broker to copy into the shared bin directory, so a
26
+ * project's own (possibly different) broker version never lands there.
27
+ */
28
+ includeCwd?: boolean;
29
+ }
30
+ /**
31
+ * The broker shipped by the npm optional dependency
32
+ * `@agent-relay/broker-<platform>-<arch>`, or null when it is not installed.
33
+ * Exposed so the CLI can copy it into the canonical bin directory.
34
+ * @param options - Resolution options
35
+ * @returns Absolute path to the npm broker, or null
36
+ */
37
+ export declare function getOptionalDepBrokerPath(options?: OptionalDepBrokerPathOptions): string | null;
9
38
  /**
10
- * Resolve the agent-relay-broker binary path.
39
+ * Resolve the agent-relay-broker binary and report where it came from.
11
40
  *
12
- * Search order:
13
- * 1. Explicit env override (BROKER_BINARY_PATH / AGENT_RELAY_BIN)
14
- * 2. Local Cargo build when the runtime is loaded from an agent-relay source
15
- * checkout
16
- * 3. Platform-specific optional-dep package
17
- * (`@agent-relay/broker-<platform>-<arch>`) — primary production path
18
- * 4. Cargo development paths (target/release and target/debug)
19
- * 5. PATH lookup via `which` / `where`
20
- * 6. Relay installer locations (launcher/executable sibling and user bin)
41
+ * Search order (first existing file wins):
42
+ * 1. Explicit env override: BROKER_BINARY_PATH, then AGENT_RELAY_BIN.
43
+ * 2. Development only: the Cargo build of an agent-relay source checkout
44
+ * when this runtime is loaded from (or run inside) that checkout.
45
+ * 3. Canonical install: `<install root>/bin/agent-relay-broker[.exe]`, where
46
+ * the install root is AGENT_RELAY_INSTALL_DIR, else AGENT_RELAY_HOME,
47
+ * else ~/.agentworkforce/relay. install.sh, the desktop app and the npm
48
+ * CLI (on first run) all put the broker here. A standalone CLI's own bin
49
+ * directory counts as its canonical install.
50
+ * 4. Legacy npm fallback: the platform optional-dependency package
51
+ * `@agent-relay/broker-<platform>-<arch>`.
52
+ * 5. Cargo development paths (target/release, target/debug).
53
+ * 6. PATH lookup via `which` / `where`.
54
+ * 7. Older installer locations (launcher sibling, ~/.agent-relay/bin,
55
+ * ~/.local/bin), for version managers that launch Node with a minimal
56
+ * PATH.
57
+ *
58
+ * @returns The resolved broker and its source, or null if none was found
59
+ */
60
+ export declare function resolveBrokerBinary(): ResolvedBrokerBinary | null;
61
+ /**
62
+ * Resolve the agent-relay-broker binary path. See {@link resolveBrokerBinary}
63
+ * for the search order.
21
64
  *
22
65
  * @returns Absolute path to the broker binary, or null if not found
23
66
  */
@@ -1 +1 @@
1
- {"version":3,"file":"broker-path.d.ts","sourceRoot":"","sources":["../src/broker-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,IAAI,GAAE,MAAqB,GAC1B,MAAM,CAER;AA2MD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAuDnD;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CASlD"}
1
+ {"version":3,"file":"broker-path.d.ts","sourceRoot":"","sources":["../src/broker-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,IAAI,GAAE,MAAqB,GAC1B,MAAM,CAER;AA4MD,0DAA0D;AAC1D,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GACL,iBAAiB,GACjB,WAAW,GACX,YAAY,GACZ,yBAAyB,GACzB,WAAW,GACX,MAAM,GACN,gBAAgB,CAAC;AAErB,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAoCD,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,4BAAiC,GAAG,MAAM,GAAG,IAAI,CAElG;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,IAAI,oBAAoB,GAAG,IAAI,CAqDjE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CASlD"}
@@ -6,12 +6,18 @@
6
6
  * const binPath = getBrokerBinaryPath();
7
7
  */
8
8
  import { existsSync, realpathSync } from 'node:fs';
9
- import { join, dirname, resolve } from 'node:path';
10
- import { execFileSync } from 'node:child_process';
9
+ import { basename, join, dirname, resolve } from 'node:path';
11
10
  import { createRequire } from 'node:module';
12
11
  import { homedir } from 'node:os';
13
12
  import { fileURLToPath } from 'node:url';
14
- const BROKER_NAME = 'agent-relay-broker';
13
+ import { BROKER_BINARY_NAME, findExecutableOnPath, getCanonicalBrokerPath, getRelayBinDir, isUsableBinary, } from './install-paths.js';
14
+ const BROKER_NAME = BROKER_BINARY_NAME;
15
+ /**
16
+ * npm package name of the platform broker, e.g. `@agent-relay/broker-linux-x64`.
17
+ * @param platform - Target platform
18
+ * @param arch - Target architecture
19
+ * @returns The optional-dependency package name
20
+ */
15
21
  export function getOptionalDepPackageName(platform = process.platform, arch = process.arch) {
16
22
  return `@agent-relay/broker-${platform}-${arch}`;
17
23
  }
@@ -71,7 +77,7 @@ function getCurrentModuleReference() {
71
77
  }
72
78
  return getImportMetaUrl();
73
79
  }
74
- function getResolutionReferences() {
80
+ function getResolutionReferences(includeCwd = true) {
75
81
  const refs = [];
76
82
  addResolutionReference(refs, getCurrentModuleReference());
77
83
  // Also try the entry script so CLI consumers and bundled installs
@@ -90,11 +96,13 @@ function getResolutionReferences() {
90
96
  // some vite/webpack bundling configurations, repl experimentation), but
91
97
  // the consumer's cwd is inside their own project. We only use this
92
98
  // reference to run require.resolve; no file I/O is triggered on misses.
93
- addResolutionReference(refs, join(process.cwd(), 'package.json'));
99
+ if (includeCwd) {
100
+ addResolutionReference(refs, join(process.cwd(), 'package.json'));
101
+ }
94
102
  return refs;
95
103
  }
96
104
  /**
97
- * Binary locations created by Relay's standalone/npm installer. These are
105
+ * Binary locations created by older Relay installers. These are
98
106
  * deliberately checked without shelling out: a version manager can launch
99
107
  * Node with a minimal PATH, which is exactly when `which` cannot see the
100
108
  * broker that the Relay installer placed beside its launcher or under the
@@ -114,7 +122,6 @@ function getInstalledBinaryPaths(ext) {
114
122
  addSiblingBinaryPaths(process.execPath);
115
123
  const userHome = homedir();
116
124
  if (userHome) {
117
- addUniquePath(binaryPaths, join(userHome, '.agentworkforce', 'relay', 'bin', binaryFile));
118
125
  addUniquePath(binaryPaths, join(userHome, '.agent-relay', 'bin', binaryFile));
119
126
  addUniquePath(binaryPaths, join(userHome, '.local', 'bin', binaryFile));
120
127
  }
@@ -127,10 +134,10 @@ function getInstalledBinaryPaths(ext) {
127
134
  * --no-optional / --omit=optional / --include= omits optional, or when the
128
135
  * broker hasn't been published for their platform yet).
129
136
  */
130
- function getOptionalDepBinaryPath(ext) {
137
+ function getOptionalDepBinaryPath(ext, includeCwd = true) {
131
138
  const pkgName = getOptionalDepPackageName();
132
139
  const binaryFile = `${BROKER_NAME}${ext}`;
133
- for (const ref of getResolutionReferences()) {
140
+ for (const ref of getResolutionReferences(includeCwd)) {
134
141
  try {
135
142
  const pkgJsonPath = createRequire(ref).resolve(`${pkgName}/package.json`);
136
143
  const binPath = join(dirname(pkgJsonPath), 'bin', binaryFile);
@@ -189,70 +196,125 @@ function getSourceCheckoutBinaryPaths(ext) {
189
196
  return getDevelopmentBinaryPaths(ext).filter((binaryPath) => isSourceCheckoutRoot(resolve(dirname(binaryPath), '..', '..')));
190
197
  }
191
198
  /**
192
- * Resolve the agent-relay-broker binary path.
199
+ * Directory of a running standalone (Bun-compiled) CLI. install.sh puts the
200
+ * standalone CLI and the broker side by side in the install's bin directory,
201
+ * so when the install root was relocated without exporting
202
+ * AGENT_RELAY_INSTALL_DIR at runtime, the executable's own directory is still
203
+ * that install's bin directory.
204
+ */
205
+ function getStandaloneCliBinDir() {
206
+ const exe = basename(process.execPath).toLowerCase();
207
+ if (exe !== 'agent-relay' && exe !== 'agent-relay.exe')
208
+ return null;
209
+ return dirname(resolve(process.execPath));
210
+ }
211
+ /**
212
+ * Step 3 of {@link resolveBrokerBinary}: the canonical bin dir, then a
213
+ * standalone CLI's own bin dir. A file there that is empty, not a regular
214
+ * file or not executable is skipped, so a damaged shared install cannot hide
215
+ * a working npm broker from SDK callers that never run the CLI's repair step.
216
+ */
217
+ function findCanonicalBroker(ext) {
218
+ const canonical = getCanonicalBrokerPath();
219
+ if (existsSync(canonical) && isUsableBinary(canonical)) {
220
+ return { path: canonical, source: 'canonical' };
221
+ }
222
+ const standaloneBinDir = getStandaloneCliBinDir();
223
+ if (standaloneBinDir) {
224
+ const standaloneBroker = join(standaloneBinDir, `${BROKER_NAME}${ext}`);
225
+ if (existsSync(standaloneBroker) && isUsableBinary(standaloneBroker)) {
226
+ return { path: standaloneBroker, source: 'standalone' };
227
+ }
228
+ }
229
+ return null;
230
+ }
231
+ /**
232
+ * The broker shipped by the npm optional dependency
233
+ * `@agent-relay/broker-<platform>-<arch>`, or null when it is not installed.
234
+ * Exposed so the CLI can copy it into the canonical bin directory.
235
+ * @param options - Resolution options
236
+ * @returns Absolute path to the npm broker, or null
237
+ */
238
+ export function getOptionalDepBrokerPath(options = {}) {
239
+ return getOptionalDepBinaryPath(process.platform === 'win32' ? '.exe' : '', options.includeCwd ?? true);
240
+ }
241
+ /**
242
+ * Resolve the agent-relay-broker binary and report where it came from.
193
243
  *
194
- * Search order:
195
- * 1. Explicit env override (BROKER_BINARY_PATH / AGENT_RELAY_BIN)
196
- * 2. Local Cargo build when the runtime is loaded from an agent-relay source
197
- * checkout
198
- * 3. Platform-specific optional-dep package
199
- * (`@agent-relay/broker-<platform>-<arch>`) — primary production path
200
- * 4. Cargo development paths (target/release and target/debug)
201
- * 5. PATH lookup via `which` / `where`
202
- * 6. Relay installer locations (launcher/executable sibling and user bin)
244
+ * Search order (first existing file wins):
245
+ * 1. Explicit env override: BROKER_BINARY_PATH, then AGENT_RELAY_BIN.
246
+ * 2. Development only: the Cargo build of an agent-relay source checkout
247
+ * when this runtime is loaded from (or run inside) that checkout.
248
+ * 3. Canonical install: `<install root>/bin/agent-relay-broker[.exe]`, where
249
+ * the install root is AGENT_RELAY_INSTALL_DIR, else AGENT_RELAY_HOME,
250
+ * else ~/.agentworkforce/relay. install.sh, the desktop app and the npm
251
+ * CLI (on first run) all put the broker here. A standalone CLI's own bin
252
+ * directory counts as its canonical install.
253
+ * 4. Legacy npm fallback: the platform optional-dependency package
254
+ * `@agent-relay/broker-<platform>-<arch>`.
255
+ * 5. Cargo development paths (target/release, target/debug).
256
+ * 6. PATH lookup via `which` / `where`.
257
+ * 7. Older installer locations (launcher sibling, ~/.agent-relay/bin,
258
+ * ~/.local/bin), for version managers that launch Node with a minimal
259
+ * PATH.
203
260
  *
204
- * @returns Absolute path to the broker binary, or null if not found
261
+ * @returns The resolved broker and its source, or null if none was found
205
262
  */
206
- export function getBrokerBinaryPath() {
263
+ export function resolveBrokerBinary() {
207
264
  const ext = process.platform === 'win32' ? '.exe' : '';
208
265
  const override = process.env.BROKER_BINARY_PATH ?? process.env.AGENT_RELAY_BIN;
266
+ // 1. Explicit override.
209
267
  if (override) {
210
268
  const resolvedOverride = resolve(override);
211
269
  if (existsSync(resolvedOverride)) {
212
- return resolvedOverride;
270
+ return { path: resolvedOverride, source: 'env' };
213
271
  }
214
272
  }
215
- // 1. Prefer a local Cargo build when this runtime is being used from a source checkout.
273
+ // 2. A local Cargo build when this runtime is being used from a source checkout.
216
274
  for (const developmentPath of getSourceCheckoutBinaryPaths(ext)) {
217
275
  if (existsSync(developmentPath)) {
218
- return developmentPath;
276
+ return { path: developmentPath, source: 'source-checkout' };
219
277
  }
220
278
  }
221
- // 2. Platform-specific optional-dep package — the primary production path.
279
+ // 3. The canonical install location shared by every install method.
280
+ const installed = findCanonicalBroker(ext);
281
+ if (installed) {
282
+ return installed;
283
+ }
284
+ // 4. Legacy: the platform-specific npm optional dependency.
222
285
  const optionalDepBinary = getOptionalDepBinaryPath(ext);
223
286
  if (optionalDepBinary) {
224
- return optionalDepBinary;
287
+ return { path: optionalDepBinary, source: 'npm-optional-dependency' };
225
288
  }
226
- // 3. Common development paths for local Cargo builds.
289
+ // 5. Common development paths for local Cargo builds.
227
290
  for (const developmentPath of getDevelopmentBinaryPaths(ext)) {
228
291
  if (existsSync(developmentPath)) {
229
- return developmentPath;
292
+ return { path: developmentPath, source: 'cargo-dev' };
230
293
  }
231
294
  }
232
- // 4. PATH lookup. Prefer the operator's active PATH over fixed user install
233
- // directories, which can contain stale brokers from an older Relay install.
234
- try {
235
- const cmd = process.platform === 'win32' ? 'where' : 'which';
236
- const result = execFileSync(cmd, [BROKER_NAME], {
237
- encoding: 'utf-8',
238
- stdio: ['pipe', 'pipe', 'pipe'],
239
- }).trim();
240
- if (result) {
241
- return result.split(/\r?\n/u)[0].trim();
242
- }
295
+ // 6. PATH lookup.
296
+ const onPath = findExecutableOnPath(BROKER_NAME);
297
+ if (onPath) {
298
+ return { path: onPath, source: 'path' };
243
299
  }
244
- catch {
245
- // Not found on PATH
246
- }
247
- // 5. Relay's npm/standalone installer locations. This also covers mise and
248
- // similar version managers when their activation PATH omits the user bin.
300
+ // 7. Older installer locations. This also covers mise and similar version
301
+ // managers when their activation PATH omits the user bin.
249
302
  for (const installedPath of getInstalledBinaryPaths(ext)) {
250
303
  if (existsSync(installedPath)) {
251
- return installedPath;
304
+ return { path: installedPath, source: 'legacy-install' };
252
305
  }
253
306
  }
254
307
  return null;
255
308
  }
309
+ /**
310
+ * Resolve the agent-relay-broker binary path. See {@link resolveBrokerBinary}
311
+ * for the search order.
312
+ *
313
+ * @returns Absolute path to the broker binary, or null if not found
314
+ */
315
+ export function getBrokerBinaryPath() {
316
+ return resolveBrokerBinary()?.path ?? null;
317
+ }
256
318
  /**
257
319
  * Human-readable error message explaining that the optional-dep broker
258
320
  * package for the current platform/arch isn't installed. Used by the SDK
@@ -262,9 +324,9 @@ export function getBrokerBinaryPath() {
262
324
  export function formatBrokerNotFoundError() {
263
325
  const pkgName = getOptionalDepPackageName();
264
326
  return (`@agent-relay/harness-driver couldn't find an agent-relay-broker binary for ` +
265
- `${process.platform}-${process.arch}. The optional dependency ` +
266
- `${pkgName} is expected to be installed alongside @agent-relay/harness-driver. ` +
267
- `Try reinstalling with --include=optional, or set BROKER_BINARY_PATH ` +
268
- `to point at a broker binary you've downloaded manually.`);
327
+ `${process.platform}-${process.arch}. Expected it at ${join(getRelayBinDir(), `${BROKER_NAME}${process.platform === 'win32' ? '.exe' : ''}`)} ` +
328
+ `(install with: curl -fsSL https://raw.githubusercontent.com/AgentWorkforce/relay/main/install.sh | bash) ` +
329
+ `or in the optional dependency ${pkgName} (reinstall with --include=optional). ` +
330
+ `Or set BROKER_BINARY_PATH to point at a broker binary you've downloaded manually.`);
269
331
  }
270
332
  //# sourceMappingURL=broker-path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"broker-path.js","sourceRoot":"","sources":["../src/broker-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAEzC,MAAM,UAAU,yBAAyB,CACvC,WAA4B,OAAO,CAAC,QAAQ,EAC5C,OAAe,OAAO,CAAC,IAAI;IAE3B,OAAO,uBAAuB,QAAQ,IAAI,IAAI,EAAE,CAAC;AACnD,CAAC;AAED,SAAS,aAAa,CAAC,KAAe,EAAE,SAAoC;IAC1E,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,OAAO;IACT,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAc,EAAE,SAAoC;IAClF,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,aAAa,CAAC,IAAI,EAA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AAoB,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,WAAW,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG;QAC/I,2GAA2G;QAC3G,iCAAiC,OAAO,wCAAwC;QAChF,mFAAmF,CACpF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -9,4 +9,6 @@ export * from './transport.js';
9
9
  export * from './broker-path.js';
10
10
  export * from './harness.js';
11
11
  export * from './predictive-echo.js';
12
+ export * from './install-paths.js';
13
+ export { ensureCanonicalBroker, SKIP_BROKER_INSTALL_ENV, type EnsureCanonicalBrokerOptions, type EnsureCanonicalBrokerResult, type EnsureCanonicalBrokerSkipReason, } from './broker-install.js';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,GACrC,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -9,4 +9,6 @@ export * from './transport.js';
9
9
  export * from './broker-path.js';
10
10
  export * from './harness.js';
11
11
  export * from './predictive-echo.js';
12
+ export * from './install-paths.js';
13
+ export { ensureCanonicalBroker, SKIP_BROKER_INSTALL_ENV, } from './broker-install.js';
12
14
  //# 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,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAIxB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The single, canonical location of every Agent Relay native binary.
3
+ *
4
+ * However Agent Relay is installed (`install.sh`, `npm i -g agent-relay`, the
5
+ * desktop app), its binaries converge on one directory so the CLI, the broker
6
+ * it launches and the desktop app always run the same executables:
7
+ *
8
+ * $AGENT_RELAY_INSTALL_DIR/bin when AGENT_RELAY_INSTALL_DIR is set
9
+ * $AGENT_RELAY_HOME/bin otherwise, when AGENT_RELAY_HOME is set
10
+ * ~/.agentworkforce/relay/bin by default
11
+ *
12
+ * Reserved binary slots in that directory (`.exe` suffix on Windows):
13
+ *
14
+ * agent-relay standalone CLI (written by install.sh)
15
+ * agent-relay-broker Rust broker (install.sh, desktop app, or copied from
16
+ * the npm optional dependency on first CLI run)
17
+ * relaycast-engine local Relaycast server (install.sh, when published)
18
+ *
19
+ * `install.sh` resolves the same directory, so the shell installer and the
20
+ * runtime resolvers cannot disagree about where binaries live.
21
+ */
22
+ export declare const BROKER_BINARY_NAME = "agent-relay-broker";
23
+ export declare const RELAYCAST_ENGINE_BINARY_NAME = "relaycast-engine";
24
+ /** Environment variable that relocates the whole install root. */
25
+ export declare const RELAY_INSTALL_DIR_ENV = "AGENT_RELAY_INSTALL_DIR";
26
+ /** Relay home (credentials, state). Its `bin/` is used when no install dir is set. */
27
+ export declare const RELAY_HOME_ENV = "AGENT_RELAY_HOME";
28
+ /** Explicit path to a relaycast-engine binary, checked before the canonical slot. */
29
+ export declare const RELAYCAST_ENGINE_PATH_ENV = "RELAYCAST_ENGINE_PATH";
30
+ type Env = Record<string, string | undefined>;
31
+ /**
32
+ * Executable file name for `name` on `platform` (`.exe` on Windows).
33
+ * @param name - Binary base name, e.g. `agent-relay-broker`
34
+ * @param platform - Target platform (defaults to the current one)
35
+ * @returns The file name to look for on disk
36
+ */
37
+ export declare function executableFileName(name: string, platform?: NodeJS.Platform): string;
38
+ /**
39
+ * Root of the Agent Relay install (`AGENT_RELAY_INSTALL_DIR` →
40
+ * `AGENT_RELAY_HOME` → `~/.agentworkforce/relay`).
41
+ * @param env - Environment to read overrides from
42
+ * @param home - Home directory used for the default
43
+ * @returns Absolute install root
44
+ */
45
+ export declare function getRelayInstallDir(env?: Env, home?: string): string;
46
+ /**
47
+ * The canonical binary directory: `<install root>/bin`.
48
+ * @param env - Environment to read overrides from
49
+ * @param home - Home directory used for the default
50
+ * @returns Absolute path of the canonical bin directory
51
+ */
52
+ export declare function getRelayBinDir(env?: Env, home?: string): string;
53
+ /**
54
+ * Canonical path of the broker binary (may not exist).
55
+ * @param env - Environment to read overrides from
56
+ * @param platform - Target platform
57
+ * @returns `<bin>/agent-relay-broker[.exe]`
58
+ */
59
+ export declare function getCanonicalBrokerPath(env?: Env, platform?: NodeJS.Platform): string;
60
+ /**
61
+ * Canonical path of the local Relaycast server binary (may not exist).
62
+ * @param env - Environment to read overrides from
63
+ * @param platform - Target platform
64
+ * @returns `<bin>/relaycast-engine[.exe]`
65
+ */
66
+ export declare function getCanonicalRelaycastEnginePath(env?: Env, platform?: NodeJS.Platform): string;
67
+ /**
68
+ * Whether `filePath` looks runnable: a non-empty regular file that is
69
+ * executable (the execute bit is not checked on Windows). Cheap enough for
70
+ * every resolve; it does not execute the file.
71
+ * @param filePath - Candidate binary
72
+ * @returns true when the file can plausibly be launched
73
+ */
74
+ export declare function isUsableBinary(filePath: string): boolean;
75
+ /**
76
+ * First match for `name` on PATH (`which` / `where`), or null.
77
+ * @param name - Command name to look up
78
+ * @returns Absolute path, or null when the command is not on PATH
79
+ */
80
+ export declare function findExecutableOnPath(name: string): string | null;
81
+ /**
82
+ * Resolve the local Relaycast server binary.
83
+ *
84
+ * Search order:
85
+ * 1. `RELAYCAST_ENGINE_PATH` (explicit override; must exist)
86
+ * 2. Canonical slot `<bin>/relaycast-engine[.exe]`
87
+ * 3. PATH lookup
88
+ *
89
+ * @param env - Environment to read overrides from
90
+ * @returns Absolute path to the binary, or null if none is installed
91
+ */
92
+ export declare function getRelaycastEnginePath(env?: Env): string | null;
93
+ export {};
94
+ //# sourceMapp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UG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,IAAI,CAW5E"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The single, canonical location of every Agent Relay native binary.
3
+ *
4
+ * However Agent Relay is installed (`install.sh`, `npm i -g agent-relay`, the
5
+ * desktop app), its binaries converge on one directory so the CLI, the broker
6
+ * it launches and the desktop app always run the same executables:
7
+ *
8
+ * $AGENT_RELAY_INSTALL_DIR/bin when AGENT_RELAY_INSTALL_DIR is set
9
+ * $AGENT_RELAY_HOME/bin otherwise, when AGENT_RELAY_HOME is set
10
+ * ~/.agentworkforce/relay/bin by default
11
+ *
12
+ * Reserved binary slots in that directory (`.exe` suffix on Windows):
13
+ *
14
+ * agent-relay standalone CLI (written by install.sh)
15
+ * agent-relay-broker Rust broker (install.sh, desktop app, or copied from
16
+ * the npm optional dependency on first CLI run)
17
+ * relaycast-engine local Relaycast server (install.sh, when published)
18
+ *
19
+ * `install.sh` resolves the same directory, so the shell installer and the
20
+ * runtime resolvers cannot disagree about where binaries live.
21
+ */
22
+ import { execFileSync } from 'node:child_process';
23
+ import { accessSync, constants, existsSync, statSync } from 'node:fs';
24
+ import { homedir } from 'node:os';
25
+ import { join, resolve } from 'node:path';
26
+ export const BROKER_BINARY_NAME = 'agent-relay-broker';
27
+ export const RELAYCAST_ENGINE_BINARY_NAME = 'relaycast-engine';
28
+ /** Environment variable that relocates the whole install root. */
29
+ export const RELAY_INSTALL_DIR_ENV = 'AGENT_RELAY_INSTALL_DIR';
30
+ /** Relay home (credentials, state). Its `bin/` is used when no install dir is set. */
31
+ export const RELAY_HOME_ENV = 'AGENT_RELAY_HOME';
32
+ /** Explicit path to a relaycast-engine binary, checked before the canonical slot. */
33
+ export const RELAYCAST_ENGINE_PATH_ENV = 'RELAYCAST_ENGINE_PATH';
34
+ function nonEmpty(value) {
35
+ const trimmed = value?.trim();
36
+ return trimmed ? trimmed : undefined;
37
+ }
38
+ /**
39
+ * Executable file name for `name` on `platform` (`.exe` on Windows).
40
+ * @param name - Binary base name, e.g. `agent-relay-broker`
41
+ * @param platform - Target platform (defaults to the current one)
42
+ * @returns The file name to look for on disk
43
+ */
44
+ export function executableFileName(name, platform = process.platform) {
45
+ return platform === 'win32' ? `${name}.exe` : name;
46
+ }
47
+ /**
48
+ * Root of the Agent Relay install (`AGENT_RELAY_INSTALL_DIR` →
49
+ * `AGENT_RELAY_HOME` → `~/.agentworkforce/relay`).
50
+ * @param env - Environment to read overrides from
51
+ * @param home - Home directory used for the default
52
+ * @returns Absolute install root
53
+ */
54
+ export function getRelayInstallDir(env = process.env, home = homedir()) {
55
+ const explicit = nonEmpty(env[RELAY_INSTALL_DIR_ENV]) ?? nonEmpty(env[RELAY_HOME_ENV]);
56
+ if (explicit)
57
+ return resolve(explicit);
58
+ return join(home, '.agentworkforce', 'relay');
59
+ }
60
+ /**
61
+ * The canonical binary directory: `<install root>/bin`.
62
+ * @param env - Environment to read overrides from
63
+ * @param home - Home directory used for the default
64
+ * @returns Absolute path of the canonical bin directory
65
+ */
66
+ export function getRelayBinDir(env = process.env, home = homedir()) {
67
+ return join(getRelayInstallDir(env, home), 'bin');
68
+ }
69
+ /**
70
+ * Canonical path of the broker binary (may not exist).
71
+ * @param env - Environment to read overrides from
72
+ * @param platform - Target platform
73
+ * @returns `<bin>/agent-relay-broker[.exe]`
74
+ */
75
+ export function getCanonicalBrokerPath(env = process.env, platform = process.platform) {
76
+ return join(getRelayBinDir(env), executableFileName(BROKER_BINARY_NAME, platform));
77
+ }
78
+ /**
79
+ * Canonical path of the local Relaycast server binary (may not exist).
80
+ * @param env - Environment to read overrides from
81
+ * @param platform - Target platform
82
+ * @returns `<bin>/relaycast-engine[.exe]`
83
+ */
84
+ export function getCanonicalRelaycastEnginePath(env = process.env, platform = process.platform) {
85
+ return join(getRelayBinDir(env), executableFileName(RELAYCAST_ENGINE_BINARY_NAME, platform));
86
+ }
87
+ /**
88
+ * Whether `filePath` looks runnable: a non-empty regular file that is
89
+ * executable (the execute bit is not checked on Windows). Cheap enough for
90
+ * every resolve; it does not execute the file.
91
+ * @param filePath - Candidate binary
92
+ * @returns true when the file can plausibly be launched
93
+ */
94
+ export function isUsableBinary(filePath) {
95
+ try {
96
+ const stat = statSync(filePath);
97
+ if (!stat.isFile() || stat.size === 0)
98
+ return false;
99
+ if (process.platform !== 'win32')
100
+ accessSync(filePath, constants.X_OK);
101
+ return true;
102
+ }
103
+ catch {
104
+ return false;
105
+ }
106
+ }
107
+ /**
108
+ * First match for `name` on PATH (`which` / `where`), or null.
109
+ * @param name - Command name to look up
110
+ * @returns Absolute path, or null when the command is not on PATH
111
+ */
112
+ export function findExecutableOnPath(name) {
113
+ try {
114
+ const cmd = process.platform === 'win32' ? 'where' : 'which';
115
+ const result = execFileSync(cmd, [name], {
116
+ encoding: 'utf-8',
117
+ stdio: ['pipe', 'pipe', 'pipe'],
118
+ }).trim();
119
+ if (result) {
120
+ return result.split(/\r?\n/u)[0].trim();
121
+ }
122
+ }
123
+ catch {
124
+ // Not found on PATH.
125
+ }
126
+ return null;
127
+ }
128
+ /**
129
+ * Resolve the local Relaycast server binary.
130
+ *
131
+ * Search order:
132
+ * 1. `RELAYCAST_ENGINE_PATH` (explicit override; must exist)
133
+ * 2. Canonical slot `<bin>/relaycast-engine[.exe]`
134
+ * 3. PATH lookup
135
+ *
136
+ * @param env - Environment to read overrides from
137
+ * @returns Absolute path to the binary, or null if none is installed
138
+ */
139
+ export function getRelaycastEnginePath(env = process.env) {
140
+ const override = nonEmpty(env[RELAYCAST_ENGINE_PATH_ENV]);
141
+ if (override) {
142
+ const resolvedOverride = resolve(override);
143
+ if (existsSync(resolvedOverride))
144
+ return resolvedOverride;
145
+ }
146
+ const canonical = getCanonicalRelaycastEnginePath(env);
147
+ if (existsSync(canonical) && isUsableBinary(canonical))
148
+ return canonical;
149
+ return findExecutableOnPath(RELAYCAST_ENGINE_BINARY_NAME);
150
+ }
151
+ //# sourceMappingURL=install-paths.js.map