@claw-link/gateway-host 0.2.1 → 0.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/package.json +1 -1
- package/scripts/install.js +3 -1
- package/src/adapters/base.js +3 -1
- package/src/detect.js +3 -1
- package/src/paths.js +35 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claw-link/gateway-host",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "ClawLink Host Gateway — a secure, outbound-only worker that bridges a local agent CLI (OpenClaw, Hermes, Claude, Codex, Cursor) to your ClawLink agents. No inbound ports; authenticated per-agent by a Host Token.",
|
|
5
5
|
"homepage": "https://claw-link.co",
|
|
6
6
|
"bin": {
|
package/scripts/install.js
CHANGED
|
@@ -54,8 +54,10 @@ async function addAgentInteractive(cfg, rl) {
|
|
|
54
54
|
agent.local_gateway_token = await ask(rl, ' Local OpenClaw gateway token (optional)', '');
|
|
55
55
|
agent.work_dir = defaultWs;
|
|
56
56
|
} else {
|
|
57
|
+
// Store the ABSOLUTE binary path so the background service (minimal PATH) can
|
|
58
|
+
// always find it — `spawn('claude')` fails under launchd/systemd otherwise.
|
|
57
59
|
if (!detected[runtime]) agent.binary = await ask(rl, ` '${runtime}' not found on PATH — full path to the binary`, runtime);
|
|
58
|
-
else console.log(` using ${runtime}: ${detected[runtime]}`);
|
|
60
|
+
else { agent.binary = detected[runtime]; console.log(` using ${runtime}: ${detected[runtime]}`); }
|
|
59
61
|
|
|
60
62
|
// Coding runtimes run inside a project workspace. Default to the managed
|
|
61
63
|
// workspace/<runtime>/agents/<id> folder; an explicit project path is also fine.
|
package/src/adapters/base.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
const { spawn } = require('child_process');
|
|
11
11
|
const logger = require('../logger');
|
|
12
|
+
const { enrichedEnv } = require('../paths');
|
|
12
13
|
|
|
13
14
|
// A small set of flags we refuse to pass through (auto-approve / no-safety modes).
|
|
14
15
|
const FORBIDDEN_FLAGS = [
|
|
@@ -45,7 +46,8 @@ async function* spawnStreaming({ binary, argv, cwd, env, timeoutMs = 600000, std
|
|
|
45
46
|
|
|
46
47
|
const child = spawn(binary, argv, {
|
|
47
48
|
cwd: cwd || undefined,
|
|
48
|
-
|
|
49
|
+
// Enriched PATH so a CLI in ~/.local/bin etc. resolves under a service's minimal env.
|
|
50
|
+
env: enrichedEnv(env),
|
|
49
51
|
shell: false, // CRITICAL: never use a shell
|
|
50
52
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
51
53
|
});
|
package/src/detect.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// Detect which runtime CLIs are installed, to pre-fill the setup wizard.
|
|
3
3
|
|
|
4
4
|
const { execSync } = require('child_process');
|
|
5
|
+
const { enrichedEnv } = require('./paths');
|
|
5
6
|
|
|
6
7
|
function which(cmd) {
|
|
7
8
|
const probe = process.platform === 'win32' ? `where ${cmd}` : `command -v ${cmd}`;
|
|
8
9
|
try {
|
|
9
|
-
|
|
10
|
+
// Use an enriched PATH so detection works under a service's minimal environment.
|
|
11
|
+
const out = execSync(probe, { stdio: ['ignore', 'pipe', 'ignore'], env: enrichedEnv() }).toString().trim();
|
|
10
12
|
return out.split(/\r?\n/)[0] || null;
|
|
11
13
|
} catch { return null; }
|
|
12
14
|
}
|
package/src/paths.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Background services (launchd/systemd) run with a MINIMAL PATH that usually omits
|
|
3
|
+
// ~/.local/bin, /opt/homebrew/bin, npm-global, etc. — so a CLI installed there
|
|
4
|
+
// (e.g. claude at ~/.local/bin) fails with `spawn <cmd> ENOENT`. We enrich PATH for
|
|
5
|
+
// both runtime detection and CLI spawning so agents resolve regardless of how the
|
|
6
|
+
// service was launched.
|
|
7
|
+
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
function enrichedPath() {
|
|
12
|
+
const home = os.homedir();
|
|
13
|
+
const extras = [
|
|
14
|
+
path.dirname(process.execPath), // dir of the running node (npm-global CLIs)
|
|
15
|
+
path.join(home, '.local', 'bin'),
|
|
16
|
+
path.join(home, 'bin'),
|
|
17
|
+
path.join(home, '.npm-global', 'bin'),
|
|
18
|
+
path.join(home, '.bun', 'bin'),
|
|
19
|
+
path.join(home, '.cargo', 'bin'),
|
|
20
|
+
'/opt/homebrew/bin',
|
|
21
|
+
'/usr/local/bin',
|
|
22
|
+
'/usr/bin', '/bin', '/usr/sbin', '/sbin',
|
|
23
|
+
];
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
const parts = [...extras, ...String(process.env.PATH || '').split(path.delimiter)]
|
|
26
|
+
.filter((p) => p && !seen.has(p) && seen.add(p));
|
|
27
|
+
return parts.join(path.delimiter);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// An env with the enriched PATH, suitable for spawn/exec.
|
|
31
|
+
function enrichedEnv(extra) {
|
|
32
|
+
return { ...process.env, ...(extra || {}), PATH: enrichedPath() };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { enrichedPath, enrichedEnv };
|