bambu-printer-mcp 1.1.89 → 1.1.91

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.
Files changed (70) hide show
  1. package/README.md +49 -1
  2. package/dist/cad/contracts.d.ts +84 -0
  3. package/dist/cad/contracts.js +50 -5
  4. package/dist/cad/examples.d.ts +22 -0
  5. package/dist/cad/examples.js +81 -0
  6. package/dist/cad/process.js +3 -0
  7. package/dist/cad-engine.d.ts +25 -0
  8. package/dist/cad-engine.js +197 -27
  9. package/dist/counterpart/flight-record.d.ts +155 -0
  10. package/dist/counterpart/flight-record.js +831 -0
  11. package/dist/counterpart/flight-tools.d.ts +213 -0
  12. package/dist/counterpart/flight-tools.js +232 -0
  13. package/dist/counterpart/fresh-frame.d.ts +16 -0
  14. package/dist/counterpart/fresh-frame.js +26 -0
  15. package/dist/counterpart/make-3mf.js +1 -4
  16. package/dist/counterpart/physical-evidence.d.ts +70 -0
  17. package/dist/counterpart/physical-evidence.js +103 -0
  18. package/dist/counterpart/print-geometry.d.ts +13 -0
  19. package/dist/counterpart/print-geometry.js +181 -0
  20. package/dist/counterpart/remote.js +4 -0
  21. package/dist/counterpart/schemas.d.ts +32 -0
  22. package/dist/counterpart/schemas.js +2 -0
  23. package/dist/counterpart/visual-evidence.d.ts +38 -0
  24. package/dist/counterpart/visual-evidence.js +155 -0
  25. package/dist/design-guidance.d.ts +22 -1
  26. package/dist/design-guidance.js +35 -2
  27. package/dist/index.js +35 -3
  28. package/dist/printers/bambu.d.ts +9 -2
  29. package/dist/printers/bambu.js +32 -6
  30. package/dist/safety/print-preview.d.ts +2 -0
  31. package/dist/safety/print-preview.js +1 -1
  32. package/dist/slicer/3mf-xml.d.ts +7 -0
  33. package/dist/slicer/3mf-xml.js +61 -0
  34. package/dist/stl/stl-manipulator.js +5 -2
  35. package/dist/tool-annotations.js +4 -0
  36. package/package.json +2 -1
  37. package/src/cad/contracts.ts +54 -5
  38. package/src/cad/examples/bag_clip.py +86 -0
  39. package/src/cad/examples/bistable_clicker.py +81 -0
  40. package/src/cad/examples/cable_clip.py +55 -0
  41. package/src/cad/examples/chainmail.py +45 -0
  42. package/src/cad/examples/hinged_box.py +101 -0
  43. package/src/cad/examples/knurled_knob.py +50 -0
  44. package/src/cad/examples/loft_handle.py +52 -0
  45. package/src/cad/examples/phone_stand.py +92 -0
  46. package/src/cad/examples/swept_hook.py +69 -0
  47. package/src/cad/examples/threaded_jar.py +62 -0
  48. package/src/cad/examples/trigger_capo.py +95 -0
  49. package/src/cad/examples/wall_hook.py +65 -0
  50. package/src/cad/examples.ts +77 -0
  51. package/src/cad/geometry.py +122 -4
  52. package/src/cad/process.ts +3 -0
  53. package/src/cad/worker.py +4 -0
  54. package/src/cad-engine.ts +221 -52
  55. package/src/counterpart/flight-record.ts +984 -0
  56. package/src/counterpart/flight-tools.ts +282 -0
  57. package/src/counterpart/fresh-frame.ts +45 -0
  58. package/src/counterpart/make-3mf.ts +1 -5
  59. package/src/counterpart/physical-evidence.ts +185 -0
  60. package/src/counterpart/print-geometry.ts +192 -0
  61. package/src/counterpart/remote.ts +4 -0
  62. package/src/counterpart/schemas.ts +3 -0
  63. package/src/counterpart/visual-evidence.ts +212 -0
  64. package/src/design-guidance.ts +35 -2
  65. package/src/index.ts +38 -4
  66. package/src/printers/bambu.ts +34 -5
  67. package/src/safety/print-preview.ts +1 -1
  68. package/src/slicer/3mf-xml.ts +52 -0
  69. package/src/stl/stl-manipulator.ts +4 -1
  70. package/src/tool-annotations.ts +4 -0
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { physicalProblems } from "./counterpart/visual-evidence.js";
3
+ import { flightKey } from "./counterpart/flight-record.js";
4
+ import { FLIGHT_RECORD_PROPERTIES, FLIGHT_RECORD_DESCRIPTION, FLIGHT_RECORD_OUTPUT_SCHEMA, flightReadOptions, flightRecordResult, FLIGHT_ASSESS_PROPERTIES, FLIGHT_ASSESS_REQUIRED, FLIGHT_ASSESS_DESCRIPTION, PRINT_EVIDENCE_GUIDANCE, visualSubmission } from "./counterpart/flight-tools.js";
2
5
  import { CAMERA_STREAM_TOOLS } from "./printers/camera-tools.js";
