agentic-numerical-control 0.1.4 → 0.1.5
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/server/relay.js +16 -3
- package/package.json +1 -1
package/dist/server/relay.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Keeps this PC linked to a Agentic Numerical Control cloud account. The PC dials out to the
|
|
2
2
|
// cloud over a WebSocket; MCP requests from Claude arrive on it and are
|
|
3
3
|
// answered by the local MCP endpoint. Nothing listens on the network.
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
4
5
|
import fs from "node:fs";
|
|
5
6
|
import os from "node:os";
|
|
6
7
|
import path from "node:path";
|
|
@@ -29,6 +30,18 @@ async function postJson(url, body) {
|
|
|
29
30
|
throw new Error(json.error ?? `${res.status} ${res.statusText}`);
|
|
30
31
|
return json;
|
|
31
32
|
}
|
|
33
|
+
/** Best effort: the link is also printed for when no browser opens. */
|
|
34
|
+
function openBrowser(url) {
|
|
35
|
+
const [cmd, args] = process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]]
|
|
36
|
+
: process.platform === "darwin" ? ["open", [url]]
|
|
37
|
+
: ["xdg-open", [url]];
|
|
38
|
+
try {
|
|
39
|
+
spawn(cmd, args, { detached: true, stdio: "ignore" }).on("error", () => { }).unref();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// no browser available (a headless machine): the printed link is enough
|
|
43
|
+
}
|
|
44
|
+
}
|
|
32
45
|
/** Device-code pairing: show a code, wait for the person to approve it online. */
|
|
33
46
|
export async function pair(cloudUrl) {
|
|
34
47
|
for (;;) {
|
|
@@ -42,10 +55,10 @@ async function pairOnce(cloudUrl) {
|
|
|
42
55
|
const name = `${os.hostname()} (Agentic Numerical Control)`;
|
|
43
56
|
const start = await postJson(`${cloudUrl}/api/device/start`, { name });
|
|
44
57
|
console.log("");
|
|
45
|
-
console.log(
|
|
46
|
-
console.log(`
|
|
47
|
-
console.log(` 2. Sign in and check the code is ${start.userCode}`);
|
|
58
|
+
console.log(` Link this computer to your account. Your code is ${start.userCode}.`);
|
|
59
|
+
console.log(` A browser page should open. If it doesn't, open ${start.verificationUri}`);
|
|
48
60
|
console.log("");
|
|
61
|
+
openBrowser(start.verificationUri);
|
|
49
62
|
const deadline = Date.now() + start.expiresIn * 1000;
|
|
50
63
|
while (Date.now() < deadline) {
|
|
51
64
|
await sleep(start.interval * 1000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-numerical-control",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Agentic Numerical Control: see and run CNC jobs from your AI assistant. A 3D toolpath viewer, live machine status and job control for CNCjs/GRBL machines.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --noEmit -p tsconfig.app.json && cross-env INPUT=viewer.html vite build && tsc -p tsconfig.build.json",
|