agent-relay 2.3.2 → 2.3.4
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/index.cjs +1 -1
- package/package.json +18 -18
- package/packages/acp-bridge/package.json +2 -2
- package/packages/api-types/package.json +1 -1
- package/packages/benchmark/package.json +5 -5
- package/packages/bridge/package.json +7 -7
- package/packages/cli-tester/package.json +1 -1
- package/packages/config/dist/cloud-config.d.ts +1 -1
- package/packages/config/dist/cloud-config.d.ts.map +1 -1
- package/packages/config/dist/cloud-config.js.map +1 -1
- package/packages/config/dist/schemas.d.ts +5 -5
- package/packages/config/dist/schemas.js +1 -1
- package/packages/config/dist/schemas.js.map +1 -1
- package/packages/config/package.json +2 -2
- package/packages/config/src/cloud-config.ts +2 -2
- package/packages/config/src/schemas.test.ts +48 -0
- package/packages/config/src/schemas.ts +1 -1
- package/packages/continuity/package.json +2 -2
- package/packages/daemon/package.json +12 -12
- package/packages/hooks/package.json +4 -4
- package/packages/mcp/package.json +5 -5
- package/packages/memory/package.json +2 -2
- package/packages/policy/package.json +2 -2
- package/packages/protocol/package.json +1 -1
- package/packages/resiliency/package.json +1 -1
- package/packages/sdk/package.json +3 -3
- package/packages/sdk-ts/dist/__tests__/facade.test.d.ts +2 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.d.ts.map +1 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.js +257 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.js.map +1 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.d.ts +2 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.d.ts.map +1 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.js +124 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.js.map +1 -0
- package/packages/sdk-ts/dist/client.d.ts +2 -0
- package/packages/sdk-ts/dist/client.d.ts.map +1 -1
- package/packages/sdk-ts/dist/client.js +2 -0
- package/packages/sdk-ts/dist/client.js.map +1 -1
- package/packages/sdk-ts/dist/protocol.d.ts +1 -0
- package/packages/sdk-ts/dist/protocol.d.ts.map +1 -1
- package/packages/sdk-ts/dist/relay.d.ts +44 -0
- package/packages/sdk-ts/dist/relay.d.ts.map +1 -1
- package/packages/sdk-ts/dist/relay.js +89 -11
- package/packages/sdk-ts/dist/relay.js.map +1 -1
- package/packages/sdk-ts/dist/relaycast.js +2 -2
- package/packages/sdk-ts/dist/relaycast.js.map +1 -1
- package/packages/sdk-ts/package.json +3 -3
- package/packages/sdk-ts/src/__tests__/facade.test.ts +296 -0
- package/packages/sdk-ts/src/__tests__/unit.test.ts +152 -0
- package/packages/sdk-ts/src/client.ts +4 -0
- package/packages/sdk-ts/src/protocol.ts +1 -1
- package/packages/sdk-ts/src/relay.ts +112 -11
- package/packages/sdk-ts/src/relaycast.ts +2 -2
- package/packages/spawner/package.json +1 -1
- package/packages/state/package.json +1 -1
- package/packages/storage/package.json +2 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +3 -3
- package/packages/wrapper/package.json +6 -6
- package/scripts/postinstall.js +106 -2
package/scripts/postinstall.js
CHANGED
|
@@ -357,6 +357,101 @@ async function installRelayPtyBinary() {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* Get the platform-specific binary name for the broker binary.
|
|
362
|
+
* The broker binary is needed by the SDK (packages/sdk-ts) for programmatic
|
|
363
|
+
* agent orchestration via `new AgentRelay()`.
|
|
364
|
+
* Returns null if platform is not supported.
|
|
365
|
+
*/
|
|
366
|
+
function getBrokerBinaryName() {
|
|
367
|
+
const platform = os.platform();
|
|
368
|
+
const arch = os.arch();
|
|
369
|
+
|
|
370
|
+
const archMap = { 'arm64': 'arm64', 'x64': 'x64' };
|
|
371
|
+
const platformMap = { 'darwin': 'darwin', 'linux': 'linux' };
|
|
372
|
+
|
|
373
|
+
const targetPlatform = platformMap[platform];
|
|
374
|
+
const targetArch = archMap[arch];
|
|
375
|
+
|
|
376
|
+
if (!targetPlatform || !targetArch) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return `agent-relay-${targetPlatform}-${targetArch}`;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Install the broker binary into packages/sdk-ts/bin/.
|
|
385
|
+
*
|
|
386
|
+
* The SDK's AgentRelayClient spawns this binary as a subprocess
|
|
387
|
+
* (`agent-relay init --name broker --channels general`). Without it,
|
|
388
|
+
* `new AgentRelay()` will fail with "broker exited (code=1)".
|
|
389
|
+
*
|
|
390
|
+
* Resolution order:
|
|
391
|
+
* 1. Already bundled at packages/sdk-ts/bin/agent-relay (e.g. from prepack)
|
|
392
|
+
* 2. Download platform-specific standalone binary from GitHub releases
|
|
393
|
+
* 3. Fall back to the local Rust debug binary at target/debug/agent-relay (dev only)
|
|
394
|
+
*/
|
|
395
|
+
async function installBrokerBinary() {
|
|
396
|
+
const pkgRoot = getPackageRoot();
|
|
397
|
+
const sdkBinDir = path.join(pkgRoot, 'packages', 'sdk-ts', 'bin');
|
|
398
|
+
const isWindows = process.platform === 'win32';
|
|
399
|
+
const binaryFilename = isWindows ? 'agent-relay.exe' : 'agent-relay';
|
|
400
|
+
const targetPath = path.join(sdkBinDir, binaryFilename);
|
|
401
|
+
|
|
402
|
+
// 1. Already installed?
|
|
403
|
+
if (fs.existsSync(targetPath)) {
|
|
404
|
+
try {
|
|
405
|
+
execSync(`"${targetPath}" init --help`, { stdio: 'pipe' });
|
|
406
|
+
info('Broker binary already installed in SDK');
|
|
407
|
+
return true;
|
|
408
|
+
} catch {
|
|
409
|
+
// Binary exists but doesn't work — reinstall
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
fs.mkdirSync(sdkBinDir, { recursive: true });
|
|
414
|
+
|
|
415
|
+
// 2. Try downloading from GitHub releases
|
|
416
|
+
const binaryName = getBrokerBinaryName();
|
|
417
|
+
if (binaryName) {
|
|
418
|
+
const version = getPackageVersion(pkgRoot);
|
|
419
|
+
if (version) {
|
|
420
|
+
const downloadUrl = `https://github.com/AgentWorkforce/relay/releases/download/v${version}/${binaryName}`;
|
|
421
|
+
info(`Downloading broker binary from ${downloadUrl} ...`);
|
|
422
|
+
|
|
423
|
+
try {
|
|
424
|
+
await downloadRelayPtyBinary(downloadUrl, targetPath);
|
|
425
|
+
fs.chmodSync(targetPath, 0o755);
|
|
426
|
+
resignBinaryForMacOS(targetPath);
|
|
427
|
+
success(`Downloaded broker binary for ${os.platform()}-${os.arch()}`);
|
|
428
|
+
return true;
|
|
429
|
+
} catch (err) {
|
|
430
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
431
|
+
warn(`Failed to download broker binary: ${message}`);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// 3. Dev fallback — check for local Rust build
|
|
437
|
+
const debugBinary = path.join(pkgRoot, 'target', 'debug', binaryFilename);
|
|
438
|
+
if (fs.existsSync(debugBinary)) {
|
|
439
|
+
try {
|
|
440
|
+
fs.copyFileSync(debugBinary, targetPath);
|
|
441
|
+
fs.chmodSync(targetPath, 0o755);
|
|
442
|
+
resignBinaryForMacOS(targetPath);
|
|
443
|
+
success('Installed broker binary from local Rust debug build');
|
|
444
|
+
return true;
|
|
445
|
+
} catch (err) {
|
|
446
|
+
warn(`Failed to copy debug broker binary: ${err.message}`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
warn('Broker binary not available — SDK programmatic usage (AgentRelay) will not work');
|
|
451
|
+
info('To fix: cargo build --release --bin agent-relay (requires Rust toolchain)');
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
|
|
360
455
|
/**
|
|
361
456
|
* Check if tmux is available on the system
|
|
362
457
|
*/
|
|
@@ -578,7 +673,7 @@ function patchAgentTrajectories() {
|
|
|
578
673
|
success('Patched agent-trajectories to record agent on trail start');
|
|
579
674
|
}
|
|
580
675
|
|
|
581
|
-
function logPostinstallDiagnostics(hasRelayPty, sqliteStatus, linkResult) {
|
|
676
|
+
function logPostinstallDiagnostics(hasRelayPty, hasBrokerBinary, sqliteStatus, linkResult) {
|
|
582
677
|
// Workspace packages status (for global installs)
|
|
583
678
|
if (linkResult && linkResult.needed) {
|
|
584
679
|
if (linkResult.success) {
|
|
@@ -594,6 +689,12 @@ function logPostinstallDiagnostics(hasRelayPty, sqliteStatus, linkResult) {
|
|
|
594
689
|
console.log('⚠ relay-pty binary not installed - falling back to tmux mode if available');
|
|
595
690
|
}
|
|
596
691
|
|
|
692
|
+
if (hasBrokerBinary) {
|
|
693
|
+
console.log('✓ broker binary installed (SDK programmatic usage ready)');
|
|
694
|
+
} else {
|
|
695
|
+
console.log('⚠ broker binary not installed - AgentRelay programmatic API will not work');
|
|
696
|
+
}
|
|
697
|
+
|
|
597
698
|
if (sqliteStatus.ok && sqliteStatus.driver === 'better-sqlite3') {
|
|
598
699
|
console.log('✓ SQLite ready (better-sqlite3)');
|
|
599
700
|
} else if (sqliteStatus.ok && sqliteStatus.driver === 'node:sqlite') {
|
|
@@ -626,6 +727,9 @@ async function main() {
|
|
|
626
727
|
// Install relay-pty binary for current platform (primary mode)
|
|
627
728
|
const hasRelayPty = await installRelayPtyBinary();
|
|
628
729
|
|
|
730
|
+
// Install broker binary for SDK programmatic usage (AgentRelay)
|
|
731
|
+
const hasBrokerBinary = await installBrokerBinary();
|
|
732
|
+
|
|
629
733
|
// Ensure SQLite driver is available (better-sqlite3 or node:sqlite)
|
|
630
734
|
const sqliteStatus = ensureSqliteDriver();
|
|
631
735
|
|
|
@@ -636,7 +740,7 @@ async function main() {
|
|
|
636
740
|
installDashboardDeps();
|
|
637
741
|
|
|
638
742
|
// Always print diagnostics (even in CI)
|
|
639
|
-
logPostinstallDiagnostics(hasRelayPty, sqliteStatus, linkResult);
|
|
743
|
+
logPostinstallDiagnostics(hasRelayPty, hasBrokerBinary, sqliteStatus, linkResult);
|
|
640
744
|
|
|
641
745
|
// Skip tmux check in CI environments
|
|
642
746
|
if (process.env.CI === 'true') {
|