@claw-link/gateway-host 0.2.5 → 0.2.6
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 +1 -0
- package/bin/cli.js +8 -1
- package/package.json +1 -1
- package/scripts/install.js +44 -1
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ After install the `clhost` command is available (aliases: `gateway-host`, `claw-
|
|
|
81
81
|
clhost install # install the background service (one-time)
|
|
82
82
|
clhost add-agent # add an agent by pasting its Host Token
|
|
83
83
|
clhost rm-agent <id># remove a mapped agent
|
|
84
|
+
clhost retoken <id> # re-enter a new token after rotating (keeps workspace/binary)
|
|
84
85
|
clhost agents # list mapped agents
|
|
85
86
|
clhost status # bridge + service state + mapped agents
|
|
86
87
|
clhost start # start the background service
|
package/bin/cli.js
CHANGED
|
@@ -27,6 +27,11 @@ async function main() {
|
|
|
27
27
|
case 'rm':
|
|
28
28
|
return require('../scripts/install').removeAgentCmd();
|
|
29
29
|
|
|
30
|
+
case 'retoken':
|
|
31
|
+
case 're-token':
|
|
32
|
+
case 'update-token':
|
|
33
|
+
return require('../scripts/install').retokenCmd();
|
|
34
|
+
|
|
30
35
|
case 'agents':
|
|
31
36
|
case 'list':
|
|
32
37
|
return require('../scripts/install').listAgents();
|
|
@@ -48,7 +53,8 @@ async function main() {
|
|
|
48
53
|
'To rotate a Host Token (also how you move an agent to a new machine):',
|
|
49
54
|
' 1. ClawLink → Agents → your agent → Host Gateway → "Rotate token"',
|
|
50
55
|
' (this clears the machine binding so a new host can claim it).',
|
|
51
|
-
' 2. Copy the new token, then run: clhost
|
|
56
|
+
' 2. Copy the new token, then run: clhost retoken <id>',
|
|
57
|
+
' (keeps the agent\'s workspace/binary; or `clhost add-agent` for a new one).',
|
|
52
58
|
' The old token + old machine stop working immediately.',
|
|
53
59
|
].join('\n'));
|
|
54
60
|
return;
|
|
@@ -63,6 +69,7 @@ async function main() {
|
|
|
63
69
|
' install Install the background service (one-time)',
|
|
64
70
|
' add-agent Add an agent by pasting its Host Token (pulls runtime from ClawLink)',
|
|
65
71
|
' rm-agent Remove a mapped agent (clhost rm-agent <id>)',
|
|
72
|
+
' retoken Re-enter a new Host Token for an existing agent (clhost retoken <id>)',
|
|
66
73
|
' agents List mapped agents',
|
|
67
74
|
' status Show bridge, service state, and mapped agents',
|
|
68
75
|
' start Start the background service',
|
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.6",
|
|
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
|
@@ -175,11 +175,54 @@ function printAgents(cfg) {
|
|
|
175
175
|
const tok = a.host_token ? `…${String(a.host_token).slice(-4)}` : '—';
|
|
176
176
|
console.log(` • ${id}… runtime=${a.runtime || 'pull'} token=${tok}` + (a.work_dir ? ` work=${a.work_dir}` : ''));
|
|
177
177
|
}
|
|
178
|
+
console.log('\n Update a token after rotating it: clhost retoken <id>');
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
// `agents` — list mapped agents.
|
|
181
182
|
function listAgents() { printAgents(config.load() || {}); }
|
|
182
183
|
|
|
184
|
+
// `retoken [id-or-prefix]` — re-enter a new Host Token for an EXISTING agent after
|
|
185
|
+
// rotating it in the dashboard, keeping the same work_dir/binary/runtime. The new
|
|
186
|
+
// token must resolve to the same agent_id; re-binds this machine on verify.
|
|
187
|
+
async function retokenCmd() {
|
|
188
|
+
const cfg = config.load();
|
|
189
|
+
if (!cfg || !(cfg.agents || []).length) { console.log('No agents configured. Run: clhost add-agent'); return; }
|
|
190
|
+
ensureBridgeUrl(cfg);
|
|
191
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
192
|
+
try {
|
|
193
|
+
let target = (process.argv[3] || '').trim();
|
|
194
|
+
if (!target && cfg.agents.length === 1) target = cfg.agents[0].agent_id || '';
|
|
195
|
+
if (!target) { printAgents(cfg); target = await ask(rl, '\n Agent ID (or prefix) to re-token'); }
|
|
196
|
+
if (!target) { console.log(' (cancelled)'); return; }
|
|
197
|
+
const agent = cfg.agents.find((a) => a.agent_id && (a.agent_id === target || a.agent_id.startsWith(target)));
|
|
198
|
+
if (!agent) { console.log(` No agent matched '${target}'.`); return; }
|
|
199
|
+
|
|
200
|
+
const token = await ask(rl, ` New Host Token for ${String(agent.agent_id).slice(0, 8)}… (clk_host_…)`);
|
|
201
|
+
if (!token) { console.log(' (cancelled)'); return; }
|
|
202
|
+
|
|
203
|
+
console.log(' Verifying new token + binding this machine…');
|
|
204
|
+
let resp;
|
|
205
|
+
try {
|
|
206
|
+
resp = await new Bridge(cfg.bridge_url, { host_token: token }, cfg.instance_id).register(null, VERSION);
|
|
207
|
+
} catch (e) { console.log(` ✗ Could not verify: ${e.message}`); return; }
|
|
208
|
+
|
|
209
|
+
if (resp.agent_id && resp.agent_id !== agent.agent_id) {
|
|
210
|
+
console.log(` ✗ That token belongs to a different agent (${String(resp.agent_id).slice(0, 8)}…), not ${String(agent.agent_id).slice(0, 8)}….`);
|
|
211
|
+
console.log(' To map a different agent, use: clhost add-agent');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
agent.host_token = token;
|
|
215
|
+
if (resp.runtime && resp.runtime !== agent.runtime) {
|
|
216
|
+
console.log(` ℹ runtime changed: ${agent.runtime} → ${resp.runtime}`);
|
|
217
|
+
agent.runtime = resp.runtime;
|
|
218
|
+
}
|
|
219
|
+
config.save(cfg);
|
|
220
|
+
const restarted = serviceControl('restart');
|
|
221
|
+
console.log(`\n ✓ Updated token for ${agent.agent_id} (…${token.slice(-4)}).` +
|
|
222
|
+
(restarted ? ' Service restarted.' : ' Run `clhost restart` to apply.') + '\n');
|
|
223
|
+
} finally { rl.close(); }
|
|
224
|
+
}
|
|
225
|
+
|
|
183
226
|
// `start | stop | restart` — control the installed background service.
|
|
184
227
|
function serviceControl(action) {
|
|
185
228
|
const platform = process.platform;
|
|
@@ -339,6 +382,6 @@ function status() {
|
|
|
339
382
|
}
|
|
340
383
|
|
|
341
384
|
module.exports = {
|
|
342
|
-
run, installOnly, addAgentCmd, removeAgentCmd, listAgents, status,
|
|
385
|
+
run, installOnly, addAgentCmd, removeAgentCmd, retokenCmd, listAgents, status,
|
|
343
386
|
serviceControl, serviceControlCmd, installService, SERVICE_LABEL,
|
|
344
387
|
};
|