bambu-printer-mcp 1.1.61 → 1.1.63
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 +9 -1
- package/dist/counterpart/discovery.d.ts +85 -0
- package/dist/counterpart/discovery.js +119 -0
- package/dist/counterpart/filaments.d.ts +307 -0
- package/dist/counterpart/filaments.js +273 -0
- package/dist/counterpart/setup.d.ts +292 -0
- package/dist/counterpart/setup.js +91 -0
- package/dist/index.js +131 -1
- package/dist/safety/printer-state.d.ts +1 -0
- package/dist/safety/printer-state.js +1 -1
- package/dist/tool-annotations.js +3 -0
- package/package.json +1 -1
- package/src/counterpart/discovery.ts +111 -0
- package/src/counterpart/filaments.ts +297 -0
- package/src/counterpart/setup.ts +127 -0
- package/src/index.ts +123 -1
- package/src/safety/printer-state.ts +1 -1
- package/src/tool-annotations.ts +3 -0
package/README.md
CHANGED
|
@@ -1085,6 +1085,14 @@ If the project does not match those assumptions, the tool fails fast with a stru
|
|
|
1085
1085
|
- `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.
|
|
1086
1086
|
- `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.
|
|
1087
1087
|
- `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`.
|
|
1088
|
+
- **`counterpart_discover_printers`** listens for Bambu printers' own SSDP announcements on UDP 2021 for `duration_ms` (default 4000, 500–15000) and sends one M-SEARCH: `{contract, network, printers: [{kind: "bambu", source: "ssdp", name, host, serial, model?, firmware?}]}`. `model` is the `bambu_model` value the announced DevModel or the serial prefix names (none for the X1, which `bambu_model` doesn't take). An announcement counts only from a private IPv4 address that names itself as its `Location`. `network` is `unavailable` when another app (Bambu Studio) holds the port. It never connects to or authenticates with a printer.
|
|
1089
|
+
- **`counterpart_setup_fields`** says what this server needs to drive a printer, so a client can offer setup without printer tables of its own: `{contract, server, kinds: [{kind: "bambu", label, env, fields}], model?}`. Each field names its form role (`host`, `serial`, `model`, `secret`), the `.env` variable to write (`PRINTER_HOST`, `BAMBU_SERIAL`, `BAMBU_MODEL`, `BAMBU_TOKEN`) and its older `aliases`, which this server reads first (a client writing the variable removes them), a label and hint, and whether it is required. The model field lists the `bambu_model` choices with Bambu's names and `fromSerial`, the model each three-character serial prefix names. Pass `serial` to get that model as `model`. `slicer` reports the slicer this server would run (type, path, whether it is there, and the Bambu profiles folder) with the `SLICER_TYPE`, `SLICER_PATH` (`input: "path"`) and `BAMBU_PROFILES_ROOT` fields, each required only when what it defaults to is missing. It sends nothing to a printer and returns no secret.
|
|
1090
|
+
- **`counterpart_propose_filaments`** proposes which loaded AMS spool prints each of a model's colours, before slicing. Pass `filaments` (`index`, `name`, `colour` `#RRGGBB`, `material`), the `painted` slots no part names, `sliced: true` for an already-sliced file and, at print time, the person's `chosen` spools. It reads the live AMS once and returns:
|
|
1091
|
+
- `trays`: the spools to choose from, each with `label` (`A2`, as Bambu Studio labels trays), `name` (Bambu Studio's colour name and the product, "Sunflower Yellow PLA Basic", from the configured slicer's `filaments_color_codes.json`), `colour`, `material`, `filamentId`, `feed`, `sliceable` and, when one resolves, `profile` (the filament profile path `slice_stl` takes in `load_filaments`). An unsliced model lists only spools with a filament profile.
|
|
1092
|
+
- `proposal`: per filament, the nearest spool in OKLab colour with the asked-for material preferred, and a `verdict`: `same-colour` (within 0.08), `closest` (that colour isn't loaded; `note` says so, "White isn't loaded. Closest loaded: A2 Sunflower Yellow PLA Basic."), `no-colour` or `none`. A sliced file's material is a hard rule. One print feeds from one `feed`.
|
|
1093
|
+
- `mapping`: every filament slot, painted ones included, to its spool, when the proposal or the person's choice can print; `problems` (`code`, `message`, `index`) says why not, such as `spool-changed`, `sliced-material`, `mixed-feeds` or `material-not-loaded`.
|
|
1094
|
+
|
|
1095
|
+
`get_printer_filaments` trays carry the same `label` and person-readable `spool_name`.
|
|
1088
1096
|
- **`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.
|
|
1089
1097
|
|
|
1090
1098
|
`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.
|
|
@@ -1131,7 +1139,7 @@ Inspect the slicer settings embedded in a saved 3MF template or in an extracted
|
|
|
1131
1139
|
}
|
|
1132
1140
|
```
|
|
1133
1141
|
|
|
1134
|
-
This returns a compact summary of the high-signal settings such as printer preset, default print profile, filament profiles, layer height, infill density, shell counts, support mode, and bed type. It accepts either `source_path` or `template_name`. For 3MF inputs it also writes the extracted settings blob to a temp path so the result can be reused directly
|
|
1142
|
+
This returns a compact summary of the high-signal settings such as printer preset, default print profile, filament profiles, layer height, infill density, shell counts, support mode, and bed type. It accepts either `source_path` or `template_name`. For 3MF inputs it also writes the extracted settings blob to a temp path so the result can be reused directly, and returns `own_process`: true when the 3MF carries its own process (a designer's project), so `slice_stl` and `print_3mf`'s auto-slice slice it with that process unless the call names `slicer_profile`, `template_name` or `template_3mf_path`.
|
|
1135
1143
|
|
|
1136
1144
|
#### slice_with_template
|
|
1137
1145
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* counterpart_discover_printers (counterpart/1): Bambu printers on the local network, from their own SSDP
|
|
3
|
+
* announcements (NOTIFY on UDP 2021, and the answers to one M-SEARCH). Bounded and never failing: a port another app
|
|
4
|
+
* holds (Bambu Studio) is "unavailable", not "none found". Never fetches a URL, connects to or authenticates with a printer.
|
|
5
|
+
*/
|
|
6
|
+
import { type Socket } from "node:dgram";
|
|
7
|
+
import { COUNTERPART_CONTRACT, PRINTER_KINDS } from "./schemas.js";
|
|
8
|
+
export type FoundPrinter = {
|
|
9
|
+
kind: typeof PRINTER_KINDS[number];
|
|
10
|
+
source: "ssdp" | "bonjour";
|
|
11
|
+
name: string;
|
|
12
|
+
host: string;
|
|
13
|
+
port?: number;
|
|
14
|
+
serial?: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
firmware?: string;
|
|
17
|
+
};
|
|
18
|
+
export type Discovery = {
|
|
19
|
+
contract: typeof COUNTERPART_CONTRACT;
|
|
20
|
+
network: "complete" | "unavailable";
|
|
21
|
+
printers: FoundPrinter[];
|
|
22
|
+
};
|
|
23
|
+
/** This server's model value (bambu_model) for a serial number's first three characters, when it has one. */
|
|
24
|
+
export declare function modelFromSerial(serial: string | undefined): string | undefined;
|
|
25
|
+
/** This server's model value for a DevModel id Bambu Studio's printer definitions use (C12 is the P1S). */
|
|
26
|
+
export declare function modelFromDevModel(id: string | undefined): string | undefined;
|
|
27
|
+
export declare function privateIPv4(value: string): boolean;
|
|
28
|
+
/** One SSDP packet from a Bambu printer. The sender must be the printer itself (Location equals its address). */
|
|
29
|
+
export declare function parseBambuAdvert(packet: Buffer, address: string): FoundPrinter | undefined;
|
|
30
|
+
/** A send completes before the next interface: dgram resolves addresses asynchronously even for IP literals. */
|
|
31
|
+
export declare function sendDiscoveryProbes(socket: Pick<Socket, "addMembership" | "setMulticastInterface" | "setMulticastTTL" | "send">, addresses: string[], active: () => boolean): Promise<void>;
|
|
32
|
+
/** Listens on UDP 2021 for `durationMs` (bounded 500–15000 ms). */
|
|
33
|
+
export declare function discoverBambu(durationMs?: number): Promise<{
|
|
34
|
+
state: "complete" | "unavailable";
|
|
35
|
+
printers: FoundPrinter[];
|
|
36
|
+
}>;
|
|
37
|
+
export declare const DISCOVER_OUTPUT_SCHEMA: {
|
|
38
|
+
type: "object";
|
|
39
|
+
properties: {
|
|
40
|
+
contract: {
|
|
41
|
+
type: string;
|
|
42
|
+
const: string;
|
|
43
|
+
};
|
|
44
|
+
network: {
|
|
45
|
+
type: string;
|
|
46
|
+
enum: string[];
|
|
47
|
+
};
|
|
48
|
+
printers: {
|
|
49
|
+
type: string;
|
|
50
|
+
items: {
|
|
51
|
+
type: string;
|
|
52
|
+
properties: {
|
|
53
|
+
kind: {
|
|
54
|
+
type: string;
|
|
55
|
+
enum: ("bambu" | "octoprint" | "klipper" | "prusa" | "duet" | "repetier" | "creality")[];
|
|
56
|
+
};
|
|
57
|
+
source: {
|
|
58
|
+
type: string;
|
|
59
|
+
enum: string[];
|
|
60
|
+
};
|
|
61
|
+
name: {
|
|
62
|
+
type: string;
|
|
63
|
+
};
|
|
64
|
+
host: {
|
|
65
|
+
type: string;
|
|
66
|
+
};
|
|
67
|
+
port: {
|
|
68
|
+
type: string;
|
|
69
|
+
};
|
|
70
|
+
serial: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
model: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
firmware: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
required: string[];
|
|
85
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* counterpart_discover_printers (counterpart/1): Bambu printers on the local network, from their own SSDP
|
|
3
|
+
* announcements (NOTIFY on UDP 2021, and the answers to one M-SEARCH). Bounded and never failing: a port another app
|
|
4
|
+
* holds (Bambu Studio) is "unavailable", not "none found". Never fetches a URL, connects to or authenticates with a printer.
|
|
5
|
+
*/
|
|
6
|
+
import { createSocket } from "node:dgram";
|
|
7
|
+
import { isIPv4 } from "node:net";
|
|
8
|
+
import { networkInterfaces } from "node:os";
|
|
9
|
+
import { normalizeModel } from "../safety/limits.js";
|
|
10
|
+
import { MODEL_IDS, SERIAL_MODELS } from "../safety/printer-state.js";
|
|
11
|
+
import { COUNTERPART_CONTRACT, PRINTER_KINDS } from "./schemas.js";
|
|
12
|
+
/** This server's model value (bambu_model) for a serial number's first three characters, when it has one. */
|
|
13
|
+
export function modelFromSerial(serial) {
|
|
14
|
+
return serial ? normalizeModel(SERIAL_MODELS[serial.trim().slice(0, 3).toUpperCase()] ?? "") : undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* DevModel ids Bambu Studio's machine definitions (profiles/BBL/machine/*.json `model_id`) use that the safety identity
|
|
18
|
+
* table doesn't list, for naming a found printer only. Never identity evidence for a print.
|
|
19
|
+
*/
|
|
20
|
+
const ANNOUNCED_MODEL_IDS = { N1: "A1 Mini", N7: "P2S" };
|
|
21
|
+
/** This server's model value for a DevModel id Bambu Studio's printer definitions use (C12 is the P1S). */
|
|
22
|
+
export function modelFromDevModel(id) {
|
|
23
|
+
const key = id?.trim().toUpperCase();
|
|
24
|
+
return key ? normalizeModel(MODEL_IDS[key] ?? ANNOUNCED_MODEL_IDS[key] ?? "") : undefined;
|
|
25
|
+
}
|
|
26
|
+
export function privateIPv4(value) {
|
|
27
|
+
if (!isIPv4(value))
|
|
28
|
+
return false;
|
|
29
|
+
const [a, b] = value.split(".").map(Number);
|
|
30
|
+
return a === 10 || (a === 192 && b === 168) || (a === 172 && b >= 16 && b <= 31);
|
|
31
|
+
}
|
|
32
|
+
/** One SSDP packet from a Bambu printer. The sender must be the printer itself (Location equals its address). */
|
|
33
|
+
export function parseBambuAdvert(packet, address) {
|
|
34
|
+
if (packet.length > 8192 || !privateIPv4(address))
|
|
35
|
+
return undefined;
|
|
36
|
+
const lines = packet.toString("utf8").split("\r\n");
|
|
37
|
+
if (!["NOTIFY * HTTP/1.1", "HTTP/1.1 200 OK"].includes(lines.shift() ?? ""))
|
|
38
|
+
return undefined;
|
|
39
|
+
const headers = new Map();
|
|
40
|
+
for (const line of lines) {
|
|
41
|
+
if (!line)
|
|
42
|
+
continue;
|
|
43
|
+
const at = line.indexOf(":");
|
|
44
|
+
if (at < 1)
|
|
45
|
+
return undefined;
|
|
46
|
+
const key = line.slice(0, at).trim().toLowerCase(), value = line.slice(at + 1).trim();
|
|
47
|
+
if (headers.has(key) || /[\x00-\x1f\x7f]/.test(value))
|
|
48
|
+
return undefined;
|
|
49
|
+
headers.set(key, value);
|
|
50
|
+
}
|
|
51
|
+
if (headers.get("location") !== address)
|
|
52
|
+
return undefined;
|
|
53
|
+
const serial = headers.get("usn"), devModel = headers.get("devmodel.bambu.com");
|
|
54
|
+
if (!serial || !/^[A-Za-z0-9]{1,64}$/.test(serial) || !devModel || devModel.length > 64)
|
|
55
|
+
return undefined;
|
|
56
|
+
const firmware = headers.get("devversion.bambu.com");
|
|
57
|
+
const model = modelFromDevModel(devModel) ?? modelFromSerial(serial);
|
|
58
|
+
return { kind: "bambu", source: "ssdp", host: address, serial: serial.toUpperCase(), ...(model ? { model } : {}),
|
|
59
|
+
name: (headers.get("devname.bambu.com") || devModel).slice(0, 128),
|
|
60
|
+
...(firmware && /^\d{2}\.\d{2}\.\d{2}\.\d{2}$/.test(firmware) ? { firmware } : {}) };
|
|
61
|
+
}
|
|
62
|
+
/** A send completes before the next interface: dgram resolves addresses asynchronously even for IP literals. */
|
|
63
|
+
export async function sendDiscoveryProbes(socket, addresses, active) {
|
|
64
|
+
for (const address of addresses) {
|
|
65
|
+
if (!active())
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
socket.addMembership("239.255.255.250", address);
|
|
69
|
+
socket.setMulticastInterface(address);
|
|
70
|
+
socket.setMulticastTTL(1);
|
|
71
|
+
await new Promise((resolve, reject) => socket.send("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:2021\r\nMAN: \"ssdp:discover\"\r\nMX: 1\r\nST: urn:bambulab-com:device:3dprinter:1\r\n\r\n", 2021, "239.255.255.250", error => error ? reject(error) : resolve()));
|
|
72
|
+
}
|
|
73
|
+
catch { /* Other interfaces can still answer. */ }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Listens on UDP 2021 for `durationMs` (bounded 500–15000 ms). */
|
|
77
|
+
export function discoverBambu(durationMs = 4000) {
|
|
78
|
+
const ms = Number.isFinite(durationMs) ? Math.max(500, Math.min(15000, Math.round(durationMs))) : 4000;
|
|
79
|
+
return new Promise(resolve => {
|
|
80
|
+
const socket = createSocket({ type: "udp4", reuseAddr: true }), found = new Map();
|
|
81
|
+
let finished = false;
|
|
82
|
+
const finish = (state) => {
|
|
83
|
+
if (finished)
|
|
84
|
+
return;
|
|
85
|
+
finished = true;
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
try {
|
|
88
|
+
socket.close();
|
|
89
|
+
}
|
|
90
|
+
catch { /* not bound yet */ }
|
|
91
|
+
resolve({ state, printers: [...found.values()].sort((a, b) => (a.serial ?? "").localeCompare(b.serial ?? "")) });
|
|
92
|
+
};
|
|
93
|
+
const timer = setTimeout(() => finish("complete"), ms);
|
|
94
|
+
socket.on("error", () => finish("unavailable"));
|
|
95
|
+
socket.on("message", (data, peer) => { const value = parseBambuAdvert(data, peer.address); if (value && found.size < 64)
|
|
96
|
+
found.set(`${value.serial}@${value.host}`, value); });
|
|
97
|
+
try {
|
|
98
|
+
socket.bind(2021, "0.0.0.0", () => {
|
|
99
|
+
const interfaces = Object.values(networkInterfaces()).flat().filter(nic => nic && !nic.internal && nic.family === "IPv4" && privateIPv4(nic.address));
|
|
100
|
+
void sendDiscoveryProbes(socket, interfaces.map(nic => nic.address), () => !finished);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
finish("unavailable");
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export const DISCOVER_OUTPUT_SCHEMA = {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
contract: { type: "string", const: COUNTERPART_CONTRACT },
|
|
112
|
+
network: { type: "string", enum: ["complete", "unavailable"] },
|
|
113
|
+
printers: { type: "array", items: { type: "object", properties: {
|
|
114
|
+
kind: { type: "string", enum: [...PRINTER_KINDS] }, source: { type: "string", enum: ["ssdp", "bonjour"] }, name: { type: "string" },
|
|
115
|
+
host: { type: "string" }, port: { type: "integer" }, serial: { type: "string" }, model: { type: "string" }, firmware: { type: "string" },
|
|
116
|
+
}, required: ["kind", "source", "name", "host"] } },
|
|
117
|
+
},
|
|
118
|
+
required: ["contract", "network", "printers"],
|
|
119
|
+
};
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { COUNTERPART_CONTRACT } from "./schemas.js";
|
|
2
|
+
/** One loaded spool as a client shows it. `feed` groups the spools that can feed one print together. */
|
|
3
|
+
export type ProposalTray = {
|
|
4
|
+
slot: number;
|
|
5
|
+
label: string;
|
|
6
|
+
name: string;
|
|
7
|
+
colour: string;
|
|
8
|
+
material: string;
|
|
9
|
+
filamentId: string;
|
|
10
|
+
feed: string;
|
|
11
|
+
/** This server can slice with it (a filament profile is resolved for it). */
|
|
12
|
+
sliceable: boolean;
|
|
13
|
+
/** The resolved slicer filament profile (absolute path), the one slice_stl takes in load_filaments. */
|
|
14
|
+
profile?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ProposalFilament = {
|
|
17
|
+
index: number;
|
|
18
|
+
name?: string;
|
|
19
|
+
colour?: string;
|
|
20
|
+
material?: string;
|
|
21
|
+
};
|
|
22
|
+
/** A filament slot no part names (a painted region): it follows the chosen spools' feed. `prints` false: not on this plate. */
|
|
23
|
+
export type PaintedFilament = {
|
|
24
|
+
index: number;
|
|
25
|
+
colour?: string;
|
|
26
|
+
material?: string;
|
|
27
|
+
prints?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type ChosenSpool = {
|
|
30
|
+
index: number;
|
|
31
|
+
slot: number;
|
|
32
|
+
colour?: string;
|
|
33
|
+
material?: string;
|
|
34
|
+
filamentId?: string;
|
|
35
|
+
};
|
|
36
|
+
export type Verdict = "same-colour" | "closest" | "no-colour" | "none";
|
|
37
|
+
export type ProposalRow = {
|
|
38
|
+
index: number;
|
|
39
|
+
slot?: number;
|
|
40
|
+
verdict: Verdict;
|
|
41
|
+
distance?: number;
|
|
42
|
+
materialMismatch?: boolean;
|
|
43
|
+
/** What the person should know about this suggestion, in their words. */
|
|
44
|
+
note?: string;
|
|
45
|
+
};
|
|
46
|
+
export type ProposalProblem = {
|
|
47
|
+
code: string;
|
|
48
|
+
message: string;
|
|
49
|
+
index?: number;
|
|
50
|
+
};
|
|
51
|
+
export type FilamentProposal = {
|
|
52
|
+
contract: typeof COUNTERPART_CONTRACT;
|
|
53
|
+
/** The spools a person may choose from: every loaded one for a sliced file, the sliceable ones otherwise. */
|
|
54
|
+
trays: ProposalTray[];
|
|
55
|
+
proposal: ProposalRow[];
|
|
56
|
+
/** Every filament slot (parts and painted) to its spool, when the proposal or the person's choice is printable. */
|
|
57
|
+
mapping?: Array<{
|
|
58
|
+
index: number;
|
|
59
|
+
slot: number;
|
|
60
|
+
}>;
|
|
61
|
+
problems: ProposalProblem[];
|
|
62
|
+
};
|
|
63
|
+
/** A colour this close (OKLab) to the asked-for one is the same colour to a person. */
|
|
64
|
+
export declare const SAME_COLOUR = 0.08;
|
|
65
|
+
/** Perceptual distance between two `#RRGGBB` colours (0 identical, about 1 black to white). Alpha is ignored. */
|
|
66
|
+
export declare function colourDistance(a: string, b: string): number;
|
|
67
|
+
type Match = {
|
|
68
|
+
slot: number;
|
|
69
|
+
distance?: number;
|
|
70
|
+
materialMismatch?: boolean;
|
|
71
|
+
guessed?: boolean;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* One match per filament, in order; undefined where nothing can serve it. Several filaments of one colour may share a
|
|
75
|
+
* spool. With `requireMaterial` (an already-sliced file) only spools of the asked-for material qualify. Automatic matches
|
|
76
|
+
* never mix feeds: the first feed listed (the AMS) is preferred, another feed only when it alone serves every colour.
|
|
77
|
+
*/
|
|
78
|
+
export declare function matchColours(model: Array<{
|
|
79
|
+
colour?: string;
|
|
80
|
+
material?: string;
|
|
81
|
+
}>, trays: ProposalTray[], options?: {
|
|
82
|
+
requireMaterial?: boolean;
|
|
83
|
+
}): (Match | undefined)[];
|
|
84
|
+
/** The colour names Bambu Studio itself uses for its filaments (profiles/BBL/filament/filaments_color_codes.json). */
|
|
85
|
+
export type ColourNames = {
|
|
86
|
+
spool(filamentId: string, colour: string): string | undefined;
|
|
87
|
+
colour(colour: string): string | undefined;
|
|
88
|
+
};
|
|
89
|
+
export declare const NO_COLOUR_NAMES: ColourNames;
|
|
90
|
+
export declare function loadColourNames(filamentProfileDir: string | undefined): ColourNames;
|
|
91
|
+
/** Where a Bambu tray sits, as Bambu Studio labels it: AMS units A–D with trays 1–4, AMS HT units by letter. */
|
|
92
|
+
export declare function bambuTrayLabel(amsId: number, trayId: number): string;
|
|
93
|
+
/** A spool's name: its colour name (when Bambu names it) and product ("Sunflower Yellow PLA Basic"), else the product. */
|
|
94
|
+
export declare function spoolName(product: string, colourName: string | undefined): string;
|
|
95
|
+
export declare function proposeFilaments(input: {
|
|
96
|
+
trays: ProposalTray[];
|
|
97
|
+
filaments: ProposalFilament[];
|
|
98
|
+
painted?: PaintedFilament[];
|
|
99
|
+
chosen?: ChosenSpool[];
|
|
100
|
+
sliced?: boolean;
|
|
101
|
+
names?: ColourNames;
|
|
102
|
+
}): FilamentProposal;
|
|
103
|
+
export declare const PROPOSE_FILAMENTS_INPUT_PROPERTIES: {
|
|
104
|
+
readonly filaments: {
|
|
105
|
+
readonly type: "array";
|
|
106
|
+
readonly maxItems: 64;
|
|
107
|
+
readonly description: "The model's filaments a person sees, in project order: 1-based index, part name, the colour it belongs in and its material when known.";
|
|
108
|
+
readonly items: {
|
|
109
|
+
readonly type: "object";
|
|
110
|
+
readonly properties: {
|
|
111
|
+
readonly index: {
|
|
112
|
+
readonly type: "integer";
|
|
113
|
+
readonly minimum: 1;
|
|
114
|
+
readonly maximum: 64;
|
|
115
|
+
};
|
|
116
|
+
readonly name: {
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
readonly maxLength: 256;
|
|
119
|
+
};
|
|
120
|
+
readonly colour: {
|
|
121
|
+
type: string;
|
|
122
|
+
pattern: string;
|
|
123
|
+
};
|
|
124
|
+
readonly material: {
|
|
125
|
+
readonly type: "string";
|
|
126
|
+
readonly maxLength: 64;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
readonly required: readonly ["index"];
|
|
130
|
+
readonly additionalProperties: false;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
readonly painted: {
|
|
134
|
+
readonly type: "array";
|
|
135
|
+
readonly maxItems: 64;
|
|
136
|
+
readonly description: "Filament slots no part names (painted regions). Each follows the chosen spools' feed; prints false when the selected plate never uses it.";
|
|
137
|
+
readonly items: {
|
|
138
|
+
readonly type: "object";
|
|
139
|
+
readonly properties: {
|
|
140
|
+
readonly index: {
|
|
141
|
+
readonly type: "integer";
|
|
142
|
+
readonly minimum: 1;
|
|
143
|
+
readonly maximum: 64;
|
|
144
|
+
};
|
|
145
|
+
readonly colour: {
|
|
146
|
+
type: string;
|
|
147
|
+
pattern: string;
|
|
148
|
+
};
|
|
149
|
+
readonly material: {
|
|
150
|
+
readonly type: "string";
|
|
151
|
+
readonly maxLength: 64;
|
|
152
|
+
};
|
|
153
|
+
readonly prints: {
|
|
154
|
+
readonly type: "boolean";
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly required: readonly ["index"];
|
|
158
|
+
readonly additionalProperties: false;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
readonly chosen: {
|
|
162
|
+
readonly type: "array";
|
|
163
|
+
readonly maxItems: 64;
|
|
164
|
+
readonly description: "The person's spool for each filament, in the same order: checked against what is loaded now. Omit for the proposal alone.";
|
|
165
|
+
readonly items: {
|
|
166
|
+
readonly type: "object";
|
|
167
|
+
readonly properties: {
|
|
168
|
+
readonly index: {
|
|
169
|
+
readonly type: "integer";
|
|
170
|
+
readonly minimum: 1;
|
|
171
|
+
readonly maximum: 64;
|
|
172
|
+
};
|
|
173
|
+
readonly slot: {
|
|
174
|
+
readonly type: "integer";
|
|
175
|
+
readonly minimum: 0;
|
|
176
|
+
readonly maximum: 4095;
|
|
177
|
+
};
|
|
178
|
+
readonly colour: {
|
|
179
|
+
type: string;
|
|
180
|
+
pattern: string;
|
|
181
|
+
};
|
|
182
|
+
readonly material: {
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
readonly maxLength: 128;
|
|
185
|
+
};
|
|
186
|
+
readonly filamentId: {
|
|
187
|
+
readonly type: "string";
|
|
188
|
+
readonly maxLength: 128;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
readonly required: readonly ["index", "slot"];
|
|
192
|
+
readonly additionalProperties: false;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
readonly sliced: {
|
|
196
|
+
readonly type: "boolean";
|
|
197
|
+
readonly description: "The file is already sliced: its materials are fixed, so only spools of the same material qualify.";
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
export declare const PROPOSE_FILAMENTS_OUTPUT_SCHEMA: {
|
|
201
|
+
type: "object";
|
|
202
|
+
properties: {
|
|
203
|
+
contract: {
|
|
204
|
+
type: string;
|
|
205
|
+
const: string;
|
|
206
|
+
};
|
|
207
|
+
trays: {
|
|
208
|
+
type: string;
|
|
209
|
+
items: {
|
|
210
|
+
type: string;
|
|
211
|
+
properties: {
|
|
212
|
+
slot: {
|
|
213
|
+
type: string;
|
|
214
|
+
};
|
|
215
|
+
label: {
|
|
216
|
+
type: string;
|
|
217
|
+
};
|
|
218
|
+
name: {
|
|
219
|
+
type: string;
|
|
220
|
+
};
|
|
221
|
+
colour: {
|
|
222
|
+
type: string;
|
|
223
|
+
};
|
|
224
|
+
material: {
|
|
225
|
+
type: string;
|
|
226
|
+
};
|
|
227
|
+
filamentId: {
|
|
228
|
+
type: string;
|
|
229
|
+
};
|
|
230
|
+
feed: {
|
|
231
|
+
type: string;
|
|
232
|
+
};
|
|
233
|
+
sliceable: {
|
|
234
|
+
type: string;
|
|
235
|
+
};
|
|
236
|
+
profile: {
|
|
237
|
+
type: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
required: string[];
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
proposal: {
|
|
244
|
+
type: string;
|
|
245
|
+
items: {
|
|
246
|
+
type: string;
|
|
247
|
+
properties: {
|
|
248
|
+
index: {
|
|
249
|
+
type: string;
|
|
250
|
+
};
|
|
251
|
+
slot: {
|
|
252
|
+
type: string;
|
|
253
|
+
};
|
|
254
|
+
verdict: {
|
|
255
|
+
type: string;
|
|
256
|
+
enum: string[];
|
|
257
|
+
};
|
|
258
|
+
distance: {
|
|
259
|
+
type: string;
|
|
260
|
+
};
|
|
261
|
+
materialMismatch: {
|
|
262
|
+
type: string;
|
|
263
|
+
};
|
|
264
|
+
note: {
|
|
265
|
+
type: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
required: string[];
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
mapping: {
|
|
272
|
+
type: string;
|
|
273
|
+
items: {
|
|
274
|
+
type: string;
|
|
275
|
+
properties: {
|
|
276
|
+
index: {
|
|
277
|
+
type: string;
|
|
278
|
+
};
|
|
279
|
+
slot: {
|
|
280
|
+
type: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
required: string[];
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
problems: {
|
|
287
|
+
type: string;
|
|
288
|
+
items: {
|
|
289
|
+
type: string;
|
|
290
|
+
properties: {
|
|
291
|
+
code: {
|
|
292
|
+
type: string;
|
|
293
|
+
};
|
|
294
|
+
message: {
|
|
295
|
+
type: string;
|
|
296
|
+
};
|
|
297
|
+
index: {
|
|
298
|
+
type: string;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
required: string[];
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
required: string[];
|
|
306
|
+
};
|
|
307
|
+
export {};
|