bambu-printer-mcp 1.1.89 → 1.1.91
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 +49 -1
- package/dist/cad/contracts.d.ts +84 -0
- package/dist/cad/contracts.js +50 -5
- package/dist/cad/examples.d.ts +22 -0
- package/dist/cad/examples.js +81 -0
- package/dist/cad/process.js +3 -0
- package/dist/cad-engine.d.ts +25 -0
- package/dist/cad-engine.js +197 -27
- package/dist/counterpart/flight-record.d.ts +155 -0
- package/dist/counterpart/flight-record.js +831 -0
- package/dist/counterpart/flight-tools.d.ts +213 -0
- package/dist/counterpart/flight-tools.js +232 -0
- package/dist/counterpart/fresh-frame.d.ts +16 -0
- package/dist/counterpart/fresh-frame.js +26 -0
- package/dist/counterpart/make-3mf.js +1 -4
- package/dist/counterpart/physical-evidence.d.ts +70 -0
- package/dist/counterpart/physical-evidence.js +103 -0
- package/dist/counterpart/print-geometry.d.ts +13 -0
- package/dist/counterpart/print-geometry.js +181 -0
- package/dist/counterpart/remote.js +4 -0
- package/dist/counterpart/schemas.d.ts +32 -0
- package/dist/counterpart/schemas.js +2 -0
- package/dist/counterpart/visual-evidence.d.ts +38 -0
- package/dist/counterpart/visual-evidence.js +155 -0
- package/dist/design-guidance.d.ts +22 -1
- package/dist/design-guidance.js +35 -2
- package/dist/index.js +35 -3
- package/dist/printers/bambu.d.ts +9 -2
- package/dist/printers/bambu.js +32 -6
- package/dist/safety/print-preview.d.ts +2 -0
- package/dist/safety/print-preview.js +1 -1
- package/dist/slicer/3mf-xml.d.ts +7 -0
- package/dist/slicer/3mf-xml.js +61 -0
- package/dist/stl/stl-manipulator.js +5 -2
- package/dist/tool-annotations.js +4 -0
- package/package.json +2 -1
- package/src/cad/contracts.ts +54 -5
- package/src/cad/examples/bag_clip.py +86 -0
- package/src/cad/examples/bistable_clicker.py +81 -0
- package/src/cad/examples/cable_clip.py +55 -0
- package/src/cad/examples/chainmail.py +45 -0
- package/src/cad/examples/hinged_box.py +101 -0
- package/src/cad/examples/knurled_knob.py +50 -0
- package/src/cad/examples/loft_handle.py +52 -0
- package/src/cad/examples/phone_stand.py +92 -0
- package/src/cad/examples/swept_hook.py +69 -0
- package/src/cad/examples/threaded_jar.py +62 -0
- package/src/cad/examples/trigger_capo.py +95 -0
- package/src/cad/examples/wall_hook.py +65 -0
- package/src/cad/examples.ts +77 -0
- package/src/cad/geometry.py +122 -4
- package/src/cad/process.ts +3 -0
- package/src/cad/worker.py +4 -0
- package/src/cad-engine.ts +221 -52
- package/src/counterpart/flight-record.ts +984 -0
- package/src/counterpart/flight-tools.ts +282 -0
- package/src/counterpart/fresh-frame.ts +45 -0
- package/src/counterpart/make-3mf.ts +1 -5
- package/src/counterpart/physical-evidence.ts +185 -0
- package/src/counterpart/print-geometry.ts +192 -0
- package/src/counterpart/remote.ts +4 -0
- package/src/counterpart/schemas.ts +3 -0
- package/src/counterpart/visual-evidence.ts +212 -0
- package/src/design-guidance.ts +35 -2
- package/src/index.ts +38 -4
- package/src/printers/bambu.ts +34 -5
- package/src/safety/print-preview.ts +1 -1
- package/src/slicer/3mf-xml.ts +52 -0
- package/src/stl/stl-manipulator.ts +4 -1
- package/src/tool-annotations.ts +4 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { arcCentre } from "../safety/print-preview.js";
|
|
2
|
+
|
|
3
|
+
/** Expected geometry from the exact selected plate's sliced commands, never printer progress. */
|
|
4
|
+
export interface LayerGeometry {
|
|
5
|
+
layer: number;
|
|
6
|
+
zMm: number;
|
|
7
|
+
boundsMm?: [number, number, number, number];
|
|
8
|
+
}
|
|
9
|
+
export interface PrintGeometry {
|
|
10
|
+
heightMm?: number;
|
|
11
|
+
layers: LayerGeometry[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function geometryFromGcode(gcode: string): PrintGeometry {
|
|
15
|
+
const layers: LayerGeometry[] = [];
|
|
16
|
+
let z: number | undefined, layer: LayerGeometry | undefined;
|
|
17
|
+
let markerCount = 0,
|
|
18
|
+
currentIndex = 0,
|
|
19
|
+
previousMarkerZ: number | undefined;
|
|
20
|
+
let x = 0,
|
|
21
|
+
y = 0,
|
|
22
|
+
e = 0,
|
|
23
|
+
relative = false,
|
|
24
|
+
absoluteXY = true,
|
|
25
|
+
positionUnknown = false,
|
|
26
|
+
changingFilament = false,
|
|
27
|
+
feature = "",
|
|
28
|
+
executableEnded = false;
|
|
29
|
+
for (const line of gcode.split(/\r?\n/)) {
|
|
30
|
+
if (line === "; EXECUTABLE_BLOCK_END") executableEnded = true;
|
|
31
|
+
if (executableEnded) break;
|
|
32
|
+
const marker = /^;\s*(?:Z_HEIGHT:|Z:)\s*([\d.]+)/.exec(line);
|
|
33
|
+
if (marker) {
|
|
34
|
+
z = Number(marker[1]);
|
|
35
|
+
if (z !== previousMarkerZ) markerCount++;
|
|
36
|
+
previousMarkerZ = z;
|
|
37
|
+
currentIndex = markerCount;
|
|
38
|
+
layer = undefined;
|
|
39
|
+
if (!Number.isFinite(z) || z <= 0 || z > 10000) z = undefined;
|
|
40
|
+
}
|
|
41
|
+
const declared = /^;\s*layer num\/total_layer_count:\s*(\d+)\/\d+/.exec(
|
|
42
|
+
line,
|
|
43
|
+
);
|
|
44
|
+
if (declared) currentIndex = Number(declared[1]);
|
|
45
|
+
const featureMatch = /^;\s*(?:FEATURE|TYPE):\s*(.*)/i.exec(line);
|
|
46
|
+
if (featureMatch) feature = featureMatch[1].trim().toLowerCase();
|
|
47
|
+
const command = line
|
|
48
|
+
.split(";")[0]
|
|
49
|
+
.trim()
|
|
50
|
+
.toUpperCase()
|
|
51
|
+
.replace(/^N\d+\s*/, "")
|
|
52
|
+
.replace(/\*\d+\s*$/, "");
|
|
53
|
+
const parsed = /^([GMT])(\d+(?:\.\d+)?)/.exec(command);
|
|
54
|
+
if (!parsed) continue;
|
|
55
|
+
const word = parsed[1] + String(Number(parsed[2]));
|
|
56
|
+
const values: Record<string, number> = {};
|
|
57
|
+
for (const match of command
|
|
58
|
+
.slice(parsed[0].length)
|
|
59
|
+
.matchAll(/([A-Z])\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))/g)) {
|
|
60
|
+
if (values[match[1]] === undefined) values[match[1]] = Number(match[2]);
|
|
61
|
+
}
|
|
62
|
+
if (word === "G90") {
|
|
63
|
+
absoluteXY = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (word === "G91") {
|
|
67
|
+
absoluteXY = false;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (word === "M83") {
|
|
71
|
+
relative = true;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (word === "M82") {
|
|
75
|
+
relative = false;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
// Do not invent bed-coordinate footprints for unsupported unit/work-coordinate changes.
|
|
79
|
+
if (
|
|
80
|
+
word === "G20" ||
|
|
81
|
+
word === "G18" || word === "G19" || word === "G90.1" ||
|
|
82
|
+
word === "G53" ||
|
|
83
|
+
(word === "G92" && (values.X !== undefined || values.Y !== undefined))
|
|
84
|
+
)
|
|
85
|
+
return { layers: [] };
|
|
86
|
+
if (word === "G28") {
|
|
87
|
+
positionUnknown = true;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (Object.values(values).some((v) => !Number.isFinite(v)))
|
|
91
|
+
return { layers: [] };
|
|
92
|
+
if (word === "G92") {
|
|
93
|
+
if (values.E !== undefined) e = values.E;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (word === "M620" && values.S !== undefined) {
|
|
97
|
+
changingFilament = true;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (word === "M621" && values.S !== undefined) {
|
|
101
|
+
changingFilament = false;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (!["G0", "G1", "G2", "G3"].includes(word)) continue;
|
|
105
|
+
const nx =
|
|
106
|
+
values.X === undefined ? x : absoluteXY ? values.X : x + values.X;
|
|
107
|
+
const ny =
|
|
108
|
+
values.Y === undefined ? y : absoluteXY ? values.Y : y + values.Y;
|
|
109
|
+
const extrusion =
|
|
110
|
+
values.E === undefined ? 0 : relative ? values.E : values.E - e;
|
|
111
|
+
if (
|
|
112
|
+
z !== undefined &&
|
|
113
|
+
extrusion > 0 &&
|
|
114
|
+
word !== "G0" &&
|
|
115
|
+
!changingFilament &&
|
|
116
|
+
feature !== "custom" &&
|
|
117
|
+
(values.X !== undefined || values.Y !== undefined || word === "G2" || word === "G3")
|
|
118
|
+
) {
|
|
119
|
+
if (positionUnknown) return { layers: [] };
|
|
120
|
+
const bounds = motionBounds(x, y, nx, ny, word, values);
|
|
121
|
+
if (!bounds) return { layers: [] };
|
|
122
|
+
if (!layer) {
|
|
123
|
+
// Repeated Z values do not create fictitious additional layers.
|
|
124
|
+
layer =
|
|
125
|
+
layers.at(-1)?.zMm === z
|
|
126
|
+
? layers.at(-1)
|
|
127
|
+
: { layer: currentIndex, zMm: z };
|
|
128
|
+
if (layer && layers.at(-1) !== layer) layers.push(layer);
|
|
129
|
+
if (layers.length > 10000) return { layers: [] };
|
|
130
|
+
}
|
|
131
|
+
if (layer) {
|
|
132
|
+
const previous = layer.boundsMm;
|
|
133
|
+
layer.boundsMm = [
|
|
134
|
+
Math.min(previous?.[0] ?? bounds[0], bounds[0]),
|
|
135
|
+
Math.min(previous?.[1] ?? bounds[1], bounds[1]),
|
|
136
|
+
Math.max(previous?.[2] ?? bounds[2], bounds[2]),
|
|
137
|
+
Math.max(previous?.[3] ?? bounds[3], bounds[3]),
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (absoluteXY && values.X !== undefined && values.Y !== undefined)
|
|
142
|
+
positionUnknown = false;
|
|
143
|
+
x = nx;
|
|
144
|
+
y = ny;
|
|
145
|
+
if (values.E !== undefined) e = relative ? e + values.E : values.E;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
...(layers.length
|
|
149
|
+
? { heightMm: Math.max(...layers.map((l) => l.zMm)) }
|
|
150
|
+
: {}),
|
|
151
|
+
layers,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Include the cardinal extrema actually swept by an XY arc, including I/J full circles. */
|
|
156
|
+
function motionBounds(x: number, y: number, nx: number, ny: number, word: string, values: Record<string, number>): [number, number, number, number] | undefined {
|
|
157
|
+
const bounds: [number, number, number, number] = [Math.min(x,nx),Math.min(y,ny),Math.max(x,nx),Math.max(y,ny)];
|
|
158
|
+
if (!bounds.every(Number.isFinite)) return;
|
|
159
|
+
if (word !== "G2" && word !== "G3") return bounds;
|
|
160
|
+
const clockwise = word === "G2";
|
|
161
|
+
const centre = arcCentre(x,y,nx,ny,clockwise,values.I,values.J,values.R);
|
|
162
|
+
if (!centre || !centre.every(Number.isFinite)) return;
|
|
163
|
+
const [cx,cy] = centre, radius = Math.hypot(x-cx,y-cy);
|
|
164
|
+
if (!Number.isFinite(radius) || radius <= 0 || Math.abs(Math.hypot(nx-cx,ny-cy)-radius) > Math.max(0.01,radius*0.001)) return;
|
|
165
|
+
const turn = 2*Math.PI;
|
|
166
|
+
const normal = (angle:number) => ((angle % turn)+turn)%turn;
|
|
167
|
+
const start = Math.atan2(y-cy,x-cx), end = Math.atan2(ny-cy,nx-cx);
|
|
168
|
+
const sweep = normal(clockwise ? start-end : end-start);
|
|
169
|
+
const full = x === nx && y === ny;
|
|
170
|
+
for (const angle of [0,Math.PI/2,Math.PI,3*Math.PI/2]) {
|
|
171
|
+
const distance = normal(clockwise ? start-angle : angle-start);
|
|
172
|
+
if (!full && distance > sweep+1e-10) continue;
|
|
173
|
+
const px = cx+radius*Math.cos(angle), py = cy+radius*Math.sin(angle);
|
|
174
|
+
bounds[0]=Math.min(bounds[0],px); bounds[1]=Math.min(bounds[1],py);
|
|
175
|
+
bounds[2]=Math.max(bounds[2],px); bounds[3]=Math.max(bounds[3],py);
|
|
176
|
+
}
|
|
177
|
+
return bounds;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Best-effort diagnostics only: an unreadable/oversize file cannot fail an already dispatched print. */
|
|
181
|
+
export async function geometryFromFile(
|
|
182
|
+
filePath: string,
|
|
183
|
+
): Promise<PrintGeometry | undefined> {
|
|
184
|
+
try {
|
|
185
|
+
const fs = await import("node:fs/promises");
|
|
186
|
+
const stat = await fs.stat(filePath);
|
|
187
|
+
if (!stat.isFile() || stat.size > 64 * 1024 * 1024) return undefined;
|
|
188
|
+
return geometryFromGcode(await fs.readFile(filePath, "utf8"));
|
|
189
|
+
} catch {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -41,7 +41,11 @@ export const REMOTE_SCOPES: Readonly<Record<string, RemoteScope>> = {
|
|
|
41
41
|
blender_mcp_status: "read",
|
|
42
42
|
counterpart_printer_info: "read",
|
|
43
43
|
counterpart_print_progress: "read",
|
|
44
|
+
counterpart_print_record: "read",
|
|
45
|
+
counterpart_print_assess: "control", // local evidence mutation, never a printer command
|
|
44
46
|
cad_status: "read",
|
|
47
|
+
cad_examples: "read",
|
|
48
|
+
design_guidance: "read",
|
|
45
49
|
cad_setup: "read",
|
|
46
50
|
cad_run: "design",
|
|
47
51
|
cad_check_fit: "design",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {PHYSICAL_EVIDENCE_SCHEMA,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.
|
|
@@ -15,6 +16,7 @@ export type ProblemSeverity = typeof PROBLEM_SEVERITIES[number];
|
|
|
15
16
|
export type Problem = { code: string; severity: ProblemSeverity; message: string; url?: string };
|
|
16
17
|
export type Temperature = { actual: number; target: number };
|
|
17
18
|
export type PrintProgress = {
|
|
19
|
+
physical?: PhysicalEvidence;
|
|
18
20
|
contract: typeof COUNTERPART_CONTRACT;
|
|
19
21
|
observedAt: string;
|
|
20
22
|
state: PrintState;
|
|
@@ -94,6 +96,7 @@ export const PRINTER_INFO_OUTPUT_SCHEMA = {
|
|
|
94
96
|
export const PRINT_PROGRESS_OUTPUT_SCHEMA = {
|
|
95
97
|
type: "object" as const,
|
|
96
98
|
properties: {
|
|
99
|
+
physical: PHYSICAL_EVIDENCE_SCHEMA,
|
|
97
100
|
contract: { type: "string", const: COUNTERPART_CONTRACT },
|
|
98
101
|
observedAt: { type: "string", description: "When the printer reported this (MQTT report time), ISO 8601." },
|
|
99
102
|
state: { type: "string", enum: [...PRINT_STATES] },
|
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
import type { EvidenceFrame, PhysicalEvidence } from "./physical-evidence.js";
|
|
4
|
+
import type { PrintGeometry } from "./print-geometry.js";
|
|
5
|
+
|
|
6
|
+
export const VISIBILITIES = [
|
|
7
|
+
"clear",
|
|
8
|
+
"dark",
|
|
9
|
+
"occluded",
|
|
10
|
+
"out_of_view",
|
|
11
|
+
"unknown",
|
|
12
|
+
] as const;
|
|
13
|
+
export type Visibility = (typeof VISIBILITIES)[number];
|
|
14
|
+
export interface VisualSubmission {
|
|
15
|
+
jobId: string;
|
|
16
|
+
artifactSha256: string;
|
|
17
|
+
frameId: string;
|
|
18
|
+
imageSha256: string;
|
|
19
|
+
visibility: Visibility;
|
|
20
|
+
footprintVisible: boolean;
|
|
21
|
+
deposition: "absent" | "present" | "unknown";
|
|
22
|
+
attempted: boolean;
|
|
23
|
+
referenceFrameId?: string;
|
|
24
|
+
referenceVisibility?: Visibility;
|
|
25
|
+
referenceEmpty?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface VisualObservation extends VisualSubmission {
|
|
28
|
+
at: string;
|
|
29
|
+
source: "client-vision";
|
|
30
|
+
}
|
|
31
|
+
const uuid = /^[a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}$/i,
|
|
32
|
+
sha = /^[a-f\d]{64}$/i;
|
|
33
|
+
export function validateVisualSubmission(
|
|
34
|
+
v: VisualSubmission,
|
|
35
|
+
): VisualSubmission {
|
|
36
|
+
if (
|
|
37
|
+
!v ||
|
|
38
|
+
!uuid.test(v.jobId) ||
|
|
39
|
+
!uuid.test(v.frameId) ||
|
|
40
|
+
!sha.test(v.artifactSha256) ||
|
|
41
|
+
!sha.test(v.imageSha256) ||
|
|
42
|
+
!VISIBILITIES.includes(v.visibility) ||
|
|
43
|
+
typeof v.footprintVisible !== "boolean" ||
|
|
44
|
+
typeof v.attempted !== "boolean" ||
|
|
45
|
+
!["absent", "present", "unknown"].includes(v.deposition) ||
|
|
46
|
+
(v.referenceFrameId !== undefined &&
|
|
47
|
+
(!uuid.test(v.referenceFrameId) ||
|
|
48
|
+
!VISIBILITIES.includes(v.referenceVisibility!))) ||
|
|
49
|
+
(v.referenceEmpty !== undefined && typeof v.referenceEmpty !== "boolean")
|
|
50
|
+
)
|
|
51
|
+
throw Error("Invalid visual observation.");
|
|
52
|
+
return {
|
|
53
|
+
jobId: v.jobId,
|
|
54
|
+
artifactSha256: v.artifactSha256,
|
|
55
|
+
frameId: v.frameId,
|
|
56
|
+
imageSha256: v.imageSha256,
|
|
57
|
+
visibility: v.visibility,
|
|
58
|
+
footprintVisible: v.footprintVisible,
|
|
59
|
+
deposition: v.deposition,
|
|
60
|
+
attempted: v.attempted,
|
|
61
|
+
...(v.referenceFrameId
|
|
62
|
+
? {
|
|
63
|
+
referenceFrameId: v.referenceFrameId,
|
|
64
|
+
referenceVisibility: v.referenceVisibility,
|
|
65
|
+
referenceEmpty: v.referenceEmpty === true,
|
|
66
|
+
}
|
|
67
|
+
: {}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function assessObservation(
|
|
71
|
+
frames: EvidenceFrame[],
|
|
72
|
+
observation: VisualObservation,
|
|
73
|
+
expected?: PrintGeometry,
|
|
74
|
+
): PhysicalEvidence {
|
|
75
|
+
const limitations = [
|
|
76
|
+
"Firmware completion is separate from physical success.",
|
|
77
|
+
"Image interpretation is supplied by the client vision worker; the MCP runs no vision model.",
|
|
78
|
+
];
|
|
79
|
+
const unknown = (reason: string): PhysicalEvidence => ({
|
|
80
|
+
status: "unknown",
|
|
81
|
+
evidence: [],
|
|
82
|
+
limitations: [...limitations, reason],
|
|
83
|
+
});
|
|
84
|
+
const frame = frames.find(
|
|
85
|
+
(f) =>
|
|
86
|
+
f.id === observation.frameId &&
|
|
87
|
+
f.status === "captured" &&
|
|
88
|
+
f.sha256 === observation.imageSha256 &&
|
|
89
|
+
f.role !== "baseline",
|
|
90
|
+
);
|
|
91
|
+
const footprint = expected?.layers.find(
|
|
92
|
+
(l) => l.layer === frame?.layer,
|
|
93
|
+
)?.boundsMm;
|
|
94
|
+
if (
|
|
95
|
+
!frame ||
|
|
96
|
+
!footprint ||
|
|
97
|
+
!footprint.every(Number.isFinite) ||
|
|
98
|
+
footprint[2] <= footprint[0] ||
|
|
99
|
+
footprint[3] <= footprint[1] ||
|
|
100
|
+
!frameMatchesReport(frame) ||
|
|
101
|
+
!observation.attempted
|
|
102
|
+
)
|
|
103
|
+
return unknown(
|
|
104
|
+
"Saved frame, expected deposition footprint or attempted-layer evidence is unavailable.",
|
|
105
|
+
);
|
|
106
|
+
if (
|
|
107
|
+
observation.visibility !== "clear" ||
|
|
108
|
+
!observation.footprintVisible ||
|
|
109
|
+
observation.deposition === "unknown"
|
|
110
|
+
)
|
|
111
|
+
return unknown(
|
|
112
|
+
"The expected footprint is dark, occluded, out of view, unlocatable or unassessed.",
|
|
113
|
+
);
|
|
114
|
+
if (observation.deposition === "present")
|
|
115
|
+
return {
|
|
116
|
+
...unknown("The client reports visible material; height, coverage and final success remain unverified."),
|
|
117
|
+
observedLayer: frame.layer,
|
|
118
|
+
evidence: [frame.id],
|
|
119
|
+
};
|
|
120
|
+
const reference = frames.find(
|
|
121
|
+
(f) => f.id === observation.referenceFrameId && f.status === "captured",
|
|
122
|
+
);
|
|
123
|
+
const evidence = [frame.id];
|
|
124
|
+
if (
|
|
125
|
+
reference &&
|
|
126
|
+
observation.referenceVisibility === "clear" &&
|
|
127
|
+
observation.referenceEmpty === true
|
|
128
|
+
)
|
|
129
|
+
evidence.unshift(reference.id);
|
|
130
|
+
return {
|
|
131
|
+
status: "suspect_no_extrusion",
|
|
132
|
+
observedLayer: frame.layer,
|
|
133
|
+
evidence,
|
|
134
|
+
limitations: [
|
|
135
|
+
...limitations,
|
|
136
|
+
"The client reports a clear expected footprint with no visible deposited material after deposition was attempted. Check the print; the cause is unverified.",
|
|
137
|
+
...(evidence.length === 1
|
|
138
|
+
? [
|
|
139
|
+
"No usable empty-bed reference was supplied; the clear empty-footprint observation is direct evidence.",
|
|
140
|
+
]
|
|
141
|
+
: [
|
|
142
|
+
"The client compared the frame with the saved empty-bed reference.",
|
|
143
|
+
]),
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Unknown checkpoints cannot erase clear empty-footprint evidence for this execution. */
|
|
148
|
+
export function assessVisual(
|
|
149
|
+
frames: EvidenceFrame[],
|
|
150
|
+
observations: VisualObservation[],
|
|
151
|
+
expected?: PrintGeometry,
|
|
152
|
+
): PhysicalEvidence | undefined {
|
|
153
|
+
let latest: PhysicalEvidence | undefined;
|
|
154
|
+
let suspect: PhysicalEvidence | undefined;
|
|
155
|
+
let recovery: PhysicalEvidence | undefined;
|
|
156
|
+
const ordered = [...observations].sort((a,b) =>
|
|
157
|
+
(frames.find(f=>f.id===a.frameId)?.layer ?? 0) - (frames.find(f=>f.id===b.frameId)?.layer ?? 0));
|
|
158
|
+
for (const observation of ordered) {
|
|
159
|
+
latest = assessObservation(frames, observation, expected);
|
|
160
|
+
if (latest.status === "suspect_no_extrusion") { suspect = latest; recovery = undefined; }
|
|
161
|
+
else if (suspect && observation.deposition === "present" &&
|
|
162
|
+
latest.evidence.includes(observation.frameId) &&
|
|
163
|
+
(latest.observedLayer ?? 0) > (suspect.observedLayer ?? 0)) {
|
|
164
|
+
suspect = undefined;
|
|
165
|
+
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.");
|
|
166
|
+
recovery = latest;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!suspect) return recovery ?? latest;
|
|
170
|
+
return {...suspect,limitations:[...suspect.limitations,
|
|
171
|
+
"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."]};
|
|
172
|
+
}
|
|
173
|
+
export function assessmentRequest(
|
|
174
|
+
frames: EvidenceFrame[],
|
|
175
|
+
observations: VisualObservation[],
|
|
176
|
+
expected?: PrintGeometry,
|
|
177
|
+
) {
|
|
178
|
+
const pending = frames.filter(
|
|
179
|
+
(f) =>
|
|
180
|
+
f.status === "captured" &&
|
|
181
|
+
frameMatchesReport(f) &&
|
|
182
|
+
f.role !== "baseline" &&
|
|
183
|
+
!observations.some((o) => o.frameId === f.id),
|
|
184
|
+
);
|
|
185
|
+
const frame = pending.find((f) => f.role === "first_layer") ?? pending.at(-1);
|
|
186
|
+
const footprint = expected?.layers.find(
|
|
187
|
+
(l) => l.layer === frame?.layer,
|
|
188
|
+
)?.boundsMm;
|
|
189
|
+
if (!frame || !footprint) return;
|
|
190
|
+
return {
|
|
191
|
+
required: true,
|
|
192
|
+
frameId: frame.id,
|
|
193
|
+
referenceFrameIds: frames
|
|
194
|
+
.filter((f) => f.role === "baseline" && f.status === "captured")
|
|
195
|
+
.map((f) => f.id),
|
|
196
|
+
layer: frame.layer,
|
|
197
|
+
expectedHeightMm: frame.expectedHeightMm,
|
|
198
|
+
expectedFootprintMm: footprint,
|
|
199
|
+
instruction:
|
|
200
|
+
"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.",
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function physicalProblems(physical: PhysicalEvidence, finished = false) {
|
|
205
|
+
if (physical.status !== "suspect_no_extrusion") return [];
|
|
206
|
+
const layer = Number.isInteger(physical.observedLayer) && physical.observedLayer! > 0
|
|
207
|
+
? ` at layer ${physical.observedLayer}` : "";
|
|
208
|
+
const message = finished
|
|
209
|
+
? `The printer reports finished, but the camera showed the part's area empty${layer}. Check the nozzle and filament path.`
|
|
210
|
+
: `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.`;
|
|
211
|
+
return [{code:"physical-no-extrusion",severity:"error" as const,message}];
|
|
212
|
+
}
|
package/src/design-guidance.ts
CHANGED
|
@@ -25,7 +25,9 @@ Find out before you design, and before you ask. Research whenever the request na
|
|
|
25
25
|
6. For what is still unknown after about two rounds per fact, shape the design so that fact does not decide whether it works (an adjustable or sprung interface, a foot that suits more than one surface), or state a bounded assumption as an assumption. Ask the person only as the last resort, one short question, and only for what exists nowhere but with them. Never ask for something a search answers: a photo of their car's dashboard, the size of a named product, what a named surface is made of.
|
|
26
26
|
Without web tools, say so in the result, use what you recall labelled as recalled rather than published, and lean harder on step 6.
|
|
27
27
|
|
|
28
|
-
Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.
|
|
28
|
+
Write the concept down before any geometry, in a few lines: the bought product you are following, its mechanism, the load path, and how it will print. Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.
|
|
29
|
+
|
|
30
|
+
Give it the product's form as well as its function. The bought thing's shape is evidence: a handle swells where the palm closes, a hook's arm thickens towards its root, a knob is round and knurled, a clip's jaws wrap what they hold. Do not reduce a product to a flat profile pushed up, or a box with holes, because that is quick to model and prints without thought: that is a bracket, and people can tell. Put curves where hands and objects touch and where load turns a corner. A flat, in-plane layout is right only for the element that needs it (a spring that must bend in the layer plane, a print-in-place hinge or chain), and then say so; the rest of the product keeps its form, split or turned for printing if need be. When the engine renders the model, look at a three-quarter view and ask whether a person would recognise the thing and want it.
|
|
29
31
|
|
|
30
32
|
Choose each fit by what that interface has to do: drop in and lift out, slide, locate without rattle, grip so it does not slip or turn, snap over, or press in to stay. There is no single fit number. Keep three things apart for each interface: the object's size and how sure it is, the correction this printer and orientation need (its own observed corrections first, when the context supplies them), and the fit the function calls for. When the size's uncertainty is wider than the function tolerates, do not answer with a better number: choose a mechanism that absorbs the difference (crush ribs, a split closed by a screw, a flexure, a snap), or ask for the one measurement that settles it. The same object changes with time and use: full and nearly empty, new and worn, soft and stiff. A fit that relies on the object giving way must still work in its stiffest, largest state, and a pocket is sized to the widest section the object passes through on the way in, with support where the object actually bears, not to its bounding box.
|
|
31
33
|
|
|
@@ -43,6 +45,8 @@ Use assembly when its benefit is worth the user's additional work. Design alignm
|
|
|
43
45
|
|
|
44
46
|
Verify the chosen geometry in its actual print orientation and inspect the slice when tools permit. Check critical fits, missing or floating features, toolpaths, supports, color assignments, total time, and material consumption. Treat a slicer prediction as a prediction, not a physical test. Fix consequential problems and re-slice relevant changes. Stop when the design meets the brief and no remaining improvement justifies its cost. State "prints without supports", "holds", or "fits" only when the engine's own checks or the slice show it, and give the number that shows it; otherwise call it an untested prediction.
|
|
45
47
|
|
|
48
|
+
Fit and flexure guidance is longer than this text and is read when it applies: fdm_fit whenever a part meets a real object or another part, fdm_flexures whenever a part must flex, grip, snap, clip or spring. If your host did not attach them, read them with this MCP's design_guidance tool before you choose that fit or size that spring. Where the MCP's code engine is in use, its cad_examples tool lists worked designs to start from.
|
|
49
|
+
|
|
46
50
|
Keep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.`;
|
|
47
51
|
|
|
48
52
|
export const FDM_MULTICOLOR = `Apply this guidance when multiple colors or support materials share a print.
|
|
@@ -350,6 +354,35 @@ export const DESIGN_PROMPTS: DesignPrompt[] = [
|
|
|
350
354
|
description: "A separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation: keep, revise, or validate one specific uncertainty." },
|
|
351
355
|
];
|
|
352
356
|
|
|
357
|
+
/**
|
|
358
|
+
* The on-demand guidance as a tool. A design worker that is handed fdm_design and the engine prompt by its host has
|
|
359
|
+
* only tools, not prompts or resources, so "add fdm_fit when a part meets an object" could never be followed there:
|
|
360
|
+
* this read-only tool returns the same texts by name.
|
|
361
|
+
*/
|
|
362
|
+
const GUIDANCE_TOPICS: Record<string, { title: string; when: string; text: () => string }> = {
|
|
363
|
+
fdm_fit: { title: "Choosing a fit by function", when: "a part meets a real object or another part", text: () => FDM_FIT_GUIDANCE },
|
|
364
|
+
fdm_flexures: { title: "Parts that flex, grip and snap", when: "a part must flex, grip, snap, clip, spring, or hold something by bending", text: () => FDM_FLEXURES },
|
|
365
|
+
fdm_assembly: { title: "Splits, inserts and joints", when: "a split, joint, insert or printed thread could improve the result", text: () => FDM_ASSEMBLY },
|
|
366
|
+
fdm_multicolor: { title: "Multicolour and support materials", when: "several colours or support materials share a print", text: () => FDM_MULTICOLOR },
|
|
367
|
+
fdm_after_slice: { title: "Review a slice", when: "a candidate has been sliced, before recommending it", text: () => FDM_AFTER_SLICE },
|
|
368
|
+
fdm_capability: { title: "Bridges and overhangs", when: "a bridge or overhang decides the plan and no measured capability is at hand", text: () => FDM_CAPABILITY_GUIDANCE },
|
|
369
|
+
};
|
|
370
|
+
export const DESIGN_GUIDANCE_TOOL = {
|
|
371
|
+
name: "design_guidance",
|
|
372
|
+
description: "Read one piece of this MCP's design guidance by name: " + Object.entries(GUIDANCE_TOPICS).map(([name, t]) => `${name} (when ${t.when})`).join("; ") + ". The same texts as the prompts of those names, for a worker that has tools but not prompts. Read-only.",
|
|
373
|
+
inputSchema: {
|
|
374
|
+
type: "object" as const,
|
|
375
|
+
properties: { name: { type: "string", enum: Object.keys(GUIDANCE_TOPICS), description: "Which guidance to read." } },
|
|
376
|
+
required: ["name"],
|
|
377
|
+
additionalProperties: false,
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
export function designGuidance(args: Record<string, unknown>): { name: string; title: string; text: string } {
|
|
381
|
+
const topic = typeof args.name === "string" ? GUIDANCE_TOPICS[args.name] : undefined;
|
|
382
|
+
if (!topic || Object.keys(args).length !== 1) throw new Error(`design_guidance takes one name: ${Object.keys(GUIDANCE_TOPICS).join(", ")}.`);
|
|
383
|
+
return { name: args.name as string, title: topic.title, text: topic.text() };
|
|
384
|
+
}
|
|
385
|
+
|
|
353
386
|
const SLICER_NAMES: Record<string, string> = {
|
|
354
387
|
bambustudio: "Bambu Studio", orcaslicer: "OrcaSlicer", "orcaslicer-bambulab": "FULU OrcaSlicer-bambulab",
|
|
355
388
|
"orca-slicer-api": "the remote OrcaSlicer service (orca-slicer-api)", prusaslicer: "PrusaSlicer", cura: "Cura", slic3r: "Slic3r",
|
|
@@ -379,4 +412,4 @@ export function slicingGuidance(slicerType: string, capabilities: { supports: bo
|
|
|
379
412
|
export const FDM_SLICING_PROMPT = { name: "fdm_slicing", title: "How this MCP slices",
|
|
380
413
|
description: "Add to every design or model-editing task: how this server's slicer orients a model and generates supports, and how to check a choice with a checkpoint slice." };
|
|
381
414
|
|
|
382
|
-
export const SERVER_INSTRUCTIONS = "When designing or editing a model to print, apply the fdm_design prompt and the fdm_slicing prompt. Add fdm_fit whenever a part meets a real object or another part, to choose each fit by what that interface has to do. Add fdm_flexures whenever a part must flex, grip, snap, clip, spring, or hold something by bending. Add fdm_multicolor when several colours or support materials share a print, fdm_assembly when a split, joint or printed fastener could help, and fdm_after_slice as a separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation. Read " + FDM_CAPABILITY_URI + " when a bridge or overhang is consequential and there is no sufficiently specific measured capability available. Read " + FDM_FIT_URI + " for the same fit guidance as the fdm_fit prompt, in resource form.";
|
|
415
|
+
export const SERVER_INSTRUCTIONS = "When designing or editing a model to print, apply the fdm_design prompt and the fdm_slicing prompt. Add fdm_fit whenever a part meets a real object or another part, to choose each fit by what that interface has to do. Add fdm_flexures whenever a part must flex, grip, snap, clip, spring, or hold something by bending. Add fdm_multicolor when several colours or support materials share a print, fdm_assembly when a split, joint or printed fastener could help, and fdm_after_slice as a separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation. Read " + FDM_CAPABILITY_URI + " when a bridge or overhang is consequential and there is no sufficiently specific measured capability available. Read " + FDM_FIT_URI + " for the same fit guidance as the fdm_fit prompt, in resource form. A worker that has tools but not prompts reads the same guidance with the design_guidance tool (fdm_fit, fdm_flexures, fdm_assembly, fdm_multicolor, fdm_after_slice, fdm_capability).";
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {physicalProblems} from "./counterpart/visual-evidence.js";
|
|
3
|
+
import {flightKey} from "./counterpart/flight-record.js";
|
|
4
|
+
import {FLIGHT_RECORD_PROPERTIES,FLIGHT_RECORD_DESCRIPTION,FLIGHT_RECORD_OUTPUT_SCHEMA,flightReadOptions,flightRecordResult,FLIGHT_ASSESS_PROPERTIES,FLIGHT_ASSESS_REQUIRED,FLIGHT_ASSESS_DESCRIPTION,PRINT_EVIDENCE_GUIDANCE,visualSubmission} from "./counterpart/flight-tools.js";
|
|
2
5
|
import {CAMERA_STREAM_TOOLS} from "./printers/camera-tools.js";
|
|
3
6
|
import { withAnnotations } from "./tool-annotations.js";
|
|
4
7
|
import { withRemote } from "./counterpart/remote.js";
|
|
@@ -60,6 +63,8 @@ import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
|
60
63
|
import { CadEngine } from "./cad-engine.js";
|
|
61
64
|
import { CadRefusal } from "./cad/refusal.js";
|
|
62
65
|
import { CAD_TOOLS, cadEnabled } from "./cad/contracts.js";
|
|
66
|
+
import { cadExamplesTool } from "./cad/examples.js";
|
|
67
|
+
import { DESIGN_GUIDANCE_TOOL, designGuidance } from "./design-guidance.js";
|
|
63
68
|
import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
|
|
64
69
|
import { FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_MCP_PIN, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge, addinAddress } from "./fusion-mcp-bridge.js";
|
|
65
70
|
import { BLENDER_SETUP_OUTPUT_SCHEMA, BlenderAddonSetup, FUSION_ADDIN_REPOSITORY, FUSION_SETUP_OUTPUT_SCHEMA, FusionAddinSetup, defaultSetupSystem, parseAddonHandshake, type BlenderAddonHandshake } from "./design-app-setup.js";
|
|
@@ -155,7 +160,7 @@ const SERVER_INFO = {
|
|
|
155
160
|
};
|
|
156
161
|
/** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
|
|
157
162
|
const OUTPUT_SCHEMA_TOOLS = new Set([
|
|
158
|
-
"cad_status", "cad_setup", "cad_run", "cad_check_fit",
|
|
163
|
+
"cad_status", "cad_setup", "cad_run", "cad_check_fit", "cad_examples",
|
|
159
164
|
"counterpart_printer_info", "counterpart_print_progress", "counterpart_make_3mf",
|
|
160
165
|
"counterpart_discover_printers", "counterpart_setup_fields", "counterpart_propose_filaments",
|
|
161
166
|
"fusion_mcp_status", "fusion_mcp_new_design", "fusion_mcp_export",
|
|
@@ -1413,7 +1418,7 @@ class BambuPrinterMCPServer {
|
|
|
1413
1418
|
resources: {},
|
|
1414
1419
|
tools: {}
|
|
1415
1420
|
},
|
|
1416
|
-
instructions: SERVER_INSTRUCTIONS + (CAD_ENABLED ? " For headless dimensioned designs and parameter edits, read the cad_design prompt before using cad_run." : "")
|
|
1421
|
+
instructions: SERVER_INSTRUCTIONS + PRINT_EVIDENCE_GUIDANCE + (CAD_ENABLED ? " For headless dimensioned designs and parameter edits, read the cad_design prompt before using cad_run." : "")
|
|
1417
1422
|
}
|
|
1418
1423
|
);
|
|
1419
1424
|
|
|
@@ -1957,6 +1962,7 @@ class BambuPrinterMCPServer {
|
|
|
1957
1962
|
throw new Error("The printer's SD card or USB stick is no longer ready. Check it and start the print again.");
|
|
1958
1963
|
}
|
|
1959
1964
|
assertActive();
|
|
1965
|
+
this.bambu.recordFlightDispatch(devIp,devId,remoteFileName,requirements,resumeFile);
|
|
1960
1966
|
markPrintCommandSent();
|
|
1961
1967
|
} });
|
|
1962
1968
|
assertActive();
|
|
@@ -1972,7 +1978,7 @@ class BambuPrinterMCPServer {
|
|
|
1972
1978
|
validatePrinterState(dispatchStatus, requirements);
|
|
1973
1979
|
this.bambu.assertPrintPreflight(dispatchStatus, preflight);
|
|
1974
1980
|
},
|
|
1975
|
-
assertDispatchAllowed: method => { if (method === bridgeMethod || method === cloudFallbackMethod) { assertActive(); markPrintCommandSent(); } },
|
|
1981
|
+
assertDispatchAllowed: method => { if (method === bridgeMethod || method === cloudFallbackMethod) { assertActive(); this.bambu.recordFlightDispatch(devIp,devId,remoteFileName,requirements,resumeFile); markPrintCommandSent(); } },
|
|
1976
1982
|
onDispatched: method => { if (method === bridgeMethod || method === cloudFallbackMethod) retainForDispatchedUpload(); },
|
|
1977
1983
|
};
|
|
1978
1984
|
let jobUpdates: BridgeJobUpdate[] = [];
|
|
@@ -3478,6 +3484,7 @@ class BambuPrinterMCPServer {
|
|
|
3478
3484
|
required: ["stl_path"]
|
|
3479
3485
|
}
|
|
3480
3486
|
},
|
|
3487
|
+
DESIGN_GUIDANCE_TOOL,
|
|
3481
3488
|
...(CAD_ENABLED ? CAD_TOOLS : []),
|
|
3482
3489
|
{
|
|
3483
3490
|
name: "blender_mcp_status",
|
|
@@ -3594,6 +3601,16 @@ class BambuPrinterMCPServer {
|
|
|
3594
3601
|
additionalProperties: false
|
|
3595
3602
|
}
|
|
3596
3603
|
},
|
|
3604
|
+
{
|
|
3605
|
+
name: "counterpart_print_record", description: FLIGHT_RECORD_DESCRIPTION,
|
|
3606
|
+
inputSchema: {type:"object",properties:{...FLIGHT_RECORD_PROPERTIES,host:{type:"string",description:"Saved printer hostname or address; used only to select a local record."},bambu_serial:{type:"string",description:"Saved Bambu printer serial; used only to select a local record."}},additionalProperties:false},
|
|
3607
|
+
outputSchema: FLIGHT_RECORD_OUTPUT_SCHEMA
|
|
3608
|
+
},
|
|
3609
|
+
{
|
|
3610
|
+
name:"counterpart_print_assess",description:FLIGHT_ASSESS_DESCRIPTION,
|
|
3611
|
+
inputSchema:{type:"object",properties:{...FLIGHT_ASSESS_PROPERTIES,host:{type:"string",description:"Saved printer hostname or address; used only to select a local record."},bambu_serial:{type:"string",description:"Saved Bambu printer serial; used only to select a local record."}},required:FLIGHT_ASSESS_REQUIRED,additionalProperties:false},
|
|
3612
|
+
outputSchema:FLIGHT_RECORD_OUTPUT_SCHEMA
|
|
3613
|
+
},
|
|
3597
3614
|
{
|
|
3598
3615
|
name: "counterpart_print_progress",
|
|
3599
3616
|
description: "Counterpart contract (counterpart/1): the printer's state, current job (name, task id, percent, time left, layers, stage words), temperatures, active filament and problems with Bambu's HMS messages and links. Read from the MQTT report this server keeps, so a held session asks the printer nothing; observedAt is when the printer sent it. An unreachable printer reports state offline. Read-only; not a safety check.",
|
|
@@ -5098,11 +5115,20 @@ class BambuPrinterMCPServer {
|
|
|
5098
5115
|
break;
|
|
5099
5116
|
}
|
|
5100
5117
|
|
|
5118
|
+
case "counterpart_print_assess":
|
|
5119
|
+
return flightRecordResult(this.bambu.flightRecords.submitVisual(flightKey(host,bambuSerial),visualSubmission(args)));
|
|
5120
|
+
|
|
5121
|
+
case "counterpart_print_record":
|
|
5122
|
+
return flightRecordResult(this.bambu.flightRecords.read(flightKey(host,bambuSerial),flightReadOptions(args)),args?.frame_format==="images");
|
|
5123
|
+
|
|
5101
5124
|
case "counterpart_print_progress": {
|
|
5102
5125
|
const report = await this.bambu.readProgressReport(host, bambuSerial, bambuToken);
|
|
5126
|
+
if (report) void this.bambu.flightRecords.sample(flightKey(host,bambuSerial), after => this.bambu.cameraSnapshot(host,bambuSerial,bambuToken,{bambuModel:this.displayModel(args,bambuSerial),timeoutMs:8000,capturedAfter:after})).catch(() => undefined);
|
|
5103
5127
|
result = report
|
|
5104
5128
|
? bambuProgress(report.raw, { receivedAt: report.receivedAt, serial: bambuSerial, model: this.displayModel(args, bambuSerial) })
|
|
5105
5129
|
: offlineProgress(Date.now());
|
|
5130
|
+
const physical=this.bambu.flightRecords.physicalForReport(flightKey(host,bambuSerial),report?.raw);
|
|
5131
|
+
result = {...result, physical,problems:[...physicalProblems(physical, result.state === "finished"),...result.problems]};
|
|
5106
5132
|
break;
|
|
5107
5133
|
}
|
|
5108
5134
|
|
|
@@ -5110,9 +5136,17 @@ class BambuPrinterMCPServer {
|
|
|
5110
5136
|
result = await makeCounterpart3mf(args ?? {});
|
|
5111
5137
|
break;
|
|
5112
5138
|
|
|
5139
|
+
case "design_guidance":
|
|
5140
|
+
result = designGuidance(args ?? {});
|
|
5141
|
+
break;
|
|
5142
|
+
|
|
5143
|
+
case "cad_examples":
|
|
5144
|
+
result = cadExamplesTool(args ?? {});
|
|
5145
|
+
break;
|
|
5146
|
+
|
|
5113
5147
|
case "cad_status":
|
|
5114
5148
|
if (args && Object.keys(args).length) throw new Error("cad_status takes no arguments.");
|
|
5115
|
-
result = await this.cad.
|
|
5149
|
+
result = await this.cad.ensureReady(extra.signal); break;
|
|
5116
5150
|
case "cad_setup":
|
|
5117
5151
|
case "cad_run":
|
|
5118
5152
|
case "cad_check_fit": {
|