alchemy 2.0.0-beta.82 → 2.0.0-beta.83

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 (72) hide show
  1. package/lib/Cloudflare/Containers/Container.d.ts +128 -40
  2. package/lib/Cloudflare/Containers/Container.d.ts.map +1 -1
  3. package/lib/Cloudflare/Containers/Container.js +124 -24
  4. package/lib/Cloudflare/Containers/Container.js.map +1 -1
  5. package/lib/Cloudflare/Containers/ContainerApplication.d.ts +59 -50
  6. package/lib/Cloudflare/Containers/ContainerApplication.d.ts.map +1 -1
  7. package/lib/Cloudflare/Containers/ContainerApplication.js.map +1 -1
  8. package/lib/Cloudflare/Containers/ContainerClient.d.ts +20 -7
  9. package/lib/Cloudflare/Containers/ContainerClient.d.ts.map +1 -1
  10. package/lib/Cloudflare/Containers/ContainerClient.js +22 -5
  11. package/lib/Cloudflare/Containers/ContainerClient.js.map +1 -1
  12. package/lib/Cloudflare/Containers/ContainerConfiguration.d.ts +132 -13
  13. package/lib/Cloudflare/Containers/ContainerConfiguration.d.ts.map +1 -1
  14. package/lib/Cloudflare/Containers/ContainerConfiguration.js +219 -35
  15. package/lib/Cloudflare/Containers/ContainerConfiguration.js.map +1 -1
  16. package/lib/Cloudflare/Containers/ContainerPlatform.d.ts +1 -1
  17. package/lib/Cloudflare/Containers/ContainerPlatform.d.ts.map +1 -1
  18. package/lib/Cloudflare/Containers/ContainerPlatform.js +21 -2
  19. package/lib/Cloudflare/Containers/ContainerPlatform.js.map +1 -1
  20. package/lib/Cloudflare/Containers/ContainerProvider.d.ts.map +1 -1
  21. package/lib/Cloudflare/Containers/ContainerProvider.js +74 -177
  22. package/lib/Cloudflare/Containers/ContainerProvider.js.map +1 -1
  23. package/lib/Cloudflare/Containers/DurableObjectApplication.d.ts +84 -0
  24. package/lib/Cloudflare/Containers/DurableObjectApplication.d.ts.map +1 -0
  25. package/lib/Cloudflare/Containers/DurableObjectApplication.js +249 -0
  26. package/lib/Cloudflare/Containers/DurableObjectApplication.js.map +1 -0
  27. package/lib/Cloudflare/Containers/LocalContainerProvider.d.ts.map +1 -1
  28. package/lib/Cloudflare/Containers/LocalContainerProvider.js +20 -41
  29. package/lib/Cloudflare/Containers/LocalContainerProvider.js.map +1 -1
  30. package/lib/Cloudflare/Containers/index.d.ts +2 -1
  31. package/lib/Cloudflare/Containers/index.d.ts.map +1 -1
  32. package/lib/Cloudflare/Containers/index.js +2 -1
  33. package/lib/Cloudflare/Containers/index.js.map +1 -1
  34. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  35. package/lib/Cloudflare/Providers.js +2 -1
  36. package/lib/Cloudflare/Providers.js.map +1 -1
  37. package/lib/Cloudflare/StateStore/Api.d.ts +3 -0
  38. package/lib/Cloudflare/Workers/DurableObject.d.ts +75 -1
  39. package/lib/Cloudflare/Workers/DurableObject.d.ts.map +1 -1
  40. package/lib/Cloudflare/Workers/DurableObject.js +50 -0
  41. package/lib/Cloudflare/Workers/DurableObject.js.map +1 -1
  42. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  43. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +29 -23
  44. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  45. package/lib/Cloudflare/Workers/Worker.d.ts +2 -0
  46. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  47. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  48. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  49. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +67 -4
  50. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  51. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +6 -0
  52. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  53. package/lib/Cloudflare/Workers/WorkerProvider.d.ts.map +1 -1
  54. package/lib/Cloudflare/Workers/WorkerProvider.js +54 -8
  55. package/lib/Cloudflare/Workers/WorkerProvider.js.map +1 -1
  56. package/lib/State/HttpStateApi.d.ts +13 -13
  57. package/package.json +6 -6
  58. package/src/Cloudflare/Containers/Container.ts +126 -56
  59. package/src/Cloudflare/Containers/ContainerApplication.ts +60 -53
  60. package/src/Cloudflare/Containers/ContainerClient.ts +47 -13
  61. package/src/Cloudflare/Containers/ContainerConfiguration.ts +316 -44
  62. package/src/Cloudflare/Containers/ContainerPlatform.ts +27 -3
  63. package/src/Cloudflare/Containers/ContainerProvider.ts +96 -256
  64. package/src/Cloudflare/Containers/DurableObjectApplication.ts +382 -0
  65. package/src/Cloudflare/Containers/LocalContainerProvider.ts +20 -48
  66. package/src/Cloudflare/Containers/index.ts +10 -0
  67. package/src/Cloudflare/Providers.ts +2 -0
  68. package/src/Cloudflare/Workers/DurableObject.ts +77 -1
  69. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +32 -21
  70. package/src/Cloudflare/Workers/Worker.ts +2 -0
  71. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +95 -4
  72. package/src/Cloudflare/Workers/WorkerProvider.ts +78 -13
