@lunora/container 1.0.0-alpha.12 → 1.0.0-alpha.13

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/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { D as DurableObjectJurisdiction, C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/jurisdiction.d-CdUpqfc-.js";
2
- export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/jurisdiction.d-CdUpqfc-.js";
1
+ import { D as DurableObjectJurisdiction, C as ContainerConfig, a as ContainerDefinition, b as ContainerImageSource, N as NormalizedContainerImage } from "./packem_shared/jurisdiction.d-8oUUvrew.js";
2
+ export type { B as BuildImageSource, c as ContainerInstanceType, d as ContainerReadinessCheck, e as ContainerRollout, f as CustomContainerInstanceType, g as NamedContainerInstanceType, R as RegistryImageSource } from "./packem_shared/jurisdiction.d-8oUUvrew.js";
3
3
  /**
4
- * Options for explicitly starting an instance (mirrors `@cloudflare/containers`).
5
- * @experimental
6
- */
4
+ * Options for explicitly starting an instance (mirrors `@cloudflare/containers`).
5
+ * @experimental
6
+ */
7
7
  interface ContainerStartOptions {
8
8
  /** Override outbound internet access for this start. */
9
9
  enableInternet?: boolean;
@@ -15,9 +15,9 @@ interface ContainerStartOptions {
15
15
  labels?: Record<string, string>;
16
16
  }
17
17
  /**
18
- * A container instance's runtime state, as returned by `getState()`. Structural — the platform adds fields over time.
19
- * @experimental
20
- */
18
+ * A container instance's runtime state, as returned by `getState()`. Structural — the platform adds fields over time.
19
+ * @experimental
20
+ */
21
21
  interface ContainerInstanceState {
22
22
  [key: string]: unknown;
23
23
  /** Process exit code, present once the instance has `stopped_with_code`. */
@@ -43,69 +43,69 @@ interface ContainerStubLike {
43
43
  stop?: (signal?: number | string) => Promise<void>;
44
44
  }
45
45
  /**
46
- * What the client needs from a Durable Object namespace binding.
47
- * @experimental
48
- */
46
+ * What the client needs from a Durable Object namespace binding.
47
+ * @experimental
48
+ */
49
49
  interface ContainerNamespaceLike {
50
50
  get: (id: unknown) => ContainerStubLike;
51
51
  idFromName: (name: string) => unknown;
52
52
  /**
53
- * Derive a jurisdiction-restricted subnamespace. Optional because older
54
- * workers-types releases (and test doubles) may not expose it.
55
- */
53
+ * Derive a jurisdiction-restricted subnamespace. Optional because older
54
+ * workers-types releases (and test doubles) may not expose it.
55
+ */
56
56
  jurisdiction?: (jurisdiction: DurableObjectJurisdiction) => ContainerNamespaceLike;
57
57
  }
58
58
  /**
59
- * A handle on one container instance (one Durable Object).
60
- * @experimental
61
- */
59
+ * A handle on one container instance (one Durable Object).
60
+ * @experimental
61
+ */
62
62
  interface ContainerHandle {
63
63
  /**
64
- * Send an HTTP (or WebSocket-upgrade) request to the container. A path
65
- * string (`"/transcode"`) is resolved against a synthetic origin; a full
66
- * `Request`/URL passes through unchanged.
67
- */
64
+ * Send an HTTP (or WebSocket-upgrade) request to the container. A path
65
+ * string (`"/transcode"`) is resolved against a synthetic origin; a full
66
+ * `Request`/URL passes through unchanged.
67
+ */
68
68
  fetch: (input: Request | string, init?: RequestInit) => Promise<Response>;
69
69
  /**
70
- * Return a handle that routes every request to `targetPort` on the
71
- * container instead of the definition's `defaultPort` — for multi-port
72
- * containers (declare the ports in `requiredPorts`). Sets the
73
- * `cf-container-target-port` header the way `@cloudflare/containers`'
74
- * `switchPort` does, so it composes with `.get()`, `.any()`, and `.pool()`:
75
- * `ctx.containers.app.get("u1").port(9090).fetch("/admin")`.
76
- */
70
+ * Return a handle that routes every request to `targetPort` on the
71
+ * container instead of the definition's `defaultPort` — for multi-port
72
+ * containers (declare the ports in `requiredPorts`). Sets the
73
+ * `cf-container-target-port` header the way `@cloudflare/containers`'
74
+ * `switchPort` does, so it composes with `.get()`, `.any()`, and `.pool()`:
75
+ * `ctx.containers.app.get("u1").port(9090).fetch("/admin")`.
76
+ */
77
77
  port: (targetPort: number) => ContainerHandle;
78
78
  }
79
79
  /**
80
- * A handle on a *named* instance (from `.get(name)`) — `fetch` plus explicit
81
- * lifecycle control. The per-entity pattern (a sandbox per user, a room per
82
- * game, a job runner per id) often needs to tear down or inspect the instance
83
- * rather than wait for `sleepAfter`, so these wrap the container DO's
84
- * `start`/`stop`/`destroy`/`getState`.
85
- * @experimental
86
- */
80
+ * A handle on a *named* instance (from `.get(name)`) — `fetch` plus explicit
81
+ * lifecycle control. The per-entity pattern (a sandbox per user, a room per
82
+ * game, a job runner per id) often needs to tear down or inspect the instance
83
+ * rather than wait for `sleepAfter`, so these wrap the container DO's
84
+ * `start`/`stop`/`destroy`/`getState`.
85
+ * @experimental
86
+ */
87
87
  interface ContainerInstanceHandle extends ContainerHandle {
88
88
  /** Stop and discard the instance (its ephemeral disk is lost). */
89
89
  destroy: () => Promise<void>;
90
90
  /**
91
- * Adjust this instance's egress allow/deny lists at runtime — the dynamic
92
- * counterpart to the static `allowedHosts`/`deniedHosts` config. Useful for
93
- * per-tenant egress policy. Requires the worker to export `ContainerProxy`
94
- * (codegen re-exports it from the generated container file whenever any
95
- * container is defined, so the runtime controls always work).
96
- */
91
+ * Adjust this instance's egress allow/deny lists at runtime — the dynamic
92
+ * counterpart to the static `allowedHosts`/`deniedHosts` config. Useful for
93
+ * per-tenant egress policy. Requires the worker to export `ContainerProxy`
94
+ * (codegen re-exports it from the generated container file whenever any
95
+ * container is defined, so the runtime controls always work).
96
+ */
97
97
  egress: ContainerEgressControls;
98
98
  /** Read the instance's current runtime state. */
99
99
  getState: () => Promise<ContainerInstanceState>;
100
100
  /**
101
- * Reset the instance's `sleepAfter` idle timer. The platform renews it on
102
- * each proxied request, and because `@lunora/container` proxies WebSocket
103
- * frames through the Durable Object, message traffic on an open socket
104
- * renews it too (the WebSocket-keepalive gap of cloudflare/containers#147 is
105
- * closed in the bundled base). This manual control is the escape hatch for
106
- * keeping a container awake during activity that is neither an HTTP request
107
- * nor a WS message — e.g. a long out-of-band job running inside it.
108
- */
101
+ * Reset the instance's `sleepAfter` idle timer. The platform renews it on
102
+ * each proxied request, and because `@lunora/container` proxies WebSocket
103
+ * frames through the Durable Object, message traffic on an open socket
104
+ * renews it too (the WebSocket-keepalive gap of cloudflare/containers#147 is
105
+ * closed in the bundled base). This manual control is the escape hatch for
106
+ * keeping a container awake during activity that is neither an HTTP request
107
+ * nor a WS message — e.g. a long out-of-band job running inside it.
108
+ */
109
109
  renewActivityTimeout: () => Promise<void>;
110
110
  /** Explicitly start the instance, optionally with per-instance env/entrypoint. */
111
111
  start: (options?: ContainerStartOptions) => Promise<void>;
@@ -113,12 +113,12 @@ interface ContainerInstanceHandle extends ContainerHandle {
113
113
  stop: (signal?: number | string) => Promise<void>;
114
114
  }
115
115
  /**
116
- * Runtime egress-firewall controls for a named instance (`handle.egress.*`).
117
- * Each maps to the corresponding `@cloudflare/containers` `Container` RPC, so
118
- * an app can tighten or relax a single instance's allowed/denied hosts after
119
- * start without redeploying.
120
- * @experimental
121
- */
116
+ * Runtime egress-firewall controls for a named instance (`handle.egress.*`).
117
+ * Each maps to the corresponding `@cloudflare/containers` `Container` RPC, so
118
+ * an app can tighten or relax a single instance's allowed/denied hosts after
119
+ * start without redeploying.
120
+ * @experimental
121
+ */
122
122
  interface ContainerEgressControls {
123
123
  /** Add one hostname (or glob) to the allow-list. */
124
124
  allow: (hostname: string) => Promise<void>;
@@ -134,85 +134,85 @@ interface ContainerEgressControls {
134
134
  setDenied: (hosts: ReadonlyArray<string>) => Promise<void>;
135
135
  }
136
136
  /**
137
- * The per-definition accessor exposed as `ctx.containers.&lt;exportName>`.
138
- * @experimental
139
- */
137
+ * The per-definition accessor exposed as `ctx.containers.&lt;exportName>`.
138
+ * @experimental
139
+ */
140
140
  interface ContainerAccessor {
141
141
  /**
142
- * A random instance from a fixed pool of `count` (defaults to the
143
- * definition's `maxInstances`, else 3 — mirroring `getRandom` from
144
- * `@cloudflare/containers`). For stateless, interchangeable workloads.
145
- *
146
- * Like `.get()`, a path/URL-string fetch transparently retries the
147
- * cold-start "instance is provisioning" transients (cloudflare/containers#45,
148
- * #139); pass {@link InstanceRetryOptions} to tune or disable it.
149
- */
142
+ * A random instance from a fixed pool of `count` (defaults to the
143
+ * definition's `maxInstances`, else 3 — mirroring `getRandom` from
144
+ * `@cloudflare/containers`). For stateless, interchangeable workloads.
145
+ *
146
+ * Like `.get()`, a path/URL-string fetch transparently retries the
147
+ * cold-start "instance is provisioning" transients (cloudflare/containers#45,
148
+ * #139); pass {@link InstanceRetryOptions} to tune or disable it.
149
+ */
150
150
  any: (count?: number, options?: InstanceRetryOptions) => ContainerHandle;
151
151
  /**
152
- * The instance for `name` — one container per entity (user, room, job…),
153
- * with lifecycle control.
154
- *
155
- * A path/URL-string fetch transparently retries the platform's cold-start
156
- * transients — "there is no Container instance available" / "container is
157
- * not listening" while an instance is still provisioning
158
- * (cloudflare/containers#45, #139) — on the *same* instance with backoff,
159
- * since the request never reached the app. Pass {@link InstanceRetryOptions}
160
- * to tune attempts/backoff or disable it (`{ attempts: 1 }`). A pre-built
161
- * `Request` (possibly a one-shot stream body) is sent once, never retried.
162
- */
152
+ * The instance for `name` — one container per entity (user, room, job…),
153
+ * with lifecycle control.
154
+ *
155
+ * A path/URL-string fetch transparently retries the platform's cold-start
156
+ * transients — "there is no Container instance available" / "container is
157
+ * not listening" while an instance is still provisioning
158
+ * (cloudflare/containers#45, #139) — on the *same* instance with backoff,
159
+ * since the request never reached the app. Pass {@link InstanceRetryOptions}
160
+ * to tune attempts/backoff or disable it (`{ attempts: 1 }`). A pre-built
161
+ * `Request` (possibly a one-shot stream body) is sent once, never retried.
162
+ */
163
163
  get: (name: string, options?: InstanceRetryOptions) => ContainerInstanceHandle;
164
164
  /**
165
- * A resilient handle over the pool: each `fetch` picks a random instance and,
166
- * on a thrown error or a retryable response (5xx by default), retries on a
167
- * freshly-picked instance with exponential backoff. Until Cloudflare ships
168
- * native autoscaling + health-aware routing this is the recommended way to
169
- * call a stateless container pool — it rides over a single cold/unhealthy
170
- * instance instead of failing the whole request.
171
- *
172
- * Because a retry re-issues the request, pass a **replayable** body — a path
173
- * string plus an `init.body` string/`ArrayBuffer` (re-created each attempt).
174
- * A pre-built `Request` carrying a stream body can only be sent once, so it
175
- * is not retry-safe here; use `.get()`/`.any()` for those.
176
- */
165
+ * A resilient handle over the pool: each `fetch` picks a random instance and,
166
+ * on a thrown error or a retryable response (5xx by default), retries on a
167
+ * freshly-picked instance with exponential backoff. Until Cloudflare ships
168
+ * native autoscaling + health-aware routing this is the recommended way to
169
+ * call a stateless container pool — it rides over a single cold/unhealthy
170
+ * instance instead of failing the whole request.
171
+ *
172
+ * Because a retry re-issues the request, pass a **replayable** body — a path
173
+ * string plus an `init.body` string/`ArrayBuffer` (re-created each attempt).
174
+ * A pre-built `Request` carrying a stream body can only be sent once, so it
175
+ * is not retry-safe here; use `.get()`/`.any()` for those.
176
+ */
177
177
  pool: (options?: PoolOptions) => ContainerHandle;
178
178
  }
179
179
  /**
180
- * Tuning for a pooled, retrying container handle. See {@link ContainerAccessor.pool}.
181
- * @experimental
182
- */
180
+ * Tuning for a pooled, retrying container handle. See {@link ContainerAccessor.pool}.
181
+ * @experimental
182
+ */
183
183
  interface PoolOptions {
184
184
  /** Total attempts before giving up (each on a freshly-picked instance). Default 3. */
185
185
  attempts?: number;
186
186
  /** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default 100. */
187
187
  backoffMs?: number;
188
188
  /**
189
- * Upper bound on a single backoff sleep, in ms. The doubling delay is clamped
190
- * to this ceiling so a large `attempts` count can't produce an unboundedly
191
- * long wait. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s).
192
- */
189
+ * Upper bound on a single backoff sleep, in ms. The doubling delay is clamped
190
+ * to this ceiling so a large `attempts` count can't produce an unboundedly
191
+ * long wait. Default {@link DEFAULT_MAX_BACKOFF_MS} (30s).
192
+ */
193
193
  maxBackoffMs?: number;
194
194
  /**
195
- * Whether a *returned* response should be retried on another instance.
196
- * Defaults to retrying any `5xx`. A thrown error (network/start failure) is
197
- * always retried regardless of this predicate.
198
- */
195
+ * Whether a *returned* response should be retried on another instance.
196
+ * Defaults to retrying any `5xx`. A thrown error (network/start failure) is
197
+ * always retried regardless of this predicate.
198
+ */
199
199
  retryOn?: (response: Response) => boolean;
200
200
  /** Pool size to spread picks across. Defaults to the definition's `maxInstances`, else 3. */
201
201
  size?: number;
202
202
  }
203
203
  /**
204
- * Tuning for the cold-start retry on a `.get()`/`.any()` handle. The retry fires
205
- * only on the platform's provisioning transients (no-instance / not-listening /
206
- * rate-limited — see {@link isColdStartTransient}), which is why it's safe by
207
- * default: those responses mean the request never reached the container.
208
- * @experimental
209
- */
204
+ * Tuning for the cold-start retry on a `.get()`/`.any()` handle. The retry fires
205
+ * only on the platform's provisioning transients (no-instance / not-listening /
206
+ * rate-limited — see {@link isColdStartTransient}), which is why it's safe by
207
+ * default: those responses mean the request never reached the container.
208
+ * @experimental
209
+ */
210
210
  interface InstanceRetryOptions {
211
211
  /**
212
- * Total attempts on a cold-start transient before the last outcome is
213
- * surfaced as-is. `1` disables the retry. Default
214
- * {@link DEFAULT_COLD_START_ATTEMPTS}.
215
- */
212
+ * Total attempts on a cold-start transient before the last outcome is
213
+ * surfaced as-is. `1` disables the retry. Default
214
+ * {@link DEFAULT_COLD_START_ATTEMPTS}.
215
+ */
216
216
  attempts?: number;
217
217
  /** Base backoff in ms between attempts; doubles each retry (0 disables the wait). Default {@link DEFAULT_COLD_START_BACKOFF_MS}. */
218
218
  backoffMs?: number;
@@ -220,9 +220,9 @@ interface InstanceRetryOptions {
220
220
  maxBackoffMs?: number;
221
221
  }
222
222
  /**
223
- * Wiring info for one definition, emitted by codegen into the generated DO.
224
- * @experimental
225
- */
223
+ * Wiring info for one definition, emitted by codegen into the generated DO.
224
+ * @experimental
225
+ */
226
226
  interface ContainerBindingSpec {
227
227
  /** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
228
228
  binding: string;
@@ -232,90 +232,90 @@ interface ContainerBindingSpec {
232
232
  maxInstances?: number;
233
233
  }
234
234
  /**
235
- * Build the `ctx.containers` record from the Worker `env`. Called by the
236
- * generated ShardDO with the specs codegen derived from `lunora/containers.ts`.
237
- * A missing binding doesn't throw here — only when the handle is actually used —
238
- * so one unprovisioned container never breaks unrelated functions.
239
- *
240
- * `traceparent` (the inbound RPC's W3C trace context, forwarded by the runtime
241
- * and read off the request by the DO) is stamped onto every outbound container
242
- * `fetch`, so the container's own spans stitch under the Worker's trace.
243
- * @experimental
244
- */
235
+ * Build the `ctx.containers` record from the Worker `env`. Called by the
236
+ * generated ShardDO with the specs codegen derived from `lunora/containers.ts`.
237
+ * A missing binding doesn't throw here — only when the handle is actually used —
238
+ * so one unprovisioned container never breaks unrelated functions.
239
+ *
240
+ * `traceparent` (the inbound RPC's W3C trace context, forwarded by the runtime
241
+ * and read off the request by the DO) is stamped onto every outbound container
242
+ * `fetch`, so the container's own spans stitch under the Worker's trace.
243
+ * @experimental
244
+ */
245
245
  declare const createContainerContext: (env: Record<string, unknown>, specs: ReadonlyArray<ContainerBindingSpec>, jurisdiction?: DurableObjectJurisdiction, traceparent?: string) => Record<string, ContainerAccessor>;
246
246
  /**
247
- * A test handler: receives the request plus the targeted instance name.
248
- * @experimental
249
- */
247
+ * A test handler: receives the request plus the targeted instance name.
248
+ * @experimental
249
+ */
250
250
  type ContainerTestHandler = (request: Request, instance: {
251
251
  name: string;
252
252
  }) => Promise<Response> | Response;
253
253
  /**
254
- * Docker-free test double for `ctx.containers`: each export name maps to a
255
- * fetch handler that plays the container. Mirrors the real shape exactly, so
256
- * action handlers under test can't tell the difference.
257
- *
258
- * ```ts
259
- * const containers = createContainerTestContext({
260
- * transcoder: (request) => new Response("ok"),
261
- * });
262
- * ```
263
- * @experimental
264
- */
254
+ * Docker-free test double for `ctx.containers`: each export name maps to a
255
+ * fetch handler that plays the container. Mirrors the real shape exactly, so
256
+ * action handlers under test can't tell the difference.
257
+ *
258
+ * ```ts
259
+ * const containers = createContainerTestContext({
260
+ * transcoder: (request) => new Response("ok"),
261
+ * });
262
+ * ```
263
+ * @experimental
264
+ */
265
265
  declare const createContainerTestContext: (handlers: Record<string, ContainerTestHandler>) => Record<string, ContainerAccessor>;
266
266
  /**
267
- * Normalize a `ContainerImageSource` into the shape wrangler wants: a
268
- * Dockerfile path + build context for local builds, or a fully-qualified
269
- * reference for pre-built images.
270
- *
271
- * A local-path string whose basename starts with `Dockerfile` (so
272
- * `Dockerfile.dev` also counts) is used as-is with its directory as the build
273
- * context; any other path is treated as the build-context directory and the
274
- * Dockerfile is expected at `&lt;dir>/Dockerfile`.
275
- * @experimental
276
- */
267
+ * Normalize a `ContainerImageSource` into the shape wrangler wants: a
268
+ * Dockerfile path + build context for local builds, or a fully-qualified
269
+ * reference for pre-built images.
270
+ *
271
+ * A local-path string whose basename starts with `Dockerfile` (so
272
+ * `Dockerfile.dev` also counts) is used as-is with its directory as the build
273
+ * context; any other path is treated as the build-context directory and the
274
+ * Dockerfile is expected at `&lt;dir>/Dockerfile`.
275
+ * @experimental
276
+ */
277
277
  declare const normalizeContainerImage: (image: ContainerImageSource) => NormalizedContainerImage;
278
278
  /**
279
- * The generated Container DO class name for a `lunora/containers.ts` export:
280
- * `transcoder` → `TranscoderContainer`. wrangler's `containers[].class_name`
281
- * and the Durable Object binding's `class_name` both reference it, so codegen
282
- * and the config layer MUST derive it identically — always via this helper.
283
- * @experimental
284
- */
279
+ * The generated Container DO class name for a `lunora/containers.ts` export:
280
+ * `transcoder` → `TranscoderContainer`. wrangler's `containers[].class_name`
281
+ * and the Durable Object binding's `class_name` both reference it, so codegen
282
+ * and the config layer MUST derive it identically — always via this helper.
283
+ * @experimental
284
+ */
285
285
  declare const containerClassName: (exportName: string) => string;
286
286
  /**
287
- * The Durable Object binding name for a container export: `transcoder` →
288
- * `CONTAINER_TRANSCODER`, `imageResizer` → `CONTAINER_IMAGE_RESIZER`. The
289
- * `CONTAINER_` prefix namespaces these away from `SHARD`/`SESSION`/`SCHEDULER`
290
- * so a container export can never collide with the built-in bindings.
291
- * @experimental
292
- */
287
+ * The Durable Object binding name for a container export: `transcoder` →
288
+ * `CONTAINER_TRANSCODER`, `imageResizer` → `CONTAINER_IMAGE_RESIZER`. The
289
+ * `CONTAINER_` prefix namespaces these away from `SHARD`/`SESSION`/`SCHEDULER`
290
+ * so a container export can never collide with the built-in bindings.
291
+ * @experimental
292
+ */
293
293
  declare const containerBindingName: (exportName: string) => string;
294
294
  /**
295
- * The local image tag a Railpack `{ build }` container is built and pushed
296
- * under: `transcoder` → `lunora-transcoder:build`. The config reconciler writes
297
- * it as the wrangler `containers[].image`, and `lunora deploy` builds that tag
298
- * with Railpack and `wrangler containers push`es it before deploying — so all
299
- * three derive the tag from this one helper and can never disagree.
300
- * @experimental
301
- */
295
+ * The local image tag a Railpack `{ build }` container is built and pushed
296
+ * under: `transcoder` → `lunora-transcoder:build`. The config reconciler writes
297
+ * it as the wrangler `containers[].image`, and `lunora deploy` builds that tag
298
+ * with Railpack and `wrangler containers push`es it before deploying — so all
299
+ * three derive the tag from this one helper and can never disagree.
300
+ * @experimental
301
+ */
302
302
  declare const containerBuildTag: (exportName: string) => string;
303
303
  /**
304
- * `defineContainer` is part of the experimental `@lunora/container` API and may change without a major version bump.
305
- * @experimental
306
- */
304
+ * `defineContainer` is part of the experimental `@lunora/container` API and may change without a major version bump.
305
+ * @experimental
306
+ */
307
307
  declare const defineContainer: (config: ContainerConfig) => ContainerDefinition;
308
308
  /**
309
- * True when a value is a `defineContainer` result (the runtime brand check).
310
- * @experimental
311
- */
309
+ * True when a value is a `defineContainer` result (the runtime brand check).
310
+ * @experimental
311
+ */
312
312
  declare const isContainerDefinition: (value: unknown) => value is ContainerDefinition;
313
313
  /**
314
- * The container's full environment at instance start: the static `env` block
315
- * plus every declared secret resolved from the Worker `env`. A declared secret
316
- * missing from the Worker env fails fast — starting the container without a
317
- * credential it was promised yields far worse errors downstream.
318
- * @experimental
319
- */
314
+ * The container's full environment at instance start: the static `env` block
315
+ * plus every declared secret resolved from the Worker `env`. A declared secret
316
+ * missing from the Worker env fails fast — starting the container without a
317
+ * credential it was promised yields far worse errors downstream.
318
+ * @experimental
319
+ */
320
320
  declare const resolveContainerEnvVariables: (definition: ContainerDefinition, workerEnv: Record<string, unknown>, exportName?: string) => Record<string, string>;
321
321
  export { type ContainerAccessor, type ContainerBindingSpec, type ContainerConfig, type ContainerDefinition, type ContainerEgressControls, type ContainerHandle, type ContainerImageSource, type ContainerInstanceHandle, type ContainerInstanceState, type ContainerNamespaceLike, type ContainerStartOptions, type ContainerTestHandler, type DurableObjectJurisdiction, type InstanceRetryOptions, type NormalizedContainerImage, type PoolOptions, containerBindingName, containerBuildTag, containerClassName, createContainerContext, createContainerTestContext, defineContainer, isContainerDefinition, normalizeContainerImage, resolveContainerEnvVariables as resolveContainerEnvVars };
package/dist/otel.d.mts CHANGED
@@ -1,16 +1,16 @@
1
1
  /**
2
- * An attribute value carried on a span or log.
3
- * @experimental
4
- */
2
+ * An attribute value carried on a span or log.
3
+ * @experimental
4
+ */
5
5
  type ContainerAttributeValue = boolean | number | string;
6
6
  /**
7
- * A `fetch` implementation — defaults to the runtime global. The exporter passes
8
- * an abort `signal` (for the per-request timeout) and, once the promise settles,
9
- * cancels the response `body` so Node/undici can release the socket for
10
- * keep-alive reuse instead of leaving it occupied by an unread stream. It reads
11
- * `ok`/`status` to detect a rejected export and nothing else from the response.
12
- * @experimental
13
- */
7
+ * A `fetch` implementation — defaults to the runtime global. The exporter passes
8
+ * an abort `signal` (for the per-request timeout) and, once the promise settles,
9
+ * cancels the response `body` so Node/undici can release the socket for
10
+ * keep-alive reuse instead of leaving it occupied by an unread stream. It reads
11
+ * `ok`/`status` to detect a rejected export and nothing else from the response.
12
+ * @experimental
13
+ */
14
14
  type OtelFetchLike = (input: string, init: {
15
15
  body: string;
16
16
  headers: Record<string, string>;
@@ -24,9 +24,9 @@ type OtelFetchLike = (input: string, init: {
24
24
  status: number;
25
25
  }>;
26
26
  /**
27
- * A single span the container process asks the exporter to record.
28
- * @experimental
29
- */
27
+ * A single span the container process asks the exporter to record.
28
+ * @experimental
29
+ */
30
30
  interface ContainerSpanInput {
31
31
  /** Attributes attached to the span (rendered under the OTLP `attributes` list). */
32
32
  attributes?: Record<string, ContainerAttributeValue>;
@@ -43,9 +43,9 @@ interface ContainerSpanInput {
43
43
  startMs: number;
44
44
  }
45
45
  /**
46
- * A single log line the container process asks the exporter to record.
47
- * @experimental
48
- */
46
+ * A single log line the container process asks the exporter to record.
47
+ * @experimental
48
+ */
49
49
  interface ContainerLogInput {
50
50
  /** Attributes attached to the log record. */
51
51
  attributes?: Record<string, ContainerAttributeValue>;
@@ -57,9 +57,9 @@ interface ContainerLogInput {
57
57
  ts?: number;
58
58
  }
59
59
  /**
60
- * Options for {@link createContainerTelemetry}.
61
- * @experimental
62
- */
60
+ * Options for {@link createContainerTelemetry}.
61
+ * @experimental
62
+ */
63
63
  interface ContainerTelemetryOptions {
64
64
  /** Base OTLP collector endpoint; defaults to the `LUNORA_OTLP_ENDPOINT` env var. */
65
65
  endpoint?: string;
@@ -76,33 +76,33 @@ interface ContainerTelemetryOptions {
76
76
  /** Bearer token sent as an `Authorization: Bearer` header; defaults to the `LUNORA_OTLP_TOKEN` env var. */
77
77
  token?: string;
78
78
  /**
79
- * W3C `traceparent` of the Worker RPC that invoked this container; defaults to
80
- * the `LUNORA_TRACEPARENT` env var. When present (and well-formed) every span
81
- * inherits its trace id and hangs off its span id, so container spans stitch
82
- * under the Worker's trace instead of forming a fresh, disconnected trace.
83
- *
84
- * `@lunora/container` stamps this trace context as the **`traceparent` request
85
- * header** on every proxied fetch (`ctx.containers.&lt;name>.…`), so a container
86
- * that serves many requests should read it per request and create a telemetry
87
- * instance scoped to that request — the trace context differs each call, so a
88
- * single process-lifetime instance can't carry it:
89
- *
90
- * ```ts
91
- * // inside the container's request handler
92
- * const telemetry = createContainerTelemetry({ traceparent: request.headers.get("traceparent") ?? undefined });
93
- * await telemetry.trace("transcode", () => transcode(job));
94
- * await telemetry.flush();
95
- * ```
96
- *
97
- * The `LUNORA_TRACEPARENT` env fallback fits a one-shot container that
98
- * processes a single job per start (the value is fixed for the process).
99
- */
79
+ * W3C `traceparent` of the Worker RPC that invoked this container; defaults to
80
+ * the `LUNORA_TRACEPARENT` env var. When present (and well-formed) every span
81
+ * inherits its trace id and hangs off its span id, so container spans stitch
82
+ * under the Worker's trace instead of forming a fresh, disconnected trace.
83
+ *
84
+ * `@lunora/container` stamps this trace context as the **`traceparent` request
85
+ * header** on every proxied fetch (`ctx.containers.&lt;name>.…`), so a container
86
+ * that serves many requests should read it per request and create a telemetry
87
+ * instance scoped to that request — the trace context differs each call, so a
88
+ * single process-lifetime instance can't carry it:
89
+ *
90
+ * ```ts
91
+ * // inside the container's request handler
92
+ * const telemetry = createContainerTelemetry({ traceparent: request.headers.get("traceparent") ?? undefined });
93
+ * await telemetry.trace("transcode", () => transcode(job));
94
+ * await telemetry.flush();
95
+ * ```
96
+ *
97
+ * The `LUNORA_TRACEPARENT` env fallback fits a one-shot container that
98
+ * processes a single job per start (the value is fixed for the process).
99
+ */
100
100
  traceparent?: string;
101
101
  }
102
102
  /**
103
- * The exporter handle {@link createContainerTelemetry} returns.
104
- * @experimental
105
- */
103
+ * The exporter handle {@link createContainerTelemetry} returns.
104
+ * @experimental
105
+ */
106
106
  interface ContainerTelemetry {
107
107
  /** Record one log line (no-op when disabled). */
108
108
  emitLog: (log: ContainerLogInput) => void;
@@ -116,20 +116,20 @@ interface ContainerTelemetry {
116
116
  trace: <T>(name: string, run: () => Promise<T>, attributes?: Record<string, ContainerAttributeValue>) => Promise<T>;
117
117
  }
118
118
  /**
119
- * Create a zero-config OTLP exporter for the container process.
120
- *
121
- * ```ts
122
- * const telemetry = createContainerTelemetry(); // reads LUNORA_OTLP_ENDPOINT / _TOKEN
123
- * await telemetry.trace("transcode", () => transcode(job), { jobId: job.id });
124
- * telemetry.emitLog({ level: "info", message: "done", attributes: { jobId: job.id } });
125
- * await telemetry.flush(); // before the process exits
126
- * ```
127
- *
128
- * With no endpoint resolvable the returned exporter is disabled (`enabled ===
129
- * false`): `emitSpan`/`emitLog` no-op and `trace` still runs its work but records
130
- * nothing — so the same code runs unchanged locally and in the cloud.
131
- * @param options Exporter options; every field falls back to a `LUNORA_*` env var.
132
- * @experimental
133
- */
119
+ * Create a zero-config OTLP exporter for the container process.
120
+ *
121
+ * ```ts
122
+ * const telemetry = createContainerTelemetry(); // reads LUNORA_OTLP_ENDPOINT / _TOKEN
123
+ * await telemetry.trace("transcode", () => transcode(job), { jobId: job.id });
124
+ * telemetry.emitLog({ level: "info", message: "done", attributes: { jobId: job.id } });
125
+ * await telemetry.flush(); // before the process exits
126
+ * ```
127
+ *
128
+ * With no endpoint resolvable the returned exporter is disabled (`enabled ===
129
+ * false`): `emitSpan`/`emitLog` no-op and `trace` still runs its work but records
130
+ * nothing — so the same code runs unchanged locally and in the cloud.
131
+ * @param options Exporter options; every field falls back to a `LUNORA_*` env var.
132
+ * @experimental
133
+ */
134
134
  declare const createContainerTelemetry: (options?: ContainerTelemetryOptions) => ContainerTelemetry;
135
135
  export { type ContainerAttributeValue, type ContainerLogInput, type ContainerSpanInput, type ContainerTelemetry, type ContainerTelemetryOptions, type OtelFetchLike, createContainerTelemetry };