Skip to content

Modules ​

A module is a pure algorithm you import and call. Unlike snaptrude.*, which is an asynchronous conversation with the running editor, a module is imported, synchronous, deterministic and never touches the scene: it takes plain data and returns plain data, and the caller does every read and every write around it.

Three doors ​

DoorHow you reach it
A plugin workerimport { … } from "@snaptrude/plugin-toolkit/<export>"
The design agent's run_worker sandboxmodules.<group>.<name>.<fn>(…), already in scope
Node, a test, a scriptthe same npm package, no host needed

The unit rule ​

Every module input carries unit: "mm" | "cm" | "m" | "ft" | "in". Every length in that call is read and written in it — 30 stays 30 — and the output echoes the unit. Angles are degrees; areas are the unit squared. The modules' own defaults and tolerances are defined in millimetres and scaled to the unit, so they mean the same thing everywhere. Pass the project's unit and never convert a value yourself.

In scope in a worker body ​

The design agent's run_worker body sees three objects, all documented here:

ObjectWhat it is
modules.<group>.<name>the pure modules below, synchronous
inputs.last(module) / inputs.at(id)the input of an earlier traced module call, byte-identical — run.inputs
kept.<name>values an earlier body returned under keep: {…} — run.inputs

Build a module input once per chat; every later body is { ...inputs.last(m), field: value }.

Modules ​

ModuleImportWhat it does
pack.bubbleLayout@snaptrude/plugin-toolkit/pack-bubble-layoutArrange sized bubbles so that wished-for neighbours end up near each other and nothing overlaps.
pack.corridorBand@snaptrude/plugin-toolkit/pack-corridor-bandReserve a strip along a centreline and carve it out of the regions you are about to pack.
pack.corridorRuns@snaptrude/plugin-toolkit/pack-corridor-runsLay typed cells along corridor paths.
pack.footprintPlacement@snaptrude/plugin-toolkit/pack-footprint-placementSeat footprints inside a boundary.
pack.linearArray@snaptrude/plugin-toolkit/pack-linear-arrayFit items of known width along aligned segments.
pack.rooms@snaptrude/plugin-toolkit/pack-roomsSubdivide a boundary into one cell per room, areas proportional to targets, and return N ranked candidates.
geom.circlePacking@snaptrude/plugin-toolkit/geom-circle-packingCircle packing primitives: keep a set of plan circles from overlapping, and keep them inside a ring.
geom.polygonBoolean@snaptrude/plugin-toolkit/geom-polygon-booleanPlan-polygon booleans and offsetting: set operations on regions with holes, stroking a centreline into a band, and the per-edge mitre inset a setback is.
geom.polygon@snaptrude/plugin-toolkit/geom-polygonThe plan-polygon primitives every pack module shares: area and winding, centroid, bounding boxes, containment, distance, segment and ring intersection, ring simplicity, convex hull, minimum-width strip (OBB), shared-edge length, transforms, convex-window clipping, SAT separation and hole bridging.
geom.polylineFrame@snaptrude/plugin-toolkit/geom-polyline-frameArc-length frame along a plan polyline.
run.inputs@snaptrude/plugin-toolkit/run-inputsWhat a worker body can carry over from earlier bodies.