@effect-agent/platform-cloudflare 0.1.0-beta.9 → 0.1.0-beta.91

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.
Files changed (100) hide show
  1. package/dist/Alarm.d.mts +188 -0
  2. package/dist/Alarm.mjs +451 -0
  3. package/dist/Alarm.mjs.map +1 -0
  4. package/dist/BrowserRestCapture.d.mts +35 -0
  5. package/dist/BrowserRestCapture.mjs +238 -0
  6. package/dist/BrowserRestCapture.mjs.map +1 -0
  7. package/dist/BrowserRestCrawl.d.mts +17 -0
  8. package/dist/BrowserRestCrawl.mjs +244 -0
  9. package/dist/BrowserRestCrawl.mjs.map +1 -0
  10. package/dist/CloudflareAiGateway.d.mts +64 -0
  11. package/dist/CloudflareAiGateway.mjs +70 -0
  12. package/dist/CloudflareAiGateway.mjs.map +1 -0
  13. package/dist/CloudflareBindings.d.mts +115 -0
  14. package/dist/CloudflareBindings.mjs +113 -0
  15. package/dist/CloudflareBindings.mjs.map +1 -0
  16. package/dist/CloudflareBrowser-DV6kya1H.mjs +495 -0
  17. package/dist/CloudflareBrowser-DV6kya1H.mjs.map +1 -0
  18. package/dist/CloudflareBrowser-Doe1M7R5.d.mts +80 -0
  19. package/dist/CloudflareBrowser.d.mts +2 -0
  20. package/dist/CloudflareBrowser.mjs +2 -0
  21. package/dist/CloudflareCodeMode.d.mts +44 -0
  22. package/dist/CloudflareCodeMode.mjs +616 -0
  23. package/dist/CloudflareCodeMode.mjs.map +1 -0
  24. package/dist/CloudflareConfig-f3CqTel1.d.mts +101 -0
  25. package/dist/CloudflareConfig.d.mts +2 -0
  26. package/dist/CloudflareConfig.mjs +122 -0
  27. package/dist/CloudflareConfig.mjs.map +1 -0
  28. package/dist/CloudflareMemory.d.mts +142 -0
  29. package/dist/CloudflareMemory.mjs +202 -0
  30. package/dist/CloudflareMemory.mjs.map +1 -0
  31. package/dist/CloudflareScheduling.d.mts +52 -0
  32. package/dist/CloudflareScheduling.mjs +396 -0
  33. package/dist/CloudflareScheduling.mjs.map +1 -0
  34. package/dist/CloudflareSubscriptions.d.mts +87 -0
  35. package/dist/CloudflareSubscriptions.mjs +530 -0
  36. package/dist/CloudflareSubscriptions.mjs.map +1 -0
  37. package/dist/CloudflareThreadClient.d.mts +1496 -0
  38. package/dist/CloudflareThreadClient.mjs +382 -0
  39. package/dist/CloudflareThreadClient.mjs.map +1 -0
  40. package/dist/InteractiveBrowser-DUE_m12-.d.mts +161 -0
  41. package/dist/InteractiveBrowser-DupDtfw2.mjs +1169 -0
  42. package/dist/InteractiveBrowser-DupDtfw2.mjs.map +1 -0
  43. package/dist/InteractiveBrowser.d.mts +2 -0
  44. package/dist/InteractiveBrowser.mjs +2 -0
  45. package/dist/ProtectedBrowser.d.mts +123 -0
  46. package/dist/ProtectedBrowser.mjs +1135 -0
  47. package/dist/ProtectedBrowser.mjs.map +1 -0
  48. package/dist/ThreadObject-CIbmXZCY.d.mts +812 -0
  49. package/dist/ThreadObject-DvRG0dDz.mjs +835 -0
  50. package/dist/ThreadObject-DvRG0dDz.mjs.map +1 -0
  51. package/dist/ThreadObject.d.mts +2 -0
  52. package/dist/ThreadObject.mjs +3 -0
  53. package/dist/WakeScheduler.d.mts +23 -0
  54. package/dist/WakeScheduler.mjs +57 -0
  55. package/dist/WakeScheduler.mjs.map +1 -0
  56. package/dist/boundary-BguazVkh.mjs +42 -0
  57. package/dist/boundary-BguazVkh.mjs.map +1 -0
  58. package/dist/index.d.mts +13 -1548
  59. package/dist/index.mjs +13 -1636
  60. package/dist/prepared-admission-DU0_T-ev.mjs +73 -0
  61. package/dist/prepared-admission-DU0_T-ev.mjs.map +1 -0
  62. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  63. package/package.json +1 -53
  64. package/src/Alarm.ts +973 -0
  65. package/src/BrowserRestCapture.ts +477 -0
  66. package/src/BrowserRestCrawl.ts +540 -0
  67. package/src/CloudflareAiGateway.ts +170 -0
  68. package/src/CloudflareBindings.ts +199 -0
  69. package/src/CloudflareBrowser.ts +15 -0
  70. package/src/{code-mode-executor.ts → CloudflareCodeMode.ts} +372 -204
  71. package/src/{config.ts → CloudflareConfig.ts} +9 -8
  72. package/src/CloudflareMemory.ts +420 -0
  73. package/src/CloudflareScheduling.ts +747 -0
  74. package/src/CloudflareSubscriptions.ts +1041 -0
  75. package/src/CloudflareThreadClient.ts +809 -0
  76. package/src/InteractiveBrowser.ts +2354 -0
  77. package/src/ProtectedBrowser.ts +9 -0
  78. package/src/ThreadObject.ts +1179 -0
  79. package/src/{wake-scheduler.ts → WakeScheduler.ts} +32 -26
  80. package/src/index.ts +12 -23
  81. package/src/internal/boundary.ts +55 -0
  82. package/src/internal/browser-quick-action.ts +857 -0
  83. package/src/internal/browser-session-lifecycle.ts +160 -0
  84. package/src/internal/layers.ts +751 -0
  85. package/src/internal/message-delivery.ts +152 -0
  86. package/src/internal/prepared-admission.ts +116 -0
  87. package/src/internal/progress-wait.ts +121 -0
  88. package/src/internal/transport.ts +44 -0
  89. package/src/protected-browser/binding.ts +313 -0
  90. package/src/protected-browser/host.ts +344 -0
  91. package/src/protected-browser/inspect-frame.ts +125 -0
  92. package/src/protected-browser/native.ts +445 -0
  93. package/src/protected-browser/policy.ts +821 -0
  94. package/dist/index.mjs.map +0 -1
  95. package/src/alarm.ts +0 -334
  96. package/src/bindings.ts +0 -145
  97. package/src/client.ts +0 -646
  98. package/src/conversation-object.ts +0 -768
  99. package/src/layers.ts +0 -376
  100. package/src/transport.ts +0 -38
