brepjs-verify 0.4.0 → 0.13.0
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/CHANGELOG.md +223 -0
- package/README.md +55 -25
- package/dist/brepjs-verify.cjs +1 -1
- package/dist/brepjs-verify.js +1 -1
- package/dist/cli/main.cjs +42 -3
- package/dist/cli/main.js +42 -3
- package/dist/cli/openBrowser.d.ts +23 -0
- package/dist/{diff-BNmCp_8I.cjs → diff-3ivpxBET.cjs} +83 -10
- package/dist/{diff-D5U3Ie2F.js → diff-DyilrTFJ.js} +83 -10
- package/dist/index.d.ts +1 -1
- package/dist/mcp/server.cjs +489 -0
- package/dist/mcp/server.d.ts +10 -0
- package/dist/mcp/server.js +489 -0
- package/dist/mcp/tools.d.ts +77 -0
- package/dist/sandbox/runProgram.d.ts +76 -0
- package/dist/sandbox/runRecord.d.ts +20 -0
- package/dist/snapshot/shoot.cjs +2 -1
- package/dist/snapshot/shoot.d.ts +2 -0
- package/dist/snapshot/shoot.js +2 -1
- package/dist/verify/report.d.ts +13 -0
- package/package.json +12 -11
- package/viewer/dist/assets/brepjs-cDw_z4Rj.js +60 -0
- package/viewer/dist/assets/index-BBdw65cO.js +4167 -0
- package/viewer/dist/assets/kernelWorker-DeA3Hcd0.js +1 -0
- package/viewer/dist/index.html +1 -1
- package/viewer/dist/wasm/occt-wasm.wasm +0 -0
- package/viewer/dist/assets/brepjs-CI5VXw8W.js +0 -57
- package/viewer/dist/assets/index-CiN0lKoi.js +0 -4167
- package/viewer/dist/assets/kernelWorker-BtcMpY8t.js +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { VerifyReport } from '../verify/report.js';
|
|
2
|
+
/** The verify report as serialized by the CLI (the report plus the top-level `ok` verdict). */
|
|
3
|
+
export type SerializedReport = VerifyReport & {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** Outcome of a sandboxed run. `completed` includes not-ok reports (the part built but failed checks). */
|
|
7
|
+
export type RunProgramResult = {
|
|
8
|
+
outcome: 'completed';
|
|
9
|
+
report: SerializedReport;
|
|
10
|
+
} | {
|
|
11
|
+
outcome: 'timeout';
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
} | {
|
|
14
|
+
outcome: 'crashed';
|
|
15
|
+
exitCode: number | null;
|
|
16
|
+
detail: string;
|
|
17
|
+
};
|
|
18
|
+
/** Outcome of a sandboxed export. `completed` carries the written artifact paths and any errors. */
|
|
19
|
+
export type ExportProgramResult = {
|
|
20
|
+
outcome: 'completed';
|
|
21
|
+
ok: boolean;
|
|
22
|
+
written: string[];
|
|
23
|
+
errors: string[];
|
|
24
|
+
} | {
|
|
25
|
+
outcome: 'timeout';
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
} | {
|
|
28
|
+
outcome: 'crashed';
|
|
29
|
+
exitCode: number | null;
|
|
30
|
+
detail: string;
|
|
31
|
+
};
|
|
32
|
+
export interface SandboxOptions {
|
|
33
|
+
/** Wall-clock budget; the child is SIGKILLed past it. Default 30000. */
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/** Child heap cap (`--max-old-space-size`), in MB. Default 2048. */
|
|
36
|
+
maxMemoryMb?: number;
|
|
37
|
+
/**
|
|
38
|
+
* CLI entry to spawn. Defaults to the in-repo TypeScript CLI (run via `tsx`), correct for
|
|
39
|
+
* dev/test. Production callers pass the built `dist/cli/main.js` (run via `node`). The runner is
|
|
40
|
+
* inferred from the extension: `.ts` → `npx tsx`, otherwise the current `node`.
|
|
41
|
+
*/
|
|
42
|
+
cliEntry?: string;
|
|
43
|
+
}
|
|
44
|
+
export type RunProgramOptions = SandboxOptions;
|
|
45
|
+
export interface ExportFormats {
|
|
46
|
+
step?: boolean;
|
|
47
|
+
glb?: boolean;
|
|
48
|
+
stl?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Clamp a caller-supplied limit to a positive, finite value, falling back to the default otherwise.
|
|
52
|
+
* Critical for the timeout: Node's `execFile` treats `timeout: 0` (and it ignores negatives) as
|
|
53
|
+
* "no timeout", which would silently disable the sandbox's only runaway protection.
|
|
54
|
+
*/
|
|
55
|
+
export declare function positiveOrDefault(value: number | undefined, fallback: number): number;
|
|
56
|
+
/** SIGKILL every in-flight sandbox process group now. Exported so a host can reap explicitly. */
|
|
57
|
+
export declare function killActiveSandboxes(signal?: NodeJS.Signals): void;
|
|
58
|
+
/**
|
|
59
|
+
* Install process-shutdown hooks that reap any in-flight sandbox process groups when THIS process
|
|
60
|
+
* (the host — e.g. the MCP server) terminates. Idempotent; call once at startup from an entrypoint.
|
|
61
|
+
*
|
|
62
|
+
* Rationale: the per-run timeout (`spawnCliOutcome`) only protects a run while the host is alive —
|
|
63
|
+
* its timer dies with the host. If the host is stopped (the agent disconnects) before a run's
|
|
64
|
+
* budget elapses, the `detached` sandbox group is in its own session and survives, burning a core
|
|
65
|
+
* indefinitely. These hooks SIGKILL every tracked group on the way down so a dying host doesn't
|
|
66
|
+
* leak its children. (A hard SIGKILL of the host can't be trapped — that residual needs the kernel's
|
|
67
|
+
* PR_SET_PDEATHSIG, which Node doesn't expose.)
|
|
68
|
+
*/
|
|
69
|
+
export declare function installSandboxShutdownHandlers(): void;
|
|
70
|
+
/** Execute `code` (an agent-authored `.brep.ts` module) in an isolated, resource-bounded child. */
|
|
71
|
+
export declare function runProgram(code: string, opts?: RunProgramOptions): Promise<RunProgramResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Execute `code` and export artifacts to `outDir`. Artifacts persist in `outDir` (the caller owns
|
|
74
|
+
* it); only the temp program directory is cleaned up. Returns the written paths and any errors.
|
|
75
|
+
*/
|
|
76
|
+
export declare function exportProgram(code: string, outDir: string, formats?: ExportFormats, opts?: SandboxOptions): Promise<ExportProgramResult>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RunProgramResult } from './runProgram.js';
|
|
2
|
+
import { VerifyMeasurements, VerifyTopology } from '../verify/report.js';
|
|
3
|
+
export interface RunRecord {
|
|
4
|
+
/** ISO-8601 capture time. */
|
|
5
|
+
timestamp: string;
|
|
6
|
+
/** The brepjs program source that was executed. */
|
|
7
|
+
program: string;
|
|
8
|
+
outcome: RunProgramResult['outcome'];
|
|
9
|
+
/** True only when the part built and passed all checks. */
|
|
10
|
+
ok: boolean;
|
|
11
|
+
/** sha256 of the program + a canonical digest of the outcome (stable for identical runs). */
|
|
12
|
+
resultHash: string;
|
|
13
|
+
/** Geometric summary — present only for completed runs. */
|
|
14
|
+
measurements?: VerifyMeasurements;
|
|
15
|
+
topology?: VerifyTopology;
|
|
16
|
+
}
|
|
17
|
+
/** Build a {@link RunRecord} from a program and its sandbox result. `now` is injectable for tests. */
|
|
18
|
+
export declare function buildRunRecord(program: string, result: RunProgramResult, now?: () => Date): RunRecord;
|
|
19
|
+
/** Append a record as one JSON line to `filePath` (creating it if absent). */
|
|
20
|
+
export declare function appendRunRecord(filePath: string, record: RunRecord): Promise<void>;
|
package/dist/snapshot/shoot.cjs
CHANGED
|
@@ -36,7 +36,8 @@ async function shoot(opts) {
|
|
|
36
36
|
width: 1200,
|
|
37
37
|
height: 900
|
|
38
38
|
});
|
|
39
|
-
const
|
|
39
|
+
const dimsParam = opts.dimensions === false ? "" : "&dims=1";
|
|
40
|
+
const target = `${server.url}/?dir=${encodeURIComponent(dir)}&file=${encodeURIComponent(rel)}&ui=0${dimsParam}`;
|
|
40
41
|
await page.goto(target, {
|
|
41
42
|
waitUntil: "domcontentloaded",
|
|
42
43
|
timeout: 3e4
|
package/dist/snapshot/shoot.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface ShootOptions extends AcquireOptions {
|
|
|
6
6
|
views?: readonly ViewName[];
|
|
7
7
|
/** Wall-clock ms to let the camera settle before each capture (default 400; raise on slow CI). */
|
|
8
8
|
settleMs?: number;
|
|
9
|
+
/** Burn the model's bbox dimensions into each PNG so the agent can read scale (default true). */
|
|
10
|
+
dimensions?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export interface ShootResult {
|
|
11
13
|
outDir: string;
|
package/dist/snapshot/shoot.js
CHANGED
|
@@ -33,7 +33,8 @@ async function shoot(opts) {
|
|
|
33
33
|
width: 1200,
|
|
34
34
|
height: 900
|
|
35
35
|
});
|
|
36
|
-
const
|
|
36
|
+
const dimsParam = opts.dimensions === false ? "" : "&dims=1";
|
|
37
|
+
const target = `${server.url}/?dir=${encodeURIComponent(dir)}&file=${encodeURIComponent(rel)}&ui=0${dimsParam}`;
|
|
37
38
|
await page.goto(target, {
|
|
38
39
|
waitUntil: "domcontentloaded",
|
|
39
40
|
timeout: 3e4
|
package/dist/verify/report.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface VerifyCheck {
|
|
|
6
6
|
export interface VerifyMeasurements {
|
|
7
7
|
volume?: number;
|
|
8
8
|
area?: number;
|
|
9
|
+
/** Volume centroid `[x, y, z]`. Absent when center-of-mass can't be computed. */
|
|
10
|
+
centerOfMass?: readonly [number, number, number];
|
|
9
11
|
bounds?: {
|
|
10
12
|
xMin: number;
|
|
11
13
|
xMax: number;
|
|
@@ -15,6 +17,15 @@ export interface VerifyMeasurements {
|
|
|
15
17
|
zMax: number;
|
|
16
18
|
};
|
|
17
19
|
}
|
|
20
|
+
/** Topology element counts — a quick structural fingerprint of a shape. */
|
|
21
|
+
export interface VerifyTopology {
|
|
22
|
+
faceCount: number;
|
|
23
|
+
edgeCount: number;
|
|
24
|
+
wireCount: number;
|
|
25
|
+
vertexCount: number;
|
|
26
|
+
/** True when every shell is manifold. Absent for shapes without shells (nothing to assess). */
|
|
27
|
+
manifold?: boolean;
|
|
28
|
+
}
|
|
18
29
|
/** A failure captured with whatever structured context it carried (a `BrepError` code/suggestion). */
|
|
19
30
|
export interface ErrorInfo {
|
|
20
31
|
message: string;
|
|
@@ -39,6 +50,8 @@ export interface VerifyReport {
|
|
|
39
50
|
shapeType: string | null;
|
|
40
51
|
checks: VerifyCheck[];
|
|
41
52
|
measurements: VerifyMeasurements;
|
|
53
|
+
/** Topology element counts. Absent when traversal fails on a degenerate shape. */
|
|
54
|
+
topology?: VerifyTopology;
|
|
42
55
|
errors: string[];
|
|
43
56
|
/** Structured copies of `errors`, carrying any `BrepError` code/suggestion. Drives `hints`. */
|
|
44
57
|
errorInfos: ErrorInfo[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs-verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Agent skill + verify/preview tooling for authoring parametric brepjs CAD code",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"bin": {
|
|
32
|
-
"brepjs-verify": "./dist/cli/main.js"
|
|
32
|
+
"brepjs-verify": "./dist/cli/main.js",
|
|
33
|
+
"brepjs-verify-mcp": "./dist/mcp/server.js"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"README.md"
|
|
41
42
|
],
|
|
42
43
|
"scripts": {
|
|
43
|
-
"build": "node scripts/copyReference.mjs && vite build && vite build --config viewer/vite.config.ts",
|
|
44
|
+
"build": "node scripts/copyReference.mjs && vite build && vite build --config viewer/vite.config.ts && node -e \"require('fs').chmodSync('dist/cli/main.js',0o755);require('fs').chmodSync('dist/cli/main.cjs',0o755);require('fs').chmodSync('dist/mcp/server.js',0o755)\"",
|
|
44
45
|
"typecheck": "tsc --noEmit && tsc -p viewer/tsconfig.json --noEmit && tsc -p bench/tsconfig.json",
|
|
45
46
|
"lint": "eslint src tests viewer bench",
|
|
46
47
|
"test": "vitest run",
|
|
@@ -51,9 +52,9 @@
|
|
|
51
52
|
"prepack": "npm run build"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@
|
|
55
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
55
56
|
"brepjs": "^18.0.0",
|
|
56
|
-
"commander": "^
|
|
57
|
+
"commander": "^15.0.0",
|
|
57
58
|
"occt-wasm": "^3.0.0",
|
|
58
59
|
"typescript": "^6.0.3"
|
|
59
60
|
},
|
|
@@ -61,20 +62,20 @@
|
|
|
61
62
|
"puppeteer": "^25.0.4"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@anthropic-ai/sdk": "0.
|
|
65
|
+
"@anthropic-ai/sdk": "0.102.0",
|
|
65
66
|
"@react-three/drei": "^10.7.7",
|
|
66
67
|
"@react-three/fiber": "^9.6.1",
|
|
67
|
-
"@types/node": "
|
|
68
|
+
"@types/node": "25.9.2",
|
|
68
69
|
"@types/react": "^19.2.15",
|
|
69
70
|
"@types/react-dom": "^19.2.3",
|
|
70
71
|
"@types/three": "^0.184.1",
|
|
71
72
|
"@vitejs/plugin-react": "^6.0.2",
|
|
72
|
-
"brepjs-viewer": "
|
|
73
|
+
"brepjs-viewer": "*",
|
|
73
74
|
"eslint": "^10.4.0",
|
|
74
|
-
"react": "
|
|
75
|
-
"react-dom": "
|
|
75
|
+
"react": "19.2.7",
|
|
76
|
+
"react-dom": "19.2.7",
|
|
76
77
|
"three": "^0.184.0",
|
|
77
|
-
"tsx": "
|
|
78
|
+
"tsx": "4.22.4",
|
|
78
79
|
"vite": "^8.0.0",
|
|
79
80
|
"vite-plugin-dts": "^5.0.1",
|
|
80
81
|
"vitest": "^4.0.0",
|