@inneranimalmedia/agentsam-occt 0.0.0-stage → 2.6.15
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/LICENSE +110 -0
- package/README.md +99 -2
- package/agentsam.package.json +60 -0
- package/dist/browser.d.ts +32 -0
- package/dist/browser.js +71 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/native-provider.d.mts +106 -0
- package/dist/native-provider.mjs +177 -0
- package/dist/native-provider.mjs.map +1 -0
- package/dist/native-session.d.mts +8 -0
- package/dist/native-session.mjs +64 -0
- package/dist/native-session.mjs.map +1 -0
- package/native/CMakeLists.txt +47 -0
- package/native/engine.cpp +864 -0
- package/native/engine.hpp +2 -0
- package/native/main.cpp +123 -0
- package/native/sketch_solver.cpp +198 -0
- package/native/sketch_solver.hpp +5 -0
- package/package.json +40 -4
- package/src/browser.ts +92 -0
- package/src/index.js +24 -0
- package/src/native-provider.mjs +156 -0
- package/src/native-session.d.mts +5 -0
- package/src/native-session.mjs +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Sam Primeaux, d/b/a Inner Animal Media
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@inneranimalmedia/agentsam-occt`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The canonical reusable AgentSam OCCT capability package. It owns the shared provider contract, the browser Boolean/export adapter, and the native C++ engine source. Consumers do not maintain their own copies of OCCT operation code.
|
|
4
|
+
|
|
5
|
+
## Ownership and runtime boundaries
|
|
6
|
+
|
|
7
|
+
- `native/` is the single C++ source of truth for the `agentsam-occt` executable.
|
|
8
|
+
- `services/cad/occt/` is a compatibility build entrypoint that delegates to this package; it contains no second engine implementation.
|
|
9
|
+
- `src/native-provider.mjs` adapts the installed native executable to the existing `cad.project.v1` provider contract. The older SDK path `src/lib/cad/occt-native-provider.mjs` is a compatibility re-export only.
|
|
10
|
+
- `src/browser.ts` owns the browser Boolean-to-GLB operation. The host injects an OpenCascade.js loader so each site can resolve its own WASM asset and defer loading until modeling is requested.
|
|
11
|
+
- `@inneranimalmedia/agentsam-3d-viewer` is the presentation-only viewer package. It reads GLB/GLTF/STL; it is not a second geometry kernel.
|
|
12
|
+
|
|
13
|
+
The browser and native adapters are separate builds of the same OpenCascade kernel family because WebAssembly must run in the browser while the C++ executable runs on a native host. They share one operation contract and do not duplicate application-level geometry algorithms.
|
|
14
|
+
|
|
15
|
+
## Native build
|
|
16
|
+
|
|
17
|
+
The existing build entrypoint is preserved:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
cmake -S services/cad/occt -B /tmp/agentsam-occt-build -G Ninja \
|
|
21
|
+
-DAGENTSAM_OCCT_PREFIX="$(brew --prefix opencascade)" \
|
|
22
|
+
-DAGENTSAM_BOOST_INCLUDE_DIR="$(brew --prefix boost)/include"
|
|
23
|
+
cmake --build /tmp/agentsam-occt-build
|
|
24
|
+
/tmp/agentsam-occt-build/agentsam-occt --doctor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A supported OCCT development prefix and C++20 toolchain are required. The package does not silently install a kernel or fall back to approximate geometry. Native consumers set `AGENTSAM_OCCT_BIN` to the absolute path of the verified executable; the default is `~/.agentsam/bin/agentsam-occt`.
|
|
28
|
+
|
|
29
|
+
The SDK native provider maps `design_model_build` for box solids or persisted feature logs and `design_model_inspect` for STEP. Existing `design_model_build` / `design_model_export` tools accept `engine: "occt"` and `element_id` to replay the selected immutable project revision’s `nativeHistory`; formats include STEP, BREP, glTF and IFC. Arbitrary caller-supplied feature histories are not accepted by the project tool. The legacy CLI remains compatible.
|
|
30
|
+
|
|
31
|
+
## Browser use
|
|
32
|
+
|
|
33
|
+
A host supplies its OpenCascade.js initializer and WASM URL once, then calls the shared provider's `createBooleanGLB(parameters)`. The kernel is not initialized merely by importing the package. Export filenames are unique per provider instance and temporary WASM filesystem files are removed after export.
|
|
34
|
+
|
|
35
|
+
## Workflow execution
|
|
36
|
+
|
|
37
|
+
PrimeTech remains the versioned procedure/orchestration layer. Python procedures run through the existing authorized `sam.superbash` operation and produce evidence receipts; neither PrimeTech nor SuperBash is a second CAD engine or a second terminal daemon.
|
|
38
|
+
|
|
39
|
+
## Release status
|
|
40
|
+
|
|
41
|
+
This package is an SDK workspace package and remains private pending native packaging/portability review. Do not publish or claim a standalone native installer until the platform-specific executable build and install path are validated.
|
|
42
|
+
|
|
43
|
+
## Persistent native project engine
|
|
44
|
+
|
|
45
|
+
`agentsam-occt --serve` reads one JSON request per line and writes prefixed `AGENTSAM_RESULT=` JSON receipts. OCCT diagnostic output is not a receipt. `@inneranimalmedia/agentsam-occt/session` supplies an ordered Node client with a timeout and explicit close. Tauri owns one process per project, validates project paths and checkpoints the operation log atomically. The existing hosted design document stores `nativeHistory`; no second project database is introduced.
|
|
46
|
+
|
|
47
|
+
All native coordinates are **millimetres, Z-up**. Viewport conversion is explicit; glTF export uses **metres, Y-up**. The architectural plan retains its existing inches and centre-ratio opening positions.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{"action":"open","projectId":"my-existing-project"}
|
|
51
|
+
{"action":"apply","operation":{"id":"wall-001","type":"wall","start":[0,0],"end":[5000,0],"thickness":200,"height":3000}}
|
|
52
|
+
{"action":"apply","operation":{"id":"door-001","type":"opening","host":"wall-001","offset":1000,"width":900,"height":2100}}
|
|
53
|
+
{"action":"mesh","id":"wall-001","deflection":0.5}
|
|
54
|
+
{"action":"replace","operation":{"id":"wall-001","type":"wall","start":[0,0],"end":[5000,0],"thickness":200,"height":3200}}
|
|
55
|
+
{"action":"undo"}
|
|
56
|
+
{"action":"state"}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The unmodified wall measures 3,000,000,000 mm³. Its door cut removes 378,000,000 mm³, leaving 2,622,000,000 mm³. Mesh triangles are produced by OCCT tessellation of that same checked BRep. Opening overlap, out-of-bounds cuts, invalid solids and stale revisions reject the operation without advancing the log.
|
|
60
|
+
|
|
61
|
+
Supported feature definitions:
|
|
62
|
+
|
|
63
|
+
| Type | Parameters |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `profile` | Closed 3D `points`, or a `sketch` solver document plus `planeZ` |
|
|
66
|
+
| `extrude` | `profile` ID and 3D `vector` |
|
|
67
|
+
| `revolve` | `profile`, `origin`, `axis`, `angle` in degrees |
|
|
68
|
+
| `sweep` | `profile` and 3D polyline `path` |
|
|
69
|
+
| `box`, `cylinder` | Dimensions / radius and height |
|
|
70
|
+
| `wall`, `opening` | Plan endpoints / host, left-edge offset, width, height, optional sill |
|
|
71
|
+
| `cut`, `fuse`, `common` | `base` and `tool` IDs |
|
|
72
|
+
| `transform` | `base`, optional `translation`, `axis` and `angle` |
|
|
73
|
+
| `fillet`, `chamfer` | `base`, `radius`, zero-based `edges` |
|
|
74
|
+
| `shell` | `base`, signed `distance`, zero-based closing `faces` |
|
|
75
|
+
| `offset` | `base`, signed `distance` |
|
|
76
|
+
|
|
77
|
+
`apply`, `replace`, `syncPlan`, `undo`, and `redo` replay into a candidate model before committing. Replacements append `$replace` events; they never erase the original feature definition. `syncPlan` appends a `$syncPlan` event for the existing plan-owned walls/openings while preserving non-plan features. `state` returns the complete operations array and cursor; `open` replays those values on another process. Every request can specify `expectedRevision` for optimistic concurrency within a live process.
|
|
78
|
+
|
|
79
|
+
**Identity limit:** element and feature IDs persist through replay and parameter edits. Face and edge indices are local to the evaluated shape. Indexed features record a base geometry fingerprint; changing that geometry rejects stale selectors and requires reselection. This does not claim to solve general persistent topological naming.
|
|
80
|
+
|
|
81
|
+
### Solver component
|
|
82
|
+
|
|
83
|
+
`agentsam-sketch-solver` is a separate CMake static library. `solveSketch` accepts `points` with `{id,x,y}` and constraints: `fixed`, `coincident`, `horizontal`, `vertical`, `distance`, `parallel`, `perpendicular`, and `equalLength`. Segment constraints use point IDs `a,b`, with `c,d` for a second segment. It returns `converged`, residual, degrees of freedom and `constrained`, `underconstrained`, or `inconsistent` status. Inconsistent profiles do not extrude. SamSketch exposes line-axis and fixed-length solving and saves the constraints in the same design document.
|
|
84
|
+
|
|
85
|
+
### Drawings and exports
|
|
86
|
+
|
|
87
|
+
`export` accepts an element ID, `format` and an absolute output path. STEP and BREP are reopened and measured before success. glTF is an embedded-buffer scene derived from the BRep mesh. IFC4 exports a tessellated `IfcWall` or proxy, semantic opening elements and `IfcRelVoidsElement` with deterministic project/element GUIDs. This is reference geometry; it does not manufacture editable FreeCAD constraints or a construction-ready model from an imported GLB.
|
|
88
|
+
|
|
89
|
+
SVG requests use `mode: "section"` with `origin`/`direction` or `mode: "projection"` with a viewing direction. Sections use OCCT intersection; projections use OCCT hidden-line removal. Curved drawing edges are sampled into SVG paths. Plan controls cut horizontally at 1,200 mm; sections cut through the selected wall centre; elevations use the wall normal. These are geometric drawings, not annotated construction sheets.
|
|
90
|
+
|
|
91
|
+
### Portable desktop runtime
|
|
92
|
+
|
|
93
|
+
`npm --prefix packages/agentsam-desktop-shell run prepare:cad` compiles this source and stages `generated/runtime/cad`. On macOS it recursively copies non-system dylibs, rewrites dependencies to `@loader_path`, removes development rpaths, includes license notices, signs the binaries and probes a relocated copy with a clean environment. The Tauri resource map includes this directory at `runtime/cad`. Normal bundle scripts and `bundle:shell-only` run this preparation. Other platform bundles fail explicitly until their dependency staging is implemented.
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
AGENTSAM_OCCT_BIN="$PWD/packages/agentsam-desktop-shell/src-tauri/generated/runtime/cad/agentsam-occt" \
|
|
97
|
+
node --test packages/agentsam-occt/test/native-engine.test.mjs
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The native suite verifies solid/mesh volume, immutable replay, parameter undo, failed-operation rollback, exports, drawings, solver consistency and each modeled feature family. Independent IFC validation additionally requires IfcOpenShell; an actual FreeCAD installation is required to validate native FCStd authoring. Existing DreamHouse V1.5 Blender/GLB revisions must not be relabeled as a V1.5 native BIM.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "agentsam.package.v1",
|
|
3
|
+
"id": "agentsam-occt",
|
|
4
|
+
"name": "@inneranimalmedia/agentsam-occt",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"class": "package",
|
|
7
|
+
"status": "in-development",
|
|
8
|
+
"catalog_status": "needs-review",
|
|
9
|
+
"languages": [
|
|
10
|
+
"cpp",
|
|
11
|
+
"javascript",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"execution_domains": [
|
|
15
|
+
"browser",
|
|
16
|
+
"desktop",
|
|
17
|
+
"local"
|
|
18
|
+
],
|
|
19
|
+
"purpose": "One OpenCascade engine contract with shared browser-WASM and native C++ adapters for AgentSam CAD surfaces.",
|
|
20
|
+
"install": [
|
|
21
|
+
{
|
|
22
|
+
"type": "npm-workspace",
|
|
23
|
+
"package": "@inneranimalmedia/agentsam-occt",
|
|
24
|
+
"command": "npm install --workspace @inneranimalmedia/agentsam-occt"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"registry": {
|
|
28
|
+
"kind": "npm-workspace",
|
|
29
|
+
"name": "@inneranimalmedia/agentsam-occt",
|
|
30
|
+
"public_claim": false
|
|
31
|
+
},
|
|
32
|
+
"use_when": [
|
|
33
|
+
"Adding OCCT-backed geometry to a browser, desktop, or local CAD application",
|
|
34
|
+
"Reusing the canonical native OCCT provider and browser Boolean adapter"
|
|
35
|
+
],
|
|
36
|
+
"avoid_when": [
|
|
37
|
+
"Displaying an existing GLB/GLTF/STL without geometry edits; use agentsam-3d-viewer",
|
|
38
|
+
"Creating a parallel native engine, provider implementation, or operation registry"
|
|
39
|
+
],
|
|
40
|
+
"commands": [],
|
|
41
|
+
"topics": [
|
|
42
|
+
"cad",
|
|
43
|
+
"geometry",
|
|
44
|
+
"opencascade",
|
|
45
|
+
"occt",
|
|
46
|
+
"wasm",
|
|
47
|
+
"native-cpp",
|
|
48
|
+
"boolean-operations",
|
|
49
|
+
"step"
|
|
50
|
+
],
|
|
51
|
+
"evidence": {
|
|
52
|
+
"directory": "packages/agentsam-occt",
|
|
53
|
+
"native_source": "packages/agentsam-occt/native/main.cpp",
|
|
54
|
+
"compatibility_build_entry": "services/cad/occt/CMakeLists.txt",
|
|
55
|
+
"tests": [
|
|
56
|
+
"packages/agentsam-occt/test/contracts.test.mjs",
|
|
57
|
+
"packages/agentsam-occt/test/browser-provider.test.mjs"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser OCCT adapter. Hosts inject the OpenCascade.js loader so each app can
|
|
3
|
+
* resolve its own WASM asset URL and keep the 50 MB kernel out of initial loads.
|
|
4
|
+
* All Boolean and GLB-export logic lives here rather than in each app.
|
|
5
|
+
*/
|
|
6
|
+
export type CadParameters = {
|
|
7
|
+
outerRadius: number;
|
|
8
|
+
cutterRadius: number;
|
|
9
|
+
cutX: number;
|
|
10
|
+
cutY: number;
|
|
11
|
+
cutZ: number;
|
|
12
|
+
};
|
|
13
|
+
export type OcctBrowserRuntime = Record<string, any>;
|
|
14
|
+
export type OcctBrowserLoader = () => Promise<OcctBrowserRuntime>;
|
|
15
|
+
export declare function createOcctBrowserProvider({ loadEngine }: {
|
|
16
|
+
loadEngine: OcctBrowserLoader;
|
|
17
|
+
}): {
|
|
18
|
+
createBooleanGLB: (parameters: CadParameters) => Promise<ArrayBuffer>;
|
|
19
|
+
doctor: () => Promise<{
|
|
20
|
+
engine: string;
|
|
21
|
+
available: boolean;
|
|
22
|
+
ready: boolean;
|
|
23
|
+
execution_lane: string;
|
|
24
|
+
reason?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
engine: string;
|
|
27
|
+
available: boolean;
|
|
28
|
+
ready: boolean;
|
|
29
|
+
reason: string;
|
|
30
|
+
execution_lane: string;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export function createOcctBrowserProvider({ loadEngine }) {
|
|
2
|
+
if (typeof loadEngine !== 'function')
|
|
3
|
+
throw new Error('occt_browser_loader_required');
|
|
4
|
+
let engine = null;
|
|
5
|
+
let outputSequence = 0;
|
|
6
|
+
async function openCad() {
|
|
7
|
+
if (!engine) {
|
|
8
|
+
engine = Promise.resolve().then(loadEngine).catch(error => {
|
|
9
|
+
engine = null;
|
|
10
|
+
throw error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return engine;
|
|
14
|
+
}
|
|
15
|
+
async function createBooleanGLB(parameters) {
|
|
16
|
+
const { outerRadius, cutterRadius, cutX, cutY, cutZ } = parameters;
|
|
17
|
+
if (![outerRadius, cutterRadius, cutX, cutY, cutZ].every(Number.isFinite) || outerRadius <= 0 || cutterRadius <= 0) {
|
|
18
|
+
throw new Error('occt_invalid_boolean_parameters');
|
|
19
|
+
}
|
|
20
|
+
const oc = await openCad();
|
|
21
|
+
const outer = new oc.BRepPrimAPI_MakeSphere_1(outerRadius);
|
|
22
|
+
const cutter = new oc.BRepPrimAPI_MakeSphere_1(cutterRadius);
|
|
23
|
+
const transform = new oc.gp_Trsf_1();
|
|
24
|
+
transform.SetTranslation_1(new oc.gp_Vec_4(cutX, cutY, cutZ));
|
|
25
|
+
const location = new oc.TopLoc_Location_2(transform);
|
|
26
|
+
const cutterShape = cutter.Shape().Moved(location, false);
|
|
27
|
+
const operation = new oc.BRepAlgoAPI_Cut_3(outer.Shape(), cutterShape, new oc.Message_ProgressRange_1());
|
|
28
|
+
operation.Build(new oc.Message_ProgressRange_1());
|
|
29
|
+
if (typeof operation.IsDone === 'function' && !operation.IsDone()) {
|
|
30
|
+
throw new Error('occt_boolean_cut_failed');
|
|
31
|
+
}
|
|
32
|
+
const shape = operation.Shape();
|
|
33
|
+
new oc.BRepMesh_IncrementalMesh_2(shape, 0.05, false, 0.15, false);
|
|
34
|
+
const document = new oc.TDocStd_Document(new oc.TCollection_ExtendedString_1());
|
|
35
|
+
const shapeTool = oc.XCAFDoc_DocumentTool.ShapeTool(document.Main()).get();
|
|
36
|
+
shapeTool.SetShape(shapeTool.NewShape(), shape);
|
|
37
|
+
// Unique names prevent overlapping export calls from overwriting each other in WASM FS.
|
|
38
|
+
const filename = `/agentsam-occt-${++outputSequence}.glb`;
|
|
39
|
+
try {
|
|
40
|
+
const writer = new oc.RWGltf_CafWriter(new oc.TCollection_AsciiString_2(filename), true);
|
|
41
|
+
const ok = writer.Perform_2(new oc.Handle_TDocStd_Document_2(document), new oc.TColStd_IndexedDataMapOfStringString_1(), new oc.Message_ProgressRange_1());
|
|
42
|
+
if (ok === false)
|
|
43
|
+
throw new Error('occt_glb_export_failed');
|
|
44
|
+
const raw = oc.FS.readFile(filename, { encoding: 'binary' });
|
|
45
|
+
const bytes = Uint8Array.from(raw);
|
|
46
|
+
if (bytes.length < 12 || bytes[0] !== 0x67 || bytes[1] !== 0x6c || bytes[2] !== 0x54 || bytes[3] !== 0x46) {
|
|
47
|
+
throw new Error('occt_glb_export_invalid');
|
|
48
|
+
}
|
|
49
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
try {
|
|
53
|
+
oc.FS.unlink(filename);
|
|
54
|
+
}
|
|
55
|
+
catch { /* Preserve the primary geometry/export error. */ }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function doctor() {
|
|
59
|
+
try {
|
|
60
|
+
await openCad();
|
|
61
|
+
return { engine: 'occt', available: true, ready: true, execution_lane: 'browser-wasm' };
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return { engine: 'occt', available: false, ready: false,
|
|
65
|
+
reason: error instanceof Error ? error.message : 'occt_browser_kernel_unavailable',
|
|
66
|
+
execution_lane: 'browser-wasm' };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { createBooleanGLB, doctor };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,yBAAyB,CAAC,EAAE,UAAU,EAAqC;IACzF,IAAI,OAAO,UAAU,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACtF,IAAI,MAAM,GAAuC,IAAI,CAAC;IACtD,IAAI,cAAc,GAAG,CAAC,CAAC;IAEvB,KAAK,UAAU,OAAO;QACpB,IAAI,CAAC,MAAM,EAAE,CA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ClF,cAAc,EAAE,cAAc,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function toMillimeters(value: any, units: any): number;
|
|
2
|
+
/** Shared AgentSam OCCT provider contract. Native C++ source lives in ./native. */
|
|
3
|
+
export const OCCT_ENGINE_ID: "occt";
|
|
4
|
+
export const OCCT_PROVIDER_CONTRACT: "agentsam.occt.provider.v1";
|
|
5
|
+
/** Canonical SDK operations currently mapped to the native provider. */
|
|
6
|
+
export const OCCT_NATIVE_OPERATIONS: readonly string[];
|
|
7
|
+
/** Provider capabilities; intentionally narrower than raw CLI capabilities. */
|
|
8
|
+
export const OCCT_NATIVE_CAPABILITIES: readonly string[];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Shared AgentSam OCCT provider contract. Native C++ source lives in ./native. */
|
|
2
|
+
export const OCCT_ENGINE_ID = 'occt';
|
|
3
|
+
export const OCCT_PROVIDER_CONTRACT = 'agentsam.occt.provider.v1';
|
|
4
|
+
/** Canonical SDK operations currently mapped to the native provider. */
|
|
5
|
+
export const OCCT_NATIVE_OPERATIONS = Object.freeze([
|
|
6
|
+
'design_model_build',
|
|
7
|
+
'design_model_inspect',
|
|
8
|
+
]);
|
|
9
|
+
/** Provider capabilities; intentionally narrower than raw CLI capabilities. */
|
|
10
|
+
export const OCCT_NATIVE_CAPABILITIES = Object.freeze([
|
|
11
|
+
'design.solid.create',
|
|
12
|
+
'design.solid.inspect',
|
|
13
|
+
'design.solid.export.step',
|
|
14
|
+
]);
|
|
15
|
+
export function toMillimeters(value, units) {
|
|
16
|
+
if (units !== 'mm' && units !== 'in')
|
|
17
|
+
throw new Error('occt_explicit_units_required');
|
|
18
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
19
|
+
throw new Error('occt_invalid_dimension');
|
|
20
|
+
const size = units === 'in' ? value * 25.4 : value;
|
|
21
|
+
if (size <= 0 || size > 1000000)
|
|
22
|
+
throw new Error('occt_invalid_dimension');
|
|
23
|
+
return size;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAElE,wEAAwE;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;IAClD,oBAAoB;IACpB,sBAAsB;CACvB,CAAC,CAAC;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,qBAAqB;IACrB,sBAAsB;IACtB,0BAA0B;CAC3B,CAAC,CAAC;AAEH,MAAM,UAAU,aAAa,CAAC,KAAK,EAAE,KAAK;IACxC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACpG,MAAM,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Native-only, fail-closed implementation of a small subset of cad.project.v1 operations.
|
|
2
|
+
* Engine availability is established from a real process receipt, never a UI claim.
|
|
3
|
+
*/
|
|
4
|
+
export function createOcctNativeProvider({ binary, runProcess, timeoutMs, }?: {
|
|
5
|
+
binary?: any;
|
|
6
|
+
runProcess?: any;
|
|
7
|
+
timeoutMs?: number | undefined;
|
|
8
|
+
}): {
|
|
9
|
+
id: string;
|
|
10
|
+
executionLanes: string[];
|
|
11
|
+
capabilities: string[];
|
|
12
|
+
discover: () => Promise<{
|
|
13
|
+
engine: string;
|
|
14
|
+
available: boolean;
|
|
15
|
+
ready: boolean;
|
|
16
|
+
version: any;
|
|
17
|
+
capabilities: any;
|
|
18
|
+
operations: string[];
|
|
19
|
+
execution_lane: string;
|
|
20
|
+
binary: any;
|
|
21
|
+
reason?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
engine: string;
|
|
24
|
+
available: boolean;
|
|
25
|
+
ready: boolean;
|
|
26
|
+
reason: any;
|
|
27
|
+
execution_lane: string;
|
|
28
|
+
version?: undefined;
|
|
29
|
+
capabilities?: undefined;
|
|
30
|
+
operations?: undefined;
|
|
31
|
+
binary?: undefined;
|
|
32
|
+
}>;
|
|
33
|
+
doctor: () => Promise<{
|
|
34
|
+
engine: string;
|
|
35
|
+
available: boolean;
|
|
36
|
+
ready: boolean;
|
|
37
|
+
version: any;
|
|
38
|
+
capabilities: any;
|
|
39
|
+
operations: string[];
|
|
40
|
+
execution_lane: string;
|
|
41
|
+
binary: any;
|
|
42
|
+
reason?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
engine: string;
|
|
45
|
+
available: boolean;
|
|
46
|
+
ready: boolean;
|
|
47
|
+
reason: any;
|
|
48
|
+
execution_lane: string;
|
|
49
|
+
version?: undefined;
|
|
50
|
+
capabilities?: undefined;
|
|
51
|
+
operations?: undefined;
|
|
52
|
+
binary?: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
execute: (operation: any, input?: {}, ctx?: {}) => Promise<{
|
|
55
|
+
verified: boolean;
|
|
56
|
+
engine: string;
|
|
57
|
+
operation: string;
|
|
58
|
+
volume_mm3: any;
|
|
59
|
+
units: string;
|
|
60
|
+
artifact_path: any;
|
|
61
|
+
} | {
|
|
62
|
+
engine: string;
|
|
63
|
+
operation: any;
|
|
64
|
+
verified: boolean;
|
|
65
|
+
native_version: any;
|
|
66
|
+
shape: string;
|
|
67
|
+
element_id: any;
|
|
68
|
+
volume_mm3: any;
|
|
69
|
+
feature_cursor: any;
|
|
70
|
+
operation_count: any;
|
|
71
|
+
artifact: {
|
|
72
|
+
path: any;
|
|
73
|
+
format: any;
|
|
74
|
+
size_bytes: any;
|
|
75
|
+
sha256: any;
|
|
76
|
+
};
|
|
77
|
+
dimensions_mm?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
engine: string;
|
|
80
|
+
operation: any;
|
|
81
|
+
verified: boolean;
|
|
82
|
+
native_version: any;
|
|
83
|
+
shape: string;
|
|
84
|
+
dimensions_mm: number[];
|
|
85
|
+
volume_mm3: any;
|
|
86
|
+
artifact: {
|
|
87
|
+
path: any;
|
|
88
|
+
format: string;
|
|
89
|
+
size_bytes: any;
|
|
90
|
+
sha256: any;
|
|
91
|
+
};
|
|
92
|
+
element_id?: undefined;
|
|
93
|
+
feature_cursor?: undefined;
|
|
94
|
+
operation_count?: undefined;
|
|
95
|
+
}>;
|
|
96
|
+
inspect: (artifact: any, ctx: any) => Promise<{
|
|
97
|
+
verified: boolean;
|
|
98
|
+
engine: string;
|
|
99
|
+
operation: string;
|
|
100
|
+
volume_mm3: any;
|
|
101
|
+
units: string;
|
|
102
|
+
artifact_path: any;
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
105
|
+
export { OCCT_NATIVE_OPERATIONS };
|
|
106
|
+
import { OCCT_NATIVE_OPERATIONS } from './index.js';
|