@mastra/apple-container 0.0.0-agent-learning-fetch-again-20260701195212
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 +22 -0
- package/LICENSE.md +30 -0
- package/README.md +118 -0
- package/dist/index.cjs +924 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +920 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +8 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/sandbox/index.d.ts +178 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/package.json +66 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @mastra/apple-container
|
|
2
|
+
|
|
3
|
+
## 0.0.0-agent-learning-fetch-again-20260701195212
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add an Apple container CLI workspace sandbox provider. ([#18643](https://github.com/mastra-ai/mastra/pull/18643))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { AppleContainerSandbox } from '@mastra/apple-container';
|
|
11
|
+
|
|
12
|
+
const sandbox = new AppleContainerSandbox({
|
|
13
|
+
id: 'local-apple-container',
|
|
14
|
+
image: 'node:22-slim',
|
|
15
|
+
volumes: { [process.cwd()]: '/workspace' },
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`0f69865`](https://github.com/mastra-ai/mastra/commit/0f69865aced225d98eac812e22699dc445ee18cb), [`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae)]:
|
|
22
|
+
- @mastra/core@0.0.0-agent-learning-fetch-again-20260701195212
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @mastra/apple-container
|
|
2
|
+
|
|
3
|
+
Apple container CLI sandbox provider for [Mastra](https://mastra.ai) workspaces.
|
|
4
|
+
|
|
5
|
+
Implements the `WorkspaceSandbox` interface with Apple's [`container`](https://github.com/apple/container) CLI. The provider starts a long-lived OCI Linux container and runs workspace commands through `container exec`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @mastra/apple-container @mastra/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Apple silicon, macOS 26 or newer, and the Apple `container` CLI. Start Apple's container system before using the provider:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
container system start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
23
|
+
import { AppleContainerSandbox } from '@mastra/apple-container';
|
|
24
|
+
|
|
25
|
+
const sandbox = new AppleContainerSandbox({
|
|
26
|
+
image: 'node:22-slim',
|
|
27
|
+
volumes: {
|
|
28
|
+
'/Users/me/project': '/workspace',
|
|
29
|
+
},
|
|
30
|
+
workingDir: '/workspace',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const workspace = new Workspace({ sandbox });
|
|
34
|
+
await workspace.init();
|
|
35
|
+
|
|
36
|
+
const result = await workspace.sandbox?.executeCommand?.('node', ['--version']);
|
|
37
|
+
console.log(result?.stdout);
|
|
38
|
+
|
|
39
|
+
await workspace.destroy();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Options
|
|
43
|
+
|
|
44
|
+
| Option | Type | Description |
|
|
45
|
+
| ------------------ | ---------------------------- | ------------------------------------------------------------------ |
|
|
46
|
+
| `id` | `string` | Unique sandbox ID. |
|
|
47
|
+
| `name` | `string` | Apple container name. Defaults to the sandbox ID. |
|
|
48
|
+
| `image` | `string` | OCI image to run. Defaults to `node:22-slim`. |
|
|
49
|
+
| `command` | `string[]` | Container init command. Defaults to `['sleep', 'infinity']`. |
|
|
50
|
+
| `env` | `Record<string, string>` | Environment variables applied to the container and command execs. |
|
|
51
|
+
| `volumes` | `Record<string, string>` | Host-to-container bind mounts. |
|
|
52
|
+
| `mounts` | `string[]` | Raw `--mount` specs passed to `container run`. |
|
|
53
|
+
| `network` | `string` | Apple container network attachment spec. |
|
|
54
|
+
| `publishedPorts` | `string[]` | Port publish specs passed as `--publish`. |
|
|
55
|
+
| `publishedSockets` | `string[]` | Socket publish specs passed as `--publish-socket`. |
|
|
56
|
+
| `cpus` | `number \| string` | Number of CPUs allocated to the container. |
|
|
57
|
+
| `memory` | `string` | Memory allocation, for example `1G`. |
|
|
58
|
+
| `platform` | `string` | OCI platform, for example `linux/arm64`. |
|
|
59
|
+
| `arch` | `string` | Image architecture when selecting multi-arch images. |
|
|
60
|
+
| `os` | `string` | Operating system when selecting multi-platform images. |
|
|
61
|
+
| `rosetta` | `boolean` | Enable Rosetta in the container. |
|
|
62
|
+
| `readonlyRootfs` | `boolean` | Start the container with a read-only root filesystem. |
|
|
63
|
+
| `ssh` | `boolean` | Forward the host SSH agent socket. |
|
|
64
|
+
| `init` | `boolean` | Enable Apple's init process in the container. |
|
|
65
|
+
| `virtualization` | `boolean` | Expose virtualization capabilities to the container. |
|
|
66
|
+
| `capAdd` | `string[]` | Linux capabilities to add. |
|
|
67
|
+
| `capDrop` | `string[]` | Linux capabilities to drop. |
|
|
68
|
+
| `tmpfs` | `string[]` | tmpfs destination paths, for example `/tmp`. |
|
|
69
|
+
| `dns` | `string[]` | DNS nameserver IPs. |
|
|
70
|
+
| `dnsSearch` | `string[]` | DNS search domains. |
|
|
71
|
+
| `noDns` | `boolean` | Do not configure DNS in the container. |
|
|
72
|
+
| `labels` | `Record<string, string>` | Container labels. Mastra labels are always added. |
|
|
73
|
+
| `workingDir` | `string` | Working directory inside the container. Defaults to `/workspace`. |
|
|
74
|
+
| `timeout` | `number` | Default command timeout in milliseconds. |
|
|
75
|
+
| `deleteOnDestroy` | `boolean` | Delete the Apple container on destroy. Defaults to `true`. |
|
|
76
|
+
| `containerBinary` | `string` | Path or name for the Apple container CLI. Defaults to `container`. |
|
|
77
|
+
| `onStart` | `({ sandbox }) => unknown` | Lifecycle hook called after the sandbox reaches `running`. |
|
|
78
|
+
| `onStop` | `({ sandbox }) => unknown` | Lifecycle hook called before the sandbox stops. |
|
|
79
|
+
| `onDestroy` | `({ sandbox }) => unknown` | Lifecycle hook called before the sandbox is destroyed. |
|
|
80
|
+
| `instructions` | `string \| (opts) => string` | Override or extend the default workspace sandbox instructions. |
|
|
81
|
+
|
|
82
|
+
Apple `--tmpfs` accepts container paths only, such as `/tmp`; it does not accept Docker-style option specs like `/tmp:rw,size=256m`.
|
|
83
|
+
When `readonlyRootfs` is enabled, make sure `workingDir` points to a path supplied by the image, a bind mount, or a writable tmpfs.
|
|
84
|
+
|
|
85
|
+
## Security model
|
|
86
|
+
|
|
87
|
+
This provider runs local containers through the host Apple `container` service. Treat constructor options as trusted server-side configuration:
|
|
88
|
+
|
|
89
|
+
- `volumes`, `mounts`, and `publishedSockets` can expose host paths to containerized code.
|
|
90
|
+
- `publishedPorts` can expose in-container services on the host or network; bind to `127.0.0.1` when only local access is intended.
|
|
91
|
+
- `ssh` forwards the host SSH agent socket.
|
|
92
|
+
- `capAdd` and `virtualization` can expand what containerized code can do.
|
|
93
|
+
- `containerBinary` is intentionally a constructor-only escape hatch for trusted code and is not part of the serializable editor provider schema.
|
|
94
|
+
|
|
95
|
+
Use the narrowest mounts and capabilities your workload needs. Existing containers are only reconnected when they carry Mastra ownership labels for the sandbox ID. Containers created by this provider also include a config-hash label; when that label is present, reconnect fails if immutable runtime options such as image, command, mounts, ports, capabilities, or working directory changed.
|
|
96
|
+
|
|
97
|
+
## Limitations
|
|
98
|
+
|
|
99
|
+
`AppleContainerSandbox` implements foreground workspace command execution with `executeCommand()`. It does not yet expose a `SandboxProcessManager` for background processes or LSP sessions.
|
|
100
|
+
|
|
101
|
+
Command timeouts are enforced inside the container so timed-out commands are cleaned up by the container runtime. Abort signals cancel the host CLI wait path and should not be used as a substitute for command timeouts when in-container cleanup matters.
|
|
102
|
+
|
|
103
|
+
## Editor provider
|
|
104
|
+
|
|
105
|
+
Register the provider with `MastraEditor` to hydrate stored sandbox configs:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { MastraEditor } from '@mastra/editor';
|
|
109
|
+
import { appleContainerSandboxProvider } from '@mastra/apple-container';
|
|
110
|
+
|
|
111
|
+
const editor = new MastraEditor({
|
|
112
|
+
sandboxes: { [appleContainerSandboxProvider.id]: appleContainerSandboxProvider },
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
Apache-2.0
|