bambu-printer-mcp 1.1.78 → 1.1.80
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.
|
@@ -658,6 +658,10 @@ export class BambuNetworkBridge {
|
|
|
658
658
|
await pump();
|
|
659
659
|
await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
660
660
|
}
|
|
661
|
+
// A delayed wake can cross the deadline while replies are queued in the host.
|
|
662
|
+
// Drain once more before inspecting replies or disconnecting.
|
|
663
|
+
assertActive();
|
|
664
|
+
await pump();
|
|
661
665
|
};
|
|
662
666
|
const certificateReadyWithin = async (ms) => {
|
|
663
667
|
const deadline = Date.now() + ms;
|
|
@@ -668,6 +672,8 @@ export class BambuNetworkBridge {
|
|
|
668
672
|
return true;
|
|
669
673
|
await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
670
674
|
} while (Date.now() < deadline);
|
|
675
|
+
assertActive();
|
|
676
|
+
await pump();
|
|
671
677
|
return certificateReady;
|
|
672
678
|
};
|
|
673
679
|
await this.ensureAgent(options);
|
|
@@ -853,6 +859,11 @@ export class BambuNetworkBridge {
|
|
|
853
859
|
if (!done())
|
|
854
860
|
await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
855
861
|
}
|
|
862
|
+
// Read replies queued during the last sleep, even if it overshot the deadline.
|
|
863
|
+
if (!done()) {
|
|
864
|
+
assertActive();
|
|
865
|
+
await pump();
|
|
866
|
+
}
|
|
856
867
|
return done();
|
|
857
868
|
};
|
|
858
869
|
const settle = async (ms) => { await waitFor(() => false, ms); };
|
package/dist/safety/artifact.js
CHANGED
|
@@ -9,9 +9,9 @@ const generations = new Map();
|
|
|
9
9
|
export function cancelPendingPrinterOperations(_host, serial) {
|
|
10
10
|
generations.set(serial, (generations.get(serial) ?? 0) + 1);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const ownedSnapshots = new Set();
|
|
13
13
|
process.once("exit", () => {
|
|
14
|
-
for (const directory of
|
|
14
|
+
for (const directory of ownedSnapshots) {
|
|
15
15
|
try {
|
|
16
16
|
rmSync(directory, { recursive: true, force: true });
|
|
17
17
|
}
|
|
@@ -42,6 +42,8 @@ export async function withPrinterOperation(_host, serial, operation) {
|
|
|
42
42
|
*/
|
|
43
43
|
export async function withPrintSnapshot(source, operation, root = os.tmpdir()) {
|
|
44
44
|
const directory = await fs.mkdtemp(path.join(root, "bambu-print-"));
|
|
45
|
+
// Register before any operation can exit without unwinding its finally.
|
|
46
|
+
ownedSnapshots.add(directory);
|
|
45
47
|
const snapshot = path.join(directory, path.basename(source));
|
|
46
48
|
let retainUntilExit = false;
|
|
47
49
|
try {
|
|
@@ -51,10 +53,10 @@ export async function withPrintSnapshot(source, operation, root = os.tmpdir()) {
|
|
|
51
53
|
}
|
|
52
54
|
finally {
|
|
53
55
|
// Native bridge APIs may return before their asynchronous upload completes.
|
|
54
|
-
if (retainUntilExit)
|
|
55
|
-
retained.add(directory);
|
|
56
|
-
else
|
|
56
|
+
if (!retainUntilExit) {
|
|
57
57
|
await fs.rm(directory, { recursive: true, force: true });
|
|
58
|
+
ownedSnapshots.delete(directory);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
export function uniquePrintName(filename) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bambu-printer-mcp",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.80",
|
|
4
4
|
"description": "MCP server for Bambu Lab 3D printers with STL manipulation, slicing, and print management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"start:stdio": "MCP_TRANSPORT=stdio node dist/index.js",
|
|
14
14
|
"start:http": "MCP_TRANSPORT=streamable-http node dist/index.js",
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"test": "npm run build && node
|
|
16
|
+
"test": "npm run build && node scripts/test-with-temp-guard.mjs --import ./tests/support/isolate-studio-config.mjs tests/*.test.mjs tests/**/*.test.mjs",
|
|
17
17
|
"package:mcpb": "npm run build && node scripts/package-mcpb.mjs",
|
|
18
18
|
"version": "node scripts/sync-manifest-version.mjs",
|
|
19
19
|
"postinstall": "node scripts/install-patches.mjs",
|
|
@@ -796,6 +796,10 @@ export class BambuNetworkBridge {
|
|
|
796
796
|
await pump();
|
|
797
797
|
await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
798
798
|
}
|
|
799
|
+
// A delayed wake can cross the deadline while replies are queued in the host.
|
|
800
|
+
// Drain once more before inspecting replies or disconnecting.
|
|
801
|
+
assertActive();
|
|
802
|
+
await pump();
|
|
799
803
|
};
|
|
800
804
|
const certificateReadyWithin = async (ms: number) => {
|
|
801
805
|
const deadline = Date.now() + ms;
|
|
@@ -805,6 +809,8 @@ export class BambuNetworkBridge {
|
|
|
805
809
|
if (certificateReady) return true;
|
|
806
810
|
await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
807
811
|
} while (Date.now() < deadline);
|
|
812
|
+
assertActive();
|
|
813
|
+
await pump();
|
|
808
814
|
return certificateReady;
|
|
809
815
|
};
|
|
810
816
|
|
|
@@ -998,6 +1004,8 @@ export class BambuNetworkBridge {
|
|
|
998
1004
|
await pump();
|
|
999
1005
|
if (!done()) await new Promise(resolve => setTimeout(resolve, timing.pollMs));
|
|
1000
1006
|
}
|
|
1007
|
+
// Read replies queued during the last sleep, even if it overshot the deadline.
|
|
1008
|
+
if (!done()) { assertActive(); await pump(); }
|
|
1001
1009
|
return done();
|
|
1002
1010
|
};
|
|
1003
1011
|
const settle = async (ms: number) => { await waitFor(() => false, ms); };
|
package/src/safety/artifact.ts
CHANGED
|
@@ -10,9 +10,9 @@ const generations = new Map<string, number>();
|
|
|
10
10
|
export function cancelPendingPrinterOperations(_host: string, serial: string): void {
|
|
11
11
|
generations.set(serial, (generations.get(serial) ?? 0) + 1);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const ownedSnapshots = new Set<string>();
|
|
14
14
|
process.once("exit", () => {
|
|
15
|
-
for (const directory of
|
|
15
|
+
for (const directory of ownedSnapshots) {
|
|
16
16
|
try { rmSync(directory, { recursive: true, force: true }); } catch { /* OS temp cleanup remains available. */ }
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -35,6 +35,8 @@ export async function withPrinterOperation<T>(_host: string, serial: string, ope
|
|
|
35
35
|
*/
|
|
36
36
|
export async function withPrintSnapshot<T>(source: string, operation: (snapshot: string, retainForDispatchedUpload: () => void) => Promise<T>, root = os.tmpdir()): Promise<T> {
|
|
37
37
|
const directory = await fs.mkdtemp(path.join(root, "bambu-print-"));
|
|
38
|
+
// Register before any operation can exit without unwinding its finally.
|
|
39
|
+
ownedSnapshots.add(directory);
|
|
38
40
|
const snapshot = path.join(directory, path.basename(source));
|
|
39
41
|
let retainUntilExit = false;
|
|
40
42
|
try {
|
|
@@ -43,8 +45,10 @@ export async function withPrintSnapshot<T>(source: string, operation: (snapshot:
|
|
|
43
45
|
return await operation(snapshot, () => { retainUntilExit = true; });
|
|
44
46
|
} finally {
|
|
45
47
|
// Native bridge APIs may return before their asynchronous upload completes.
|
|
46
|
-
if (retainUntilExit)
|
|
47
|
-
|
|
48
|
+
if (!retainUntilExit) {
|
|
49
|
+
await fs.rm(directory, { recursive: true, force: true });
|
|
50
|
+
ownedSnapshots.delete(directory);
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|