bambu-printer-mcp 1.1.90 → 1.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CONTRIBUTORS.md +2 -0
  2. package/README.md +48 -3
  3. package/dist/bambu-native.js +1 -1
  4. package/dist/cad/contracts.js +16 -7
  5. package/dist/cad/examples.d.ts +2 -1
  6. package/dist/cad/examples.js +13 -10
  7. package/dist/cad/serial.d.ts +1 -1
  8. package/dist/cad/serial.js +4 -6
  9. package/dist/cad-engine.js +17 -12
  10. package/dist/counterpart/flight-record.d.ts +155 -0
  11. package/dist/counterpart/flight-record.js +831 -0
  12. package/dist/counterpart/flight-tools.d.ts +213 -0
  13. package/dist/counterpart/flight-tools.js +232 -0
  14. package/dist/counterpart/fresh-frame.d.ts +16 -0
  15. package/dist/counterpart/fresh-frame.js +26 -0
  16. package/dist/counterpart/make-3mf.js +1 -4
  17. package/dist/counterpart/physical-evidence.d.ts +70 -0
  18. package/dist/counterpart/physical-evidence.js +103 -0
  19. package/dist/counterpart/print-geometry.d.ts +13 -0
  20. package/dist/counterpart/print-geometry.js +181 -0
  21. package/dist/counterpart/remote.js +2 -0
  22. package/dist/counterpart/schemas.d.ts +32 -0
  23. package/dist/counterpart/schemas.js +2 -0
  24. package/dist/counterpart/visual-evidence.d.ts +38 -0
  25. package/dist/counterpart/visual-evidence.js +155 -0
  26. package/dist/index.js +63 -24
  27. package/dist/printers/bambu.d.ts +15 -2
  28. package/dist/printers/bambu.js +64 -12
  29. package/dist/safety/limits.d.ts +6 -0
  30. package/dist/safety/limits.js +8 -0
  31. package/dist/safety/print-file.js +2 -2
  32. package/dist/safety/print-preview.d.ts +2 -0
  33. package/dist/safety/print-preview.js +1 -1
  34. package/dist/safety/printer-state.d.ts +4 -0
  35. package/dist/safety/printer-state.js +14 -1
  36. package/dist/slicer/3mf-xml.d.ts +7 -0
  37. package/dist/slicer/3mf-xml.js +61 -0
  38. package/dist/stl/stl-manipulator.js +5 -2
  39. package/dist/studio-print-options.d.ts +9 -0
  40. package/dist/studio-print-options.js +34 -2
  41. package/dist/tool-annotations.js +2 -0
  42. package/package.json +2 -1
  43. package/src/bambu-native.ts +1 -1
  44. package/src/cad/contracts.ts +17 -7
  45. package/src/cad/examples/bag_clip.py +1 -0
  46. package/src/cad/examples/bistable_clicker.py +1 -0
  47. package/src/cad/examples/broom_grip.py +61 -0
  48. package/src/cad/examples/cable_clip.py +1 -0
  49. package/src/cad/examples/chainmail.py +1 -0
  50. package/src/cad/examples/desk_clamp_hook.py +91 -0
  51. package/src/cad/examples/desk_edge_cable_holder.py +55 -0
  52. package/src/cad/examples/drawer_divider.py +56 -0
  53. package/src/cad/examples/hinged_box.py +1 -0
  54. package/src/cad/examples/knurled_knob.py +1 -0
  55. package/src/cad/examples/loft_handle.py +1 -0
  56. package/src/cad/examples/organizer_tray.py +41 -0
  57. package/src/cad/examples/phone_stand.py +1 -0
  58. package/src/cad/examples/plant_pot.py +53 -0
  59. package/src/cad/examples/shelf_bracket.py +53 -0
  60. package/src/cad/examples/swept_hook.py +1 -0
  61. package/src/cad/examples/threaded_jar.py +1 -0
  62. package/src/cad/examples/trigger_capo.py +1 -0
  63. package/src/cad/examples/wall_hook.py +1 -0
  64. package/src/cad/examples.ts +13 -10
  65. package/src/cad/geometry.py +6 -0
  66. package/src/cad/serial.ts +4 -6
  67. package/src/cad-engine.ts +9 -3
  68. package/src/counterpart/flight-record.ts +984 -0
  69. package/src/counterpart/flight-tools.ts +282 -0
  70. package/src/counterpart/fresh-frame.ts +45 -0
  71. package/src/counterpart/make-3mf.ts +1 -5
  72. package/src/counterpart/physical-evidence.ts +185 -0
  73. package/src/counterpart/print-geometry.ts +192 -0
  74. package/src/counterpart/remote.ts +2 -0
  75. package/src/counterpart/schemas.ts +3 -0
  76. package/src/counterpart/visual-evidence.ts +212 -0
  77. package/src/index.ts +61 -21
  78. package/src/printers/bambu.ts +64 -10
  79. package/src/safety/limits.ts +8 -0
  80. package/src/safety/print-file.ts +2 -2
  81. package/src/safety/print-preview.ts +1 -1
  82. package/src/safety/printer-state.ts +13 -1
  83. package/src/slicer/3mf-xml.ts +52 -0
  84. package/src/stl/stl-manipulator.ts +4 -1
  85. package/src/studio-print-options.ts +33 -2
  86. package/src/tool-annotations.ts +2 -0
