@claw-link/gateway-host 0.2.1 → 0.2.3
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 +11 -0
- package/package.json +1 -1
- package/scripts/install.js +3 -1
- package/src/adapters/base.js +3 -1
- package/src/adapters/claude.js +7 -0
- package/src/adapters/cli.js +6 -1
- package/src/detect.js +3 -1
- package/src/paths.js +35 -0
package/README.md
CHANGED
|
@@ -61,6 +61,17 @@ Change the Claude model by editing `.claude/settings.json` (e.g. `"model": "opus
|
|
|
61
61
|
For Codex/Cursor, set the model via their CLI (`args_template` in the config, or the
|
|
62
62
|
tool's own settings).
|
|
63
63
|
|
|
64
|
+
**Permissions by scope** — each job carries a scope, and the Claude adapter runs with
|
|
65
|
+
matching permissions automatically:
|
|
66
|
+
|
|
67
|
+
| Trigger | Scope | Claude permissions |
|
|
68
|
+
|---------|-------|--------------------|
|
|
69
|
+
| Admin **Setup via Chat** / apply skill | `configure` | `--permission-mode acceptEdits` — may write workspace files (GUARDRAILS/SOUL/BOOTSTRAP/TOOLS/AGENTS) |
|
|
70
|
+
| Customer chat + discovery | `customer` | `--disallowedTools "Write Edit MultiEdit NotebookEdit Bash"` — **read-only**, cannot edit config or run shell |
|
|
71
|
+
|
|
72
|
+
So an agent's files are editable from the admin panel but never from customer/discovery
|
|
73
|
+
chat. (Operator `args_template` overrides this for advanced setups.)
|
|
74
|
+
|
|
64
75
|
## Commands
|
|
65
76
|
|
|
66
77
|
After install the `clhost` command is available (aliases: `gateway-host`, `claw-host`):
|
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.3",
|
|
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/adapters/claude.js
CHANGED
|
@@ -16,4 +16,11 @@ module.exports = makeCliAdapter({
|
|
|
16
16
|
'--verbose',
|
|
17
17
|
...(resumeId ? ['--resume', resumeId] : []),
|
|
18
18
|
],
|
|
19
|
+
// Admin "configure" turns may write workspace files (auto-accept edits, no shell
|
|
20
|
+
// prompt); customer/discovery turns are strictly read-only (no Write/Edit/Bash) so
|
|
21
|
+
// they can never modify the agent's config or hang on a permission prompt.
|
|
22
|
+
permissions: (scope) =>
|
|
23
|
+
(scope === 'configure' || scope === 'sub_configure')
|
|
24
|
+
? ['--permission-mode', 'acceptEdits']
|
|
25
|
+
: ['--disallowedTools', 'Write Edit MultiEdit NotebookEdit Bash'],
|
|
19
26
|
});
|
package/src/adapters/cli.js
CHANGED
|
@@ -76,9 +76,14 @@ function makeCliAdapter(cfg) {
|
|
|
76
76
|
// spawn never fails with ENOENT (coding workspaces are validated at setup).
|
|
77
77
|
try { fs.mkdirSync(agent.work_dir, { recursive: true }); } catch { /* ignore */ }
|
|
78
78
|
|
|
79
|
+
// Scope-based permissions: admin "configure" turns may write workspace files
|
|
80
|
+
// (GUARDRAILS/SOUL/etc.); customer/discovery turns are read-only and cannot
|
|
81
|
+
// edit or run shell. Operator args_template overrides take full control.
|
|
82
|
+
const scope = job.scope || 'customer';
|
|
83
|
+
const permArgs = (!Array.isArray(agent.args_template) && cfg.permissions) ? cfg.permissions(scope) : [];
|
|
79
84
|
const argvFor = (rid) => Array.isArray(agent.args_template)
|
|
80
85
|
? buildArgv(agent.args_template, { prompt: fullPrompt, sessionId: rid || '', systemPrompt })
|
|
81
|
-
: cfg.defaultArgs(fullPrompt, rid, cfg.promptViaStdin);
|
|
86
|
+
: [...cfg.defaultArgs(fullPrompt, rid, cfg.promptViaStdin), ...permArgs];
|
|
82
87
|
|
|
83
88
|
let emittedAny = false;
|
|
84
89
|
const runOnce = async function* (rid) {
|
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 };
|