@moinulmoin/eden-runtime-cloudflare 0.3.0 → 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/NOTICE +8 -0
- package/dist/eden-eve-host-worker.mjs +24253 -241
- package/dist/eve-host-runtime.d.ts +44 -1
- package/dist/eve-host-runtime.js +264 -8
- package/dist/eve-host.d.ts +35 -15
- package/dist/eve-host.js +73 -19
- package/dist/index.d.ts +1 -1
- package/package.json +2 -1
package/dist/eve-host.js
CHANGED
|
@@ -155,16 +155,16 @@ export function eveScheduleCronFiresWithin(cron, nowMs, leadMs = EVE_SCHEDULE_WA
|
|
|
155
155
|
}
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
|
-
/** Queue
|
|
158
|
+
/** Queue and World RPC routes are private; webhooks and manifests stay forwarded. */
|
|
159
159
|
export function isEveWorkflowInternalRoute(pathname) {
|
|
160
160
|
let decodedPath = pathname;
|
|
161
161
|
try {
|
|
162
162
|
decodedPath = decodeURIComponent(pathname);
|
|
163
163
|
}
|
|
164
164
|
catch {
|
|
165
|
-
//
|
|
165
|
+
// A malformed escape cannot identify an internal route.
|
|
166
166
|
}
|
|
167
|
-
return
|
|
167
|
+
return /^\/(?:\.well-known\/workflow\/v1\/(?:flow|step)|__eden\/world)(?:\/|$)/iu.test(decodedPath.replace(/\/+/gu, "/"));
|
|
168
168
|
}
|
|
169
169
|
export const EVE_HOST_OWNED_HEADERS = [
|
|
170
170
|
"forwarded",
|
|
@@ -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
|
|
@@ -329,25 +382,16 @@ export function createEveHostConfig(request) {
|
|
|
329
382
|
...(request.containerSleepAfter === undefined
|
|
330
383
|
? {}
|
|
331
384
|
: { EDEN_EVE_CONTAINER_SLEEP_AFTER: request.containerSleepAfter }),
|
|
385
|
+
...(request.workflowWorld === "@moinulmoin/eden-world-cloudflare"
|
|
386
|
+
? { EDEN_EVE_WORLD_CLOUDFLARE: true }
|
|
387
|
+
: {}),
|
|
332
388
|
},
|
|
333
389
|
...(schedules.length === 0
|
|
334
390
|
? {}
|
|
335
391
|
: { triggers: { crons: [EVE_SCHEDULE_WAKE_TRIGGER_CRON] } }),
|
|
336
392
|
containers: [container],
|
|
337
|
-
durable_objects: {
|
|
338
|
-
|
|
339
|
-
{
|
|
340
|
-
name: request.containerBindingName,
|
|
341
|
-
class_name: request.containerClassName,
|
|
342
|
-
},
|
|
343
|
-
],
|
|
344
|
-
},
|
|
345
|
-
migrations: [
|
|
346
|
-
{
|
|
347
|
-
tag: "v1",
|
|
348
|
-
new_sqlite_classes: [request.containerClassName],
|
|
349
|
-
},
|
|
350
|
-
],
|
|
393
|
+
durable_objects: { bindings },
|
|
394
|
+
migrations,
|
|
351
395
|
},
|
|
352
396
|
container: {
|
|
353
397
|
applicationName: request.containerApplicationName,
|
|
@@ -373,6 +417,7 @@ export function generateEveHostWorkerSource(request) {
|
|
|
373
417
|
containerBindingName: request.config.container.bindingName,
|
|
374
418
|
deploymentId: request.config.container.deploymentId,
|
|
375
419
|
generationId: request.config.container.generationId,
|
|
420
|
+
containerImage: request.config.worker.containers[0].image,
|
|
376
421
|
stableContainerInstanceName: request.config.container.instanceName,
|
|
377
422
|
...(request.config.container.runtimeRevisionHandle === undefined
|
|
378
423
|
? {}
|
|
@@ -389,6 +434,11 @@ export function generateEveHostWorkerSource(request) {
|
|
|
389
434
|
? "export { ContainerProxy, EveHostContainer };"
|
|
390
435
|
: `export { ContainerProxy, EveHostContainer as ${request.config.container.className} };`,
|
|
391
436
|
"",
|
|
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"))
|
|
440
|
+
? [`export { EdenWorldDurableObject } from ${JSON.stringify(moduleSpecifier)};`]
|
|
441
|
+
: []),
|
|
392
442
|
`EveHostContainer.outboundByHost = { ${JSON.stringify(new URL(request.config.container.publicOrigin).hostname)}: routeEveOutboundRequest };`,
|
|
393
443
|
"",
|
|
394
444
|
`export default createEveHostWorker(${JSON.stringify(workerOptions)});`,
|
|
@@ -445,6 +495,9 @@ export function createTrustedEveRequest(request, metadata) {
|
|
|
445
495
|
headers.set("x-eden-eve-deployment-id", metadata.deploymentId);
|
|
446
496
|
headers.set("x-eden-eve-generation-id", metadata.generationId);
|
|
447
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
|
+
}
|
|
448
501
|
if (metadata.runtimeRevisionHandle !== undefined) {
|
|
449
502
|
headers.set("x-eden-eve-runtime-revision", metadata.runtimeRevisionHandle);
|
|
450
503
|
}
|
|
@@ -511,6 +564,7 @@ const RESERVED_EVE_HOST_VARIABLES = new Set([
|
|
|
511
564
|
"NODE_ENV",
|
|
512
565
|
"NODE_EXTRA_CA_CERTS",
|
|
513
566
|
"WORKFLOW_LOCAL_BASE_URL",
|
|
567
|
+
"EDEN_WORLD_URL",
|
|
514
568
|
"EDEN_EVE_DEPLOYMENT_ID",
|
|
515
569
|
"EDEN_EVE_GENERATION_ID",
|
|
516
570
|
"EDEN_EVE_RUNTIME_REVISION",
|
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,6 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@cloudflare/containers": "0.3.7",
|
|
24
|
+
"@moinulmoin/eden-world-cloudflare": "0.5.0",
|
|
24
25
|
"@cloudflare/workers-types": "5.20260810.1"
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|