bambu-printer-mcp 1.1.91 → 1.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTORS.md +2 -0
- package/README.md +5 -3
- package/dist/bambu-native.js +1 -1
- package/dist/cad/contracts.js +16 -7
- package/dist/cad/examples.d.ts +2 -1
- package/dist/cad/examples.js +13 -10
- package/dist/cad/serial.d.ts +1 -1
- package/dist/cad/serial.js +4 -6
- package/dist/cad-engine.js +17 -12
- package/dist/index.js +39 -23
- package/dist/printers/bambu.d.ts +6 -0
- package/dist/printers/bambu.js +32 -6
- package/dist/safety/limits.d.ts +6 -0
- package/dist/safety/limits.js +8 -0
- package/dist/safety/print-file.js +2 -2
- package/dist/safety/printer-state.d.ts +4 -0
- package/dist/safety/printer-state.js +14 -1
- package/dist/studio-print-options.d.ts +9 -0
- package/dist/studio-print-options.js +34 -2
- package/package.json +1 -1
- package/src/bambu-native.ts +1 -1
- package/src/cad/contracts.ts +17 -7
- package/src/cad/examples/bag_clip.py +1 -0
- package/src/cad/examples/bistable_clicker.py +1 -0
- package/src/cad/examples/broom_grip.py +61 -0
- package/src/cad/examples/cable_clip.py +1 -0
- package/src/cad/examples/chainmail.py +1 -0
- package/src/cad/examples/desk_clamp_hook.py +91 -0
- package/src/cad/examples/desk_edge_cable_holder.py +55 -0
- package/src/cad/examples/drawer_divider.py +56 -0
- package/src/cad/examples/hinged_box.py +1 -0
- package/src/cad/examples/knurled_knob.py +1 -0
- package/src/cad/examples/loft_handle.py +1 -0
- package/src/cad/examples/organizer_tray.py +41 -0
- package/src/cad/examples/phone_stand.py +1 -0
- package/src/cad/examples/plant_pot.py +53 -0
- package/src/cad/examples/shelf_bracket.py +53 -0
- package/src/cad/examples/swept_hook.py +1 -0
- package/src/cad/examples/threaded_jar.py +1 -0
- package/src/cad/examples/trigger_capo.py +1 -0
- package/src/cad/examples/wall_hook.py +1 -0
- package/src/cad/examples.ts +13 -10
- package/src/cad/geometry.py +6 -0
- package/src/cad/serial.ts +4 -6
- package/src/cad-engine.ts +9 -3
- package/src/index.ts +36 -19
- package/src/printers/bambu.ts +30 -5
- package/src/safety/limits.ts +8 -0
- package/src/safety/print-file.ts +2 -2
- package/src/safety/printer-state.ts +13 -1
- package/src/studio-print-options.ts +33 -2
package/CONTRIBUTORS.md
CHANGED
|
@@ -6,6 +6,8 @@ Thank you to everyone who builds, tests, reports problems, and shares real print
|
|
|
6
6
|
|
|
7
7
|
| Contributor | Contribution |
|
|
8
8
|
| --- | --- |
|
|
9
|
+
| [ianhyzy](https://github.com/ianhyzy) | Contributes the one-way P1S-file/P1P-printer compatibility change in [#140](https://github.com/DMontgomery40/bambu-printer-mcp/pull/140), with P1P enclosure-kit hardware, firmware and Bambu Studio inspection evidence. Integration adds mocked route and live-identity regressions; those tests do not establish a physical MCP print. |
|
|
10
|
+
| [geooff](https://github.com/geooff) | Contributes X1C firmware 01.12 external-slot normalization and the opt-in native print/upload route in [#128](https://github.com/DMontgomery40/bambu-printer-mcp/pull/128), with one reported physical macOS X1C print to an SD card using an AMS 2 Pro slot. Linux, other X1C firmware and X1E hardware remain unverified. Integration adds fresh storage-capability and mocked dispatch/resume regressions; these do not independently verify physical printing. |
|
|
9
11
|
| [Rowan McMahon (RowanMcMahon)](https://github.com/RowanMcMahon) | Reports A1 firmware 01.08.01.00 retaining `FAILED` after a stopped job and contributes the narrow terminal-state fix and regression tests in [#133](https://github.com/DMontgomery40/bambu-printer-mcp/pull/133). Supplies fresh MQTT evidence and reports a subsequent job reaching `FINISH`; this is contributor-reported status, not inspected physical-part verification. |
|
|
10
12
|
| [billh-hub](https://github.com/billh-hub) | Reports and isolates three official H2C time-lapse and filament-change command rejections in [#84](https://github.com/DMontgomery40/bambu-printer-mcp/issues/84), supplies emitted commands and multi-colour reproduction evidence, and distinguishes the unknown cooling parameter for source-backed investigation. The correction preserves independent safety checks; no maintainer physical printing is claimed. |
|
|
11
13
|
| [Steve Pritchard (sjpritchard)](https://github.com/sjpritchard) | Reports and diagnoses H2C per-variant first-layer temperature rejection in [#81](https://github.com/DMontgomery40/bambu-printer-mcp/issues/81), supplies the exact official preset metadata and reproduction, and identifies the upstream variant-mapping contract. Verification uses synthetic slicing and offline regressions, not physical printing. |
|
package/README.md
CHANGED
|
@@ -1027,6 +1027,8 @@ The npm package and desktop bundle include `native/bambu-native-print.cpp`, `scr
|
|
|
1027
1027
|
|
|
1028
1028
|
For X2D, `print_3mf` defaults to `connection_mode: "bambu_native"`; legacy `lan_mqtt_ftps` requests are redirected to it. Supply `ams_slots`, a complete project-level `ams_mapping`, or `auto_match_ams: true`. A job that uses only one external spool requires explicit `use_ams: false`; a job mixing AMS trays with the external spools maps them as `254` (left/deputy nozzle) and `255` (right/main nozzle). Raw `ams_mapping2` and nozzle/extra-option overrides are rejected before dispatch; the server derives both AMS representations from the checked structured mapping. Model/nozzle/material inspection and fresh printer-state checks apply before the helper receives a private snapshot. The native helper requests fresh shared printer-state authorization immediately before each print submission, including a certificate retry, and before checked heating, resume, or error-clearing commands; custom helpers must support this handshake. Stop and heater-off remain available without preflight. Native upload-only requests use the same all-plate inspection as FTPS uploads. They accept `project_name`, `preset_name`, `bed_type`, and an existing `plate_index`; AMS, nozzle, and calibration print options are rejected. Use `print_3mf` for checked print settings.
|
|
1029
1029
|
|
|
1030
|
+
X1C can opt in to the same route with `connection_mode: "bambu_native"` on `print_3mf` or `upload_file`; its default stays `lan_mqtt_ftps` and nothing is redirected. Use it when the printer refuses direct FTPS uploads: an X1C on firmware 01.12.00.00 (LAN Only and Developer Mode on, a ready writable SD card) answered every FTPS `STOR` with `553 Could not create file.` while Bambu Studio printed normally, and an X1C `print_3mf` or `upload_file` that fails with 553 now names this route. The same inspection, AMS mapping and fresh printer-state checks apply. Native X1C printing requires a freshly reported ready SD card or USB stick unless fresh status advertises internal-printing support (`fun2` bit 0, as Bambu Studio reads it). Explicit or environment eMMC requests without that capability are refused, and storage readiness/capability is rechecked before dispatch. That X1C completed a native print on macOS (AMS slot, SD card storage); Linux and other X1C firmware are untested, and X1E is not enabled. Native controls (`x2d_native_control`, native heating and error clearing) remain X2D-only: an X1C job is stopped, paused and resumed over direct MQTT, even when the request names `bambu_native`.
|
|
1031
|
+
|
|
1030
1032
|
The helper waits for connection/certificate exchange and retries only the initial `-4030` send once. Rebuild the helper after upgrading to receive the teardown fix. A successful dispatch receipt ends the helper before plug-in cleanup can turn an accepted job into an error. If an older/custom helper crashes after dispatch, the server reports uncertainty: check the printer state and job name before retrying, because resending can duplicate a print. Previous hardware testing reached `RUNNING` on X2D; this revision is validated with mocked transport regressions and clean installs, not a new physical print. `bambu_connect` is an optional macOS handoff for user review in Bambu Connect and does not start a print. Native task, heater, and error controls retain the common safety checks; raw controls cannot bypass them. Request cancellation, stop, and heater-off interrupt pending native helpers; the server waits for process exit before releasing a checked file. A command already sent to the printer cannot be recalled by cancelling the request, so verify printer state before retrying.
|
|
1031
1033
|
|
|
1032
1034
|
#### X2D native transport (Linux)
|
|
@@ -1317,7 +1319,7 @@ Check only by default. `{"install":true}` installs a pinned isolated environment
|
|
|
1317
1319
|
|
|
1318
1320
|
#### cad_run
|
|
1319
1321
|
|
|
1320
|
-
Read the `cad_design` prompt first. Supply `script` or a saved `script_path`, `output_dir`, and `name`. Scripts declare literal `P = {...}` parameters and a `build()` function returning a build123d shape. One later call with `script_path` and `parameters` changes a dimension and rebuilds. Each run creates a new subfolder and preserves its source/parameter checkpoint, even on failure. The result contains STL/STEP paths, measured geometry, validity checks, six orthographic views, a perspective view and a contact sheet with the perspective view large beside the six.
|
|
1322
|
+
Read the `cad_design` prompt first. Supply `script` or a saved `script_path`, `output_dir`, and `name`. Scripts declare literal `P = {...}` parameters and a `build()` function returning a build123d shape. One later call with `script_path` and `parameters` changes a dimension and rebuilds. Each run creates a new subfolder and preserves its source/parameter checkpoint, even on failure. The result contains STL/STEP paths, measured geometry, validity checks, six orthographic views, a perspective view and a contact sheet with the perspective view large beside the six; `next` says to read the perspective view before the next change, and `printed` carries whatever the script wrote with `print()` (up to 4000 characters), so a design can report a number it computed.
|
|
1321
1323
|
|
|
1322
1324
|
Explicit `inputs: [{"name": "scan", "path": "/allowed/scan.stl"}]` snapshots the files a script may read as `INPUTS["scan"]`. For a mesh-only edit, use `mode: "mesh"` and return `trimesh.Trimesh`: it exports and validates STL plus renders, with `step: null` and a clear reason. For captured meshes, the injected `load_scan` helper takes explicit source units and an up-axis, converts coordinates to millimetres/Z-up, and grounds the mesh without fitting its size. Cleanup choices and labels belong to the caller’s rules; the MCP supplies execution, mesh libraries, checks and renders.
|
|
1323
1325
|
|
|
@@ -1329,11 +1331,11 @@ Unchanged declared inputs reuse immutable content-hash bundles, with `snapshot_b
|
|
|
1329
1331
|
|
|
1330
1332
|
#### cad_examples
|
|
1331
1333
|
|
|
1332
|
-
The code engine's cookbook:
|
|
1334
|
+
The code engine's cookbook: nineteen worked build123d designs from simple to complex (cable clip, wall hook, drawer divider, organiser tray, plant pot, knurled knob, phone stand, swept headphone hook, lofted tool handle, shelf bracket, broom grip, desk-edge cable holder, threaded jar, desk-clamp headphone hook, bag clip, hinged box, bistable clicker, chainmail, trigger capo), each modelled on the best bought version of the thing, with what it is for, its concept, the published sizes it used and its script. Without arguments it lists them by purpose (`use_for`) with the pattern each shows; with `name` it returns one record and script. The `cad_design` prompt names every example by its purpose in one line, so a design worker chooses the one made for the nearest request before it chooses a mechanism. Read-only; needs no CAD runtime. The scripts are in `src/cad/examples/`.
|
|
1333
1335
|
|
|
1334
1336
|
#### cad_check_fit
|
|
1335
1337
|
|
|
1336
|
-
Check a model and reference STL with an explicit rigid transform. Returns interference volume and minimum surface gap, without quietly scaling a scan. Open/nonmanifold meshes are refused. A gap of zero includes intentional floor contact, so choose clearance checks to match the interface you actually want to measure.
|
|
1338
|
+
Check a model and reference STL with an explicit rigid transform. Returns interference volume and minimum surface gap, without quietly scaling a scan. Open/nonmanifold meshes are refused. A gap of zero includes intentional floor contact, so choose clearance checks to match the interface you actually want to measure. Like `cad_run`, a check waits for the engine's execution slot up to its `timeout_ms` and returns `queue_wait_ms`, so several can be sent at once.
|
|
1337
1339
|
|
|
1338
1340
|
See [CAD setup, confinement, script contract and removal](docs/CAD.md) for configuration, examples and limits.
|
|
1339
1341
|
|
package/dist/bambu-native.js
CHANGED
|
@@ -131,7 +131,7 @@ function isRegularFile(file) {
|
|
|
131
131
|
*/
|
|
132
132
|
function resolveNativeInstall() {
|
|
133
133
|
if (!isBambuNativePlatform()) {
|
|
134
|
-
throw new Error("Bambu native
|
|
134
|
+
throw new Error("Bambu native transport requires macOS or x86-64 Linux and Bambu's networking plug-in.");
|
|
135
135
|
}
|
|
136
136
|
const helper = resolveNativeHelper();
|
|
137
137
|
if (process.platform !== "linux")
|
package/dist/cad/contracts.js
CHANGED
|
@@ -103,7 +103,7 @@ export const CAD_TOOLS = [
|
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
name: "cad_run",
|
|
106
|
-
description: "Build parametric CAD headlessly in OS confinement. Read cad_design first: declare literal P = {...} and build() returning a build123d Shape. Supply script OR script_path; parameters overrides saved named values in one call before derived dimensions. Calls wait for the environment’s exclusive execution slot up to their own deadline and report queue_wait_ms. Each call creates a private immutable subfolder under allowed output_dir, never overwriting previous artifacts. The saved .py and .parameters.json are the recovery checkpoint even after cancellation. Returns independently measured geometry, STL/STEP, six orthographic renders, a perspective view and a contact sheet, the closest approach between every pair of solids (bodies), problems,
|
|
106
|
+
description: "Build parametric CAD headlessly in OS confinement. Read cad_design first: declare literal P = {...} and build() returning a build123d Shape. Supply script OR script_path; parameters overrides saved named values in one call before derived dimensions. Calls wait for the environment’s exclusive execution slot up to their own deadline and report queue_wait_ms. Each call creates a private immutable subfolder under allowed output_dir, never overwriting previous artifacts. The saved .py and .parameters.json are the recovery checkpoint even after cancellation. Returns independently measured geometry, STL/STEP, six orthographic renders, a perspective view and a contact sheet (with next: read the perspective view before the next change), the closest approach between every pair of solids (bodies), problems, what was checked and not checked, and printed: whatever the script wrote with print(), capped at 4000 characters, so a design can report a number it computed; valid means only that the exported geometry is sound, never that the part fits, holds, moves or prints.",
|
|
107
107
|
inputSchema: {
|
|
108
108
|
type: "object",
|
|
109
109
|
properties: {
|
|
@@ -204,6 +204,11 @@ export const CAD_TOOLS = [
|
|
|
204
204
|
checked: { type: "array", items: { type: "string" } },
|
|
205
205
|
not_checked: { type: "array", items: { type: "string" } },
|
|
206
206
|
renders: { type: "object", additionalProperties: { type: "string" } },
|
|
207
|
+
next: { type: "string", description: "What to do before the next change: look at the perspective render." },
|
|
208
|
+
printed: {
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "The script's own print() output from this run, capped at 4000 characters (build.log keeps the rest). The script's words, not a measurement by the engine.",
|
|
211
|
+
},
|
|
207
212
|
seconds: { type: "number" },
|
|
208
213
|
}, [
|
|
209
214
|
"valid",
|
|
@@ -227,7 +232,7 @@ export const CAD_TOOLS = [
|
|
|
227
232
|
},
|
|
228
233
|
{
|
|
229
234
|
name: "cad_examples",
|
|
230
|
-
description: "The code engine's cookbook: worked build123d designs from simple to complex, each modelled on the best bought version of the thing, with its concept, published sizes and script. Without arguments, lists them (name, title, the pattern
|
|
235
|
+
description: "The code engine's cookbook: worked build123d designs from simple to complex, each modelled on the best bought version of the thing, with its concept, published sizes and script. Without arguments, lists them by purpose (name, title, use_for: the requests it suits, the pattern it shows, the product it is modelled on): choose by use_for before choosing a mechanism. With name, returns that example's record and full script to adapt. Read-only; starts no process.",
|
|
231
236
|
inputSchema: {
|
|
232
237
|
type: "object",
|
|
233
238
|
properties: {
|
|
@@ -246,15 +251,17 @@ export const CAD_TOOLS = [
|
|
|
246
251
|
properties: {
|
|
247
252
|
name: { type: "string" },
|
|
248
253
|
title: { type: "string" },
|
|
254
|
+
use_for: { type: "string" },
|
|
249
255
|
pattern: { type: "string" },
|
|
250
256
|
modelled_on: { type: "string" },
|
|
251
257
|
},
|
|
252
|
-
required: ["name", "title", "pattern"],
|
|
258
|
+
required: ["name", "title", "use_for", "pattern"],
|
|
253
259
|
},
|
|
254
260
|
},
|
|
255
261
|
usage: { type: "string" },
|
|
256
262
|
name: { type: "string" },
|
|
257
263
|
title: { type: "string" },
|
|
264
|
+
use_for: { type: "string" },
|
|
258
265
|
pattern: { type: "string" },
|
|
259
266
|
modelled_on: { type: "string" },
|
|
260
267
|
published_sizes: { type: "string" },
|
|
@@ -265,7 +272,7 @@ export const CAD_TOOLS = [
|
|
|
265
272
|
},
|
|
266
273
|
{
|
|
267
274
|
name: "cad_check_fit",
|
|
268
|
-
description: "Check two allowed watertight manifold STL meshes in millimetres. Applies only the explicit rigid transform to reference: XYZ rotation in degrees about the origin, then translation. Never silently scales a scan. Reports Boolean interference volume and minimum surface gap (zero on contact/intersection), plus a clearance verdict; intentional support contact also has zero gap. Fails rather than guessing for open meshes or excessive triangle workload.",
|
|
275
|
+
description: "Check two allowed watertight manifold STL meshes in millimetres. Applies only the explicit rigid transform to reference: XYZ rotation in degrees about the origin, then translation. Never silently scales a scan. Reports Boolean interference volume and minimum surface gap (zero on contact/intersection), plus a clearance verdict; intentional support contact also has zero gap. Like cad_run, a call waits for the environment's exclusive execution slot up to its timeout_ms and reports queue_wait_ms, so several checks may be sent at once. Fails rather than guessing for open meshes or excessive triangle workload.",
|
|
269
276
|
inputSchema: {
|
|
270
277
|
type: "object",
|
|
271
278
|
properties: {
|
|
@@ -309,6 +316,7 @@ export const CAD_TOOLS = [
|
|
|
309
316
|
},
|
|
310
317
|
outputSchema: output({
|
|
311
318
|
units: { type: "string", const: "mm" },
|
|
319
|
+
queue_wait_ms: { type: "integer" },
|
|
312
320
|
interference_volume_mm3: { type: "number" },
|
|
313
321
|
minimum_gap_mm: { type: "number" },
|
|
314
322
|
clearance_mm: { type: "number" },
|
|
@@ -330,9 +338,10 @@ export const CAD_DESIGN_PROMPT = {
|
|
|
330
338
|
title: "Parametric code-CAD design",
|
|
331
339
|
description: "MCP-owned rules for headless build123d designs and one-call parameter revisions.",
|
|
332
340
|
text: `Use code-CAD for dimensioned functional designs and parameter edits. Build in millimetres with build123d 0.13.0; the MCP owns the Python environment, execution, export, validation and rendering. Check cad_status and use cad_setup with install: true when needed. No Blender, Fusion, network or printer access is available to your script.
|
|
333
|
-
|
|
334
|
-
|
|
341
|
+
A new design starts from the product, in this order. First, name two or three products a person would buy for this request (search when you are not sure what is sold) and say which one the design follows. Second, choose from the cookbook by purpose: the list below says what each example is for (cad_examples with no name returns it with each one's pattern and product). Read the example whose use is nearest the request, with cad_examples and its name, before deciding anything else, and adapt its form and pattern, never its sizes. Third, and only then, choose the mechanism (a clamp, screw, spring, hinge or snap) and read a second example for it if you need one. A mechanism chosen before the product gives a bracket with the mechanism bolted on.
|
|
342
|
+
The cookbook, by what each example is for:
|
|
335
343
|
${cadExampleLines()}
|
|
344
|
+
Form first: build the product's shape, not a profile pushed up. Before any geometry, write the concept as the script's opening docstring, the way every cookbook example does: what it is, then "Modelled on:" the bought product you named, its mechanism, the load path, the print orientation and why. A script whose header names no product was designed from the mechanism. build123d has loft (through sections of different shape), sweep (a section along a path or a Helix), revolve, fillet, chamfer, offset and shell as well as extrude; use the one the product's surface calls for: lofted where a hand closes round it, revolved where it turns, swept where it runs like a bent rod or a thread, filleted where two surfaces meet under load. Extrude a flat profile only for something that really is a plate or a lever, or for a print-in-place mechanism or spring that must lie in the layers, and say that reason in the result. Choose the print orientation after the form: split a part, turn it or accept a modest support before flattening its design.
|
|
336
345
|
What the cookbook taught about this engine: return several bodies as Compound([a, b]); bodies that touch or overlap come back invalid, so leave a real gap (0.2 mm or more) or union them, and check that solid_count equals the bodies you intend (for a print-in-place mechanism that count is the first evidence nothing fused). fillet() often fails on the edges of an outline unioned from many curves, where chamfer() usually succeeds: fillet or chamfer simple bodies before the booleans that complicate them, and when a chamfer fails too, apply it to the plain body and union the details on afterwards. Do not round a sketch by growing and shrinking it with offset(): the solid looks right and its STEP comes back with no solids (the step_solids check fails). A whole Sphere() exports open at its poles: trim them (Sphere(r) & Box(2 * r, 2 * r, 2 * r - 0.1)). One fillet of the same radius over every edge of a box can export open: fillet in two passes with different radii. A model with moving parts takes a pose parameter: the assembled pose to judge it, the print plate to make it.
|
|
337
346
|
Declare exactly one top-level P = {...} dictionary of JSON-compatible literal named parameters. Put every functional dimension in P; derive geometry from P. Define build() to return a build123d Shape or Compound of disjoint solid parts. When a design has separate bodies (print-in-place parts, a captive wheel, links of a fabric), return Compound(children=[...]) with a label on each body: cad_run then checks that each labelled body is exactly one solid, so a piece cut off one body cannot hide behind two bodies fused into one. Near pairs of solids are screened and, where the screen cannot clear them, measured exactly against P["print_in_place_clearance_mm"] when you declare it, else 0.3 mm. If the bodies are shown assembled rather than printed in place (a shaft in its hole at a fit clearance), set P["print_in_place"] = False: only touching or overlap is then a problem. Export in print orientation with the plate at Z = 0: a solid below it, or above it with nothing under it that reaches it, is a problem. Do not put construction or exports in a __main__ block: cad_run calls build() and exports the result. Imports, functions and derived P entries are fine. Parameters are applied to the literal defaults before derived expressions execute. For solid designs without inputs, the script and parameters file alone reconstruct it. For input-dependent designs, declare inputs as an array of {name, path} files: cad_run snapshots only those allowed files, exposes INPUTS[alias] to your script, and saves an inputs manifest. Retain the snapshots too for recovery; subsequent script_path edits reuse them unless inputs is explicitly supplied. No other personal files are readable. For a mesh-only experiment use mode: "mesh" and return a trimesh.Trimesh from build(); it exports and checks STL plus the same renders, with step: null and an explicit reason. It does not manufacture a fake parametric STEP or promise scan-cleanup capability.
|
|
338
347
|
Call cad_run with script, output_dir and a plain name. It saves <name>.py and <name>.parameters.json before running, then exports <name>.stl and <name>.step in a fresh subfolder. For an edit, one cad_run with script_path pointing to the earlier .py, parameters containing just the changed dimension, output_dir and name regenerates it without resending the script. Existing parameter values are retained; unknown names and type changes are refused. A killed run can be retried from its checkpoint in a new workspace; mutations are never replayed automatically.
|
|
@@ -341,7 +350,7 @@ Fit reference workflow: return load_scan("scan", source_units="m", up_axis="y")
|
|
|
341
350
|
Result selection and edits: set final: true only on the result you select. cad-result.json in each immediate run folder is protected from script writes and retains final, completed_at, lineage_id (source hash), full checks and artifact paths; clients can discover the latest completed final record after restart without rebuilding. Final is a selection marker, not a replacement for valid/checks. Queued calls may expire with cad-queue-timeout before dispatch; do not automatically replay. Unchanged declared files reuse a read-only content-addressed bundle under output_dir/.cad-inputs, preserving filenames and restricting reads to that bundle. Keep this shared cache with the saved runs.
|
|
342
351
|
Mesh cleanup workflow: return a trimesh.Trimesh in mode: "mesh". Load the prepared mesh, fit needed geometry with NumPy/SciPy, rebuild regular sections/features with build123d or manifold3d CrossSection/extrusion/revolve, and combine meshes with manifold3d booleans. scikit-image supplies marching cubes for voxel/SDF work; Shapely supplies planar operations; Pillow supplies image/texture reads. Keep numeric choices in P and regenerate from declared inputs. Validate closure, winding, manifold status, dimensions and all six views using cad_run. What to regularise, infer, preserve or label comes from the caller's cleanup rules, not this engine prompt.
|
|
343
352
|
Captured scan touch-up: t = scan_touchup(load_scan("scan", source_units="m", up_axis="y", ground=False), colour="colour", normal="normal", edge_mm=0.4) takes a textured capture (declare its OBJ, MTL and colour and normal map PNGs as inputs; pass the map aliases). It removes loose pieces and spikes, closes holes and refines to edge_mm without shrinking the body. t.regions() prints the colour regions (id, colour, area, size, flatness; 0 is the body) to build.log and saves regions.png in the run folder: read both, then name regions by id in the same scan and edge_mm. t.flatten(ids, shape="plane" or "curved"), t.bead(id, diameter_mm, proud_mm), t.cord(id, diameter_mm, proud_mm) (a cord follows its region's own curve) and t.seat(height_mm) record steps; return t.mesh(relief_gain=1.0), which adds the normal map's measured relief, applies the steps with manifold3d and prints its changes. Keep relief_gain at 1: a larger gain amplifies the map's noise, not stitches. When the caller's rules call for a textile's relief the scan missed (fabric, knit, crochet the photos show raised), t.texture_relief(height_mm, regions=None) raises its stitch pattern from the colour texture on the textile only (never flattened, beaded or corded regions); about 0.6 to 1.0 mm peak to peak prints visibly. It is off unless called: never for hard objects, printed graphics or labels.
|
|
344
|
-
The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
|
|
353
|
+
The result includes paths, millimetre bounds/size, mesh and STEP volumes, solid count, watertight/manifold/winding/STEP checks, bodies (closest approach between solids, contact with the print plate at Z = 0, labelled bodies that are not one solid), problems, checked and not_checked, six orthographic renders (front, back, left, right, top, bottom), a perspective view from the front right and above, and a contact sheet with the perspective view large beside the six. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. After every cad_run, Read its perspective view (renders.perspective, as the result's next says) before the next cad_run or any other change: a run you have not looked at tells you nothing about the form. Judge the form from the perspective view first: would a person recognise the product and want it? Then inspect all six; revise visible defects. Before the final run, list what the views show is wrong against the bought product you named (for a scan, the object in its photos), and fix each one or report it. To get a number out of a design (a spring force, a strain, a clearance you derived), print() it in the script: the result returns it as printed, with no need to make a run fail. A valid mesh or nominal parameter does not prove the requested dimension: measure the actual exported interfaces. Use cad_check_fit on a model and reference STL with an explicit rigid transform; report raw-scan interference and minimum gap. Calipers are authoritative but disagreement with a scan is unresolved measurement evidence, not permission to silently rescale it. Check assembly/insertion paths and actual articulated poses, not sums of local joint limits or reference points alone. Printing, clearance under load, supports and motion need separate evidence.
|
|
345
354
|
Fit, flexure and thread parameters: put each interface's nominal size, its source (measured, published, or assumed), the print correction, and the design fit in P as separate named values, so a fit report revises one number without resending the script. Model every dimension you claim: a parameter the geometry never uses (a wallet or case width that no cut or wall reads) is a defect; use it or remove it. Shape flexures so their bending lies in the layer plane of the exported print orientation, with the stroke, preload, and hard-stop gap as P values; build the stopped pose as well as the rest pose when checking. Model printed threads as explicit coarse geometry with the same pitch on both sides and clearance as a radial P offset; never scale a screw to clear its hole.
|
|
346
355
|
Check insertion and articulated poses with cad_check_fit against each object state that matters (the bare product, the product in its case, and the case with its attachment as its own reference envelope), including the widest section on the way in. Report interference and minimum gap per state. In your summary, attach each "fits", "holds", and "prints without supports" claim to the check or slice number that shows it; a valid flag alone shows none of them. Apply fdm_design and fdm_slicing too. When a part meets a real object apply fdm_fit, and when it flexes, grips, snaps or springs apply fdm_flexures: if they were not attached, read them with the design_guidance tool before choosing that fit or spring. Never invoke a printer as part of constructing CAD.`,
|
|
347
356
|
};
|
package/dist/cad/examples.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const FIELDS: {
|
|
2
|
+
readonly "Use for": "use_for";
|
|
2
3
|
readonly Pattern: "pattern";
|
|
3
4
|
readonly "Modelled on": "modelled_on";
|
|
4
5
|
readonly "Published sizes used": "published_sizes";
|
|
@@ -15,7 +16,7 @@ export type CadExample = {
|
|
|
15
16
|
export declare const CAD_EXAMPLE_ORDER: string[];
|
|
16
17
|
/** Every example on disk, in cookbook order (unlisted files last, by name). Empty when the folder is missing. */
|
|
17
18
|
export declare function cadExamples(): CadExample[];
|
|
18
|
-
/** One line per example for the cad_design prompt: "name: what it is
|
|
19
|
+
/** One line per example for the cad_design prompt: "name: what it is for". */
|
|
19
20
|
export declare function cadExampleLines(): string;
|
|
20
21
|
/** cad_examples: without a name, the list; with one, that example's record and script. */
|
|
21
22
|
export declare function cadExamplesTool(args: Record<string, unknown>): Record<string, unknown>;
|
package/dist/cad/examples.js
CHANGED
|
@@ -4,14 +4,16 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
/**
|
|
5
5
|
* The code engine's cookbook: worked build123d designs, each modelled on the best bought version of the thing, kept as
|
|
6
6
|
* plain scripts in src/cad/examples/. A design worker reaches them only through this MCP: the cad_design prompt names
|
|
7
|
-
* each
|
|
8
|
-
* line per example instead of a script per example.
|
|
7
|
+
* each one by what it is for in one line, and the read-only cad_examples tool lists them and returns one script on
|
|
8
|
+
* request, so the prompt pays a line per example instead of a script per example.
|
|
9
9
|
*
|
|
10
|
-
* A script's header (its docstring) is the record: title on the first line, then "
|
|
11
|
-
*
|
|
10
|
+
* A script's header (its docstring) is the record: title on the first line, then "Use for:" (the requests it suits,
|
|
11
|
+
* so a worker chooses by purpose before mechanism), "Pattern:", "Modelled on:", "Published sizes used:", "Concept:"
|
|
12
|
+
* and "What makes this good:".
|
|
12
13
|
*/
|
|
13
14
|
const DIR = fileURLToPath(new URL("../../src/cad/examples/", import.meta.url));
|
|
14
15
|
const FIELDS = {
|
|
16
|
+
"Use for": "use_for",
|
|
15
17
|
"Pattern": "pattern",
|
|
16
18
|
"Modelled on": "modelled_on",
|
|
17
19
|
"Published sizes used": "published_sizes",
|
|
@@ -20,8 +22,9 @@ const FIELDS = {
|
|
|
20
22
|
};
|
|
21
23
|
/** Simplest first: the order the list and the prompt present them in. */
|
|
22
24
|
export const CAD_EXAMPLE_ORDER = [
|
|
23
|
-
"cable_clip", "wall_hook", "
|
|
24
|
-
"
|
|
25
|
+
"cable_clip", "wall_hook", "drawer_divider", "organizer_tray", "plant_pot", "knurled_knob", "phone_stand",
|
|
26
|
+
"swept_hook", "loft_handle", "shelf_bracket", "broom_grip", "desk_edge_cable_holder", "threaded_jar",
|
|
27
|
+
"desk_clamp_hook", "bag_clip", "hinged_box", "bistable_clicker", "chainmail", "trigger_capo",
|
|
25
28
|
];
|
|
26
29
|
function parse(name, script) {
|
|
27
30
|
const header = /^\s*"""([\s\S]*?)"""/.exec(script)?.[1] ?? "";
|
|
@@ -57,9 +60,9 @@ export function cadExamples() {
|
|
|
57
60
|
.sort((a, b) => rank(a.name) - rank(b.name) || a.name.localeCompare(b.name));
|
|
58
61
|
return cache;
|
|
59
62
|
}
|
|
60
|
-
/** One line per example for the cad_design prompt: "name: what it is
|
|
63
|
+
/** One line per example for the cad_design prompt: "name: what it is for". */
|
|
61
64
|
export function cadExampleLines() {
|
|
62
|
-
return cadExamples().map((e) => `${e.name}: ${e.
|
|
65
|
+
return cadExamples().map((e) => `${e.name}: ${e.use_for}`).join("\n");
|
|
63
66
|
}
|
|
64
67
|
/** cad_examples: without a name, the list; with one, that example's record and script. */
|
|
65
68
|
export function cadExamplesTool(args) {
|
|
@@ -69,8 +72,8 @@ export function cadExamplesTool(args) {
|
|
|
69
72
|
const all = cadExamples();
|
|
70
73
|
if (args.name === undefined)
|
|
71
74
|
return {
|
|
72
|
-
examples: all.map(({ name, title, pattern, modelled_on }) => ({ name, title, pattern, modelled_on })),
|
|
73
|
-
usage: "Call cad_examples with
|
|
75
|
+
examples: all.map(({ name, title, use_for, pattern, modelled_on }) => ({ name, title, use_for, pattern, modelled_on })),
|
|
76
|
+
usage: "Choose by use_for: the example made for the nearest request, before you choose a mechanism. Call cad_examples with that name to read its concept and script. Adapt the form and pattern to the request and to the product the person means; do not paste an example's sizes onto a different object.",
|
|
74
77
|
};
|
|
75
78
|
if (typeof args.name !== "string")
|
|
76
79
|
throw new Error("name must be a string.");
|
package/dist/cad/serial.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** One dispatched operation per environment; runs queue across processes and never replay. */
|
|
1
|
+
/** One dispatched operation per environment; runs and fit checks queue across processes and never replay. */
|
|
2
2
|
export declare function withCadLock<T>(data: string, options: {
|
|
3
3
|
operation: "setup" | "run" | "fit";
|
|
4
4
|
deadline?: number;
|
package/dist/cad/serial.js
CHANGED
|
@@ -15,13 +15,13 @@ function dead(pid) {
|
|
|
15
15
|
return e.code === "ESRCH";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
/** One dispatched operation per environment; runs queue across processes and never replay. */
|
|
18
|
+
/** One dispatched operation per environment; runs and fit checks queue across processes and never replay. */
|
|
19
19
|
export async function withCadLock(data, options, work) {
|
|
20
20
|
await fs.mkdir(data, { recursive: true, mode: 0o700 });
|
|
21
21
|
const lock = path.join(data, "operation.lock"), queue = path.join(data, "queue");
|
|
22
22
|
const start = performance.now();
|
|
23
23
|
let ticket, temporary;
|
|
24
|
-
const queued = options.operation
|
|
24
|
+
const queued = options.operation !== "setup";
|
|
25
25
|
if (queued) {
|
|
26
26
|
await fs.mkdir(queue, { recursive: true, mode: 0o700 });
|
|
27
27
|
const name = `${String(Date.now()).padStart(13, "0")}-${process.hrtime.bigint().toString().padStart(20, "0")}-${randomUUID()}.json`;
|
|
@@ -37,7 +37,7 @@ export async function withCadLock(data, options, work) {
|
|
|
37
37
|
for (;;) {
|
|
38
38
|
options.signal?.throwIfAborted();
|
|
39
39
|
if (queued && performance.now() >= options.deadline)
|
|
40
|
-
throw new CadRefusal("cad-queue-timeout",
|
|
40
|
+
throw new CadRefusal("cad-queue-timeout", `The CAD ${options.operation === "fit" ? "fit check" : "run"}'s timeout expired while waiting for another operation. It was not dispatched.`);
|
|
41
41
|
const names = (await fs.readdir(queue).catch((e) => {
|
|
42
42
|
if (e.code === "ENOENT")
|
|
43
43
|
return [];
|
|
@@ -99,9 +99,7 @@ export async function withCadLock(data, options, work) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
if (!queued)
|
|
102
|
-
throw new CadRefusal(
|
|
103
|
-
? "cad-setup-busy"
|
|
104
|
-
: "cad-operation-busy", "Another CAD operation is already running or queued. Wait for it to finish; this request was not dispatched.");
|
|
102
|
+
throw new CadRefusal("cad-setup-busy", "Another CAD operation is already running or queued. Wait for it to finish; this request was not dispatched.");
|
|
105
103
|
await delay(Math.min(50, Math.max(1, options.deadline - performance.now())), undefined, { signal: options.signal });
|
|
106
104
|
}
|
|
107
105
|
}
|
package/dist/cad-engine.js
CHANGED
|
@@ -587,8 +587,13 @@ export class CadEngine {
|
|
|
587
587
|
throw new Error(`CAD ${ext} export is missing, unsafe or too large.`);
|
|
588
588
|
}
|
|
589
589
|
const checked = JSON.parse((await this.confined("inspect", request, job, protectedFiles, remaining(), signal, readableInputs)).stdout);
|
|
590
|
+
const printed = built.stdout.trim();
|
|
590
591
|
const result = {
|
|
591
592
|
...checked,
|
|
593
|
+
// Beside the image paths, where the next step is decided.
|
|
594
|
+
next: "Read renders.perspective before the next cad_run or any other change: say what it shows is wrong against what you are making (the bought product you named, or the object in the photos), then fix that.",
|
|
595
|
+
// The script's own print() output: its words, not a measurement by this engine.
|
|
596
|
+
...(printed ? { printed: printed.length > 4000 ? printed.slice(0, 4000) + "\n[cut at 4000 characters; build.log has the rest]" : printed } : {}),
|
|
592
597
|
status: "completed",
|
|
593
598
|
final: args.final === true,
|
|
594
599
|
completed_at: new Date().toISOString(),
|
|
@@ -649,7 +654,7 @@ export class CadEngine {
|
|
|
649
654
|
// One deadline for the whole call: the automatic re-check and the fit share timeout_ms.
|
|
650
655
|
const deadline = performance.now() + milliseconds(args.timeout_ms);
|
|
651
656
|
const before = await this.ensureReady(signal, deadline);
|
|
652
|
-
return this.exclusive(async () => {
|
|
657
|
+
return this.exclusive(async (queueWaitMs) => {
|
|
653
658
|
const status = await this.status();
|
|
654
659
|
if (!status.ready)
|
|
655
660
|
throw new CadRefusal("cad-not-ready", before.error ?? status.error);
|
|
@@ -664,21 +669,21 @@ export class CadEngine {
|
|
|
664
669
|
transform: args.transform ?? {},
|
|
665
670
|
clearance_mm: clearance,
|
|
666
671
|
}));
|
|
667
|
-
return JSON.parse((await this.confined("fit", request, job, [
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
672
|
+
return { queue_wait_ms: queueWaitMs, ...JSON.parse((await this.confined("fit", request, job, [
|
|
673
|
+
request,
|
|
674
|
+
path.join(job, "model.stl"),
|
|
675
|
+
path.join(job, "reference.stl"),
|
|
676
|
+
], (() => {
|
|
677
|
+
const left = Math.floor(deadline - performance.now());
|
|
678
|
+
if (left <= 0)
|
|
679
|
+
throw new Error("CAD fit timed out.");
|
|
680
|
+
return left;
|
|
681
|
+
})(), signal)).stdout) };
|
|
677
682
|
}
|
|
678
683
|
finally {
|
|
679
684
|
await fs.rm(job, { recursive: true, force: true });
|
|
680
685
|
}
|
|
681
|
-
}, "fit", signal);
|
|
686
|
+
}, "fit", signal, deadline);
|
|
682
687
|
}
|
|
683
688
|
}
|
|
684
689
|
function only(args, keys) {
|
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ import { resolveStudioPrintOptions, usedNozzleCount } from "./studio-print-optio
|
|
|
45
45
|
import { inspectPrintFile } from "./safety/print-file.js";
|
|
46
46
|
import { previewPrintFile } from "./safety/print-preview.js";
|
|
47
47
|
import { loadSafe3mfArchive } from "./safety/archive.js";
|
|
48
|
-
import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
48
|
+
import { SERIAL_MODELS, internalPrintingSupported, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
49
49
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
50
50
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
|
|
51
51
|
import { detectProfilesRoot } from "./slicer/profile-flatten.js";
|
|
@@ -146,19 +146,26 @@ function withEmergencyMqttTimeout(send) {
|
|
|
146
146
|
return Promise.race([Promise.resolve().then(() => send(controller.signal)), timeout]).finally(() => clearTimeout(timer));
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Whether
|
|
149
|
+
* Whether a native print stores its job on the SD card or USB stick
|
|
150
150
|
* (true) or internal storage (eMMC). An explicit try_emmc_print wins, then
|
|
151
151
|
* BAMBU_NATIVE_TRY_EMMC_PRINT read as the helper reads it; otherwise a ready
|
|
152
152
|
* card is used, as OrcaSlicer does, so the job can be reprinted from the
|
|
153
|
-
* printer and read over FTPS.
|
|
153
|
+
* printer and read over FTPS. X1C internal printing additionally requires
|
|
154
|
+
* the capability bit from fresh status, including at final dispatch.
|
|
154
155
|
*/
|
|
155
|
-
function nativeExternalStorage(tryEmmcPrint, raw) {
|
|
156
|
-
if (tryEmmcPrint !== undefined)
|
|
157
|
-
return !tryEmmcPrint;
|
|
156
|
+
function nativeExternalStorage(tryEmmcPrint, raw, model) {
|
|
158
157
|
const configured = process.env.BAMBU_NATIVE_TRY_EMMC_PRINT?.trim();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
const external = tryEmmcPrint !== undefined ? !tryEmmcPrint
|
|
159
|
+
: configured ? !["1", "true", "TRUE", "yes"].includes(configured)
|
|
160
|
+
: externalStorageState(raw) === "normal";
|
|
161
|
+
if (!external)
|
|
162
|
+
assertNativeInternalStorage(model, raw);
|
|
163
|
+
return external;
|
|
164
|
+
}
|
|
165
|
+
function assertNativeInternalStorage(model, raw) {
|
|
166
|
+
if (model === "x1c" && !internalPrintingSupported(raw)) {
|
|
167
|
+
throw new Error("X1C internal printing is not advertised in the fresh status. Use a ready SD card or USB stick; unsupported internal storage requests are refused.");
|
|
168
|
+
}
|
|
162
169
|
}
|
|
163
170
|
function requestedPrintNozzles(args) {
|
|
164
171
|
if (args.nozzle_diameters !== undefined && args.nozzle_diameter !== undefined) {
|
|
@@ -209,6 +216,11 @@ function callerPrintOptions(args) {
|
|
|
209
216
|
// the dual-nozzle H2 path. Keep it in this gate so pre-sliced multi-filament
|
|
210
217
|
// jobs take the correct branch instead of the legacy 5-slot mapping.
|
|
211
218
|
const H2_BAMBU_MODELS = new Set(["h2d", "h2dpro", "h2s", "h2c", "x2d"]);
|
|
219
|
+
// Models that may print and upload over connection_mode=bambu_native. X2D
|
|
220
|
+
// defaults to it. X1C opts in: firmware 01.12.00.00 was seen refusing every
|
|
221
|
+
// direct FTPS STOR with 553 while Bambu Studio's plug-in still printed.
|
|
222
|
+
const NATIVE_ROUTE_MODELS = new Set(["x2d", "x1c"]);
|
|
223
|
+
const NATIVE_ROUTE_RESTRICTION = "connection_mode=bambu_native is restricted to X2D and X1C.";
|
|
212
224
|
const VALID_BED_TYPES = ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"];
|
|
213
225
|
const VALID_NOZZLE_TYPES = ["stainless_steel", "hardened_steel", "tungsten_carbide", "brass"];
|
|
214
226
|
/** The installed hotend material. Bambu machine presets assume the stock nozzle; the print gate compares this with the printer. */
|
|
@@ -1430,7 +1442,7 @@ class BambuPrinterMCPServer {
|
|
|
1430
1442
|
const { threeMFPath, autoSliced } = await this.ensurePrintableThreeMFPath(args, printModel, printPreset, printBedType);
|
|
1431
1443
|
const { useAMS, finalAmsMapping, finalAmsSlots } = await this.resolveAmsPrintSettings(threeMFPath, args, host, bambuSerial, bambuToken, printModel, printNozzle);
|
|
1432
1444
|
if (native && args.use_ams !== false && !useAMS) {
|
|
1433
|
-
throw new Error("Native
|
|
1445
|
+
throw new Error("Native printing requires ams_mapping, ams_slots, auto_match_ams, or explicit use_ams: false for an external spool.");
|
|
1434
1446
|
}
|
|
1435
1447
|
const threeMfFilename = path.basename(threeMFPath);
|
|
1436
1448
|
const projectName = String(args?.project_name || args?.task_name || threeMfFilename.replace(/\.3mf$/i, ''));
|
|
@@ -1531,7 +1543,7 @@ class BambuPrinterMCPServer {
|
|
|
1531
1543
|
};
|
|
1532
1544
|
assertActive();
|
|
1533
1545
|
if (native) {
|
|
1534
|
-
const externalStorage = nativeExternalStorage(args?.try_emmc_print, confirmedStatus.raw);
|
|
1546
|
+
const externalStorage = nativeExternalStorage(args?.try_emmc_print, confirmedStatus.raw, printModel);
|
|
1535
1547
|
if (externalStorage && externalStorageState(confirmedStatus.raw) !== "normal") {
|
|
1536
1548
|
throw new Error("External storage was requested, but the printer reports no ready SD card or USB stick.");
|
|
1537
1549
|
}
|
|
@@ -1561,6 +1573,8 @@ class BambuPrinterMCPServer {
|
|
|
1561
1573
|
if (externalStorage && externalStorageState(dispatchStatus.raw) !== "normal") {
|
|
1562
1574
|
throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
|
|
1563
1575
|
}
|
|
1576
|
+
if (!externalStorage)
|
|
1577
|
+
assertNativeInternalStorage(printModel, dispatchStatus.raw);
|
|
1564
1578
|
assertActive();
|
|
1565
1579
|
this.bambu.recordFlightDispatch(devIp, devId, remoteFileName, requirements, resumeFile);
|
|
1566
1580
|
markPrintCommandSent();
|
|
@@ -1664,18 +1678,18 @@ class BambuPrinterMCPServer {
|
|
|
1664
1678
|
async print3mfViaBambuNative(args, host, bambuSerial, bambuToken, onUpdate, signal) {
|
|
1665
1679
|
assertBambuNativeAvailable();
|
|
1666
1680
|
const model = await this.resolveBambuModel(args.bambu_model);
|
|
1667
|
-
if (model
|
|
1668
|
-
throw new Error(
|
|
1681
|
+
if (!NATIVE_ROUTE_MODELS.has(model))
|
|
1682
|
+
throw new Error(NATIVE_ROUTE_RESTRICTION);
|
|
1669
1683
|
return this.print3mfViaBambuNetwork({ ...args, bambu_model: model, connection_type: "lan", bambu_network_method: "start_local_print" }, host, bambuSerial, bambuToken, { onUpdate, signal });
|
|
1670
1684
|
}
|
|
1671
1685
|
async uploadFileViaBambuNative(args, host, bambuSerial, bambuToken, onUpdate, signal) {
|
|
1672
1686
|
if (args.print)
|
|
1673
1687
|
throw new Error("Native upload never starts printing; use print_3mf.");
|
|
1674
1688
|
// Resolve and enforce the model first, as the print path does, so a
|
|
1675
|
-
//
|
|
1689
|
+
// request for another model is never told to install the native helper.
|
|
1676
1690
|
const model = await this.resolveBambuModel(args.bambu_model);
|
|
1677
|
-
if (model
|
|
1678
|
-
throw new Error(
|
|
1691
|
+
if (!NATIVE_ROUTE_MODELS.has(model))
|
|
1692
|
+
throw new Error(NATIVE_ROUTE_RESTRICTION);
|
|
1679
1693
|
assertBambuNativeAvailable();
|
|
1680
1694
|
const unsupported = ["use_ams", "ams_mapping", "ams_mapping2", "ams_mapping_info", "nozzle_mapping", "nozzles_info",
|
|
1681
1695
|
"bed_leveling", "flow_calibration", "vibration_calibration", "layer_inspect", "timelapse"];
|
|
@@ -2454,7 +2468,7 @@ class BambuPrinterMCPServer {
|
|
|
2454
2468
|
nozzle_mapping: { type: "string", description: "Raw JSON string for FULU PrintParams nozzle_mapping." },
|
|
2455
2469
|
nozzles_info: { type: "string", description: "Raw JSON string for FULU PrintParams nozzles_info." },
|
|
2456
2470
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
2457
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
2471
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
2458
2472
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2459
2473
|
layer_inspect: { type: "boolean", description: "First-layer inspection where supported (default true, as Bambu Studio sends)." },
|
|
2460
2474
|
timelapse: { type: "boolean", description: "Enable timelapse recording in FULU PrintParams (default: false)." },
|
|
@@ -2536,7 +2550,7 @@ class BambuPrinterMCPServer {
|
|
|
2536
2550
|
connection_mode: {
|
|
2537
2551
|
type: "string",
|
|
2538
2552
|
enum: ["lan_mqtt_ftps", "bambu_native"],
|
|
2539
|
-
description: "Upload transport; bambu_native uses the installed Bambu networking plug-in for X2D and never starts printing."
|
|
2553
|
+
description: "Upload transport; bambu_native uses the installed Bambu networking plug-in for X2D or X1C and never starts printing."
|
|
2540
2554
|
},
|
|
2541
2555
|
bambu_model: {
|
|
2542
2556
|
type: "string",
|
|
@@ -2845,9 +2859,9 @@ class BambuPrinterMCPServer {
|
|
|
2845
2859
|
connection_mode: {
|
|
2846
2860
|
type: "string",
|
|
2847
2861
|
enum: ["lan_mqtt_ftps", "bambu_network", "bambu_native", "bambu_connect"],
|
|
2848
|
-
description: "Print path: bambu_connect hands a printable file to the signed-in Bambu Connect app for cloud-mode review; X2D otherwise defaults to bambu_native (Bambu Studio's installed local networking plug-in, storing the job on a ready SD card or USB stick, otherwise internal eMMC); lan_mqtt_ftps is the legacy direct MQTT/FTPS path; bambu_network uses the FULU bridge."
|
|
2862
|
+
description: "Print path: bambu_connect hands a printable file to the signed-in Bambu Connect app for cloud-mode review; X2D otherwise defaults to bambu_native (Bambu Studio's installed local networking plug-in, storing the job on a ready SD card or USB stick, otherwise internal eMMC); X1C may opt in to bambu_native, for example when its firmware refuses FTPS uploads with 553; lan_mqtt_ftps is the legacy direct MQTT/FTPS path; bambu_network uses the FULU bridge."
|
|
2849
2863
|
},
|
|
2850
|
-
try_emmc_print: { type: "boolean", description: "X2D native printing: true stores the job on internal storage (eMMC), false on the SD card or USB stick (refused unless the printer reports one ready). Omit to use the card when ready, else eMMC; BAMBU_NATIVE_TRY_EMMC_PRINT sets a server default." },
|
|
2864
|
+
try_emmc_print: { type: "boolean", description: "X2D native printing: true stores the job on internal storage (eMMC), false on the SD card or USB stick (refused unless the printer reports one ready). Omit to use the card when ready, else eMMC; X1C requires fresh advertised internal-printing support before using eMMC. BAMBU_NATIVE_TRY_EMMC_PRINT sets a server default." },
|
|
2851
2865
|
connection_type: { type: "string", enum: ["cloud", "lan"], description: "BambuNetwork connection type when connection_mode is bambu_network; cloud uses restored internet printing, lan uses local bridge printing." },
|
|
2852
2866
|
bambu_network_method: { type: "string", enum: BAMBU_NETWORK_PRINT_METHODS, description: "FULU print method when connection_mode is bambu_network; defaults to start_local_print for lan, and for cloud to Bambu Studio's order: start_local_print_with_record, then start_print if that fails." },
|
|
2853
2867
|
dev_id: { type: "string", description: "Bambu device id for FULU BambuNetwork printing; defaults to BAMBU_DEV_ID or BAMBU_SERIAL." },
|
|
@@ -2897,7 +2911,7 @@ class BambuPrinterMCPServer {
|
|
|
2897
2911
|
description: "When true, match the sliced 3MF's tray_info_idx requirements against live AMS inventory and use the resulting ams_slots. Ignored when ams_mapping or ams_slots is provided."
|
|
2898
2912
|
},
|
|
2899
2913
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
2900
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
2914
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
2901
2915
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2902
2916
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
2903
2917
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
@@ -2933,7 +2947,7 @@ class BambuPrinterMCPServer {
|
|
|
2933
2947
|
description: "Bed plate type currently installed (default: textured_plate)"
|
|
2934
2948
|
},
|
|
2935
2949
|
bed_leveling: { type: "boolean", description: "Auto bed leveling on or off. Omit to send what Bambu Studio's Send dialog would: the choice saved in BambuStudio.conf for this printer, else Studio's default." },
|
|
2936
|
-
flow_calibration: { type: "boolean", description: "Flow calibration
|
|
2950
|
+
flow_calibration: { type: "boolean", description: "Flow calibration task boolean. Omission resolves Studio settings (auto on P1/P1S); direct MQTT sends false for auto but does not transmit the integer auto mode. The result calibration report distinguishes resolved and transmitted options." },
|
|
2937
2951
|
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2938
2952
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
2939
2953
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
@@ -3299,7 +3313,9 @@ class BambuPrinterMCPServer {
|
|
|
3299
3313
|
? linuxEmergency(() => nativeCommand(), signal => this.bambu.sendStopOverMqtt(host, bambuSerial, bambuToken, signal))
|
|
3300
3314
|
: nativeCommand;
|
|
3301
3315
|
}
|
|
3302
|
-
|
|
3316
|
+
// Native controls are X2D-only. Another model printed natively (X1C)
|
|
3317
|
+
// is stopped, paused and resumed over direct MQTT, as its default route is.
|
|
3318
|
+
if (route.mode === "bambu_native" && x2dTarget)
|
|
3303
3319
|
throw new Error(nativeUnavailableReason());
|
|
3304
3320
|
if (route.mode !== "bambu_network")
|
|
3305
3321
|
return undefined;
|
package/dist/printers/bambu.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { FlightRecords, type PrintGeometry } from "../counterpart/flight-record.
|
|
|
2
2
|
import { CameraStreams, type FrameOptions } from "./camera-stream.js";
|
|
3
3
|
import { inspectPrintFile, type PrintFileInspection } from "../safety/print-file.js";
|
|
4
4
|
import { type PrinterStateRequirements } from "../safety/printer-state.js";
|
|
5
|
+
/**
|
|
6
|
+
* X1C firmware 01.12.00.00 was seen refusing every FTPS STOR with
|
|
7
|
+
* "553 Could not create file." (card ready and writable, Developer Mode on)
|
|
8
|
+
* while Bambu Studio's networking plug-in still printed. Name that route.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ftpsRefusalHint(error: unknown, model: string | undefined): string;
|
|
5
11
|
export declare function assertDirectPrintSupported(model: string | undefined, serial?: string): void;
|
|
6
12
|
interface BambuPrintOptionsInternal {
|
|
7
13
|
/** Bytes sent to the printer so far over FTPS, and the file's size (LAN route). */
|