@moinulmoin/eden-runtime-cloudflare 0.5.0 → 0.6.0
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/NOTICE +0 -9
- package/dist/eden-eve-host-worker.mjs +381 -1743
- package/dist/eve-host-runtime.d.ts +75 -53
- package/dist/eve-host-runtime.js +299 -186
- package/dist/eve-host.d.ts +24 -26
- package/dist/eve-host.js +108 -99
- package/package.json +3 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
|
|
2
2
|
import { type EveHostContainerEnvironment, type EveHostForwardingMetadata, type EveHostReadinessEvidence, type EveScheduleCronEntry } from "./eve-host.js";
|
|
3
|
-
export { ContainerProxy };
|
|
4
3
|
/** The deployment's single SQLite-backed Workflow World. */
|
|
5
4
|
export declare class EdenWorldDurableObject {
|
|
6
5
|
private readonly core;
|
|
@@ -9,13 +8,16 @@ export declare class EdenWorldDurableObject {
|
|
|
9
8
|
alarm(): Promise<void>;
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
|
-
* Delivers the container's own HTTPS requests to its public workers.dev
|
|
13
|
-
* back into the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
11
|
+
* Delivers the container's own HTTPS requests to its public workers.dev
|
|
12
|
+
* origin back into the deployment without crossing the public edge. The
|
|
13
|
+
* Workflow local World posts queue deliveries to `WORKFLOW_LOCAL_BASE_URL`,
|
|
14
|
+
* which must remain the public origin so Eve's externally visible callback
|
|
15
|
+
* URLs stay correct; the DO registers an outbound-HTTPS intercept for that
|
|
16
|
+
* hostname aimed at `EveHostLoopback`, and this function routes the request:
|
|
17
|
+
* non-public hosts egress plainly, `/__eden/world/rpc` reaches the World
|
|
18
|
+
* Durable Object, and everything else re-enters the container over the
|
|
19
|
+
* internal port so the public Worker path can keep refusing the
|
|
20
|
+
* unauthenticated queue endpoints.
|
|
19
21
|
*/
|
|
20
22
|
export declare function routeEveOutboundRequest(request: Request, env: EveHostContainerEnvironment): Promise<Response>;
|
|
21
23
|
/**
|
|
@@ -24,63 +26,83 @@ export declare function routeEveOutboundRequest(request: Request, env: EveHostCo
|
|
|
24
26
|
* package's public declaration surface, so plain-Node consumers never load
|
|
25
27
|
* `cloudflare:workers`-dependent code.
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The WorkerEntrypoint the container's intercepted outbound HTTPS traffic is
|
|
31
|
+
* delivered to (registered by `EveHostDurableContainer` right after every
|
|
32
|
+
* `ctx.container.start()`). Props carry the DO instance name because
|
|
33
|
+
* entrypoint props cannot hold a Fetcher.
|
|
34
|
+
*/
|
|
35
|
+
export declare class EveHostLoopback extends WorkerEntrypoint<EveHostContainerEnvironment> {
|
|
36
|
+
fetch(request: Request): Promise<Response>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The Eve host Durable Object. It drives `ctx.container` directly: the
|
|
40
|
+
* image is selected at `start()` from this Worker version's `images.eve`
|
|
41
|
+
* entry, the writable filesystem is preserved across sleep via a container
|
|
42
|
+
* snapshot, and an update restarts the instance when `inspect()` shows the
|
|
43
|
+
* running image predates the configured one.
|
|
44
|
+
*/
|
|
45
|
+
export declare class EveHostDurableContainer extends DurableObject<EveHostContainerEnvironment> {
|
|
35
46
|
readonly lifecycle: import("./eve-host.js").EveHostLifecycleObserver;
|
|
36
47
|
private readinessStarted;
|
|
37
|
-
/** Evidence is cached only
|
|
48
|
+
/** Evidence is cached only while the container it was proven on keeps running. */
|
|
38
49
|
private readinessEvidence;
|
|
50
|
+
/** True once the running container's image was proven to equal `images.eve`. */
|
|
51
|
+
private imageVerified;
|
|
39
52
|
/**
|
|
40
53
|
* Bumped whenever the Container stops or is reset. Readiness work captures
|
|
41
|
-
* the epoch it started under and may only
|
|
42
|
-
*
|
|
54
|
+
* the epoch it started under and may only cache evidence if no stop
|
|
55
|
+
* happened in between.
|
|
43
56
|
*/
|
|
44
57
|
private readinessEpoch;
|
|
58
|
+
private monitorAttached;
|
|
59
|
+
private readonly envVars;
|
|
60
|
+
private readonly sleepAfterMs;
|
|
45
61
|
private readonly readiness;
|
|
46
|
-
constructor(ctx:
|
|
62
|
+
constructor(ctx: DurableObjectState, env: EveHostContainerEnvironment);
|
|
63
|
+
private containerRuntime;
|
|
64
|
+
/** Container lifetime the platform keeps after the DO goes inactive. */
|
|
65
|
+
private get inactivityTimeoutMs();
|
|
66
|
+
private attachMonitor;
|
|
67
|
+
private recordContainerStopped;
|
|
68
|
+
/** Routes the container's own requests to its public origin back inside. */
|
|
69
|
+
private registerLoopbackIntercept;
|
|
47
70
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* stale Durable Object still detects the update because the header is
|
|
52
|
-
* stamped by new Worker code, not this code's environment.
|
|
53
|
-
*
|
|
54
|
-
* DO-managed Container instances are excluded from the application's fleet
|
|
55
|
-
* rollout — the image is only re-selected on the next
|
|
56
|
-
* `ctx.container.start()` — so an update must stop the instance itself.
|
|
57
|
-
* A missing marker means the running image cannot be trusted, so the
|
|
58
|
-
* container is restarted too (first update from runtimes that predate the
|
|
59
|
-
* marker). Restarts are rate-limited because Cloudflare activates a new
|
|
60
|
-
* Worker before the image rollout lands; starting in that window would
|
|
61
|
-
* re-launch the *old* image, so the deployment marker is only recorded
|
|
62
|
-
* after `inspect()` proves the running image is the expected one.
|
|
71
|
+
* Records request activity and arms the sleep alarm at
|
|
72
|
+
* `lastActivityAt + sleepAfter`. The alarm — not the inactivity timeout —
|
|
73
|
+
* is what snapshots the writable filesystem before the container stops.
|
|
63
74
|
*/
|
|
64
|
-
private
|
|
65
|
-
private containerServesImage;
|
|
75
|
+
private touchActivity;
|
|
66
76
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* When the Worker stamps no image, the marker is recorded unverified,
|
|
73
|
-
* matching pre-drift behavior.
|
|
77
|
+
* Starts the container when it is not running. A stored workspace snapshot
|
|
78
|
+
* is restored only when it was captured from the exact image this Worker
|
|
79
|
+
* version configures — restoring an older snapshot silently runs the
|
|
80
|
+
* previous image — so after an image update the container starts fresh and
|
|
81
|
+
* workspace files intentionally do not carry across.
|
|
74
82
|
*/
|
|
75
|
-
private
|
|
76
|
-
|
|
83
|
+
private ensureContainerStarted;
|
|
84
|
+
/**
|
|
85
|
+
* Replaces the running container when `inspect()` proves it still serves a
|
|
86
|
+
* pre-update image: this Worker version's `images.eve` is selected at
|
|
87
|
+
* `start()`, so an in-place update must stop the stale instance itself.
|
|
88
|
+
*/
|
|
89
|
+
private reconcileRunningImage;
|
|
90
|
+
ensureEveReady(signal?: AbortSignal): Promise<EveHostReadinessEvidence>;
|
|
77
91
|
fetch(request: Request): Promise<Response>;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Queue deliveries and loopback traffic enter here: same readiness and
|
|
94
|
+
* forwarding as `fetch` without the deployment-header echo rules (the
|
|
95
|
+
* loopback path is not a deployment-health signal).
|
|
96
|
+
*/
|
|
97
|
+
loopbackFetch(request: Request): Promise<Response>;
|
|
98
|
+
/**
|
|
99
|
+
* The idle-sleep path: once the container has been quiet for `sleepAfter`,
|
|
100
|
+
* snapshot the writable filesystem (so `/workspace` survives the sleep)
|
|
101
|
+
* and destroy the instance. A snapshot failure retries up to
|
|
102
|
+
* `EVE_HOST_SNAPSHOT_MAX_ATTEMPTS` times, then destroys anyway so billing
|
|
103
|
+
* for the running container stops.
|
|
104
|
+
*/
|
|
105
|
+
alarm(): Promise<void>;
|
|
84
106
|
}
|
|
85
107
|
export type EveHostWorkerEnvironment = EveHostContainerEnvironment;
|
|
86
108
|
export interface EveHostWorkerOptions extends EveHostForwardingMetadata {
|