agentic-numerical-control 0.1.2 → 0.1.4

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.
@@ -34,7 +34,12 @@ export function createServer() {
34
34
  gcode: z.string().optional().describe("G-code program text to preview"),
35
35
  name: z.string().optional().describe("Display name when passing gcode text"),
36
36
  }),
37
- _meta: { ui: { resourceUri: VIEWER_URI } },
37
+ _meta: {
38
+ ui: { resourceUri: VIEWER_URI },
39
+ // Status lines ChatGPT shows while the tool runs; other hosts ignore them.
40
+ "openai/toolInvocation/invoking": "Opening the toolpath viewer…",
41
+ "openai/toolInvocation/invoked": "Toolpath viewer ready",
42
+ },
38
43
  }, async ({ file, gcode, name }) => {
39
44
  try {
40
45
  const job = file
@@ -256,6 +261,10 @@ export function createServer() {
256
261
  uri: VIEWER_URI,
257
262
  mimeType: RESOURCE_MIME_TYPE,
258
263
  text: await fs.readFile(VIEWER_HTML, "utf-8"),
264
+ // The viewer is self-contained (one bundled file) and only talks to
265
+ // this server through the host bridge: no outside origins at all.
266
+ // Hosts default border styling differently, so say what we want.
267
+ _meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true } },
259
268
  },
260
269
  ],
261
270
  }));
@@ -50,15 +50,16 @@ export function buildToolpath(gcode) {
50
50
  addArcCurve: (modal, v1, v2, v0) => {
51
51
  const clockwise = modal.motion === "G2";
52
52
  const radius = Math.hypot(v1.x - v0.x, v1.y - v0.y);
53
- let start = Math.atan2(v1.y - v0.y, v1.x - v0.x);
54
- let end = Math.atan2(v2.y - v0.y, v2.x - v0.x);
55
- if (start === end)
56
- end += 2 * Math.PI;
57
- // Normalise the sweep so it runs in the commanded direction.
53
+ const start = Math.atan2(v1.y - v0.y, v1.x - v0.x);
54
+ const end = Math.atan2(v2.y - v0.y, v2.x - v0.x);
55
+ // Normalise the sweep so it runs in the commanded direction. Equal start
56
+ // and end angles mean a full circle (G2/G3 back to the start point).
58
57
  let sweep = end - start;
59
- if (clockwise && sweep > 0)
58
+ if (sweep === 0)
59
+ sweep = clockwise ? -2 * Math.PI : 2 * Math.PI;
60
+ else if (clockwise && sweep > 0)
60
61
  sweep -= 2 * Math.PI;
61
- if (!clockwise && sweep < 0)
62
+ else if (!clockwise && sweep < 0)
62
63
  sweep += 2 * Math.PI;
63
64
  let prev = null;
64
65
  for (let i = 0; i <= ARC_DIVISIONS; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-numerical-control",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",
@@ -9,7 +9,8 @@
9
9
  "dev:stdio": "npm run build 1>&2 && tsx server/cli.ts stdio",
10
10
  "sim:build": "node sim/build.mjs",
11
11
  "sim:e2e": "node sim/e2e.mjs",
12
- "prepack": "npm run build"
12
+ "prepack": "npm run build",
13
+ "demo:site": "tsx scripts/build-demo.ts"
13
14
  },
14
15
  "license": "MIT",
15
16
  "dependencies": {