@moinulmoin/eden-runtime-cloudflare 0.4.1 → 0.5.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/dist/eden-eve-host-worker.mjs +150 -10
- package/dist/eve-host-runtime.d.ts +37 -1
- package/dist/eve-host-runtime.js +181 -8
- package/dist/eve-host.d.ts +31 -12
- package/dist/eve-host.js +64 -25
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -25453,13 +25453,13 @@ var EVE_HOST_OWNED_HEADERS = [
|
|
|
25453
25453
|
"x-eden-eve-callback-base",
|
|
25454
25454
|
"x-eden-eve-deployment-id",
|
|
25455
25455
|
"x-eden-eve-generation-id",
|
|
25456
|
+
"x-eden-eve-image",
|
|
25457
|
+
"x-eden-eve-started-deployment",
|
|
25456
25458
|
"x-eden-eve-public-origin",
|
|
25457
25459
|
"x-eden-eve-correlation-id",
|
|
25458
25460
|
"x-eden-eve-container-name",
|
|
25459
25461
|
"x-eden-eve-container-id",
|
|
25460
25462
|
"x-eden-eve-runtime-revision",
|
|
25461
|
-
"x-eden-deployment-id",
|
|
25462
|
-
"x-eden-generation-id",
|
|
25463
25463
|
"x-eden-container-name",
|
|
25464
25464
|
"x-eden-container-id",
|
|
25465
25465
|
"cf-container-target-port"
|
|
@@ -25556,6 +25556,9 @@ function createTrustedEveRequest(request, metadata) {
|
|
|
25556
25556
|
headers.set("x-eden-eve-deployment-id", metadata.deploymentId);
|
|
25557
25557
|
headers.set("x-eden-eve-generation-id", metadata.generationId);
|
|
25558
25558
|
headers.set("x-eden-eve-correlation-id", metadata.correlationId);
|
|
25559
|
+
if (metadata.containerImage !== void 0) {
|
|
25560
|
+
headers.set("x-eden-eve-image", metadata.containerImage);
|
|
25561
|
+
}
|
|
25559
25562
|
if (metadata.runtimeRevisionHandle !== void 0) {
|
|
25560
25563
|
headers.set(
|
|
25561
25564
|
"x-eden-eve-runtime-revision",
|
|
@@ -25909,6 +25912,11 @@ async function routeEveOutboundRequest(request, env) {
|
|
|
25909
25912
|
}
|
|
25910
25913
|
return namespace.getByName(instanceName).containerFetch(request, EVE_HOST_DEFAULTS.internalPort);
|
|
25911
25914
|
}
|
|
25915
|
+
var EVE_HOST_CONTAINER_DEPLOYMENT_KEY = "eden.eve.host.started-deployment";
|
|
25916
|
+
var EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY = "eden.eve.host.restart-attempted-at";
|
|
25917
|
+
function containerRepositoryName(image) {
|
|
25918
|
+
return (image.split("@")[0] ?? "").split(":")[0] ?? "";
|
|
25919
|
+
}
|
|
25912
25920
|
var EveHostContainer = class extends Container {
|
|
25913
25921
|
defaultPort = EVE_HOST_DEFAULTS.internalPort;
|
|
25914
25922
|
sleepAfter = EVE_HOST_DEFAULTS.sleepAfter;
|
|
@@ -25918,7 +25926,14 @@ var EveHostContainer = class extends Container {
|
|
|
25918
25926
|
pingEndpoint = "localhost/eve/v1/health";
|
|
25919
25927
|
lifecycle = createEveHostLifecycleObserver();
|
|
25920
25928
|
readinessStarted = false;
|
|
25929
|
+
/** Evidence is cached only under the deployment whose image was verified. */
|
|
25921
25930
|
readinessEvidence;
|
|
25931
|
+
/**
|
|
25932
|
+
* Bumped whenever the Container stops or is reset. Readiness work captures
|
|
25933
|
+
* the epoch it started under and may only record a marker or cache
|
|
25934
|
+
* evidence if no stop happened in between.
|
|
25935
|
+
*/
|
|
25936
|
+
readinessEpoch = 0;
|
|
25922
25937
|
readiness;
|
|
25923
25938
|
constructor(ctx, env) {
|
|
25924
25939
|
super(ctx, env);
|
|
@@ -25933,7 +25948,6 @@ var EveHostContainer = class extends Container {
|
|
|
25933
25948
|
}
|
|
25934
25949
|
assertStableOrigin(publicOrigin);
|
|
25935
25950
|
assertNonEmpty(deploymentId, "deployment identity");
|
|
25936
|
-
assertNonEmpty(generationId, "generation identity");
|
|
25937
25951
|
const runtimeEnv = readProtectedRuntimeVariables(env);
|
|
25938
25952
|
this.envVars = {
|
|
25939
25953
|
...runtimeEnv,
|
|
@@ -25963,22 +25977,136 @@ var EveHostContainer = class extends Container {
|
|
|
25963
25977
|
healthFetch: (request) => this.containerFetch(request, EVE_HOST_DEFAULTS.internalPort)
|
|
25964
25978
|
});
|
|
25965
25979
|
}
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
25980
|
+
/**
|
|
25981
|
+
* Compares the deployment the running Container was started under (stored
|
|
25982
|
+
* in Durable Object storage, which survives Worker redeploys) against the
|
|
25983
|
+
* deployment the *current* Worker stamps on the forwarded request. A
|
|
25984
|
+
* stale Durable Object still detects the update because the header is
|
|
25985
|
+
* stamped by new Worker code, not this code's environment.
|
|
25986
|
+
*
|
|
25987
|
+
* DO-managed Container instances are excluded from the application's fleet
|
|
25988
|
+
* rollout — the image is only re-selected on the next
|
|
25989
|
+
* `ctx.container.start()` — so an update must stop the instance itself.
|
|
25990
|
+
* A missing marker means the running image cannot be trusted, so the
|
|
25991
|
+
* container is restarted too (first update from runtimes that predate the
|
|
25992
|
+
* marker). Restarts are rate-limited because Cloudflare activates a new
|
|
25993
|
+
* Worker before the image rollout lands; starting in that window would
|
|
25994
|
+
* re-launch the *old* image, so the deployment marker is only recorded
|
|
25995
|
+
* after `inspect()` proves the running image is the expected one.
|
|
25996
|
+
*/
|
|
25997
|
+
async reconcileStartedDeployment(requestDeploymentId, requestImage) {
|
|
25998
|
+
if (requestDeploymentId === void 0) return;
|
|
25999
|
+
const storage = this.ctx?.storage;
|
|
26000
|
+
if (storage === void 0 || typeof storage.get !== "function" || typeof storage.put !== "function") {
|
|
26001
|
+
return;
|
|
26002
|
+
}
|
|
26003
|
+
const lastStarted = await storage.get(
|
|
26004
|
+
EVE_HOST_CONTAINER_DEPLOYMENT_KEY
|
|
26005
|
+
);
|
|
26006
|
+
if (lastStarted === requestDeploymentId) return;
|
|
26007
|
+
const runtime = this.ctx?.container;
|
|
26008
|
+
if (runtime?.running !== true) return;
|
|
26009
|
+
if (requestImage !== void 0 && await this.containerServesImage(runtime, requestImage) === true) {
|
|
26010
|
+
await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
|
|
26011
|
+
return;
|
|
26012
|
+
}
|
|
26013
|
+
const attemptedAt = await storage.get(
|
|
26014
|
+
EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY
|
|
26015
|
+
);
|
|
26016
|
+
const now = Date.now();
|
|
26017
|
+
if (attemptedAt !== void 0 && now - attemptedAt < 3e4) return;
|
|
26018
|
+
await storage.put(EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY, now);
|
|
26019
|
+
this.lifecycle.record("replaced");
|
|
26020
|
+
this.readinessEpoch += 1;
|
|
26021
|
+
this.readinessStarted = false;
|
|
26022
|
+
this.readinessEvidence = void 0;
|
|
26023
|
+
this.readiness.reset();
|
|
26024
|
+
await this.stop();
|
|
26025
|
+
const stoppedAt = Date.now();
|
|
26026
|
+
while (runtime.running && Date.now() - stoppedAt < 1e4) {
|
|
26027
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
26028
|
+
}
|
|
26029
|
+
}
|
|
26030
|
+
async containerServesImage(runtime, expectedImage) {
|
|
26031
|
+
const inspect = runtime.inspect;
|
|
26032
|
+
if (typeof inspect !== "function") return void 0;
|
|
26033
|
+
let info;
|
|
26034
|
+
try {
|
|
26035
|
+
info = await inspect.call(runtime);
|
|
26036
|
+
} catch {
|
|
26037
|
+
return void 0;
|
|
26038
|
+
}
|
|
26039
|
+
if (info?.image === void 0) return void 0;
|
|
26040
|
+
return containerRepositoryName(info.image) === containerRepositoryName(expectedImage);
|
|
26041
|
+
}
|
|
26042
|
+
/**
|
|
26043
|
+
* Records the started deployment only when the running Container provably
|
|
26044
|
+
* serves this deployment's image (`inspect()` matches the forwarded
|
|
26045
|
+
* `x-eden-eve-image`). `false` or unknown (no `inspect`, a throwing call,
|
|
26046
|
+
* or no image field) never records — a start inside the
|
|
26047
|
+
* Worker-active-before-image-rollout window must not pin the old image.
|
|
26048
|
+
* When the Worker stamps no image, the marker is recorded unverified,
|
|
26049
|
+
* matching pre-drift behavior.
|
|
26050
|
+
*/
|
|
26051
|
+
async recordStartedDeployment(requestDeploymentId, requestImage) {
|
|
26052
|
+
if (requestDeploymentId === void 0) return true;
|
|
26053
|
+
const storage = this.ctx?.storage;
|
|
26054
|
+
if (storage === void 0 || typeof storage.get !== "function" || typeof storage.put !== "function") {
|
|
26055
|
+
return true;
|
|
26056
|
+
}
|
|
26057
|
+
const runtime = this.ctx?.container;
|
|
26058
|
+
if (requestImage !== void 0) {
|
|
26059
|
+
if (runtime?.running !== true) {
|
|
26060
|
+
this.lifecycle.record("image_mismatch");
|
|
26061
|
+
return false;
|
|
26062
|
+
}
|
|
26063
|
+
const verified = await this.containerServesImage(runtime, requestImage);
|
|
26064
|
+
if (verified !== true) {
|
|
26065
|
+
this.lifecycle.record("image_mismatch");
|
|
26066
|
+
return false;
|
|
26067
|
+
}
|
|
26068
|
+
}
|
|
26069
|
+
await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
|
|
26070
|
+
return true;
|
|
26071
|
+
}
|
|
26072
|
+
async ensureEveReady(signal = new AbortController().signal, requestDeploymentId, requestImage) {
|
|
26073
|
+
await this.reconcileStartedDeployment(requestDeploymentId, requestImage);
|
|
26074
|
+
if (this.readinessEvidence !== void 0 && this.readinessEvidence.deploymentId === requestDeploymentId) {
|
|
26075
|
+
return this.readinessEvidence.evidence;
|
|
25969
26076
|
}
|
|
25970
26077
|
if (!this.readinessStarted) {
|
|
25971
26078
|
this.readinessStarted = true;
|
|
25972
26079
|
this.lifecycle.record("start_requested");
|
|
25973
26080
|
}
|
|
26081
|
+
const epoch = this.readinessEpoch;
|
|
25974
26082
|
const evidence = await this.readiness(signal);
|
|
25975
|
-
this.
|
|
26083
|
+
if (epoch === this.readinessEpoch && await this.recordStartedDeployment(requestDeploymentId, requestImage) && epoch === this.readinessEpoch) {
|
|
26084
|
+
this.readinessEvidence = {
|
|
26085
|
+
deploymentId: requestDeploymentId,
|
|
26086
|
+
evidence
|
|
26087
|
+
};
|
|
26088
|
+
}
|
|
25976
26089
|
this.lifecycle.record("health_ready", evidence.healthStatus);
|
|
25977
26090
|
return evidence;
|
|
25978
26091
|
}
|
|
25979
26092
|
async fetch(request) {
|
|
25980
|
-
|
|
25981
|
-
|
|
26093
|
+
const requestDeploymentId = request.headers.get("x-eden-eve-deployment-id") ?? void 0;
|
|
26094
|
+
await this.ensureEveReady(
|
|
26095
|
+
request.signal,
|
|
26096
|
+
requestDeploymentId,
|
|
26097
|
+
request.headers.get("x-eden-eve-image") ?? void 0
|
|
26098
|
+
);
|
|
26099
|
+
const response = await super.fetch(request);
|
|
26100
|
+
if (this.readinessEvidence !== void 0 && this.readinessEvidence.deploymentId === requestDeploymentId && requestDeploymentId !== void 0) {
|
|
26101
|
+
const headers = new Headers(response.headers);
|
|
26102
|
+
headers.set("x-eden-eve-started-deployment", requestDeploymentId);
|
|
26103
|
+
return new Response(response.body, {
|
|
26104
|
+
status: response.status,
|
|
26105
|
+
statusText: response.statusText,
|
|
26106
|
+
headers
|
|
26107
|
+
});
|
|
26108
|
+
}
|
|
26109
|
+
return response;
|
|
25982
26110
|
}
|
|
25983
26111
|
onStart() {
|
|
25984
26112
|
if (this.lifecycle.events.some((event) => event.type === "started")) {
|
|
@@ -25987,12 +26115,14 @@ var EveHostContainer = class extends Container {
|
|
|
25987
26115
|
this.lifecycle.record("started");
|
|
25988
26116
|
}
|
|
25989
26117
|
onStop(params) {
|
|
26118
|
+
this.readinessEpoch += 1;
|
|
25990
26119
|
this.readinessStarted = false;
|
|
25991
26120
|
this.readinessEvidence = void 0;
|
|
25992
26121
|
this.readiness.reset();
|
|
25993
26122
|
this.lifecycle.record("stopped", `${params.reason}:${params.exitCode}`);
|
|
25994
26123
|
}
|
|
25995
26124
|
onError(error61) {
|
|
26125
|
+
this.readinessEpoch += 1;
|
|
25996
26126
|
this.readinessStarted = false;
|
|
25997
26127
|
this.readinessEvidence = void 0;
|
|
25998
26128
|
this.readiness.reset();
|
|
@@ -26043,6 +26173,7 @@ function createEveHostWorker(options) {
|
|
|
26043
26173
|
deploymentId: options.deploymentId,
|
|
26044
26174
|
generationId: options.generationId,
|
|
26045
26175
|
correlationId: globalThis.crypto.randomUUID(),
|
|
26176
|
+
...options.containerImage === void 0 ? {} : { containerImage: options.containerImage },
|
|
26046
26177
|
...options.runtimeRevisionHandle === void 0 ? {} : { runtimeRevisionHandle: options.runtimeRevisionHandle }
|
|
26047
26178
|
});
|
|
26048
26179
|
const response = await container.fetch(forwarded);
|
|
@@ -26077,7 +26208,16 @@ function createEveHostWorker(options) {
|
|
|
26077
26208
|
if (!due) return;
|
|
26078
26209
|
ctx.waitUntil(
|
|
26079
26210
|
resolveContainer(env).fetch(new Request(
|
|
26080
|
-
new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin)
|
|
26211
|
+
new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin),
|
|
26212
|
+
{
|
|
26213
|
+
headers: {
|
|
26214
|
+
// Stamp the Worker's own deployment so a stale Durable
|
|
26215
|
+
// Object never falls back to its own environment when
|
|
26216
|
+
// deciding whether to restart the running Container.
|
|
26217
|
+
"x-eden-eve-deployment-id": options.deploymentId,
|
|
26218
|
+
...options.containerImage === void 0 ? {} : { "x-eden-eve-image": options.containerImage }
|
|
26219
|
+
}
|
|
26220
|
+
}
|
|
26081
26221
|
)).catch((error61) => {
|
|
26082
26222
|
console.error(
|
|
26083
26223
|
"The scheduled wake request failed:",
|
|
@@ -34,10 +34,46 @@ export declare class EveHostContainer extends Container<EveHostContainerEnvironm
|
|
|
34
34
|
pingEndpoint: string;
|
|
35
35
|
readonly lifecycle: import("./eve-host.js").EveHostLifecycleObserver;
|
|
36
36
|
private readinessStarted;
|
|
37
|
+
/** Evidence is cached only under the deployment whose image was verified. */
|
|
37
38
|
private readinessEvidence;
|
|
39
|
+
/**
|
|
40
|
+
* Bumped whenever the Container stops or is reset. Readiness work captures
|
|
41
|
+
* the epoch it started under and may only record a marker or cache
|
|
42
|
+
* evidence if no stop happened in between.
|
|
43
|
+
*/
|
|
44
|
+
private readinessEpoch;
|
|
38
45
|
private readonly readiness;
|
|
39
46
|
constructor(ctx: EveHostContainerContext, env: EveHostContainerEnvironment);
|
|
40
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Compares the deployment the running Container was started under (stored
|
|
49
|
+
* in Durable Object storage, which survives Worker redeploys) against the
|
|
50
|
+
* deployment the *current* Worker stamps on the forwarded request. A
|
|
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.
|
|
63
|
+
*/
|
|
64
|
+
private reconcileStartedDeployment;
|
|
65
|
+
private containerServesImage;
|
|
66
|
+
/**
|
|
67
|
+
* Records the started deployment only when the running Container provably
|
|
68
|
+
* serves this deployment's image (`inspect()` matches the forwarded
|
|
69
|
+
* `x-eden-eve-image`). `false` or unknown (no `inspect`, a throwing call,
|
|
70
|
+
* or no image field) never records — a start inside the
|
|
71
|
+
* Worker-active-before-image-rollout window must not pin the old image.
|
|
72
|
+
* When the Worker stamps no image, the marker is recorded unverified,
|
|
73
|
+
* matching pre-drift behavior.
|
|
74
|
+
*/
|
|
75
|
+
private recordStartedDeployment;
|
|
76
|
+
ensureEveReady(signal?: AbortSignal, requestDeploymentId?: string, requestImage?: string): Promise<EveHostReadinessEvidence>;
|
|
41
77
|
fetch(request: Request): Promise<Response>;
|
|
42
78
|
onStart(): void;
|
|
43
79
|
onStop(params: {
|
package/dist/eve-host-runtime.js
CHANGED
|
@@ -112,6 +112,23 @@ export async function routeEveOutboundRequest(request, env) {
|
|
|
112
112
|
.getByName(instanceName)
|
|
113
113
|
.containerFetch(request, EVE_HOST_DEFAULTS.internalPort);
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Durable Object storage key recording which deployment last started the
|
|
117
|
+
* Container. Cloudflare does not roll DO-managed Container instances onto a
|
|
118
|
+
* new image when the Worker redeploys — the image is selected at
|
|
119
|
+
* `ctx.container.start()` — so an in-place update must restart the running
|
|
120
|
+
* instance itself before new code is served.
|
|
121
|
+
*/
|
|
122
|
+
const EVE_HOST_CONTAINER_DEPLOYMENT_KEY = "eden.eve.host.started-deployment";
|
|
123
|
+
/** Restart attempts are rate-limited under this key: during the
|
|
124
|
+
* Worker-active-before-image-rollout window a restart still launches the old
|
|
125
|
+
* image, so retries must wait for the rollout. */
|
|
126
|
+
const EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY = "eden.eve.host.restart-attempted-at";
|
|
127
|
+
/** Compares image references by their generation-scoped repository name so
|
|
128
|
+
* digest and tag spellings of the same pushed image match. */
|
|
129
|
+
function containerRepositoryName(image) {
|
|
130
|
+
return (image.split("@")[0] ?? "").split(":")[0] ?? "";
|
|
131
|
+
}
|
|
115
132
|
export class EveHostContainer extends Container {
|
|
116
133
|
defaultPort = EVE_HOST_DEFAULTS.internalPort;
|
|
117
134
|
sleepAfter = EVE_HOST_DEFAULTS.sleepAfter;
|
|
@@ -121,7 +138,14 @@ export class EveHostContainer extends Container {
|
|
|
121
138
|
pingEndpoint = "localhost/eve/v1/health";
|
|
122
139
|
lifecycle = createEveHostLifecycleObserver();
|
|
123
140
|
readinessStarted = false;
|
|
141
|
+
/** Evidence is cached only under the deployment whose image was verified. */
|
|
124
142
|
readinessEvidence;
|
|
143
|
+
/**
|
|
144
|
+
* Bumped whenever the Container stops or is reset. Readiness work captures
|
|
145
|
+
* the epoch it started under and may only record a marker or cache
|
|
146
|
+
* evidence if no stop happened in between.
|
|
147
|
+
*/
|
|
148
|
+
readinessEpoch = 0;
|
|
125
149
|
readiness;
|
|
126
150
|
constructor(ctx, env) {
|
|
127
151
|
super(ctx, env);
|
|
@@ -135,7 +159,6 @@ export class EveHostContainer extends Container {
|
|
|
135
159
|
}
|
|
136
160
|
assertStableOrigin(publicOrigin);
|
|
137
161
|
assertNonEmpty(deploymentId, "deployment identity");
|
|
138
|
-
assertNonEmpty(generationId, "generation identity");
|
|
139
162
|
const runtimeEnv = readProtectedRuntimeVariables(env);
|
|
140
163
|
this.envVars = {
|
|
141
164
|
...runtimeEnv,
|
|
@@ -172,22 +195,157 @@ export class EveHostContainer extends Container {
|
|
|
172
195
|
healthFetch: (request) => this.containerFetch(request, EVE_HOST_DEFAULTS.internalPort),
|
|
173
196
|
});
|
|
174
197
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Compares the deployment the running Container was started under (stored
|
|
200
|
+
* in Durable Object storage, which survives Worker redeploys) against the
|
|
201
|
+
* deployment the *current* Worker stamps on the forwarded request. A
|
|
202
|
+
* stale Durable Object still detects the update because the header is
|
|
203
|
+
* stamped by new Worker code, not this code's environment.
|
|
204
|
+
*
|
|
205
|
+
* DO-managed Container instances are excluded from the application's fleet
|
|
206
|
+
* rollout — the image is only re-selected on the next
|
|
207
|
+
* `ctx.container.start()` — so an update must stop the instance itself.
|
|
208
|
+
* A missing marker means the running image cannot be trusted, so the
|
|
209
|
+
* container is restarted too (first update from runtimes that predate the
|
|
210
|
+
* marker). Restarts are rate-limited because Cloudflare activates a new
|
|
211
|
+
* Worker before the image rollout lands; starting in that window would
|
|
212
|
+
* re-launch the *old* image, so the deployment marker is only recorded
|
|
213
|
+
* after `inspect()` proves the running image is the expected one.
|
|
214
|
+
*/
|
|
215
|
+
async reconcileStartedDeployment(requestDeploymentId, requestImage) {
|
|
216
|
+
// Requests without the Worker's deployment header (scheduled wakes on old
|
|
217
|
+
// Worker code, probes) cannot arbitrate drift; the Durable Object's own
|
|
218
|
+
// environment may itself be stale, so never fall back to it here.
|
|
219
|
+
if (requestDeploymentId === undefined)
|
|
220
|
+
return;
|
|
221
|
+
const storage = this.ctx?.storage;
|
|
222
|
+
if (storage === undefined ||
|
|
223
|
+
typeof storage.get !== "function" ||
|
|
224
|
+
typeof storage.put !== "function") {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const lastStarted = await storage.get(EVE_HOST_CONTAINER_DEPLOYMENT_KEY);
|
|
228
|
+
if (lastStarted === requestDeploymentId)
|
|
229
|
+
return;
|
|
230
|
+
const runtime = this.ctx?.container;
|
|
231
|
+
if (runtime?.running !== true)
|
|
232
|
+
return;
|
|
233
|
+
if (requestImage !== undefined &&
|
|
234
|
+
(await this.containerServesImage(runtime, requestImage)) === true) {
|
|
235
|
+
// The running instance already provably serves this deployment's image
|
|
236
|
+
// (e.g. the rollout replaced it); safe to mark it as started.
|
|
237
|
+
await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const attemptedAt = await storage.get(EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY);
|
|
241
|
+
const now = Date.now();
|
|
242
|
+
if (attemptedAt !== undefined && now - attemptedAt < 30_000)
|
|
243
|
+
return;
|
|
244
|
+
await storage.put(EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY, now);
|
|
245
|
+
this.lifecycle.record("replaced");
|
|
246
|
+
this.readinessEpoch += 1;
|
|
247
|
+
this.readinessStarted = false;
|
|
248
|
+
this.readinessEvidence = undefined;
|
|
249
|
+
this.readiness.reset();
|
|
250
|
+
await this.stop();
|
|
251
|
+
const stoppedAt = Date.now();
|
|
252
|
+
while (runtime.running && Date.now() - stoppedAt < 10_000) {
|
|
253
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async containerServesImage(runtime, expectedImage) {
|
|
257
|
+
const inspect = runtime.inspect;
|
|
258
|
+
if (typeof inspect !== "function")
|
|
259
|
+
return undefined;
|
|
260
|
+
let info;
|
|
261
|
+
try {
|
|
262
|
+
info = await inspect.call(runtime);
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
if (info?.image === undefined)
|
|
268
|
+
return undefined;
|
|
269
|
+
return containerRepositoryName(info.image) ===
|
|
270
|
+
containerRepositoryName(expectedImage);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Records the started deployment only when the running Container provably
|
|
274
|
+
* serves this deployment's image (`inspect()` matches the forwarded
|
|
275
|
+
* `x-eden-eve-image`). `false` or unknown (no `inspect`, a throwing call,
|
|
276
|
+
* or no image field) never records — a start inside the
|
|
277
|
+
* Worker-active-before-image-rollout window must not pin the old image.
|
|
278
|
+
* When the Worker stamps no image, the marker is recorded unverified,
|
|
279
|
+
* matching pre-drift behavior.
|
|
280
|
+
*/
|
|
281
|
+
async recordStartedDeployment(requestDeploymentId, requestImage) {
|
|
282
|
+
if (requestDeploymentId === undefined)
|
|
283
|
+
return true;
|
|
284
|
+
const storage = this.ctx?.storage;
|
|
285
|
+
if (storage === undefined ||
|
|
286
|
+
typeof storage.get !== "function" ||
|
|
287
|
+
typeof storage.put !== "function") {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
const runtime = this.ctx?.container;
|
|
291
|
+
if (requestImage !== undefined) {
|
|
292
|
+
// A stopped (or stopping) instance can't prove which image it serves.
|
|
293
|
+
if (runtime?.running !== true) {
|
|
294
|
+
this.lifecycle.record("image_mismatch");
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const verified = await this.containerServesImage(runtime, requestImage);
|
|
298
|
+
if (verified !== true) {
|
|
299
|
+
this.lifecycle.record("image_mismatch");
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
async ensureEveReady(signal = new AbortController().signal, requestDeploymentId, requestImage) {
|
|
307
|
+
await this.reconcileStartedDeployment(requestDeploymentId, requestImage);
|
|
308
|
+
// Cached evidence only serves the deployment it was verified under;
|
|
309
|
+
// a request for a different deployment re-runs readiness.
|
|
310
|
+
if (this.readinessEvidence !== undefined &&
|
|
311
|
+
this.readinessEvidence.deploymentId === requestDeploymentId) {
|
|
312
|
+
return this.readinessEvidence.evidence;
|
|
178
313
|
}
|
|
179
314
|
if (!this.readinessStarted) {
|
|
180
315
|
this.readinessStarted = true;
|
|
181
316
|
this.lifecycle.record("start_requested");
|
|
182
317
|
}
|
|
318
|
+
const epoch = this.readinessEpoch;
|
|
183
319
|
const evidence = await this.readiness(signal);
|
|
184
|
-
this.
|
|
320
|
+
if (epoch === this.readinessEpoch &&
|
|
321
|
+
await this.recordStartedDeployment(requestDeploymentId, requestImage) &&
|
|
322
|
+
epoch === this.readinessEpoch) {
|
|
323
|
+
this.readinessEvidence = {
|
|
324
|
+
deploymentId: requestDeploymentId,
|
|
325
|
+
evidence,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
185
328
|
this.lifecycle.record("health_ready", evidence.healthStatus);
|
|
186
329
|
return evidence;
|
|
187
330
|
}
|
|
188
331
|
async fetch(request) {
|
|
189
|
-
|
|
190
|
-
|
|
332
|
+
const requestDeploymentId = request.headers.get("x-eden-eve-deployment-id") ?? undefined;
|
|
333
|
+
await this.ensureEveReady(request.signal, requestDeploymentId, request.headers.get("x-eden-eve-image") ?? undefined);
|
|
334
|
+
const response = await super.fetch(request);
|
|
335
|
+
// Reporting the verified marker back lets deploy health-gate promotion on
|
|
336
|
+
// the served container actually running this generation's image.
|
|
337
|
+
if (this.readinessEvidence !== undefined &&
|
|
338
|
+
this.readinessEvidence.deploymentId === requestDeploymentId &&
|
|
339
|
+
requestDeploymentId !== undefined) {
|
|
340
|
+
const headers = new Headers(response.headers);
|
|
341
|
+
headers.set("x-eden-eve-started-deployment", requestDeploymentId);
|
|
342
|
+
return new Response(response.body, {
|
|
343
|
+
status: response.status,
|
|
344
|
+
statusText: response.statusText,
|
|
345
|
+
headers,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
return response;
|
|
191
349
|
}
|
|
192
350
|
onStart() {
|
|
193
351
|
if (this.lifecycle.events.some((event) => event.type === "started")) {
|
|
@@ -196,12 +354,14 @@ export class EveHostContainer extends Container {
|
|
|
196
354
|
this.lifecycle.record("started");
|
|
197
355
|
}
|
|
198
356
|
onStop(params) {
|
|
357
|
+
this.readinessEpoch += 1;
|
|
199
358
|
this.readinessStarted = false;
|
|
200
359
|
this.readinessEvidence = undefined;
|
|
201
360
|
this.readiness.reset();
|
|
202
361
|
this.lifecycle.record("stopped", `${params.reason}:${params.exitCode}`);
|
|
203
362
|
}
|
|
204
363
|
onError(error) {
|
|
364
|
+
this.readinessEpoch += 1;
|
|
205
365
|
this.readinessStarted = false;
|
|
206
366
|
this.readinessEvidence = undefined;
|
|
207
367
|
this.readiness.reset();
|
|
@@ -240,6 +400,9 @@ export function createEveHostWorker(options) {
|
|
|
240
400
|
deploymentId: options.deploymentId,
|
|
241
401
|
generationId: options.generationId,
|
|
242
402
|
correlationId: globalThis.crypto.randomUUID(),
|
|
403
|
+
...(options.containerImage === undefined
|
|
404
|
+
? {}
|
|
405
|
+
: { containerImage: options.containerImage }),
|
|
243
406
|
...(options.runtimeRevisionHandle === undefined
|
|
244
407
|
? {}
|
|
245
408
|
: { runtimeRevisionHandle: options.runtimeRevisionHandle }),
|
|
@@ -270,7 +433,17 @@ export function createEveHostWorker(options) {
|
|
|
270
433
|
// Wake only: the in-process Nitro runner inside the container
|
|
271
434
|
// fires the tick itself, so the schedule runs exactly once.
|
|
272
435
|
ctx.waitUntil(resolveContainer(env)
|
|
273
|
-
.fetch(new Request(new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin)
|
|
436
|
+
.fetch(new Request(new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin), {
|
|
437
|
+
headers: {
|
|
438
|
+
// Stamp the Worker's own deployment so a stale Durable
|
|
439
|
+
// Object never falls back to its own environment when
|
|
440
|
+
// deciding whether to restart the running Container.
|
|
441
|
+
"x-eden-eve-deployment-id": options.deploymentId,
|
|
442
|
+
...(options.containerImage === undefined
|
|
443
|
+
? {}
|
|
444
|
+
: { "x-eden-eve-image": options.containerImage }),
|
|
445
|
+
},
|
|
446
|
+
}))
|
|
274
447
|
.catch((error) => {
|
|
275
448
|
console.error("The scheduled wake request failed:", error instanceof Error ? error.message : "unknown");
|
|
276
449
|
}));
|
package/dist/eve-host.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare function parseEveScheduleCron(cron: string): ParsedEveCron | unde
|
|
|
51
51
|
export declare function eveScheduleCronFiresWithin(cron: string, nowMs: number, leadMs?: number): boolean;
|
|
52
52
|
/** Queue and World RPC routes are private; webhooks and manifests stay forwarded. */
|
|
53
53
|
export declare function isEveWorkflowInternalRoute(pathname: string): boolean;
|
|
54
|
-
export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-
|
|
54
|
+
export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-image", "x-eden-eve-started-deployment", "x-eden-eve-public-origin", "x-eden-eve-correlation-id", "x-eden-eve-container-name", "x-eden-eve-container-id", "x-eden-eve-runtime-revision", "x-eden-container-name", "x-eden-container-id", "cf-container-target-port"];
|
|
55
55
|
export declare const WORKER_NAME_PATTERN: RegExp;
|
|
56
56
|
export declare const IDENTIFIER_PATTERN: RegExp;
|
|
57
57
|
export type EveHostErrorCode = "HOST_ORIGIN_UNAVAILABLE" | "HOST_REQUEST_ABORTED" | "HOST_READINESS_UNPROVEN" | "HOST_TRANSPORT_UNTESTABLE" | "HOST_WEBSOCKET_UNSUPPORTED";
|
|
@@ -88,6 +88,31 @@ export interface EveHostConfigRequest extends EveHostIdentity {
|
|
|
88
88
|
/** Overrides the Container `sleepAfter` (e.g. "30s") for testing. */
|
|
89
89
|
readonly containerSleepAfter?: string;
|
|
90
90
|
readonly workflowWorld?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Durable Object state already published for this exact target. In-place
|
|
93
|
+
* updates carry the recorded binding and migration history forward
|
|
94
|
+
* verbatim: a class is only ever added once (`new_sqlite_classes` entries
|
|
95
|
+
* are append-only) and a class is never silently removed — a
|
|
96
|
+
* `deleted_classes` migration permanently destroys that class's data.
|
|
97
|
+
*/
|
|
98
|
+
readonly durableObjects?: {
|
|
99
|
+
readonly bindings?: readonly EveDurableBinding[];
|
|
100
|
+
readonly migrations?: readonly EveDurableMigration[];
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** One `durable_objects.bindings` entry as it appears in wrangler config. */
|
|
104
|
+
export interface EveDurableBinding {
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly class_name: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* One `migrations` entry as it appears in wrangler config. Only the
|
|
110
|
+
* `new_sqlite_classes` form Eden has ever emitted is modelled; entries are
|
|
111
|
+
* compared by tag and carried forward verbatim across in-place updates.
|
|
112
|
+
*/
|
|
113
|
+
export interface EveDurableMigration {
|
|
114
|
+
readonly tag: string;
|
|
115
|
+
readonly new_sqlite_classes: readonly string[];
|
|
91
116
|
}
|
|
92
117
|
export interface EveHostWranglerConfig {
|
|
93
118
|
readonly account_id?: string;
|
|
@@ -120,17 +145,9 @@ export interface EveHostWranglerConfig {
|
|
|
120
145
|
}
|
|
121
146
|
];
|
|
122
147
|
readonly durable_objects: {
|
|
123
|
-
readonly bindings: readonly
|
|
124
|
-
readonly name: string;
|
|
125
|
-
readonly class_name: string;
|
|
126
|
-
}[];
|
|
148
|
+
readonly bindings: readonly EveDurableBinding[];
|
|
127
149
|
};
|
|
128
|
-
readonly migrations: readonly [
|
|
129
|
-
{
|
|
130
|
-
readonly tag: "v1";
|
|
131
|
-
readonly new_sqlite_classes: readonly string[];
|
|
132
|
-
}
|
|
133
|
-
];
|
|
150
|
+
readonly migrations: readonly EveDurableMigration[];
|
|
134
151
|
}
|
|
135
152
|
export interface EveHostContainerConfig {
|
|
136
153
|
readonly applicationName: string;
|
|
@@ -160,6 +177,8 @@ export interface EveHostForwardingMetadata {
|
|
|
160
177
|
readonly deploymentId: string;
|
|
161
178
|
readonly generationId: string;
|
|
162
179
|
readonly correlationId: string;
|
|
180
|
+
/** The image this deployment's Worker config selects; the Durable Object verifies a running Container actually serves it before recording the deployment as started. */
|
|
181
|
+
readonly containerImage?: string;
|
|
163
182
|
readonly runtimeRevisionHandle?: string;
|
|
164
183
|
}
|
|
165
184
|
export declare function createTrustedEveRequest(request: Request, metadata: EveHostForwardingMetadata): Request;
|
|
@@ -173,7 +192,7 @@ export interface EveHostProxyOptions extends EveHostForwardingMetadata {
|
|
|
173
192
|
}
|
|
174
193
|
export declare function createEveHostProxy(options: EveHostProxyOptions): (request: Request) => Promise<Response>;
|
|
175
194
|
export interface EveHostLifecycleEvent {
|
|
176
|
-
readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "replaced";
|
|
195
|
+
readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "image_mismatch" | "replaced";
|
|
177
196
|
readonly at: number;
|
|
178
197
|
readonly safeStatus?: string;
|
|
179
198
|
}
|
package/dist/eve-host.js
CHANGED
|
@@ -189,13 +189,13 @@ export const EVE_HOST_OWNED_HEADERS = [
|
|
|
189
189
|
"x-eden-eve-callback-base",
|
|
190
190
|
"x-eden-eve-deployment-id",
|
|
191
191
|
"x-eden-eve-generation-id",
|
|
192
|
+
"x-eden-eve-image",
|
|
193
|
+
"x-eden-eve-started-deployment",
|
|
192
194
|
"x-eden-eve-public-origin",
|
|
193
195
|
"x-eden-eve-correlation-id",
|
|
194
196
|
"x-eden-eve-container-name",
|
|
195
197
|
"x-eden-eve-container-id",
|
|
196
198
|
"x-eden-eve-runtime-revision",
|
|
197
|
-
"x-eden-deployment-id",
|
|
198
|
-
"x-eden-generation-id",
|
|
199
199
|
"x-eden-container-name",
|
|
200
200
|
"x-eden-container-id",
|
|
201
201
|
"cf-container-target-port",
|
|
@@ -307,6 +307,59 @@ export function createEveHostConfig(request) {
|
|
|
307
307
|
max_instances: EVE_HOST_DEFAULTS.maxInstances,
|
|
308
308
|
instance_type: EVE_HOST_DEFAULTS.instanceType,
|
|
309
309
|
};
|
|
310
|
+
const worldCloudflare = request.workflowWorld === "@moinulmoin/eden-world-cloudflare";
|
|
311
|
+
const priorMigrations = [];
|
|
312
|
+
for (const migration of request.durableObjects?.migrations ?? []) {
|
|
313
|
+
if (typeof migration.tag !== "string" ||
|
|
314
|
+
migration.tag.length === 0 ||
|
|
315
|
+
!Array.isArray(migration.new_sqlite_classes) ||
|
|
316
|
+
migration.new_sqlite_classes.some((className) => typeof className !== "string" ||
|
|
317
|
+
!IDENTIFIER_PATTERN.test(className))) {
|
|
318
|
+
throw new EveHostError("HOST_READINESS_UNPROVEN", "The recorded Durable Object migration history is not safely reusable; refusing to drop or rewrite prior tags.");
|
|
319
|
+
}
|
|
320
|
+
priorMigrations.push(migration);
|
|
321
|
+
}
|
|
322
|
+
const bindings = [
|
|
323
|
+
{
|
|
324
|
+
name: request.containerBindingName,
|
|
325
|
+
class_name: request.containerClassName,
|
|
326
|
+
},
|
|
327
|
+
...(worldCloudflare
|
|
328
|
+
? [{ name: "EDEN_WORLD", class_name: "EdenWorldDurableObject" }]
|
|
329
|
+
: []),
|
|
330
|
+
];
|
|
331
|
+
for (const priorBinding of request.durableObjects?.bindings ?? []) {
|
|
332
|
+
if (typeof priorBinding.name !== "string" ||
|
|
333
|
+
!IDENTIFIER_PATTERN.test(priorBinding.name) ||
|
|
334
|
+
typeof priorBinding.class_name !== "string" ||
|
|
335
|
+
!IDENTIFIER_PATTERN.test(priorBinding.class_name)) {
|
|
336
|
+
throw new EveHostError("HOST_READINESS_UNPROVEN", "The recorded Durable Object bindings are not safely reusable; refusing to drop or rewrite prior bindings.");
|
|
337
|
+
}
|
|
338
|
+
// Only classes the generated Worker can export are carried; the World
|
|
339
|
+
// Durable Object's binding is retained across World switches so its class
|
|
340
|
+
// (and SQLite data) is never dropped or left without a namespace.
|
|
341
|
+
if (priorBinding.class_name === "EdenWorldDurableObject" &&
|
|
342
|
+
bindings.every((binding) => binding.name !== priorBinding.name)) {
|
|
343
|
+
bindings.push(priorBinding);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const declaredClasses = new Set(priorMigrations.flatMap((migration) => migration.new_sqlite_classes));
|
|
347
|
+
const newClasses = [
|
|
348
|
+
...new Set(bindings.map((binding) => binding.class_name)),
|
|
349
|
+
].filter((className) => !declaredClasses.has(className));
|
|
350
|
+
const migrations = [...priorMigrations];
|
|
351
|
+
if (newClasses.length > 0) {
|
|
352
|
+
let sequence = priorMigrations.reduce((highest, migration) => /^v(\d+)$/u.test(migration.tag)
|
|
353
|
+
? Math.max(highest, Number(migration.tag.slice(1)))
|
|
354
|
+
: highest, 0);
|
|
355
|
+
const usedTags = new Set(priorMigrations.map((migration) => migration.tag));
|
|
356
|
+
let tag = `v${sequence + 1}`;
|
|
357
|
+
while (usedTags.has(tag)) {
|
|
358
|
+
sequence += 1;
|
|
359
|
+
tag = `v${sequence + 1}`;
|
|
360
|
+
}
|
|
361
|
+
migrations.push({ tag, new_sqlite_classes: newClasses });
|
|
362
|
+
}
|
|
310
363
|
return {
|
|
311
364
|
worker: {
|
|
312
365
|
...(request.accountId === undefined
|
|
@@ -337,28 +390,8 @@ export function createEveHostConfig(request) {
|
|
|
337
390
|
? {}
|
|
338
391
|
: { triggers: { crons: [EVE_SCHEDULE_WAKE_TRIGGER_CRON] } }),
|
|
339
392
|
containers: [container],
|
|
340
|
-
durable_objects: {
|
|
341
|
-
|
|
342
|
-
{
|
|
343
|
-
name: request.containerBindingName,
|
|
344
|
-
class_name: request.containerClassName,
|
|
345
|
-
},
|
|
346
|
-
...(request.workflowWorld === "@moinulmoin/eden-world-cloudflare"
|
|
347
|
-
? [{ name: "EDEN_WORLD", class_name: "EdenWorldDurableObject" }]
|
|
348
|
-
: []),
|
|
349
|
-
],
|
|
350
|
-
},
|
|
351
|
-
migrations: [
|
|
352
|
-
{
|
|
353
|
-
tag: "v1",
|
|
354
|
-
new_sqlite_classes: [
|
|
355
|
-
request.containerClassName,
|
|
356
|
-
...(request.workflowWorld === "@moinulmoin/eden-world-cloudflare"
|
|
357
|
-
? ["EdenWorldDurableObject"]
|
|
358
|
-
: []),
|
|
359
|
-
],
|
|
360
|
-
},
|
|
361
|
-
],
|
|
393
|
+
durable_objects: { bindings },
|
|
394
|
+
migrations,
|
|
362
395
|
},
|
|
363
396
|
container: {
|
|
364
397
|
applicationName: request.containerApplicationName,
|
|
@@ -384,6 +417,7 @@ export function generateEveHostWorkerSource(request) {
|
|
|
384
417
|
containerBindingName: request.config.container.bindingName,
|
|
385
418
|
deploymentId: request.config.container.deploymentId,
|
|
386
419
|
generationId: request.config.container.generationId,
|
|
420
|
+
containerImage: request.config.worker.containers[0].image,
|
|
387
421
|
stableContainerInstanceName: request.config.container.instanceName,
|
|
388
422
|
...(request.config.container.runtimeRevisionHandle === undefined
|
|
389
423
|
? {}
|
|
@@ -400,7 +434,9 @@ export function generateEveHostWorkerSource(request) {
|
|
|
400
434
|
? "export { ContainerProxy, EveHostContainer };"
|
|
401
435
|
: `export { ContainerProxy, EveHostContainer as ${request.config.container.className} };`,
|
|
402
436
|
"",
|
|
403
|
-
...(request.config.worker.vars.EDEN_EVE_WORLD_CLOUDFLARE
|
|
437
|
+
...(request.config.worker.vars.EDEN_EVE_WORLD_CLOUDFLARE === true ||
|
|
438
|
+
request.config.worker.durable_objects.bindings.some((binding) => binding.class_name === "EdenWorldDurableObject") ||
|
|
439
|
+
request.config.worker.migrations.some((migration) => migration.new_sqlite_classes.includes("EdenWorldDurableObject"))
|
|
404
440
|
? [`export { EdenWorldDurableObject } from ${JSON.stringify(moduleSpecifier)};`]
|
|
405
441
|
: []),
|
|
406
442
|
`EveHostContainer.outboundByHost = { ${JSON.stringify(new URL(request.config.container.publicOrigin).hostname)}: routeEveOutboundRequest };`,
|
|
@@ -459,6 +495,9 @@ export function createTrustedEveRequest(request, metadata) {
|
|
|
459
495
|
headers.set("x-eden-eve-deployment-id", metadata.deploymentId);
|
|
460
496
|
headers.set("x-eden-eve-generation-id", metadata.generationId);
|
|
461
497
|
headers.set("x-eden-eve-correlation-id", metadata.correlationId);
|
|
498
|
+
if (metadata.containerImage !== undefined) {
|
|
499
|
+
headers.set("x-eden-eve-image", metadata.containerImage);
|
|
500
|
+
}
|
|
462
501
|
if (metadata.runtimeRevisionHandle !== undefined) {
|
|
463
502
|
headers.set("x-eden-eve-runtime-revision", metadata.runtimeRevisionHandle);
|
|
464
503
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { EVE_HOST_DEFAULTS, EVE_SCHEDULE_WAKE_LEAD_MS, EVE_SCHEDULE_WAKE_TRIGGER_CRON, eveScheduleCronFiresWithin, expandEveCronField, parseEveScheduleCron, EVE_HOST_OWNED_HEADERS, EveHostError, createEveHostConfig, createEveHostLifecycleObserver, createEveHostProxy, createEveReadinessGate, createTrustedEveRequest, generateEveHostWorkerSource, resolveStableWorkersDevOrigin, } from "./eve-host.js";
|
|
2
|
-
export type { EveContainerTransport, EveHostConfig, EveHostConfigRequest, EveHostContainerConfig, EveHostContainerEnvironment, EveHostErrorCode, EveScheduleCronEntry, EveHostForwardingMetadata, EveHostIdentity, EveHostLifecycleEvent, EveHostLifecycleObserver, EveHostProxyOptions, EveHostReadinessEvidence, EveHostReadinessOptions, EveReadinessGate, EveHostWranglerConfig, EveGeneratedWorkerSourceRequest, StableWorkersDevOriginRequest, } from "./eve-host.js";
|
|
2
|
+
export type { EveDurableBinding, EveDurableMigration, EveContainerTransport, EveHostConfig, EveHostConfigRequest, EveHostContainerConfig, EveHostContainerEnvironment, EveHostErrorCode, EveScheduleCronEntry, EveHostForwardingMetadata, EveHostIdentity, EveHostLifecycleEvent, EveHostLifecycleObserver, EveHostProxyOptions, EveHostReadinessEvidence, EveHostReadinessOptions, EveReadinessGate, EveHostWranglerConfig, EveGeneratedWorkerSourceRequest, StableWorkersDevOriginRequest, } from "./eve-host.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moinulmoin/eden-runtime-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Cloudflare Worker/Container host runtime for Eden's Eve deployments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@cloudflare/containers": "0.3.7",
|
|
24
|
-
"@moinulmoin/eden-world-cloudflare": "0.
|
|
24
|
+
"@moinulmoin/eden-world-cloudflare": "0.5.0",
|
|
25
25
|
"@cloudflare/workers-types": "5.20260810.1"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|