@@ -0,0 +1,13 @@
1
+ /** Expected geometry from the exact selected plate's sliced commands, never printer progress. */
2
+ export interface LayerGeometry {
3
+ layer: number;
4
+ zMm: number;
5
+ boundsMm?: [number, number, number, number];
6
+ }
7
+ export interface PrintGeometry {
8
+ heightMm?: number;
9
+ layers: LayerGeometry[];
10
+ }
11
+ export declare function geometryFromGcode(gcode: string): PrintGeometry;
12
+ /** Best-effort diagnostics only: an unreadable/oversize file cannot fail an already dispatched print. */
13
+ export declare function geometryFromFile(filePath: string): Promise<PrintGeometry | undefined>;
@@ -0,0 +1,181 @@
1
+ import { arcCentre } from "../safety/print-preview.js";
2
+ export function geometryFromGcode(gcode) {
3
+ const layers = [];
4
+ let z, layer;
5
+ let markerCount = 0, currentIndex = 0, previousMarkerZ;
6
+ let x = 0, y = 0, e = 0, relative = false, absoluteXY = true, positionUnknown = false, changingFilament = false, feature = "", executableEnded = false;
7
+ for (const line of gcode.split(/\r?\n/)) {
8
+ if (line === "; EXECUTABLE_BLOCK_END")
9
+ executableEnded = true;
10
+ if (executableEnded)
11
+ break;
12
+ const marker = /^;\s*(?:Z_HEIGHT:|Z:)\s*([\d.]+)/.exec(line);
13
+ if (marker) {
14
+ z = Number(marker[1]);
15
+ if (z !== previousMarkerZ)
16
+ markerCount++;
17
+ previousMarkerZ = z;
18
+ currentIndex = markerCount;
19
+ layer = undefined;
20
+ if (!Number.isFinite(z) || z <= 0 || z > 10000)
21
+ z = undefined;
22
+ }
23
+ const declared = /^;\s*layer num\/total_layer_count:\s*(\d+)\/\d+/.exec(line);
24
+ if (declared)
25
+ currentIndex = Number(declared[1]);
26
+ const featureMatch = /^;\s*(?:FEATURE|TYPE):\s*(.*)/i.exec(line);
27
+ if (featureMatch)
28
+ feature = featureMatch[1].trim().toLowerCase();
29
+ const command = line
30
+ .split(";")[0]
31
+ .trim()
32
+ .toUpperCase()
33
+ .replace(/^N\d+\s*/, "")
34
+ .replace(/\*\d+\s*$/, "");
35
+ const parsed = /^([GMT])(\d+(?:\.\d+)?)/.exec(command);
36
+ if (!parsed)
37
+ continue;
38
+ const word = parsed[1] + String(Number(parsed[2]));
39
+ const values = {};
40
+ for (const match of command
41
+ .slice(parsed[0].length)
42
+ .matchAll(/([A-Z])\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))/g)) {
43
+ if (values[match[1]] === undefined)
44
+ values[match[1]] = Number(match[2]);
45
+ }
46
+ if (word === "G90") {
47
+ absoluteXY = true;
48
+ continue;
49
+ }
50
+ if (word === "G91") {
51
+ absoluteXY = false;
52
+ continue;
53
+ }
54
+ if (word === "M83") {
55
+ relative = true;
56
+ continue;
57
+ }
58
+ if (word === "M82") {
59
+ relative = false;
60
+ continue;
61
+ }
62
+ // Do not invent bed-coordinate footprints for unsupported unit/work-coordinate changes.
63
+ if (word === "G20" ||
64
+ word === "G18" || word === "G19" || word === "G90.1" ||
65
+ word === "G53" ||
66
+ (word === "G92" && (values.X !== undefined || values.Y !== undefined)))
67
+ return { layers: [] };
68
+ if (word === "G28") {
69
+ positionUnknown = true;
70
+ continue;
71
+ }
72
+ if (Object.values(values).some((v) => !Number.isFinite(v)))
73
+ return { layers: [] };
74
+ if (word === "G92") {
75
+ if (values.E !== undefined)
76
+ e = values.E;
77
+ continue;
78
+ }
79
+ if (word === "M620" && values.S !== undefined) {
80
+ changingFilament = true;
81
+ continue;
82
+ }
83
+ if (word === "M621" && values.S !== undefined) {
84
+ changingFilament = false;
85
+ continue;
86
+ }
87
+ if (!["G0", "G1", "G2", "G3"].includes(word))
88
+ continue;
89
+ const nx = values.X === undefined ? x : absoluteXY ? values.X : x + values.X;
90
+ const ny = values.Y === undefined ? y : absoluteXY ? values.Y : y + values.Y;
91
+ const extrusion = values.E === undefined ? 0 : relative ? values.E : values.E - e;
92
+ if (z !== undefined &&
93
+ extrusion > 0 &&
94
+ word !== "G0" &&
95
+ !changingFilament &&
96
+ feature !== "custom" &&
97
+ (values.X !== undefined || values.Y !== undefined || word === "G2" || word === "G3")) {
98
+ if (positionUnknown)
99
+ return { layers: [] };
100
+ const bounds = motionBounds(x, y, nx, ny, word, values);
101
+ if (!bounds)
102
+ return { layers: [] };
103
+ if (!layer) {
104
+ // Repeated Z values do not create fictitious additional layers.
105
+ layer =
106
+ layers.at(-1)?.zMm === z
107
+ ? layers.at(-1)
108
+ : { layer: currentIndex, zMm: z };
109
+ if (layer && layers.at(-1) !== layer)
110
+ layers.push(layer);
111
+ if (layers.length > 10000)
112
+ return { layers: [] };
113
+ }
114
+ if (layer) {
115
+ const previous = layer.boundsMm;
116
+ layer.boundsMm = [
117
+ Math.min(previous?.[0] ?? bounds[0], bounds[0]),
118
+ Math.min(previous?.[1] ?? bounds[1], bounds[1]),
119
+ Math.max(previous?.[2] ?? bounds[2], bounds[2]),
120
+ Math.max(previous?.[3] ?? bounds[3], bounds[3]),
121
+ ];
122
+ }
123
+ }
124
+ if (absoluteXY && values.X !== undefined && values.Y !== undefined)
125
+ positionUnknown = false;
126
+ x = nx;
127
+ y = ny;
128
+ if (values.E !== undefined)
129
+ e = relative ? e + values.E : values.E;
130
+ }
131
+ return {
132
+ ...(layers.length
133
+ ? { heightMm: Math.max(...layers.map((l) => l.zMm)) }
134
+ : {}),
135
+ layers,
136
+ };
137
+ }
138
+ /** Include the cardinal extrema actually swept by an XY arc, including I/J full circles. */
139
+ function motionBounds(x, y, nx, ny, word, values) {
140
+ const bounds = [Math.min(x, nx), Math.min(y, ny), Math.max(x, nx), Math.max(y, ny)];
141
+ if (!bounds.every(Number.isFinite))
142
+ return;
143
+ if (word !== "G2" && word !== "G3")
144
+ return bounds;
145
+ const clockwise = word === "G2";
146
+ const centre = arcCentre(x, y, nx, ny, clockwise, values.I, values.J, values.R);
147
+ if (!centre || !centre.every(Number.isFinite))
148
+ return;
149
+ const [cx, cy] = centre, radius = Math.hypot(x - cx, y - cy);
150
+ if (!Number.isFinite(radius) || radius <= 0 || Math.abs(Math.hypot(nx - cx, ny - cy) - radius) > Math.max(0.01, radius * 0.001))
151
+ return;
152
+ const turn = 2 * Math.PI;
153
+ const normal = (angle) => ((angle % turn) + turn) % turn;
154
+ const start = Math.atan2(y - cy, x - cx), end = Math.atan2(ny - cy, nx - cx);
155
+ const sweep = normal(clockwise ? start - end : end - start);
156
+ const full = x === nx && y === ny;
157
+ for (const angle of [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2]) {
158
+ const distance = normal(clockwise ? start - angle : angle - start);
159
+ if (!full && distance > sweep + 1e-10)
160
+ continue;
161
+ const px = cx + radius * Math.cos(angle), py = cy + radius * Math.sin(angle);
162
+ bounds[0] = Math.min(bounds[0], px);
163
+ bounds[1] = Math.min(bounds[1], py);
164
+ bounds[2] = Math.max(bounds[2], px);
165
+ bounds[3] = Math.max(bounds[3], py);
166
+ }
167
+ return bounds;
168
+ }
169
+ /** Best-effort diagnostics only: an unreadable/oversize file cannot fail an already dispatched print. */
170
+ export async function geometryFromFile(filePath) {
171
+ try {
172
+ const fs = await import("node:fs/promises");
173
+ const stat = await fs.stat(filePath);
174
+ if (!stat.isFile() || stat.size > 64 * 1024 * 1024)
175
+ return undefined;
176
+ return geometryFromGcode(await fs.readFile(filePath, "utf8"));
177
+ }
178
+ catch {
179
+ return undefined;
180
+ }
181
+ }
@@ -18,6 +18,8 @@ export const REMOTE_SCOPES = {
18
18
  blender_mcp_status: "read",
19
19
  counterpart_printer_info: "read",
20
20
  counterpart_print_progress: "read",
21
+ counterpart_print_record: "read",
22
+ counterpart_print_assess: "control", // local evidence mutation, never a printer command
21
23
  cad_status: "read",
22
24
  cad_examples: "read",
23
25
  design_guidance: "read",
@@ -1,3 +1,4 @@
1
+ import { type PhysicalEvidence } from "./physical-evidence.js";
1
2
  /**
2
3
  * The Counterpart tool contract (counterpart/1): output schemas shared by the
3
4
  * tool list and the tests. mcp-3D-printer-server declares the same results.
@@ -21,6 +22,7 @@ export type Temperature = {
21
22
  target: number;
22
23
  };
23
24
  export type PrintProgress = {
25
+ physical?: PhysicalEvidence;
24
26
  contract: typeof COUNTERPART_CONTRACT;
25
27
  observedAt: string;
26
28
  state: PrintState;
@@ -211,6 +213,36 @@ export declare const PRINTER_INFO_OUTPUT_SCHEMA: {
211
213
  export declare const PRINT_PROGRESS_OUTPUT_SCHEMA: {
212
214
  type: "object";
213
215
  properties: {
216
+ physical: {
217
+ type: string;
218
+ properties: {
219
+ status: {
220
+ type: string;
221
+ enum: string[];
222
+ };
223
+ observedLayer: {
224
+ type: string;
225
+ minimum: number;
226
+ };
227
+ assessment: {
228
+ type: string;
229
+ additionalProperties: boolean;
230
+ };
231
+ evidence: {
232
+ type: string;
233
+ items: {
234
+ type: string;
235
+ };
236
+ };
237
+ limitations: {
238
+ type: string;
239
+ items: {
240
+ type: string;
241
+ };
242
+ };
243
+ };
244
+ required: string[];
245
+ };
214
246
  contract: {
215
247
  type: string;
216
248
  const: string;
@@ -1,3 +1,4 @@
1
+ import { PHYSICAL_EVIDENCE_SCHEMA } from "./physical-evidence.js";
1
2
  /**
2
3
  * The Counterpart tool contract (counterpart/1): output schemas shared by the
3
4
  * tool list and the tests. mcp-3D-printer-server declares the same results.
@@ -61,6 +62,7 @@ export const PRINTER_INFO_OUTPUT_SCHEMA = {
61
62
  export const PRINT_PROGRESS_OUTPUT_SCHEMA = {
62
63
  type: "object",
63
64
  properties: {
65
+ physical: PHYSICAL_EVIDENCE_SCHEMA,
64
66
  contract: { type: "string", const: COUNTERPART_CONTRACT },
65
67
  observedAt: { type: "string", description: "When the printer reported this (MQTT report time), ISO 8601." },
66
68
  state: { type: "string", enum: [...PRINT_STATES] },
@@ -0,0 +1,38 @@
1
+ import type { EvidenceFrame, PhysicalEvidence } from "./physical-evidence.js";
2
+ import type { PrintGeometry } from "./print-geometry.js";
3
+ export declare const VISIBILITIES: readonly ["clear", "dark", "occluded", "out_of_view", "unknown"];
4
+ export type Visibility = (typeof VISIBILITIES)[number];
5
+ export interface VisualSubmission {
6
+ jobId: string;
7
+ artifactSha256: string;
8
+ frameId: string;
9
+ imageSha256: string;
10
+ visibility: Visibility;
11
+ footprintVisible: boolean;
12
+ deposition: "absent" | "present" | "unknown";
13
+ attempted: boolean;
14
+ referenceFrameId?: string;
15
+ referenceVisibility?: Visibility;
16
+ referenceEmpty?: boolean;
17
+ }
18
+ export interface VisualObservation extends VisualSubmission {
19
+ at: string;
20
+ source: "client-vision";
21
+ }
22
+ export declare function validateVisualSubmission(v: VisualSubmission): VisualSubmission;
23
+ /** Unknown checkpoints cannot erase clear empty-footprint evidence for this execution. */
24
+ export declare function assessVisual(frames: EvidenceFrame[], observations: VisualObservation[], expected?: PrintGeometry): PhysicalEvidence | undefined;
25
+ export declare function assessmentRequest(frames: EvidenceFrame[], observations: VisualObservation[], expected?: PrintGeometry): {
26
+ required: boolean;
27
+ frameId: string;
28
+ referenceFrameIds: string[];
29
+ layer: number;
30
+ expectedHeightMm: number;
31
+ expectedFootprintMm: [number, number, number, number];
32
+ instruction: string;
33
+ } | undefined;
34
+ export declare function physicalProblems(physical: PhysicalEvidence, finished?: boolean): {
35
+ code: string;
36
+ severity: "error";
37
+ message: string;
38
+ }[];
@@ -0,0 +1,155 @@
1
+ /** Visual observations come from the client's worker; this module runs no image model or printer I/O. */
2
+ import { frameMatchesReport } from "./physical-evidence.js";
3
+ export const VISIBILITIES = [
4
+ "clear",
5
+ "dark",
6
+ "occluded",
7
+ "out_of_view",
8
+ "unknown",
9
+ ];
10
+ const uuid = /^[a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}$/i, sha = /^[a-f\d]{64}$/i;
11
+ export function validateVisualSubmission(v) {
12
+ if (!v ||
13
+ !uuid.test(v.jobId) ||
14
+ !uuid.test(v.frameId) ||
15
+ !sha.test(v.artifactSha256) ||
16
+ !sha.test(v.imageSha256) ||
17
+ !VISIBILITIES.includes(v.visibility) ||
18
+ typeof v.footprintVisible !== "boolean" ||
19
+ typeof v.attempted !== "boolean" ||
20
+ !["absent", "present", "unknown"].includes(v.deposition) ||
21
+ (v.referenceFrameId !== undefined &&
22
+ (!uuid.test(v.referenceFrameId) ||
23
+ !VISIBILITIES.includes(v.referenceVisibility))) ||
24
+ (v.referenceEmpty !== undefined && typeof v.referenceEmpty !== "boolean"))
25
+ throw Error("Invalid visual observation.");
26
+ return {
27
+ jobId: v.jobId,
28
+ artifactSha256: v.artifactSha256,
29
+ frameId: v.frameId,
30
+ imageSha256: v.imageSha256,
31
+ visibility: v.visibility,
32
+ footprintVisible: v.footprintVisible,
33
+ deposition: v.deposition,
34
+ attempted: v.attempted,
35
+ ...(v.referenceFrameId
36
+ ? {
37
+ referenceFrameId: v.referenceFrameId,
38
+ referenceVisibility: v.referenceVisibility,
39
+ referenceEmpty: v.referenceEmpty === true,
40
+ }
41
+ : {}),
42
+ };
43
+ }
44
+ function assessObservation(frames, observation, expected) {
45
+ const limitations = [
46
+ "Firmware completion is separate from physical success.",
47
+ "Image interpretation is supplied by the client vision worker; the MCP runs no vision model.",
48
+ ];
49
+ const unknown = (reason) => ({
50
+ status: "unknown",
51
+ evidence: [],
52
+ limitations: [...limitations, reason],
53
+ });
54
+ const frame = frames.find((f) => f.id === observation.frameId &&
55
+ f.status === "captured" &&
56
+ f.sha256 === observation.imageSha256 &&
57
+ f.role !== "baseline");
58
+ const footprint = expected?.layers.find((l) => l.layer === frame?.layer)?.boundsMm;
59
+ if (!frame ||
60
+ !footprint ||
61
+ !footprint.every(Number.isFinite) ||
62
+ footprint[2] <= footprint[0] ||
63
+ footprint[3] <= footprint[1] ||
64
+ !frameMatchesReport(frame) ||
65
+ !observation.attempted)
66
+ return unknown("Saved frame, expected deposition footprint or attempted-layer evidence is unavailable.");
67
+ if (observation.visibility !== "clear" ||
68
+ !observation.footprintVisible ||
69
+ observation.deposition === "unknown")
70
+ return unknown("The expected footprint is dark, occluded, out of view, unlocatable or unassessed.");
71
+ if (observation.deposition === "present")
72
+ return {
73
+ ...unknown("The client reports visible material; height, coverage and final success remain unverified."),
74
+ observedLayer: frame.layer,
75
+ evidence: [frame.id],
76
+ };
77
+ const reference = frames.find((f) => f.id === observation.referenceFrameId && f.status === "captured");
78
+ const evidence = [frame.id];
79
+ if (reference &&
80
+ observation.referenceVisibility === "clear" &&
81
+ observation.referenceEmpty === true)
82
+ evidence.unshift(reference.id);
83
+ return {
84
+ status: "suspect_no_extrusion",
85
+ observedLayer: frame.layer,
86
+ evidence,
87
+ limitations: [
88
+ ...limitations,
89
+ "The client reports a clear expected footprint with no visible deposited material after deposition was attempted. Check the print; the cause is unverified.",
90
+ ...(evidence.length === 1
91
+ ? [
92
+ "No usable empty-bed reference was supplied; the clear empty-footprint observation is direct evidence.",
93
+ ]
94
+ : [
95
+ "The client compared the frame with the saved empty-bed reference.",
96
+ ]),
97
+ ],
98
+ };
99
+ }
100
+ /** Unknown checkpoints cannot erase clear empty-footprint evidence for this execution. */
101
+ export function assessVisual(frames, observations, expected) {
102
+ let latest;
103
+ let suspect;
104
+ let recovery;
105
+ const ordered = [...observations].sort((a, b) => (frames.find(f => f.id === a.frameId)?.layer ?? 0) - (frames.find(f => f.id === b.frameId)?.layer ?? 0));
106
+ for (const observation of ordered) {
107
+ latest = assessObservation(frames, observation, expected);
108
+ if (latest.status === "suspect_no_extrusion") {
109
+ suspect = latest;
110
+ recovery = undefined;
111
+ }
112
+ else if (suspect && observation.deposition === "present" &&
113
+ latest.evidence.includes(observation.frameId) &&
114
+ (latest.observedLayer ?? 0) > (suspect.observedLayer ?? 0)) {
115
+ suspect = undefined;
116
+ latest.limitations.push("A later clear, visible-footprint present observation at a higher layer supersedes the earlier no-extrusion warning; final physical success remains unverified.");
117
+ recovery = latest;
118
+ }
119
+ }
120
+ if (!suspect)
121
+ return recovery ?? latest;
122
+ return { ...suspect, limitations: [...suspect.limitations,
123
+ "This job's no-extrusion warning stays active through unknown checkpoints and firmware completion. Only a later clear present observation with a visible footprint at a higher layer can supersede it."] };
124
+ }
125
+ export function assessmentRequest(frames, observations, expected) {
126
+ const pending = frames.filter((f) => f.status === "captured" &&
127
+ frameMatchesReport(f) &&
128
+ f.role !== "baseline" &&
129
+ !observations.some((o) => o.frameId === f.id));
130
+ const frame = pending.find((f) => f.role === "first_layer") ?? pending.at(-1);
131
+ const footprint = expected?.layers.find((l) => l.layer === frame?.layer)?.boundsMm;
132
+ if (!frame || !footprint)
133
+ return;
134
+ return {
135
+ required: true,
136
+ frameId: frame.id,
137
+ referenceFrameIds: frames
138
+ .filter((f) => f.role === "baseline" && f.status === "captured")
139
+ .map((f) => f.id),
140
+ layer: frame.layer,
141
+ expectedHeightMm: frame.expectedHeightMm,
142
+ expectedFootprintMm: footprint,
143
+ instruction: "Fetch this frame (and any usable reference) with counterpart_print_record include_frames:true frame_format:images. Have the client vision worker locate the expected footprint. Record its observation with counterpart_print_assess. A clearly empty footprint after attempted printing is suspect_no_extrusion even without a usable reference. Dark/occluded/unlocatable is unknown. Never infer a first layer is down from counters.",
144
+ };
145
+ }
146
+ export function physicalProblems(physical, finished = false) {
147
+ if (physical.status !== "suspect_no_extrusion")
148
+ return [];
149
+ const layer = Number.isInteger(physical.observedLayer) && physical.observedLayer > 0
150
+ ? ` at layer ${physical.observedLayer}` : "";
151
+ const message = finished
152
+ ? `The printer reports finished, but the camera showed the part's area empty${layer}. Check the nozzle and filament path.`
153
+ : `Nothing seems to be coming out of the nozzle: the camera shows the part's area empty${layer}. The printer can still count layers without printing anything. Check the nozzle and filament path.`;
154
+ return [{ code: "physical-no-extrusion", severity: "error", message }];
155
+ }