@mastra/daytona 0.8.1-alpha.0 → 0.9.0-alpha.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 +42 -0
- package/dist/index.cjs +30 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -34
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +20 -9
- package/dist/sandbox/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @mastra/daytona
|
|
2
2
|
|
|
3
|
+
## 0.9.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added a `secrets` option to `DaytonaSandbox` for injecting Daytona Secrets into sandboxes. Map environment variable names to Daytona Secret names and the real value is substituted into HTTPS request headers at egress — the raw credential never enters the sandbox. ([#22322](https://github.com/mastra-ai/mastra/pull/22322))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const sandbox = new DaytonaSandbox({
|
|
11
|
+
secrets: {
|
|
12
|
+
GITHUB_TOKEN: 'github-token',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Closes https://github.com/mastra-ai/mastra/issues/22314
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Fixed a leak where every command left its process handle behind, by removing Daytona's own `executeCommand` in favour of the shared one, which releases them. ([#21984](https://github.com/mastra-ai/mastra/pull/21984))
|
|
22
|
+
|
|
23
|
+
Command results now match every other provider: `command` holds the full command string, and the separate `args` array is gone.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const result = await sandbox.executeCommand('echo', ['hello']);
|
|
27
|
+
// before: result.command === 'echo', result.args === ['hello']
|
|
28
|
+
// after: result.command === 'echo hello', result.args === undefined
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Starting a sandbox now reports whether it created a fresh sandbox or reconnected to an existing one, so an `onStart` handler can run first-time setup only when it's actually needed: ([#21984](https://github.com/mastra-ai/mastra/pull/21984))
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
new E2BSandbox({
|
|
35
|
+
id: 'session-1',
|
|
36
|
+
onStart: async ({ outcome }) => {
|
|
37
|
+
if (outcome === 'created') await cloneRepo();
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8)]:
|
|
43
|
+
- @mastra/core@1.62.0-alpha.11
|
|
44
|
+
|
|
3
45
|
## 0.8.1-alpha.0
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -708,6 +708,7 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
708
708
|
networkBlockAll;
|
|
709
709
|
networkAllowList;
|
|
710
710
|
domainAllowList;
|
|
711
|
+
secrets;
|
|
711
712
|
connectionOpts;
|
|
712
713
|
_constructorOptions;
|
|
713
714
|
constructor(options = {}) {
|
|
@@ -734,6 +735,7 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
734
735
|
this.networkBlockAll = options.networkBlockAll;
|
|
735
736
|
this.networkAllowList = options.networkAllowList;
|
|
736
737
|
this.domainAllowList = options.domainAllowList;
|
|
738
|
+
this.secrets = options.secrets;
|
|
737
739
|
this.connectionOpts = {
|
|
738
740
|
...options.apiKey !== void 0 && { apiKey: options.apiKey },
|
|
739
741
|
...options.apiUrl !== void 0 && { apiUrl: options.apiUrl },
|
|
@@ -791,26 +793,35 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
791
793
|
return this.daytona;
|
|
792
794
|
}
|
|
793
795
|
/**
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
796
|
+
* Acquisition primitives (base-orchestrated start): the base derives
|
|
797
|
+
* `created` structurally from whether an existing sandbox was found, so
|
|
798
|
+
* reconnecting to one with the same logical ID reports `connected`.
|
|
799
|
+
* Lookup errors other than not-found propagate deliberately — creating a
|
|
800
|
+
* duplicate sandbox on a transient/auth error would be worse than failing.
|
|
797
801
|
*/
|
|
798
|
-
async
|
|
799
|
-
if (this._sandbox) return;
|
|
802
|
+
async find() {
|
|
803
|
+
if (this._sandbox) return this._sandbox;
|
|
800
804
|
if (!this._daytona) this._daytona = new _daytonaio_sdk.Daytona(this.connectionOpts);
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
this.logger.debug(`${LOG_PREFIX}
|
|
807
|
-
|
|
808
|
-
this.logger.debug(`${LOG_PREFIX} Running mount reconciliation...`);
|
|
809
|
-
await this.reconcileMounts(expectedPaths);
|
|
810
|
-
this.logger.debug(`${LOG_PREFIX} Mount reconciliation complete`);
|
|
811
|
-
await this.detectWorkingDir();
|
|
812
|
-
return;
|
|
805
|
+
return await this.findExistingSandbox() ?? void 0;
|
|
806
|
+
}
|
|
807
|
+
async connect(existing) {
|
|
808
|
+
if (existing === this._sandbox) return;
|
|
809
|
+
if (existing.state !== _daytonaio_sdk.SandboxState.STARTED) {
|
|
810
|
+
this.logger.debug(`${LOG_PREFIX} Restarting sandbox ${existing.id} (state: ${existing.state})`);
|
|
811
|
+
await this.waitForStableStateAndStart(existing);
|
|
813
812
|
}
|
|
813
|
+
this._sandbox = existing;
|
|
814
|
+
this._daytonaSandboxId = existing.id;
|
|
815
|
+
this._createdAt = existing.createdAt ? new Date(existing.createdAt) : /* @__PURE__ */ new Date();
|
|
816
|
+
this.logger.debug(`${LOG_PREFIX} Reconnected to existing sandbox ${existing.id} for: ${this.id}`);
|
|
817
|
+
const expectedPaths = Array.from(this.mounts.entries.keys());
|
|
818
|
+
this.logger.debug(`${LOG_PREFIX} Running mount reconciliation...`);
|
|
819
|
+
await this.reconcileMounts(expectedPaths);
|
|
820
|
+
this.logger.debug(`${LOG_PREFIX} Mount reconciliation complete`);
|
|
821
|
+
await this.detectWorkingDir();
|
|
822
|
+
}
|
|
823
|
+
async create() {
|
|
824
|
+
if (!this._daytona) this._daytona = new _daytonaio_sdk.Daytona(this.connectionOpts);
|
|
814
825
|
this.logger.debug(`${LOG_PREFIX} Creating sandbox for: ${this.id}`);
|
|
815
826
|
const baseParams = compact({
|
|
816
827
|
language: this.language,
|
|
@@ -828,7 +839,8 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
828
839
|
public: this.sandboxPublic,
|
|
829
840
|
networkBlockAll: this.networkBlockAll,
|
|
830
841
|
networkAllowList: this.networkAllowList,
|
|
831
|
-
domainAllowList: this.domainAllowList
|
|
842
|
+
domainAllowList: this.domainAllowList,
|
|
843
|
+
secrets: this.secrets
|
|
832
844
|
});
|
|
833
845
|
if (this.resources && !this.image) this.logger.warn(`${LOG_PREFIX} 'resources' option requires 'image' to take effect — falling back to snapshot-based creation without custom resources`);
|
|
834
846
|
const createParams = this.image && !this.snapshotId ? compact({
|
|
@@ -933,18 +945,6 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
933
945
|
return parts.join(" ");
|
|
934
946
|
}
|
|
935
947
|
/**
|
|
936
|
-
* Execute a command in the sandbox and return the result.
|
|
937
|
-
*/
|
|
938
|
-
async executeCommand(command, args = [], options = {}) {
|
|
939
|
-
await this.ensureRunning();
|
|
940
|
-
const fullCommand = args.length > 0 ? `${command} ${args.map(shellQuote).join(" ")}` : command;
|
|
941
|
-
return {
|
|
942
|
-
...await (await this.processes.spawn(fullCommand, options)).wait(),
|
|
943
|
-
command,
|
|
944
|
-
args
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
948
|
* Bulk-write files into the sandbox filesystem via the SDK's native upload.
|
|
949
949
|
*/
|
|
950
950
|
async writeFiles(files) {
|
|
@@ -1315,10 +1315,6 @@ var DaytonaSandbox = class DaytonaSandbox extends _mastra_core_workspace.MastraS
|
|
|
1315
1315
|
} catch {}
|
|
1316
1316
|
return null;
|
|
1317
1317
|
}
|
|
1318
|
-
if (state !== _daytonaio_sdk.SandboxState.STARTED) {
|
|
1319
|
-
this.logger.debug(`${LOG_PREFIX} Restarting sandbox ${sandbox.id} (state: ${state})`);
|
|
1320
|
-
await this.waitForStableStateAndStart(sandbox);
|
|
1321
|
-
}
|
|
1322
1318
|
return sandbox;
|
|
1323
1319
|
}
|
|
1324
1320
|
/**
|