node-command 2.0.0 → 2.0.1
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/bin/nc.mjs +30 -0
- package/package.json +3 -3
package/bin/nc.mjs
CHANGED
|
@@ -1402,6 +1402,29 @@ function printCliHelp() {
|
|
|
1402
1402
|
);
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
/**
|
|
1406
|
+
* True when the invocation is exactly the bare enrollment form
|
|
1407
|
+
* `nodecommand <host_id> <token>` — the shape emitted by the dashboard and
|
|
1408
|
+
* the control-plane install_command (`npx node-command <host_id> <token>`).
|
|
1409
|
+
*
|
|
1410
|
+
* Exactly two non-flag arguments with plausible shapes route to the same path
|
|
1411
|
+
* as `setup <host_id> <token>`. The guards stay deliberately loose (host id
|
|
1412
|
+
* >= 3 chars, token >= 8 chars): both values are re-validated canonically
|
|
1413
|
+
* inside pairDeviceAndInstall (HOST_ID_RE / ENROLL_TOKEN_RE), so a
|
|
1414
|
+
* malformed-but-intended enrollment surfaces the setup error codes
|
|
1415
|
+
* (INVALID_HOST_ID / INVALID_ENROLL_TOKEN) instead of silently starting the
|
|
1416
|
+
* interactive device flow. Zero or one positional argument, or any flag, is
|
|
1417
|
+
* never mapped to setup and keeps its previous behavior.
|
|
1418
|
+
* @param {string[]} args
|
|
1419
|
+
*/
|
|
1420
|
+
export function isBareEnrollmentInvocation(args = []) {
|
|
1421
|
+
if (!Array.isArray(args) || args.length !== 2) return false;
|
|
1422
|
+
const [hostId, token] = args;
|
|
1423
|
+
if (typeof hostId !== 'string' || typeof token !== 'string') return false;
|
|
1424
|
+
if (hostId.startsWith('-') || token.startsWith('-')) return false;
|
|
1425
|
+
return hostId.length >= 3 && token.length >= 8;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1405
1428
|
async function main() {
|
|
1406
1429
|
const cliArgs = process.argv.slice(2);
|
|
1407
1430
|
// Subcommands route FIRST: otherwise `setup --diagnostics` or a stray flag
|
|
@@ -1439,6 +1462,13 @@ async function main() {
|
|
|
1439
1462
|
if (!result.ok) process.exit(1);
|
|
1440
1463
|
return;
|
|
1441
1464
|
}
|
|
1465
|
+
// Bare enrollment: route `nodecommand <host_id> <token>` (the form the
|
|
1466
|
+
// dashboard and install_command emit) to the `setup <host_id> <token>`
|
|
1467
|
+
// path instead of silently ignoring the arguments in the device flow.
|
|
1468
|
+
if (isBareEnrollmentInvocation(cliArgs)) {
|
|
1469
|
+
await runSetup(cliArgs);
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1442
1472
|
await runDeviceFlow();
|
|
1443
1473
|
}
|
|
1444
1474
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-command",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "Node Command agent CLI
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Node Command agent CLI \u2014 connect this machine to your AI assistant fleet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"bin": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/huseyincig/NodeCommand/issues"
|
|
36
36
|
},
|
|
37
|
-
"author": "
|
|
37
|
+
"author": "H\u00fcseyin Hadi \u00c7\u0131\u011f <huseyincig@users.noreply.github.com>"
|
|
38
38
|
}
|