bambu-printer-mcp 1.1.47 → 1.1.49
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 +117 -3
- package/dist/blender-mcp-bridge.d.ts +15 -0
- package/dist/blender-mcp-bridge.js +21 -3
- package/dist/counterpart/info.d.ts +10 -0
- package/dist/counterpart/info.js +34 -0
- package/dist/counterpart/make-3mf.d.ts +16 -0
- package/dist/counterpart/make-3mf.js +219 -0
- package/dist/counterpart/progress.d.ts +28 -0
- package/dist/counterpart/progress.js +254 -0
- package/dist/counterpart/schemas.d.ts +322 -0
- package/dist/counterpart/schemas.js +124 -0
- package/dist/fusion-mcp-bridge.d.ts +182 -0
- package/dist/fusion-mcp-bridge.js +557 -0
- package/dist/index.js +192 -12
- package/dist/printers/bambu-stages.d.ts +7 -0
- package/dist/printers/bambu-stages.js +89 -0
- package/dist/printers/bambu.d.ts +76 -4
- package/dist/printers/bambu.js +298 -38
- package/dist/printers/camera-models.d.ts +7 -0
- package/dist/printers/camera-models.js +18 -0
- package/dist/safety/hms-messages.d.ts +42 -0
- package/dist/safety/hms-messages.js +6194 -0
- package/dist/safety/printer-state.d.ts +18 -0
- package/dist/safety/printer-state.js +3 -3
- package/dist/slicer/process-overrides.d.ts +12 -0
- package/dist/slicer/process-overrides.js +33 -0
- package/dist/slicer/remote-slicer.js +2 -0
- package/dist/stl/stl-manipulator.d.ts +2 -0
- package/dist/stl/stl-manipulator.js +19 -0
- package/package.json +1 -1
- package/src/blender-mcp-bridge.ts +22 -3
- package/src/counterpart/info.ts +36 -0
- package/src/counterpart/make-3mf.ts +220 -0
- package/src/counterpart/progress.ts +254 -0
- package/src/counterpart/schemas.ts +154 -0
- package/src/fusion-mcp-bridge.ts +545 -0
- package/src/index.ts +199 -12
- package/src/printers/bambu-stages.ts +90 -0
- package/src/printers/bambu.ts +316 -38
- package/src/printers/camera-models.ts +18 -0
- package/src/safety/hms-messages.ts +6198 -0
- package/src/safety/printer-state.ts +4 -4
- package/src/slicer/process-overrides.ts +42 -0
- package/src/slicer/remote-slicer.ts +2 -0
- package/src/stl/stl-manipulator.ts +22 -0
|
@@ -121,7 +121,7 @@ interface ReportedNozzle { index: number; diameter: number; type?: string; flow?
|
|
|
121
121
|
interface ReportedFilament { position: number; material: string; trayIndex: number; nozzleMin?: number; nozzleMax?: number }
|
|
122
122
|
export interface ValidatedPrinterState { model: string; reportedNozzles: ReportedNozzle[]; filaments: ReportedFilament[] }
|
|
123
123
|
|
|
124
|
-
function finiteNumber(value: unknown): number | undefined {
|
|
124
|
+
export function finiteNumber(value: unknown): number | undefined {
|
|
125
125
|
if (typeof value !== "number" && (typeof value !== "string" || !value.trim())) return undefined;
|
|
126
126
|
const number = Number(value);
|
|
127
127
|
return Number.isFinite(number) ? number : undefined;
|
|
@@ -251,8 +251,8 @@ function reportedNozzles(raw: Record<string,any>): ReportedNozzle[] {
|
|
|
251
251
|
|
|
252
252
|
const hiddenHmsSets = new Map(Object.entries(HIDDEN_HMS).map(([prefix, codes]) => [prefix, new Set(codes)]));
|
|
253
253
|
|
|
254
|
-
type HmsEntry = { attr: number; code: number; severity: number; hex: string };
|
|
255
|
-
function hmsCode(entry: any): HmsEntry | undefined {
|
|
254
|
+
export type HmsEntry = { attr: number; code: number; severity: number; hex: string };
|
|
255
|
+
export function hmsCode(entry: any): HmsEntry | undefined {
|
|
256
256
|
const code = finiteNumber(entry?.code);
|
|
257
257
|
const attr = finiteNumber(entry?.attr);
|
|
258
258
|
const valid = (value: number | undefined): value is number => value !== undefined && Number.isInteger(value) && value >= 0 && value <= 0xffffffff;
|
|
@@ -286,7 +286,7 @@ export function describeHmsKey(key: string): string {
|
|
|
286
286
|
* without a serial must not let a misconfigured serial pick another model's
|
|
287
287
|
* table. Fatal, invalid-level and unlisted entries never qualify.
|
|
288
288
|
*/
|
|
289
|
-
function isHiddenNotice(serial: string, model: string, entry: HmsEntry): boolean {
|
|
289
|
+
export function isHiddenNotice(serial: string, model: string, entry: HmsEntry): boolean {
|
|
290
290
|
if (entry.severity !== 2 && entry.severity !== 3) return false;
|
|
291
291
|
const prefix = serial.trim().toUpperCase().slice(0, 3);
|
|
292
292
|
const normalized = normalizeModel(model);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* slice_stl's layer_height, wall_loops and sparse_infill_density arguments
|
|
3
|
+
* (PRD §8.4). They are written over the process preset the slicer already
|
|
4
|
+
* resolved, using Bambu Studio/Orca keys and their string forms ("0.2", "2",
|
|
5
|
+
* "15%"), so the machine preset and every other process value stay as resolved.
|
|
6
|
+
*/
|
|
7
|
+
export type ProcessOverrides = Partial<Record<"layer_height" | "wall_loops" | "sparse_infill_density", string>>;
|
|
8
|
+
|
|
9
|
+
export const PROCESS_OVERRIDE_KEYS = ["layer_height", "wall_loops", "sparse_infill_density"] as const;
|
|
10
|
+
|
|
11
|
+
/** Validate the tool arguments; undefined when none are given. */
|
|
12
|
+
export function parseProcessOverrides(args: Record<string, unknown> | undefined, nozzleDiameter: number): ProcessOverrides | undefined {
|
|
13
|
+
const overrides: ProcessOverrides = {};
|
|
14
|
+
const layerHeight = args?.layer_height;
|
|
15
|
+
if (layerHeight !== undefined) {
|
|
16
|
+
if (typeof layerHeight !== "number" || !Number.isFinite(layerHeight) || layerHeight <= 0 ||
|
|
17
|
+
(Number.isFinite(nozzleDiameter) && nozzleDiameter > 0 && layerHeight > nozzleDiameter)) {
|
|
18
|
+
throw new Error("layer_height must be a positive number of millimetres, no larger than the nozzle diameter.");
|
|
19
|
+
}
|
|
20
|
+
overrides.layer_height = String(Number(layerHeight.toFixed(4)));
|
|
21
|
+
}
|
|
22
|
+
const wallLoops = args?.wall_loops;
|
|
23
|
+
if (wallLoops !== undefined) {
|
|
24
|
+
// Bambu Studio's wall_loops option ranges from 0 to 1000.
|
|
25
|
+
if (typeof wallLoops !== "number" || !Number.isInteger(wallLoops) || wallLoops < 0 || wallLoops > 1000) {
|
|
26
|
+
throw new Error("wall_loops must be an integer from 0 to 1000.");
|
|
27
|
+
}
|
|
28
|
+
overrides.wall_loops = String(wallLoops);
|
|
29
|
+
}
|
|
30
|
+
const density = args?.sparse_infill_density;
|
|
31
|
+
if (density !== undefined) {
|
|
32
|
+
const match = typeof density === "string" ? /^\s*(\d+(?:\.\d+)?)\s*%\s*$/.exec(density) : null;
|
|
33
|
+
if (!match || Number(match[1]) > 100) throw new Error('sparse_infill_density must be a percentage from 0% to 100%, such as "15%".');
|
|
34
|
+
overrides.sparse_infill_density = `${Number(match[1])}%`;
|
|
35
|
+
}
|
|
36
|
+
return Object.keys(overrides).length ? overrides : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The process profile with the overrides written over its values. */
|
|
40
|
+
export function applyProcessOverrides(profile: Record<string, unknown>, overrides: ProcessOverrides): Record<string, unknown> {
|
|
41
|
+
return { ...profile, ...overrides };
|
|
42
|
+
}
|
|
@@ -10,6 +10,8 @@ const MAX_BYTES = 100_000_000;
|
|
|
10
10
|
const SUPPORTED_OPTIONS = new Set([
|
|
11
11
|
'arrange', 'orient', 'loadFilaments', 'filamentColours', 'bedType',
|
|
12
12
|
'nozzleType', 'nozzleVolumeType', 'slicePlate',
|
|
13
|
+
// Written into the uploaded process preset before the request, not sent as API options.
|
|
14
|
+
'processOverrides',
|
|
13
15
|
]);
|
|
14
16
|
|
|
15
17
|
function configuration(): { base: string; headers: Record<string, string>; mode: string; timeout: number } {
|
|
@@ -10,6 +10,7 @@ import { EventEmitter } from 'events';
|
|
|
10
10
|
import * as crypto from 'crypto';
|
|
11
11
|
import { execFile } from 'child_process';
|
|
12
12
|
import { flattenForCli, detectProfilesRoot, resolveBblMachineProfile } from '../slicer/profile-flatten.js';
|
|
13
|
+
import { applyProcessOverrides, type ProcessOverrides } from '../slicer/process-overrides.js';
|
|
13
14
|
import { profileJsonFiles } from '../slicer/profile-files.js';
|
|
14
15
|
import { materializeOrcaProfilesRoot, stageOrcaCliProfiles } from '../slicer/orca-profile-cache.js';
|
|
15
16
|
import { sliceWithOrcaApi, validateRemoteSliceOptions } from '../slicer/remote-slicer.js';
|
|
@@ -182,6 +183,7 @@ export interface BambuSliceOptions {
|
|
|
182
183
|
minSave?: boolean; // --min-save: smaller output 3MF
|
|
183
184
|
skipModifiedGcodes?: boolean;// --skip-modified-gcodes: ignore stale custom gcodes
|
|
184
185
|
slicePlate?: number; // --slice N: which plate (default: 0 = all)
|
|
186
|
+
processOverrides?: ProcessOverrides; // layer_height / wall_loops / sparse_infill_density over the resolved process preset
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
interface BambuSettingsBundle {
|
|
@@ -1696,6 +1698,10 @@ export class STLManipulator extends EventEmitter {
|
|
|
1696
1698
|
const outputFileName = path.basename(stlFilePath, '.stl') + '.gcode';
|
|
1697
1699
|
let outputFilePath = path.join(this.tempDir, outputFileName);
|
|
1698
1700
|
|
|
1701
|
+
if (bambuOptions?.processOverrides && !['bambustudio', 'orcaslicer', 'orcaslicer-bambulab', 'orca-slicer-api'].includes(slicerType)) {
|
|
1702
|
+
throw new Error(`layer_height, wall_loops and sparse_infill_density need a Bambu-compatible slicer (bambustudio, orcaslicer, orcaslicer-bambulab or orca-slicer-api), not ${slicerType}.`);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1699
1705
|
let args: string[] = [];
|
|
1700
1706
|
let cliResult: CliResultSource | undefined;
|
|
1701
1707
|
const orcaTemporaryDirectories: string[] = [];
|
|
@@ -1795,6 +1801,22 @@ export class STLManipulator extends EventEmitter {
|
|
|
1795
1801
|
this.sanitizeProcessForOrca(this.readJsonFile(processPath), printerPreset)),
|
|
1796
1802
|
].join(';');
|
|
1797
1803
|
}
|
|
1804
|
+
// Print-sheet quality settings go over the fully resolved process
|
|
1805
|
+
// preset, after flattening and Orca normalization, so every
|
|
1806
|
+
// Bambu-compatible route (local CLI, Orca cache staging, remote API)
|
|
1807
|
+
// slices with them and the machine preset is untouched.
|
|
1808
|
+
if (bambuOptions?.processOverrides) {
|
|
1809
|
+
const [machinePath, processPath, ...rest] = settingsBundle.settingsArg?.split(';') ?? [];
|
|
1810
|
+
if (!machinePath || !processPath) {
|
|
1811
|
+
throw new Error('layer_height, wall_loops and sparse_infill_density need a resolved machine and process preset.');
|
|
1812
|
+
}
|
|
1813
|
+
settingsBundle.settingsArg = [
|
|
1814
|
+
machinePath,
|
|
1815
|
+
this.writeTempJson(outputBase, 'process_override',
|
|
1816
|
+
applyProcessOverrides(this.readJsonFile(processPath), bambuOptions.processOverrides)),
|
|
1817
|
+
...rest,
|
|
1818
|
+
].join(';');
|
|
1819
|
+
}
|
|
1798
1820
|
let cliBundle = this.isolateMachineSettings(settingsBundle);
|
|
1799
1821
|
let orcaExtraArgs: string[] = [];
|
|
1800
1822
|
if (!remote && profileSlicerType === 'orcaslicer' && profilesRoot !== selectedProfilesRoot) {
|