@@ -76,7 +76,7 @@ export declare class ContainerNotRunningError extends ContainerNotRunningError_b
76
76
  }> {
77
77
  }
78
78
  export type ContainerStartupOptions = cf.ContainerStartupOptions;
79
- import type { ContainerImageProps, DurableObjectContainerProps, EffectfulContainerProps, ExternalContainerProps, RemoteContainerProps } from "./ContainerApplication.ts";
79
+ import type { DurableObjectContainerProps, EffectfulContainerProps, ExternalContainerProps, RemoteContainerProps } from "./ContainerApplication.ts";
80
80
  export type { DurableObjectContainerProps, EffectfulContainerProps, ExternalContainerProps, RemoteContainerProps, };
81
81
  /**
82
82
  * Props for an image-backed container declaration — either the plain props
@@ -106,19 +106,11 @@ export type { DurableObjectContainerProps, EffectfulContainerProps, ExternalCont
106
106
  * `undefined` until something yields it.
107
107
  */
108
108
  export type ImageContainerProps<Req = never> = InputProps<ExternalContainerProps> | InputProps<RemoteContainerProps> | InputProps<DurableObjectContainerProps> | Effect.Effect<InputProps<ExternalContainerProps> | InputProps<RemoteContainerProps> | InputProps<DurableObjectContainerProps>, Config.ConfigError, Req>;
109
- /**
110
- * Durable Object container props with statically known image names, so the
111
- * native client can type `images.<name>` as present.
112
- */
113
- type NamedImageProps<ImageName extends string> = Omit<DurableObjectContainerProps, "images"> & {
114
- images: Record<ImageName, ContainerImageProps>;
115
- };
116
- type NamedImageContainerProps<ImageName extends string, Req> = InputProps<NamedImageProps<ImageName>> | Effect.Effect<InputProps<NamedImageProps<ImageName>>, Config.ConfigError, Req>;
117
109
  /**
118
110
  * The handle `yield* MyContainer` returns inside a Durable Object. See
119
111
  * {@link ContainerClient}.
120
112
  */
121
- export type Container<Id extends string = string, ImageName extends string = string> = Named<Id> & ContainerClient<ImageName>;
113
+ export type Container<Id extends string = string> = Named<Id> & ContainerClient;
122
114
  /** An RPC shape may not redeclare the container handle's own methods. */
