@effect-agent/platform-cloudflare 0.1.0-beta.14 → 0.1.0-beta.16

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.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { Context, Effect, Layer, Option, Schema } from "effect";
2
- import { AbortCommand, AbortIntent, AdmissionConflict, AgentBindingResolver, AppendConflict, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, CanonicalRecordEnvelope, CanonicalSequence, ConversationNotMaterialized, ConversationStore, ConversationStoreError, DefinitionDigests, DigestError, DurableAgentRuntime, DurableBindingFailure, DurableRuntimeConfig, DurableRuntimeFailpointError, DurableRuntimeFailpointHandler, DurableSubmitAgent, DurableSubmitOptions, DurableWorkerFailure, FenceRejected, IntegrityReport, JoinedToHost, LedgerError, ObligationReport, ObligationThresholds, OperationDenied, OwnershipLost, ProducerId, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, RetryRefused, RunJournalError, Settlement, SettlementConflict, SubmissionLedger, ToolReconciler, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WakeScheduler } from "@effect-agent/session";
1
+ import { Context, Crypto, Effect, Layer, Option, Schema, Scope } from "effect";
2
+ import { AbortCommand, AbortIntent, AdmissionConflict, AgentBindingResolver, AppendConflict, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, CanonicalRecordEnvelope, CanonicalSequence, ConversationNotMaterialized, ConversationStore, ConversationStoreError, DefinitionDigests, DigestError, DurableAgentRuntime, DurableBindingFailure, DurableRuntimeConfig, DurableRuntimeFailpointError, DurableRuntimeFailpointHandler, DurableSubmitAgent, DurableSubmitOptions, DurableWorkerFailure, FenceRejected, IntegrityReport, JoinedToHost, LedgerError, ObligationReport, ObligationThresholds, OperationAuthorizerService, OperationDenied, OwnershipLost, ProducerId, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, RetryRefused, RunJournalError, Settlement, SettlementConflict, SubmissionLedger, ToolReconciler, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WakeScheduler } from "@effect-agent/session";
3
3
  import { ConversationPortTransport, DoStorageFailpointHandler, DoStorageInitializationError } from "@effect-agent/storage-cloudflare";
4
4
  import { AgentInputError, ConversationId } from "@effect-agent/core";
5
5
  import { DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
@@ -31,6 +31,10 @@ interface ConversationObjectRpc extends Rpc.DurableObjectBranded {
31
31
  submitEncoded(encoded: unknown): Promise<unknown>;
32
32
  /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */
33
33
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
34
+ /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */
35
+ awaitProgressEncoded(encoded: unknown): Promise<unknown>;
36
+ /** Best-effort cancellation for one in-flight progress wait. */
37
+ cancelProgressEncoded(encoded: unknown): Promise<unknown>;
34
38
  /** One bounded page of canonical records; answers an `ObservePageResponse`. */
35
39
  observePage(encoded: unknown): Promise<unknown>;
36
40
  /** Durable abort intent; answers an `AbortResponse`. */
@@ -195,11 +199,10 @@ declare const DurableAlarmError_base: Schema.Class<DurableAlarmError, Schema.Tag
195
199
  * and abort re-checks, retry backoff) multiplexes into one idempotent maintenance pass, and
196
200
  * the slot always holds the EARLIEST deadline any caller asked for.
197
201
  *
198
- * The alarm invariant (plan §1.4): committed nonterminal work implies a committed alarm.
199
- * It is established by pre-arming every mutating entry point and every pass arms the alarm
200
- * BEFORE its durable mutations — so an eviction at any failpoint leaves a persisted alarm
201
- * that workerd re-delivers to a fresh incarnation WITHOUT any incoming request. Spurious
202
- * alarms are harmless by design: a pass over an all-settled lane simply deletes the slot.
202
+ * The alarm invariant (plan §1.4): every committed actionable mutation carries a newer durable
203
+ * maintenance generation and a committed alarm. Stable externally-driven waits may be
204
+ * nonterminal without retaining an alarm; their resolving mutation advances the generation and
205
+ * restores the alarm atomically.
203
206
  */
204
207
  /** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */
205
208
  declare class DurableAlarmError extends DurableAlarmError_base {}
@@ -220,17 +223,16 @@ declare const DurableAlarmService_base: Context.ServiceClass<DurableAlarmService
220
223
  * caused, and routing open uncertain-class Tool Calls into spurious Unknown Outcomes.
221
224
  * Deferral is contract-safe: wakes are droppable hints, every mutating entry point
222
225
  * pre-arms BEFORE its first durable mutation (the alarm invariant never rests on this
223
- * call), and the deferred wake is flushed when the pass completes.
226
+ * call). The pass's durable generation check observes any racing mutation, so the
227
+ * in-memory hint does not need to be flushed after a stable wait is acknowledged.
224
228
  */