@@ -0,0 +1,812 @@
1
+ import { DurableObjectContext, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement } from "./CloudflareBindings.mjs";
2
+ import { c as CloudflarePlatformConfigError, o as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded } from "./CloudflareConfig-f3CqTel1.mjs";
3
+ import { DurableAlarmError, DurableAlarmService, ThreadMaintenance, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMutationGate, ThreadPublication } from "./Alarm.mjs";
4
+ import { HostProtocolError, SubmitRequest } from "./CloudflareThreadClient.mjs";
5
+ import { Context, Crypto, Effect, Layer, Option, Schema, Scope } from "effect";
6
+ import { AgentRegistration } from "effect-agent/agent-registration";
7
+ import { DurableAgentRuntime, DurableRuntimeConfig, RecoveryReport } from "effect-agent/durable-agent-runtime";
8
+ import { SubmissionId, ThreadId } from "effect-agent/identifiers";
9
+ import { AdmissionPolicyError, LedgerError, OwnershipLost, SettlementConflict, SubmissionLedger, SubmissionSnapshot } from "effect-agent/submission-ledger";
10
+ import { ThreadProjectionMaintenance } from "effect-agent/thread-projection-maintenance";
11
+ import { SqlClient } from "effect/unstable/sql/SqlClient";
12
+ import { DurableObject, DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
13
+ import { DigestError } from "effect-agent/digest";
14
+ import { DurableRuntimeFailpoint, DurableRuntimeFailpointError, DurableRuntimeFailpointHandler } from "effect-agent/durable-failpoint";
15
+ import { OperationAuthorizerService, OperationDenied } from "effect-agent/operation-authorizer";
16
+ import { AppendConflict, FenceRejected, ThreadNotMaterialized, ThreadStore, ThreadStoreError } from "effect-agent/thread-store";
17
+ import { PreparedInputAdmission } from "effect-agent/prepared-input-admission";
18
+ import { PortRequest, PortResponse } from "@effect-agent/storage-cloudflare/port-protocol";
19
+ import { IntegrityReport, ObligationReport, ObligationThresholds, RecoveryExplanation, RetryCommand, RetryRefused } from "effect-agent/admin";
20
+ import { RunJournalError } from "effect-agent/run-journal";
21
+ import { WakeScheduler } from "effect-agent/wake-scheduler";
22
+ import { DoStorageFailpoint, DoStorageFailpointHandler } from "@effect-agent/storage-cloudflare/do-storage-failpoint";
23
+ import { DoStorageInitializationError } from "@effect-agent/storage-cloudflare/do-thread-store";
24
+ import { MessageDeliveryError, MessageDeliveryStore } from "effect-agent/message-delivery";
25
+ import { RunContextPreparation, RunCostEstimator, RunToolAuthorization, RunToolFailureObserver } from "effect-agent/run-options";
26
+ import { ToolReconciler } from "effect-agent/tool-reconciler";
27
+ //#region src/internal/progress-wait.d.ts
28
+ declare const ProgressWaitRegistry_base: Context.ServiceClass<ProgressWaitRegistry, "@effect-agent/platform-cloudflare/ProgressWaitRegistry", {
29
+ /** Register a Scope-owned cancellation signal, observing any early cancel tombstone. */
30
+ readonly subscribe: (waiterId: string) => Effect.Effect<Effect.Effect<void>, never, Scope.Scope>;
31
+ /** Cancel every attempt and retain a bounded tombstone for later transport attempts. */
32
+ readonly cancel: (waiterId: string) => Effect.Effect<void>;
33
+ }>;
34
+ /**
35
+ * Per-incarnation cancellation registry for long-lived progress RPCs. The public runtime owns
36
+ * the actual wake registration; this host-only registry lets an interrupted Worker Effect ask
37
+ * the Object to interrupt its scoped wait before the Worker execution context itself ends.
38
+ */
39
+ declare class ProgressWaitRegistry extends ProgressWaitRegistry_base {
40
+ static readonly layer: Layer.Layer<ProgressWaitRegistry>;
41
+ }
42
+ //#endregion
43
+ //#region src/internal/layers.d.ts
44
+ /**
45
+ * Raw (unvalidated) construction options for `ThreadObject.make`, mirroring
46
+ * `NodeDurableAgentRuntimeOptions`. Optional fields default to the documented production values
47
+ * (`CLOUDFLARE_RUNTIME_DEFAULTS`); everything is schema-decoded into
48
+ * `CloudflareDurableRuntimeConfigValue` before any resource opens (deployment §5 gate 1).
49
+ */
50
+ interface CloudflareDurableRuntimeOptions {
51
+ readonly deploymentId: string;
52
+ /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */
53
+ readonly producerPrefix: string;
54
+ /** Milliseconds; default 30s (D5). */
55
+ readonly ownershipLeaseDuration?: number | undefined;
56
+ /** Milliseconds; default 100. */
57
+ readonly alarmBackoffBase?: number | undefined;
58
+ /** Milliseconds; default 5000. */
59
+ readonly alarmBackoffCap?: number | undefined;
60
+ /** Milliseconds; default 1000. Bounds every alarm re-arm delay. */
61
+ readonly wakeScanInterval?: number | undefined;
62
+ /** Milliseconds; default 500. */
63
+ readonly settlementPollInterval?: number | undefined;
64
+ /** Milliseconds; default 10000. */
65
+ readonly leaseRenewalInterval?: number | undefined;
66
+ /** Milliseconds; default 500. */
67
+ readonly abortPollInterval?: number | undefined;
68
+ /** Deployment-owned pricing authority used by durable cost budgets and settlements. */
69
+ readonly estimateCostMicrousd?: RunCostEstimator | undefined;
70
+ /** Closed trusted Tool failure reporting. Omission masks ambient observers at construction. */
71
+ readonly toolFailureObserver?: RunToolFailureObserver | undefined;
72
+ /** Milliseconds; default 25. */
73
+ readonly observationPollInterval?: number | undefined;
74
+ /** Bytes; default just under the 2 MB platform value limit. */
75
+ readonly maxStoredValueBytes?: number | undefined;
76
+ /** Default false. */
77
+ readonly verifyOnOpen?: boolean | undefined;
78
+ /** Nonterminal Submissions per lane before admission refuses; default 256. */
79
+ readonly maxQueueDepthPerLane?: number | undefined;
80
+ /** Encoded input bytes per Submission; default = the stored-value bound. */
81
+ readonly maxInputBytes?: number | undefined;
82
+ /** `ctx.storage.sql.databaseSize` ceiling at admission; default 9 GB (10 GB platform cap). */
83
+ readonly maxDatabaseBytes?: number | undefined;
84
+ /**
85
+ * Durable Object storage fault injection (`ledger:*` / `append:*` locations). Handlers are
86
+ * constructed per incarnation WITH the live `DurableObjectState`, so eviction harnesses can
87
+ * map an armed hit to `ctx.abort()` — the platform's real failure mode. Default none.
88
+ */
89
+ readonly storageFailpoint?: ((ctx: DurableObjectState) => DoStorageFailpointHandler) | undefined;
90
+ /** Coordinator fault injection (`submit:*` / `terminalize:*` locations); default none. */
91
+ readonly runtimeFailpoint?: ((ctx: DurableObjectState) => DurableRuntimeFailpointHandler) | undefined;
92
+ /** Thread-maintenance generation/alarm fault injection; default none. */
93
+ readonly maintenanceFailpoint?: ((ctx: DurableObjectState) => ThreadMaintenanceFailpointHandler) | undefined;
94
+ /** Host-supplied fail-closed authorization policy; defaults to service possession. */
95
+ readonly operationAuthorizer?: OperationAuthorizerService | undefined;
96
+ /**
97
+ * Reconciliation policy consulted for open ordinary Tool Calls before an Unknown Outcome
98
+ * is recorded (durability §10, DUR-009). Defaults to the fail-closed
99
+ * `ToolReconciler.uncertain`.
100
+ */
101
+ readonly toolReconciler?: Layer.Layer<ToolReconciler> | undefined;
102
+ }
103
+ /** Services supplied before the application graph is built, including its dependencies. */
104
+ type CloudflareBootstrapServices = CloudflareDurableRuntimeConfig | ThreadObjectIdentity | ThreadObjectPlacement | DurableRuntimeConfig | Crypto.Crypto | DoStorageFailpoint | DurableRuntimeFailpoint | ThreadMaintenanceFailpoint | RunContextPreparation | RunToolAuthorization | ToolReconciler;
105
+ /** Every construction failure of the assembled Cloudflare durable runtime stack. */
106
+ type CloudflareDurableRuntimeInitializationError = CloudflarePlatformConfigError | DigestError | MessageDeliveryError | DoStorageInitializationError;
107
+ /**
108
+ * The services `ThreadObject.layer` provides, including its single owner SQL client.
109
+ * Its Context also supplies ThreadMessageDelivery (a defaulted Reference, with no required R)
110
+ * so application-composed maintenance retains the same native message recovery capability.
111
+ */
112
+ type CloudflareDurableRuntimeServices = DurableAgentRuntime | SubmissionLedger | ThreadStore | MessageDeliveryStore | WakeScheduler | DurableAlarmService | ThreadMaintenance | ThreadMutationGate | ThreadPublication | ThreadProjectionMaintenance | ThreadObjectPorts | ProgressWaitRegistry | SqlClient;
113
+ declare const ThreadObjectPorts_base: Context.ServiceClass<ThreadObjectPorts, "@effect-agent/platform-cloudflare/ThreadObjectPorts", {
114
+ readonly handle: (request: PortRequest) => Effect.Effect<PortResponse>;
115
+ /** Local-only identity check before a bound RPC can read or mutate a Submission. */
116
+ readonly lookupSubmission: (submissionId: SubmissionId) => Effect.Effect<Option.Option<SubmissionSnapshot>, LedgerError>;
117
+ }>;
118
+ /**
119
+ * Owner-side execution port for a `portCall` request the wire endpoint has already decoded.
120
+ * It executes against THIS Object's LOCAL port facets — never the routed decorators, so a
121
+ * request cannot bounce between Objects — and returns the typed response for the endpoint to
122
+ * encode.
123
+ */
124
+ declare class ThreadObjectPorts extends ThreadObjectPorts_base {}
125
+ /** Native one-Thread configuration; retains its existing producer and logical identities. */
126
+ declare const layerConfig: (options: CloudflareDurableRuntimeOptions) => Layer.Layer<CloudflareBootstrapServices, CloudflarePlatformConfigError, DurableObjectContext>;
127
+ /**
128
+ * Configuration for an application Object owning several logical Threads. The producer is
129
+ * the stable physical Object. No logical identity is installed globally: handleRpc binds and
130
+ * validates it per request using the placement guard and this actual runtime producer.
131
+ */
132
+ declare const layerHostConfig: (options: CloudflareDurableRuntimeOptions, ownsThread: (threadId: ThreadId) => boolean) => Layer.Layer<Exclude<CloudflareBootstrapServices, ThreadObjectIdentity>, CloudflarePlatformConfigError, DurableObjectContext>;
133
+ interface ThreadPublicationOptions<E = never, R = never, P = never> {
134
+ /**
135
+ * Optional host outbox consumer, built once per incarnation with RAW LOCAL ThreadStore and
136
+ * SubmissionLedger services. Yield DurableObjectContext and ThreadObjectIdentity for native
137
+ * bindings and identity. Initialization is local-only, inside the constructor gate; setup
138
+ * errors and additional requirements remain in the returned Layer. Layer.effect owns Scope.
139
+ * Canonical appends and durable approval, abort and unknown-resolution intents invalidate
140
+ * publication after commit. Custom host facts must use ThreadMaintenance.withMutation.
141
+ */
142
+ readonly publication?: Layer.Layer<ThreadPublication, E, R>;
143
+ /**
144
+ * Disposable index maintenance, built once with the raw local ThreadStore and owner
145
+ * SqlClient. Additional services P are exposed by the returned Layer, allowing Tool
146
+ * handlers and maintenance to share one index instance. Construction is local-only.
147
+ * Live committed batches run before append returns; bounded backfill uses the native
148
+ * alarm without delaying execution behind projection backlog.
149
+ */
150
+ readonly projection?: Layer.Layer<ThreadProjectionMaintenance | P, E, R>;
151
+ }
152
+ /**
153
+ * Register typed Agents and version declarations. Hashing and dependency capture happen in
154
+ * this Layer's Scope, after application Layers have been provided. Every Agent's instruction,
155
+ * Tool, Schema, and model requirements remain visible until satisfied by Layer composition.
156
+ * Use Layer.unwrap for registration values that need effectful application setup.
157
+ */
158
+ declare const registeredLayer: <const Entries extends ReadonlyArray<AgentRegistration>, E = never, R = never>(registrations: Entries, options?: ThreadPublicationOptions<E, R>) => Layer.Layer<CloudflareDurableRuntimeServices, E | DigestError | MessageDeliveryError | DoStorageInitializationError, DurableObjectContext | ThreadObjectNamespace | Exclude<R, SqlClient | SubmissionLedger | ThreadStore> | Exclude<[Entries[number]] extends [never] ? never : Entries[number] extends (infer T_3) ? T_3 extends Entries[number] ? T_3 extends unknown ? (("attemptLayer" extends keyof T_3 ? T_3[keyof T_3 & "attemptLayer"] : undefined) extends (infer T_4) ? T_4 extends ("attemptLayer" extends keyof T_3 ? T_3[keyof T_3 & "attemptLayer"] : undefined) ? T_4 extends ((context: import("effect-agent/agent-registration").AgentAttemptContext) => Layer.Layer<infer Provides, never, infer Requires>) ? Requires | Exclude<T_3 extends {
159
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
160
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
161
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
162
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
163
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
164
+ };
165
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
166
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
167
+ readonly definition: D;
168
+ readonly model: M;
169
+ }> : never, Provides> : T_3 extends {
170
+ readonly agent: infer A extends import("effect-agent/agent-registration").ExecutableAgentBinding;
171
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<A> : T_3 extends {
172
+ readonly agent: infer D extends import("effect-agent/agent").Definition<Schema.Top, Schema.Top, unknown, import("effect/unstable/ai/Toolkit").Any, import("effect-agent/agent").RunDispositionDeclaration<never, Schema.Top> | undefined, unknown, Schema.Top | undefined> & {
173
+ readonly instructions: import("effect-agent/agent").InstructionSource<never, unknown, unknown>;
174
+ readonly inputPrompt?: import("effect-agent/agent").InputPromptSource<never, unknown, unknown> | undefined;
175
+ };
176
+ readonly model: infer M extends import("effect-agent/agent-registration").ExecutableAgentBinding["model"];
177
+ } ? import("effect-agent/durable-agent-runtime").DurableWorkerRequirements<{
178
+ readonly definition: D;
179
+ readonly model: M;
180
+ }> : never : never : never) | ("reporting" extends keyof T_3 ? T_3[keyof T_3 & "reporting"] extends (infer T_5) ? T_5 extends T_3[keyof T_3 & "reporting"] ? T_5 extends readonly import("effect-agent/subagent-host").WorkerReporting<unknown, unknown>[] ? [T_5[number]] extends [never] ? never : T_5[number] extends import("effect-agent/subagent-host").WorkerReporting<unknown, infer R_1> ? Exclude<R_1, import("effect/Scope").Scope> : never : never : never : never : never) : never : never : never, import("effect/Scope").Scope> | CloudflareBootstrapServices>;
181
+ /** Preserve additional index services only when a projection Layer is actually supplied. */
182
+ declare function layer<const Entries extends ReadonlyArray<AgentRegistration>, E = never, R = never, P = never, PE = never, PR = never>(registrations: Entries, options: Omit<ThreadPublicationOptions<E, R>, "projection"> & {
183
+ readonly projection: Layer.Layer<ThreadProjectionMaintenance | P, PE, PR>;
184
+ }): Layer.Layer<Layer.Success<ReturnType<typeof registeredLayer<Entries, E | PE, R | PR>>> | P, Layer.Error<ReturnType<typeof registeredLayer<Entries, E | PE, R | PR>>>, Layer.Services<ReturnType<typeof registeredLayer<Entries, E | PE, R | PR>>>>;
185
+ declare function layer<const Entries extends ReadonlyArray<AgentRegistration>, E = never, R = never>(registrations: Entries, options?: ThreadPublicationOptions<E, R>): ReturnType<typeof registeredLayer<Entries, E, R>>;
186
+ /**
187
+ * Build the application runtime over the existing owner SqlClient and native ports, then
188
+ * assemble its one maintenance coordinator. The application may acquire its Bindings from
189
+ * those ports and expose extra services, including ThreadHostMaintenance. It must not acquire
190
+ * another runtime stack or require ThreadMaintenance while constructing this Layer.
191
+ * Supply layerHostConfig and deterministic placement; dispatch addressed ingress with handleRpc.
192
+ */
193
+ declare function layerInHost<A, E, R, P = never, PE = never, PR = never>(application: Layer.Layer<DurableAgentRuntime | A, E, R>, options: Omit<ThreadPublicationOptions<PE, PR>, "projection"> & {
194
+ readonly projection: Layer.Layer<ThreadProjectionMaintenance | P, PE, PR>;
195
+ }): Layer.Layer<CloudflareDurableRuntimeServices | A | P, Layer.Error<ReturnType<typeof sharedLayer<A, E, R, PE, PR>>>, Layer.Services<ReturnType<typeof sharedLayer<A, E, Exclude<R, P>, PE, PR>>>>;
196
+ declare function layerInHost<A, E, R, PE = never, PR = never>(application: Layer.Layer<DurableAgentRuntime | A, E, R>, options?: ThreadPublicationOptions<PE, PR>): ReturnType<typeof sharedLayer<A, E, R, PE, PR>>;
197
+ type HostRuntimeServices = Exclude<CloudflareDurableRuntimeServices, DurableAgentRuntime | ThreadMaintenance>;
198
+ declare const sharedLayer: <A, E, R, PE = never, PR = never>(application: Layer.Layer<DurableAgentRuntime | A, E, R>, options?: ThreadPublicationOptions<PE, PR>) => Layer.Layer<CloudflareDurableRuntimeServices | A, DoStorageInitializationError | MessageDeliveryError | E | PE, DurableObjectContext | ThreadObjectNamespace | Exclude<CloudflareBootstrapServices, ThreadObjectIdentity> | SqlClient | Exclude<R, HostRuntimeServices | PreparedInputAdmission> | Exclude<PR, ThreadStore | SubmissionLedger | SqlClient>>;
199
+ declare namespace ThreadObject_d_exports {
200
+ export { AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, CloudflareBootstrapServices as BootstrapServices, Class, ExplainedRecovery, CloudflareDurableRuntimeInitializationError as InitializationError, Instance, ObligationsScanned, Options, ThreadPublicationOptions as PublicationOptions, RetryExecuted, CloudflareDurableRuntimeOptions as RuntimeOptions, CloudflareDurableRuntimeServices as Services, ThreadObjectPorts, ThreadRpcOperation, VerifiedIntegrity, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeObligationThresholds, decodeRetryCommand, encodeAdminResponse, handleRpc, layer, layerConfig, layerHostConfig, layerInHost, make, portCall, submit };
201
+ }
202
+ /**
203
+ * `ThreadObject.make(application, options)` — the Thread Durable Object
204
+ * (plan §1.4,
205
+ * D-P6-1): a factory returning a class that applications export from their Worker entry.
206
+ * One SQLite-backed Object per Thread is the serialized owner (durability §6); the
207
+ * Object never runs `runResolvedWorker`'s infinite loop — each ingress event or alarm runs
208
+ * ONE bounded `runRecovery` + `processThreadHead` pass, and the persisted alarm
209
+ * (the single multiplexed slot, D-P6-2) finishes accepted work across evictions WITHOUT any
210
+ * incoming request.
211
+ * `Services` exposes the same owner `SqlClient` used by the Thread stores. Compose optional
212
+ * local repositories after `ThreadObject.layer`; never acquire another independently locked
213
+ * SQL client for the same Object. Exposing the client installs no additional storage schemas.
214
+ *
215
+ * Constructor gate (`blockConcurrencyWhile`) is LOCAL-ONLY: schema migration and the
216
+ * exact-version check, configuration decode, and the defensive ensure-alarm half of the
217
+ * alarm invariant. It deliberately does NOT run the recovery pass: parent recovery can
218
+ * require child-Object reads and vice versa, and two Objects blocked in constructor gates
219
+ * awaiting each other's RPC would deadlock (plan §1.4). Instead every pass runs
220
+ * `runRecovery` BEFORE any claim, so reconciliation still strictly precedes new work.
221
+ */
222
+ /** Construction options for one deployed Thread Object class. */
223
+ interface Options<ApplicationServices = never, EventServices = never, EventLayerError = never> extends CloudflareDurableRuntimeOptions {
224
+ /** Accept transient native RPC tracing through effect-cf; disabled by default. */
225
+ readonly rpcTracing?: boolean;
226
+ /**
227
+ * Name of the Worker `env` binding carrying THIS class's `DurableObjectNamespace` — the
228
+ * Object's route back to sibling Thread Objects for the WP2 cross-Object port calls
229
+ * and remote wakes (DEPLOY-010: the binding enters through a Layer, never ambiently).
230
+ */
231
+ readonly namespaceBinding: string;
232
+ /** Acquired and finalized per native event, with access to the complete application runtime. */
233
+ readonly eventLayer?: Layer.Layer<EventServices, EventLayerError, RuntimeServices | ApplicationServices | DurableObjectState$1.DurableObjectState | WorkerEnvironment>;
234
+ }
235
+ type EndpointServices = CloudflareDurableRuntimeServices | CloudflareBootstrapServices | DurableObjectContext;
236
+ type RuntimeServices = EndpointServices | ThreadObjectNamespace;
237
+ /**
238
+ * Admit an already Schema-decoded request to a logical Thread in this physical owner.
239
+ * Custom hosts validate local placement before calling this Effect and provide their same
240
+ * runtime/maintenance instances. The native endpoint uses this path too: queue limits,
241
+ * idempotent receipts and the pre-admission generation/alarm commit have one owner.
242
+ */
243
+ declare const submit: (threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">, request: SubmitRequest) => Effect.Effect<import("effect-agent/receipt").Receipt, AdmissionLimitExceeded | DurableAlarmError | HostProtocolError | import("effect-agent/durable-agent-runtime").DurableSubmitFailure, CloudflareDurableRuntimeConfig | DurableAgentRuntime | DurableObjectContext | SubmissionLedger | ThreadMutationGate | ThreadObjectPlacement | ThreadPublication>;
244
+ declare const AdminExplainRequest_base: Schema.Class<AdminExplainRequest, Schema.Struct<{
245
+ readonly submissionId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
246
+ }>, {}>;
247
+ /** Explain one Submission (`submissionId` present) or every nonterminal lane member. */
248
+ declare class AdminExplainRequest extends AdminExplainRequest_base {}
249
+ declare const AdminVerifyRequest_base: Schema.Class<AdminVerifyRequest, Schema.Struct<{}>, {}>;
250
+ /** Verify carries no parameters — the addressed Object IS the lane. */
251
+ declare class AdminVerifyRequest extends AdminVerifyRequest_base {}
252
+ /** Every typed failure of the four admin entry points, plus the protocol's own errors. */
253
+ declare const AdminFailure: Schema.Union<readonly [typeof AdmissionPolicyError, typeof OperationDenied, typeof RetryRefused, typeof LedgerError, typeof RunJournalError, typeof DigestError, typeof OwnershipLost, typeof SettlementConflict, typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof DurableAlarmError, typeof HostProtocolError]>;
254
+ type AdminFailure = typeof AdminFailure.Type;
255
+ declare const ExplainedRecovery_base: Schema.Class<ExplainedRecovery, Schema.TaggedStruct<"ExplainedRecovery", {
256
+ readonly explanations: Schema.$Array<typeof RecoveryExplanation>;
257
+ }>, {}>;
258
+ declare class ExplainedRecovery extends ExplainedRecovery_base {}
259
+ declare const VerifiedIntegrity_base: Schema.Class<VerifiedIntegrity, Schema.TaggedStruct<"VerifiedIntegrity", {
260
+ readonly report: typeof IntegrityReport;
261
+ }>, {}>;
262
+ declare class VerifiedIntegrity extends VerifiedIntegrity_base {}
263
+ declare const RetryExecuted_base: Schema.Class<RetryExecuted, Schema.TaggedStruct<"RetryExecuted", {
264
+ readonly report: typeof RecoveryReport;
265
+ }>, {}>;
266
+ declare class RetryExecuted extends RetryExecuted_base {}
267
+ declare const ObligationsScanned_base: Schema.Class<ObligationsScanned, Schema.TaggedStruct<"ObligationsScanned", {
268
+ readonly report: typeof ObligationReport;
269
+ }>, {}>;
270
+ declare class ObligationsScanned extends ObligationsScanned_base {}
271
+ declare const AdminFailed_base: Schema.Class<AdminFailed, Schema.TaggedStruct<"AdminFailed", {
272
+ readonly failure: Schema.Union<readonly [typeof AdmissionPolicyError, typeof OperationDenied, typeof RetryRefused, typeof LedgerError, typeof RunJournalError, typeof DigestError, typeof OwnershipLost, typeof SettlementConflict, typeof ThreadStoreError, typeof ThreadNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof DurableAlarmError, typeof HostProtocolError]>;
273
+ }>, {}>;
274
+ /** The admin entry point failed TYPED on the Object; the failure re-decodes verbatim. */
275
+ declare class AdminFailed extends AdminFailed_base {}
276
+ /** The uniform answer of one admin entry point. Callers narrow by the tag their call implies. */
277
+ declare const AdminResponse: Schema.Union<readonly [typeof ExplainedRecovery, typeof VerifiedIntegrity, typeof RetryExecuted, typeof ObligationsScanned, typeof AdminFailed]>;
278
+ type AdminResponse = typeof AdminResponse.Type;
279
+ declare const decodeAdminExplainRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminExplainRequest, Schema.SchemaError, never>;
280
+ declare const decodeAdminVerifyRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminVerifyRequest, Schema.SchemaError, never>;
281
+ declare const decodeRetryCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<RetryCommand, Schema.SchemaError, never>;
282
+ declare const decodeObligationThresholds: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<ObligationThresholds, Schema.SchemaError, never>;
283
+ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<{
284
+ readonly _tag: "ExplainedRecovery";
285
+ readonly explanations: readonly {
286
+ readonly submission: {
287
+ readonly submissionId: string;
288
+ readonly threadId: string;
289
+ readonly state: "admitted" | "input-applied" | "joined" | "joining" | "ready" | "running" | "settled" | "suspended" | "terminalizing" | "unknown";
290
+ readonly queueSequence: number;
291
+ readonly createdAt: string;
292
+ readonly readyAt?: string | undefined;
293
+ readonly ageSeconds: number;
294
+ readonly readyAgeSeconds?: number | undefined;
295
+ readonly parentLinkage?: {
296
+ readonly parentSubmissionId: string;
297
+ readonly parentToolCallId: string;
298
+ } | undefined;
299
+ };
300
+ readonly evidence: {
301
+ readonly threadMaterialized: boolean;
302
+ readonly inputRecorded: boolean;
303
+ readonly abortRecorded: boolean;
304
+ readonly recordedSettlementOutcome?: "aborted" | "completed" | "failed" | undefined;
305
+ readonly openToolCalls: readonly {
306
+ readonly toolCallId: string;
307
+ readonly toolName: string;
308
+ readonly turn: number;
309
+ }[];
310
+ readonly openDelegationCalls: readonly {
311
+ readonly toolCallId: string;
312
+ readonly toolName: string;
313
+ readonly turn: number;
314
+ readonly requested: boolean;
315
+ readonly started: boolean;
316
+ readonly joined: boolean;
317
+ readonly childThreadId?: string | undefined;
318
+ readonly childSubmissionId?: string | undefined;
319
+ readonly admission?: "admitted" | "indeterminate" | "not-admitted" | undefined;
320
+ }[];
321
+ readonly approvalsPending: readonly {
322
+ readonly toolCallId: string;
323
+ readonly turn: number;
324
+ }[];
325
+ readonly unknownCalls: readonly {
326
+ readonly toolCallId: string;
327
+ readonly toolName: string;
328
+ readonly reason: string;
329
+ readonly recordedAt: string;
330
+ readonly resolved: boolean;
331
+ }[];
332
+ readonly approvalDecisions: readonly {
333
+ readonly submissionId: string;
334
+ readonly toolCallId: string;
335
+ readonly decision: "approved" | "denied";
336
+ readonly resolver: string;
337
+ readonly reason: string;
338
+ readonly decidedAt: string;
339
+ readonly canonicalRecordId?: string | undefined;
340
+ }[];
341
+ readonly unknownResolutions: readonly {
342
+ readonly submissionId: string;
343
+ readonly toolCallId: string;
344
+ readonly author: string;
345
+ readonly reason: string;
346
+ readonly resolution: {
347
+ readonly _tag: "CompletedWithResult";
348
+ readonly result: Schema.Json;
349
+ readonly isFailure: boolean;
350
+ } | {
351
+ readonly _tag: "NeverHappened";
352
+ } | {
353
+ readonly _tag: "SafeToRetry";
354
+ } | {
355
+ readonly _tag: "AbortSubmission";
356
+ };
357
+ readonly resolvedAt: string;
358
+ readonly canonicalRecordId?: string | undefined;
359
+ }[];
360
+ readonly childAttachments: readonly {
361
+ readonly toolCallId: string;
362
+ readonly childSubmissionId: string;
363
+ readonly childState: "admitted" | "input-applied" | "joined" | "joining" | "ready" | "running" | "settled" | "suspended" | "terminalizing" | "unknown";
364
+ readonly childOutcome?: "aborted" | "completed" | "failed" | undefined;
365
+ }[];
366
+ readonly joins: readonly {
367
+ readonly submissionId: string;
368
+ readonly state: "admitted" | "input-applied" | "joined" | "joining" | "ready" | "running" | "settled" | "suspended" | "terminalizing" | "unknown";
369
+ readonly hostSubmissionId: string;
370
+ }[];
371
+ readonly hostSubmissionId?: string | undefined;
372
+ readonly suspension?: {
373
+ readonly reason: {
374
+ readonly _tag: "ApprovalPending";
375
+ readonly toolCallIds: readonly [string, ...string[]];
376
+ } | {
377
+ readonly _tag: "WaitingForChild";
378
+ readonly children: readonly [{
379
+ readonly toolCallId: string;
380
+ readonly childSubmissionId: string;
381
+ }, ...{
382
+ readonly toolCallId: string;
383
+ readonly childSubmissionId: string;
384
+ }[]];
385
+ };
386
+ readonly suspendedAt: string;
387
+ } | undefined;
388
+ readonly abortIntent?: {
389
+ readonly submissionId: string;
390
+ readonly author: string;
391
+ readonly reason: string;
392
+ readonly requestedAt: string;
393
+ readonly canonicalRecordId?: string | undefined;
394
+ } | undefined;
395
+ };
396
+ readonly decision: {
397
+ readonly _tag: "CompleteMaterialization";
398
+ readonly submissionId: string;
399
+ } | {
400
+ readonly _tag: "RepairReadiness";
401
+ readonly submissionId: string;
402
+ } | {
403
+ readonly _tag: "ApplyInput";
404
+ readonly submissionId: string;
405
+ } | {
406
+ readonly _tag: "RepairInputMarker";
407
+ readonly submissionId: string;
408
+ } | {
409
+ readonly _tag: "ResumeFromTurnBoundary";
410
+ readonly submissionId: string;
411
+ } | {
412
+ readonly _tag: "AppendReservedSettlement";
413
+ readonly submissionId: string;
414
+ readonly settlementId: string;
415
+ readonly outcome: "aborted" | "completed" | "failed";
416
+ } | {
417
+ readonly _tag: "FinalizeLedgerFromHistory";
418
+ readonly submissionId: string;
419
+ readonly settlementId: string;
420
+ readonly outcome: "aborted" | "completed" | "failed";
421
+ } | {
422
+ readonly _tag: "SettleAborted";
423
+ readonly submissionId: string;
424
+ } | {
425
+ readonly _tag: "MarkUnknown";
426
+ readonly submissionId: string;
427
+ readonly reason: string;
428
+ readonly openToolCallIds: readonly string[];
429
+ } | {
430
+ readonly _tag: "ResumePendingToolBatch";
431
+ readonly submissionId: string;
432
+ readonly turn: number;
433
+ } | {
434
+ readonly _tag: "AwaitApprovalDecision";
435
+ readonly submissionId: string;
436
+ } | {
437
+ readonly _tag: "ResumeSuspended";
438
+ readonly submissionId: string;
439
+ } | {
440
+ readonly _tag: "AwaitUnknownResolution";
441
+ readonly submissionId: string;
442
+ } | {
443
+ readonly _tag: "ApplyUnknownResolutions";
444
+ readonly submissionId: string;
445
+ } | {
446
+ readonly _tag: "RevertJoining";
447
+ readonly submissionId: string;
448
+ } | {
449
+ readonly _tag: "RepairJoinMarker";
450
+ readonly submissionId: string;
451
+ } | {
452
+ readonly _tag: "SettleJoinedWithHost";
453
+ readonly submissionId: string;
454
+ readonly outcome: "aborted" | "completed" | "failed";
455
+ } | {
456
+ readonly _tag: "AwaitHostSettlement";
457
+ readonly submissionId: string;
458
+ readonly hostSubmissionId?: string | undefined;
459
+ } | {
460
+ readonly _tag: "CompleteChildAdmission";
461
+ readonly submissionId: string;
462
+ readonly toolCallId: string;
463
+ } | {
464
+ readonly _tag: "AwaitChildAdmissionResolution";
465
+ readonly submissionId: string;
466
+ readonly toolCallId: string;
467
+ } | {
468
+ readonly _tag: "RepairSubagentStartLink";
469
+ readonly submissionId: string;
470
+ readonly toolCallId: string;
471
+ } | {
472
+ readonly _tag: "EnsureWaitingForChild";
473
+ readonly submissionId: string;
474
+ readonly children: readonly [{
475
+ readonly toolCallId: string;
476
+ readonly childSubmissionId: string;
477
+ }, ...{
478
+ readonly toolCallId: string;
479
+ readonly childSubmissionId: string;
480
+ }[]];
481
+ } | {
482
+ readonly _tag: "AwaitChildSettlement";
483
+ readonly submissionId: string;
484
+ } | {
485
+ readonly _tag: "ResumeWaitingParent";
486
+ readonly submissionId: string;
487
+ readonly children: readonly [{
488
+ readonly toolCallId: string;
489
+ readonly childSubmissionId: string;
490
+ }, ...{
491
+ readonly toolCallId: string;
492
+ readonly childSubmissionId: string;
493
+ }[]];
494
+ } | {
495
+ readonly _tag: "ApplyJoinAccounting";
496
+ readonly submissionId: string;
497
+ readonly toolCallId: string;
498
+ readonly reservationId: string;
499
+ } | {
500
+ readonly _tag: "PropagateChildAbort";
501
+ readonly submissionId: string;
502
+ readonly children: readonly [{
503
+ readonly toolCallId: string;
504
+ readonly childSubmissionId: string;
505
+ }, ...{
506
+ readonly toolCallId: string;
507
+ readonly childSubmissionId: string;
508
+ }[]];
509
+ } | {
510
+ readonly _tag: "ReleaseOrphanChildReservation";
511
+ readonly submissionId: string;
512
+ readonly reservationIds: readonly [string, ...string[]];
513
+ } | {
514
+ readonly _tag: "AwaitParentEstablishment";
515
+ readonly submissionId: string;
516
+ readonly parentSubmissionId: string;
517
+ readonly parentToolCallId: string;
518
+ } | {
519
+ readonly _tag: "NoAction";
520
+ readonly submissionId: string;
521
+ };
522
+ readonly decisionMeaning: string;
523
+ readonly disposition: "deferred" | "none" | "repaired" | "unknown";
524
+ readonly explainedAt: string;
525
+ }[];
526
+ } | {
527
+ readonly _tag: "VerifiedIntegrity";
528
+ readonly report: {
529
+ readonly threadId: string;
530
+ readonly tailSequence: number;
531
+ readonly recordCount: number;
532
+ readonly submissionCount: number;
533
+ readonly checks: readonly {
534
+ readonly name: "all-settled" | "checkpoint-binding" | "digest-chain" | "fifo-input-order" | "fifo-settlement-order" | "ledger-canonical-agreement" | "record-identity" | "schema-round-trip" | "sequence-contiguity" | "terminal-uniqueness";
535
+ readonly status: "failed" | "passed" | "skipped";
536
+ readonly detail?: string | undefined;
537
+ }[];
538
+ readonly ok: boolean;
539
+ };
540
+ } | {
541
+ readonly _tag: "RetryExecuted";
542
+ readonly report: {
543
+ readonly submissionId: string;
544
+ readonly threadId: string;
545
+ readonly decision: {
546
+ readonly _tag: "CompleteMaterialization";
547
+ readonly submissionId: string;
548
+ } | {
549
+ readonly _tag: "RepairReadiness";
550
+ readonly submissionId: string;
551
+ } | {
552
+ readonly _tag: "ApplyInput";
553
+ readonly submissionId: string;
554
+ } | {
555
+ readonly _tag: "RepairInputMarker";
556
+ readonly submissionId: string;
557
+ } | {
558
+ readonly _tag: "ResumeFromTurnBoundary";
559
+ readonly submissionId: string;
560
+ } | {
561
+ readonly _tag: "AppendReservedSettlement";
562
+ readonly submissionId: string;
563
+ readonly settlementId: string;
564
+ readonly outcome: "aborted" | "completed" | "failed";
565
+ } | {
566
+ readonly _tag: "FinalizeLedgerFromHistory";
567
+ readonly submissionId: string;
568
+ readonly settlementId: string;
569
+ readonly outcome: "aborted" | "completed" | "failed";
570
+ } | {
571
+ readonly _tag: "SettleAborted";
572
+ readonly submissionId: string;
573
+ } | {
574
+ readonly _tag: "MarkUnknown";
575
+ readonly submissionId: string;
576
+ readonly reason: string;
577
+ readonly openToolCallIds: readonly string[];
578
+ } | {
579
+ readonly _tag: "ResumePendingToolBatch";
580
+ readonly submissionId: string;
581
+ readonly turn: number;
582
+ } | {
583
+ readonly _tag: "AwaitApprovalDecision";
584
+ readonly submissionId: string;
585
+ } | {
586
+ readonly _tag: "ResumeSuspended";
587
+ readonly submissionId: string;
588
+ } | {
589
+ readonly _tag: "AwaitUnknownResolution";
590
+ readonly submissionId: string;
591
+ } | {
592
+ readonly _tag: "ApplyUnknownResolutions";
593
+ readonly submissionId: string;
594
+ } | {
595
+ readonly _tag: "RevertJoining";
596
+ readonly submissionId: string;
597
+ } | {
598
+ readonly _tag: "RepairJoinMarker";
599
+ readonly submissionId: string;
600
+ } | {
601
+ readonly _tag: "SettleJoinedWithHost";
602
+ readonly submissionId: string;
603
+ readonly outcome: "aborted" | "completed" | "failed";
604
+ } | {
605
+ readonly _tag: "AwaitHostSettlement";
606
+ readonly submissionId: string;
607
+ readonly hostSubmissionId?: string | undefined;
608
+ } | {
609
+ readonly _tag: "CompleteChildAdmission";
610
+ readonly submissionId: string;
611
+ readonly toolCallId: string;
612
+ } | {
613
+ readonly _tag: "AwaitChildAdmissionResolution";
614
+ readonly submissionId: string;
615
+ readonly toolCallId: string;
616
+ } | {
617
+ readonly _tag: "RepairSubagentStartLink";
618
+ readonly submissionId: string;
619
+ readonly toolCallId: string;
620
+ } | {
621
+ readonly _tag: "EnsureWaitingForChild";
622
+ readonly submissionId: string;
623
+ readonly children: readonly [{
624
+ readonly toolCallId: string;
625
+ readonly childSubmissionId: string;
626
+ }, ...{
627
+ readonly toolCallId: string;
628
+ readonly childSubmissionId: string;
629
+ }[]];
630
+ } | {
631
+ readonly _tag: "AwaitChildSettlement";
632
+ readonly submissionId: string;
633
+ } | {
634
+ readonly _tag: "ResumeWaitingParent";
635
+ readonly submissionId: string;
636
+ readonly children: readonly [{
637
+ readonly toolCallId: string;
638
+ readonly childSubmissionId: string;
639
+ }, ...{
640
+ readonly toolCallId: string;
641
+ readonly childSubmissionId: string;
642
+ }[]];
643
+ } | {
644
+ readonly _tag: "ApplyJoinAccounting";
645
+ readonly submissionId: string;
646
+ readonly toolCallId: string;
647
+ readonly reservationId: string;
648
+ } | {
649
+ readonly _tag: "PropagateChildAbort";
650
+ readonly submissionId: string;
651
+ readonly children: readonly [{
652
+ readonly toolCallId: string;
653
+ readonly childSubmissionId: string;
654
+ }, ...{
655
+ readonly toolCallId: string;
656
+ readonly childSubmissionId: string;
657
+ }[]];
658
+ } | {
659
+ readonly _tag: "ReleaseOrphanChildReservation";
660
+ readonly submissionId: string;
661
+ readonly reservationIds: readonly [string, ...string[]];
662
+ } | {
663
+ readonly _tag: "AwaitParentEstablishment";
664
+ readonly submissionId: string;
665
+ readonly parentSubmissionId: string;
666
+ readonly parentToolCallId: string;
667
+ } | {
668
+ readonly _tag: "NoAction";
669
+ readonly submissionId: string;
670
+ };
671
+ readonly disposition: "deferred" | "none" | "repaired" | "unknown";
672
+ };
673
+ } | {
674
+ readonly _tag: "ObligationsScanned";
675
+ readonly report: {
676
+ readonly thresholds: {
677
+ readonly agingSeconds: number;
678
+ readonly overdueSeconds: number;
679
+ };
680
+ readonly entries: readonly {
681
+ readonly submissionId: string;
682
+ readonly threadId: string;
683
+ readonly state: "admitted" | "input-applied" | "joined" | "joining" | "ready" | "running" | "settled" | "suspended" | "terminalizing" | "unknown";
684
+ readonly blockedOn: "approval" | "ready-aged" | "running-aged" | "unknown" | "waitingForChild";
685
+ readonly ageSeconds: number;
686
+ readonly severity: "aging" | "ok" | "overdue";
687
+ }[];
688
+ readonly generatedAt: string;
689
+ };
690
+ } | {
691
+ readonly _tag: "AdminFailed";
692
+ readonly failure: {
693
+ readonly _tag: "LedgerError";
694
+ readonly operation: string;
695
+ readonly message: string;
696
+ readonly cause?: Schema.Json | undefined;
697
+ } | {
698
+ readonly _tag: "AppendConflict";
699
+ readonly threadId: string;
700
+ readonly batchId: string;
701
+ readonly reason: "batch-digest" | "record-identity" | "tail";
702
+ readonly actualTailSequence?: number | undefined;
703
+ readonly actualTailDigest?: string | undefined;
704
+ } | {
705
+ readonly _tag: "FenceRejected";
706
+ readonly threadId: string;
707
+ readonly actualEpoch: number;
708
+ readonly attemptedEpoch: number;
709
+ } | {
710
+ readonly _tag: "ThreadNotMaterialized";
711
+ readonly threadId: string;
712
+ } | {
713
+ readonly _tag: "ThreadStoreError";
714
+ readonly operation: string;
715
+ readonly message: string;
716
+ readonly cause?: Schema.Json | undefined;
717
+ } | {
718
+ readonly _tag: "OperationDenied";
719
+ readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
720
+ readonly reason: string;
721
+ readonly threadId?: string | undefined;
722
+ readonly submissionId?: string | undefined;
723
+ } | {
724
+ readonly _tag: "AdmissionPolicyError";
725
+ readonly reason: "occupied" | "refused" | "unavailable";
726
+ readonly code: string;
727
+ } | {
728
+ readonly _tag: "DigestError";
729
+ readonly message: string;
730
+ readonly cause?: Schema.Json | undefined;
731
+ } | {
732
+ readonly _tag: "DurableRuntimeFailpointError";
733
+ readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "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" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
734
+ } | {
735
+ readonly _tag: "SettlementConflict";
736
+ readonly submissionId: string;
737
+ readonly existingOutcome: "aborted" | "completed" | "failed";
738
+ } | {
739
+ readonly _tag: "OwnershipLost";
740
+ readonly submissionId: string;
741
+ readonly actualEpoch: number;
742
+ } | {
743
+ readonly _tag: "RunJournalError";
744
+ readonly message: string;
745
+ readonly cause?: Schema.Json | undefined;
746
+ } | {
747
+ readonly _tag: "DurableAlarmError";
748
+ readonly operation: string;
749
+ readonly message: string;
750
+ readonly cause?: Schema.Json | undefined;
751
+ } | {
752
+ readonly _tag: "HostProtocolError";
753
+ readonly message: string;
754
+ } | {
755
+ readonly _tag: "RetryRefused";
756
+ readonly submissionId: string;
757
+ readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
758
+ readonly decisionTag: string;
759
+ readonly message: string;
760
+ };
761
+ }, Schema.SchemaError, never>;
762
+ declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
763
+ declare const portCall: (encoded: unknown) => Effect.Effect<unknown, never, ThreadObjectPorts | ThreadMaintenance | DurableAlarmService | ThreadObjectIdentity>;
764
+ /** The per-Thread wire operations supported by native and application-owned endpoints. */
765
+ declare const ThreadRpcOperation: Schema.Literals<readonly ["submitEncoded", "submissionStatusEncoded", "awaitSettlementEncoded", "awaitProgressEncoded", "cancelProgressEncoded", "observePage", "abortEncoded", "resolveApprovalEncoded", "resolveUnknownEncoded", "portCall", "wake"]>;
766
+ type ThreadRpcOperation = typeof ThreadRpcOperation.Type;
767
+ /**
768
+ * Bind an addressed request to its logical Thread while sharing one physical runtime. This
769
+ * validates local placement before invoking the same native handlers. Receipts, Submission
770
+ * commands and port envelopes must match this identity; progress cancellation is Thread-scoped.
771
+ * The producer comes from the actual runtime configuration, never from caller input. These
772
+ * guards supplement the existing current model/Tool and operation authorization policies.
773
+ */
774
+ declare const handleRpc: (threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">, operation: "abortEncoded" | "awaitProgressEncoded" | "awaitSettlementEncoded" | "cancelProgressEncoded" | "observePage" | "portCall" | "resolveApprovalEncoded" | "resolveUnknownEncoded" | "submissionStatusEncoded" | "submitEncoded" | "wake", encoded: unknown) => Effect.Effect<unknown, HostProtocolError, CloudflareDurableRuntimeConfig | import("effect/Crypto").Crypto | import("@effect-agent/storage-cloudflare/do-storage-failpoint").DoStorageFailpoint | DurableObjectContext | DurableRuntimeConfig | import("effect-agent/durable-failpoint").DurableRuntimeFailpoint | import("effect-agent/run-options").RunContextPreparation | import("effect-agent/run-options").RunToolAuthorization | ThreadMaintenanceFailpoint | ThreadObjectPlacement | import("effect-agent/tool-reconciler").ToolReconciler | CloudflareDurableRuntimeServices>;
775
+ /** The public endpoints and effect-cf invocation hook of one Thread Object instance. */
776
+ interface Instance<EventServices = never> extends InstanceType<DurableObject.DurableObjectClass<Record<never, never>, RuntimeServices | EventServices>> {
777
+ submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
778
+ submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
779
+ awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
780
+ awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
781
+ cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
782
+ observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;
783
+ abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
784
+ resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
785
+ resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
786
+ explainEncoded(encoded: unknown): Promise<unknown>;
787
+ verifyEncoded(encoded: unknown): Promise<unknown>;
788
+ retryEncoded(encoded: unknown): Promise<unknown>;
789
+ obligationsEncoded(encoded: unknown): Promise<unknown>;
790
+ portCall(encoded: unknown): Promise<unknown>;
791
+ wake(): Promise<void>;
792
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> | void;
793
+ }
794
+ /** The constructor shape workerd instantiates for each Thread Object. */
795
+ interface Class<EventServices = never> {
796
+ new (ctx: DurableObjectState, env: Cloudflare.Env): Instance<EventServices>;
797
+ }
798
+ /**
799
+ * Export a composed application Layer as a native Durable Object class.
800
+ * Bootstrap services are provided to the whole graph before it acquires, so application Layers
801
+ * can yield effect-cf's WorkerEnvironment and DurableObjectState, derived identity, and Crypto.
802
+ * Effect Config reads scalar Worker vars and secrets through effect-cf's environment provider;
803
+ * WorkerEnvironment exposes resource bindings without a separate config Layer.
804
+ * Application dependencies remain visible until Layer.provide satisfies them. effect-cf owns the
805
+ * cached ManagedRuntime, native RPC methods, event scopes, and telemetry flushing.
806
+ * Initialization is local and bounded inside the constructor gate. Cloudflare eviction does not
807
+ * guarantee finalizers; put resources requiring timely release in scoped operations or eventLayer.
808
+ */
809
+ declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError>) => Class<ApplicationServices | EventServices>;
810
+ //#endregion
811
+ export { ThreadPublicationOptions as A, portCall as C, CloudflareDurableRuntimeOptions as D, CloudflareDurableRuntimeInitializationError as E, layerConfig as M, layerHostConfig as N, CloudflareDurableRuntimeServices as O, layerInHost as P, make as S, CloudflareBootstrapServices as T, decodeAdminVerifyRequest as _, AdminVerifyRequest as a, encodeAdminResponse as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminResponse as g, decodeAdminExplainRequest as h, AdminResponse as i, layer as j, ThreadObjectPorts as k, ObligationsScanned as l, VerifiedIntegrity as m, AdminFailed as n, Class as o, ThreadRpcOperation as p, AdminFailure as r, ExplainedRecovery as s, AdminExplainRequest as t, Options as u, decodeObligationThresholds as v, submit as w, handleRpc as x, decodeRetryCommand as y };
812
+ //# sourceMappingURL=ThreadObject-CIbmXZCY.d.mts.map