bambu-printer-mcp 1.1.49 → 1.1.51
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/README.md +11 -2
- package/dist/bambu-native.d.ts +5 -0
- package/dist/bambu-native.js +14 -4
- package/dist/counterpart/progress.js +4 -2
- package/dist/fusion-mcp-bridge.js +6 -4
- package/dist/index.js +67 -34
- package/dist/printers/bambu.d.ts +5 -0
- package/dist/printers/bambu.js +72 -16
- package/dist/stl/stl-manipulator.d.ts +37 -1
- package/dist/stl/stl-manipulator.js +203 -79
- package/dist/studio-hms-text.d.ts +2 -0
- package/dist/studio-hms-text.js +63 -0
- package/dist/studio-print-options.d.ts +57 -0
- package/dist/studio-print-options.js +179 -0
- package/package.json +2 -2
- package/src/bambu-native.ts +19 -4
- package/src/counterpart/progress.ts +4 -2
- package/src/fusion-mcp-bridge.ts +6 -4
- package/src/index.ts +67 -33
- package/src/printers/bambu.ts +70 -15
- package/src/stl/stl-manipulator.ts +240 -88
- package/src/studio-hms-text.ts +54 -0
- package/src/studio-print-options.ts +201 -0
package/README.md
CHANGED
|
@@ -713,7 +713,7 @@ If `filename` does not include a directory prefix, the server prepends `cache/`
|
|
|
713
713
|
|
|
714
714
|
#### cancel_print
|
|
715
715
|
|
|
716
|
-
Cancel the currently running print job. Sends
|
|
716
|
+
Cancel the currently running print job. Sends Bambu Studio's stop, `{"print":{"command":"stop","param":"","sequence_id":"<n>"}}`, at MQTT QoS 1, and waits up to 10 seconds for the printer to acknowledge it. A stop that isn't acknowledged returns an error, and its MQTT client is closed so it can't be sent late. Not resumable — use `pause_print` if you may want to continue.
|
|
717
717
|
|
|
718
718
|
```json
|
|
719
719
|
{
|
|
@@ -909,6 +909,15 @@ Inspect a prepared sliced 3MF or textual G-code file offline before deciding wha
|
|
|
909
909
|
|
|
910
910
|
The generic result has `receipt_version: "1"`, `evidence: "file-only"`, `dispatch_authorized: false`, `artifact` (`sha256`, `byte_length`, `file_format`), the requested `selection`, and the original `inspection` including declared model, nozzles, materials/used filament positions, internal plate path and checked temperature peaks. Hash and byte length identify the exact inspected snapshot; a consumer must compare them with its own artifact and selected plate. The temporary snapshot is removed, and its path is not a dispatch capability. The receipt does not prove printer readiness, physical material/nozzle contents, fit, full motion simulation or permission to print. Actual print routes still independently inspect the dispatched snapshot and require fresh hardware state and human preflight.
|
|
911
911
|
|
|
912
|
+
#### Print options
|
|
913
|
+
|
|
914
|
+
Every print route sends the options Bambu Studio's Send dialog sends (Bambu Studio 02.08.02.61, `SelectMachine.cpp:3344-3356`): bed leveling, flow calibration and nozzle offset calibration, vibration calibration, first-layer inspection and `extruder_cali_manual_mode`. That covers the BambuNetwork bridge, the native helper and LAN `project_file`. Each option you don't pass resolves as Studio resolves it:
|
|
915
|
+
|
|
916
|
+
1. Studio's saved choice for that printer type in `BambuStudio.conf`, if the printer offers it. For example, a P1S offers only on/off for bed leveling, so a saved "auto" counts as unset.
|
|
917
|
+
2. Otherwise "auto" if the printer offers it, else "on". On a P1S, flow calibration and nozzle offset calibration are hidden, so they stay "auto".
|
|
918
|
+
|
|
919
|
+
Studio hard-codes vibration calibration off, first-layer inspection on and `extruder_cali_manual_mode` 0. For a P1S with nothing passed, the bridge sends `task_bed_leveling: true`, `auto_bed_leveling: 1`, `task_flow_cali: false`, `auto_flow_cali: 2`, `task_vibration_cali: false`, `task_layer_inspect: true`, `auto_offset_cali: 2` and `extruder_cali_manual_mode: 0`. An option you pass wins. `bed_leveling`/`flow_calibration` set "on" or "off", and `auto_bed_leveling`, `auto_flow_cali` and `auto_offset_cali` take 0 (off), 1 (on) or 2 (auto). On the H2/P2S LAN `project_file` route, the printer only receives flow calibration as on or off: no verified field requests "auto", so "auto" sends off, as before. The BambuNetwork and native routes carry `auto_flow_cali`. Only the printer type's own section of `BambuStudio.conf` is read; the file also holds access codes. `BAMBU_STUDIO_CONFIG` names another file, and an empty value uses no saved choices.
|
|
920
|
+
|
|
912
921
|
#### print_3mf
|
|
913
922
|
|
|
914
923
|
The primary tool for starting a Bambu print. **Recommended input: a pre-sliced `.gcode.3mf` exported from FULU OrcaSlicer-bambulab, OrcaSlicer, or Bambu Studio** — see [slicing guide](https://github.com/DMontgomery40/bambu-printer-mcp/blob/main/docs/SLICING.md). This tool handles the complete workflow:
|
|
@@ -1062,7 +1071,7 @@ If the project does not match those assumptions, the tool fails fast with a stru
|
|
|
1062
1071
|
- `job` (not for idle, busy or offline): `name` is `subtask_name`, else the basename of `gcode_file` (a raw G-code print reports only its file path; that basename is the `jobName` the print returns); `id` is `task_id`, omitted when it is the LAN placeholder `"0"`; `progress` is `mc_percent`; `remainingSec` is `mc_remaining_time` (minutes) × 60; `layer`/`totalLayers` appear once the printer reports a total; `stage` is Bambu Studio's words for `stg_cur` ("Heatbed preheating", "Auto bed leveling").
|
|
1063
1072
|
- `temps`: nozzle and bed `{actual, target}`, and `chamber` from the H2 chamber controller or the X1 sensor. On H2 and X2D the nozzle is the active extruder's, from `device.extruder`. P1 and A1 printers have no chamber sensor, so it is omitted.
|
|
1064
1073
|
- `activeFilament`: the loaded spool's `material` and `#RRGGBB` `color`. `slot` is the index `ams_slots` uses: `amsId × 4 + tray` for an AMS, the unit id (128 and up) for an AMS-HT, and `"ext"` for the external spool, or `"254"` (left) / `"255"` (right) on dual-nozzle H2D, H2C and X2D. On H2 and X2D it comes from the active extruder's report.
|
|
1065
|
-
- `problems`: a non-zero `print_error` as 8 hex digits, such as `07008011`, and each HMS entry as `AAAA_BBBB_CCCC_DDDD`, such as `0300_1800_0001_0003`. Severity follows Bambu's HMS level: fatal is `fatal`, serious `error`, common `warning` and info `info`. Each HMS problem links to Bambu's page for that code. Messages come from the English HMS tables bundled with the pinned Bambu Studio release; `scripts/generate-hms-messages.mjs` turns them into `src/safety/hms-messages.ts` and the stage words into `src/printers/bambu-stages.ts`. A model without its own table, such as the P1S, gets the text the other tables share. Codes that Bambu lists for a printer without text are reported as `info`.
|
|
1074
|
+
- `problems`: a non-zero `print_error` as 8 hex digits, such as `07008011`, and each HMS entry as `AAAA_BBBB_CCCC_DDDD`, such as `0300_1800_0001_0003`. Severity follows Bambu's HMS level: fatal is `fatal`, serious `error`, common `warning` and info `info`. Each HMS problem links to Bambu's page for that code. Messages come from the English HMS tables bundled with the pinned Bambu Studio release; `scripts/generate-hms-messages.mjs` turns them into `src/safety/hms-messages.ts` and the stage words into `src/printers/bambu-stages.ts`. A model without its own table, such as the P1S, gets the text the other tables share. A code none of them has falls back to the user's own Bambu Studio download: `hms_en_<serial prefix>.json`, then `hms_en.json`, in the `hms` folder next to `BambuStudio.conf` (see `BAMBU_STUDIO_CONFIG`). Those files are read only, and Bambu's text is passed through unchanged. Codes that Bambu lists for a printer without text are reported as `info`.
|
|
1066
1075
|
- **`counterpart_make_3mf`** takes `{parts: [{stl_path, name, filament?}], out_path}` and writes a new 3MF for multi-colour printing. The parts become one assembly: they keep their relative positions, and each part prints with its own filament number (by default part 1 uses filament 1, part 2 filament 2, and so on). Slice it with `slice_stl` and one `load_filaments` profile per filament number, then print it with `print_3mf` and `ams_slots` or `ams_mapping`. The file holds one assembly rather than one object per part, because Bambu Studio 02.08.02.61's CLI arranges separate objects apart, reports G-code path conflicts between stacked objects when arranging is off, and refuses `load_filament_ids` for 3MF input. It never overwrites a file. The result lists `path`, `objects`, `filaments` (the highest filament number) and each part's triangle count.
|
|
1067
1076
|
|
|
1068
1077
|
`print_3mf` also returns `subtaskName`, the `subtask_name` it sends with the job, when it starts a 3MF with the LAN `project_file` command: an STL or 3MF sliced by `slice_stl`, and any 3MF on H2, P2S and A1. On H2 and P2S it also returns `taskId`, the `task_id` sent with the job; other models send `task_id: "0"`. A client can match `counterpart_print_progress` reports to its own print with these. Pre-sliced `.gcode.3mf` files on P1, X1 and A1 mini (sent as a G-code file), the X2D native route, and the BambuNetwork and Bambu Connect routes return neither.
|
package/dist/bambu-native.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export type BambuNativePrintOptions = {
|
|
|
18
18
|
flowCalibration?: boolean;
|
|
19
19
|
vibrationCalibration?: boolean;
|
|
20
20
|
layerInspect?: boolean;
|
|
21
|
+
/** Bambu Studio's PrintParams auto_* values (0 off, 1 on, 2 auto) and extruder_cali_manual_mode. */
|
|
22
|
+
autoBedLeveling?: number;
|
|
23
|
+
autoFlowCali?: number;
|
|
24
|
+
autoOffsetCali?: number;
|
|
25
|
+
extruderCaliManualMode?: number;
|
|
21
26
|
timelapse?: boolean;
|
|
22
27
|
/** true: the SD card or USB stick; false: internal storage (eMMC); unset: BAMBU_NATIVE_TRY_EMMC_PRINT or internal. Reported as the requested storage. */
|
|
23
28
|
externalStorage?: boolean;
|
package/dist/bambu-native.js
CHANGED
|
@@ -745,8 +745,13 @@ export async function printWithBambuNative(options, onUpdate, execution) {
|
|
|
745
745
|
BAMBU_NATIVE_NOZZLES_INFO: options.nozzlesInfo || "",
|
|
746
746
|
BAMBU_NATIVE_BED_LEVELING: boolEnv(options.bedLeveling, true),
|
|
747
747
|
BAMBU_NATIVE_FLOW_CALIBRATION: boolEnv(options.flowCalibration, true),
|
|
748
|
-
|
|
749
|
-
|
|
748
|
+
// Bambu Studio's Send dialog hard-codes these (SelectMachine.cpp:3344-3356).
|
|
749
|
+
BAMBU_NATIVE_VIBRATION_CALIBRATION: boolEnv(options.vibrationCalibration, false),
|
|
750
|
+
BAMBU_NATIVE_LAYER_INSPECT: boolEnv(options.layerInspect, true),
|
|
751
|
+
...(options.autoBedLeveling === undefined ? {} : { BAMBU_NATIVE_AUTO_BED_LEVELING: String(options.autoBedLeveling) }),
|
|
752
|
+
...(options.autoFlowCali === undefined ? {} : { BAMBU_NATIVE_AUTO_FLOW_CALI: String(options.autoFlowCali) }),
|
|
753
|
+
...(options.autoOffsetCali === undefined ? {} : { BAMBU_NATIVE_AUTO_OFFSET_CALI: String(options.autoOffsetCali) }),
|
|
754
|
+
...(options.extruderCaliManualMode === undefined ? {} : { BAMBU_NATIVE_EXTRUDER_CALI_MANUAL_MODE: String(options.extruderCaliManualMode) }),
|
|
750
755
|
BAMBU_NATIVE_TIMELAPSE: boolEnv(options.timelapse, false),
|
|
751
756
|
...(options.externalStorage === undefined ? {} : { BAMBU_NATIVE_TRY_EMMC_PRINT: String(!options.externalStorage) }),
|
|
752
757
|
}, 300000, onUpdate, execution);
|
|
@@ -793,8 +798,13 @@ export async function uploadWithBambuNative(options, onUpdate, execution) {
|
|
|
793
798
|
BAMBU_NATIVE_NOZZLES_INFO: options.nozzlesInfo || "",
|
|
794
799
|
BAMBU_NATIVE_BED_LEVELING: boolEnv(options.bedLeveling, true),
|
|
795
800
|
BAMBU_NATIVE_FLOW_CALIBRATION: boolEnv(options.flowCalibration, true),
|
|
796
|
-
|
|
797
|
-
|
|
801
|
+
// Bambu Studio's Send dialog hard-codes these (SelectMachine.cpp:3344-3356).
|
|
802
|
+
BAMBU_NATIVE_VIBRATION_CALIBRATION: boolEnv(options.vibrationCalibration, false),
|
|
803
|
+
BAMBU_NATIVE_LAYER_INSPECT: boolEnv(options.layerInspect, true),
|
|
804
|
+
...(options.autoBedLeveling === undefined ? {} : { BAMBU_NATIVE_AUTO_BED_LEVELING: String(options.autoBedLeveling) }),
|
|
805
|
+
...(options.autoFlowCali === undefined ? {} : { BAMBU_NATIVE_AUTO_FLOW_CALI: String(options.autoFlowCali) }),
|
|
806
|
+
...(options.autoOffsetCali === undefined ? {} : { BAMBU_NATIVE_AUTO_OFFSET_CALI: String(options.autoOffsetCali) }),
|
|
807
|
+
...(options.extruderCaliManualMode === undefined ? {} : { BAMBU_NATIVE_EXTRUDER_CALI_MANUAL_MODE: String(options.extruderCaliManualMode) }),
|
|
798
808
|
BAMBU_NATIVE_TIMELAPSE: boolEnv(options.timelapse, false),
|
|
799
809
|
}, 300000, onUpdate, execution);
|
|
800
810
|
if (result.resultCode !== 0) {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { BAMBU_STAGES } from "../printers/bambu-stages.js";
|
|
8
8
|
import { HMS_MESSAGES, HMS_MESSAGES_SOURCE, PRINT_ERROR_MESSAGES } from "../safety/hms-messages.js";
|
|
9
|
+
import { studioDownloadedText } from "../studio-hms-text.js";
|
|
9
10
|
import { isDualNozzleModel, normalizeModel } from "../safety/limits.js";
|
|
10
11
|
import { finiteNumber, hmsCode, isHiddenNotice } from "../safety/printer-state.js";
|
|
11
12
|
import { COUNTERPART_CONTRACT } from "./schemas.js";
|
|
@@ -73,7 +74,7 @@ export function bambuProblems(raw, serial, model) {
|
|
|
73
74
|
// 0300400C only records a cancel; it is the state, not a problem.
|
|
74
75
|
if (error !== undefined && Number.isInteger(error) && error > 0 && error <= 0xffffffff && error !== TASK_CANCELLED) {
|
|
75
76
|
const code = error.toString(16).padStart(8, "0").toUpperCase();
|
|
76
|
-
add({ code, severity: "error", message: tableText(PRINT_ERROR_MESSAGES, code, serial) ?? undocumented(code) });
|
|
77
|
+
add({ code, severity: "error", message: tableText(PRINT_ERROR_MESSAGES, code, serial) ?? studioDownloadedText("error", code, serial) ?? undocumented(code) });
|
|
77
78
|
}
|
|
78
79
|
for (const reported of Array.isArray(raw.hms) ? raw.hms : []) {
|
|
79
80
|
const entry = hmsCode(reported);
|
|
@@ -89,7 +90,8 @@ export function bambuProblems(raw, serial, model) {
|
|
|
89
90
|
add({
|
|
90
91
|
code,
|
|
91
92
|
severity: HMS_SEVERITIES[entry.severity] ?? "error",
|
|
92
|
-
|
|
93
|
+
// The pinned tag bundles no P1, X1 or A1 table; the user's own Studio download may have the text.
|
|
94
|
+
message: tableText(HMS_MESSAGES, entry.hex, serial) ?? studioDownloadedText("hms", entry.hex, serial) ?? undocumented(code),
|
|
93
95
|
url: hmsUrl(entry.hex),
|
|
94
96
|
});
|
|
95
97
|
}
|
|
@@ -52,9 +52,11 @@ export const defaultFusionSystem = {
|
|
|
52
52
|
/**
|
|
53
53
|
* An open port is not enough: Blender's MCP add-on defaults to
|
|
54
54
|
* localhost:9876, the add-in's own default. The add-in speaks newline-delimited JSON
|
|
55
|
-
* (addon/server/socket_server.py) and answers {"type":"ping"}
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* (addon/server/socket_server.py) and answers {"type":"ping"} without touching
|
|
56
|
+
* Fusion's API: on its fast path (event_bridge.py) with
|
|
57
|
+
* {"status":"success","result":{"ok":true,"status":"pong"}}, and through its
|
|
58
|
+
* command handler with {"pong":true}. Blender's add-on answers an unknown command
|
|
59
|
+
* with an error.
|
|
58
60
|
*/
|
|
59
61
|
addinAnswers: (host, port, timeoutMs) => new Promise(resolve => {
|
|
60
62
|
const socket = net.connect({ host, port });
|
|
@@ -78,7 +80,7 @@ export const defaultFusionSystem = {
|
|
|
78
80
|
const newline = buffer.indexOf("\n");
|
|
79
81
|
try {
|
|
80
82
|
const reply = JSON.parse(newline >= 0 ? buffer.slice(0, newline) : buffer);
|
|
81
|
-
done(reply?.status === "success" && reply?.result?.pong === true);
|
|
83
|
+
done(reply?.status === "success" && (reply?.result?.status === "pong" || reply?.result?.pong === true));
|
|
82
84
|
}
|
|
83
85
|
catch {
|
|
84
86
|
if (newline >= 0)
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import os from "node:os";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import { createServer as createHttpServer } from "node:http";
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
|
-
import { STLManipulator, SLICER_TYPES, normalizeSlicerType, } from "./stl/stl-manipulator.js";
|
|
12
|
+
import { STLManipulator, SLICER_TYPES, normalizeSlicerType, SlicerRunError, } from "./stl/stl-manipulator.js";
|
|
13
13
|
import { BambuNetworkBridge, describeBambuNetworkPrintError } from "./bambu-network-bridge.js";
|
|
14
14
|
import { assertBambuNativeAvailable, bambuNativeControlsAvailable, bambuNativeUnavailableReason, interruptNativeOperations, validateBambuNativeMetadata, buildBambuNativeFanCommand, buildBambuNativeTemperatureCommand, printWithBambuNative, sendCommandWithBambuNative, uploadWithBambuNative, } from "./bambu-native.js";
|
|
15
15
|
import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
@@ -18,6 +18,7 @@ import { FUSION_CALL_OUTPUT_SCHEMA, FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFA
|
|
|
18
18
|
import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, hasAmsMappingInput, normalizeAmsMappingObject, normalizeBridgeAmsTrayValue } from "./ams-mapping.js";
|
|
19
19
|
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, parse3MF } from './3mf_parser.js';
|
|
20
20
|
import { BambuImplementation, assertDirectPrintSupported, checkedFile } from "./printers/bambu.js";
|
|
21
|
+
import { resolveStudioPrintOptions, usedNozzleCount } from "./studio-print-options.js";
|
|
21
22
|
import { inspectPrintFile } from "./safety/print-file.js";
|
|
22
23
|
import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
23
24
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
@@ -123,6 +124,29 @@ function assertUniformCliNozzles(args) {
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
const VALID_BAMBU_MODELS = ["p1s", "p1p", "p2s", "x1c", "x1e", "a1", "a1mini", "h2d", "h2dpro", "h2s", "h2c", "x2d"];
|
|
127
|
+
/** The Send dialog options a caller set explicitly; the rest resolve as Bambu Studio does (studio-print-options.ts). */
|
|
128
|
+
function callerPrintOptions(args) {
|
|
129
|
+
const flag = (value) => value === undefined ? undefined : Boolean(value);
|
|
130
|
+
const int = (value, label) => {
|
|
131
|
+
if (value === undefined)
|
|
132
|
+
return undefined;
|
|
133
|
+
const number = Number(value);
|
|
134
|
+
if (!Number.isInteger(number))
|
|
135
|
+
throw new Error(`${label} must be an integer.`);
|
|
136
|
+
return number;
|
|
137
|
+
};
|
|
138
|
+
const options = {
|
|
139
|
+
bedLeveling: flag(args?.bed_leveling),
|
|
140
|
+
flowCalibration: flag(args?.flow_calibration),
|
|
141
|
+
vibrationCalibration: flag(args?.vibration_calibration),
|
|
142
|
+
layerInspect: flag(args?.layer_inspect),
|
|
143
|
+
autoBedLeveling: int(args?.auto_bed_leveling, "auto_bed_leveling"),
|
|
144
|
+
autoFlowCali: int(args?.auto_flow_cali, "auto_flow_cali"),
|
|
145
|
+
autoOffsetCali: int(args?.auto_offset_cali, "auto_offset_cali"),
|
|
146
|
+
extruderCaliManualMode: int(args?.extruder_cali_manual_mode, "extruder_cali_manual_mode"),
|
|
147
|
+
};
|
|
148
|
+
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined));
|
|
149
|
+
}
|
|
126
150
|
// X2D uses the same project_file/ams_mapping2 family of LAN print fields as
|
|
127
151
|
// the dual-nozzle H2 path. Keep it in this gate so pre-sliced multi-filament
|
|
128
152
|
// jobs take the correct branch instead of the legacy 5-slot mapping.
|
|
@@ -1231,6 +1255,8 @@ class BambuPrinterMCPServer {
|
|
|
1231
1255
|
return withPrinterOperation(devIp, devId, assertActive => withPrintSnapshot(threeMFPath, async (snapshot, retainForDispatchedUpload) => {
|
|
1232
1256
|
const inspection = await inspectPrintFile(snapshot, { model: printModel, nozzleDiameters: printNozzles, plateIndex, bedType: printBedType });
|
|
1233
1257
|
const resumeFile = await checkedFile(inspection, snapshot);
|
|
1258
|
+
// The options Bambu Studio's Send dialog would send; explicit ones win.
|
|
1259
|
+
const studio = resolveStudioPrintOptions(printModel, callerPrintOptions(args), { usedNozzles: usedNozzleCount(inspection) });
|
|
1234
1260
|
let mapping = finalAmsMapping?.slice();
|
|
1235
1261
|
if (finalAmsSlots) {
|
|
1236
1262
|
if (finalAmsSlots.length !== inspection.usedFilamentPositions.length)
|
|
@@ -1295,18 +1321,18 @@ class BambuPrinterMCPServer {
|
|
|
1295
1321
|
use_ssl_for_mqtt: args?.use_ssl_for_mqtt !== undefined ? Boolean(args.use_ssl_for_mqtt) : true,
|
|
1296
1322
|
username: String(args?.username || "bblp"),
|
|
1297
1323
|
password,
|
|
1298
|
-
task_bed_leveling:
|
|
1299
|
-
task_flow_cali:
|
|
1300
|
-
task_vibration_cali:
|
|
1301
|
-
task_layer_inspect:
|
|
1324
|
+
task_bed_leveling: studio.task_bed_leveling,
|
|
1325
|
+
task_flow_cali: studio.task_flow_cali,
|
|
1326
|
+
task_vibration_cali: studio.task_vibration_cali,
|
|
1327
|
+
task_layer_inspect: studio.task_layer_inspect,
|
|
1302
1328
|
task_record_timelapse: args?.timelapse !== undefined ? Boolean(args.timelapse) : false,
|
|
1303
1329
|
task_use_ams: useAMS,
|
|
1304
1330
|
task_bed_type: printBedType,
|
|
1305
1331
|
extra_options: stringifyBridgeJson(args?.extra_options) || "",
|
|
1306
|
-
auto_bed_leveling:
|
|
1307
|
-
auto_flow_cali:
|
|
1308
|
-
auto_offset_cali:
|
|
1309
|
-
extruder_cali_manual_mode:
|
|
1332
|
+
auto_bed_leveling: studio.auto_bed_leveling,
|
|
1333
|
+
auto_flow_cali: studio.auto_flow_cali,
|
|
1334
|
+
auto_offset_cali: studio.auto_offset_cali,
|
|
1335
|
+
extruder_cali_manual_mode: studio.extruder_cali_manual_mode,
|
|
1310
1336
|
task_ext_change_assist: args?.external_change_assist !== undefined ? Boolean(args.external_change_assist) : false,
|
|
1311
1337
|
try_emmc_print: args?.try_emmc_print !== undefined ? Boolean(args.try_emmc_print) : false,
|
|
1312
1338
|
};
|
|
@@ -1328,6 +1354,10 @@ class BambuPrinterMCPServer {
|
|
|
1328
1354
|
flowCalibration: params.task_flow_cali,
|
|
1329
1355
|
vibrationCalibration: params.task_vibration_cali,
|
|
1330
1356
|
layerInspect: params.task_layer_inspect,
|
|
1357
|
+
autoBedLeveling: studio.auto_bed_leveling,
|
|
1358
|
+
autoFlowCali: studio.auto_flow_cali,
|
|
1359
|
+
autoOffsetCali: studio.auto_offset_cali,
|
|
1360
|
+
extruderCaliManualMode: studio.extruder_cali_manual_mode,
|
|
1331
1361
|
timelapse: params.task_record_timelapse,
|
|
1332
1362
|
externalStorage,
|
|
1333
1363
|
}, native.onUpdate, { signal: native.signal, assertActive, beforeDispatch: async () => {
|
|
@@ -1981,7 +2011,7 @@ class BambuPrinterMCPServer {
|
|
|
1981
2011
|
},
|
|
1982
2012
|
{
|
|
1983
2013
|
name: "slice_stl",
|
|
1984
|
-
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer.",
|
|
2014
|
+
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. A failed slice's text starts with those words.",
|
|
1985
2015
|
inputSchema: {
|
|
1986
2016
|
type: "object",
|
|
1987
2017
|
properties: {
|
|
@@ -2150,10 +2180,10 @@ class BambuPrinterMCPServer {
|
|
|
2150
2180
|
ams_mapping_info: { type: "string", description: "Raw JSON string for FULU PrintParams ams_mapping_info, matching OrcaSlicer-bambulab's detailed AMS mapping field." },
|
|
2151
2181
|
nozzle_mapping: { type: "string", description: "Raw JSON string for FULU PrintParams nozzle_mapping." },
|
|
2152
2182
|
nozzles_info: { type: "string", description: "Raw JSON string for FULU PrintParams nozzles_info." },
|
|
2153
|
-
bed_leveling: { type: "boolean", description: "
|
|
2154
|
-
flow_calibration: { type: "boolean", description: "
|
|
2155
|
-
vibration_calibration: { type: "boolean", description: "
|
|
2156
|
-
layer_inspect: { type: "boolean", description: "
|
|
2183
|
+
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." },
|
|
2184
|
+
flow_calibration: { type: "boolean", description: "Flow calibration on or off. Omit to send what Bambu Studio's Send dialog would (auto on P1/P1S)." },
|
|
2185
|
+
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2186
|
+
layer_inspect: { type: "boolean", description: "First-layer inspection where supported (default true, as Bambu Studio sends)." },
|
|
2157
2187
|
timelapse: { type: "boolean", description: "Enable timelapse recording in FULU PrintParams (default: false)." },
|
|
2158
2188
|
use_ssl_for_ftp: { type: "boolean", description: "Whether FULU local print should use SSL for FTP (default: true)." },
|
|
2159
2189
|
use_ssl_for_mqtt: { type: "boolean", description: "Whether FULU local print should use SSL for MQTT (default: true)." },
|
|
@@ -2585,9 +2615,9 @@ class BambuPrinterMCPServer {
|
|
|
2585
2615
|
type: "boolean",
|
|
2586
2616
|
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."
|
|
2587
2617
|
},
|
|
2588
|
-
bed_leveling: { type: "boolean", description: "
|
|
2589
|
-
flow_calibration: { type: "boolean", description: "
|
|
2590
|
-
vibration_calibration: { type: "boolean", description: "
|
|
2618
|
+
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." },
|
|
2619
|
+
flow_calibration: { type: "boolean", description: "Flow calibration on or off. Omit to send what Bambu Studio's Send dialog would (auto on P1/P1S)." },
|
|
2620
|
+
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2591
2621
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
2592
2622
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
2593
2623
|
template_3mf_path: { type: "string", description: "Optional template 3MF whose embedded Bambu slicer settings should be reused when auto-slicing this print job." },
|
|
@@ -2621,9 +2651,9 @@ class BambuPrinterMCPServer {
|
|
|
2621
2651
|
enum: ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"],
|
|
2622
2652
|
description: "Bed plate type currently installed (default: textured_plate)"
|
|
2623
2653
|
},
|
|
2624
|
-
bed_leveling: { type: "boolean", description: "
|
|
2625
|
-
flow_calibration: { type: "boolean", description: "
|
|
2626
|
-
vibration_calibration: { type: "boolean", description: "
|
|
2654
|
+
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." },
|
|
2655
|
+
flow_calibration: { type: "boolean", description: "Flow calibration on or off. Omit to send what Bambu Studio's Send dialog would (auto on P1/P1S)." },
|
|
2656
|
+
vibration_calibration: { type: "boolean", description: "Vibration calibration (default false, as Bambu Studio sends)." },
|
|
2627
2657
|
timelapse: { type: "boolean", description: "Enable timelapse recording (default: false)" },
|
|
2628
2658
|
slicer_profile: { type: "string", description: "Path to the slicer profile/config file for auto-slicing (optional)." },
|
|
2629
2659
|
nozzle_diameter: { type: "string", description: "Nozzle diameter in mm for auto-slicing (default: 0.4)" }
|
|
@@ -2656,7 +2686,7 @@ class BambuPrinterMCPServer {
|
|
|
2656
2686
|
},
|
|
2657
2687
|
{
|
|
2658
2688
|
name: "lay_flat",
|
|
2659
|
-
description: "Rotate the model so
|
|
2689
|
+
description: "Rotate the model so a face rests on the bed (Z=0), choosing the orientation with the least part and support volume per mm² of bed contact. A face counts only if nothing hangs below it. Returns the new STL path; structuredContent.laid_flat is false, with the input path, when no orientation qualifies.",
|
|
2660
2690
|
inputSchema: {
|
|
2661
2691
|
type: "object",
|
|
2662
2692
|
properties: {
|
|
@@ -3581,9 +3611,11 @@ class BambuPrinterMCPServer {
|
|
|
3581
3611
|
console.warn("Could not resolve live printer filaments for slicing:", filamentError);
|
|
3582
3612
|
}
|
|
3583
3613
|
}
|
|
3584
|
-
|
|
3614
|
+
const sliced = await this.stlManipulator.sliceSTLWithResult(String(args.stl_path), slicerType, slicerPath, activeSlicerProfile, undefined, // progressCallback
|
|
3585
3615
|
printerPreset, sliceBambuOptions);
|
|
3586
|
-
|
|
3616
|
+
await progressNotifications;
|
|
3617
|
+
// The text stays the sliced file's path; slicer_result is the slicer's own result.json, verbatim.
|
|
3618
|
+
return { content: [{ type: "text", text: sliced.path }], structuredContent: sliced };
|
|
3587
3619
|
}
|
|
3588
3620
|
case "print_3mf": {
|
|
3589
3621
|
if (!args?.three_mf_path) {
|
|
@@ -3749,10 +3781,7 @@ class BambuPrinterMCPServer {
|
|
|
3749
3781
|
amsMapping: finalAmsMapping,
|
|
3750
3782
|
amsSlots: finalAmsSlots,
|
|
3751
3783
|
bedType: printBedType,
|
|
3752
|
-
|
|
3753
|
-
flowCalibration: args?.flow_calibration !== undefined ? Boolean(args.flow_calibration) : undefined,
|
|
3754
|
-
vibrationCalibration: args?.vibration_calibration !== undefined ? Boolean(args.vibration_calibration) : undefined,
|
|
3755
|
-
layerInspect: args?.layer_inspect !== undefined ? Boolean(args.layer_inspect) : undefined,
|
|
3784
|
+
...callerPrintOptions(args),
|
|
3756
3785
|
timelapse: args?.timelapse !== undefined ? Boolean(args.timelapse) : undefined,
|
|
3757
3786
|
});
|
|
3758
3787
|
// Report what the printer did, not merely that a command was published.
|
|
@@ -3786,9 +3815,7 @@ class BambuPrinterMCPServer {
|
|
|
3786
3815
|
useAMS: true,
|
|
3787
3816
|
amsSlots: collarAnalysis.amsSlots,
|
|
3788
3817
|
bedType: printBedType,
|
|
3789
|
-
|
|
3790
|
-
flowCalibration: args?.flow_calibration !== undefined ? Boolean(args.flow_calibration) : true,
|
|
3791
|
-
vibrationCalibration: args?.vibration_calibration !== undefined ? Boolean(args.vibration_calibration) : true,
|
|
3818
|
+
...callerPrintOptions(args),
|
|
3792
3819
|
timelapse: args?.timelapse !== undefined ? Boolean(args.timelapse) : false,
|
|
3793
3820
|
});
|
|
3794
3821
|
result = {
|
|
@@ -3828,11 +3855,14 @@ class BambuPrinterMCPServer {
|
|
|
3828
3855
|
throw new Error("Missing required parameter: stl_path");
|
|
3829
3856
|
result = await this.stlManipulator.centerModel(String(args.stl_path));
|
|
3830
3857
|
break;
|
|
3831
|
-
case "lay_flat":
|
|
3858
|
+
case "lay_flat": {
|
|
3832
3859
|
if (!args?.stl_path)
|
|
3833
3860
|
throw new Error("Missing required parameter: stl_path");
|
|
3834
|
-
|
|
3835
|
-
|
|
3861
|
+
const layFlatResult = await this.stlManipulator.layFlatWithResult(String(args.stl_path));
|
|
3862
|
+
await progressNotifications;
|
|
3863
|
+
// The text stays the STL path clients read; structuredContent says whether it was laid flat.
|
|
3864
|
+
return { content: [{ type: "text", text: layFlatResult.path }], structuredContent: layFlatResult };
|
|
3865
|
+
}
|
|
3836
3866
|
case "blender_mcp_status":
|
|
3837
3867
|
result = await this.blender.status(args ?? {}, extra.signal);
|
|
3838
3868
|
break;
|
|
@@ -3894,11 +3924,14 @@ class BambuPrinterMCPServer {
|
|
|
3894
3924
|
: `Check parameters and try again. Error: ${message}`,
|
|
3895
3925
|
message,
|
|
3896
3926
|
tool: name,
|
|
3927
|
+
// The slicer's own result.json; the message starts with its error_string and warnings.
|
|
3928
|
+
...(error instanceof SlicerRunError && error.slicerResult ? { slicer_result: error.slicerResult } : {}),
|
|
3897
3929
|
};
|
|
3898
3930
|
// MCP clients validate structuredContent against a declared outputSchema even on
|
|
3899
3931
|
// errors (SDK 1.32 Client.callTool), so those tools return the error as text only.
|
|
3900
3932
|
return {
|
|
3901
|
-
|
|
3933
|
+
// A slicer failure leads with the slicer's own words.
|
|
3934
|
+
content: [{ type: "text", text: error instanceof SlicerRunError && error.slicerText ? message : `Error: ${message}` }],
|
|
3902
3935
|
...(OUTPUT_SCHEMA_TOOLS.has(name) ? {} : { structuredContent: structured }),
|
|
3903
3936
|
isError: true,
|
|
3904
3937
|
};
|
package/dist/printers/bambu.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ interface BambuPrintOptionsInternal {
|
|
|
13
13
|
flowCalibration?: boolean;
|
|
14
14
|
vibrationCalibration?: boolean;
|
|
15
15
|
layerInspect?: boolean;
|
|
16
|
+
/** Explicit Studio option values (0 off, 1 on, 2 auto); see studio-print-options.ts. */
|
|
17
|
+
autoBedLeveling?: number;
|
|
18
|
+
autoFlowCali?: number;
|
|
19
|
+
autoOffsetCali?: number;
|
|
20
|
+
extruderCaliManualMode?: number;
|
|
16
21
|
timelapse?: boolean;
|
|
17
22
|
amsMapping?: number[];
|
|
18
23
|
/**
|
package/dist/printers/bambu.js
CHANGED
|
@@ -12,6 +12,7 @@ import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, d
|
|
|
12
12
|
import { describeHmsKey, hiddenHmsKeys, hiddenHmsNotices, reportedHmsKey, unchippedNozzles, validatePrinterState, manualHeatingRequirements } from "../safety/printer-state.js";
|
|
13
13
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName, normalizedRemotePath, cancelPendingPrinterOperations } from "../safety/artifact.js";
|
|
14
14
|
import { RTSP_CAMERA_MODELS, TCP_CAMERA_MODELS } from "./camera-models.js";
|
|
15
|
+
import { resolveStudioPrintOptions, usedNozzleCount } from "../studio-print-options.js";
|
|
15
16
|
import { Client as FTPClient } from "basic-ftp";
|
|
16
17
|
import * as mqtt from "mqtt";
|
|
17
18
|
import { BambuClient, GCodeFileCommand, GCodeLineCommand, PushAllCommand, UpdateFanCommand, UpdateLightCommand, UpdateStateCommand, } from "bambu-node";
|
|
@@ -37,6 +38,36 @@ function loadClientCreds() {
|
|
|
37
38
|
}
|
|
38
39
|
const CLIENT_CREDS = loadClientCreds();
|
|
39
40
|
const COMMAND_SETTLE_MS = 300;
|
|
41
|
+
/** How long a stop waits for the printer's MQTT PUBACK before its client is closed (BAMBU_STOP_ACK_MS for tests). */
|
|
42
|
+
const stopAckMs = () => { const value = Number(process.env.BAMBU_STOP_ACK_MS); return Number.isInteger(value) && value > 0 ? value : 10000; };
|
|
43
|
+
/**
|
|
44
|
+
* Publish JSON exactly as Bambu Studio's MachineObject::publish_json does
|
|
45
|
+
* (DeviceManager.cpp:2462): the given message on device/<serial>/request at the
|
|
46
|
+
* given QoS. With QoS 1 it resolves on the printer's PUBACK. bambu-node's own
|
|
47
|
+
* publish has no QoS (MQTT.js defaults to 0).
|
|
48
|
+
*/
|
|
49
|
+
function publishStudioJson(client, message, qos) {
|
|
50
|
+
const mqttClient = client.mqttClient;
|
|
51
|
+
const serial = client.config?.serialNumber;
|
|
52
|
+
if (!mqttClient || typeof mqttClient.publish !== "function" || typeof serial !== "string")
|
|
53
|
+
return client.publish(message);
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
mqttClient.publish(`device/${serial}/request`, JSON.stringify(message), { qos }, (error) => {
|
|
56
|
+
if (error)
|
|
57
|
+
reject(new Error(`Error publishing to device/${serial}/request: ${error.message}`));
|
|
58
|
+
else
|
|
59
|
+
resolve();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Bambu Studio's stop, MachineObject::command_task_abort (DeviceManager.cpp:1418-1426):
|
|
65
|
+
* {"print":{"command":"stop","param":"","sequence_id":"<n>"}} at QoS 1. bambu-node's
|
|
66
|
+
* UpdateStateCommand sends no param, at QoS 0.
|
|
67
|
+
*/
|
|
68
|
+
const studioStopCommand = {
|
|
69
|
+
invoke: (client) => publishStudioJson(client, { print: { command: "stop", param: "", sequence_id: String(Date.now()) } }, 1),
|
|
70
|
+
};
|
|
40
71
|
/** A cached report older than this may be refreshed once with PushAll; see readProgressReport. */
|
|
41
72
|
const STALE_REPORT_MS = 300000;
|
|
42
73
|
/** HMS 0500-0500-0001-0007: firmware 01.08.05+ rejected an unsigned MQTT command. */
|
|
@@ -844,6 +875,13 @@ export class BambuImplementation {
|
|
|
844
875
|
model, nozzleDiameters: options.nozzleDiameters, plateIndex: options.plateIndex ?? 0, bedType: options.bedType,
|
|
845
876
|
});
|
|
846
877
|
const resumeFile = await checkedFile(inspection, options.filePath);
|
|
878
|
+
// The options Bambu Studio's Send dialog would send; explicit ones win.
|
|
879
|
+
const studio = resolveStudioPrintOptions(model, {
|
|
880
|
+
bedLeveling: options.bedLeveling, flowCalibration: options.flowCalibration,
|
|
881
|
+
vibrationCalibration: options.vibrationCalibration, layerInspect: options.layerInspect,
|
|
882
|
+
autoBedLeveling: options.autoBedLeveling, autoFlowCali: options.autoFlowCali,
|
|
883
|
+
autoOffsetCali: options.autoOffsetCali, extruderCaliManualMode: options.extruderCaliManualMode,
|
|
884
|
+
}, { usedNozzles: usedNozzleCount(inspection) });
|
|
847
885
|
const projectMetadata = await this.resolveProjectFileMetadata(options.filePath, options.plateIndex, inspection.plateInternalPath);
|
|
848
886
|
// Send project_file command via bambu-node MQTT (bypasses bambu-js
|
|
849
887
|
// hardcoded use_ams=true and missing ams_mapping support)
|
|
@@ -1005,16 +1043,21 @@ export class BambuImplementation {
|
|
|
1005
1043
|
md5,
|
|
1006
1044
|
bed_type: options.bedType || "auto",
|
|
1007
1045
|
timelapse: b(options.timelapse),
|
|
1008
|
-
bed_leveling: b(
|
|
1009
|
-
auto_bed_leveling:
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1046
|
+
bed_leveling: b(studio.task_bed_leveling),
|
|
1047
|
+
auto_bed_leveling: studio.auto_bed_leveling,
|
|
1048
|
+
// No verified project_file field requests automatic flow calibration
|
|
1049
|
+
// (Studio's PrintParams auto_flow_cali reaches the printer through the
|
|
1050
|
+
// plug-in, whose MQTT form is not public), so "auto" sends 0 as before,
|
|
1051
|
+
// and extrude_cali_flag keeps its existing 0. The bridge and native
|
|
1052
|
+
// routes carry auto_flow_cali.
|
|
1053
|
+
flow_cali: b(studio.task_flow_cali),
|
|
1054
|
+
vibration_cali: b(studio.task_vibration_cali),
|
|
1055
|
+
layer_inspect: b(studio.task_layer_inspect),
|
|
1013
1056
|
use_ams: options.useAMS !== false,
|
|
1014
1057
|
cfg: "0",
|
|
1015
1058
|
extrude_cali_flag: 0,
|
|
1016
|
-
extrude_cali_manual_mode:
|
|
1017
|
-
nozzle_offset_cali:
|
|
1059
|
+
extrude_cali_manual_mode: studio.extruder_cali_manual_mode,
|
|
1060
|
+
nozzle_offset_cali: studio.auto_offset_cali,
|
|
1018
1061
|
subtask_name: subtaskName,
|
|
1019
1062
|
profile_id: "0",
|
|
1020
1063
|
project_id: submissionId,
|
|
@@ -1033,10 +1076,10 @@ export class BambuImplementation {
|
|
|
1033
1076
|
url: projectUrl,
|
|
1034
1077
|
subtask_name: subtaskName,
|
|
1035
1078
|
md5,
|
|
1036
|
-
flow_cali:
|
|
1037
|
-
layer_inspect:
|
|
1038
|
-
vibration_cali:
|
|
1039
|
-
bed_leveling:
|
|
1079
|
+
flow_cali: studio.task_flow_cali,
|
|
1080
|
+
layer_inspect: studio.task_layer_inspect,
|
|
1081
|
+
vibration_cali: studio.task_vibration_cali,
|
|
1082
|
+
bed_leveling: studio.task_bed_leveling,
|
|
1040
1083
|
bed_type: options.bedType || "textured_plate",
|
|
1041
1084
|
timelapse: options.timelapse ?? false,
|
|
1042
1085
|
use_ams: options.useAMS !== false,
|
|
@@ -1083,10 +1126,23 @@ export class BambuImplementation {
|
|
|
1083
1126
|
try {
|
|
1084
1127
|
if (dispatch)
|
|
1085
1128
|
return await dispatch();
|
|
1086
|
-
|
|
1087
|
-
|
|
1129
|
+
// A stop with no PUBACK must not stay queued in MQTT.js and reach a later job.
|
|
1130
|
+
const ackMs = stopAckMs();
|
|
1131
|
+
const deadline = new AbortController();
|
|
1132
|
+
const timer = setTimeout(() => deadline.abort(Object.assign(new Error("stop not acknowledged"), { name: "TimeoutError" })), ackMs);
|
|
1133
|
+
try {
|
|
1134
|
+
await this.invokeEmergencyCommand(printer, studioStopCommand, deadline.signal);
|
|
1135
|
+
}
|
|
1136
|
+
catch (error) {
|
|
1137
|
+
if (error?.name === "TimeoutError")
|
|
1138
|
+
throw new Error(`The printer did not acknowledge the stop within ${ackMs / 1000} s; its MQTT client was closed so the stop cannot be sent late. Check the printer.`);
|
|
1139
|
+
throw error;
|
|
1140
|
+
}
|
|
1141
|
+
finally {
|
|
1142
|
+
clearTimeout(timer);
|
|
1143
|
+
}
|
|
1088
1144
|
this.checkedJobs.delete(`${host}\n${serial}`);
|
|
1089
|
-
return { status: "success", message: "
|
|
1145
|
+
return { status: "success", message: "Stop sent and acknowledged by the printer (MQTT QoS 1), as Bambu Studio sends it. Check get_printer_status to confirm the job stopped." };
|
|
1090
1146
|
}
|
|
1091
1147
|
catch (error) {
|
|
1092
1148
|
throw new Error(`Failed to cancel print: ${error.message}`);
|
|
@@ -1124,8 +1180,8 @@ export class BambuImplementation {
|
|
|
1124
1180
|
signal?.throwIfAborted();
|
|
1125
1181
|
const printer = await this.getPrinter(host, serial, token);
|
|
1126
1182
|
signal?.throwIfAborted();
|
|
1127
|
-
await this.invokeEmergencyCommand(printer,
|
|
1128
|
-
return { status: "success", message: "
|
|
1183
|
+
await this.invokeEmergencyCommand(printer, studioStopCommand, signal);
|
|
1184
|
+
return { status: "success", message: "Stop sent over MQTT and acknowledged by the printer (QoS 1)." };
|
|
1129
1185
|
}
|
|
1130
1186
|
/** Raw MQTT heater-off; switching off needs no material or model declaration. */
|
|
1131
1187
|
async sendHeaterOffOverMqtt(host, serial, token, heater, signal) {
|
|
@@ -52,6 +52,22 @@ export interface BambuSliceOptions {
|
|
|
52
52
|
slicePlate?: number;
|
|
53
53
|
processOverrides?: ProcessOverrides;
|
|
54
54
|
}
|
|
55
|
+
/** Bambu Studio's or OrcaSlicer's own result.json, parsed verbatim. */
|
|
56
|
+
export type SlicerResult = Record<string, unknown>;
|
|
57
|
+
/** A sliced file, with the slicer's own result.json when it wrote one. */
|
|
58
|
+
export type SliceOutput = {
|
|
59
|
+
path: string;
|
|
60
|
+
slicer_result?: SlicerResult;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A slicer failure that keeps the slicer's own result.json. The message starts
|
|
64
|
+
* with the slicer's own words (`slicerText`), when it gave any, then `detail`.
|
|
65
|
+
*/
|
|
66
|
+
export declare class SlicerRunError extends Error {
|
|
67
|
+
readonly slicerResult?: SlicerResult | undefined;
|
|
68
|
+
readonly slicerText: string;
|
|
69
|
+
constructor(detail: string, slicerResult?: SlicerResult | undefined);
|
|
70
|
+
}
|
|
55
71
|
export declare class STLManipulator extends EventEmitter {
|
|
56
72
|
private tempDir;
|
|
57
73
|
private activeOperations;
|
|
@@ -172,6 +188,12 @@ export declare class STLManipulator extends EventEmitter {
|
|
|
172
188
|
* @returns Path to the generated G-code or sliced 3MF file
|
|
173
189
|
*/
|
|
174
190
|
sliceSTL(stlFilePath: string, slicerType: SlicerType, slicerPath: string, slicerProfile?: string, progressCallback?: ProgressCallback, printerPreset?: string, bambuOptions?: BambuSliceOptions): Promise<string>;
|
|
191
|
+
/**
|
|
192
|
+
* sliceSTL with the Bambu-compatible CLI's own result.json, parsed verbatim.
|
|
193
|
+
* A failure throws SlicerRunError, whose message starts with the slicer's
|
|
194
|
+
* error_string and plate warnings.
|
|
195
|
+
*/
|
|
196
|
+
sliceSTLWithResult(stlFilePath: string, slicerType: SlicerType, slicerPath: string, slicerProfile?: string, progressCallback?: ProgressCallback, printerPreset?: string, bambuOptions?: BambuSliceOptions): Promise<SliceOutput>;
|
|
175
197
|
/**
|
|
176
198
|
* Enhanced version of confirmTemperatures with better error handling
|
|
177
199
|
* @param gcodePath Path to the G-code file
|
|
@@ -207,7 +229,21 @@ export declare class STLManipulator extends EventEmitter {
|
|
|
207
229
|
*/
|
|
208
230
|
centerModel(stlFilePath: string, progressCallback?: ProgressCallback): Promise<string>;
|
|
209
231
|
/**
|
|
210
|
-
* Rotate the model so
|
|
232
|
+
* Rotate the model so a face rests on the bed, in the pose with the least
|
|
233
|
+
* part and support material per mm² of bed contact, then move it down to
|
|
234
|
+
* Z=0. Returns the new file's path, or the input path when no pose qualifies.
|
|
211
235
|
*/
|
|
212
236
|
layFlat(stlFilePath: string, progressCallback?: ProgressCallback): Promise<string>;
|
|
237
|
+
/**
|
|
238
|
+
* layFlat with its outcome. A pose qualifies only when some face, turned to
|
|
239
|
+
* face down, lies on the rotated mesh's lowest plane; `laid_flat` is false
|
|
240
|
+
* and the model is unchanged when none does.
|
|
241
|
+
*/
|
|
242
|
+
layFlatWithResult(stlFilePath: string, progressCallback?: ProgressCallback): Promise<LayFlatResult>;
|
|
213
243
|
}
|
|
244
|
+
export type LayFlatResult = {
|
|
245
|
+
/** The laid-flat STL, or the unchanged input when `laid_flat` is false. */
|
|
246
|
+
path: string;
|
|
247
|
+
laid_flat: boolean;
|
|
248
|
+
message: string;
|
|
249
|
+
};
|