@moinulmoin/eden-runtime-cloudflare 0.6.0 → 0.7.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.
@@ -1,5 +1,13 @@
1
1
  import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
2
2
  import { type EveHostContainerEnvironment, type EveHostForwardingMetadata, type EveHostReadinessEvidence, type EveScheduleCronEntry } from "./eve-host.js";
3
+ /**
4
+ * Carry archive limits. `chunkBytes` stays safely under the per-key limit;
5
+ * `maxBytes` caps the compressed archive (tests shrink both).
6
+ */
7
+ export declare const EVE_HOST_CARRY_LIMITS: {
8
+ chunkBytes: number;
9
+ maxBytes: number;
10
+ };
3
11
  /** The deployment's single SQLite-backed Workflow World. */
4
12
  export declare class EdenWorldDurableObject {
5
13
  private readonly core;
@@ -43,8 +51,6 @@ export declare class EveHostLoopback extends WorkerEntrypoint<EveHostContainerEn
43
51
  * running image predates the configured one.
44
52
  */
45
53
  export declare class EveHostDurableContainer extends DurableObject<EveHostContainerEnvironment> {
46
- readonly lifecycle: import("./eve-host.js").EveHostLifecycleObserver;
47
- private readinessStarted;
48
54
  /** Evidence is cached only while the container it was proven on keeps running. */
49
55
  private readinessEvidence;
50
56
  /** True once the running container's image was proven to equal `images.eve`. */
@@ -56,12 +62,19 @@ export declare class EveHostDurableContainer extends DurableObject<EveHostContai
56
62
  */
57
63
  private readinessEpoch;
58
64
  private monitorAttached;
65
+ /** Serializes sandbox-session carry-outs on this Durable Object instance. */
66
+ private carryOutQueue;
67
+ /** True only while the last start was fresh from `images.eve`, not a snapshot. */
68
+ private pendingCarryRestore;
69
+ /** Shared single-flight carry restore for the current container generation. */
70
+ private carryRestorePromise;
59
71
  private readonly envVars;
60
72
  private readonly sleepAfterMs;
61
73
  private readonly readiness;
62
74
  constructor(ctx: DurableObjectState, env: EveHostContainerEnvironment);
63
75
  private containerRuntime;
64
- /** Container lifetime the platform keeps after the DO goes inactive. */
76
+ /** Container lifetime the platform keeps after the DO goes inactive: long
77
+ * enough for the idle alarm to snapshot first, within Cloudflare's 6 h cap. */
65
78
  private get inactivityTimeoutMs();
66
79
  private attachMonitor;
67
80
  private recordContainerStopped;
@@ -78,15 +91,41 @@ export declare class EveHostDurableContainer extends DurableObject<EveHostContai
78
91
  * is restored only when it was captured from the exact image this Worker
79
92
  * version configures — restoring an older snapshot silently runs the
80
93
  * previous image — so after an image update the container starts fresh and
81
- * workspace files intentionally do not carry across.
94
+ * the readiness path restores the carried sandbox sessions instead.
82
95
  */
83
96
  private ensureContainerStarted;
84
97
  /**
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.
98
+ * Replaces the running container when it still serves a pre-update image:
99
+ * this Worker version's `images.eve` is selected at `start()`, so an
100
+ * in-place update must stop the stale instance itself. `inspect()` reports
101
+ * an empty image for a snapshot-restored container, so the image recorded
102
+ * at start stands in for it.
88
103
  */
89
104
  private reconcileRunningImage;
105
+ /**
106
+ * Streams `/workspace/.eve/sandbox-cache/just-bash/sessions` — every
107
+ * conversation's sandbox files and metadata — into Durable Object storage,
108
+ * so a fresh container started by an image update can restore them. Not
109
+ * carried: templates and the rest of `/workspace`, which come from the new
110
+ * image. One carry runs at a time on this Durable Object; a failure never
111
+ * blocks the destroy that follows and leaves the previous carry intact.
112
+ */
113
+ private carrySandboxSessionsOut;
114
+ private carrySandboxSessionsOutNow;
115
+ /**
116
+ * Single restore per fresh container generation, shared by every
117
+ * concurrent readiness caller: the first caller starts it, everyone awaits
118
+ * the same promise, and no request is forwarded before it settles.
119
+ */
120
+ private restoreCarriedSandboxSessions;
121
+ /**
122
+ * Extracts the carried sandbox sessions into a container that started
123
+ * fresh from `images.eve`. The archive streams chunk by chunk from Durable
124
+ * Object storage through exec stdin, so it never sits in isolate memory. A
125
+ * failure is logged and swallowed: the agent still serves, only the
126
+ * carried files are missing.
127
+ */
128
+ private carrySandboxSessionsIn;
90
129
  ensureEveReady(signal?: AbortSignal): Promise<EveHostReadinessEvidence>;
91
130
  fetch(request: Request): Promise<Response>;
92
131
  /**
@@ -95,6 +134,7 @@ export declare class EveHostDurableContainer extends DurableObject<EveHostContai
95
134
  * loopback path is not a deployment-health signal).
96
135
  */
97
136
  loopbackFetch(request: Request): Promise<Response>;
137
+ private forwardToEve;
98
138
  /**
99
139
  * The idle-sleep path: once the container has been quiet for `sleepAfter`,
100
140
  * snapshot the writable filesystem (so `/workspace` survives the sleep)
@@ -104,10 +144,8 @@ export declare class EveHostDurableContainer extends DurableObject<EveHostContai
104
144
  */
105
145
  alarm(): Promise<void>;
106
146
  }
107
- export type EveHostWorkerEnvironment = EveHostContainerEnvironment;
108
147
  export interface EveHostWorkerOptions extends EveHostForwardingMetadata {
109
148
  readonly workerName: string;
110
- readonly containerBindingName: string;
111
149
  readonly stableContainerInstanceName: string;
112
150
  readonly schedules?: readonly EveScheduleCronEntry[];
113
151
  }
@@ -116,11 +154,11 @@ export interface EveHostWorkerOptions extends EveHostForwardingMetadata {
116
154
  * declarations never reference provider ambient types.
117
155
  */
118
156
  export interface EveHostWorkerHandler {
119
- fetch(request: Request, env: EveHostWorkerEnvironment): Promise<Response>;
157
+ fetch(request: Request, env: EveHostContainerEnvironment): Promise<Response>;
120
158
  scheduled?(event: {
121
159
  readonly cron: string;
122
160
  readonly scheduledTime: number;
123
- }, env: EveHostWorkerEnvironment, ctx: {
161
+ }, env: EveHostContainerEnvironment, ctx: {
124
162
  waitUntil(task: Promise<unknown>): void;
125
163
  }): void;
126
164
  }