@mastra/daytona 0.2.0 → 0.2.1
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 +18 -0
- package/dist/index.cjs +20 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -37
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +2 -10
- package/dist/sandbox/index.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/daytona
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed Daytona sandbox reconnection with newer Daytona SDK releases. Existing sandboxes now reconnect more reliably across stop/start cycles and process restarts. ([#14667](https://github.com/mastra-ai/mastra/pull/14667))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`dc9fc19`](https://github.com/mastra-ai/mastra/commit/dc9fc19da4437f6b508cc355f346a8856746a76b), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`d084b66`](https://github.com/mastra-ai/mastra/commit/d084b6692396057e83c086b954c1857d20b58a14), [`79c699a`](https://github.com/mastra-ai/mastra/commit/79c699acf3cd8a77e11c55530431f48eb48456e9), [`62757b6`](https://github.com/mastra-ai/mastra/commit/62757b6db6e8bb86569d23ad0b514178f57053f8), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
|
|
10
|
+
- @mastra/core@1.18.0
|
|
11
|
+
|
|
12
|
+
## 0.2.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed Daytona sandbox reconnection with newer Daytona SDK releases. Existing sandboxes now reconnect more reliably across stop/start cycles and process restarts. ([#14667](https://github.com/mastra-ai/mastra/pull/14667))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778)]:
|
|
19
|
+
- @mastra/core@1.18.0-alpha.0
|
|
20
|
+
|
|
3
21
|
## 0.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -480,6 +480,7 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
480
480
|
autoDeleteInterval;
|
|
481
481
|
volumeConfigs;
|
|
482
482
|
sandboxName;
|
|
483
|
+
_daytonaSandboxId;
|
|
483
484
|
sandboxUser;
|
|
484
485
|
sandboxPublic;
|
|
485
486
|
networkBlockAll;
|
|
@@ -564,6 +565,7 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
564
565
|
const existing = await this.findExistingSandbox();
|
|
565
566
|
if (existing) {
|
|
566
567
|
this._sandbox = existing;
|
|
568
|
+
this._daytonaSandboxId = existing.id;
|
|
567
569
|
this._createdAt = existing.createdAt ? new Date(existing.createdAt) : /* @__PURE__ */ new Date();
|
|
568
570
|
this.logger.debug(`${LOG_PREFIX} Reconnected to existing sandbox ${existing.id} for: ${this.id}`);
|
|
569
571
|
const expectedPaths = Array.from(this.mounts.entries.keys());
|
|
@@ -599,6 +601,7 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
599
601
|
resources: this.resources
|
|
600
602
|
}) : compact({ ...baseParams, snapshot: this.snapshotId });
|
|
601
603
|
this._sandbox = await this._daytona.create(createParams);
|
|
604
|
+
this._daytonaSandboxId = this._sandbox.id;
|
|
602
605
|
this.logger.debug(`${LOG_PREFIX} Created sandbox ${this._sandbox.id} for logical ID: ${this.id}`);
|
|
603
606
|
this._createdAt = /* @__PURE__ */ new Date();
|
|
604
607
|
await this.detectWorkingDir();
|
|
@@ -633,15 +636,17 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
633
636
|
} catch {
|
|
634
637
|
}
|
|
635
638
|
} else if (!this._sandbox && this._daytona) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
const lookupKey = this._daytonaSandboxId ?? this.sandboxName;
|
|
640
|
+
if (lookupKey) {
|
|
641
|
+
try {
|
|
642
|
+
const orphan = await this._daytona.get(lookupKey);
|
|
639
643
|
await this._daytona.delete(orphan);
|
|
644
|
+
} catch {
|
|
640
645
|
}
|
|
641
|
-
} catch {
|
|
642
646
|
}
|
|
643
647
|
}
|
|
644
648
|
this._sandbox = null;
|
|
649
|
+
this._daytonaSandboxId = void 0;
|
|
645
650
|
this._daytona = null;
|
|
646
651
|
this.mounts?.clear();
|
|
647
652
|
}
|
|
@@ -1019,16 +1024,7 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
1019
1024
|
// Internal Helpers
|
|
1020
1025
|
// ---------------------------------------------------------------------------
|
|
1021
1026
|
/**
|
|
1022
|
-
* Try to find and reconnect to an existing Daytona sandbox.
|
|
1023
|
-
*
|
|
1024
|
-
* Uses two strategies:
|
|
1025
|
-
* 1. `get()` by sandbox name — calls the getSandbox API directly, which
|
|
1026
|
-
* returns sandboxes in ANY state (including stopped). This is the
|
|
1027
|
-
* primary path and fixes reconnection after stop/start cycles.
|
|
1028
|
-
* 2. `findOne()` by label — falls back to label-based search. Note: the
|
|
1029
|
-
* SDK's list() API only returns started sandboxes by default (no states
|
|
1030
|
-
* param in v0.143.0), so this only finds running sandboxes.
|
|
1031
|
-
*
|
|
1027
|
+
* Try to find and reconnect to an existing Daytona sandbox by ID.
|
|
1032
1028
|
* Returns the sandbox if found and usable, or null if a fresh one should
|
|
1033
1029
|
* be created.
|
|
1034
1030
|
*/
|
|
@@ -1052,31 +1048,19 @@ var DaytonaSandbox = class _DaytonaSandbox extends workspace.MastraSandbox {
|
|
|
1052
1048
|
sdk.SandboxState.ERROR,
|
|
1053
1049
|
sdk.SandboxState.BUILD_FAILED
|
|
1054
1050
|
];
|
|
1055
|
-
|
|
1056
|
-
if (
|
|
1057
|
-
|
|
1058
|
-
sandbox = await this._daytona.get(this.sandboxName);
|
|
1059
|
-
} catch (error) {
|
|
1060
|
-
if (error instanceof sdk.DaytonaNotFoundError) ; else if (error instanceof sdk.DaytonaError && (error.statusCode === 401 || error.statusCode === 403)) {
|
|
1061
|
-
throw error;
|
|
1062
|
-
} else {
|
|
1063
|
-
this.logger.debug(`${LOG_PREFIX} Transient error looking up sandbox by name: ${error}`);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1051
|
+
const lookupKey = this._daytonaSandboxId ?? this.sandboxName;
|
|
1052
|
+
if (!lookupKey) {
|
|
1053
|
+
return null;
|
|
1066
1054
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
if (error instanceof sdk.DaytonaError && (error.statusCode === 401 || error.statusCode === 403)) {
|
|
1075
|
-
throw error;
|
|
1076
|
-
}
|
|
1077
|
-
this.logger.debug(`${LOG_PREFIX} Transient error looking up sandbox by label: ${error}`);
|
|
1055
|
+
let sandbox;
|
|
1056
|
+
try {
|
|
1057
|
+
sandbox = await this._daytona.get(lookupKey);
|
|
1058
|
+
} catch (error) {
|
|
1059
|
+
if (error instanceof sdk.DaytonaNotFoundError) {
|
|
1060
|
+
this._daytonaSandboxId = void 0;
|
|
1078
1061
|
return null;
|
|
1079
1062
|
}
|
|
1063
|
+
throw error;
|
|
1080
1064
|
}
|
|
1081
1065
|
const state = sandbox.state;
|
|
1082
1066
|
if (state && DEAD_STATES.includes(state)) {
|