agent-relay-server 0.10.18 → 0.10.19
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/README.md +5 -0
- package/package.json +3 -1
- package/scripts/install-bin-shim.cjs +104 -0
package/README.md
CHANGED
|
@@ -261,6 +261,11 @@ agent-relay setup --yes
|
|
|
261
261
|
agent-relay daemon install --binary "$(command -v agent-relay)" --enable --start --yes
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
+
Global installs create a user-level fallback shim at `~/.local/bin/agent-relay`
|
|
265
|
+
when the package manager's bin directory is not reliably visible. If a new shell
|
|
266
|
+
still cannot find `agent-relay`, add `~/.local/bin` and your Bun bin directory to
|
|
267
|
+
`PATH`.
|
|
268
|
+
|
|
264
269
|
`setup` creates a managed env file with a generated token, loopback bind, and a
|
|
265
270
|
durable SQLite path. `daemon install` auto-detects systemd (Linux) and
|
|
266
271
|
LaunchAgents (macOS).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay-server",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.19",
|
|
4
4
|
"description": "Lightweight HTTP message relay for inter-agent communication across machines",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"!src/**/*.test.ts",
|
|
21
21
|
"examples/**",
|
|
22
22
|
"recipes/**",
|
|
23
|
+
"scripts/install-bin-shim.cjs",
|
|
23
24
|
"scripts/orchestrator-spawn-smoke.ts",
|
|
24
25
|
"runner/src/config.ts",
|
|
25
26
|
"runner/src/adapter.ts",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"agent-relay-sdk": "0.2.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
37
|
+
"postinstall": "node scripts/install-bin-shim.cjs",
|
|
36
38
|
"start": "bun run src/index.ts",
|
|
37
39
|
"dev": "bun --watch run src/index.ts",
|
|
38
40
|
"dev:dashboard": "cd dashboard && npx vite",
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync, chmodSync } = require("node:fs");
|
|
3
|
+
const { homedir } = require("node:os");
|
|
4
|
+
const { delimiter, join, relative } = require("node:path");
|
|
5
|
+
|
|
6
|
+
const MARKER = "agent-relay managed user shim";
|
|
7
|
+
|
|
8
|
+
function shellQuote(value) {
|
|
9
|
+
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function truthy(value) {
|
|
13
|
+
return value === "1" || value === "true" || value === "yes";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function packageLooksGlobal(packageRoot) {
|
|
17
|
+
const normalized = packageRoot.replace(/\\/g, "/");
|
|
18
|
+
return normalized.includes("/lib/node_modules/agent-relay-server") ||
|
|
19
|
+
normalized.includes("/.bun/install/global/node_modules/agent-relay-server") ||
|
|
20
|
+
normalized.includes("/.bun/install/global/agent-relay-server");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function shouldInstallShim(env, packageRoot) {
|
|
24
|
+
if (truthy(env.AGENT_RELAY_SKIP_BIN_SHIM) || env.AGENT_RELAY_INSTALL_USER_BIN === "0") return false;
|
|
25
|
+
if (truthy(env.AGENT_RELAY_INSTALL_USER_BIN)) return true;
|
|
26
|
+
if (env.npm_config_global === "true") return true;
|
|
27
|
+
return packageLooksGlobal(packageRoot);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function pathContains(dir, env) {
|
|
31
|
+
return String(env.PATH || "").split(delimiter).some((entry) => entry === dir);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function chooseBinDir(env, home) {
|
|
35
|
+
if (env.AGENT_RELAY_USER_BIN_DIR) return env.AGENT_RELAY_USER_BIN_DIR;
|
|
36
|
+
const localBin = join(home, ".local", "bin");
|
|
37
|
+
const bunBin = join(home, ".bun", "bin");
|
|
38
|
+
if (pathContains(localBin, env)) return localBin;
|
|
39
|
+
if (pathContains(bunBin, env)) return bunBin;
|
|
40
|
+
return localBin;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function canOverwriteShim(path) {
|
|
44
|
+
if (!existsSync(path)) return true;
|
|
45
|
+
const stat = lstatSync(path);
|
|
46
|
+
if (stat.isSymbolicLink()) return true;
|
|
47
|
+
if (!stat.isFile()) return false;
|
|
48
|
+
return readFileSync(path, "utf8").includes(MARKER);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function renderShim(cliPath) {
|
|
52
|
+
return [
|
|
53
|
+
"#!/usr/bin/env sh",
|
|
54
|
+
`# ${MARKER}`,
|
|
55
|
+
`CLI=${shellQuote(cliPath)}`,
|
|
56
|
+
"if command -v bun >/dev/null 2>&1; then",
|
|
57
|
+
' exec bun "$CLI" "$@"',
|
|
58
|
+
"fi",
|
|
59
|
+
'if [ -n "$HOME" ] && [ -x "$HOME/.bun/bin/bun" ]; then',
|
|
60
|
+
' exec "$HOME/.bun/bin/bun" "$CLI" "$@"',
|
|
61
|
+
"fi",
|
|
62
|
+
'echo "agent-relay: Bun is required but was not found on PATH or at $HOME/.bun/bin/bun" >&2',
|
|
63
|
+
"exit 127",
|
|
64
|
+
"",
|
|
65
|
+
].join("\n");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function installShim(env = process.env) {
|
|
69
|
+
const packageRoot = join(__dirname, "..");
|
|
70
|
+
if (!shouldInstallShim(env, packageRoot)) return { installed: false, skipped: "not-global" };
|
|
71
|
+
|
|
72
|
+
const home = env.HOME || homedir();
|
|
73
|
+
if (!home) return { installed: false, skipped: "no-home" };
|
|
74
|
+
|
|
75
|
+
const binDir = chooseBinDir(env, home);
|
|
76
|
+
const shimPath = join(binDir, "agent-relay");
|
|
77
|
+
const cliPath = join(packageRoot, "src", "index.ts");
|
|
78
|
+
|
|
79
|
+
if (!canOverwriteShim(shimPath)) {
|
|
80
|
+
console.warn(`[agent-relay] Not overwriting existing ${shimPath}; set AGENT_RELAY_USER_BIN_DIR to choose another shim location.`);
|
|
81
|
+
return { installed: false, skipped: "exists", path: shimPath };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
mkdirSync(binDir, { recursive: true });
|
|
85
|
+
writeFileSync(shimPath, renderShim(cliPath), "utf8");
|
|
86
|
+
chmodSync(shimPath, 0o755);
|
|
87
|
+
|
|
88
|
+
if (!pathContains(binDir, env)) {
|
|
89
|
+
const display = relative(home, binDir).startsWith("..") ? binDir : `~/${relative(home, binDir)}`;
|
|
90
|
+
console.warn(`[agent-relay] Installed ${shimPath}. Add ${display} to PATH to run agent-relay from a new shell.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return { installed: true, path: shimPath };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (require.main === module) {
|
|
97
|
+
try {
|
|
98
|
+
installShim();
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn(`[agent-relay] Could not install user PATH shim: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = { installShim, renderShim, shouldInstallShim };
|