3
6
  import { withAnnotations } from "./tool-annotations.js";
4
7
  import { withRemote } from "./counterpart/remote.js";
@@ -30,6 +33,8 @@ import { importFileViaBambuConnect } from "./bambu-connect.js";
30
33
  import { CadEngine } from "./cad-engine.js";
31
34
  import { CadRefusal } from "./cad/refusal.js";
32
35
  import { CAD_TOOLS, cadEnabled } from "./cad/contracts.js";
36
+ import { cadExamplesTool } from "./cad/examples.js";
37
+ import { DESIGN_GUIDANCE_TOOL, designGuidance } from "./design-guidance.js";
33
38
  import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
34
39
  import { FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_MCP_PIN, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge, addinAddress } from "./fusion-mcp-bridge.js";
35
40
  import { BLENDER_SETUP_OUTPUT_SCHEMA, BlenderAddonSetup, FUSION_ADDIN_REPOSITORY, FUSION_SETUP_OUTPUT_SCHEMA, FusionAddinSetup, defaultSetupSystem, parseAddonHandshake } from "./design-app-setup.js";
@@ -119,7 +124,7 @@ const SERVER_INFO = {
119
124
  };
120
125
  /** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
121
126
  const OUTPUT_SCHEMA_TOOLS = new Set([
122
- "cad_status", "cad_setup", "cad_run", "cad_check_fit",
127
+ "cad_status", "cad_setup", "cad_run", "cad_check_fit", "cad_examples",
123
128
  "counterpart_printer_info", "counterpart_print_progress", "counterpart_make_3mf",
124
129
  "counterpart_discover_printers", "counterpart_setup_fields", "counterpart_propose_filaments",
125
130
  "fusion_mcp_status", "fusion_mcp_new_design", "fusion_mcp_export",
@@ -1129,7 +1134,7 @@ class BambuPrinterMCPServer {
1129
1134
  resources: {},
1130
1135
  tools: {}
1131
1136
  },
1132
- instructions: SERVER_INSTRUCTIONS + (CAD_ENABLED ? " For headless dimensioned designs and parameter edits, read the cad_design prompt before using cad_run." : "")
1137
+ instructions: SERVER_INSTRUCTIONS + PRINT_EVIDENCE_GUIDANCE + (CAD_ENABLED ? " For headless dimensioned designs and parameter edits, read the cad_design prompt before using cad_run." : "")
1133
1138
  });
1134
1139
  this.bambu = new BambuImplementation(async (message) => {
1135
1140
  try {
@@ -1557,6 +1562,7 @@ class BambuPrinterMCPServer {
1557
1562
  throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
1558
1563
  }
1559
1564
  assertActive();
1565
+ this.bambu.recordFlightDispatch(devIp, devId, remoteFileName, requirements, resumeFile);
1560
1566
  markPrintCommandSent();
1561
1567
  } });
1562
1568
  assertActive();
@@ -1575,6 +1581,7 @@ class BambuPrinterMCPServer {
1575
1581
  },
1576
1582
  assertDispatchAllowed: method => { if (method === bridgeMethod || method === cloudFallbackMethod) {
1577
1583
  assertActive();
1584
+ this.bambu.recordFlightDispatch(devIp, devId, remoteFileName, requirements, resumeFile);
1578
1585
  markPrintCommandSent();
1579
1586
  } },
1580
1587
  onDispatched: method => { if (method === bridgeMethod || method === cloudFallbackMethod)
@@ -2969,6 +2976,7 @@ class BambuPrinterMCPServer {
2969
2976
  required: ["stl_path"]
2970
2977
  }
2971
2978
  },
2979
+ DESIGN_GUIDANCE_TOOL,
2972
2980
  ...(CAD_ENABLED ? CAD_TOOLS : []),
2973
2981
  {
2974
2982
  name: "blender_mcp_status",
@@ -3085,6 +3093,16 @@ class BambuPrinterMCPServer {
3085
3093
  additionalProperties: false
3086
3094
  }
3087
3095
  },
3096
+ {
3097
+ name: "counterpart_print_record", description: FLIGHT_RECORD_DESCRIPTION,
3098
+ inputSchema: { type: "object", properties: { ...FLIGHT_RECORD_PROPERTIES, host: { type: "string", description: "Saved printer hostname or address; used only to select a local record." }, bambu_serial: { type: "string", description: "Saved Bambu printer serial; used only to select a local record." } }, additionalProperties: false },
3099
+ outputSchema: FLIGHT_RECORD_OUTPUT_SCHEMA
3100
+ },
3101
+ {
3102
+ name: "counterpart_print_assess", description: FLIGHT_ASSESS_DESCRIPTION,
3103
+ inputSchema: { type: "object", properties: { ...FLIGHT_ASSESS_PROPERTIES, host: { type: "string", description: "Saved printer hostname or address; used only to select a local record." }, bambu_serial: { type: "string", description: "Saved Bambu printer serial; used only to select a local record." } }, required: FLIGHT_ASSESS_REQUIRED, additionalProperties: false },
3104
+ outputSchema: FLIGHT_RECORD_OUTPUT_SCHEMA
3105
+ },
3088
3106
  {
3089
3107
  name: "counterpart_print_progress",
3090
3108
  description: "Counterpart contract (counterpart/1): the printer's state, current job (name, task id, percent, time left, layers, stage words), temperatures, active filament and problems with Bambu's HMS messages and links. Read from the MQTT report this server keeps, so a held session asks the printer nothing; observedAt is when the printer sent it. An unreachable printer reports state offline. Read-only; not a safety check.",
@@ -4374,20 +4392,34 @@ class BambuPrinterMCPServer {
4374
4392
  choices: options.filter(option => option.available).map(option => option.id), options, savedTo };
4375
4393
  break;
4376
4394
  }
4395
+ case "counterpart_print_assess":
4396
+ return flightRecordResult(this.bambu.flightRecords.submitVisual(flightKey(host, bambuSerial), visualSubmission(args)));
4397
+ case "counterpart_print_record":
4398
+ return flightRecordResult(this.bambu.flightRecords.read(flightKey(host, bambuSerial), flightReadOptions(args)), args?.frame_format === "images");
4377
4399
  case "counterpart_print_progress": {
4378
4400
  const report = await this.bambu.readProgressReport(host, bambuSerial, bambuToken);
4401
+ if (report)
4402
+ void this.bambu.flightRecords.sample(flightKey(host, bambuSerial), after => this.bambu.cameraSnapshot(host, bambuSerial, bambuToken, { bambuModel: this.displayModel(args, bambuSerial), timeoutMs: 8000, capturedAfter: after })).catch(() => undefined);
4379
4403
  result = report
4380
4404
  ? bambuProgress(report.raw, { receivedAt: report.receivedAt, serial: bambuSerial, model: this.displayModel(args, bambuSerial) })
4381
4405
  : offlineProgress(Date.now());
4406
+ const physical = this.bambu.flightRecords.physicalForReport(flightKey(host, bambuSerial), report?.raw);
4407
+ result = { ...result, physical, problems: [...physicalProblems(physical, result.state === "finished"), ...result.problems] };
4382
4408
  break;
4383
4409
  }
4384
4410
  case "counterpart_make_3mf":
4385
4411
  result = await makeCounterpart3mf(args ?? {});
4386
4412
  break;
4413
+ case "design_guidance":
4414
+ result = designGuidance(args ?? {});
4415
+ break;
4416
+ case "cad_examples":
4417
+ result = cadExamplesTool(args ?? {});
4418
+ break;
4387
4419
  case "cad_status":
4388
4420
  if (args && Object.keys(args).length)
4389
4421
  throw new Error("cad_status takes no arguments.");
4390
- result = await this.cad.status();
4422
+ result = await this.cad.ensureReady(extra.signal);
4391
4423
  break;
4392
4424
  case "cad_setup":
4393
4425
  case "cad_run":
@@ -1,3 +1,4 @@
1
+ import { FlightRecords, type PrintGeometry } from "../counterpart/flight-record.js";
1
2
  import { CameraStreams, type FrameOptions } from "./camera-stream.js";
2
3
  import { inspectPrintFile, type PrintFileInspection } from "../safety/print-file.js";
3
4
  import { type PrinterStateRequirements } from "../safety/printer-state.js";
@@ -42,6 +43,7 @@ export type ProgressReport = {
42
43
  /** The inspected bytes and limits of a started job, for the resume prompt and byte check. */