123
115
  type ContainerShape<Shape> = {
124
116
  [K in keyof Shape]: K extends ReservedContainerKey ? never : Shape[K];
@@ -253,39 +245,37 @@ type ContainerShape<Shape> = {
253
245
  * ```
254
246
  *
255
247
  * ### Native Durable Object Containers
256
- * Use `schedulingPolicy: "durable_object"` to choose an image and instance
257
- * size for each container at runtime. Named images are built or copied into
258
- * Cloudflare's registry, pinned to a digest, and prepared before the Worker
259
- * is uploaded. Omit `images` to use `cloudflare/debian-trixie` or restore a
260
- * snapshot without publishing an image.
248
+ * Use `schedulingPolicy: "durable_object"` to let a Durable Object pick its
249
+ * image and instance size at runtime. One Container is one image: `image`
250
+ * copies a registry image, `context`/`dockerfile` builds one. Alchemy pins the
251
+ * image to a digest and prepares it before the Worker is uploaded.
261
252
  *
262
- * `yield* Sandbox` returns the container's handle without starting it. Its
263
- * `exec` takes an argument vector and returns a scoped process with streams,
264
- * an exit code, and an `output()` collector.
253
+ * `yield* Node` returns the container's handle without starting it.
254
+ * `start()` starts the Container's own image. Its `exec` takes an argument
255
+ * vector and returns a scoped process with streams, an exit code, and an
256
+ * `output()` collector.
265
257
  *
266
- * **Example:** Execute a command in a named image
258
+ * **Example:** Execute a command in a Container's image
267
259
  * ```typescript
268
- * export class Sandbox extends Cloudflare.Container<Sandbox>()("Sandbox", {
260
+ * export class Node extends Cloudflare.Container<Node>()("Node", {
269
261
  * schedulingPolicy: "durable_object",
270
- * images: { node: { image: "node:24-slim" } },
262
+ * image: "node:24-slim",
271
263
  * }) {}
272
264
  *
273
265
  * export class Agent extends Cloudflare.DurableObject<Agent>()(
274
266
  * "Agent",
275
267
  * Effect.gen(function* () {
276
- * const sandbox = yield* Sandbox;
268
+ * const node = yield* Node;
277
269
  * return Effect.succeed({
278
270
  * exec: (args: string[]) =>
279
271
  * Effect.gen(function* () {
280
- * const images = yield* sandbox.images;
281
- * // A no-op when the container is already running.
282
- * yield* sandbox.start({
283
- * image: images.node,
272
+ * // Starts the Node image; a no-op when the container is running.
273
+ * yield* node.start({
284
274
  * instance: "lite",
285
275
  * entrypoint: ["sleep", "infinity"],
286
276
  * enableInternet: false,
287
277
  * });
288
- * const process = yield* sandbox.exec(args);
278
+ * const process = yield* node.exec(args);
289
279
  * const result = yield* process.output();
290
280
  * return { text: new TextDecoder().decode(result.stdout), exitCode: result.exitCode };
291
281
  * }).pipe(Effect.scoped),
@@ -294,13 +284,62 @@ type ContainerShape<Shape> = {
294
284
  * ) {}
295
285
  * ```
296
286
  *
287
+ * ### Several Images in One Durable Object
288
+ * Cloudflare gives each Durable Object class one container application and
289
+ * each object one container instance. Bind several Containers to choose
290
+ * between their images. Every binding adds its image to the class's
291
+ * application under the Container's id. Each handle's `start()` starts its
292
+ * own image; start one at a time and `destroy()` before switching.
293
+ *
294
+ * **Example:** A Durable Object with Node and Python images
295
+ * ```typescript
296
+ * export class Node extends Cloudflare.Container<Node>()("Node", {
297
+ * schedulingPolicy: "durable_object",
298
+ * image: "node:24-slim",
299
+ * }) {}
300
+ *
301
+ * export class Python extends Cloudflare.Container<Python>()("Python", {
302
+ * schedulingPolicy: "durable_object",
303
+ * context: "./python",
304
+ * }) {}
305
+ *
306
+ * export class Agent extends Cloudflare.DurableObject<Agent>()(
307
+ * "Agent",
308
+ * Effect.gen(function* () {
309
+ * const node = yield* Node;
310
+ * const python = yield* Python;
311
+ * const run = (cmd: string[]) =>
312
+ * Effect.scoped(Effect.flatMap(node.exec(cmd), (process) => process.output()));
313
+ * return Effect.succeed({
314
+ * node: (cmd: string[]) =>
315
+ * node
316
+ * .start({ entrypoint: ["sleep", "infinity"], enableInternet: false })
317
+ * .pipe(Effect.andThen(run(cmd))),
318
+ * python: (cmd: string[]) =>
319
+ * Effect.gen(function* () {
320
+ * // Every handle controls the same instance: switch images explicitly.
321
+ * if (yield* node.running) yield* node.destroy();
322
+ * yield* python.start({ entrypoint: ["sleep", "infinity"], enableInternet: false });
323
+ * return yield* Effect.scoped(
324
+ * Effect.flatMap(python.exec(cmd), (process) => process.output()),
325
+ * );
326
+ * }),
327
+ * });
328
+ * }),
329
+ * ) {}
330
+ * ```
331
+ *
332
+ * Application-wide settings (`ssh`, `authorizedKeys`, `observability`) may be
333
+ * declared on any of the class's Containers. Two Containers declaring
334
+ * different values fail the deploy with `ContainerApplicationSettingsConflict`.
335
+ *
297
336
  * **Example:** Save and restore the writable filesystem
298
337
  * ```typescript
299
- * const snapshot = yield* sandbox.snapshotContainer({ name: "workspace" });
338
+ * const snapshot = yield* node.snapshotContainer({ name: "workspace" });
300
339
  * // Persist this handle in Durable Object storage before stopping the instance.
301
340
  * yield* state.storage.put("snapshot", snapshot);
302
- * yield* sandbox.destroy();
303
- * yield* sandbox.start({
341
+ * yield* node.destroy();
342
+ * yield* node.start({
304
343
  * containerSnapshot: snapshot,
305
344
  * entrypoint: ["sleep", "infinity"],
306
345
  * enableInternet: false,
@@ -314,9 +353,62 @@ type ContainerShape<Shape> = {
314
353
  * when needed. Scope closure kills an unfinished exec process, but does not
315
354
  * signal its descendants. Use an Effect timeout to bound a command's lifetime.
316
355
  *
317
- * Native async Durable Objects use the same declaration on a Worker's `env`
318
- * and call `this.ctx.container` directly. Local development exposes the named
319
- * images through workerd and Docker.
356
+ * ### Native Durable Objects on Async Workers
357
+ * A plain Durable Object class on an async Worker attaches its Containers
358
+ * through its Durable Object binding:
359
+ * `Cloudflare.DurableObject(className, { containers })`. Each Container adds
360
+ * its image to the class's application, and the class reads it from
361
+ * `ctx.container.images` under the Container's id. A Container may be listed
362
+ * by several classes; each class gets its own copy of the image key.
363
+ *
364
+ * **Example:** Two classes sharing the Node image
365
+ * ```typescript
366
+ * // alchemy.run.ts
367
+ * const Node = Cloudflare.Container("Node", {
368
+ * schedulingPolicy: "durable_object",
369
+ * image: "node:24-slim",
370
+ * });
371
+ * const Python = Cloudflare.Container("Python", {
372
+ * schedulingPolicy: "durable_object",
373
+ * image: "python:3.13-slim",
374
+ * });
375
+ * const Rust = Cloudflare.Container("Rust", {
376
+ * schedulingPolicy: "durable_object",
377
+ * image: "rust:1.90-slim",
378
+ * });
379
+ * export const Worker = Cloudflare.Worker("App", {
380
+ * main: "./src/worker.ts",
381
+ * env: {
382
+ * AGENT: Cloudflare.DurableObject("Agent", { containers: [Node, Python] }),
383
+ * REVIEWER: Cloudflare.DurableObject("Reviewer", { containers: [Node, Rust] }),
384
+ * },
385
+ * });
386
+ * ```
387
+ *
388
+ * A Durable Object-managed Container placed directly in `env` fails with
389
+ * `DurableObjectContainerBindingError`; only fleet Containers bind that way.
390
+ *
391
+ * **Example:** Starting an image from the class
392
+ * ```typescript
393
+ * // src/worker.ts
394
+ * import { DurableObject } from "cloudflare:workers";
395
+ *
396
+ * export class Agent extends DurableObject {
397
+ * async run(cmd: string[]) {
398
+ * const container = this.ctx.container!;
399
+ * if (!container.running) {
400
+ * container.start({
401
+ * image: container.images.Node,
402
+ * entrypoint: ["sleep", "infinity"],
403
+ * enableInternet: false,
404
+ * });
405
+ * }
406
+ * return (await container.exec(cmd)).output();
407
+ * }
408
+ * }
409
+ * ```
410
+ *
411
+ * Local development runs every image through workerd and Docker.
320
412
  *
321
413
  * Switching an existing application to this scheduling policy requires a new
322
414
  * application and a new Durable Object class/namespace. Alchemy rejects an
@@ -653,7 +745,7 @@ type ContainerShape<Shape> = {
653
745
  * ```
654
746
  *
655
747
  * A container's shape cannot declare a method the handle already has
656
- * (`start`, `exec`, `images`, `getTcpPort`, …); declaring one is a type
748
+ * (`start`, `exec`, `image`, `getTcpPort`, …); declaring one is a type
657
749
  * error, because the handle's method would shadow the RPC call.
658
750
  *
659
751
  * ### Using a Container from a Layer
@@ -711,10 +803,8 @@ type ContainerShape<Shape> = {
711
803
  * @category Workers & Compute
712
804
  */
713
805
  export declare const Container: ResourceClassLike<ContainerApplication> & Pick<ResourceClass<ContainerApplication>, "ref"> & {
714
- <DOShape = unknown, const Id extends string = string, PropsReq = never, ImageName extends string = string>(id: Id, props: NamedImageContainerProps<ImageName, PropsReq>): Container.Decl<Container<Id, ImageName>, {}, Id, PropsReq, DOShape, ImageName>;
715
806
  <DOShape = unknown, const Id extends string = string, PropsReq = never>(id: Id, props: ImageContainerProps<PropsReq>): Container.Decl<Container<Id>, {}, Id, PropsReq, DOShape>;
716
807
  <Self>(): {
717
- <const Id extends string, ImageName extends string, PropsReq = never>(id: Id, props: NamedImageContainerProps<ImageName, PropsReq>): Container.Decl<Self, {}, Id, PropsReq, unknown, ImageName>;
718
808
  <const Id extends string, PropsReq = never>(id: Id, props: ImageContainerProps<PropsReq>): Container.Decl<Self, {}, Id, PropsReq>;
719
809
  };
720
810
  <Self, Shape extends ContainerShape<Shape>>(): {
@@ -722,16 +812,14 @@ export declare const Container: ResourceClassLike<ContainerApplication> & Pick<R
722
812
  };
723
813
  };
724
814
  export declare namespace Container {
725
- interface Decl<Self = any, Shape = any, Id extends string = string, Req = never, DOShape = unknown, ImageName extends string = string> extends Effect.Effect<Self, never, Providers | Req>, Rpc<Shape>, Named<Id> {
726
- new (): Container<Id, ImageName> & Shape;
815
+ interface Decl<Self = any, Shape = any, Id extends string = string, Req = never, DOShape = unknown> extends Effect.Effect<Self, never, Providers | Req>, Rpc<Shape>, Named<Id> {
816
+ new (): Container<Id> & Shape;
727
817
  /**
728
818
  * @internal phantom — the Durable Object class type backing this
729
819
  * container when it is bound on an async Worker's `env`. Drives
730
820
  * `InferEnv` (`env.NAME` becomes `DurableObjectNamespace<DOShape>`).
731
821
  */
732
822
  readonly "~alchemy/Container/Shape": DOShape;
733
- /** @internal phantom — required image names available to the native client. */
734
- readonly "~alchemy/Container/Images": ImageName;
735
823
  /**
736
824
  * @internal — the explicit `className` from props (`undefined` defaults
737
825
  * to the binding name at bind time). Doubles as the runtime marker that
@@ -1 +1 @@
1
- {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Containers/Container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,eAAe,yBAAyB,CAAC;AACtD,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAErD,eAAO,MAAM,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EAAE,OAAO,CAAC;QAC7C;;;;;WAKG;QACH,QAAQ,CAAC,8BAA8B,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QAChG;;;WAGG;QACH,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,CAAC;QAC/E,IAAI,EAAE,CAAC,OAAO,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EACzD,KAAK,EACD,UAAU,CAAC,uBAAuB,CAAC,GACnC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EACpF,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,KAC7E,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACtD,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,KAAK,CAAC;KACvC;IACD,UAAiB,IAAI,CAAC;QACpB,KAAY,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;KACpD;IAED,UAAiB,WAAW,CAAC,IAAI;QAC/B,eAAe,EAAE,sBAAsB,CAAC;QACxC,eAAe,EAAE,IAAI,CAAC;KACvB;IAED,KAAY,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,SAAS,GAAG,KAAK,CAAC;CACvD"}
@@ -170,39 +170,37 @@ export class ContainerNotRunningError extends Data.TaggedError("ContainerNotRunn
170
170
  * ```
171
171
  *
172
172
  * ### Native Durable Object Containers
173
- * Use `schedulingPolicy: "durable_object"` to choose an image and instance
174
- * size for each container at runtime. Named images are built or copied into
175
- * Cloudflare's registry, pinned to a digest, and prepared before the Worker
176
- * is uploaded. Omit `images` to use `cloudflare/debian-trixie` or restore a
177
- * snapshot without publishing an image.
173
+ * Use `schedulingPolicy: "durable_object"` to let a Durable Object pick its
174
+ * image and instance size at runtime. One Container is one image: `image`
175
+ * copies a registry image, `context`/`dockerfile` builds one. Alchemy pins the
176
+ * image to a digest and prepares it before the Worker is uploaded.
178
177
  *
179
- * `yield* Sandbox` returns the container's handle without starting it. Its
180
- * `exec` takes an argument vector and returns a scoped process with streams,
181
- * an exit code, and an `output()` collector.
178
+ * `yield* Node` returns the container's handle without starting it.
179
+ * `start()` starts the Container's own image. Its `exec` takes an argument
180
+ * vector and returns a scoped process with streams, an exit code, and an
181
+ * `output()` collector.
182
182
  *
183
- * **Example:** Execute a command in a named image
183
+ * **Example:** Execute a command in a Container's image
184
184
  * ```typescript
185
- * export class Sandbox extends Cloudflare.Container<Sandbox>()("Sandbox", {
185
+ * export class Node extends Cloudflare.Container<Node>()("Node", {
186
186
  * schedulingPolicy: "durable_object",
187
- * images: { node: { image: "node:24-slim" } },
187
+ * image: "node:24-slim",
188
188
  * }) {}
189
189
  *
190
190
  * export class Agent extends Cloudflare.DurableObject<Agent>()(
191
191
  * "Agent",
192
192
  * Effect.gen(function* () {
193
- * const sandbox = yield* Sandbox;
193
+ * const node = yield* Node;
194
194
  * return Effect.succeed({
195
195
  * exec: (args: string[]) =>
196
196
  * Effect.gen(function* () {
197
- * const images = yield* sandbox.images;
198
- * // A no-op when the container is already running.
199
- * yield* sandbox.start({
200
- * image: images.node,
197
+ * // Starts the Node image; a no-op when the container is running.
198
+ * yield* node.start({
201
199
  * instance: "lite",
202
200
  * entrypoint: ["sleep", "infinity"],
203
201
  * enableInternet: false,
204
202
  * });
205
- * const process = yield* sandbox.exec(args);
203
+ * const process = yield* node.exec(args);
206
204
  * const result = yield* process.output();
207
205
  * return { text: new TextDecoder().decode(result.stdout), exitCode: result.exitCode };
208
206
  * }).pipe(Effect.scoped),
@@ -211,13 +209,62 @@ export class ContainerNotRunningError extends Data.TaggedError("ContainerNotRunn
211
209
  * ) {}
212
210
  * ```
213
211
  *
212
+ * ### Several Images in One Durable Object
213
+ * Cloudflare gives each Durable Object class one container application and
214
+ * each object one container instance. Bind several Containers to choose
215
+ * between their images. Every binding adds its image to the class's
216
+ * application under the Container's id. Each handle's `start()` starts its
217
+ * own image; start one at a time and `destroy()` before switching.
218
+ *
219
+ * **Example:** A Durable Object with Node and Python images
220
+ * ```typescript
221
+ * export class Node extends Cloudflare.Container<Node>()("Node", {
222
+ * schedulingPolicy: "durable_object",
223
+ * image: "node:24-slim",
224
+ * }) {}
225
+ *
226
+ * export class Python extends Cloudflare.Container<Python>()("Python", {
227
+ * schedulingPolicy: "durable_object",
228
+ * context: "./python",
229
+ * }) {}
230
+ *
231
+ * export class Agent extends Cloudflare.DurableObject<Agent>()(
232
+ * "Agent",
233
+ * Effect.gen(function* () {
234
+ * const node = yield* Node;
235
+ * const python = yield* Python;
236
+ * const run = (cmd: string[]) =>
237
+ * Effect.scoped(Effect.flatMap(node.exec(cmd), (process) => process.output()));
238
+ * return Effect.succeed({
239
+ * node: (cmd: string[]) =>
240
+ * node
241
+ * .start({ entrypoint: ["sleep", "infinity"], enableInternet: false })
242
+ * .pipe(Effect.andThen(run(cmd))),
243
+ * python: (cmd: string[]) =>
244
+ * Effect.gen(function* () {
245
+ * // Every handle controls the same instance: switch images explicitly.
246
+ * if (yield* node.running) yield* node.destroy();
247
+ * yield* python.start({ entrypoint: ["sleep", "infinity"], enableInternet: false });
248
+ * return yield* Effect.scoped(
249
+ * Effect.flatMap(python.exec(cmd), (process) => process.output()),
250
+ * );
251
+ * }),
252
+ * });
253
+ * }),
254
+ * ) {}
255
+ * ```
256
+ *
257
+ * Application-wide settings (`ssh`, `authorizedKeys`, `observability`) may be
258
+ * declared on any of the class's Containers. Two Containers declaring
259
+ * different values fail the deploy with `ContainerApplicationSettingsConflict`.
260
+ *
214
261
  * **Example:** Save and restore the writable filesystem
215
262
  * ```typescript
216
- * const snapshot = yield* sandbox.snapshotContainer({ name: "workspace" });
263
+ * const snapshot = yield* node.snapshotContainer({ name: "workspace" });
217
264
  * // Persist this handle in Durable Object storage before stopping the instance.
218
265
  * yield* state.storage.put("snapshot", snapshot);
219
- * yield* sandbox.destroy();
220
- * yield* sandbox.start({
266
+ * yield* node.destroy();
267
+ * yield* node.start({
221
268
  * containerSnapshot: snapshot,
222
269
  * entrypoint: ["sleep", "infinity"],
223
270
  * enableInternet: false,
@@ -231,9 +278,62 @@ export class ContainerNotRunningError extends Data.TaggedError("ContainerNotRunn
231
278
  * when needed. Scope closure kills an unfinished exec process, but does not
232
279
  * signal its descendants. Use an Effect timeout to bound a command's lifetime.
233
280
  *
234
- * Native async Durable Objects use the same declaration on a Worker's `env`
235
- * and call `this.ctx.container` directly. Local development exposes the named
236
- * images through workerd and Docker.
281
+ * ### Native Durable Objects on Async Workers
282
+ * A plain Durable Object class on an async Worker attaches its Containers
283
+ * through its Durable Object binding:
284
+ * `Cloudflare.DurableObject(className, { containers })`. Each Container adds
285
+ * its image to the class's application, and the class reads it from
286
+ * `ctx.container.images` under the Container's id. A Container may be listed
287
+ * by several classes; each class gets its own copy of the image key.
288
+ *
289
+ * **Example:** Two classes sharing the Node image
290
+ * ```typescript
291
+ * // alchemy.run.ts
292
+ * const Node = Cloudflare.Container("Node", {
293
+ * schedulingPolicy: "durable_object",
294
+ * image: "node:24-slim",
295
+ * });
296
+ * const Python = Cloudflare.Container("Python", {
297
+ * schedulingPolicy: "durable_object",
298
+ * image: "python:3.13-slim",
299
+ * });
300
+ * const Rust = Cloudflare.Container("Rust", {
301
+ * schedulingPolicy: "durable_object",
302
+ * image: "rust:1.90-slim",
303
+ * });
304
+ * export const Worker = Cloudflare.Worker("App", {
305
+ * main: "./src/worker.ts",
306
+ * env: {
307
+ * AGENT: Cloudflare.DurableObject("Agent", { containers: [Node, Python] }),
308
+ * REVIEWER: Cloudflare.DurableObject("Reviewer", { containers: [Node, Rust] }),
309
+ * },
310
+ * });
311
+ * ```
312
+ *
313
+ * A Durable Object-managed Container placed directly in `env` fails with
314
+ * `DurableObjectContainerBindingError`; only fleet Containers bind that way.
315
+ *
316
+ * **Example:** Starting an image from the class
317
+ * ```typescript
318
+ * // src/worker.ts
319
+ * import { DurableObject } from "cloudflare:workers";
320
+ *
321
+ * export class Agent extends DurableObject {
322
+ * async run(cmd: string[]) {
323
+ * const container = this.ctx.container!;
324
+ * if (!container.running) {
325
+ * container.start({
326
+ * image: container.images.Node,
327
+ * entrypoint: ["sleep", "infinity"],
328
+ * enableInternet: false,
329
+ * });
330
+ * }
331
+ * return (await container.exec(cmd)).output();
332
+ * }
333
+ * }
334
+ * ```
335
+ *
336
+ * Local development runs every image through workerd and Docker.
237
337
  *
238
338
  * Switching an existing application to this scheduling policy requires a new
239
339
  * application and a new Durable Object class/namespace. Alchemy rejects an
@@ -570,7 +670,7 @@ export class ContainerNotRunningError extends Data.TaggedError("ContainerNotRunn
570
670
  * ```
571
671
  *
572
672
  * A container's shape cannot declare a method the handle already has
573
- * (`start`, `exec`, `images`, `getTcpPort`, …); declaring one is a type
673
+ * (`start`, `exec`, `image`, `getTcpPort`, …); declaring one is a type
574
674
  * error, because the handle's method would shadow the RPC call.
575
675
  *
576
676
  * ### Using a Container from a Layer
@@ -1 +1 @@
1
- {"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/Cloudflare/Containers/Container.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAExD,OAAO,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