225
229
  readonly scheduleNow: Effect.Effect<void, DurableAlarmError>;
226
230
  /**
227
- * Run one maintenance pass with wake deferral (see `scheduleNow`): `scheduleNow` calls
228
- * while `body` executes coalesce into one flag, flushed as an immediate re-arm after the
229
- * pass — failures of the flush are logged and swallowed (hints are droppable; the pass's
230
- * own re-arm policy already bounded the next delivery).
231
+ * Run one maintenance pass with wake deferral (see `scheduleNow`). Calls made while `body`
232
+ * executes are droppable promptness hints; correctness rests on the durable generation.
231
233
  */
232
234
  readonly withWakesDeferred: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
233
- /** Clear the slot; only the maintenance pass does this, and only when all work settled. */
235
+ /** Clear the slot; correctness-sensitive clears live in maintenance generation transactions. */
234
236
  readonly cancel: Effect.Effect<void, DurableAlarmError>;
235
237
  }>;
236
238
  /** `ctx.storage` alarm slot as an Effect service; storage is truth, never a memory field. */
@@ -238,57 +240,60 @@ declare class DurableAlarmService extends DurableAlarmService_base {
238
240
  static readonly layer: Layer.Layer<DurableAlarmService, never, DurableObjectContext>;
239
241
  }
240
242
  declare const MaintenancePassReport_base: Schema.Class<MaintenancePassReport, Schema.Struct<{
243
+ /** `caught-up` is generation-only; `actionable` ran recovery and one bounded drain. */
244
+ readonly phase: Schema.Literals<readonly ["caught-up", "actionable"]>;
241
245
  /** Recovery decisions executed (or deferred) BEFORE any new claim in this pass. */
242
246
  readonly recovered: Schema.Int;
243
247
  /** Settlements the drain pass finalized. */
244
248
  readonly settled: Schema.Int;
245
249
  /** Submissions still nonterminal after the pass (suspended/unknown lanes stay honest). */
246
250
  readonly nonterminal: Schema.Int;
247
- /** `rearmed` while nonterminal work remains, `cleared` once everything settled. */
251
+ /** `rearmed` for dirty/autonomous work, `cleared` for stable waits or settlement. */
248
252
  readonly alarm: Schema.Literals<readonly ["rearmed", "cleared"]>;
249
253
  }>, {}>;
250
254
  /** What one maintenance pass did — auditable evidence mirroring `NodeDurableHost`'s report. */
251
255
  declare class MaintenancePassReport extends MaintenancePassReport_base {}
256
+ /** Fault boundaries around every maintenance-owned durable mutation. */
257
+ type ConversationMaintenanceFailpointLocation = "maintenance:dirty:before" | "maintenance:dirty:after" | "maintenance:mutation:armed" | "maintenance:mutation:finished" | "maintenance:ensure:before" | "maintenance:ensure:after" | "maintenance:begin:before" | "maintenance:begin:after" | "maintenance:finish:before" | "maintenance:finish:after";
258
+ type ConversationMaintenanceFailpointHandler = (location: ConversationMaintenanceFailpointLocation) => Effect.Effect<void>;
259
+ declare const ConversationMaintenanceFailpoint_base: Context.ServiceClass<ConversationMaintenanceFailpoint, "@effect-agent/platform-cloudflare/ConversationMaintenanceFailpoint", {
260
+ readonly hit: ConversationMaintenanceFailpointHandler;
261
+ }>;
262
+ /** Test-only fault authority; production uses the inert layer. */
263
+ declare class ConversationMaintenanceFailpoint extends ConversationMaintenanceFailpoint_base {
264
+ static readonly layer: Layer.Layer<ConversationMaintenanceFailpoint, never, never>;
265
+ }
252
266
  type MaintenancePassFailure = DurableWorkerFailure | DurableBindingFailure | DurableAlarmError;
253
267
  declare const ConversationMaintenance_base: Context.ServiceClass<ConversationMaintenance, "@effect-agent/platform-cloudflare/ConversationMaintenance", {
254
268
  /** One idempotent maintenance pass; failures propagate so workerd retries the alarm. */
255
269
  readonly pass: Effect.Effect<MaintenancePassReport, MaintenancePassFailure>;
256
270
  /**
257
- * Defensive half of the alarm invariant, run by the constructor gate: if any local
258
- * Submission is nonterminal and no alarm is scheduled, arm one within the scan interval.
259
- * Local-only (one ledger scan + the alarm slot) — never a recovery pass, never transport.
271
+ * Constructor gate: initialize/inspect only the O(1) maintenance record and ensure a dirty
272
+ * generation has an alarm. It never scans the ledger or canonical history.
260
273
  */
261
274
  readonly ensureAlarm: Effect.Effect<void, MaintenancePassFailure>;
262
275
  /**
263
- * The pre-arm every mutating entry point runs BEFORE its first durable mutation: with
264
- * the alarm committed first, a committed admission (or any other committed nonterminal
265
- * transition) can never be observed without the alarm that will finish it.
276
+ * Serialize the pre-arm boundary with pass acknowledgement, advance the durable dirty
277
+ * generation and arm the alarm in one transaction BEFORE running the caller's mutation.
278
+ * A pass cannot acknowledge while that mutation remains in flight.
266
279
  */
267
- readonly preArm: Effect.Effect<void, DurableAlarmError>;
280
+ readonly withMutation: <A, E, R>(body: Effect.Effect<A, E, R>) => Effect.Effect<A, E | DurableAlarmError, R>;
268
281
  }>;