43
44
  export type CheckedFile = {
44
45
  sha256: string;
46
+ expected?: PrintGeometry;
45
47
  /** A project's printed plate: its number and the SHA-256 of its Metadata/plate_<index>.gcode. */
46
48
  plate?: {
47
49
  index: number;
@@ -71,6 +73,7 @@ export type PrintPreflight = {
71
73
  export { cameraFrameParser } from "./camera-wire.js";
72
74
  export declare class BambuImplementation {
73
75
  private readonly confirm?;
76
+ readonly flightRecords: FlightRecords;
74
77
  private printerStore;
75
78
  readonly cameraStreams: CameraStreams;
76
79
  /**
@@ -108,6 +111,8 @@ export declare class BambuImplementation {
108
111
  * verified: a resume then re-reads it if it can and otherwise matches the
109
112
  * unique name, as KAN-216 does for firmware that cannot download a file.
110
113
  */
114
+ /** At the existing send-authorization boundary: record evidence even if the reply/helper is lost. */
115
+ recordFlightDispatch(host: string, serial: string, remotePath: string, requirements: PrinterStateRequirements, file: CheckedFile): void;
111
116
  recordCheckedJob(host: string, serial: string, remotePath: string, requirements: PrinterStateRequirements, file: CheckedFile, uploadedHere?: boolean): void;
112
117
  /** Feed one merged report to the resume record (internal; the client store calls it for every report). */
113
118
  observeReport(host: string, serial: string, raw: Record<string, any> | undefined): void;
@@ -206,7 +211,7 @@ export declare class BambuImplementation {
206
211
  status: string;
207
212
  uploaded: boolean;
208
213
  printRequested: boolean;
209
- dispatch: "started" | "unconfirmed";
214
+ dispatch: "unconfirmed" | "started";
210
215
  remotePath: string;
211
216
  jobName: string;
212
217
  message: string;
@@ -223,7 +228,7 @@ export declare class BambuImplementation {
223
228
  status: string;
224
229
  uploaded: boolean;
225
230
  printRequested: boolean;
226
- dispatch: "started" | "unconfirmed";
231
+ dispatch: "unconfirmed" | "started";
227
232
  remotePath: string;
228
233
  jobName: string;
229
234
  message: string;
@@ -276,6 +281,7 @@ export declare class BambuImplementation {
276
281
  };
277
282
  cameraSnapshot(host: string, _serial: string, token: string, options?: {
278
283
  savePath?: string;
284
+ capturedAfter?: string;
279
285
  timeoutMs?: number;
280
286
  bambuModel?: string;
281
287
  /**
@@ -297,6 +303,7 @@ export declare class BambuImplementation {
297
303
  sizeBytes: number;
298
304
  base64: string;
299
305
  savedTo?: string;
306
+ capturedAt?: string;
300
307
  width?: number;
301
308
  height?: number;
302
309
  note?: string;
@@ -1,3 +1,6 @@
1
+ import { snapshotFrame } from "../counterpart/fresh-frame.js";
2
+ import { FlightRecords, flightKey } from "../counterpart/flight-record.js";
3
+ import { geometryFromGcode, geometryFromFile } from "../counterpart/print-geometry.js";
1
4
  import { PrinterRefusal, markPrintCommandSent } from "../refusal.js";
2
5
  import { CameraStreams } from "./camera-stream.js";
3
6
  import { openTcpCameraSource, openRtspCameraSource } from "./camera-sources.js";
@@ -597,14 +600,22 @@ function reportsJob(raw, remotePath) {
597
600
  export async function checkedFile(inspection, filePath) {
598
601
  const used = inspection.usedFilamentPositions.map(position => inspection.materials[position]).filter(Boolean);
599
602
  let plate;
603
+ let expected;
600
604
  const plateNumber = /^Metadata\/plate_(\d+)\.gcode$/i.exec(inspection.plateInternalPath ?? "");
601
605
  if (plateNumber && /\.3mf$/i.test(filePath)) {
602
606
  const entry = (await readSafe3mfArchive(filePath)).zip.file(inspection.plateInternalPath);
603
- if (entry)
604
- plate = { index: Number(plateNumber[1]), sha256: createHash("sha256").update(await entry.async("nodebuffer")).digest("hex") };
607
+ if (entry) {
608
+ const bytes = await entry.async("nodebuffer");
609
+ plate = { index: Number(plateNumber[1]), sha256: createHash("sha256").update(bytes).digest("hex") };
610
+ if (bytes.length <= 64 * 1024 * 1024)
611
+ expected = geometryFromGcode(bytes.toString("utf8"));
612
+ }
613
+ }
614
+ else if (!/\.3mf$/i.test(filePath)) {
615
+ expected = await geometryFromFile(filePath);
605
616
  }
606
617
  return {
607
- sha256: inspection.sha256, ...(plate ? { plate } : {}), model: inspection.model,
618
+ sha256: inspection.sha256, ...(plate ? { plate } : {}), ...(expected ? { expected } : {}), model: inspection.model,
608
619
  maxNozzleTemperature: inspection.maxNozzleTemperature, maxBedTemperature: inspection.maxBedTemperature, maxChamberTemperature: inspection.maxChamberTemperature,
609
620
  materials: [...new Set(used.length ? used : inspection.materials)],
610
621
  };
@@ -632,6 +643,7 @@ export { cameraFrameParser } from "./camera-wire.js";
632
643
  export class BambuImplementation {
633
644
  constructor(confirm, options = {}) {
634
645
  this.confirm = confirm;
646
+ this.flightRecords = new FlightRecords();
635
647
  this.cameraStreams = new CameraStreams();
636
648
  /** In-flight counterpart_print_progress reads, one per printer. */
637
649
  this.progressReads = new Map();
@@ -708,16 +720,26 @@ export class BambuImplementation {
708
720
  * verified: a resume then re-reads it if it can and otherwise matches the
709
721
  * unique name, as KAN-216 does for firmware that cannot download a file.
710
722
  */
723
+ /** At the existing send-authorization boundary: record evidence even if the reply/helper is lost. */
724
+ recordFlightDispatch(host, serial, remotePath, requirements, file) {
725
+ this.flightRecords.begin(flightKey(host, serial), { sha256: file.sha256, jobName: remotePath, mapping: requirements.amsMapping, materials: file.materials, plate: file.plate, expected: file.expected });
726
+ }
711
727
  recordCheckedJob(host, serial, remotePath, requirements, file, uploadedHere = true) {
712
728
  if (!/^[a-f0-9]{64}$/.test(file?.sha256 ?? ""))
713
729
  throw new Error("A started job needs the SHA-256 of its inspected bytes.");
714
730
  this.checkedJobs.set(`${host}\n${serial}`, {
715
731
  ...structuredClone(file), remotePath, requirements: structuredClone(requirements), seenRunning: false, uploadedHere,
716
732
  });
733
+ if (!this.flightRecords.accept(flightKey(host, serial), remotePath)) {
734
+ this.recordFlightDispatch(host, serial, remotePath, requirements, file);
735
+ this.flightRecords.accept(flightKey(host, serial), remotePath);
736
+ }
717
737
  this.clearedErrors.delete(serial);
718
738
  }
719
739
  /** Feed one merged report to the resume record (internal; the client store calls it for every report). */
720
740
  observeReport(host, serial, raw) {
741
+ if (raw)
742
+ this.flightRecords.observe(flightKey(host, serial), raw);
721
743
  const key = `${host}\n${serial}`;
722
744
  const checked = this.checkedJobs.get(key);
723
745
  if (!checked || !raw || typeof raw.gcode_state !== "string")
@@ -1106,6 +1128,7 @@ export class BambuImplementation {
1106
1128
  assertActive();
1107
1129
  if (legacyContainer) {
1108
1130
  const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
1131
+ this.recordFlightDispatch(host, serial, remoteProjectPath, requirements, resumeFile);
1109
1132
  markPrintCommandSent();
1110
1133
  try {
1111
1134
  await invokeWithoutAck(printer, new GCodeFileCommand({ fileName: remoteProjectPath }));
@@ -1193,6 +1216,7 @@ export class BambuImplementation {
1193
1216
  };
1194
1217
  }
1195
1218
  const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
1219
+ this.recordFlightDispatch(host, serial, remoteProjectPath, requirements, resumeFile);
1196
1220
  markPrintCommandSent();
1197
1221
  try {
1198
1222
  await printer.publish(projectFileCmd);
@@ -1799,6 +1823,7 @@ export class BambuImplementation {
1799
1823
  const printer = await this.getPrinter(host, serial, token);
1800
1824
  assertActive();
1801
1825
  const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
1826
+ this.recordFlightDispatch(host, serial, remotePath, requirements, resumeFile);
1802
1827
  markPrintCommandSent();
1803
1828
  try {
1804
1829
  await invokeWithoutAck(printer, new GCodeFileCommand({ fileName: remotePath }));
@@ -1990,12 +2015,13 @@ export class BambuImplementation {
1990
2015
  const timeoutMs = options.timeoutMs ?? 8000;
1991
2016
  const stream = this.cameraStreams.get(JSON.stringify([host, _serial]));
1992
2017
  if (stream && !stream.stopped) {
1993
- const jpeg = await stream.latest(Math.min(timeoutMs, 10000));
1994
- if (!jpeg)
2018
+ const frame = await snapshotFrame(stream, timeoutMs, options.capturedAfter);
2019
+ if (frame.status !== "frame" || !frame.base64)
1995
2020
  throw new Error("The active camera stream has not produced a live frame");
2021
+ const jpeg = Buffer.from(frame.base64, "base64");
1996
2022
  if (options.savePath)
1997
2023
  await (await import("node:fs/promises")).writeFile(options.savePath, jpeg);
1998
- return { status: "success", format: "image/jpeg", sizeBytes: jpeg.length, base64: jpeg.toString("base64"), transport: stream.transport,
2024
+ return { status: "success", format: "image/jpeg", sizeBytes: jpeg.length, base64: jpeg.toString("base64"), transport: stream.transport, capturedAt: frame.capturedAt,
1999
2025
  ...(options.savePath ? { savedTo: options.savePath } : {}) };
2000
2026
  }
2001
2027
  const model = (options.bambuModel ?? "").toLowerCase();
@@ -31,6 +31,8 @@ export declare function extrusionSegments(gcode: string): {
31
31
  segments: Segment[];
32
32
  layers: number;
33
33
  };
34
+ /** An arc's centre from I/J (offsets from the start) or R (radius; negative takes the longer way round). */
35
+ export declare function arcCentre(x: number, y: number, tx: number, ty: number, clockwise: boolean, i?: number, j?: number, r?: number): [number, number] | undefined;
34
36
  /** The top and bed-side pictures of one plate's G-code. `colours` are the project's filament colours by slot. */
35
37
  export declare function renderPrintPreview(gcode: string, colours?: unknown[]): PrintPreview | undefined;
36
38
  /** The preview of one plate of a sliced .3mf or a .gcode file, or undefined when it has no extruding moves. */
@@ -198,7 +198,7 @@ function parameterWords(text) {
198
198
  return words;
199
199
  }
200
200
  /** An arc's centre from I/J (offsets from the start) or R (radius; negative takes the longer way round). */
201
- function arcCentre(x, y, tx, ty, clockwise, i, j, r) {
201
+ export function arcCentre(x, y, tx, ty, clockwise, i, j, r) {
202
202
  if (i !== undefined || j !== undefined)
203
203
  return [x + (i ?? 0), y + (j ?? 0)];
204
204
  if (r === undefined || r === 0 || (tx === x && ty === y))
@@ -0,0 +1,7 @@
1
+ /** Encode text for a quoted XML attribute, preserving whitespace through XML parsing. */
2
+ export declare function xmlAttribute(value: string): string;
3
+ /** Studio 02.08.02.61 bbs_3mf.cpp writes object opt_serialize values without XML escaping.
4
+ * Only repair its single-line key/value metadata form. Unexpected malformed XML fails closed. */
5
+ export declare function escapedModelSettings(xml: string): Promise<string>;
6
+ /** Normalize only a newly produced/restored slice, before caching or handing it to the client. */
7
+ export declare function normalize3mfMetadata(filePath: string): Promise<void>;
@@ -0,0 +1,61 @@
1
+ /** XML output boundary for 3MF metadata; no printer calls or geometry/G-code changes. */
2
+ import fs from "node:fs/promises";
3
+ import { randomUUID } from "node:crypto";
4
+ import { SaxesParser } from "saxes";
5
+ import { readSafe3mfArchive } from "../safety/archive.js";
6
+ /** Encode text for a quoted XML attribute, preserving whitespace through XML parsing. */
7
+ export function xmlAttribute(value) {
8
+ const entities = { "&": "&amp;", '"': "&quot;", "'": "&apos;", "<": "&lt;", ">": "&gt;", "\t": "&#9;", "\n": "&#10;", "\r": "&#13;" };
9
+ return value.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, "").replace(/[&"'<>\t\r\n]/g, char => entities[char]);
10
+ }
11
+ const parses = (xml) => {
12
+ try {
13
+ let root;
14
+ const parser = new SaxesParser();
15
+ parser.on("error", error => { throw error; });
16
+ parser.on("opentag", node => { root ?? (root = node.name); });
17
+ parser.write(xml).close();
18
+ return root === "config";
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ };
24
+ /** Studio 02.08.02.61 bbs_3mf.cpp writes object opt_serialize values without XML escaping.
25
+ * Only repair its single-line key/value metadata form. Unexpected malformed XML fails closed. */
26
+ export async function escapedModelSettings(xml) {
27
+ if (Buffer.byteLength(xml) > 16 * 1024 * 1024)
28
+ throw Error("3MF model settings exceed the 16 MiB XML limit.");
29
+ if (await parses(xml))
30
+ return xml;
31
+ const lines = xml.split(/(?<=\n)/);
32
+ for (let i = 0; i < lines.length; i++) {
33
+ const match = /^([ \t]*<metadata\s+key="[\w.:-]+"\s+value=")(.*)("\s*\/>[ \t]*\r?\n?)$/.exec(lines[i]);
34
+ if (!match || await parses('<config>' + lines[i] + '</config>'))
35
+ continue;
36
+ lines[i] = match[1] + xmlAttribute(match[2]) + match[3];
37
+ }
38
+ const repaired = lines.join('');
39
+ if (!await parses(repaired))
40
+ throw Error("Slicer produced malformed Metadata/model_settings.config; no safe attribute repair is available.");
41
+ return repaired;
42
+ }
43
+ /** Normalize only a newly produced/restored slice, before caching or handing it to the client. */
44
+ export async function normalize3mfMetadata(filePath) {
45
+ const { zip } = await readSafe3mfArchive(filePath);
46
+ const entry = zip.file('Metadata/model_settings.config');
47
+ if (!entry)
48
+ return;
49
+ const original = await entry.async('string'), repaired = await escapedModelSettings(original);
50
+ if (repaired === original)
51
+ return;
52
+ zip.file(entry.name, repaired);
53
+ const staged = filePath + '.' + randomUUID() + '.xml-tmp';
54
+ try {
55
+ await fs.writeFile(staged, await zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' }), { flag: 'wx', mode: 0o600 });
56
+ await fs.rename(staged, filePath);
57
+ }
58
+ finally {
59
+ await fs.rm(staged, { force: true }).catch(() => { });
60
+ }
61
+ }
@@ -1,3 +1,4 @@
1
+ import { normalize3mfMetadata } from "../slicer/3mf-xml.js";
1
2
  import { customGcodesWithPauses, layerTops, machinePauseGcode, pausedLayers, readPlateGcode, readProjectCustomGcodes } from "../slicer/layer-pauses.js";
2
3
  import * as THREE from 'three';
3
4
  import { STLLoader } from 'three/examples/jsm/loaders/STLLoader.js';
@@ -1732,11 +1733,13 @@ export class STLManipulator extends EventEmitter {
1732
1733
  if (typeof slicerResult?.return_code === "number" && slicerResult.return_code !== 0) {
1733
1734
  throw new SlicerRunError(`Slicer failed: the slicer exited with code 0, but its result.json reports return_code ${slicerResult.return_code}.`, slicerResult);
1734
1735
  }
1735
- if (cacheKey && !restored && fs.existsSync(outputFilePath))
1736
- await keepSlice(cacheKey, cacheRun);
1737
1736
  if (!fs.existsSync(outputFilePath)) {
1738
1737
  throw new SlicerRunError(`Slicer finished but output file not found: ${outputFilePath}`, slicerResult);
1739
1738
  }
1739
+ if (/\.3mf$/i.test(outputFilePath))
1740
+ await normalize3mfMetadata(outputFilePath);
1741
+ if (cacheKey && !restored)
1742
+ await keepSlice(cacheKey, cacheRun);
1740
1743
  if (progressCallback)
1741
1744
  progressCallback(100, "Slicing completed successfully");
1742
1745
  this.emit('operationComplete', {
@@ -16,12 +16,16 @@ export const TOOL_ANNOTATIONS = {
16
16
  cad_setup: hints(false, true, true, true),
17
17
  cad_run: hints(false, false, false, false),
18
18
  cad_check_fit: READ_LOCAL,
19
+ cad_examples: READ_LOCAL,
20
+ design_guidance: READ_LOCAL,
19
21
  // Printer and cloud reads
20
22
  get_printer_status: READ_OUTSIDE,
21
23
  get_printer_filaments: READ_OUTSIDE,
22
24
  resolve_3mf_ams_slots: READ_OUTSIDE, // reads the live AMS inventory
23
25
  list_printer_files: READ_OUTSIDE,
24
26
  counterpart_print_progress: READ_OUTSIDE,
27
+ counterpart_print_record: READ_LOCAL,
28
+ counterpart_print_assess: hints(false, false, true, false),
25
29
  counterpart_discover_printers: READ_OUTSIDE, // listens for the printers' own SSDP announcements
26
30
  counterpart_propose_filaments: READ_OUTSIDE, // reads the live AMS inventory
27
31
  // connect: true starts the bridge agent, which writes its configuration and device identity and can replace certificates.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bambu-printer-mcp",
3
- "version": "1.1.89",
3
+ "version": "1.1.91",
4
4
  "description": "MCP server for Bambu Lab 3D printers with STL manipulation, slicing, and print management",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -55,6 +55,7 @@
55
55
  "jszip": "^3.10.2",
56
56
  "mqtt": "^5.16.1",
57
57
  "patch-package": "8.0.1",
58
+ "saxes": "^6.0.0",
58
59
  "sharp": "0.35.5",
59
60
  "three": "^0.173.0",
60
61
  "xml2js": "^0.6.2"
@@ -1,4 +1,5 @@
1
1
  import { CAD_REFUSAL_CODES } from "./refusal.js";
2
+ import { cadExampleLines } from "./examples.js";
2
3
  /** cad/1 is an optional engine owned by the printer MCP. Readiness comes from cad_status, not the capability. */
3
4
  export function cadEnabled(env: NodeJS.ProcessEnv = process.env): boolean {
4
5
  return !["0", "false", "off"].includes(
@@ -11,6 +12,7 @@ export const CAD_CAPABILITY = {
11
12
  setup: "cad_setup",
12
13
  run: "cad_run",
13
14
  checkFit: "cad_check_fit",
15
+ examples: "cad_examples",
14
16
  prompt: "cad_design",
15
17
  } as const;
16
18
  const storage = {
@@ -37,6 +39,7 @@ const status = {
37
39
  build123d: { type: "string" },
38
40
  platform: { type: "string" },
39
41
  error: { type: "string" },
42
+ reverified: { type: "string" },
40
43
  };
41
44
  const failure = {
42
45
  type: "object",
@@ -66,7 +69,7 @@ export const CAD_TOOLS = [
66
69
  {
67
70
  name: "cad_status",
68
71
  description:
69
- "Read the optional code-CAD runtime's last verified readiness and pinned version, without starting Python or installing anything.",
72
+ "Read the optional code-CAD runtime's readiness and pinned version. Never installs or downloads anything. When only this MCP's own engine files changed since the runtime was last verified (an update) and the installed runtime still matches the pinned lock exactly, it re-runs setup's confined build, STL and STEP round trip (about 15 to 20 seconds) and reports ready; a changed runtime still needs cad_setup with install: true.",
70
73
  inputSchema: {
71
74
  type: "object" as const,
72
75
  properties: {},
@@ -110,7 +113,7 @@ export const CAD_TOOLS = [
110
113
  {
111
114
  name: "cad_run",
112
115
  description:
113
- "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 renders and a contact sheet, the closest approach between every pair of solids (bodies), problems, and what was checked and not checked; valid means only that the exported geometry is sound, never that the part fits, holds, moves or prints.",
116
+ "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, and what was checked and not checked; valid means only that the exported geometry is sound, never that the part fits, holds, moves or prints.",
114
117
  inputSchema: {
115
118
  type: "object" as const,
116
119
  properties: {
@@ -245,6 +248,48 @@ export const CAD_TOOLS = [
245
248
  ],
246
249
  ),
247
250
  },
251
+ {
252
+ name: "cad_examples",
253
+ description:
254
+ "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 each shows, the product it is modelled on). With name, returns that example's record and full script to adapt. Read-only; starts no process.",
255
+ inputSchema: {
256
+ type: "object" as const,
257
+ properties: {
258
+ name: {
259
+ type: "string",
260
+ description: "An example's name from the list; omit to list them.",
261
+ },
262
+ },
263
+ additionalProperties: false,
264
+ },
265
+ outputSchema: output(
266
+ {
267
+ examples: {
268
+ type: "array",
269
+ items: {
270
+ type: "object",
271
+ properties: {
272
+ name: { type: "string" },
273
+ title: { type: "string" },
274
+ pattern: { type: "string" },
275
+ modelled_on: { type: "string" },
276
+ },
277
+ required: ["name", "title", "pattern"],
278
+ },
279
+ },
280
+ usage: { type: "string" },
281
+ name: { type: "string" },
282
+ title: { type: "string" },
283
+ pattern: { type: "string" },
284
+ modelled_on: { type: "string" },
285
+ published_sizes: { type: "string" },
286
+ concept: { type: "string" },
287
+ what_makes_this_good: { type: "string" },
288
+ script: { type: "string" },
289
+ },
290
+ [],
291
+ ),
292
+ },
248
293
  {
249
294
  name: "cad_check_fit",
250
295
  description:
@@ -320,14 +365,18 @@ export const CAD_DESIGN_PROMPT = {
320
365
  description:
321
366
  "MCP-owned rules for headless build123d designs and one-call parameter revisions.",
322
367
  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.
323
- 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 six renders, with step: null and an explicit reason. It does not manufacture a fake parametric STEP or promise scan-cleanup capability.
368
+ Form first: build the product's shape, not a profile pushed up. Before any geometry, write the concept in a few lines: the bought product you are following, its mechanism, the load path, the print orientation and why. 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.
369
+ Worked examples: cad_examples lists this engine's cookbook (each modelled on a bought product, with its concept, published sizes and script) and returns one script by name. When the request works like one of these, read that example first and adapt its pattern, never its sizes:
370
+ ${cadExampleLines()}
371
+ 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.
372
+ 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.
324
373
  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.
325
374
  Captured mesh preparation: load_scan(name, source_units="m" or "mm", up_axis="x"|"-x"|"y"|"-y"|"z"|"-z", ground=True) is provided to build(). Name must be a declared input. Declare source units and the object's usage-up axis explicitly: the helper converts metres to millimetres, applies a rigid up-axis rotation and translates the lowest Z to zero; it never guesses scale or fits to calipers. Geometry/texture references must be declared inputs too; snapshots preserve distinct original filenames. Exports must be millimetres, Z up, in the orientation the object is used.
326
375
  Fit reference workflow: return load_scan("scan", source_units="m", up_axis="y") from build() in mode: "mesh" to export an unchanged, prepared reference STL for cad_check_fit. Declare every linked OBJ/MTL/texture asset. If you crop, simplify, fill, or otherwise alter this reference, report exactly what you excluded/changed and that the fit check proves only that reduced reference in the stated pose. A fit check against a scan is information; it must never resize or override an interface specified by measured dimensions. Keep those measured interfaces and report the discrepancy.
327
376
  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.
328
377
  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.
329
378
  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.
330
- 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) and contact sheet. Fix every entry in problems before selecting a result; an empty problems list proves nothing listed in not_checked. 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.
379
+ 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.
331
380
  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.
332
- 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, with fdm_fit and fdm_flexures when they apply; never invoke a printer as part of constructing CAD.`,
381
+ 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.`,
333
382
  };