mcp-3d-printer-server 1.2.25 → 1.2.27
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/CHANGELOG.md +67 -0
- package/CONTRIBUTORS.md +5 -1
- package/README.md +64 -29
- package/dist/ams-mapping.d.ts +38 -0
- package/dist/ams-mapping.js +125 -0
- package/dist/bambu-network-bridge.d.ts +211 -0
- package/dist/bambu-network-bridge.js +918 -0
- package/dist/bambu-network-certs.d.ts +13 -0
- package/dist/bambu-network-certs.js +152 -0
- package/dist/control-reply.d.ts +21 -0
- package/dist/control-reply.js +44 -0
- package/dist/counterpart/camera-sources.d.ts +16 -0
- package/dist/counterpart/camera-sources.js +138 -0
- package/dist/counterpart/camera-stream.d.ts +66 -0
- package/dist/counterpart/camera-stream.js +246 -0
- package/dist/counterpart/camera-tools.d.ts +247 -0
- package/dist/counterpart/camera-tools.js +35 -0
- package/dist/counterpart/contract.d.ts +21 -5
- package/dist/counterpart/contract.js +8 -2
- package/dist/counterpart/route.d.ts +31 -0
- package/dist/counterpart/route.js +70 -0
- package/dist/counterpart/service.d.ts +60 -4
- package/dist/counterpart/service.js +142 -16
- package/dist/design-guidance.d.ts +26 -0
- package/dist/design-guidance.js +177 -0
- package/dist/fulu-orca.d.ts +7 -0
- package/dist/fulu-orca.js +18 -2
- package/dist/index.js +514 -70
- package/dist/printers/bambu-filaments.d.ts +68 -0
- package/dist/printers/bambu-filaments.js +262 -0
- package/dist/printers/bambu.d.ts +99 -6
- package/dist/printers/bambu.js +478 -72
- package/dist/printers/creality.d.ts +2 -1
- package/dist/printers/creality.js +5 -1
- package/dist/printers/generic-base.d.ts +11 -6
- package/dist/printers/generic-base.js +21 -25
- package/dist/printers/klipper.d.ts +2 -1
- package/dist/printers/klipper.js +10 -7
- package/dist/printers/octoprint.d.ts +2 -1
- package/dist/printers/octoprint.js +15 -8
- package/dist/printers/printer-factory.d.ts +1 -1
- package/dist/printers/printer-factory.js +3 -3
- package/dist/printers/prusa.js +0 -1
- package/dist/safety/confirmation.d.ts +11 -16
- package/dist/safety/confirmation.js +8 -32
- package/dist/safety/hidden-hms.d.ts +32 -0
- package/dist/safety/hidden-hms.js +405 -0
- package/dist/safety/limits.d.ts +8 -2
- package/dist/safety/limits.js +14 -5
- package/dist/safety/print-file.d.ts +5 -0
- package/dist/safety/print-file.js +156 -19
- package/dist/safety/printer-state.d.ts +68 -8
- package/dist/safety/printer-state.js +187 -40
- package/dist/slicer/bambu-cli.d.ts +2 -0
- package/dist/slicer/bambu-cli.js +7 -5
- package/dist/slicer/layer-pauses.d.ts +47 -0
- package/dist/slicer/layer-pauses.js +130 -0
- package/dist/stl/stl-manipulator.d.ts +1 -0
- package/dist/stl/stl-manipulator.js +40 -0
- package/dist/studio-print-options.d.ts +57 -0
- package/dist/studio-print-options.js +179 -0
- package/dist/tool-annotations.d.ts +25 -0
- package/dist/tool-annotations.js +58 -0
- package/package.json +27 -4
- package/server.json +2 -2
- package/src/ams-mapping.ts +132 -0
- package/src/bambu-network-bridge.ts +1106 -0
- package/src/bambu-network-certs.ts +154 -0
- package/src/control-reply.ts +41 -0
- package/src/counterpart/camera-sources.ts +102 -0
- package/src/counterpart/camera-stream.ts +195 -0
- package/src/counterpart/camera-tools.ts +35 -0
- package/src/counterpart/contract.ts +12 -4
- package/src/counterpart/route.ts +82 -0
- package/src/counterpart/service.ts +150 -16
- package/src/design-guidance.ts +188 -0
- package/src/fulu-orca.ts +18 -2
- package/src/index.ts +528 -83
- package/src/printers/bambu-filaments.ts +346 -0
- package/src/printers/bambu.ts +506 -81
- package/src/printers/creality.ts +8 -3
- package/src/printers/generic-base.ts +33 -40
- package/src/printers/klipper.ts +12 -8
- package/src/printers/octoprint.ts +16 -9
- package/src/printers/printer-factory.ts +3 -3
- package/src/printers/prusa.ts +0 -1
- package/src/safety/confirmation.ts +15 -38
- package/src/safety/hidden-hms.ts +406 -0
- package/src/safety/limits.ts +15 -5
- package/src/safety/print-file.ts +139 -17
- package/src/safety/printer-state.ts +192 -41
- package/src/slicer/bambu-cli.ts +8 -5
- package/src/slicer/layer-pauses.ts +143 -0
- package/src/stl/stl-manipulator.ts +45 -0
- package/src/studio-print-options.ts +201 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/** A parenthesized explanation of a plug-in print result, or "" when it names no known cause. */
|
|
2
|
+
export declare function describeBambuNetworkPrintError(value: number): string;
|
|
3
|
+
/** Waits from native/bambu-native-print.cpp, which prints through the same plug-in calls. */
|
|
4
|
+
export type LocalTiming = {
|
|
5
|
+
connectTimeoutMs: number;
|
|
6
|
+
pollMs: number;
|
|
7
|
+
settleMs: number;
|
|
8
|
+
retryWaitMs: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const LOCAL_PRINT_TIMING: Readonly<LocalTiming>;
|
|
11
|
+
/** A control waits briefly for the certificate message, then sends; -4/-4030 returns are retried after a reinstall. */
|
|
12
|
+
export type LocalControlTiming = LocalTiming & {
|
|
13
|
+
certificateWaitMs: number;
|
|
14
|
+
attempts: number;
|
|
15
|
+
deliveryMs: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const LOCAL_CONTROL_TIMING: Readonly<LocalControlTiming>;
|
|
18
|
+
export { controlReply, isAuthorizationRefusal } from "./control-reply.js";
|
|
19
|
+
/** Cloud session waits: connection and printer subscription, certificate, settle after the state requests. */
|
|
20
|
+
export type CloudTiming = {
|
|
21
|
+
connectTimeoutMs: number;
|
|
22
|
+
pollMs: number;
|
|
23
|
+
settleMs: number;
|
|
24
|
+
certificateWaitMs: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const CLOUD_PRINT_TIMING: Readonly<CloudTiming>;
|
|
27
|
+
export type CloudSession = {
|
|
28
|
+
settle: (ms: number) => Promise<void>;
|
|
29
|
+
/** Ask the plug-in to install the printer's certificate again, as Bambu Studio does after a failed send. */
|
|
30
|
+
installCertificate: () => Promise<void>;
|
|
31
|
+
/** Wait up to ms for device_cert_installed; true once it has arrived. */
|
|
32
|
+
certificateReadyWithin: (ms: number) => Promise<boolean>;
|
|
33
|
+
/** This printer's cloud messages, as they arrive. */
|
|
34
|
+
messages: string[];
|
|
35
|
+
jobUpdates: BridgeJobUpdate[];
|
|
36
|
+
};
|
|
37
|
+
export type LocalPrinter = {
|
|
38
|
+
devId: string;
|
|
39
|
+
devIp: string;
|
|
40
|
+
username: string;
|
|
41
|
+
password: string;
|
|
42
|
+
useSsl: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type BridgeJobUpdate = {
|
|
45
|
+
status: unknown;
|
|
46
|
+
code: unknown;
|
|
47
|
+
msg: unknown;
|
|
48
|
+
};
|
|
49
|
+
export type LocalSession = {
|
|
50
|
+
installCertificate: () => Promise<void>;
|
|
51
|
+
settle: (ms: number) => Promise<void>;
|
|
52
|
+
/** Waits up to ms for FULU's certificate-installed message for this printer; false if it never came. */
|
|
53
|
+
certificateReadyWithin: (ms: number) => Promise<boolean>;
|
|
54
|
+
/** This printer's messages about stop/pause/resume, as they arrive. */
|
|
55
|
+
controlMessages: string[];
|
|
56
|
+
jobUpdates: BridgeJobUpdate[];
|
|
57
|
+
};
|
|
58
|
+
/** One line per FULU event or control send, for diagnosing controls. Never includes access codes. */
|
|
59
|
+
export type BridgeTrace = (entry: Record<string, unknown>) => void;
|
|
60
|
+
type JsonObject = Record<string, unknown>;
|
|
61
|
+
export type BambuNetworkBridgeOptions = {
|
|
62
|
+
bridgeCommand?: string;
|
|
63
|
+
configDir?: string;
|
|
64
|
+
countryCode?: string;
|
|
65
|
+
userInfo?: string;
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
/** Trusted in-process preflight; never populated from tool arguments. */
|
|
68
|
+
beforeDispatch?: (method: string) => Promise<void>;
|
|
69
|
+
assertDispatchAllowed?: (method: string) => void;
|
|
70
|
+
/** Diagnostics for a print control: every FULU event and send in its session. */
|
|
71
|
+
trace?: BridgeTrace;
|
|
72
|
+
onDispatched?: (method: string) => void;
|
|
73
|
+
};
|
|
74
|
+
export type BambuNetworkBridgeStatus = {
|
|
75
|
+
configured: boolean;
|
|
76
|
+
command: string;
|
|
77
|
+
platform: NodeJS.Platform;
|
|
78
|
+
running: boolean;
|
|
79
|
+
pid?: number;
|
|
80
|
+
configDir: string;
|
|
81
|
+
countryCode: string;
|
|
82
|
+
agentReady: boolean;
|
|
83
|
+
lastStderr: string;
|
|
84
|
+
recentLogs: string[];
|
|
85
|
+
runtime: {
|
|
86
|
+
/** Folder passed to the plug-in's set_cert_file. */
|
|
87
|
+
certDir: string;
|
|
88
|
+
/** Linux only: absolute plug-in library paths passed to FULU's host. */
|
|
89
|
+
pluginLibraries?: Record<string, string>;
|
|
90
|
+
/** macOS only: conventional FULU runtime discovery. */
|
|
91
|
+
macosRuntimeDir?: string;
|
|
92
|
+
macosRuntimeDirExists?: boolean;
|
|
93
|
+
macosPluginDir?: string;
|
|
94
|
+
macosPluginDirExists?: boolean;
|
|
95
|
+
macosMissingRuntimeFiles?: string[];
|
|
96
|
+
macosMissingPluginFiles?: string[];
|
|
97
|
+
suggestedMacCommand?: string;
|
|
98
|
+
};
|
|
99
|
+
note?: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* The plug-in's certificate folder: BAMBU_NETWORK_CERT_DIR when set, else
|
|
103
|
+
* Bambu's pinned public certificates written to the agent's config folder,
|
|
104
|
+
* which the host must already be able to read.
|
|
105
|
+
*/
|
|
106
|
+
export declare function bambuNetworkCertDir(configDir: string, env?: NodeJS.ProcessEnv): string;
|
|
107
|
+
export declare function prepareBambuNetworkCertDir(configDir: string, env?: NodeJS.ProcessEnv): string;
|
|
108
|
+
export declare function defaultBambuNetworkConfigDir(): string;
|
|
109
|
+
/**
|
|
110
|
+
* The client identity FULU's GUI gives the plug-in before agent start
|
|
111
|
+
* (GUI_App::init_http_extra_header). Through the Linux bridge FULU presents
|
|
112
|
+
* itself as Bambu Studio at the version its plug-in ABI belongs to
|
|
113
|
+
* (PJarczakLinuxBridgeConfig.cpp forced_client_version, "02.05.02.51").
|
|
114
|
+
* Bambu's cloud issues the printer-control certificate and creates print
|
|
115
|
+
* tasks for this client, so an agent started without it is an unknown client.
|
|
116
|
+
* The device id is kept in the config folder so it stays the same per install.
|
|
117
|
+
* Ported from bambu-printer-mcp src/bambu-network-bridge.ts.
|
|
118
|
+
*/
|
|
119
|
+
export declare function bambuNetworkClientHeaders(configDir: string, env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
120
|
+
export declare class BambuNetworkBridge {
|
|
121
|
+
private child?;
|
|
122
|
+
private commandLine?;
|
|
123
|
+
private stdoutBuffer;
|
|
124
|
+
private pending;
|
|
125
|
+
private nextRequestId;
|
|
126
|
+
private agentId?;
|
|
127
|
+
private agentKey?;
|
|
128
|
+
private handshake?;
|
|
129
|
+
private lastStderr;
|
|
130
|
+
private recentLogs;
|
|
131
|
+
private inferredExpectedNetworkVersion?;
|
|
132
|
+
/** Whether the host accepted the certificate folder and callbacks a LAN session needs. */
|
|
133
|
+
private localSessionReady;
|
|
134
|
+
/**
|
|
135
|
+
* The plug-in holds one LAN printer connection and the host one event queue,
|
|
136
|
+
* so LAN sessions run one at a time, as Bambu Studio connects one printer.
|
|
137
|
+
*/
|
|
138
|
+
private localSessionTail;
|
|
139
|
+
resolveBridgeCommand(override?: string): string;
|
|
140
|
+
resolveConfigDir(override?: string): string;
|
|
141
|
+
resolveCountryCode(override?: string): string;
|
|
142
|
+
getStatus(options?: BambuNetworkBridgeOptions): BambuNetworkBridgeStatus;
|
|
143
|
+
request(method: string, payload?: JsonObject, options?: BambuNetworkBridgeOptions): Promise<unknown>;
|
|
144
|
+
ensureAgent(options?: BambuNetworkBridgeOptions): Promise<{
|
|
145
|
+
agent: number;
|
|
146
|
+
handshake: unknown;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Open the plug-in's own LAN MQTT session with a printer, in the order Bambu
|
|
150
|
+
* Studio and native/bambu-native-print.cpp use: connect, install the
|
|
151
|
+
* printer's application certificate (again on each "wait_info"), wait for
|
|
152
|
+
* the local connection, request the printer's state and let the key
|
|
153
|
+
* exchange settle. Without the certificate the plug-in uploads a job but
|
|
154
|
+
* cannot encrypt or publish project_file (-4030). The session is closed
|
|
155
|
+
* after `run`, so printer reports stop accumulating in the host's queue.
|
|
156
|
+
*/
|
|
157
|
+
withLocalSession<T>(printer: LocalPrinter, options: BambuNetworkBridgeOptions, assertActive: () => void, timing: Readonly<LocalTiming>, run: (session: LocalSession) => Promise<T>): Promise<T>;
|
|
158
|
+
private runLocalSession;
|
|
159
|
+
/**
|
|
160
|
+
* Run a LAN print method in a local session. A synchronous -4030 means the
|
|
161
|
+
* plug-in published nothing, so it is retried once after the certificate
|
|
162
|
+
* exchange, as the native helper does; each attempt passes the caller's
|
|
163
|
+
* fresh pre-dispatch checks.
|
|
164
|
+
*/
|
|
165
|
+
startLocalPrint(printer: LocalPrinter, method: string, payload: JsonObject, options?: BambuNetworkBridgeOptions, assertActive?: () => void, timing?: Readonly<LocalTiming>): Promise<{
|
|
166
|
+
result: unknown;
|
|
167
|
+
jobUpdates: BridgeJobUpdate[];
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* A print control (stop, pause, resume) through the same authenticated LAN
|
|
171
|
+
* session as a FULU print. FULU's own app sends controls exactly this way
|
|
172
|
+
* (send_message_to_printer, qos 1, flag 0) on a connection whose certificate
|
|
173
|
+
* is installed. A fresh connection can report SEND_MSG_FAILED (-4) or
|
|
174
|
+
* LP_PUBLISH_MSG_FAILED (-4030) while that exchange finishes: those returns
|
|
175
|
+
* mean nothing was sent, so the certificate is reinstalled and the control
|
|
176
|
+
* tried again, as the native X2D helper does. Any other return is final.
|
|
177
|
+
* beforeDispatch runs before every send, so a resume re-checks the paused job.
|
|
178
|
+
*/
|
|
179
|
+
sendLocalPrintCommand(printer: LocalPrinter, command: "stop" | "pause" | "resume", options?: BambuNetworkBridgeOptions, beforeDispatch?: () => Promise<void>, timing?: Readonly<LocalControlTiming>): Promise<Record<string, unknown>>;
|
|
180
|
+
/**
|
|
181
|
+
* Open the plug-in's Bambu Cloud session with a printer bound to the account, in the order
|
|
182
|
+
* Bambu Studio uses (GUI_App.cpp on_server_connected / on_printer_connected): wait for the
|
|
183
|
+
* cloud connection, select and subscribe to the printer, and when it connects request its
|
|
184
|
+
* state (pushall, get_version, get_access_code) and install its certificate for cloud use.
|
|
185
|
+
* Without that state the plug-in refuses a cloud print with -3140 (ENC_FLAG_NOT_READY).
|
|
186
|
+
* Shares the LAN session queue: one reader of the plug-in's events at a time.
|
|
187
|
+
*/
|
|
188
|
+
withCloudSession<T>(devId: string, options: BambuNetworkBridgeOptions, assertActive: () => void, timing: Readonly<CloudTiming>, run: (session: CloudSession) => Promise<T>): Promise<T>;
|
|
189
|
+
/** A cloud print method (start_print) in a cloud session, so the plug-in has the printer's state. */
|
|
190
|
+
startCloudPrint(devId: string, method: string, payload: JsonObject, options?: BambuNetworkBridgeOptions, assertActive?: () => void, timing?: Readonly<CloudTiming>): Promise<{
|
|
191
|
+
result: unknown;
|
|
192
|
+
jobUpdates: BridgeJobUpdate[];
|
|
193
|
+
}>;
|
|
194
|
+
/**
|
|
195
|
+
* A print control over Bambu Cloud: how Bambu Studio and FULU's slicer control a printer
|
|
196
|
+
* bound to the account (MachineObject::publish_json → cloud_publish_json: send_message,
|
|
197
|
+
* qos 1, flag 0), in a cloud session. Held open like the LAN control.
|
|
198
|
+
*/
|
|
199
|
+
sendCloudPrintCommand(devId: string, command: "stop" | "pause" | "resume", options?: BambuNetworkBridgeOptions, beforeDispatch?: () => Promise<void>, timing?: Readonly<LocalControlTiming>): Promise<Record<string, unknown>>;
|
|
200
|
+
/** Appends control diagnostics to control-trace.log in the bridge's config folder. */
|
|
201
|
+
private controlTrace;
|
|
202
|
+
callWithAgent(method: string, payload?: JsonObject, options?: BambuNetworkBridgeOptions): Promise<unknown>;
|
|
203
|
+
stop(): Promise<void>;
|
|
204
|
+
private ensureStarted;
|
|
205
|
+
private handleStdout;
|
|
206
|
+
private resolvePendingJson;
|
|
207
|
+
private rememberLog;
|
|
208
|
+
private rememberStderr;
|
|
209
|
+
private rejectAllPending;
|
|
210
|
+
private needsExpectedVersionRetry;
|
|
211
|
+
}
|