269
282
  /**
270
- * The idempotent maintenance pass and the alarm-invariant helpers (plan §1.4, D-P6-1/2).
271
- *
272
- * `pass` = pre-arm → `runRecovery` → `processConversationResolved` → re-arm-or-clear:
283
+ * Incremental, quiescent maintenance over a durable dirty/processed generation (issue #93).
273
284
  *
274
- * 1. **Pre-arm**: the alarm is re-armed at `now + wakeScanInterval` BEFORE any work, so an
275
- * eviction (or thrown failure → workerd alarm retry) at any point of the pass leaves a
276
- * committed alarm and the fresh incarnation converges without an incoming request.
277
- * 2. **Reconcile before new work** (exit gate): every pass classifies and repairs every
278
- * nonterminal Submission before the drain claims anything; the pure classifier and the
279
- * repair executors are idempotent, so at-least-once alarm delivery re-runs them safely.
280
- * 3. **Drain**: one bounded `processConversationResolved` pass over this Object's lane — the
281
- * D-P6-1 shape; no infinite `runResolvedWorker` loop ever pins the Object.
282
- * 4. **Re-arm policy**: nonterminal work re-arms at `now + min(backoff-with-jitter,
283
- * wakeScanInterval)` — the scan interval bounds every wait (lease expiry of a dead
284
- * incarnation included, since claims retry each pass) and the backoff (reset on progress,
285
- * grown otherwise) keeps stuck lanes from busy-spinning; all settled clears the slot.
285
+ * `pass` = generation snapshot/pre-arm recovery bounded drain generation acknowledgement:
286
286
  *
287
- * Every step is a durability-protocol step that already tolerates re-execution, which is
288
- * what makes double-fired alarms harmless (the alarm.test.ts gate).
287
+ * 1. One storage transaction reads dirty/processed and re-arms before work. A caught-up forced
288
+ * alarm takes an O(1) path without recovery, ledger scans, or canonical-history reads.
289
+ * 2. Recovery still strictly precedes a new claim, and one bounded drain advances the lane.
290
+ * 3. The final transaction acknowledges only the generation observed at pass start. A racing
291
+ * mutation therefore remains `dirty > processed` and retains its atomically-established alarm.
292
+ * 4. Stable external waits acknowledge and clear. Autonomous retry, indeterminate, and lease
293
+ * recovery states leave their generation dirty and retain bounded backoff rearming.
289
294
  */
290
295
  declare class ConversationMaintenance extends ConversationMaintenance_base {
291
- static readonly layer: Layer.Layer<ConversationMaintenance, never, DurableAgentRuntime | AgentBindingResolver | SubmissionLedger | DurableAlarmService | CloudflareDurableRuntimeConfig | ConversationObjectIdentity>;
296
+ static readonly layer: Layer.Layer<ConversationMaintenance, never, DurableAgentRuntime | AgentBindingResolver | SubmissionLedger | DurableAlarmService | ConversationMaintenanceFailpoint | CloudflareDurableRuntimeConfig | ConversationObjectIdentity | DurableObjectContext>;
292
297
  }
293
298
  //#endregion
294
299
  //#region src/wake-scheduler.d.ts
