bambu-printer-mcp 1.1.12 → 1.1.14

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.
@@ -26,6 +26,10 @@ export type BambuNetworkBridgeOptions = {
26
26
  countryCode?: string;
27
27
  userInfo?: string;
28
28
  timeoutMs?: number;
29
+ /** Trusted in-process preflight; never populated from tool arguments. */
30
+ beforeDispatch?: (method: string) => Promise<void>;
31
+ assertDispatchAllowed?: (method: string) => void;
32
+ onDispatched?: (method: string) => void;
29
33
  };
30
34
 
31
35
  export type BambuNetworkBridgeStatus = {
@@ -242,6 +246,7 @@ export class BambuNetworkBridge {
242
246
  }
243
247
 
244
248
  await this.ensureStarted(options.bridgeCommand);
249
+ await options.beforeDispatch?.(method);
245
250
 
246
251
  const id = this.nextRequestId++;
247
252
  const requestPayload = Buffer.from(JSON.stringify({ method, payload }), "utf8");
@@ -261,6 +266,7 @@ export class BambuNetworkBridge {
261
266
  this.pending.set(id, { method, resolve, reject, timer });
262
267
 
263
268
  try {
269
+ options.assertDispatchAllowed?.(method);
264
270
  this.child!.stdin.write(frame, (error) => {
265
271
  if (error) {
266
272
  const pending = this.pending.get(id);
@@ -271,6 +277,7 @@ export class BambuNetworkBridge {
271
277
  }
272
278
  }
273
279
  });
280
+ options.onDispatched?.(method);
274
281
  } catch (error) {
275
282
  clearTimeout(timer);
276
283
  this.pending.delete(id);