@multiplayer-app/sandbox 7.0.1 → 7.0.3

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.
Files changed (36) hide show
  1. package/README.md +80 -0
  2. package/dist/cli.js +970 -107
  3. package/dist/cli.js.map +4 -4
  4. package/dist/config.d.ts +9 -0
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/console-relays.d.ts +4 -4
  7. package/dist/console-relays.d.ts.map +1 -1
  8. package/dist/executor/index.d.ts +12 -1
  9. package/dist/executor/index.d.ts.map +1 -1
  10. package/dist/executor/lambda-microvm-executor.d.ts +13 -3
  11. package/dist/executor/lambda-microvm-executor.d.ts.map +1 -1
  12. package/dist/executor/types.d.ts +16 -2
  13. package/dist/executor/types.d.ts.map +1 -1
  14. package/dist/images.d.ts.map +1 -1
  15. package/dist/index.js +409 -53
  16. package/dist/index.js.map +4 -4
  17. package/dist/microvm-guest-agents.d.ts +18 -0
  18. package/dist/microvm-guest-agents.d.ts.map +1 -0
  19. package/dist/microvm-images.d.ts +37 -0
  20. package/dist/microvm-images.d.ts.map +1 -0
  21. package/dist/services/serial-relay.d.ts +11 -0
  22. package/dist/services/serial-relay.d.ts.map +1 -1
  23. package/dist/socket-client.d.ts.map +1 -1
  24. package/dist/vendor/builder-types/events.d.ts +10 -0
  25. package/dist/vendor/builder-types/events.d.ts.map +1 -1
  26. package/dist/vendor/builder-types/index.d.ts +1 -0
  27. package/dist/vendor/builder-types/index.d.ts.map +1 -1
  28. package/dist/vendor/builder-types/release.d.ts +5 -5
  29. package/dist/vendor/builder-types/release.d.ts.map +1 -1
  30. package/dist/vendor/builder-types/vm-cost.d.ts +88 -0
  31. package/dist/vendor/builder-types/vm-cost.d.ts.map +1 -0
  32. package/dist/vendor/builder-types/vm.d.ts +5 -0
  33. package/dist/vendor/builder-types/vm.d.ts.map +1 -1
  34. package/dist/worker-identity.d.ts +11 -0
  35. package/dist/worker-identity.d.ts.map +1 -0
  36. package/package.json +6 -2
package/README.md CHANGED
@@ -126,6 +126,13 @@ Firecracker requires a compatible Linux host, `/dev/kvm`, and the Firecracker
126
126
  binary. Cloud runners use the normal AWS environment variables or workload
127
127
  credentials.
128
128
 
129
+ Lambda MicroVMs automatically receive the AWS-managed `SHELL_INGRESS` connector so
130
+ `/vm-console` can open a terminal. The worker role therefore needs
131
+ `lambda:CreateMicrovmShellAuthToken` and permission to pass that connector. Any
132
+ `MICROVM_INGRESS_CONNECTORS` configured for application traffic are preserved. Release
133
+ artifacts and custom per-VM environment variables travel in the unique run-hook payload;
134
+ the guest exposes the presigned release URL to the launched app as `APP_URL`.
135
+
129
136
  For the `qemu` engine, the host needs QEMU (`qemu-system-*`) installed; for
130
137
  `firecracker`, a Linux host with `/dev/kvm`; for `docker`, just a running Docker
131
138
  daemon (Docker Desktop/OrbStack) plus local images from
@@ -198,6 +205,79 @@ sandbox worker, or otherwise restarts/starts the Compose sandbox service;
198
205
  `VM_IMAGES_REFRESH=true` makes that worker replace its cached QEMU/Firecracker
199
206
  images from MinIO before advertising its engines.
200
207
 
208
+ ## Publishing your own AWS Lambda MicroVM images
209
+
210
+ Unlike the ops commands above, this works from a plain `npm install
211
+ @multiplayer-app/sandbox` — no monorepo checkout needed. It builds the guest
212
+ agent for each stack (`node`/`python`/`static`) and zips it entirely in memory
213
+ (see `src/microvm-guest-agents.ts`), then registers or updates it as an AWS
214
+ Lambda MicroVM image in **your own AWS account**, using whatever credentials
215
+ are already active (`AWS_PROFILE`, static env vars, an assumed role, ...).
216
+
217
+ ```sh
218
+ # Discover a base OS image ARN to build on top of
219
+ npx @multiplayer-app/sandbox images microvm-list-base --region us-east-1
220
+
221
+ # Build and register/update sandbox-node, sandbox-python, sandbox-static
222
+ npx @multiplayer-app/sandbox images microvm-create \
223
+ --region us-east-1 \
224
+ --bucket my-artifacts-bucket \
225
+ --base-image-arn arn:aws:lambda:us-east-1:aws:microvm-image:al2023-1 \
226
+ --build-role-arn arn:aws:iam::123456789012:role/microvm-image-build
227
+ ```
228
+
229
+ `--build-role-arn` is an IAM role the build assumes to read the uploaded code
230
+ artifact from `--bucket` — trust policy allowing `lambda.amazonaws.com` to
231
+ assume it, permissions limited to `s3:GetObject` on that bucket. It's a
232
+ one-time setup step this command doesn't automate; see the "MicroVM base image
233
+ build role" section below for the exact `aws iam` commands.
234
+
235
+ The first run creates each image; every later run updates it in place — AWS
236
+ records that as a new numbered version under the same stable ARN, so nothing
237
+ else needs to change when you publish a new version. The command prints a
238
+ ready-to-paste `MICROVM_STACK_IMAGE_ARNS` line for your worker's environment
239
+ once every image finishes building.
240
+
241
+ Lambda MicroVMs is ARM/Graviton-only today, so there's no architecture flag —
242
+ run `--help` on either command for the rest of the options (`--stack`,
243
+ `--min-memory-mib`, `--image-name-prefix`).
244
+
245
+ ### MicroVM base image build role
246
+
247
+ One-time, per AWS account:
248
+
249
+ ```sh
250
+ aws iam create-role --profile my-profile \
251
+ --role-name microvm-image-build \
252
+ --assume-role-policy-document '{
253
+ "Version": "2012-10-17",
254
+ "Statement": [{
255
+ "Effect": "Allow",
256
+ "Principal": { "Service": "lambda.amazonaws.com" },
257
+ "Action": ["sts:AssumeRole", "sts:TagSession"]
258
+ }]
259
+ }'
260
+
261
+ aws iam put-role-policy --profile my-profile \
262
+ --role-name microvm-image-build \
263
+ --policy-name microvm-build-permissions \
264
+ --policy-document '{
265
+ "Version": "2012-10-17",
266
+ "Statement": [
267
+ {
268
+ "Effect": "Allow",
269
+ "Action": "s3:GetObject",
270
+ "Resource": "arn:aws:s3:::my-artifacts-bucket/microvm-images/*"
271
+ },
272
+ {
273
+ "Effect": "Allow",
274
+ "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
275
+ "Resource": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda-microvms/sandbox-*:*"
276
+ }
277
+ ]
278
+ }'
279
+ ```
280
+
201
281
  If the build already succeeded and only the upload needs retrying, run:
202
282
 
203
283
  ```sh