@@ -306,6 +311,22 @@ declare class ConversationMaintenance extends ConversationMaintenance_base {
306
311
  */
307
312
  declare const cloudflareWakeSchedulerLayer: Layer.Layer<WakeScheduler, never, DurableAlarmService | ConversationObjectIdentity | ConversationObjectNamespace>;
308
313
  //#endregion
314
+ //#region src/progress-wait.d.ts
315
+ declare const ProgressWaitRegistry_base: Context.ServiceClass<ProgressWaitRegistry, "@effect-agent/platform-cloudflare/ProgressWaitRegistry", {
316
+ /** Register a Scope-owned cancellation signal, observing any early cancel tombstone. */
317
+ readonly subscribe: (waiterId: string) => Effect.Effect<Effect.Effect<void>, never, Scope.Scope>;
318
+ /** Cancel a registered waiter, or remember a bounded early cancellation. */
319
+ readonly cancel: (waiterId: string) => Effect.Effect<void>;
320
+ }>;
321
+ /**
322
+ * Per-incarnation cancellation registry for long-lived progress RPCs. The public runtime owns
323
+ * the actual wake registration; this host-only registry lets an interrupted Worker Effect ask
324
+ * the Object to interrupt its scoped wait before the Worker execution context itself ends.
325
+ */
326
+ declare class ProgressWaitRegistry extends ProgressWaitRegistry_base {
327
+ static readonly layer: Layer.Layer<ProgressWaitRegistry>;
328
+ }
329
+ //#endregion
309
330
  //#region src/transport.d.ts
310
331
  /**
311
332
  * `ConversationPortTransport` over native Durable Object JS RPC (decision D-P6-3): one
@@ -367,6 +388,10 @@ interface CloudflareDurableRuntimeOptions {
367
388
  readonly storageFailpoint?: ((ctx: DurableObjectState) => DoStorageFailpointHandler) | undefined;
368
389
  /** Coordinator fault injection (`submit:*` / `terminalize:*` locations); default none. */
369
390
  readonly runtimeFailpoint?: ((ctx: DurableObjectState) => DurableRuntimeFailpointHandler) | undefined;
391
+ /** Conversation-maintenance generation/alarm fault injection; default none. */
392
+ readonly maintenanceFailpoint?: ((ctx: DurableObjectState) => ConversationMaintenanceFailpointHandler) | undefined;
393
+ /** Host-supplied fail-closed authorization policy; defaults to service possession. */
394
+ readonly operationAuthorizer?: OperationAuthorizerService | undefined;
370
395
  /**
371
396
  * Reconciliation policy consulted for open ordinary Tool Calls before an Unknown Outcome
372
397
  * is recorded (durability §10, DUR-009). Defaults to the fail-closed
@@ -397,7 +422,7 @@ type CloudflareBindingSource = ReadonlyArray<ResolvedBinding> | Effect.Effect<Re
397
422
  /** Every construction failure of the assembled Cloudflare durable runtime stack. */
398
423
  type CloudflareDurableRuntimeInitializationError = CloudflarePlatformConfigError | DoStorageInitializationError;
399
424
  /** The services `CloudflareDurableRuntime.layer` provides. */
400
- type CloudflareDurableRuntimeServices = DurableAgentRuntime | SubmissionLedger | ConversationStore | WakeScheduler | DurableRuntimeConfig | AgentBindingResolver | CloudflareDurableRuntimeConfig | ConversationObjectIdentity | DurableAlarmService | ConversationMaintenance | ConversationObjectPorts;
425
+ type CloudflareDurableRuntimeServices = DurableAgentRuntime | SubmissionLedger | ConversationStore | WakeScheduler | DurableRuntimeConfig | AgentBindingResolver | CloudflareDurableRuntimeConfig | ConversationObjectIdentity | DurableAlarmService | ConversationMaintenance | ConversationObjectPorts | ProgressWaitRegistry;
401
426
  declare const ConversationObjectPorts_base: Context.ServiceClass<ConversationObjectPorts, "@effect-agent/platform-cloudflare/ConversationObjectPorts", {
402
427
  readonly handle: (encoded: unknown) => Effect.Effect<unknown>;
403
428
  }>;
@@ -444,6 +469,10 @@ declare const ConversationClientError_base: Schema.Class<ConversationClientError
444
469
  readonly conversationId: Schema.String;
445
470
  readonly message: Schema.String;
446
471
  readonly cause: Schema.optionalKey<Schema.Defect>;
472
+ /** Cloudflare's own classification for a failure safe to retry with a fresh stub. */
473
+ readonly retryable: Schema.optionalKey<Schema.Boolean>;
474
+ /** Cloudflare overloads are surfaced immediately instead of adding retry pressure. */
475
+ readonly overloaded: Schema.optionalKey<Schema.Boolean>;
447
476
  }>, import("effect/Cause").YieldableError>;
448
477
  /** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */
449
478
  declare class ConversationClientError extends ConversationClientError_base {}
@@ -467,13 +496,24 @@ declare const ObservePageRequest_base: Schema.Class<ObservePageRequest, Schema.S
467
496
  }>, {}>;
468
497
  /** One bounded page of canonical records after an optional sequence. */
469
498
  declare class ObservePageRequest extends ObservePageRequest_base {}
499
+ declare const AwaitProgressRequest_base: Schema.Class<AwaitProgressRequest, Schema.Struct<{
500
+ readonly afterSequence: Schema.brand<Schema.Natural, "@effect-agent/session/CanonicalSequence">;
501
+ readonly waiterId: Schema.String;
502
+ }>, {}>;
503
+ /** One event-driven wait for canonical progress strictly after this sequence. */
504
+ declare class AwaitProgressRequest extends AwaitProgressRequest_base {}
505
+ declare const CancelProgressRequest_base: Schema.Class<CancelProgressRequest, Schema.Struct<{
506
+ readonly waiterId: Schema.String;
507
+ }>, {}>;
508
+ /** Best-effort cancellation of one in-flight progress RPC. */
509
+ declare class CancelProgressRequest extends CancelProgressRequest_base {}
470
510
  /**
471
511
  * Every typed failure a host entry point can produce, plus the protocol's own errors. Same
472
512
  * closed-union discipline as the WP2 `PortFailure`: members re-decode to the SAME tagged
473
513
  * classes on the Worker side; `cause` chains travel as Schema defects without instance
474
514
  * fidelity (plan §2.8).
475
515
  */
