@claw-link/gateway-host 0.2.9 → 0.2.10
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 +44 -3
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.10",
|
|
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
|
@@ -96,12 +96,27 @@ function saveAgent(cfg, agent) {
|
|
|
96
96
|
|
|
97
97
|
// `setup` — install the service (if needed) + add one or more agents.
|
|
98
98
|
async function run() {
|
|
99
|
-
console.log('\n ClawLink Host Gateway — setup\n ─────────────────────────────\n');
|
|
100
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
101
99
|
const cfg = config.load() || config.defaultConfig();
|
|
102
100
|
ensureBridgeUrl(cfg);
|
|
103
101
|
config.save(cfg);
|
|
104
102
|
|
|
103
|
+
// Backward-compat: a bare `npx @claw-link/gateway-host@latest` on an ALREADY-configured
|
|
104
|
+
// host is an UPDATE, not first-run setup — don't re-prompt for agents. Refresh the
|
|
105
|
+
// background service so the new version takes effect, and show status.
|
|
106
|
+
const existing = (cfg.agents || []).length;
|
|
107
|
+
if (existing > 0) {
|
|
108
|
+
console.log(`\n ClawLink Host Gateway v${VERSION} — already set up (${existing} agent${existing > 1 ? 's' : ''}).`);
|
|
109
|
+
const installed = installService();
|
|
110
|
+
console.log(installed
|
|
111
|
+
? ' ✓ Service refreshed to the latest version.'
|
|
112
|
+
: ' ⚠ Could not refresh the service automatically — run: clhost restart');
|
|
113
|
+
console.log('\n Commands: clhost status · clhost agents · clhost add-agent · clhost transport-test\n');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log('\n ClawLink Host Gateway — setup\n ─────────────────────────────\n');
|
|
118
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
119
|
+
|
|
105
120
|
let added = 0, more = true;
|
|
106
121
|
while (more) {
|
|
107
122
|
console.log('\n Add an agent:');
|
|
@@ -258,11 +273,37 @@ function serviceControlCmd(action) {
|
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
function nodeBin() { return process.execPath; }
|
|
261
|
-
function
|
|
276
|
+
function pkgRoot() { return path.join(__dirname, '..'); }
|
|
277
|
+
function appDir() { return path.join(config.HOME_DIR, 'app'); }
|
|
278
|
+
|
|
279
|
+
// The background service must run from a STABLE path — not the version-pinned, GC-able npx
|
|
280
|
+
// cache (`__dirname`), which is why republishing never changed the running version. Copy the
|
|
281
|
+
// currently-running package into ~/.clawlink-host/app on every install/update so a newer
|
|
282
|
+
// `npx @claw-link/gateway-host@latest` actually swaps the code the service runs.
|
|
283
|
+
function syncAppDir() {
|
|
284
|
+
const src = pkgRoot();
|
|
285
|
+
const dest = appDir();
|
|
286
|
+
if (path.resolve(src) === path.resolve(dest)) return; // already running from the stable dir
|
|
287
|
+
try {
|
|
288
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
289
|
+
fs.cpSync(src, dest, {
|
|
290
|
+
recursive: true,
|
|
291
|
+
filter: (s) => { const b = path.basename(s); return b !== 'node_modules' && b !== '.git'; },
|
|
292
|
+
});
|
|
293
|
+
try { fs.chmodSync(path.join(dest, 'bin', 'cli.js'), 0o755); } catch { /* best effort */ }
|
|
294
|
+
} catch { /* non-fatal — cliEntry() falls back to the current path */ }
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function cliEntry() {
|
|
298
|
+
const stable = path.join(appDir(), 'bin', 'cli.js');
|
|
299
|
+
try { if (fs.existsSync(stable)) return stable; } catch { /* */ }
|
|
300
|
+
return path.join(pkgRoot(), 'bin', 'cli.js'); // fallback if the stable copy failed
|
|
301
|
+
}
|
|
262
302
|
|
|
263
303
|
function installService() {
|
|
264
304
|
const platform = process.platform;
|
|
265
305
|
try {
|
|
306
|
+
syncAppDir(); // refresh the stable app dir so the service runs the just-updated version
|
|
266
307
|
if (platform === 'darwin') {
|
|
267
308
|
const plistDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
|
|
268
309
|
fs.mkdirSync(plistDir, { recursive: true });
|