diff --git a/.gitignore b/.gitignore index b64df1b..d507561 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,3 @@ Thumbs.db .vscode/ *.swp *.swo - -# Claude Code local settings (machine-specific) -.claude/settings.local.json diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index b99e8ab..0000000 --- a/.mcp.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "mcpServers": { - "sketchforge-scene-bridge": { - "command": "npm", - "args": ["run", "start", "--silent", "--prefix", "apps/mcp"], - "env": { - "SKETCHFORGE_BASE_URL": "http://127.0.0.1:3000" - } - } - } -} diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index e99689d..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,93 +0,0 @@ -# SketchForge-3D — AI Scene Bridge (fork) - -## What this fork adds - -Upstream SketchForge is a local-first, browser-based CAD editor. This fork adds an -**AI scene bridge** so an MCP server (driven by Claude) can push parametric 3D scenes -into the running editor. A later V2 flips the MCP into the source of truth over a live -connection (see `docs/scene-bridge/PLAN.md` → V2). - -We are **not** rewriting the editor. All work in this fork is **additive**. - -## The one fact that governs the whole design - -The editor's source of truth is **browser-origin storage**, not the server: - -- **Project shapes → IndexedDB.** DB `sketchForge.projectShapes`, store `projectShapes`, - `keyPath: "id"`, record shape `{ id, revision, shapes: WorkplaneShape[], updatedAt }`. - (See the persistence block in `apps/web/src/app/page.tsx`, ~lines 44–135.) -- **Dashboard / project metadata → localStorage.** See the projects-storage key and the - `readStoredProjects` / merge helpers in `page.tsx`. Confirm the exact key from source — - do not hardcode a guessed string. -- **The editor opens a project via URL:** `/?editor=1&project=`. There is also - a `codexBooleanCase` test param. - -An MCP server is a Node process and **cannot write browser IndexedDB/localStorage -directly** — that storage is sandboxed to the page origin. Therefore the bridge is always: - -``` -MCP (Node) → local HTTP route (Next server) → staged command file on disk - → poller inside Home (page.tsx) calls the EXISTING updateProjectShapes() - handler (writes IndexedDB + localStorage + a winning project revision) - → the editor's initialShapes/projectRevision props change → its existing - rehydration effect (~line 4354) re-renders the scene -``` - -Never attempt to have the Node side write the scene store. If a design idea requires that, -it is wrong — re-read this section. - -## Data contract - -`WorkplaneShape` in `apps/web/src/types/sketchforge.ts` is THE contract. Key semantics: - -- A cutter is an ordinary shape with `hole: true`. -- A boolean/combined result carries its parts in `groupedShapes: WorkplaneShape[]`. -- The `ShapeKind` union (18 kinds) is the validation source of truth — wider than the - toolbar catalog (11). `shapeCatalog.ts` / `workplaneShapes.ts` hold per-kind **defaults + - canonicalisation**, NOT ranges. Do not hand-author ranges: import and reuse - `canonicalizeShape` + the per-kind defaults as the validator (the monorepo makes this a - direct import). Some kinds need extra data (`text` → text/font, `mesh` → importedMesh); - the *generatable* subset is smaller than the union and is model guidance, not the enum. - -Claude's job is emitting **valid `WorkplaneShape[]` JSON**. Manifold WASM (client-side) -does the actual CSG/meshing. Do **not** do mesh maths on the server. - -## Hard rules - -- **Additive only.** Do not refactor, rename, or reformat existing files. Do not load - `SketchForgeEditor.tsx` (~5,700 lines) whole — grep for the one hook you need. -- **Reuse, don't reimplement.** - - Copy the `isLocalSameOriginRequest` guard from an existing route - (`apps/web/src/app/api/local-download/route.ts`) into the new route. - - The IndexedDB/localStorage helpers in `page.tsx` (`saveProjectShapes`, etc.) are - **module-private** — do not import them. Drive persistence through the editor's - existing `onProjectShapesChange` handler, `updateProjectShapes` (in `Home`), which - already writes IndexedDB + localStorage + a winning revision in one place. The bridge - never calls `saveProjectShapes` or sets a project revision itself — `saveProjectShapes` - silently drops any revision not greater than the current one. -- **Pin upstream.** This is an alpha repo; internal shapes churn. Forked from upstream - commit: ``. Do not chase `main`. -- **Keep transport swappable.** Put the scene-delivery mechanism behind a small - `SceneTransport` interface so V2 can replace the poller with a WebSocket without - touching the route or the MCP tools. - -## Where new things go - -- Bridge route: `apps/web/src/app/api/scene/route.ts` -- Client poller: a hook called from `Home` in `apps/web/src/app/page.tsx` (it needs - `updateProjectShapes` + project state). NOT a new `components/` module — those can't - reach the private helpers, and `Home` is where project lifecycle lives. -- MCP server: `apps/mcp/` (new workspace; imports `WorkplaneShape` from `apps/web/src/types`) -- Staged scenes: `.codex/pending-scenes/.json` (mirror the existing `.codex/` convention) - -## Commands - -- `npm run dev` — app at http://127.0.0.1:3000 -- `npm run typecheck` -- vitest tests live in `tests/` - -## Working agreement - -Read `docs/scene-bridge/PLAN.md` before each phase and do its orientation step. -Work **one phase per session**. Confirm your understanding and the plan before writing code. -End each session with a short handoff note (what changed, what's next, open questions). diff --git a/README.md b/README.md index 65636dd..96b0103 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ No login. No server project storage. No heavyweight CAD install just to make a u - **Boolean Intersection** - keep only the geometry where selected solid and hole shapes overlap. - **STL import** - bring outside models into the same workspace as primitives. - **STL and OBJ export** - export selected objects or the whole scene. -- **AI scene bridge (MCP)** - drive the editor from Claude: an MCP server pushes parametric scenes into the live workplane. See [AI Scene Bridge (MCP)](#ai-scene-bridge-mcp). - **Fast browser stack** - Next.js, React, TypeScript, Three.js, and Manifold/CSG geometry tooling. ## Demo @@ -163,59 +162,17 @@ npm run export Build with static export mode enabled. -## AI Scene Bridge (MCP) - -This fork adds an **AI scene bridge** so an MCP server (driven by Claude) can push parametric 3D scenes straight into the running editor. Claude emits `WorkplaneShape` JSON; the editor renders it with the same Manifold/CSG pipeline used for hand-built shapes. Geometry stays client-side — the bridge only stages a command on disk that an in-page poller applies through the editor's existing save path, so the Node side never touches your browser project storage. - -### Enable bridge mode - -Start the app (`npm run dev`), then open the editor with the `bridge` flag and any project id: - -```text -http://127.0.0.1:3000/?bridge=1&project=my-first-scene -``` - -The project id does not need to exist yet — the first scene push creates and opens it. Reloading keeps the scene (it lives in browser storage), and an incoming push is deferred while you are dragging a shape. - -### Connect the MCP server - -The MCP server lives in [`apps/mcp/`](apps/mcp) and is registered for Claude Code in [`.mcp.json`](.mcp.json). Install its dependencies once, then restart Claude Code so it picks up the `sketchforge-scene-bridge` server and approve it when prompted: - -```bash -npm install --prefix apps/mcp -``` - -It talks to the running app at `SKETCHFORGE_BASE_URL` (default `http://127.0.0.1:3000`). To run it standalone for an MCP inspector: - -```bash -npm run start --prefix apps/mcp -``` - -### Tools - -| Tool | Purpose | -| --- | --- | -| `list_kinds` | List shape kinds, default sizes, and example scenes. Call this first. | -| `set_scene` | Replace a project's scene (unknown ids are created automatically). | -| `add_shapes` | Append shapes to the current scene. | -| `get_scene` | Read the current scene back to iterate on it. | - -With the app open in bridge mode, ask Claude for something like *"a 40 mm phone stand with a cable slot"* and the shapes appear in the workplane within a second; follow up with *"make the cable slot 5 mm wider"* to iterate. The full data contract, architecture, and design notes are in [`docs/scene-bridge/README.md`](docs/scene-bridge/README.md). - ## Project Layout ```text apps/web/ Next.js app workspace apps/web/src/app/ App routes, dashboard, API routes, styles -apps/web/src/app/api/scene/ AI scene bridge route (stages MCP scene commands) apps/web/src/components/ Editor, viewport, sidebar, icons, controls apps/web/src/types/ Shared shape and editor types apps/web/src/generated/ Generated Manifold runtime source -apps/web/src/lib/ Shared utilities (incl. sceneBridge transport) +apps/web/src/lib/ Shared utilities apps/web/public/assets/ Static app images, icons, logos, shape assets -apps/mcp/ MCP server for the AI scene bridge docs/media/ README screenshots and demo videos -docs/scene-bridge/ AI scene bridge plan, notes, and usage docs deploy/docker/ Docker, Compose, and Nginx deployment files .github/ Issue templates and community files ``` diff --git a/apps/mcp/package-lock.json b/apps/mcp/package-lock.json deleted file mode 100644 index c5f4a50..0000000 --- a/apps/mcp/package-lock.json +++ /dev/null @@ -1,1728 +0,0 @@ -{ - "name": "@sketchforge/mcp", - "version": "0.1.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@sketchforge/mcp", - "version": "0.1.0", - "dependencies": { - "@modelcontextprotocol/sdk": "^1.0.0", - "zod": "^3.23.8" - }, - "devDependencies": { - "@types/node": "^22.15.18", - "tsx": "^4.19.2", - "typescript": "^5.8.3" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", - "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", - "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", - "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", - "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", - "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", - "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", - "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", - "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", - "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", - "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", - "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", - "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", - "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", - "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", - "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", - "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", - "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", - "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", - "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", - "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", - "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openharmony-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", - "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", - "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", - "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", - "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", - "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@hono/node-server": { - "version": "1.19.14", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz", - "integrity": "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==", - "license": "MIT", - "engines": { - "node": ">=18.14.1" - }, - "peerDependencies": { - "hono": "^4" - } - }, - "node_modules/@modelcontextprotocol/sdk": { - "version": "1.29.0", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz", - "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==", - "license": "MIT", - "dependencies": { - "@hono/node-server": "^1.19.9", - "ajv": "^8.17.1", - "ajv-formats": "^3.0.1", - "content-type": "^1.0.5", - "cors": "^2.8.5", - "cross-spawn": "^7.0.5", - "eventsource": "^3.0.2", - "eventsource-parser": "^3.0.0", - "express": "^5.2.1", - "express-rate-limit": "^8.2.1", - "hono": "^4.11.4", - "jose": "^6.1.3", - "json-schema-typed": "^8.0.2", - "pkce-challenge": "^5.0.0", - "raw-body": "^3.0.0", - "zod": "^3.25 || ^4.0", - "zod-to-json-schema": "^3.25.1" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@cfworker/json-schema": "^4.1.1", - "zod": "^3.25 || ^4.0" - }, - "peerDependenciesMeta": { - "@cfworker/json-schema": { - "optional": true - }, - "zod": { - "optional": false - } - } - }, - "node_modules/@types/node": { - "version": "22.20.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.0.tgz", - "integrity": "sha512-QWlFW2wf3nTjC13/DqRnBpR4ZO36VJH/JVBkA/vcnmbTBNQIlnObqyqZE1tUR7+Ni23Lda8R1BxMfbXRpCUx5g==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/ajv": { - "version": "8.20.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", - "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ajv-formats": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", - "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", - "license": "MIT", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, - "node_modules/body-parser": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", - "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^2.0.0", - "debug": "^4.4.3", - "http-errors": "^2.0.1", - "iconv-lite": "^0.7.2", - "on-finished": "^2.4.1", - "qs": "^6.15.2", - "raw-body": "^3.0.2", - "type-is": "^2.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/body-parser/node_modules/content-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", - "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/content-disposition": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", - "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "node_modules/cors": { - "version": "2.8.6", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", - "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", - "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/esbuild": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", - "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.28.1", - "@esbuild/android-arm": "0.28.1", - "@esbuild/android-arm64": "0.28.1", - "@esbuild/android-x64": "0.28.1", - "@esbuild/darwin-arm64": "0.28.1", - "@esbuild/darwin-x64": "0.28.1", - "@esbuild/freebsd-arm64": "0.28.1", - "@esbuild/freebsd-x64": "0.28.1", - "@esbuild/linux-arm": "0.28.1", - "@esbuild/linux-arm64": "0.28.1", - "@esbuild/linux-ia32": "0.28.1", - "@esbuild/linux-loong64": "0.28.1", - "@esbuild/linux-mips64el": "0.28.1", - "@esbuild/linux-ppc64": "0.28.1", - "@esbuild/linux-riscv64": "0.28.1", - "@esbuild/linux-s390x": "0.28.1", - "@esbuild/linux-x64": "0.28.1", - "@esbuild/netbsd-arm64": "0.28.1", - "@esbuild/netbsd-x64": "0.28.1", - "@esbuild/openbsd-arm64": "0.28.1", - "@esbuild/openbsd-x64": "0.28.1", - "@esbuild/openharmony-arm64": "0.28.1", - "@esbuild/sunos-x64": "0.28.1", - "@esbuild/win32-arm64": "0.28.1", - "@esbuild/win32-ia32": "0.28.1", - "@esbuild/win32-x64": "0.28.1" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/eventsource": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", - "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", - "license": "MIT", - "dependencies": { - "eventsource-parser": "^3.0.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/eventsource-parser": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.0.tgz", - "integrity": "sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/express": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", - "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.1", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "depd": "^2.0.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/express-rate-limit": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz", - "integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==", - "license": "MIT", - "dependencies": { - "ip-address": "^10.2.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/express-rate-limit" - }, - "peerDependencies": { - "express": ">= 4.11" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, - "node_modules/fast-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz", - "integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/finalhandler": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", - "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", - "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/hono": { - "version": "4.12.27", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.27.tgz", - "integrity": "sha512-1yrb/+w6HWQJrUCLkJ2IF5jNIPvvFkblV5RNOYl6bV+OA6p9GLcMpHFFGTosSvHvcAUibuUukRqhlYI4z32C7Q==", - "license": "MIT", - "engines": { - "node": ">=16.9.0" - } - }, - "node_modules/http-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", - "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", - "license": "MIT", - "dependencies": { - "depd": "~2.0.0", - "inherits": "~2.0.4", - "setprototypeof": "~1.2.0", - "statuses": "~2.0.2", - "toidentifier": "~1.0.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/iconv-lite": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", - "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/ip-address": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz", - "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", - "license": "MIT" - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "license": "ISC" - }, - "node_modules/jose": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.3.tgz", - "integrity": "sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "license": "MIT" - }, - "node_modules/json-schema-typed": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", - "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", - "license": "BSD-2-Clause" - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", - "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-to-regexp": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", - "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/pkce-challenge": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", - "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", - "license": "MIT", - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/qs": { - "version": "6.15.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz", - "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", - "license": "BSD-3-Clause", - "dependencies": { - "es-define-property": "^1.0.1", - "side-channel": "^1.1.1" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", - "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/raw-body": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", - "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.7.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/router": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", - "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "depd": "^2.0.0", - "is-promise": "^4.0.0", - "parseurl": "^1.3.3", - "path-to-regexp": "^8.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/send": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", - "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.3", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.1", - "mime-types": "^3.0.2", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/serve-static": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", - "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", - "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.4", - "side-channel-list": "^1.0.1", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", - "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.4" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/tsx": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.22.4.tgz", - "integrity": "sha512-X8EX+XV4QR5xCsrgxaED954zTDfY8KqlDtskKEL0cHhyS/P8b4IFOvGDQpsC9Q1XnLq915wEfwwY/zzskCtmhg==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "~0.28.0" - }, - "bin": { - "tsx": "dist/cli.mjs" - }, - "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - } - }, - "node_modules/type-is": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", - "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", - "license": "MIT", - "dependencies": { - "content-type": "^2.0.0", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/type-is/node_modules/content-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz", - "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "license": "ISC" - }, - "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "node_modules/zod-to-json-schema": { - "version": "3.25.2", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", - "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", - "license": "ISC", - "peerDependencies": { - "zod": "^3.25.28 || ^4" - } - } - } -} diff --git a/apps/mcp/package.json b/apps/mcp/package.json deleted file mode 100644 index c59f355..0000000 --- a/apps/mcp/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@sketchforge/mcp", - "version": "0.1.0", - "private": true, - "type": "module", - "description": "MCP server that pushes WorkplaneShape scenes into the SketchForge editor via the /api/scene bridge.", - "scripts": { - "start": "tsx src/index.ts", - "dev": "tsx watch src/index.ts", - "typecheck": "tsc --noEmit" - }, - "dependencies": { - "@modelcontextprotocol/sdk": "^1.0.0", - "zod": "^3.23.8" - }, - "devDependencies": { - "@types/node": "^22.15.18", - "tsx": "^4.19.2", - "typescript": "^5.8.3" - } -} diff --git a/apps/mcp/src/bridgeClient.ts b/apps/mcp/src/bridgeClient.ts deleted file mode 100644 index 9ffd344..0000000 --- a/apps/mcp/src/bridgeClient.ts +++ /dev/null @@ -1,43 +0,0 @@ -import type { WorkplaneShape } from "@/types/sketchforge"; - -// Where the running Next app (and its /api/scene bridge) lives. The route's same-origin -// guard passes a plain Node fetch from localhost with no extra headers (verified in Phase 1). -const BASE_URL = (process.env.SKETCHFORGE_BASE_URL ?? process.env.SCENE_BRIDGE_URL ?? "http://127.0.0.1:3000").replace(/\/$/, ""); - -export function bridgeBaseUrl() { - return BASE_URL; -} - -export type StagedScene = { - shapes: WorkplaneShape[]; - stagingRevision: number | null; - name?: string; -}; - -export async function postScene(projectId: string, shapes: WorkplaneShape[], name?: string): Promise<{ stagingRevision: number }> { - const response = await fetch(`${BASE_URL}/api/scene`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ projectId, op: "upsertScene", name, shapes }), - }); - if (!response.ok) { - throw new Error(`POST /api/scene failed (${response.status}): ${await response.text().catch(() => response.statusText)}`); - } - return (await response.json()) as { stagingRevision: number }; -} - -export async function getScene(projectId: string): Promise { - const params = new URLSearchParams({ projectId, sinceStaging: "0" }); - const response = await fetch(`${BASE_URL}/api/scene?${params.toString()}`, { - method: "GET", - headers: { "Cache-Control": "no-store" }, - }); - if (response.status === 204) { - return { shapes: [], stagingRevision: null }; - } - if (!response.ok) { - throw new Error(`GET /api/scene failed (${response.status}): ${await response.text().catch(() => response.statusText)}`); - } - const command = (await response.json()) as { shapes?: WorkplaneShape[]; stagingRevision?: number; name?: string }; - return { shapes: command.shapes ?? [], stagingRevision: command.stagingRevision ?? null, name: command.name }; -} diff --git a/apps/mcp/src/examples.ts b/apps/mcp/src/examples.ts deleted file mode 100644 index df83ca7..0000000 --- a/apps/mcp/src/examples.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ShapeInput } from "./shapes"; - -// In-context reference scenes the model can copy from. Plain WorkplaneShape inputs: -// dimensions in millimetres, x/z on the workplane, elevation = height above it, a cutter -// is any shape with hole: true. These are intentionally simple and valid. - -export const PHONE_STAND_EXAMPLE: { name: string; shapes: ShapeInput[] } = { - name: "Phone stand", - shapes: [ - { name: "Base", kind: "box", color: "#0098c7", x: 0, z: 0, elevation: 0, width: 80, depth: 70, height: 8 }, - // Backrest tilted back ~20° so a phone leans against it. - { name: "Backrest", kind: "box", color: "#0098c7", x: 0, z: -22, elevation: 4, width: 80, depth: 8, height: 70, rotationX: 20 }, - // Lip at the front to stop the phone sliding off. - { name: "Lip", kind: "box", color: "#0098c7", x: 0, z: 28, elevation: 8, width: 80, depth: 8, height: 14 }, - // Cable slot cut through the base. - { name: "Cable slot", kind: "cylinder", color: "#d41721", hole: true, x: 0, z: 6, elevation: 0, width: 16, depth: 16, height: 24, radius: 8, sides: 64 }, - ], -}; - -export const BRACKET_EXAMPLE: { name: string; shapes: ShapeInput[] } = { - name: "L-bracket with bolt holes", - shapes: [ - { name: "Base flange", kind: "box", color: "#33983d", x: 0, z: 0, elevation: 0, width: 60, depth: 40, height: 6 }, - { name: "Upright flange", kind: "box", color: "#33983d", x: 0, z: -17, elevation: 6, width: 60, depth: 6, height: 40 }, - { name: "Bolt hole L", kind: "cylinder", color: "#d41721", hole: true, x: -18, z: 8, elevation: 0, width: 8, depth: 8, height: 12, radius: 4, sides: 48 }, - { name: "Bolt hole R", kind: "cylinder", color: "#d41721", hole: true, x: 18, z: 8, elevation: 0, width: 8, depth: 8, height: 12, radius: 4, sides: 48 }, - ], -}; - -export const EXAMPLE_SCENES = [PHONE_STAND_EXAMPLE, BRACKET_EXAMPLE]; diff --git a/apps/mcp/src/index.ts b/apps/mcp/src/index.ts deleted file mode 100644 index 2f023e5..0000000 --- a/apps/mcp/src/index.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; -import { z } from "zod"; -import { bridgeBaseUrl, getScene, postScene } from "./bridgeClient"; -import { shapeInputSchema, toWorkplaneShapes, type ShapeInput } from "./shapes"; -import { describeKinds } from "./kinds"; -import { EXAMPLE_SCENES } from "./examples"; - -const projectIdSchema = z - .string() - .min(1) - .describe("Editor project id. Open the app at /?bridge=1&project= to watch it live; unknown ids are created automatically."); - -function viewUrl(projectId: string) { - return `${bridgeBaseUrl()}/?bridge=1&project=${encodeURIComponent(projectId)}`; -} - -function jsonResult(summary: string, data: unknown) { - return { - content: [ - { type: "text" as const, text: summary }, - { type: "text" as const, text: JSON.stringify(data, null, 2) }, - ], - }; -} - -function errorResult(message: string) { - return { isError: true, content: [{ type: "text" as const, text: message }] }; -} - -const server = new McpServer( - { name: "sketchforge-scene-bridge", version: "0.1.0" }, - { - instructions: - "Push parametric 3D scenes into the SketchForge editor. Scenes are arrays of WorkplaneShape " + - "objects (millimetres; x/z on the workplane, elevation = height above it; a cutter is any shape " + - "with hole:true; a boolean result carries its parts in groupedShapes). The user must have the app " + - "open at /?bridge=1&project= to see updates live. Call list_kinds first to learn the shape " + - "kinds, their default sizes, and example scenes. Use set_scene to replace a scene, add_shapes to " + - "append, and get_scene to read the current scene back before iterating.", - }, -); - -server.registerTool( - "list_kinds", - { - title: "List shape kinds", - description: - "List every valid shape kind with its default dimensions and which optional fields matter, plus " + - "ready-to-use example scenes. Call this before generating shapes so you self-correct on kind names " + - "and required fields.", - inputSchema: {}, - }, - async () => { - return jsonResult("Valid shape kinds, defaults, and example scenes.", { - note: "Every shape needs kind, width, depth, height. color/name are auto-filled if omitted. Positions default to the origin. Sizes are clamped/canonicalised by the editor, not by this server.", - kinds: describeKinds(), - examples: EXAMPLE_SCENES, - }); - }, -); - -server.registerTool( - "get_scene", - { - title: "Get current scene", - description: "Read back the shapes currently staged for a project, so you can iterate on an existing scene.", - inputSchema: { projectId: projectIdSchema }, - }, - async ({ projectId }) => { - try { - const scene = await getScene(projectId); - return jsonResult( - `Project ${projectId} has ${scene.shapes.length} staged shape(s)` + - (scene.stagingRevision === null ? " (nothing staged yet)." : `.`), - scene, - ); - } catch (error) { - return errorResult(error instanceof Error ? error.message : "Could not read scene"); - } - }, -); - -server.registerTool( - "set_scene", - { - title: "Set (replace) scene", - description: - "Replace the project's scene with the given shapes. Unknown project ids are created automatically. " + - "Shapes are validated against the shape-kind contract, then defaulted/canonicalised by the editor.", - inputSchema: { - projectId: projectIdSchema, - shapes: z.array(shapeInputSchema).min(1).describe("The full scene as an array of WorkplaneShape inputs."), - name: z.string().optional().describe("Optional project name used only when the project is first created."), - }, - }, - async ({ projectId, shapes, name }) => { - try { - const workplaneShapes = toWorkplaneShapes(shapes as ShapeInput[]); - const { stagingRevision } = await postScene(projectId, workplaneShapes, name); - return jsonResult(`Staged ${workplaneShapes.length} shape(s) for ${projectId}. View: ${viewUrl(projectId)}`, { - projectId, - stagingRevision, - shapeCount: workplaneShapes.length, - viewUrl: viewUrl(projectId), - }); - } catch (error) { - return errorResult(error instanceof Error ? error.message : "Could not stage scene"); - } - }, -); - -server.registerTool( - "add_shapes", - { - title: "Add shapes to scene", - description: "Append shapes to the project's current staged scene (merge, then re-stage the whole scene).", - inputSchema: { - projectId: projectIdSchema, - shapes: z.array(shapeInputSchema).min(1).describe("Shapes to append to the existing scene."), - }, - }, - async ({ projectId, shapes }) => { - try { - const current = await getScene(projectId); - const added = toWorkplaneShapes(shapes as ShapeInput[]); - const merged = [...current.shapes, ...added]; - const { stagingRevision } = await postScene(projectId, merged); - return jsonResult( - `Added ${added.length} shape(s) to ${projectId} (now ${merged.length} total). View: ${viewUrl(projectId)}`, - { projectId, stagingRevision, added: added.length, total: merged.length, viewUrl: viewUrl(projectId) }, - ); - } catch (error) { - return errorResult(error instanceof Error ? error.message : "Could not add shapes"); - } - }, -); - -async function main() { - const transport = new StdioServerTransport(); - await server.connect(transport); - // stderr only — stdout is the MCP JSON-RPC channel. - console.error(`sketchforge-scene-bridge MCP server ready (bridge: ${bridgeBaseUrl()})`); -} - -main().catch((error) => { - console.error("Fatal MCP server error:", error); - process.exit(1); -}); diff --git a/apps/mcp/src/kinds.ts b/apps/mcp/src/kinds.ts deleted file mode 100644 index 49e365d..0000000 --- a/apps/mcp/src/kinds.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { sceneShape } from "@/lib/shapeCatalog"; -import { fallbackSolidColor } from "@/lib/workplaneShapes"; -import type { ShapeKind, WorkplaneShape } from "@/types/sketchforge"; -import { SHAPE_KINDS } from "./shapes"; - -// Per-kind guidance for the model. This is NOT the validation enum (that's SHAPE_KINDS / -// the ShapeKind union) — it's hints about which optional fields matter and which kinds need -// payloads a model can't author by hand. "requires" lists fields beyond width/depth/height. -const KIND_GUIDANCE: Record = { - box: { useful: ["radius (corner fillet)"], generatable: true }, - cylinder: { useful: ["radius", "sides"], generatable: true }, - sphere: { useful: ["steps"], generatable: true }, - cone: { useful: ["baseRadius", "topRadius", "sides"], generatable: true }, - pyramid: { useful: ["sides"], generatable: true }, - wedge: { generatable: true }, - roundRoof: { useful: ["sides"], generatable: true }, - halfSphere: { useful: ["steps"], generatable: true }, - torus: { useful: ["radius", "bevel"], generatable: true }, - tube: { useful: ["radius", "bevel"], generatable: true }, - ring: { useful: ["radius", "bevel"], generatable: true }, - polygon: { useful: ["sides"], generatable: true }, - icosahedron: { generatable: true }, - roof: { generatable: true }, - text: { requires: ["text", "font"], note: "Set text to the string and font to a font name.", generatable: true }, - sketch: { note: "Free-form sketch; not directly generatable from numeric params.", generatable: false }, - scribble: { note: "Free-form scribble; not directly generatable from numeric params.", generatable: false }, - mesh: { requires: ["importedMesh"], note: "Needs imported geometry (positions/normals) — produced by STL import, not authored.", generatable: false }, -}; - -export type KindInfo = { - kind: ShapeKind; - generatable: boolean; - defaults: { width: number; depth: number; height: number; size: number; rotation: number }; - requires: string[]; - useful: string[]; - note?: string; -}; - -export function describeKinds(): KindInfo[] { - return SHAPE_KINDS.map((kind) => { - // Derive defaults from the app's own defaulter rather than hard-coding them. - const d = sceneShape({ name: kind, kind, color: fallbackSolidColor({ kind } as WorkplaneShape) }); - const guidance = KIND_GUIDANCE[kind]; - return { - kind, - generatable: guidance.generatable, - defaults: { width: d.width, depth: d.depth, height: d.height, size: d.size, rotation: d.rotation }, - requires: guidance.requires ?? [], - useful: guidance.useful ?? [], - note: guidance.note, - }; - }); -} diff --git a/apps/mcp/src/shapes.ts b/apps/mcp/src/shapes.ts deleted file mode 100644 index 66fd6ef..0000000 --- a/apps/mcp/src/shapes.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { z } from "zod"; -import { sceneShape } from "@/lib/shapeCatalog"; -import { fallbackSolidColor } from "@/lib/workplaneShapes"; -import type { ShapeKind, WorkplaneShape } from "@/types/sketchforge"; - -// The ShapeKind union is the validation source of truth (CLAUDE.md). The type is -// compile-time only, so we mirror it here as a runtime list for the zod enum, with a -// two-way compile-time guard so the list can never silently drift from the union. -export const SHAPE_KINDS = [ - "box", - "cylinder", - "sphere", - "sketch", - "scribble", - "cone", - "pyramid", - "roof", - "text", - "roundRoof", - "halfSphere", - "torus", - "tube", - "ring", - "wedge", - "polygon", - "icosahedron", - "mesh", -] as const; - -type MissingFromList = Exclude; -type ExtraInList = Exclude<(typeof SHAPE_KINDS)[number], ShapeKind>; -// If either of these errors, SHAPE_KINDS and the ShapeKind union have drifted — fix the list. -const _assertNoneMissing: MissingFromList extends never ? true : false = true; -const _assertNoneExtra: ExtraInList extends never ? true : false = true; -void _assertNoneMissing; -void _assertNoneExtra; - -// Structural input contract for a model-authored shape. We require only the base -// numerics every kind needs (width/depth/height) plus a valid kind; everything else is -// optional and gets filled + canonicalised by the app's own sceneShape(). We deliberately -// do NOT encode parameter ranges here — the app's canonicaliser owns that. -export interface ShapeInput { - id?: string; - name?: string; - kind: ShapeKind; - color?: string; - hole?: boolean; - x?: number; - z?: number; - elevation?: number; - width: number; - depth: number; - height: number; - size?: number; - rotation?: number; - rotationX?: number; - rotationZ?: number; - mirrorX?: boolean; - mirrorY?: boolean; - mirrorZ?: boolean; - radius?: number; - steps?: number; - sides?: number; - bevel?: number; - segments?: number; - topRadius?: number; - baseRadius?: number; - text?: string; - font?: string; - importedMesh?: unknown; - imagePlate?: unknown; - groupedShapes?: ShapeInput[]; - groupedBaseWidth?: number; - groupedBaseDepth?: number; - groupedBaseHeight?: number; - locked?: boolean; - hidden?: boolean; -} - -const finiteNumber = z.number().finite(); - -// z.lazy for the groupedShapes recursion (a boolean result carries its parts). -export const shapeInputSchema: z.ZodType = z.lazy(() => - z.object({ - id: z.string().optional(), - name: z.string().optional(), - kind: z.enum(SHAPE_KINDS), - color: z.string().optional(), - hole: z.boolean().optional(), - x: finiteNumber.optional(), - z: finiteNumber.optional(), - elevation: finiteNumber.optional(), - width: finiteNumber, - depth: finiteNumber, - height: finiteNumber, - size: finiteNumber.optional(), - rotation: finiteNumber.optional(), - rotationX: finiteNumber.optional(), - rotationZ: finiteNumber.optional(), - mirrorX: z.boolean().optional(), - mirrorY: z.boolean().optional(), - mirrorZ: z.boolean().optional(), - radius: finiteNumber.optional(), - steps: finiteNumber.optional(), - sides: finiteNumber.optional(), - bevel: finiteNumber.optional(), - segments: finiteNumber.optional(), - topRadius: finiteNumber.optional(), - baseRadius: finiteNumber.optional(), - text: z.string().optional(), - font: z.string().optional(), - importedMesh: z.unknown().optional(), - imagePlate: z.unknown().optional(), - groupedShapes: z.array(shapeInputSchema).optional(), - groupedBaseWidth: finiteNumber.optional(), - groupedBaseDepth: finiteNumber.optional(), - groupedBaseHeight: finiteNumber.optional(), - locked: z.boolean().optional(), - hidden: z.boolean().optional(), - }), -); - -export const shapesArraySchema = z.array(shapeInputSchema); - -function prettifyKind(kind: ShapeKind) { - const spaced = kind.replace(/([a-z])([A-Z])/g, "$1 $2"); - return spaced.charAt(0).toUpperCase() + spaced.slice(1); -} - -// Validate-then-defaults pipeline: the zod layer only rejects structurally broken shapes; -// sceneShape() (which calls canonicalizeShape) is the single source of truth for defaults -// + canonicalisation. Grouped parts are normalised depth-first so children get defaults too. -export function toWorkplaneShape(input: ShapeInput): WorkplaneShape { - const kind = input.kind; - const color = input.color ?? fallbackSolidColor({ kind } as WorkplaneShape); - const name = input.name ?? prettifyKind(kind); - const groupedShapes = input.groupedShapes?.map(toWorkplaneShape); - return sceneShape({ - ...(input as Partial), - name, - kind, - color, - groupedShapes, - }); -} - -export function toWorkplaneShapes(inputs: ShapeInput[]): WorkplaneShape[] { - return inputs.map(toWorkplaneShape); -} diff --git a/apps/mcp/tsconfig.json b/apps/mcp/tsconfig.json deleted file mode 100644 index 5f496e4..0000000 --- a/apps/mcp/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "lib": ["ES2023"], - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "noEmit": true, - "resolveJsonModule": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "@/*": ["../web/src/*"] - }, - "types": ["node"] - }, - "include": ["src/**/*.ts"] -} diff --git a/apps/web/src/app/api/scene/route.ts b/apps/web/src/app/api/scene/route.ts deleted file mode 100644 index e348afc..0000000 --- a/apps/web/src/app/api/scene/route.ts +++ /dev/null @@ -1,162 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { NextResponse } from "next/server"; -import type { WorkplaneShape } from "@/types/sketchforge"; - -export const revalidate = false; - -// Scene bridge: stages MCP-pushed commands on disk for the client poller (Phase 2) -// to apply via the editor's existing updateProjectShapes() path. The Node side never -// touches IndexedDB/localStorage — see CLAUDE.md. This route only writes/reads a file. -const PENDING_SCENES_DIR = path.join(process.cwd(), ".codex", "pending-scenes"); -const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]); -const MAX_SCENE_BYTES = 16 * 1024 * 1024; -const SUPPORTED_OPS = new Set(["upsertScene"]); - -type SceneOp = "upsertScene"; - -type StagedSceneCommand = { - stagingRevision: number; - op: SceneOp; - projectId: string; - name?: string; - shapes: WorkplaneShape[]; - updatedAt: number; -}; - -// Copied from the sibling api/project-thumbnail route — keep the bridge in lockstep -// with the app's existing same-origin policy rather than inventing a new one. -function safeProjectId(projectId: string) { - const clean = projectId.replace(/[^a-zA-Z0-9_-]/g, ""); - return clean || null; -} - -function pendingScenePath(projectId: string) { - const safeId = safeProjectId(projectId); - if (!safeId) { - return null; - } - return path.join(PENDING_SCENES_DIR, `${safeId}.json`); -} - -function isLocalSameOriginRequest(request: Request) { - const requestUrl = new URL(request.url); - if (!LOCAL_HOSTS.has(requestUrl.hostname)) { - return false; - } - - const origin = request.headers.get("origin"); - if (origin) { - try { - const originUrl = new URL(origin); - if (!LOCAL_HOSTS.has(originUrl.hostname) || originUrl.port !== requestUrl.port || originUrl.protocol !== requestUrl.protocol) { - return false; - } - } catch { - return false; - } - } - - const fetchSite = request.headers.get("sec-fetch-site"); - return !fetchSite || fetchSite === "same-origin" || fetchSite === "same-site" || fetchSite === "none"; -} - -async function readStagedCommand(filePath: string): Promise { - try { - const raw = await fs.readFile(filePath, "utf8"); - return JSON.parse(raw) as StagedSceneCommand; - } catch { - return null; - } -} - -// The bridge's OWN counter — separate from the app's project revision. Monotonic per -// project and survives a server restart by stepping past whatever the staged file holds. -function nextStagingRevision(previous: StagedSceneCommand | null) { - const prior = typeof previous?.stagingRevision === "number" ? previous.stagingRevision : 0; - return Math.max(Date.now(), prior + 1); -} - -export async function GET(request: Request) { - if (!isLocalSameOriginRequest(request)) { - return NextResponse.json({ error: "Scene bridge is only available from this localhost app" }, { status: 403 }); - } - - const params = new URL(request.url).searchParams; - const filePath = pendingScenePath(params.get("projectId") ?? ""); - if (!filePath) { - return NextResponse.json({ error: "Invalid project id" }, { status: 400 }); - } - - const sinceRaw = Number(params.get("sinceStaging")); - const sinceStaging = Number.isFinite(sinceRaw) ? sinceRaw : 0; - - const command = await readStagedCommand(filePath); - if (!command || command.stagingRevision <= sinceStaging) { - return new NextResponse(null, { status: 204 }); - } - - return NextResponse.json(command, { headers: { "Cache-Control": "no-store" } }); -} - -export async function POST(request: Request) { - if (!isLocalSameOriginRequest(request)) { - return NextResponse.json({ error: "Scene bridge is only available from this localhost app" }, { status: 403 }); - } - - const contentLength = Number(request.headers.get("content-length")); - if (Number.isFinite(contentLength) && contentLength > MAX_SCENE_BYTES) { - return NextResponse.json({ error: "Scene is too large" }, { status: 413 }); - } - - const rawBody = await request.text(); - if (Buffer.byteLength(rawBody, "utf8") > MAX_SCENE_BYTES) { - return NextResponse.json({ error: "Scene is too large" }, { status: 413 }); - } - - let body: { projectId?: unknown; shapes?: unknown; op?: unknown; name?: unknown }; - try { - body = JSON.parse(rawBody) as typeof body; - } catch { - return NextResponse.json({ error: "Invalid scene request" }, { status: 400 }); - } - - try { - if (typeof body.projectId !== "string" || !Array.isArray(body.shapes)) { - return NextResponse.json({ error: "Invalid scene request" }, { status: 400 }); - } - - const filePath = pendingScenePath(body.projectId); - if (!filePath) { - return NextResponse.json({ error: "Invalid project id" }, { status: 400 }); - } - - const op = body.op === undefined ? "upsertScene" : body.op; - if (typeof op !== "string" || !SUPPORTED_OPS.has(op)) { - return NextResponse.json({ error: `Unsupported op: ${String(body.op)}` }, { status: 400 }); - } - - if (body.name !== undefined && typeof body.name !== "string") { - return NextResponse.json({ error: "Invalid scene name" }, { status: 400 }); - } - - const previous = await readStagedCommand(filePath); - const command: StagedSceneCommand = { - stagingRevision: nextStagingRevision(previous), - op: op as SceneOp, - projectId: body.projectId, - shapes: body.shapes as WorkplaneShape[], - updatedAt: Date.now(), - }; - if (typeof body.name === "string") { - command.name = body.name; - } - - await fs.mkdir(PENDING_SCENES_DIR, { recursive: true }); - await fs.writeFile(filePath, JSON.stringify(command, null, 2), "utf8"); - - return NextResponse.json({ stagingRevision: command.stagingRevision }); - } catch (error) { - return NextResponse.json({ error: error instanceof Error ? error.message : "Could not stage scene" }, { status: 500 }); - } -} diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index d8f4dd6..6005ece 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -6,7 +6,6 @@ import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForg import { createLocalId } from "@/lib/localIds"; import { importExtensionSupported } from "@/lib/stlImport"; import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings } from "@/lib/workplaneSettings"; -import { createPollingSceneTransport, resolveSceneBridgeTarget, type StagedSceneCommand } from "@/lib/sceneBridge"; import type { GridSize, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge"; type AppView = "dashboard" | "editor"; @@ -239,62 +238,6 @@ function projectNameFromFileName(fileName: string) { return fileName.replace(/\.[^.]+$/, "").trim() || "Imported STL design"; } -const SCENE_BRIDGE_POLL_MS = 1000; - -// Scene bridge poller. Lives in Home (not a components/ module) because applying a -// staged command needs the project lifecycle + updateProjectShapes that live here. -// V2 will swap createPollingSceneTransport for a WebSocket transport without touching -// this hook's apply path. Defers while a pointer is down so an incoming push never -// fights an in-progress drag. -function useSceneBridge({ ready, apply }: { ready: boolean; apply: (command: StagedSceneCommand) => void }) { - const applyRef = useRef(apply); - applyRef.current = apply; - const lastAppliedRef = useRef(0); - const pointerDownRef = useRef(false); - - useEffect(() => { - if (!ready || typeof window === "undefined") return; - const envEnabled = process.env.NEXT_PUBLIC_SCENE_BRIDGE === "true"; - const { enabled, projectId } = resolveSceneBridgeTarget(window.location.search, envEnabled); - if (!enabled || !projectId) return; - - const transport = createPollingSceneTransport(projectId); - let active = true; - - const onPointerDown = () => { - pointerDownRef.current = true; - }; - const onPointerUp = () => { - pointerDownRef.current = false; - }; - window.addEventListener("pointerdown", onPointerDown, true); - window.addEventListener("pointerup", onPointerUp, true); - window.addEventListener("pointercancel", onPointerUp, true); - - const tick = async () => { - if (!active || pointerDownRef.current) return; - try { - const command = await transport.poll(lastAppliedRef.current); - if (!active || !command || command.stagingRevision <= lastAppliedRef.current) return; - lastAppliedRef.current = command.stagingRevision; - applyRef.current(command); - } catch { - // Transient (server reload, file mid-write). The command stays staged; retry next tick. - } - }; - - void tick(); - const interval = window.setInterval(() => void tick(), SCENE_BRIDGE_POLL_MS); - return () => { - active = false; - window.clearInterval(interval); - window.removeEventListener("pointerdown", onPointerDown, true); - window.removeEventListener("pointerup", onPointerUp, true); - window.removeEventListener("pointercancel", onPointerUp, true); - }; - }, [ready]); -} - export default function Home() { const [mounted, setMounted] = useState(false); const [view, setView] = useState("dashboard"); @@ -555,37 +498,6 @@ export default function Home() { ); }, []); - const applyBridgeCommand = useCallback( - (command: StagedSceneCommand) => { - if (command.op !== "upsertScene") return; - const projectId = command.projectId; - const name = command.name?.trim(); - // Create the localStorage metadata entry if the id is unknown — the editor needs - // BOTH a project entry and a shapes record to open. Never overwrite an existing name. - setProjects((current) => { - if (current.some((project) => project.id === projectId)) return current; - const created: DashboardProject = { ...newProject(name || "AI scene", current.length), id: projectId }; - return [created, ...current]; - }); - // Existing save path: writes IndexedDB + localStorage + a winning project revision. - // The editor's rehydration effect (keyed on initialShapes/projectRevision) re-renders. - updateProjectShapes({ projectId, shapes: command.shapes }); - setActiveProjectId(projectId); - setEditorStarted(true); - setView("editor"); - if (typeof window !== "undefined") { - const params = new URLSearchParams(window.location.search); - params.set("editor", "1"); - params.set("project", projectId); - if (!params.has("bridge")) params.set("bridge", "1"); - window.history.replaceState(null, "", `/?${params.toString()}`); - } - }, - [updateProjectShapes], - ); - - useSceneBridge({ ready: mounted, apply: applyBridgeCommand }); - const createAndOpenProject = (name?: string) => { const project = newProject(name ?? `Untitled design ${projects.length + 1}`, projects.length); setProjectShapesById((current) => ({ diff --git a/apps/web/src/lib/sceneBridge.ts b/apps/web/src/lib/sceneBridge.ts deleted file mode 100644 index de281fb..0000000 --- a/apps/web/src/lib/sceneBridge.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { WorkplaneShape } from "@/types/sketchforge"; - -// Client-side contract for the scene bridge. Mirrors the record written by -// apps/web/src/app/api/scene/route.ts. `stagingRevision` is the bridge's OWN -// monotonic counter — distinct from the app's per-project revision. -export type SceneCommandOp = "upsertScene"; - -export type StagedSceneCommand = { - stagingRevision: number; - op: SceneCommandOp; - projectId: string; - name?: string; - shapes: WorkplaneShape[]; - updatedAt: number; -}; - -// The seam V2 swaps out: today a poller, later a WebSocket `subscribe()`. -// Keeping the route and the MCP tools untouched when that happens. -export interface SceneTransport { - // Returns the staged command if its stagingRevision is newer than `sinceStaging`, - // otherwise null (the route answers 204 when nothing newer is staged). - poll(sinceStaging: number): Promise; - // subscribe?(onCommand): () => void; // reserved for V2 (live push) -} - -export function createPollingSceneTransport(projectId: string): SceneTransport { - return { - async poll(sinceStaging: number) { - const params = new URLSearchParams({ projectId, sinceStaging: String(sinceStaging) }); - const response = await fetch(`/api/scene?${params.toString()}`, { - method: "GET", - headers: { "Cache-Control": "no-store" }, - }); - if (response.status === 204 || !response.ok) { - return null; - } - return (await response.json()) as StagedSceneCommand; - }, - }; -} - -// Pure config resolver so the enable/target logic is testable without a DOM. -// Enabled by `?bridge=1` (any value except 0/false) or the env flag; the target -// project id comes from the existing `project` query param. -export function resolveSceneBridgeTarget(search: string, envEnabled = false): { enabled: boolean; projectId: string | null } { - const params = new URLSearchParams(search); - const flag = params.get("bridge"); - const flagEnabled = flag !== null && flag !== "0" && flag !== "false"; - const projectId = params.get("project"); - return { enabled: (envEnabled || flagEnabled) && Boolean(projectId), projectId: projectId || null }; -} diff --git a/docs/scene-bridge/NOTES.md b/docs/scene-bridge/NOTES.md deleted file mode 100644 index 9163cad..0000000 Binary files a/docs/scene-bridge/NOTES.md and /dev/null differ diff --git a/docs/scene-bridge/PLAN.md b/docs/scene-bridge/PLAN.md deleted file mode 100644 index 176e75d..0000000 --- a/docs/scene-bridge/PLAN.md +++ /dev/null @@ -1,127 +0,0 @@ -# Scene Bridge — Build Plan - -Work one phase per session. Each phase is a vertical slice that is independently -testable. Do not start a phase until the previous one meets its acceptance criteria. - ---- - -## Phase 0 — Orientation (NO CODE) - -**Goal:** Prove you understand the architecture before touching anything. - -Read only these: -- `CLAUDE.md` (root) -- `apps/web/src/types/sketchforge.ts` -- The persistence block in `apps/web/src/app/page.tsx` (IndexedDB + localStorage helpers, ~44–135) -- `apps/web/src/app/api/local-download/route.ts` (route + same-origin guard template) -- `apps/web/src/lib/shapeCatalog.ts` and `apps/web/src/lib/workplaneShapes.ts` - -**Deliverable:** a short note (`docs/scene-bridge/NOTES.md`) stating, in your own words: -the IndexedDB record shape, the exact localStorage key, the existing read/write helper -names you will reuse, the URL the editor opens with, and the data flow diagram from -`CLAUDE.md`. List anything that contradicts `CLAUDE.md` — alpha drift is expected. - -**Acceptance:** the note is correct against source. No code written. - ---- - -## Phase 1 — Bridge route (server only) - -**Goal:** A local HTTP endpoint that stages and returns a scene. - -- Create `apps/web/src/app/api/scene/route.ts`. -- `POST` body `{ projectId: string, shapes: WorkplaneShape[], op?: "upsertScene", name?: string }`. - Validate with the existing routes' style (size cap, `isLocalSameOriginRequest`, `safeProjectId`). - Assign a monotonic `stagingRevision` and write `.codex/pending-scenes/.json` = - `{ stagingRevision, op, projectId, name, shapes, updatedAt }`. This `stagingRevision` is the - bridge's OWN counter — it is NOT the app's project revision (keep them separate). -- `GET ?projectId=&sinceStaging=` returns the staged command if its stagingRevision is - newer, else 204/empty. -- Do **not** import or validate full geometry here — just the JSON shape. - -**Acceptance (curl, app running):** -- `curl -X POST .../api/scene` with a 1-box scene → 200, file appears under `.codex/pending-scenes/`. -- `GET` returns it; `GET` with `since` equal to current revision returns empty. -- Non-local / wrong-origin request → 403 (verify a plain Node `fetch` from localhost passes; - if it does not, document the exact header the MCP must send). - ---- - -## Phase 2 — Client hydrator (browser side) - -**Goal:** The running app picks up a staged command and shows the scene. - -- Add a `SceneTransport` interface (`poll()` now; `subscribe()` reserved for V2) and a - polling implementation that hits `GET /api/scene?...&sinceStaging=` for the target project. -- Add the poller as a **hook called from `Home`** (`page.tsx`) — NOT a `components/` module. - On a command whose `stagingRevision` exceeds the last one applied: - - if `op === "upsertScene"` and the project id is unknown, create it via the existing - create-project path, then make it the active/open project; - - call the existing `updateProjectShapes({ projectId, shapes })` — it writes IndexedDB + - localStorage + a winning project revision, and the editor's existing rehydration effect - (keyed on `initialShapes`/`projectRevision`) re-renders the viewport for free. - - record the applied `stagingRevision` to avoid re-applying. -- Gate behind a flag (e.g. `?bridge=1` or an env var) so normal use is untouched. -- Do NOT write IndexedDB directly and do NOT set a project revision yourself. - -**Acceptance:** -- From the dashboard, `POST` an `upsertScene` for a NEW project id (2 shapes, one with - `hole: true`, grouped) → project is created, opened, and the geometry renders, no console - errors. `POST` again with a higher `stagingRevision` → scene updates. Reload → it persists - (it's in IndexedDB). While dragging a shape, an incoming push is deferred, not fought. - ---- - -## Phase 3 — MCP server (`apps/mcp/`) - -**Goal:** Claude-callable tools that drive the bridge. - -- New workspace `apps/mcp/`. Import `WorkplaneShape`, `canonicalizeShape`, and the per-kind - defaults from `apps/web` (shared in the monorepo). -- Tools: - - `get_scene(projectId)` → current staged shapes. - - `set_scene(projectId, shapes, name?)` → validate, then `POST /api/scene` as `upsertScene` - (unknown ids are fine — the client creates the project in Phase 2). - - `add_shapes(projectId, shapes)` → merge with current, re-`POST`. - - `list_kinds()` → kinds + required/optional fields + defaults derived from the catalog, - so the model self-corrects. -- Validation: zod checks the `ShapeKind` **union enum** + base required numerics ONLY, then - run the imported `canonicalizeShape` to clamp/default. Do NOT hand-author parameter ranges — - the app's canonicaliser is the single source of truth. Reject only structurally-broken shapes. -- Ship a few example scenes (phone stand, bracket with bolt holes) as in-context references. - -**Acceptance:** -- From Claude Code (or an MCP inspector): `set_scene` with a hand-written 3-shape scene for a - fresh project id → project is created and the scene appears. Invalid shape (bad kind / - malformed) → rejected by zod with a useful message, nothing staged. A valid-but-extreme shape - is clamped by `canonicalizeShape`, not rejected. - ---- - -## Phase 4 — End-to-end + polish - -**Goal:** Prompt → scene in the editor. - -- Driving Claude through the MCP: "a 40 mm phone stand with a cable slot" → valid - `WorkplaneShape[]` → renders. -- Add `get_scene` round-trip so the model can read back and iterate ("make the slot 5 mm wider"). -- Document the loop in `docs/scene-bridge/README.md`. Add 1–2 vitest cases for the schema - validator and the route handler. - -**Acceptance:** three different natural-language prompts each produce a sensible, -error-free scene; iteration on an existing scene works. - ---- - -## V2 — MCP as source of truth (separate effort) - -Only after V1 is solid. The seams are already in place: - -- Replace the polling `SceneTransport` with a WebSocket implementation (`subscribe()`); - route stays as a fallback. -- MCP holds the canonical scene; pushes diffs; the editor reflects them live and - round-trips user edits back over the socket. -- Keep the `WorkplaneShape` contract identical so V1 tools keep working. - -Do not build V2 abstractions early. The `SceneTransport` interface from Phase 2 is the -only forward-compatibility you need now. diff --git a/docs/scene-bridge/README.md b/docs/scene-bridge/README.md deleted file mode 100644 index 5cd2834..0000000 --- a/docs/scene-bridge/README.md +++ /dev/null @@ -1,134 +0,0 @@ -# AI Scene Bridge - -Push parametric 3D scenes from Claude (via an MCP server) into the running SketchForge -editor. Claude emits `WorkplaneShape[]` JSON; the editor's existing save path hydrates it -into the viewport. Manifold WASM (client-side) does all the actual CSG/meshing — the bridge -never does mesh maths. - -## The loop - -``` -Claude ──(MCP tool call)──▶ apps/mcp ──POST /api/scene──▶ Next route (server) - │ stages a command file: - │ .codex/pending-scenes/.json - ▼ - editor viewport ◀── rehydration effect ◀── updateProjectShapes() ◀── poller in Home (page.tsx) - (renders shapes) (initialShapes/ (writes IndexedDB + GET /api/scene?sinceStaging= - projectRevision) localStorage + revision) -``` - -An MCP server is a Node process and **cannot** write the browser's IndexedDB/localStorage — -that storage is sandboxed to the page origin. So the bridge always goes through the HTTP -route + an in-page poller that reuses the app's own save path. - -### Two independent counters - -- **`stagingRevision`** — the bridge's own monotonic counter (per project, in the staged - file). The poller polls `GET /api/scene?sinceStaging=` and only applies - newer commands. -- **project `revision`** — the app's existing per-project revision, owned entirely by - `updateProjectShapes()`. The bridge never sets it. - -These are kept separate on purpose: the bridge can re-deliver without fighting the app's -own revisioning, and the editor defers an incoming push while the user is mid-drag. - -## Running it - -1. Start the app: - ``` - npm run dev # http://127.0.0.1:3000 - ``` -2. Open the editor in **bridge mode**, choosing any project id you like: - ``` - http://127.0.0.1:3000/?bridge=1&project=my-first-scene - ``` - The id need not exist yet — the first `set_scene` creates and opens it. -3. The MCP server is registered for Claude Code in [`.mcp.json`](../../.mcp.json) at the repo - root (`sketchforge-scene-bridge`). It launches via `npm run start --prefix apps/mcp` and - talks to the app at `SKETCHFORGE_BASE_URL` (default `http://127.0.0.1:3000`). Claude Code - picks up `.mcp.json` on startup — restart it once after first checkout and approve the - server. - -You can also run the server standalone for an MCP inspector: -``` -SKETCHFORGE_BASE_URL=http://127.0.0.1:3000 npm run start --prefix apps/mcp -``` - -## Tools - -| Tool | Args | What it does | -|------|------|--------------| -| `list_kinds` | — | Lists every shape kind, its default dimensions, which optional fields matter, and example scenes. **Call this first.** | -| `set_scene` | `projectId, shapes[], name?` | Replaces the project's scene. Unknown ids are created automatically. | -| `add_shapes` | `projectId, shapes[]` | Appends shapes to the current scene (merge + re-stage). | -| `get_scene` | `projectId` | Reads the current staged shapes back, so you can iterate. | - -## The data contract - -`WorkplaneShape` (`apps/web/src/types/sketchforge.ts`) is THE contract. For authoring: - -- Units are **millimetres**. `x`/`z` position on the workplane; `elevation` is height above it. -- Every shape needs `kind` + `width` + `depth` + `height`. `color`/`name` auto-fill if omitted; - position defaults to the origin. -- A **cutter** is any shape with `hole: true`. -- A **boolean/combined result** carries its parts in `groupedShapes: WorkplaneShape[]`. -- `kind` must be one of the 18 `ShapeKind` values (`list_kinds`). Some kinds need extra data - (`text` → `text`/`font`; `mesh` → imported geometry) and aren't directly generatable. - -### Validation - -The MCP validates with zod against the `ShapeKind` **union enum** + the base numerics only, -then runs the app's own `sceneShape`/`canonicalizeShape` to fill defaults and canonicalise. -There are **no hand-authored parameter ranges** — the app's canonicaliser is the single -source of truth. So: - -- a bad kind or malformed (non-numeric) field is **rejected** with a useful message, nothing - is staged; -- a valid-but-extreme shape (e.g. `rotation: 725`) is **canonicalised** (→ `5`), not rejected. - -## Example prompts → scenes - -- *"a 40 mm phone stand with a cable slot"* → base box + tilted backrest + front lip + - a `hole: true` cylinder for the cable slot. -- *"a pen holder, a 50 mm cylinder hollowed from the top"* → outer cylinder + inner - `hole: true` cylinder. -- *"a little toy house"* → a box body + a `roof` on top. - -## Iterating on a scene - -``` -get_scene(projectId) # read the current shapes -# edit the shape you want, e.g. widen the cable slot by 5 mm -set_scene(projectId, shapes) # re-stage; the editor updates in place -``` - -Because the scene lives in IndexedDB, it persists across reloads. While the user is dragging -a shape, an incoming push is deferred (not fought) and applied when the drag ends. - -## Tests - -``` -npm run test -``` - -- `tests/unit/sceneRoute.test.ts` — the `/api/scene` route handler (stage/poll, monotonic - `stagingRevision`, same-origin 403, validation 400, 204 semantics). -- `tests/unit/sceneSchema.test.ts` — the MCP schema validator (defaults via the app's - defaulter, cutter/grouped preserved, bad kind / malformed rejected, extreme canonicalised). - -## File map - -| Path | Role | -|------|------| -| `apps/web/src/app/api/scene/route.ts` | Bridge route (stages/serves commands). | -| `apps/web/src/lib/sceneBridge.ts` | `SceneTransport` interface + polling transport (V2 swap point). | -| `apps/web/src/app/page.tsx` | `useSceneBridge` poller hook + `applyBridgeCommand` (in `Home`). | -| `apps/mcp/` | MCP server: tools, zod schema, app-reused defaulter, example scenes. | -| `.codex/pending-scenes/.json` | Staged command (gitignored). | - -## V2 (later) - -The `SceneTransport` interface in `sceneBridge.ts` is the only forward-compatibility seam: -V2 replaces the polling transport with a WebSocket (`subscribe()`) so the MCP becomes the -live source of truth, while the route stays as a fallback and the `WorkplaneShape` contract -is unchanged. See `PLAN.md` → V2. diff --git a/tests/unit/sceneRoute.test.ts b/tests/unit/sceneRoute.test.ts deleted file mode 100644 index 53670e2..0000000 --- a/tests/unit/sceneRoute.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { promises as fs } from "node:fs"; -import path from "node:path"; -import { afterAll, describe, expect, it } from "vitest"; -import { GET, POST } from "@/app/api/scene/route"; - -const PENDING_DIR = path.join(process.cwd(), ".codex", "pending-scenes"); -const projectId = `project-vitest-${Date.now()}`; -const stagedFile = path.join(PENDING_DIR, `${projectId}.json`); - -function sceneRequest(body: unknown, headers: Record = {}) { - return new Request("http://127.0.0.1:3000/api/scene", { - method: "POST", - headers: { "Content-Type": "application/json", ...headers }, - body: JSON.stringify(body), - }); -} - -function getRequest(query: string, headers: Record = {}) { - return new Request(`http://127.0.0.1:3000/api/scene?${query}`, { method: "GET", headers }); -} - -const oneBox = { - projectId, - shapes: [{ id: "s1", name: "Box", kind: "box", color: "#d41721", x: 0, z: 0, size: 20, width: 20, depth: 20, height: 20, rotation: 0 }], -}; - -afterAll(async () => { - await fs.rm(stagedFile, { force: true }); -}); - -describe("/api/scene route", () => { - it("POSTs a scene, stages it, and GET returns it then 204 when caught up", async () => { - const postRes = await POST(sceneRequest(oneBox)); - expect(postRes.status).toBe(200); - const { stagingRevision } = (await postRes.json()) as { stagingRevision: number }; - expect(typeof stagingRevision).toBe("number"); - - // GET with sinceStaging=0 -> returns the staged command - const getNew = await GET(getRequest(`projectId=${projectId}&sinceStaging=0`)); - expect(getNew.status).toBe(200); - const command = (await getNew.json()) as { stagingRevision: number; op: string; shapes: unknown[] }; - expect(command.op).toBe("upsertScene"); - expect(command.shapes).toHaveLength(1); - expect(command.stagingRevision).toBe(stagingRevision); - - // GET with sinceStaging=current -> nothing newer -> 204 - const getCaughtUp = await GET(getRequest(`projectId=${projectId}&sinceStaging=${stagingRevision}`)); - expect(getCaughtUp.status).toBe(204); - }); - - it("assigns a strictly increasing stagingRevision on re-POST", async () => { - const first = (await (await POST(sceneRequest(oneBox))).json()) as { stagingRevision: number }; - const second = (await (await POST(sceneRequest(oneBox))).json()) as { stagingRevision: number }; - expect(second.stagingRevision).toBeGreaterThan(first.stagingRevision); - }); - - it("rejects a cross-origin request with 403", async () => { - const res = await POST(sceneRequest(oneBox, { Origin: "http://evil.example" })); - expect(res.status).toBe(403); - }); - - it("rejects a structurally invalid body with 400", async () => { - const res = await POST(sceneRequest({ projectId, shapes: "not-an-array" })); - expect(res.status).toBe(400); - }); - - it("returns 204 for an unknown project", async () => { - const res = await GET(getRequest(`projectId=project-does-not-exist-${Date.now()}&sinceStaging=0`)); - expect(res.status).toBe(204); - }); -}); diff --git a/tests/unit/sceneSchema.test.ts b/tests/unit/sceneSchema.test.ts deleted file mode 100644 index b9376b6..0000000 --- a/tests/unit/sceneSchema.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { SHAPE_KINDS, shapesArraySchema, toWorkplaneShapes, type ShapeInput } from "../../apps/mcp/src/shapes"; - -describe("MCP scene schema + normalisation", () => { - it("exposes all 18 shape kinds", () => { - expect(SHAPE_KINDS).toHaveLength(18); - expect(SHAPE_KINDS).toContain("box"); - expect(SHAPE_KINDS).toContain("mesh"); - }); - - it("accepts a minimal valid shape and fills defaults via the app's defaulter", () => { - const parsed = shapesArraySchema.parse([{ kind: "box", width: 40, depth: 40, height: 10 }]); - const [shape] = toWorkplaneShapes(parsed as ShapeInput[]); - expect(shape.kind).toBe("box"); - expect(typeof shape.color).toBe("string"); // auto-filled - expect(shape.color.length).toBeGreaterThan(0); - expect(typeof shape.size).toBe("number"); // derived by sceneShape - expect(typeof shape.id).toBe("string"); - expect(shape.name).toBeTruthy(); - }); - - it("preserves a cutter (hole: true) and grouped parts", () => { - const [shape] = toWorkplaneShapes( - shapesArraySchema.parse([ - { - kind: "box", - width: 40, - depth: 40, - height: 10, - groupedShapes: [{ kind: "cylinder", hole: true, width: 8, depth: 8, height: 12 }], - }, - ]) as ShapeInput[], - ); - expect(shape.groupedShapes).toHaveLength(1); - expect(shape.groupedShapes?.[0]?.hole).toBe(true); - }); - - it("rejects an invalid ShapeKind", () => { - const result = shapesArraySchema.safeParse([{ kind: "banana", width: 1, depth: 1, height: 1 }]); - expect(result.success).toBe(false); - if (!result.success) { - expect(JSON.stringify(result.error.issues)).toContain("invalid_enum_value"); - } - }); - - it("rejects a malformed numeric field", () => { - const result = shapesArraySchema.safeParse([{ kind: "box", width: "wide", depth: 10, height: 10 }]); - expect(result.success).toBe(false); - }); - - it("accepts an extreme shape and canonicalises rotation instead of rejecting", () => { - const parsed = shapesArraySchema.parse([{ kind: "box", width: 100000, depth: 100000, height: 100000, rotation: 725 }]); - const [shape] = toWorkplaneShapes(parsed as ShapeInput[]); - expect(shape.rotation).toBe(5); // 725 mod 360 via canonicalizeShape, not rejected - expect(shape.width).toBe(100000); // magnitude not range-rejected - }); -});