476
- declare const HostFailure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof HostProtocolError]>;
516
+ declare const HostFailure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof OperationDenied, typeof HostProtocolError]>;
477
517
  type HostFailure = typeof HostFailure.Type;
478
518
  declare const SubmitSucceeded_base: Schema.Class<SubmitSucceeded, Schema.TaggedStruct<"SubmitSucceeded", {
479
519
  readonly receipt: typeof Receipt;
@@ -487,6 +527,11 @@ declare const ObservedPage_base: Schema.Class<ObservedPage, Schema.TaggedStruct<
487
527
  readonly records: Schema.$Array<typeof CanonicalRecordEnvelope>;
488
528
  }>, {}>;
489
529
  declare class ObservedPage extends ObservedPage_base {}
530
+ declare const ProgressObserved_base: Schema.Class<ProgressObserved, Schema.TaggedStruct<"ProgressObserved", {}>, {}>;
531
+ /** A record was already committed or an incarnation-local hint says the caller should re-read. */
532
+ declare class ProgressObserved extends ProgressObserved_base {}
533
+ declare const ProgressCancelled_base: Schema.Class<ProgressCancelled, Schema.TaggedStruct<"ProgressCancelled", {}>, {}>;
534
+ declare class ProgressCancelled extends ProgressCancelled_base {}
490
535
  declare const AbortRecorded_base: Schema.Class<AbortRecorded, Schema.TaggedStruct<"AbortRecorded", {
491
536
  readonly intent: typeof AbortIntent;
492
537
  }>, {}>;
@@ -500,12 +545,12 @@ declare const UnknownResolutionRecorded_base: Schema.Class<UnknownResolutionReco
500
545
  }>, {}>;
501
546
  declare class UnknownResolutionRecorded extends UnknownResolutionRecorded_base {}
502
547
  declare const HostFailed_base: Schema.Class<HostFailed, Schema.TaggedStruct<"HostFailed", {
503
- readonly failure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof HostProtocolError]>;
548
+ readonly failure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof SettlementConflict, typeof ApprovalConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof LedgerError, typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof OperationDenied, typeof HostProtocolError]>;
504
549
  }>, {}>;
505
550
  /** The entry point failed TYPED on the Object; the failure re-decodes verbatim. */
506
551
  declare class HostFailed extends HostFailed_base {}
507
552
  /** The uniform answer of one host entry point. Callers narrow by the tag their call implies. */
508
- declare const HostResponse: Schema.Union<readonly [typeof SubmitSucceeded, typeof SettlementReached, typeof ObservedPage, typeof AbortRecorded, typeof ApprovalRecorded, typeof UnknownResolutionRecorded, typeof HostFailed]>;
553
+ declare const HostResponse: Schema.Union<readonly [typeof SubmitSucceeded, typeof SettlementReached, typeof ObservedPage, typeof ProgressObserved, typeof ProgressCancelled, typeof AbortRecorded, typeof ApprovalRecorded, typeof UnknownResolutionRecorded, typeof HostFailed]>;
509
554
  type HostResponse = typeof HostResponse.Type;
510
555
  declare const decodeSubmitRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<SubmitRequest, Schema.SchemaError, never>;
