bambu-printer-mcp 1.1.46 → 1.1.47
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 +1 -1
- package/dist/index.js +5 -5
- package/dist/printers/bambu.d.ts +3 -4
- package/dist/printers/bambu.js +14 -19
- package/dist/safety/printer-state.d.ts +2 -2
- package/dist/safety/printer-state.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +5 -5
- package/src/printers/bambu.ts +14 -19
- package/src/safety/printer-state.ts +2 -2
package/README.md
CHANGED
|
@@ -206,7 +206,7 @@ The optional FULU **BambuNetwork bridge** exposes `bambu_network_bridge_status`,
|
|
|
206
206
|
- Set print speed mode (`silent`/`standard`/`sport`/`ludicrous`), clear HMS/print errors, trigger AMS RFID re-read, and control H2/P2 airduct mode (`cooling`/`heating`) via MQTT
|
|
207
207
|
- **Start/stop AMS filament drying** (`set_ams_drying`) on heated AMS units (AMS Pro / AMS-HT). Sends `print.ams_control` MQTT command.
|
|
208
208
|
- Set nozzle and bed temperature via G-code dispatch over MQTT
|
|
209
|
-
- Confirm print starts and positive manual heating through a human preflight prompt.
|
|
209
|
+
- Confirm print starts and positive manual heating through a human preflight prompt. Hardware-error clearing requires explicit human acknowledgment; see [hardware safety and headless configuration](https://github.com/DMontgomery40/bambu-printer-mcp/blob/main/docs/SLICING.md).
|
|
210
210
|
- Set fan speed (part, auxiliary, chamber) and chamber light mode (on/off/flashing) via MQTT
|
|
211
211
|
- Read HMS (Health Management System) diagnostics as an MCP resource at `printer://{host}/hms` — read-only error summary from the printer, with automatic settle retry
|
|
212
212
|
- Start G-code files already stored on the printer
|
package/dist/index.js
CHANGED
|
@@ -946,7 +946,7 @@ class BambuPrinterMCPServer {
|
|
|
946
946
|
throw new Error(`No hardware confirmation within ${describeDuration(this.confirmationTimeoutMs)}; nothing was sent to the printer. Retry when someone can check the printer, or raise BAMBU_CONFIRMATION_TIMEOUT_MS.`);
|
|
947
947
|
}
|
|
948
948
|
if (isElicitationUnsupported(error)) {
|
|
949
|
-
throw new Error("Human hardware confirmation requires an MCP client with elicitation support. For deliberately headless operation, BAMBU_REQUIRE_CONFIRMATION=0 disables ordinary print/heat prompts;
|
|
949
|
+
throw new Error("Human hardware confirmation requires an MCP client with elicitation support. For deliberately headless operation, BAMBU_REQUIRE_CONFIRMATION=0 disables ordinary print/heat prompts; hardware-error confirmation still requires elicitation.");
|
|
950
950
|
}
|
|
951
951
|
throw new Error(`Human hardware confirmation failed: ${error?.message ?? error}. Nothing was sent to the printer.`);
|
|
952
952
|
}
|
|
@@ -1229,10 +1229,10 @@ class BambuPrinterMCPServer {
|
|
|
1229
1229
|
const requirements = { ...inspection, amsMapping: mapping, useAMS };
|
|
1230
1230
|
const initialStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1231
1231
|
validatePrinterState(initialStatus, requirements);
|
|
1232
|
-
const
|
|
1232
|
+
const preflight = await this.bambu.confirmPrintPreflight(devId, initialStatus, inspection);
|
|
1233
1233
|
const confirmedStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1234
1234
|
validatePrinterState(confirmedStatus, requirements);
|
|
1235
|
-
this.bambu.
|
|
1235
|
+
this.bambu.assertPrintPreflight(confirmedStatus, preflight);
|
|
1236
1236
|
const amsMapping = stringifyBridgeJson(mapping?.map(value => bridgeAmsMappingValue(value, isDualNozzleModel(printModel))));
|
|
1237
1237
|
const remoteFileName = uniquePrintName(threeMFPath);
|
|
1238
1238
|
const checkedName = remoteFileName.replace(/(?:\.gcode)?\.3mf$/i, "");
|
|
@@ -1310,7 +1310,7 @@ class BambuPrinterMCPServer {
|
|
|
1310
1310
|
assertActive();
|
|
1311
1311
|
const dispatchStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1312
1312
|
validatePrinterState(dispatchStatus, requirements);
|
|
1313
|
-
this.bambu.
|
|
1313
|
+
this.bambu.assertPrintPreflight(dispatchStatus, preflight);
|
|
1314
1314
|
if (externalStorage && externalStorageState(dispatchStatus.raw) !== "normal") {
|
|
1315
1315
|
throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
|
|
1316
1316
|
}
|
|
@@ -1328,7 +1328,7 @@ class BambuPrinterMCPServer {
|
|
|
1328
1328
|
assertActive();
|
|
1329
1329
|
const dispatchStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1330
1330
|
validatePrinterState(dispatchStatus, requirements);
|
|
1331
|
-
this.bambu.
|
|
1331
|
+
this.bambu.assertPrintPreflight(dispatchStatus, preflight);
|
|
1332
1332
|
},
|
|
1333
1333
|
assertDispatchAllowed: method => { if (method === bridgeMethod)
|
|
1334
1334
|
assertActive(); },
|
package/dist/printers/bambu.d.ts
CHANGED
|
@@ -46,13 +46,12 @@ export declare class BambuImplementation {
|
|
|
46
46
|
confirmHardwareAction(message: string, physicalCheck?: boolean): Promise<void>;
|
|
47
47
|
private finishedJobIdentity;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* situation the human confirmed has changed.
|
|
49
|
+
* Record the current job and notices during preflight so a changed printer state
|
|
50
|
+
* is detected before dispatch.
|
|
52
51
|
*/
|
|
53
52
|
confirmPrintPreflight(serial: string, status: any, inspection: Awaited<ReturnType<typeof inspectPrintFile>>): Promise<PrintPreflight>;
|
|
54
53
|
/** Stop a print whose confirmed situation changed: a newly finished job, or a hidden HMS notice the preflight did not name. */
|
|
55
|
-
|
|
54
|
+
assertPrintPreflight(status: any, preflight: PrintPreflight): void;
|
|
56
55
|
private getPrinter;
|
|
57
56
|
/** Internal handoff from a successful inspected transport; never exposed as an MCP tool. */
|
|
58
57
|
recordCheckedJob(host: string, serial: string, remotePath: string, requirements: PrinterStateRequirements): void;
|
package/dist/printers/bambu.js
CHANGED
|
@@ -386,7 +386,7 @@ class BambuClientStore {
|
|
|
386
386
|
this.initialReportResolvers.clear();
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
/**
|
|
389
|
+
/** The preflight state, checked again before dispatch. */
|
|
390
390
|
function printJobIdentity(raw) {
|
|
391
391
|
return JSON.stringify([raw.gcode_file, raw.subtask_name, raw.task_id, raw.subtask_id, raw.job_id]);
|
|
392
392
|
}
|
|
@@ -448,9 +448,8 @@ export class BambuImplementation {
|
|
|
448
448
|
: undefined;
|
|
449
449
|
}
|
|
450
450
|
/**
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
* situation the human confirmed has changed.
|
|
451
|
+
* Record the current job and notices during preflight so a changed printer state
|
|
452
|
+
* is detected before dispatch.
|
|
454
453
|
*/
|
|
455
454
|
async confirmPrintPreflight(serial, status, inspection) {
|
|
456
455
|
const finishedJob = this.finishedJobIdentity(status);
|
|
@@ -459,25 +458,21 @@ export class BambuImplementation {
|
|
|
459
458
|
const unchipped = unchippedNozzles(status?.raw);
|
|
460
459
|
await this.confirmHardwareAction(`Start a checked print on ${inspection.model.toUpperCase()} (${serial})? Nozzles: ${inspection.nozzleDiameters.join(", ")} mm. ` +
|
|
461
460
|
`Materials: ${inspection.materials.join(", ")}. Peak targets: nozzle ${inspection.maxNozzleTemperature}°C, bed ${inspection.maxBedTemperature}°C, chamber ${inspection.maxChamberTemperature}°C. ` +
|
|
462
|
-
`File SHA-256: ${inspection.sha256}. Confirm the physical spool labels
|
|
463
|
-
(finishedJob !== undefined ?
|
|
464
|
-
? (isFinishedP1SJob(status.raw, inspection.model)
|
|
465
|
-
? " The previous P1S job ended in FAILED and the printer now reports idle with no print or HMS errors. Remove the previous part and every detached part, support and strand from the plate and nozzle before confirming. No error-reset command is sent."
|
|
466
|
-
: " The previous X2D task was canceled (0300400C): remove every detached part, support and strand from the plate and nozzle before confirming. FAILED is the previous job's terminal state; no error-reset command is sent.")
|
|
467
|
-
: " The printer reports FINISH: remove the previous part and debris before confirming.") : "") +
|
|
461
|
+
`File SHA-256: ${inspection.sha256}. Confirm the physical spool labels.` +
|
|
462
|
+
(status.raw.gcode_state === "FAILED" && finishedJob !== undefined ? " The previous job reports FAILED; the current printer report meets the checked idle and error requirements. No error-reset command is sent." : "") +
|
|
468
463
|
(cleared ? ` Previously cleared hardware codes: ${cleared.map(describeHmsKey).join(", ")}. Confirm their physical causes have been resolved.` : "") +
|
|
469
464
|
(notices.length ? ` The printer also reports ${notices.join(", ")}, which Bambu lists for this model without text and never shows as a fault; ` +
|
|
470
465
|
`${notices.length === 1 ? "it does" : "they do"} not block printing.` : "") +
|
|
471
466
|
(unchipped.length ? ` Printer ${unchipped.length === 1 ? `nozzle ${unchipped[0]} reports` : `nozzles ${unchipped.join(" and ")} report`} no identity chip, ` +
|
|
472
|
-
`so ${unchipped.length === 1 ? "its" : "their"} diameter and type are the printer's configured settings; confirm they match the installed ${unchipped.length === 1 ? "hotend" : "hotends"}.` : ""),
|
|
467
|
+
`so ${unchipped.length === 1 ? "its" : "their"} diameter and type are the printer's configured settings; confirm they match the installed ${unchipped.length === 1 ? "hotend" : "hotends"}.` : ""), !!cleared);
|
|
473
468
|
return { finishedJob, serial, model: inspection.model, notices };
|
|
474
469
|
}
|
|
475
470
|
/** Stop a print whose confirmed situation changed: a newly finished job, or a hidden HMS notice the preflight did not name. */
|
|
476
|
-
|
|
471
|
+
assertPrintPreflight(status, preflight) {
|
|
477
472
|
const current = this.finishedJobIdentity(status);
|
|
478
473
|
if ((preflight.finishedJob !== undefined && printJobIdentity(status.raw) !== preflight.finishedJob)
|
|
479
474
|
|| (current !== undefined && preflight.finishedJob === undefined)) {
|
|
480
|
-
throw new Error("Printer
|
|
475
|
+
throw new Error("Printer job changed during preflight. Review the current printer status and retry.");
|
|
481
476
|
}
|
|
482
477
|
// An X2D raises its hidden camera notice about 15 seconds after boot, so it
|
|
483
478
|
// can appear after the human confirmed. Never pass a notice nobody was told about.
|
|
@@ -762,13 +757,13 @@ export class BambuImplementation {
|
|
|
762
757
|
requirements = this.validateLoadedGcodeState(initialStatus, inspection);
|
|
763
758
|
else
|
|
764
759
|
validatePrinterState(initialStatus, requirements);
|
|
765
|
-
const
|
|
760
|
+
const preflight = await this.confirmPrintPreflight(serial, initialStatus, inspection);
|
|
766
761
|
const confirmedStatus = await this.getSafetyStatus(host, serial, token);
|
|
767
762
|
if (legacyContainer)
|
|
768
763
|
requirements = this.validateLoadedGcodeState(confirmedStatus, inspection);
|
|
769
764
|
else
|
|
770
765
|
validatePrinterState(confirmedStatus, requirements);
|
|
771
|
-
this.
|
|
766
|
+
this.assertPrintPreflight(confirmedStatus, preflight);
|
|
772
767
|
assertActive();
|
|
773
768
|
await this.ftpUpload(host, token, options.filePath, remoteUploadPath);
|
|
774
769
|
// Uploads can be long. Recheck current state before the command is dispatched.
|
|
@@ -777,7 +772,7 @@ export class BambuImplementation {
|
|
|
777
772
|
requirements = this.validateLoadedGcodeState(dispatchStatus, inspection);
|
|
778
773
|
else
|
|
779
774
|
validatePrinterState(dispatchStatus, requirements);
|
|
780
|
-
this.
|
|
775
|
+
this.assertPrintPreflight(dispatchStatus, preflight);
|
|
781
776
|
const printer = await this.getPrinter(host, serial, token);
|
|
782
777
|
assertActive();
|
|
783
778
|
if (legacyContainer) {
|
|
@@ -1346,16 +1341,16 @@ export class BambuImplementation {
|
|
|
1346
1341
|
throw new Error("Raw G-code with AMS selection requires a .3mf project export with verified physical slot mappings.");
|
|
1347
1342
|
const initialStatus = await this.getSafetyStatus(host, serial, token);
|
|
1348
1343
|
let requirements = this.validateLoadedGcodeState(initialStatus, inspection);
|
|
1349
|
-
const
|
|
1344
|
+
const preflight = await this.confirmPrintPreflight(serial, initialStatus, inspection);
|
|
1350
1345
|
const confirmedStatus = await this.getSafetyStatus(host, serial, token);
|
|
1351
1346
|
requirements = this.validateLoadedGcodeState(confirmedStatus, inspection);
|
|
1352
|
-
this.
|
|
1347
|
+
this.assertPrintPreflight(confirmedStatus, preflight);
|
|
1353
1348
|
assertActive();
|
|
1354
1349
|
const remotePath = path.posix.join(path.posix.dirname(filename), uniquePrintName(filename));
|
|
1355
1350
|
await this.ftpUpload(host, token, filePath, `/${remotePath}`);
|
|
1356
1351
|
const dispatchStatus = await this.getSafetyStatus(host, serial, token);
|
|
1357
1352
|
requirements = this.validateLoadedGcodeState(dispatchStatus, inspection);
|
|
1358
|
-
this.
|
|
1353
|
+
this.assertPrintPreflight(dispatchStatus, preflight);
|
|
1359
1354
|
const printer = await this.getPrinter(host, serial, token);
|
|
1360
1355
|
assertActive();
|
|
1361
1356
|
const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
|
|
@@ -46,12 +46,12 @@ export interface ValidatedPrinterState {
|
|
|
46
46
|
* calls 0300400C "The task was canceled."
|
|
47
47
|
* Only this observed terminal condition qualifies, never an arbitrary failure.
|
|
48
48
|
* Callers still validate HMS, identity, hardware and material configuration,
|
|
49
|
-
* and print dispatch
|
|
49
|
+
* and print dispatch rechecks the identity of the observed job.
|
|
50
50
|
*/
|
|
51
51
|
export declare function isCancelledX2DJob(raw: Record<string, any>, model: string): boolean;
|
|
52
52
|
/** Bambu Studio 2.8.2.61 marks FAILED as finished. Limit P1S recovery to
|
|
53
53
|
* a named prior job explicitly reporting idle, no print error and no HMS.
|
|
54
|
-
*
|
|
54
|
+
* Dispatch rechecks the observed job identity. */
|
|
55
55
|
export declare function isFinishedP1SJob(raw: Record<string, any>, model: string): boolean;
|
|
56
56
|
/** Nozzles whose reported diameter and type are configured settings rather than chip readings. */
|
|
57
57
|
export declare function unchippedNozzles(raw: unknown): number[];
|
|
@@ -123,7 +123,7 @@ function finiteNumber(value) {
|
|
|
123
123
|
* calls 0300400C "The task was canceled."
|
|
124
124
|
* Only this observed terminal condition qualifies, never an arbitrary failure.
|
|
125
125
|
* Callers still validate HMS, identity, hardware and material configuration,
|
|
126
|
-
* and print dispatch
|
|
126
|
+
* and print dispatch rechecks the identity of the observed job.
|
|
127
127
|
*/
|
|
128
128
|
export function isCancelledX2DJob(raw, model) {
|
|
129
129
|
return normalizeModel(model) === "x2d" && raw.gcode_state === "FAILED" &&
|
|
@@ -132,7 +132,7 @@ export function isCancelledX2DJob(raw, model) {
|
|
|
132
132
|
}
|
|
133
133
|
/** Bambu Studio 2.8.2.61 marks FAILED as finished. Limit P1S recovery to
|
|
134
134
|
* a named prior job explicitly reporting idle, no print error and no HMS.
|
|
135
|
-
*
|
|
135
|
+
* Dispatch rechecks the observed job identity. */
|
|
136
136
|
export function isFinishedP1SJob(raw, model) {
|
|
137
137
|
return normalizeModel(model) === "p1s" && raw.gcode_state === "FAILED" && raw.print_type === "idle" &&
|
|
138
138
|
finiteNumber(raw.print_error) === 0 && Array.isArray(raw.hms) && raw.hms.length === 0 &&
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1243,7 +1243,7 @@ class BambuPrinterMCPServer {
|
|
|
1243
1243
|
throw new Error(`No hardware confirmation within ${describeDuration(this.confirmationTimeoutMs)}; nothing was sent to the printer. Retry when someone can check the printer, or raise BAMBU_CONFIRMATION_TIMEOUT_MS.`);
|
|
1244
1244
|
}
|
|
1245
1245
|
if (isElicitationUnsupported(error)) {
|
|
1246
|
-
throw new Error("Human hardware confirmation requires an MCP client with elicitation support. For deliberately headless operation, BAMBU_REQUIRE_CONFIRMATION=0 disables ordinary print/heat prompts;
|
|
1246
|
+
throw new Error("Human hardware confirmation requires an MCP client with elicitation support. For deliberately headless operation, BAMBU_REQUIRE_CONFIRMATION=0 disables ordinary print/heat prompts; hardware-error confirmation still requires elicitation.");
|
|
1247
1247
|
}
|
|
1248
1248
|
throw new Error(`Human hardware confirmation failed: ${error?.message ?? error}. Nothing was sent to the printer.`);
|
|
1249
1249
|
}
|
|
@@ -1642,10 +1642,10 @@ class BambuPrinterMCPServer {
|
|
|
1642
1642
|
const requirements = { ...inspection, amsMapping: mapping, useAMS };
|
|
1643
1643
|
const initialStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1644
1644
|
validatePrinterState(initialStatus, requirements);
|
|
1645
|
-
const
|
|
1645
|
+
const preflight = await this.bambu.confirmPrintPreflight(devId, initialStatus, inspection);
|
|
1646
1646
|
const confirmedStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1647
1647
|
validatePrinterState(confirmedStatus, requirements);
|
|
1648
|
-
this.bambu.
|
|
1648
|
+
this.bambu.assertPrintPreflight(confirmedStatus, preflight);
|
|
1649
1649
|
const amsMapping = stringifyBridgeJson(mapping?.map(value => bridgeAmsMappingValue(value, isDualNozzleModel(printModel))));
|
|
1650
1650
|
const remoteFileName = uniquePrintName(threeMFPath);
|
|
1651
1651
|
const checkedName = remoteFileName.replace(/(?:\.gcode)?\.3mf$/i, "");
|
|
@@ -1724,7 +1724,7 @@ class BambuPrinterMCPServer {
|
|
|
1724
1724
|
assertActive();
|
|
1725
1725
|
const dispatchStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1726
1726
|
validatePrinterState(dispatchStatus, requirements);
|
|
1727
|
-
this.bambu.
|
|
1727
|
+
this.bambu.assertPrintPreflight(dispatchStatus, preflight);
|
|
1728
1728
|
if (externalStorage && externalStorageState(dispatchStatus.raw) !== "normal") {
|
|
1729
1729
|
throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
|
|
1730
1730
|
}
|
|
@@ -1741,7 +1741,7 @@ class BambuPrinterMCPServer {
|
|
|
1741
1741
|
assertActive();
|
|
1742
1742
|
const dispatchStatus = await this.bambu.getSafetyStatus(devIp, devId, password || bambuToken);
|
|
1743
1743
|
validatePrinterState(dispatchStatus, requirements);
|
|
1744
|
-
this.bambu.
|
|
1744
|
+
this.bambu.assertPrintPreflight(dispatchStatus, preflight);
|
|
1745
1745
|
},
|
|
1746
1746
|
assertDispatchAllowed: method => { if (method === bridgeMethod) assertActive(); },
|
|
1747
1747
|
onDispatched: method => { if (method === bridgeMethod) retainForDispatchedUpload(); },
|
package/src/printers/bambu.ts
CHANGED
|
@@ -471,7 +471,7 @@ class BambuClientStore {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
/**
|
|
474
|
+
/** The preflight state, checked again before dispatch. */
|
|
475
475
|
function printJobIdentity(raw: Record<string, any>): string {
|
|
476
476
|
return JSON.stringify([raw.gcode_file, raw.subtask_name, raw.task_id, raw.subtask_id, raw.job_id]);
|
|
477
477
|
}
|
|
@@ -538,9 +538,8 @@ export class BambuImplementation {
|
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* situation the human confirmed has changed.
|
|
541
|
+
* Record the current job and notices during preflight so a changed printer state
|
|
542
|
+
* is detected before dispatch.
|
|
544
543
|
*/
|
|
545
544
|
async confirmPrintPreflight(serial: string, status: any, inspection: Awaited<ReturnType<typeof inspectPrintFile>>): Promise<PrintPreflight> {
|
|
546
545
|
const finishedJob = this.finishedJobIdentity(status);
|
|
@@ -550,28 +549,24 @@ export class BambuImplementation {
|
|
|
550
549
|
await this.confirmHardwareAction(
|
|
551
550
|
`Start a checked print on ${inspection.model.toUpperCase()} (${serial})? Nozzles: ${inspection.nozzleDiameters.join(", ")} mm. ` +
|
|
552
551
|
`Materials: ${inspection.materials.join(", ")}. Peak targets: nozzle ${inspection.maxNozzleTemperature}°C, bed ${inspection.maxBedTemperature}°C, chamber ${inspection.maxChamberTemperature}°C. ` +
|
|
553
|
-
`File SHA-256: ${inspection.sha256}. Confirm the physical spool labels
|
|
554
|
-
(finishedJob !== undefined ?
|
|
555
|
-
? (isFinishedP1SJob(status.raw, inspection.model)
|
|
556
|
-
? " The previous P1S job ended in FAILED and the printer now reports idle with no print or HMS errors. Remove the previous part and every detached part, support and strand from the plate and nozzle before confirming. No error-reset command is sent."
|
|
557
|
-
: " The previous X2D task was canceled (0300400C): remove every detached part, support and strand from the plate and nozzle before confirming. FAILED is the previous job's terminal state; no error-reset command is sent.")
|
|
558
|
-
: " The printer reports FINISH: remove the previous part and debris before confirming.") : "") +
|
|
552
|
+
`File SHA-256: ${inspection.sha256}. Confirm the physical spool labels.` +
|
|
553
|
+
(status.raw.gcode_state === "FAILED" && finishedJob !== undefined ? " The previous job reports FAILED; the current printer report meets the checked idle and error requirements. No error-reset command is sent." : "") +
|
|
559
554
|
(cleared ? ` Previously cleared hardware codes: ${cleared.map(describeHmsKey).join(", ")}. Confirm their physical causes have been resolved.` : "") +
|
|
560
555
|
(notices.length ? ` The printer also reports ${notices.join(", ")}, which Bambu lists for this model without text and never shows as a fault; ` +
|
|
561
556
|
`${notices.length === 1 ? "it does" : "they do"} not block printing.` : "") +
|
|
562
557
|
(unchipped.length ? ` Printer ${unchipped.length === 1 ? `nozzle ${unchipped[0]} reports` : `nozzles ${unchipped.join(" and ")} report`} no identity chip, ` +
|
|
563
558
|
`so ${unchipped.length === 1 ? "its" : "their"} diameter and type are the printer's configured settings; confirm they match the installed ${unchipped.length === 1 ? "hotend" : "hotends"}.` : ""),
|
|
564
|
-
|
|
559
|
+
!!cleared
|
|
565
560
|
);
|
|
566
561
|
return { finishedJob, serial, model: inspection.model, notices };
|
|
567
562
|
}
|
|
568
563
|
|
|
569
564
|
/** Stop a print whose confirmed situation changed: a newly finished job, or a hidden HMS notice the preflight did not name. */
|
|
570
|
-
|
|
565
|
+
assertPrintPreflight(status: any, preflight: PrintPreflight): void {
|
|
571
566
|
const current = this.finishedJobIdentity(status);
|
|
572
567
|
if ((preflight.finishedJob !== undefined && printJobIdentity(status.raw) !== preflight.finishedJob)
|
|
573
568
|
|| (current !== undefined && preflight.finishedJob === undefined)) {
|
|
574
|
-
throw new Error("Printer
|
|
569
|
+
throw new Error("Printer job changed during preflight. Review the current printer status and retry.");
|
|
575
570
|
}
|
|
576
571
|
// An X2D raises its hidden camera notice about 15 seconds after boot, so it
|
|
577
572
|
// can appear after the human confirmed. Never pass a notice nobody was told about.
|
|
@@ -902,18 +897,18 @@ export class BambuImplementation {
|
|
|
902
897
|
const initialStatus = await this.getSafetyStatus(host, serial, token);
|
|
903
898
|
if (legacyContainer) requirements = this.validateLoadedGcodeState(initialStatus, inspection);
|
|
904
899
|
else validatePrinterState(initialStatus, requirements);
|
|
905
|
-
const
|
|
900
|
+
const preflight = await this.confirmPrintPreflight(serial, initialStatus, inspection);
|
|
906
901
|
const confirmedStatus = await this.getSafetyStatus(host, serial, token);
|
|
907
902
|
if (legacyContainer) requirements = this.validateLoadedGcodeState(confirmedStatus, inspection);
|
|
908
903
|
else validatePrinterState(confirmedStatus, requirements);
|
|
909
|
-
this.
|
|
904
|
+
this.assertPrintPreflight(confirmedStatus, preflight);
|
|
910
905
|
assertActive();
|
|
911
906
|
await this.ftpUpload(host, token, options.filePath, remoteUploadPath);
|
|
912
907
|
// Uploads can be long. Recheck current state before the command is dispatched.
|
|
913
908
|
const dispatchStatus = await this.getSafetyStatus(host, serial, token);
|
|
914
909
|
if (legacyContainer) requirements = this.validateLoadedGcodeState(dispatchStatus, inspection);
|
|
915
910
|
else validatePrinterState(dispatchStatus, requirements);
|
|
916
|
-
this.
|
|
911
|
+
this.assertPrintPreflight(dispatchStatus, preflight);
|
|
917
912
|
const printer = await this.getPrinter(host, serial, token);
|
|
918
913
|
assertActive();
|
|
919
914
|
if (legacyContainer) {
|
|
@@ -1543,16 +1538,16 @@ export class BambuImplementation {
|
|
|
1543
1538
|
if (inspection.selectsAms) throw new Error("Raw G-code with AMS selection requires a .3mf project export with verified physical slot mappings.");
|
|
1544
1539
|
const initialStatus = await this.getSafetyStatus(host, serial, token);
|
|
1545
1540
|
let requirements = this.validateLoadedGcodeState(initialStatus, inspection);
|
|
1546
|
-
const
|
|
1541
|
+
const preflight = await this.confirmPrintPreflight(serial, initialStatus, inspection);
|
|
1547
1542
|
const confirmedStatus = await this.getSafetyStatus(host, serial, token);
|
|
1548
1543
|
requirements = this.validateLoadedGcodeState(confirmedStatus, inspection);
|
|
1549
|
-
this.
|
|
1544
|
+
this.assertPrintPreflight(confirmedStatus, preflight);
|
|
1550
1545
|
assertActive();
|
|
1551
1546
|
const remotePath = path.posix.join(path.posix.dirname(filename), uniquePrintName(filename));
|
|
1552
1547
|
await this.ftpUpload(host, token, filePath, `/${remotePath}`);
|
|
1553
1548
|
const dispatchStatus = await this.getSafetyStatus(host, serial, token);
|
|
1554
1549
|
requirements = this.validateLoadedGcodeState(dispatchStatus, inspection);
|
|
1555
|
-
this.
|
|
1550
|
+
this.assertPrintPreflight(dispatchStatus, preflight);
|
|
1556
1551
|
const printer = await this.getPrinter(host, serial, token);
|
|
1557
1552
|
assertActive();
|
|
1558
1553
|
const watcher = this.watchDispatch(printer, host, serial, token, dispatchStatus, assertActive);
|
|
@@ -134,7 +134,7 @@ function finiteNumber(value: unknown): number | undefined {
|
|
|
134
134
|
* calls 0300400C "The task was canceled."
|
|
135
135
|
* Only this observed terminal condition qualifies, never an arbitrary failure.
|
|
136
136
|
* Callers still validate HMS, identity, hardware and material configuration,
|
|
137
|
-
* and print dispatch
|
|
137
|
+
* and print dispatch rechecks the identity of the observed job.
|
|
138
138
|
*/
|
|
139
139
|
export function isCancelledX2DJob(raw: Record<string, any>, model: string): boolean {
|
|
140
140
|
return normalizeModel(model) === "x2d" && raw.gcode_state === "FAILED" &&
|
|
@@ -143,7 +143,7 @@ export function isCancelledX2DJob(raw: Record<string, any>, model: string): bool
|
|
|
143
143
|
}
|
|
144
144
|
/** Bambu Studio 2.8.2.61 marks FAILED as finished. Limit P1S recovery to
|
|
145
145
|
* a named prior job explicitly reporting idle, no print error and no HMS.
|
|
146
|
-
*
|
|
146
|
+
* Dispatch rechecks the observed job identity. */
|
|
147
147
|
export function isFinishedP1SJob(raw: Record<string, any>, model: string): boolean {
|
|
148
148
|
return normalizeModel(model) === "p1s" && raw.gcode_state === "FAILED" && raw.print_type === "idle" &&
|
|
149
149
|
finiteNumber(raw.print_error) === 0 && Array.isArray(raw.hms) && raw.hms.length === 0 &&
|