@stage-labs/metro 0.1.0-beta.79 → 0.1.0-beta.80
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/dist/node-name.js +21 -1
- package/package.json +1 -1
- package/runtime/runtime.json +1 -1
package/dist/node-name.js
CHANGED
|
@@ -6,6 +6,15 @@ import { agentsDir } from './local.js';
|
|
|
6
6
|
const NODE_FILE = '.node';
|
|
7
7
|
const ALPHABET = 'abcdefghjkmnpqrstuvwxyz23456789';
|
|
8
8
|
const NAME_RE = /^metro-[a-z0-9]{6}$/;
|
|
9
|
+
const RENAME_WAIT_MS = 30_000;
|
|
10
|
+
const RENAME_POLL_MS = 500;
|
|
11
|
+
const renameWaitMs = () => Number(process.env.METRO_NODE_RENAME_WAIT_MS) || RENAME_WAIT_MS;
|
|
12
|
+
const pause = (ms) => {
|
|
13
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
14
|
+
};
|
|
15
|
+
const stderrLine = (line) => {
|
|
16
|
+
process.stderr.write(`${line}\n`);
|
|
17
|
+
};
|
|
9
18
|
export function newNodeName() {
|
|
10
19
|
const bytes = randomBytes(6);
|
|
11
20
|
return `metro-${[...bytes].map((b) => ALPHABET[b % ALPHABET.length] ?? 'x').join('')}`;
|
|
@@ -36,7 +45,17 @@ export function currentNodeLabel(bin) {
|
|
|
36
45
|
return null;
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
|
|
48
|
+
function awaitRename(bin, wanted, warn) {
|
|
49
|
+
const wait = renameWaitMs();
|
|
50
|
+
const until = Date.now() + wait;
|
|
51
|
+
while (Date.now() < until) {
|
|
52
|
+
if (currentNodeLabel(bin) === wanted)
|
|
53
|
+
return;
|
|
54
|
+
pause(RENAME_POLL_MS);
|
|
55
|
+
}
|
|
56
|
+
warn(`tailscale still reports the old machine name after ${String(Math.round(wait / 1000))}s; the Funnel address may come up under it until the next restart`);
|
|
57
|
+
}
|
|
58
|
+
export function ensureNodeName(bin, dir = agentsDir(), warn = stderrLine) {
|
|
40
59
|
const wanted = nodeName(dir);
|
|
41
60
|
if (currentNodeLabel(bin) === wanted)
|
|
42
61
|
return wanted;
|
|
@@ -47,5 +66,6 @@ export function ensureNodeName(bin, dir = agentsDir()) {
|
|
|
47
66
|
throw new Error(`could not name this machine ${wanted} on your tailnet (${reason}).\n` +
|
|
48
67
|
`Run it once yourself, then start again: sudo tailscale set --hostname ${wanted}`);
|
|
49
68
|
}
|
|
69
|
+
awaitRename(bin, wanted, warn);
|
|
50
70
|
return wanted;
|
|
51
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stage-labs/metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.80",
|
|
4
4
|
"description": "The metro command line. Sign in once per machine, then hand your MCP connector list to Claude Code without the credentials touching disk, argv or shell history.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/runtime/runtime.json
CHANGED