511
556
  declare const encodeSubmitRequest: (input: SubmitRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
@@ -531,6 +576,15 @@ declare const encodeObservePageRequest: (input: ObservePageRequest, options?: im
531
576
  readonly afterSequence?: number | undefined;
532
577
  readonly limit: number;
533
578
  }, Schema.SchemaError, never>;
579
+ declare const decodeAwaitProgressRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AwaitProgressRequest, Schema.SchemaError, never>;
580
+ declare const encodeAwaitProgressRequest: (input: AwaitProgressRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
581
+ readonly afterSequence: number;
582
+ readonly waiterId: string;
583
+ }, Schema.SchemaError, never>;
584
+ declare const decodeCancelProgressRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<CancelProgressRequest, Schema.SchemaError, never>;
585
+ declare const encodeCancelProgressRequest: (input: CancelProgressRequest, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
586
+ readonly waiterId: string;
587
+ }, Schema.SchemaError, never>;
534
588
  declare const decodeAbortCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortCommand, Schema.SchemaError, never>;
535
589
  declare const encodeAbortCommand: (input: AbortCommand, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
536
590
  readonly submissionId: string;
@@ -563,7 +617,7 @@ declare const encodeUnknownResolutionCommand: (input: UnknownResolutionCommand,
563
617
  readonly _tag: "AbortSubmission";
564
618
  };
565
619
  }, Schema.SchemaError, never>;
566
- declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
620
+ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
567
621
  readonly _tag: "SubmitSucceeded";
568
622
  readonly receipt: {
569
623
  readonly receiptId: string;
@@ -594,42 +648,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
594
648
  readonly createdAt: string;
595
649
  readonly deploymentId: string;
596
650
  readonly payload: {
597
- readonly _tag: "ToolCallPrepared";
598
- readonly runId: string;
599
- readonly turnId: string;
600
- readonly turn: number;
601
- readonly toolCallId: string;
602
- readonly toolName: string;
603
- readonly parameters: Schema.Json;
604
- readonly parametersDigest: string;
605
- } | {
606
- readonly _tag: "ToolCallUnknown";
607
- readonly runId: string;
608
- readonly turn: number;
609
- readonly toolCallId: string;
610
- readonly toolName: string;
611
- readonly reason: string;
612
- } | {
613
- readonly _tag: "ToolApprovalDecided";
614
- readonly runId: string;
615
- readonly turn: number;
616
- readonly toolCallId: string;
617
- readonly decision: "approved" | "denied";
618
- readonly resolver: string;
619
- readonly reason: string;
620
- } | {
621
- readonly _tag: "ToolCallResolved";
622
- readonly runId: string;
623
- readonly toolCallId: string;
624
- readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
625
- readonly author: string;
626
- readonly reason: string;
627
- } | {
628
- readonly _tag: "AbortRequested";
629
- readonly submissionId: string;
630
- readonly author: string;
631
- readonly reason: string;
632
- } | {
633
651
  readonly _tag: "ConversationCreated";
634
652
  readonly agentId: string;
635
653
  readonly definitions: {
@@ -657,6 +675,15 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
657
675
  readonly inputTokens?: number | undefined;
658
676
  readonly outputTokens?: number | undefined;
659
677
  readonly costMicrousd?: number | undefined;
678
+ } | {
679
+ readonly _tag: "ToolCallPrepared";
680
+ readonly runId: string;
681
+ readonly turnId: string;
682
+ readonly turn: number;
683
+ readonly toolCallId: string;
684
+ readonly toolName: string;
685
+ readonly parameters: Schema.Json;
686
+ readonly parametersDigest: string;
660
687
  } | {
661
688
  readonly _tag: "ToolCallSettled";
662
689
  readonly runId: string;
@@ -664,6 +691,20 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
664
691
  readonly toolName: string;
665
692
  readonly result: Schema.Json;
666
693
  readonly isFailure: boolean;
694
+ } | {
695
+ readonly _tag: "ToolCallUnknown";
696
+ readonly runId: string;
697
+ readonly turn: number;
698
+ readonly toolCallId: string;
699
+ readonly toolName: string;
700
+ readonly reason: string;
701
+ } | {
702
+ readonly _tag: "ToolCallResolved";
703
+ readonly runId: string;
704
+ readonly toolCallId: string;
705
+ readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
706
+ readonly author: string;
707
+ readonly reason: string;
667
708
  } | {
668
709
  readonly _tag: "ToolStepSettled";
669
710
  readonly runId: string;
@@ -679,6 +720,14 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
679
720
  readonly toolCallId: string;
680
721
  readonly toolName: string;
681
722
  readonly parametersDigest: string;
723
+ } | {
724
+ readonly _tag: "ToolApprovalDecided";
725
+ readonly runId: string;
726
+ readonly turn: number;
727
+ readonly toolCallId: string;
728
+ readonly decision: "approved" | "denied";
729
+ readonly resolver: string;
730
+ readonly reason: string;
682
731
  } | {
683
732
  readonly _tag: "ModelResponseInterrupted";
684
733
  readonly runId: string;
@@ -700,6 +749,11 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
700
749
  readonly _tag: "RunCompleted";
701
750
  readonly runId: string;
702
751
  readonly output: Schema.Json;
752
+ } | {
753
+ readonly _tag: "AbortRequested";
754
+ readonly submissionId: string;
755
+ readonly author: string;
756
+ readonly reason: string;
703
757
  } | {
704
758
  readonly _tag: "SubmissionSettled";
705
759
  readonly submissionId: string;
@@ -777,6 +831,10 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
777
831
  };
778
832
  };
779
833
  }[];
834
+ } | {
835
+ readonly _tag: "ProgressObserved";
836
+ } | {
837
+ readonly _tag: "ProgressCancelled";
780
838
  } | {
781
839
  readonly _tag: "AbortRecorded";
782
840
  readonly intent: {
@@ -821,18 +879,50 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
821
879
  } | {
822
880
  readonly _tag: "HostFailed";
823
881
  readonly failure: {
824
- readonly _tag: "LedgerError";
825
- readonly operation: string;
882
+ readonly _tag: "HostProtocolError";
883
+ readonly message: string;
884
+ } | {
885
+ readonly _tag: "OperationDenied";
886
+ readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
887
+ readonly reason: string;
888
+ readonly conversationId?: string | undefined;
889
+ readonly submissionId?: string | undefined;
890
+ } | {
891
+ readonly _tag: "AgentInputError";
826
892
  readonly message: string;
827
- readonly cause?: Schema.Json | undefined;
828
893
  } | {
829
894
  readonly _tag: "DigestError";
830
895
  readonly message: string;
831
896
  readonly cause?: Schema.Json | undefined;
897
+ } | {
898
+ readonly _tag: "AdmissionConflict";
899
+ readonly conversationId: string;
900
+ readonly principal: string;
901
+ readonly idempotencyKey: string;
902
+ readonly existingInputDigest: string;
903
+ readonly attemptedInputDigest: string;
832
904
  } | {
833
905
  readonly _tag: "SettlementConflict";
834
906
  readonly submissionId: string;
835
907
  readonly existingOutcome: "aborted" | "completed" | "failed";
908
+ } | {
909
+ readonly _tag: "ApprovalConflict";
910
+ readonly submissionId: string;
911
+ readonly toolCallId: string;
912
+ readonly existingDecision: "approved" | "denied";
913
+ } | {
914
+ readonly _tag: "UnknownResolutionConflict";
915
+ readonly submissionId: string;
916
+ readonly toolCallId: string;
917
+ } | {
918
+ readonly _tag: "JoinedToHost";
919
+ readonly submissionId: string;
920
+ readonly hostSubmissionId: string;
921
+ } | {
922
+ readonly _tag: "LedgerError";
923
+ readonly operation: string;
924
+ readonly message: string;
925
+ readonly cause?: Schema.Json | undefined;
836
926
  } | {
837
927
  readonly _tag: "ConversationStoreError";
838
928
  readonly operation: string;
@@ -856,57 +946,37 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
856
946
  } | {
857
947
  readonly _tag: "DurableRuntimeFailpointError";
858
948
  readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "compaction:after-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "resolve:after-intent" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append";
859
- } | {
860
- readonly _tag: "DurableAlarmError";
861
- readonly operation: string;
862
- readonly message: string;
863
- readonly cause?: Schema.Json | undefined;
864
- } | {
865
- readonly _tag: "HostProtocolError";
866
- readonly message: string;
867
- } | {
868
- readonly _tag: "AgentInputError";
869
- readonly message: string;
870
- } | {
871
- readonly _tag: "AdmissionConflict";
872
- readonly conversationId: string;
873
- readonly principal: string;
874
- readonly idempotencyKey: string;
875
- readonly existingInputDigest: string;
876
- readonly attemptedInputDigest: string;
877
- } | {
878
- readonly _tag: "ApprovalConflict";
879
- readonly submissionId: string;
880
- readonly toolCallId: string;
881
- readonly existingDecision: "approved" | "denied";
882
- } | {
883
- readonly _tag: "UnknownResolutionConflict";
884
- readonly submissionId: string;
885
- readonly toolCallId: string;
886
- } | {
887
- readonly _tag: "JoinedToHost";
888
- readonly submissionId: string;
889
- readonly hostSubmissionId: string;
890
949
  } | {
891
950
  readonly _tag: "AdmissionLimitExceeded";
892
951
  readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
893
952
  readonly actual: number;
894
953
  readonly maximum: number;
954
+ } | {
955
+ readonly _tag: "DurableAlarmError";
956
+ readonly operation: string;
957
+ readonly message: string;
958
+ readonly cause?: Schema.Json | undefined;
895
959
  };
896
960
  }, Schema.SchemaError, never>;
897
- declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
961
+ declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
898
962
  /** Failure surface of `CloudflareConversationClient.submit`. */
899
963
  type ClientSubmitFailure = AgentInputError | DigestError | AdmissionConflict | LedgerError | ConversationStoreError | ConversationNotMaterialized | AppendConflict | FenceRejected | DurableRuntimeFailpointError | AdmissionLimitExceeded | DurableAlarmError | HostProtocolError | ConversationClientError;
900
964
  type ClientAwaitFailure = LedgerError | SettlementConflict | HostProtocolError | ConversationClientError;
901
- type ClientObserveFailure = ConversationStoreError | ConversationNotMaterialized | HostProtocolError | ConversationClientError;
965
+ type ClientObserveFailure = ConversationStoreError | ConversationNotMaterialized | OperationDenied | HostProtocolError | ConversationClientError;
966
+ type ClientProgressFailure = ConversationStoreError | ConversationNotMaterialized | OperationDenied | HostProtocolError | ConversationClientError;
902
967
  type ClientAbortFailure = LedgerError | SettlementConflict | JoinedToHost | DurableRuntimeFailpointError | DurableAlarmError | HostProtocolError | ConversationClientError;
903
- type ClientApprovalFailure = LedgerError | SettlementConflict | ApprovalConflict | DurableAlarmError | HostProtocolError | ConversationClientError;
904
- type ClientUnknownFailure = LedgerError | SettlementConflict | UnknownResolutionConflict | JoinedToHost | DurableRuntimeFailpointError | DurableAlarmError | HostProtocolError | ConversationClientError;
968
+ type ClientApprovalFailure = LedgerError | SettlementConflict | ApprovalConflict | OperationDenied | DurableAlarmError | HostProtocolError | ConversationClientError;
969
+ type ClientUnknownFailure = LedgerError | SettlementConflict | UnknownResolutionConflict | JoinedToHost | DurableRuntimeFailpointError | OperationDenied | DurableAlarmError | HostProtocolError | ConversationClientError;
905
970
  declare const CloudflareConversationClient_base: Context.ServiceClass<CloudflareConversationClient, "@effect-agent/platform-cloudflare/CloudflareConversationClient", {
906
971
  /** Encode the input client-side, then durably submit to the owning Object. */
907
972
  readonly submit: <InputSchema extends Schema.Top>(agent: DurableSubmitAgent<InputSchema>, input: InputSchema["Type"], options: DurableSubmitOptions) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema["EncodingServices"]>;
908
973
  /** Wake-hinted, poll-guaranteed settlement wait executed inside the owning Object. */
909
974
  readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, ClientAwaitFailure>;
975
+ /**
976
+ * Wait without polling until progress after `afterSequence` is already durable or hinted.
977
+ * The result is deliberately void: canonical records remain authoritative and must be read.
978
+ */
979
+ readonly awaitProgress: (conversationId: ConversationId, afterSequence: CanonicalSequence) => Effect.Effect<void, ClientProgressFailure>;
910
980
  /** One bounded page of canonical records. */
911
981
  readonly readPage: (conversationId: ConversationId, options?: {
912
982
  readonly afterSequence?: CanonicalSequence | undefined;
@@ -929,7 +999,7 @@ declare const CloudflareConversationClient_base: Context.ServiceClass<Cloudflare
929
999
  }>;
930
1000
  /** Worker-side client over the Conversation Object namespace (DEPLOY-010). */
931
1001
  declare class CloudflareConversationClient extends CloudflareConversationClient_base {
932
- static readonly layer: Layer.Layer<CloudflareConversationClient, never, ConversationObjectNamespace>;
1002
+ static readonly layer: Layer.Layer<CloudflareConversationClient, never, ConversationObjectNamespace | Crypto.Crypto>;
933
1003
  }
934
1004
  //#endregion
935
1005
  //#region src/conversation-object.d.ts
@@ -1478,6 +1548,8 @@ declare const decodeAdminResponse: (input: unknown, options?: import("effect/Sch
1478
1548
  interface ConversationObjectInstance extends DurableObject$1 {
1479
1549
  submitEncoded(encoded: unknown): Promise<unknown>;
1480
1550
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1551
+ awaitProgressEncoded(encoded: unknown): Promise<unknown>;
1552
+ cancelProgressEncoded(encoded: unknown): Promise<unknown>;
1481
1553
  observePage(encoded: unknown): Promise<unknown>;
1482
1554
  abortEncoded(encoded: unknown): Promise<unknown>;
1483
1555
  resolveApprovalEncoded(encoded: unknown): Promise<unknown>;
@@ -1546,5 +1618,5 @@ interface DynamicWorkerCodeExecutorOptions {
1546
1618
  /** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
1547
1619
  declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
1548
1620
  //#endregion
1549
- export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CodeModeHostEntrypoint, CodeModeHostStub, ConversationClientError, ConversationMaintenance, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, DynamicWorkerCodeExecutorOptions, ExplainedRecovery, HostFailed, HostFailure, HostProtocolError, HostResponse, MaintenancePassFailure, MaintenancePassReport, ObligationsScanned, ObservePageRequest, ObservedPage, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1621
+ export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, AwaitProgressRequest, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CodeModeHostEntrypoint, CodeModeHostStub, ConversationClientError, ConversationMaintenance, ConversationMaintenanceFailpoint, ConversationMaintenanceFailpointHandler, ConversationMaintenanceFailpointLocation, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, DynamicWorkerCodeExecutorOptions, ExplainedRecovery, HostFailed, HostFailure, HostProtocolError, HostResponse, MaintenancePassFailure, MaintenancePassReport, ObligationsScanned, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, ProgressWaitRegistry, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1550
1622
  //# sourceMappingURL=index.d.mts.map