@yielded/agent-platform-cloudflare 0.1.0-beta.181 → 0.1.0-beta.183
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/CloudflareBindings.d.mts +6 -2
- package/dist/CloudflareBindings.mjs.map +1 -1
- package/dist/CloudflareScheduling.mjs +2 -2
- package/dist/CloudflareSubscriptions.mjs +2 -2
- package/dist/{CloudflareThreadClient-CEUjVwis.mjs → CloudflareThreadClient-CnvMXPmV.mjs} +17 -6
- package/dist/CloudflareThreadClient-CnvMXPmV.mjs.map +1 -0
- package/dist/{CloudflareThreadClient-Atp-Clb4.d.mts → CloudflareThreadClient-DNsFhgVu.d.mts} +46 -40
- package/dist/CloudflareThreadClient.d.mts +1 -1
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{ThreadObject-B1Rv8jPn.d.mts → ThreadObject-BVoyFKHN.d.mts} +3 -3
- package/dist/{ThreadObject-vmc0jRTS.mjs → ThreadObject-Cr1CFWXb.mjs} +98 -60
- package/dist/ThreadObject-Cr1CFWXb.mjs.map +1 -0
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{prepared-admission-C3uBqIz0.mjs → prepared-admission-w2Kq32_k.mjs} +2 -2
- package/dist/{prepared-admission-C3uBqIz0.mjs.map → prepared-admission-w2Kq32_k.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/CloudflareBindings.ts +6 -2
- package/src/CloudflareThreadClient.ts +18 -4
- package/src/internal/live-text-protocol.ts +7 -0
- package/src/internal/live-text.ts +129 -91
- package/dist/CloudflareThreadClient-CEUjVwis.mjs.map +0 -1
- package/dist/ThreadObject-vmc0jRTS.mjs.map +0 -1
|
@@ -23,7 +23,7 @@ export declare class CloudflareBindingError extends CloudflareBindingError_base
|
|
|
23
23
|
* `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry
|
|
24
24
|
* points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC
|
|
25
25
|
* boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return
|
|
26
|
-
* a bounded
|
|
26
|
+
* a bounded byte stream with a disposable RPC lifetime. The optional trailing trace context is
|
|
27
27
|
* transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding
|
|
28
28
|
* the host or port envelope. It never enters durable state.
|
|
29
29
|
*/
|
|
@@ -39,7 +39,11 @@ export interface ThreadObjectRpc extends Rpc.DurableObjectBranded {
|
|
|
39
39
|
awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
|
|
40
40
|
/** Best-effort cancellation for one in-flight progress wait. */
|
|
41
41
|
cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Authorized provisional text; stream with RPC lifetime, or encoded HostFailed.
|
|
44
|
+
* Direct callers must dispose the RPC result; canceling an idle stream alone may not
|
|
45
|
+
* reach its source. CloudflareThreadClient owns both lifetimes for callers.
|
|
46
|
+
*/
|
|
43
47
|
watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
|
|
44
48
|
/** One bounded page of canonical records; answers an `ObservePageResponse`. */
|
|
45
49
|
observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareBindings.mjs","names":[],"sources":["../src/CloudflareBindings.ts"],"sourcesContent":["import { type ThreadId } from \"@yielded/agent/identifiers\";\nimport { type ProducerId } from \"@yielded/agent/records\";\nimport { Context, Effect, Layer, Predicate, Schema } from \"effect\";\nimport { RpcTargets } from \"effect-cf\";\n\n/**\n * Cloudflare platform bindings as Effect services (DEPLOY-010: \"Cloudflare platform bindings\n * are supplied as Effect services/Layers\"). Application code never reads `env` or touches a\n * `DurableObjectState` directly — the Thread Object class constructs these Layers once\n * per incarnation and everything downstream consumes the services.\n */\n\n/** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */\nexport class CloudflareBindingError extends Schema.TaggedError<CloudflareBindingError>()(\n \"CloudflareBindingError\",\n {\n binding: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * The RPC surface one Thread Durable Object exposes to Workers and to sibling\n * Thread Objects. `ThreadObject.make` implements it; the Worker-side client\n * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every\n * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry\n * points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC\n * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return\n * a bounded, disposable byte stream. The optional trailing trace context is\n * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding\n * the host or port envelope. It never enters durable state.\n */\nexport interface ThreadObjectRpc extends Rpc.DurableObjectBranded {\n /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */\n submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */\n submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Finalized canonical settlement record; requires settlement and observation authority. */\n awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */\n awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Best-effort cancellation for one in-flight progress wait. */\n cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized prospective provisional text; byte stream or encoded HostFailed. */\n watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** One bounded page of canonical records; answers an `ObservePageResponse`. */\n observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable abort intent; answers an `AbortResponse`. */\n abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */\n resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */\n resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */\n portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Droppable liveness hint from another Object: arms an immediate alarm. */\n wake(): Promise<void>;\n}\n\n/** A logical Thread endpoint may be bound to an application Object without forging its brand. */\nexport type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>;\n\n/**\n * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;\n * a shared application owner can bind that logical identity into its RPC adapter instead.\n * Lookup performs no I/O and grants no authority. Calls reuse a native target within\n * one invocation; incoming requests and durable retries acquire their own targets.\n */\nexport class ThreadObjectNamespace extends Context.Service<\n ThreadObjectNamespace,\n {\n readonly get: (threadId: ThreadId) => ThreadObjectClient;\n /** Stable binding name for opted-in native RPC tracing; absent by default. */\n readonly rpcTracing?: string;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectNamespace\") {\n static layer(\n namespace: DurableObjectNamespace<ThreadObjectRpc>,\n options: { readonly rpcTracing?: string } = {},\n ): Layer.Layer<ThreadObjectNamespace> {\n return Layer.succeed(ThreadObjectNamespace)({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === undefined ? {} : { rpcTracing: options.rpcTracing }),\n });\n }\n}\n\n/** Invoke a placed Thread using the current invocation's native RPC channel. */\nexport const callThreadObject = Effect.fnUntraced(function* <A, E>(\n threadId: ThreadId,\n invoke: (target: ThreadObjectClient) => Promise<A>,\n onError: (cause: unknown) => E,\n): Effect.fn.Return<A, E, ThreadObjectNamespace> {\n const namespace = yield* ThreadObjectNamespace;\n\n const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(\n Effect.mapError(onError),\n );\n\n return yield* Effect.tryPromise({ try: () => invoke(target), catch: onError }).pipe(\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n );\n});\n\n/**\n * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,\n * and a namespace binding is a host object no Schema can decode, so this is the documented\n * narrowest-boundary check (structural probe for the namespace surface the transport uses);\n * a missing or misshaped binding fails typed before any Layer is built.\n */\nexport const threadNamespaceFromEnv = Effect.fnUntraced(function* (\n env: unknown,\n binding: string,\n): Effect.fn.Return<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError> {\n if (!Predicate.isObjectKeyword(env)) {\n return yield* CloudflareBindingError.make({\n binding,\n message: \"The Worker environment is not an object; no bindings are available.\",\n });\n }\n\n const candidate = yield* Effect.try({\n try: () => {\n const value: unknown = Reflect.get(env, binding);\n\n if (!Predicate.isObjectKeyword(value)) return undefined;\n const idFromName: unknown = Reflect.get(value, \"idFromName\");\n const get: unknown = Reflect.get(value, \"get\");\n\n return typeof idFromName === \"function\" && typeof get === \"function\" ? value : undefined;\n },\n catch: () =>\n CloudflareBindingError.make({\n binding,\n message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`,\n }),\n });\n\n if (candidate !== undefined) {\n // The structural probe above is the entire runtime contract this package relies on;\n // the assertion records that `idFromName`/`get` name a DurableObjectNamespace.\n return candidate as unknown as DurableObjectNamespace<ThreadObjectRpc>;\n }\n\n return yield* CloudflareBindingError.make({\n binding,\n message:\n `env.${binding} is not a DurableObjectNamespace binding; declare the Thread ` +\n \"Object class under this binding in the Worker configuration.\",\n });\n});\n\n/**\n * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the\n * receiver also opts into the effect-cf native RPC trace-context contract.\n */\nexport const threadNamespaceLayer = (\n env: unknown,\n binding: string,\n options: { readonly rpcTracing?: boolean } = {},\n): Layer.Layer<ThreadObjectNamespace, CloudflareBindingError> =>\n Layer.effect(ThreadObjectNamespace)(\n Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === true ? { rpcTracing: binding } : {}),\n })),\n );\n\n/**\n * The live Durable Object execution context of THIS incarnation. Only Layer construction and\n * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,\n * everything in memory is a cache — deployment spec §11).\n */\nexport class DurableObjectContext extends Context.Service<\n DurableObjectContext,\n {\n readonly ctx: DurableObjectState;\n readonly env: unknown;\n }\n>()(\"@effect-agent/platform-cloudflare/DurableObjectContext\") {\n static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext> {\n return Layer.succeed(DurableObjectContext)({ ctx, env });\n }\n}\n\n/**\n * The Thread identity this Object serializes and the producer identity its Attempts\n * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation\n * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.\n */\nexport class ThreadObjectIdentity extends Context.Service<\n ThreadObjectIdentity,\n {\n readonly threadId: ThreadId;\n readonly producerId: ProducerId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectIdentity\") {}\n\n/** Logical Threads whose canonical stores and admission ledger live in this physical Object. */\nexport class ThreadObjectPlacement extends Context.Service<\n ThreadObjectPlacement,\n {\n readonly ownsThread: (threadId: ThreadId) => boolean;\n /** Present only when this physical Object owns exactly this one Thread. */\n readonly threadId?: ThreadId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectPlacement\") {}\n\n/** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */\nexport class DurableAlarmError extends Schema.TaggedError<DurableAlarmError>()(\n \"DurableAlarmError\",\n {\n operation: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,yBAAb,cAA4C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KAAA;EACjF;EACA,aACE,uBAAuB,KAAK;GAC1B;GACA,SAAS,OAAO,QAAQ;EAC1B,CAAC;CACL,CAAC;CAED,IAAI,cAAc,KAAA,GAGhB,OAAO;CAGT,OAAO,OAAO,uBAAuB,KAAK;EACxC;EACA,SACE,OAAO,QAAQ;CAEnB,CAAC;AACH,CAAC;;;;;AAMD,MAAa,wBACX,KACA,SACA,UAA6C,CAAC,MAE9C,MAAM,OAAO,qBAAqB,CAAC,CACjC,OAAO,IAAI,uBAAuB,KAAK,OAAO,IAAI,eAAe;CAC/D,MAAM,aAAa,UAAU,IAAI,UAAU,WAAW,QAAQ,CAAC;CAC/D,GAAI,QAAQ,eAAe,OAAO,EAAE,YAAY,QAAQ,IAAI,CAAC;AAC/D,EAAE,CACJ;;;;;;AAOF,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC;CAC5D,OAAO,MAAM,KAAyB,KAAiD;EACrF,OAAO,MAAM,QAAQ,oBAAoB,CAAC,CAAC;GAAE;GAAK;EAAI,CAAC;CACzD;AACF;;;;;;AAOA,IAAa,uBAAb,cAA0C,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC,CAAC;;AAG/D,IAAa,wBAAb,cAA2C,QAAQ,QAOjD,CAAC,CAAC,yDAAyD,CAAC,CAAC,CAAC;;AAGhE,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAC5E,qBACA;CACE,WAAW,OAAO;CAClB,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"CloudflareBindings.mjs","names":[],"sources":["../src/CloudflareBindings.ts"],"sourcesContent":["import { type ThreadId } from \"@yielded/agent/identifiers\";\nimport { type ProducerId } from \"@yielded/agent/records\";\nimport { Context, Effect, Layer, Predicate, Schema } from \"effect\";\nimport { RpcTargets } from \"effect-cf\";\n\n/**\n * Cloudflare platform bindings as Effect services (DEPLOY-010: \"Cloudflare platform bindings\n * are supplied as Effect services/Layers\"). Application code never reads `env` or touches a\n * `DurableObjectState` directly — the Thread Object class constructs these Layers once\n * per incarnation and everything downstream consumes the services.\n */\n\n/** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */\nexport class CloudflareBindingError extends Schema.TaggedError<CloudflareBindingError>()(\n \"CloudflareBindingError\",\n {\n binding: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * The RPC surface one Thread Durable Object exposes to Workers and to sibling\n * Thread Objects. `ThreadObject.make` implements it; the Worker-side client\n * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every\n * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry\n * points, `@yielded/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC\n * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return\n * a bounded byte stream with a disposable RPC lifetime. The optional trailing trace context is\n * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding\n * the host or port envelope. It never enters durable state.\n */\nexport interface ThreadObjectRpc extends Rpc.DurableObjectBranded {\n /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */\n submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */\n submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Finalized canonical settlement record; requires settlement and observation authority. */\n awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */\n awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Best-effort cancellation for one in-flight progress wait. */\n cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /**\n * Authorized provisional text; stream with RPC lifetime, or encoded HostFailed.\n * Direct callers must dispose the RPC result; canceling an idle stream alone may not\n * reach its source. CloudflareThreadClient owns both lifetimes for callers.\n */\n watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** One bounded page of canonical records; answers an `ObservePageResponse`. */\n observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable abort intent; answers an `AbortResponse`. */\n abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */\n resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */\n resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */\n portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>;\n /** Droppable liveness hint from another Object: arms an immediate alarm. */\n wake(): Promise<void>;\n}\n\n/** A logical Thread endpoint may be bound to an application Object without forging its brand. */\nexport type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>;\n\n/**\n * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;\n * a shared application owner can bind that logical identity into its RPC adapter instead.\n * Lookup performs no I/O and grants no authority. Calls reuse a native target within\n * one invocation; incoming requests and durable retries acquire their own targets.\n */\nexport class ThreadObjectNamespace extends Context.Service<\n ThreadObjectNamespace,\n {\n readonly get: (threadId: ThreadId) => ThreadObjectClient;\n /** Stable binding name for opted-in native RPC tracing; absent by default. */\n readonly rpcTracing?: string;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectNamespace\") {\n static layer(\n namespace: DurableObjectNamespace<ThreadObjectRpc>,\n options: { readonly rpcTracing?: string } = {},\n ): Layer.Layer<ThreadObjectNamespace> {\n return Layer.succeed(ThreadObjectNamespace)({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === undefined ? {} : { rpcTracing: options.rpcTracing }),\n });\n }\n}\n\n/** Invoke a placed Thread using the current invocation's native RPC channel. */\nexport const callThreadObject = Effect.fnUntraced(function* <A, E>(\n threadId: ThreadId,\n invoke: (target: ThreadObjectClient) => Promise<A>,\n onError: (cause: unknown) => E,\n): Effect.fn.Return<A, E, ThreadObjectNamespace> {\n const namespace = yield* ThreadObjectNamespace;\n\n const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(\n Effect.mapError(onError),\n );\n\n return yield* Effect.tryPromise({ try: () => invoke(target), catch: onError }).pipe(\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n );\n});\n\n/**\n * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,\n * and a namespace binding is a host object no Schema can decode, so this is the documented\n * narrowest-boundary check (structural probe for the namespace surface the transport uses);\n * a missing or misshaped binding fails typed before any Layer is built.\n */\nexport const threadNamespaceFromEnv = Effect.fnUntraced(function* (\n env: unknown,\n binding: string,\n): Effect.fn.Return<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError> {\n if (!Predicate.isObjectKeyword(env)) {\n return yield* CloudflareBindingError.make({\n binding,\n message: \"The Worker environment is not an object; no bindings are available.\",\n });\n }\n\n const candidate = yield* Effect.try({\n try: () => {\n const value: unknown = Reflect.get(env, binding);\n\n if (!Predicate.isObjectKeyword(value)) return undefined;\n const idFromName: unknown = Reflect.get(value, \"idFromName\");\n const get: unknown = Reflect.get(value, \"get\");\n\n return typeof idFromName === \"function\" && typeof get === \"function\" ? value : undefined;\n },\n catch: () =>\n CloudflareBindingError.make({\n binding,\n message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`,\n }),\n });\n\n if (candidate !== undefined) {\n // The structural probe above is the entire runtime contract this package relies on;\n // the assertion records that `idFromName`/`get` name a DurableObjectNamespace.\n return candidate as unknown as DurableObjectNamespace<ThreadObjectRpc>;\n }\n\n return yield* CloudflareBindingError.make({\n binding,\n message:\n `env.${binding} is not a DurableObjectNamespace binding; declare the Thread ` +\n \"Object class under this binding in the Worker configuration.\",\n });\n});\n\n/**\n * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the\n * receiver also opts into the effect-cf native RPC trace-context contract.\n */\nexport const threadNamespaceLayer = (\n env: unknown,\n binding: string,\n options: { readonly rpcTracing?: boolean } = {},\n): Layer.Layer<ThreadObjectNamespace, CloudflareBindingError> =>\n Layer.effect(ThreadObjectNamespace)(\n Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === true ? { rpcTracing: binding } : {}),\n })),\n );\n\n/**\n * The live Durable Object execution context of THIS incarnation. Only Layer construction and\n * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,\n * everything in memory is a cache — deployment spec §11).\n */\nexport class DurableObjectContext extends Context.Service<\n DurableObjectContext,\n {\n readonly ctx: DurableObjectState;\n readonly env: unknown;\n }\n>()(\"@effect-agent/platform-cloudflare/DurableObjectContext\") {\n static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext> {\n return Layer.succeed(DurableObjectContext)({ ctx, env });\n }\n}\n\n/**\n * The Thread identity this Object serializes and the producer identity its Attempts\n * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation\n * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.\n */\nexport class ThreadObjectIdentity extends Context.Service<\n ThreadObjectIdentity,\n {\n readonly threadId: ThreadId;\n readonly producerId: ProducerId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectIdentity\") {}\n\n/** Logical Threads whose canonical stores and admission ledger live in this physical Object. */\nexport class ThreadObjectPlacement extends Context.Service<\n ThreadObjectPlacement,\n {\n readonly ownsThread: (threadId: ThreadId) => boolean;\n /** Present only when this physical Object owns exactly this one Thread. */\n readonly threadId?: ThreadId;\n }\n>()(\"@effect-agent/platform-cloudflare/ThreadObjectPlacement\") {}\n\n/** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */\nexport class DurableAlarmError extends Schema.TaggedError<DurableAlarmError>()(\n \"DurableAlarmError\",\n {\n operation: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,SAAS,OAAO;CAChB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;;;AAsDH,IAAa,wBAAb,MAAa,8BAA8B,QAAQ,QAOjD,CAAC,CAAC,yDAAyD,CAAC,CAAC;CAC7D,OAAO,MACL,WACA,UAA4C,CAAC,GACT;EACpC,OAAO,MAAM,QAAQ,qBAAqB,CAAC,CAAC;GAC1C,MAAM,aAAa,UAAU,IAAI,UAAU,WAAW,QAAQ,CAAC;GAC/D,GAAI,QAAQ,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,QAAQ,WAAW;EAC/E,CAAC;CACH;AACF;;AAGA,MAAa,mBAAmB,OAAO,WAAW,WAChD,UACA,QACA,SAC+C;CAC/C,MAAM,YAAY,OAAO;CAEzB,MAAM,SAAS,OAAO,WAAW,IAAI,WAAW,gBAAgB,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,KACvF,OAAO,SAAS,OAAO,CACzB;CAEA,OAAO,OAAO,OAAO,WAAW;EAAE,WAAW,OAAO,MAAM;EAAG,OAAO;CAAQ,CAAC,CAAC,CAAC,KAC7E,OAAO,eAAe,WAAW,WAAW,MAAM,CAAC,CACrD;AACF,CAAC;;;;;;;AAQD,MAAa,yBAAyB,OAAO,WAAW,WACtD,KACA,SACmF;CACnF,IAAI,CAAC,UAAU,gBAAgB,GAAG,GAChC,OAAO,OAAO,uBAAuB,KAAK;EACxC;EACA,SAAS;CACX,CAAC;CAGH,MAAM,YAAY,OAAO,OAAO,IAAI;EAClC,WAAW;GACT,MA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AC3C,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { n as cloudflareScheduledInputAdmissionLayer, t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-
|
|
2
|
+
import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-CnvMXPmV.mjs";
|
|
3
|
+
import { n as cloudflareScheduledInputAdmissionLayer, t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-w2Kq32_k.mjs";
|
|
4
4
|
import "@yielded/agent/durable-agent-runtime";
|
|
5
5
|
import { AgentId } from "@yielded/agent/identifiers";
|
|
6
6
|
import { AdmissionFence } from "@yielded/agent/submission-ledger";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-
|
|
2
|
+
import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-CnvMXPmV.mjs";
|
|
3
|
+
import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-w2Kq32_k.mjs";
|
|
4
4
|
import { Principal } from "@yielded/agent/submission-ledger";
|
|
5
5
|
import { Cause, Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
|
|
6
6
|
import { DurableObject, DurableObjectAlarm, DurableObjectState } from "effect-cf";
|
|
@@ -6,7 +6,7 @@ import "@yielded/agent/durable-agent-runtime";
|
|
|
6
6
|
import { AgentId, ThreadId } from "@yielded/agent/identifiers";
|
|
7
7
|
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, IdempotencyKey, JoinedToHost, LedgerError, OwnershipLost, Principal, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@yielded/agent/submission-ledger";
|
|
8
8
|
import { Context, Crypto, Duration, Effect, Layer, PlatformError, Predicate, Schema, Stream } from "effect";
|
|
9
|
-
import { RpcTargets, RpcTracing } from "effect-cf";
|
|
9
|
+
import { Rpc, RpcTargets, RpcTracing } from "effect-cf";
|
|
10
10
|
import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests, PersistedJson, SubmissionSettledRecord, WorkerAdmission } from "@yielded/agent/records";
|
|
11
11
|
import { AgentInputError } from "@yielded/agent/agent-error";
|
|
12
12
|
import { DigestError } from "@yielded/agent/digest";
|
|
@@ -49,6 +49,11 @@ const MAX_DELTA_LENGTH = 4096;
|
|
|
49
49
|
const MAX_DRAFT_LENGTH = 2097152;
|
|
50
50
|
const streamId = Schema.NonEmptyString.check(Schema.isMaxLength(256));
|
|
51
51
|
const Request = Schema.Struct({ schemaVersion: Schema.Literal(1) });
|
|
52
|
+
/** The RPC lifetime survives an idle byte stream and is disposed on caller disconnect. */
|
|
53
|
+
const Observation = Schema.Struct({
|
|
54
|
+
stream: Schema.instanceOf(ReadableStream),
|
|
55
|
+
lifetime: Schema.declare(Rpc.isDisposable)
|
|
56
|
+
});
|
|
52
57
|
/**
|
|
53
58
|
* Reset replaces all drafts with a snapshot, streamed as native Text parts before live deltas.
|
|
54
59
|
* Each snapshot starts a fresh streamId. Its sequences are unrelated to canonical sequences.
|
|
@@ -490,7 +495,12 @@ var CloudflareThreadClient = class CloudflareThreadClient extends Context.Servic
|
|
|
490
495
|
const cancel = () => {
|
|
491
496
|
const value = received;
|
|
492
497
|
received = void 0;
|
|
493
|
-
|
|
498
|
+
const observation = Schema.is(Observation)(value) ? value : void 0;
|
|
499
|
+
try {
|
|
500
|
+
observation?.lifetime[Symbol.dispose]();
|
|
501
|
+
} catch {}
|
|
502
|
+
const stream = observation?.stream ?? value;
|
|
503
|
+
return stream instanceof ReadableStream && !stream.locked ? stream.cancel().catch(() => void 0) : Promise.resolve();
|
|
494
504
|
};
|
|
495
505
|
yield* Effect.addFinalizer(() => Effect.try({
|
|
496
506
|
try: () => {
|
|
@@ -515,8 +525,9 @@ var CloudflareThreadClient = class CloudflareThreadClient extends Context.Servic
|
|
|
515
525
|
},
|
|
516
526
|
catch: openingFailure
|
|
517
527
|
}).pipe(Effect.interruptible, Effect.tapCause(() => RpcTargets.invalidate(target)));
|
|
518
|
-
|
|
519
|
-
|
|
528
|
+
const stream = Schema.is(Observation)(raw) ? raw.stream : raw;
|
|
529
|
+
if (stream instanceof ReadableStream) return Stream.fromReadableStream({
|
|
530
|
+
evaluate: () => stream,
|
|
520
531
|
releaseLockOnEnd: true,
|
|
521
532
|
onError: (cause) => ThreadClientError.make({
|
|
522
533
|
threadId,
|
|
@@ -606,6 +617,6 @@ var CloudflareThreadClient = class CloudflareThreadClient extends Context.Servic
|
|
|
606
617
|
}));
|
|
607
618
|
};
|
|
608
619
|
//#endregion
|
|
609
|
-
export { decodeLiveText as A, encodeHostResponse as B, boundHostDiagnostic as C, decodeAwaitSettlementRequest as D, decodeAwaitProgressRequest as E, encodeAbortCommand as F, Frame as G, encodeReceipt as H, encodeApprovalDecisionCommand as I, MAX_FRAME_BYTES as J, MAX_DELTA_LENGTH as K, encodeAwaitProgressRequest as L, decodeReceipt as M, decodeSubmitRequest as N, decodeCancelProgressRequest as O, decodeUnknownResolutionCommand as P, encodeAwaitSettlementRequest as R, UnknownResolutionRecorded as S, decodeApprovalDecisionCommand as T, encodeSubmitRequest as U, encodeObservePageRequest as V, encodeUnknownResolutionCommand as W,
|
|
620
|
+
export { decodeLiveText as A, encodeHostResponse as B, boundHostDiagnostic as C, decodeAwaitSettlementRequest as D, decodeAwaitProgressRequest as E, encodeAbortCommand as F, Frame as G, encodeReceipt as H, encodeApprovalDecisionCommand as I, MAX_FRAME_BYTES as J, MAX_DELTA_LENGTH as K, encodeAwaitProgressRequest as L, decodeReceipt as M, decodeSubmitRequest as N, decodeCancelProgressRequest as O, decodeUnknownResolutionCommand as P, cloudflareCryptoLayer as Q, encodeAwaitSettlementRequest as R, UnknownResolutionRecorded as S, decodeApprovalDecisionCommand as T, encodeSubmitRequest as U, encodeObservePageRequest as V, encodeUnknownResolutionCommand as W, Request as X, Observation as Y, isBoundedEvent as Z, SettlementRecordReached as _, CancelProgressRequest as a, SubmitSucceeded as b, HostFailed as c, HostResponse as d, ObservePageRequest as f, SettlementReached as g, ProgressObserved as h, AwaitSettlementRequest as i, decodeObservePageRequest as j, decodeHostResponse as k, HostFailure as l, ProgressCancelled as m, ApprovalRecorded as n, CloudflareThreadClient as o, ObservedPage as p, MAX_DRAFT_LENGTH as q, AwaitProgressRequest as r, CloudflareThreadClient_exports as s, AbortRecorded as t, HostProtocolError as u, SubmissionStatusResponse as v, decodeAbortCommand as w, ThreadClientError as x, SubmitRequest as y, encodeCancelProgressRequest as z };
|
|
610
621
|
|
|
611
|
-
//# sourceMappingURL=CloudflareThreadClient-
|
|
622
|
+
//# sourceMappingURL=CloudflareThreadClient-CnvMXPmV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareThreadClient-CnvMXPmV.mjs","names":["LiveTextFrame","LiveTextObservation","WatchTextRequest"],"sources":["../src/internal/crypto.ts","../src/internal/live-text-protocol.ts","../src/CloudflareThreadClient.ts"],"sourcesContent":["// Implement the Effect Crypto service with the Workers native hashing primitive.\n// @effect-diagnostics-next-line nodeBuiltinImport:off\nimport { createHash } from \"node:crypto\";\n\nimport { BrowserCrypto } from \"@effect/platform-browser\";\nimport { Crypto, Effect, Layer, PlatformError } from \"effect\";\n\n/** Workers use native SHA-256 while retaining BrowserCrypto's services and overrides. */\nexport const cloudflareCryptoLayer: Layer.Layer<Crypto.Crypto> = Layer.effect(\n Crypto.Crypto,\n Effect.gen(function* () {\n const base = yield* Crypto.Crypto;\n const webCrypto = yield* BrowserCrypto.WebCrypto;\n const hostGlobals: object = globalThis;\n\n return Crypto.Crypto.of({\n ...base,\n digest: (algorithm, data) => {\n if (\n algorithm !== \"SHA-256\" ||\n !(\"crypto\" in hostGlobals) ||\n webCrypto !== hostGlobals.crypto ||\n typeof webCrypto.subtle?.digest !== \"function\"\n )\n return base.digest(algorithm, data);\n\n return Effect.try({\n try: () => Uint8Array.from(createHash(\"sha256\").update(data).digest()),\n catch: (cause) =>\n PlatformError.systemError({\n module: \"Crypto\",\n method: \"digest\",\n _tag: \"Unknown\",\n description: \"Could not compute digest\",\n cause,\n }),\n });\n },\n });\n }),\n).pipe(Layer.provide(BrowserCrypto.layer));\n","import { ThreadId } from \"@yielded/agent/identifiers\";\nimport { Event } from \"@yielded/agent/provisional-text\";\nimport { Schema } from \"effect\";\nimport { Rpc } from \"effect-cf\";\n\nexport const MAX_FRAME_BYTES = 32 * 1_024;\nexport const MAX_ID_LENGTH = 256;\nexport const MAX_DELTA_LENGTH = 4_096;\nexport const BUFFER_SIZE = 32;\nexport const MAX_OBSERVERS = 8;\nexport const MAX_DRAFT_PARTS = 32;\nexport const MAX_DRAFT_LENGTH = 2 * 1_024 * 1_024;\n\nconst streamId = Schema.NonEmptyString.check(Schema.isMaxLength(MAX_ID_LENGTH));\n\nexport const Request = Schema.Struct({ schemaVersion: Schema.Literal(1) });\n\n/** The RPC lifetime survives an idle byte stream and is disposed on caller disconnect. */\nexport const Observation = Schema.Struct({\n stream: Schema.instanceOf(ReadableStream<Uint8Array>),\n lifetime: Schema.declare(Rpc.isDisposable),\n});\n\n/**\n * Reset replaces all drafts with a snapshot, streamed as native Text parts before live deltas.\n * Each snapshot starts a fresh streamId. Its sequences are unrelated to canonical sequences.\n */\nexport const Frame = Schema.Union([\n Schema.TaggedStruct(\"Reset\", {\n schemaVersion: Schema.Literal(1),\n streamId,\n threadId: ThreadId,\n sequence: Schema.Literal(0),\n }),\n Schema.TaggedStruct(\"Event\", {\n schemaVersion: Schema.Literal(1),\n streamId,\n sequence: Schema.Int.check(Schema.isGreaterThan(0)),\n event: Event,\n }),\n]);\n\nexport type Frame = typeof Frame.Type;\n\n/** Bounds are checked before queueing; provider metadata is deliberately absent. */\nexport const isBoundedEvent = (event: Event): boolean => {\n const ids: string[] = [event.threadId, event.submissionId, event.attemptId];\n\n if (event._tag !== \"AttemptEnded\") ids.push(event.runId, event.turnId);\n if (ids.some((id) => id.length > MAX_ID_LENGTH)) return false;\n\n return (\n event._tag !== \"Text\" ||\n (event.part.id.length <= MAX_ID_LENGTH &&\n Object.keys(event.part.metadata).length === 0 &&\n (event.part.type !== \"text-delta\" || event.part.delta.length <= MAX_DELTA_LENGTH))\n );\n};\n","import { AgentInputError } from \"@yielded/agent/agent-error\";\nimport { DigestError } from \"@yielded/agent/digest\";\nimport {\n type DurableSubmitAgent,\n type DurableSubmitOptions,\n} from \"@yielded/agent/durable-agent-runtime\";\nimport { DurableRuntimeFailpointError } from \"@yielded/agent/durable-failpoint\";\nimport { AgentId, type ThreadId } from \"@yielded/agent/identifiers\";\nimport { InputMessage } from \"@yielded/agent/messaging\";\nimport { OperationDenied } from \"@yielded/agent/operation-authorizer\";\nimport { Receipt } from \"@yielded/agent/receipt\";\nimport {\n CanonicalRecordEnvelope,\n CanonicalSequence,\n DefinitionDigests,\n PersistedJson,\n SubmissionSettledRecord,\n WorkerAdmission,\n} from \"@yielded/agent/records\";\nimport {\n AdmissionFence,\n AdmissionGroup,\n AbortCommand,\n AbortIntent,\n AdmissionConflict,\n AdmissionPolicyError,\n ApprovalConflict,\n ApprovalDecisionCommand,\n ApprovalDecisionIntent,\n IdempotencyKey,\n JoinedToHost,\n LedgerError,\n OwnershipLost,\n Principal,\n Settlement,\n SettlementConflict,\n UnknownResolutionCommand,\n UnknownResolutionConflict,\n UnknownResolutionIntent,\n} from \"@yielded/agent/submission-ledger\";\nimport { SubmissionStatus } from \"@yielded/agent/submission-status\";\nimport {\n AppendConflict,\n ThreadNotMaterialized,\n ThreadStoreError,\n} from \"@yielded/agent/thread-store\";\nimport { Context, Crypto, Duration, Effect, Layer, Predicate, Schema, Stream } from \"effect\";\nimport { RpcTargets, RpcTracing } from \"effect-cf\";\n\nimport {\n callThreadObject,\n DurableAlarmError,\n ThreadObjectNamespace,\n type ThreadObjectRpc,\n} from \"./CloudflareBindings.ts\";\nimport { AdmissionLimitExceeded } from \"./CloudflareConfig.ts\";\nimport { cloudflareFailureSignals, safeCauseMessage } from \"./internal/boundary.ts\";\nimport { cloudflareCryptoLayer } from \"./internal/crypto.ts\";\nimport {\n Frame as LiveTextFrame,\n isBoundedEvent,\n MAX_DRAFT_PARTS,\n MAX_FRAME_BYTES,\n Observation as LiveTextObservation,\n Request as WatchTextRequest,\n} from \"./internal/live-text-protocol.ts\";\n\nexport { Frame as LiveTextFrame } from \"./internal/live-text-protocol.ts\";\n\n/**\n * The Worker↔Thread-Object host protocol (plan §1.4): Schema envelopes for the host\n * entry points (`submitEncoded`, `awaitSettlementEncoded`, `observePage`, `abortEncoded`,\n * `resolveApprovalEncoded`, `resolveUnknownEncoded`) plus the Worker-side client that speaks\n * it. Mirrors the WP2 port protocol: requests and responses are closed Schema unions, typed\n * failures travel as their own tagged classes and RE-DECODE to identical tags on the caller\n * (error-tag fidelity), and protocol anomalies are answered typed instead of thrown.\n */\n\n/** Ceiling for host protocol diagnostic strings. */\nconst MAX_HOST_DIAGNOSTIC_LENGTH = 4_096;\nconst PROGRESS_CANCELLATION_TIMEOUT = \"1 second\";\n\nconst BoundedDiagnostic = Schema.String.check(Schema.isMaxLength(MAX_HOST_DIAGNOSTIC_LENGTH));\n\n/** Truncate a diagnostic string to the host protocol's bounded length. */\nexport const boundHostDiagnostic = (value: string): string =>\n value.length > MAX_HOST_DIAGNOSTIC_LENGTH\n ? `${value.slice(0, MAX_HOST_DIAGNOSTIC_LENGTH - 3)}...`\n : value;\n\n/**\n * The envelope itself could not be honored: the Object could not decode the request, or a\n * response could not be encoded/decoded. Never carries operation semantics.\n */\nexport class HostProtocolError extends Schema.TaggedError<HostProtocolError>()(\n \"HostProtocolError\",\n {\n message: BoundedDiagnostic,\n },\n) {}\n\n/** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */\nexport class ThreadClientError extends Schema.TaggedError<ThreadClientError>()(\n \"ThreadClientError\",\n {\n threadId: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n /** Cloudflare's own classification for a failure safe to retry with a fresh stub. */\n retryable: Schema.optionalKey(Schema.Boolean),\n /** Cloudflare overloads are surfaced immediately instead of adding retry pressure. */\n overloaded: Schema.optionalKey(Schema.Boolean),\n },\n) {}\n\n// ---------------------------------------------------------------------------\n// Requests\n// ---------------------------------------------------------------------------\n\n/**\n * One durable submission, input ALREADY encoded by the caller through the Agent Binding's\n * input schema (the Worker bundles the same Agent definitions as the Object, so schema\n * validation happens client-side; the resolved Binding re-validates at claim time). The\n * Thread identity is deliberately absent — the addressed Object IS the lane.\n */\nexport class SubmitRequest extends Schema.Class<SubmitRequest>(\n \"@effect-agent/platform-cloudflare/SubmitRequest\",\n)({\n agentId: AgentId,\n principal: Principal,\n idempotencyKey: IdempotencyKey,\n admissionGroup: Schema.optionalKey(AdmissionGroup),\n admissionFence: Schema.optionalKey(AdmissionFence),\n workerAdmission: Schema.optionalKey(WorkerAdmission),\n messageAdmission: Schema.optionalKey(InputMessage),\n definitions: DefinitionDigests,\n inputPayload: PersistedJson,\n}) {}\n\n/** One bounded page of canonical records after an optional sequence. */\nexport class ObservePageRequest extends Schema.Class<ObservePageRequest>(\n \"@effect-agent/platform-cloudflare/ObservePageRequest\",\n)({\n afterSequence: Schema.optionalKey(CanonicalSequence),\n limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1_024)),\n}) {}\n\n/** Receipt-shaped observation request; the optional identity owns only the remote wait. */\nexport class AwaitSettlementRequest extends Receipt.extend<AwaitSettlementRequest>(\n \"@effect-agent/platform-cloudflare/AwaitSettlementRequest\",\n)({\n waiterId: Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256))),\n}) {}\n\n/** One event-driven wait for canonical progress strictly after this sequence. */\nexport class AwaitProgressRequest extends Schema.Class<AwaitProgressRequest>(\n \"@effect-agent/platform-cloudflare/AwaitProgressRequest\",\n)({\n afterSequence: CanonicalSequence,\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n/** Best-effort cancellation of one in-flight progress or settlement observation. */\nexport class CancelProgressRequest extends Schema.Class<CancelProgressRequest>(\n \"@effect-agent/platform-cloudflare/CancelProgressRequest\",\n)({\n waiterId: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Responses\n// ---------------------------------------------------------------------------\n\n/**\n * Every typed failure a host entry point can produce, plus the protocol's own errors. Same\n * closed-union discipline as the WP2 `PortFailure`: members re-decode to the SAME tagged\n * classes on the Worker side; `cause` chains travel as Schema defects without instance\n * fidelity (plan §2.8).\n */\nexport const HostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n SettlementConflict,\n ApprovalConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n LedgerError,\n OwnershipLost,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n OperationDenied,\n HostProtocolError,\n]);\n\nexport type HostFailure = typeof HostFailure.Type;\n\nexport class SubmitSucceeded extends Schema.TaggedClass<SubmitSucceeded>(\n \"@effect-agent/platform-cloudflare/SubmitSucceeded\",\n)(\"SubmitSucceeded\", {\n receipt: Receipt,\n}) {}\n\nexport class SubmissionStatusResponse extends Schema.TaggedClass<SubmissionStatusResponse>(\n \"@effect-agent/platform-cloudflare/SubmissionStatusResponse\",\n)(\"SubmissionStatusResponse\", { status: SubmissionStatus }) {}\n\nexport class SettlementReached extends Schema.TaggedClass<SettlementReached>(\n \"@effect-agent/platform-cloudflare/SettlementReached\",\n)(\"SettlementReached\", {\n settlement: Settlement,\n}) {}\n\n/** The exact canonical record of an operationally finalized Submission. */\nexport class SettlementRecordReached extends Schema.TaggedClass<SettlementRecordReached>(\n \"@effect-agent/platform-cloudflare/SettlementRecordReached\",\n)(\"SettlementRecordReached\", {\n record: SubmissionSettledRecord,\n}) {}\n\nexport class ObservedPage extends Schema.TaggedClass<ObservedPage>(\n \"@effect-agent/platform-cloudflare/ObservedPage\",\n)(\"ObservedPage\", {\n records: Schema.Array(CanonicalRecordEnvelope).check(Schema.isMaxLength(1_024)),\n}) {}\n\n/** A record was already committed or an incarnation-local hint says the caller should re-read. */\nexport class ProgressObserved extends Schema.TaggedClass<ProgressObserved>(\n \"@effect-agent/platform-cloudflare/ProgressObserved\",\n)(\"ProgressObserved\", {}) {}\n\nexport class ProgressCancelled extends Schema.TaggedClass<ProgressCancelled>(\n \"@effect-agent/platform-cloudflare/ProgressCancelled\",\n)(\"ProgressCancelled\", {}) {}\n\nexport class AbortRecorded extends Schema.TaggedClass<AbortRecorded>(\n \"@effect-agent/platform-cloudflare/AbortRecorded\",\n)(\"AbortRecorded\", {\n intent: AbortIntent,\n}) {}\n\nexport class ApprovalRecorded extends Schema.TaggedClass<ApprovalRecorded>(\n \"@effect-agent/platform-cloudflare/ApprovalRecorded\",\n)(\"ApprovalRecorded\", {\n intent: ApprovalDecisionIntent,\n}) {}\n\nexport class UnknownResolutionRecorded extends Schema.TaggedClass<UnknownResolutionRecorded>(\n \"@effect-agent/platform-cloudflare/UnknownResolutionRecorded\",\n)(\"UnknownResolutionRecorded\", {\n intent: UnknownResolutionIntent,\n}) {}\n\n/** The entry point failed TYPED on the Object; the failure re-decodes verbatim. */\nexport class HostFailed extends Schema.TaggedClass<HostFailed>(\n \"@effect-agent/platform-cloudflare/HostFailed\",\n)(\"HostFailed\", {\n failure: HostFailure,\n}) {}\n\n/** The uniform answer of one host entry point. Callers narrow by the tag their call implies. */\nexport const HostResponse = Schema.Union([\n SubmitSucceeded,\n SettlementReached,\n SettlementRecordReached,\n SubmissionStatusResponse,\n ObservedPage,\n ProgressObserved,\n ProgressCancelled,\n AbortRecorded,\n ApprovalRecorded,\n UnknownResolutionRecorded,\n HostFailed,\n]);\n\nexport type HostResponse = typeof HostResponse.Type;\n\n// ---------------------------------------------------------------------------\n// Codecs (shared by the Object endpoints and the Worker client)\n// ---------------------------------------------------------------------------\n\nexport const decodeSubmitRequest = Schema.decodeUnknownEffect(SubmitRequest);\n// Encode the caller's fields directly: constructing a Class first would validate the\n// same envelope twice. The Object still decodes its untrusted request independently.\nexport const encodeSubmitRequest = Schema.encodeEffect(Schema.Struct(SubmitRequest.fields));\nexport const decodeReceipt = Schema.decodeUnknownEffect(Receipt);\nexport const encodeReceipt = Schema.encodeEffect(Receipt);\nexport const decodeAwaitSettlementRequest = Schema.decodeUnknownEffect(AwaitSettlementRequest);\nexport const encodeAwaitSettlementRequest = Schema.encodeEffect(AwaitSettlementRequest);\nexport const decodeObservePageRequest = Schema.decodeUnknownEffect(ObservePageRequest);\nexport const encodeObservePageRequest = Schema.encodeEffect(ObservePageRequest);\nexport const decodeAwaitProgressRequest = Schema.decodeUnknownEffect(AwaitProgressRequest);\nexport const encodeAwaitProgressRequest = Schema.encodeEffect(AwaitProgressRequest);\nexport const decodeCancelProgressRequest = Schema.decodeUnknownEffect(CancelProgressRequest);\nexport const encodeCancelProgressRequest = Schema.encodeEffect(CancelProgressRequest);\nexport const decodeAbortCommand = Schema.decodeUnknownEffect(AbortCommand);\nexport const encodeAbortCommand = Schema.encodeEffect(AbortCommand);\nexport const decodeApprovalDecisionCommand = Schema.decodeUnknownEffect(ApprovalDecisionCommand);\nexport const encodeApprovalDecisionCommand = Schema.encodeEffect(ApprovalDecisionCommand);\nexport const decodeUnknownResolutionCommand = Schema.decodeUnknownEffect(UnknownResolutionCommand);\nexport const encodeUnknownResolutionCommand = Schema.encodeEffect(UnknownResolutionCommand);\nexport const encodeHostResponse = Schema.encodeEffect(HostResponse);\nexport const decodeHostResponse = Schema.decodeUnknownEffect(HostResponse);\n\n// ---------------------------------------------------------------------------\n// Worker-side client\n// ---------------------------------------------------------------------------\n\n/** Failure surface of `CloudflareThreadClient.submit`. */\nconst ClientSubmitHostFailure = Schema.Union([\n AgentInputError,\n DigestError,\n AdmissionConflict,\n AdmissionPolicyError,\n LedgerError,\n OwnershipLost,\n ThreadStoreError,\n ThreadNotMaterialized,\n AppendConflict,\n DurableRuntimeFailpointError,\n AdmissionLimitExceeded,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientAwaitHostFailure = Schema.Union([\n LedgerError,\n OwnershipLost,\n SettlementConflict,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientObserveHostFailure = Schema.Union([\n ThreadStoreError,\n ThreadNotMaterialized,\n OperationDenied,\n HostProtocolError,\n]);\n\nconst ClientAbortHostFailure = Schema.Union([\n OperationDenied,\n LedgerError,\n OwnershipLost,\n SettlementConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientApprovalHostFailure = Schema.Union([\n LedgerError,\n OwnershipLost,\n SettlementConflict,\n ApprovalConflict,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nconst ClientUnknownHostFailure = Schema.Union([\n LedgerError,\n OwnershipLost,\n SettlementConflict,\n UnknownResolutionConflict,\n JoinedToHost,\n DurableRuntimeFailpointError,\n OperationDenied,\n DurableAlarmError,\n HostProtocolError,\n]);\n\nexport type ClientSubmitFailure = typeof ClientSubmitHostFailure.Type | ThreadClientError;\nexport type ClientAwaitFailure = typeof ClientAwaitHostFailure.Type | ThreadClientError;\nexport type ClientObserveFailure = typeof ClientObserveHostFailure.Type | ThreadClientError;\nexport type ClientProgressFailure = ClientObserveFailure;\nexport type ClientAbortFailure = typeof ClientAbortHostFailure.Type | ThreadClientError;\nexport type ClientApprovalFailure = typeof ClientApprovalHostFailure.Type | ThreadClientError;\nexport type ClientUnknownFailure = typeof ClientUnknownHostFailure.Type | ThreadClientError;\n\nconst liveTextProtocolFailure = () =>\n HostProtocolError.make({\n message: \"Provisional text is incomplete or invalid; discard drafts and read canonical records\",\n });\n\nconst decodeLiveTextFrame = Schema.decodeUnknownSync(Schema.fromJsonString(LiveTextFrame));\n\n/**\n * Validate untrusted NDJSON at the final consumer, including frame bounds, thread,\n * sequence and text lifecycle. Stream loss invalidates all provisional drafts.\n */\nexport const decodeLiveText = <E, R>(\n threadId: ThreadId,\n source: Stream.Stream<Uint8Array, E, R>,\n): Stream.Stream<LiveTextFrame, E | HostProtocolError, R> =>\n Stream.suspend(() => {\n const decoder = new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: false });\n let pending = \"\";\n let pendingBytes = 0;\n let expected = 0;\n let streamId: string | undefined;\n const models = new Map<string, { attemptId: string; parts: Set<string> }>();\n\n const accept = Effect.fnUntraced(function* (frame: LiveTextFrame) {\n if (frame._tag === \"Reset\") {\n if (frame.streamId === streamId || frame.threadId !== threadId)\n return yield* liveTextProtocolFailure();\n streamId = frame.streamId;\n expected = 1;\n models.clear();\n\n return true;\n }\n if (\n streamId === undefined ||\n frame.streamId !== streamId ||\n frame.sequence !== expected++ ||\n frame.event.threadId !== threadId ||\n !isBoundedEvent(frame.event)\n )\n return yield* liveTextProtocolFailure();\n const event = frame.event;\n\n if (event._tag === \"AttemptEnded\") {\n for (const [key, model] of models)\n if (model.attemptId === event.attemptId) models.delete(key);\n\n return true;\n }\n const key = JSON.stringify([event.attemptId, event.runId, event.turnId, event.generation]);\n\n if (event._tag === \"Discard\") {\n models.delete(key);\n\n return true;\n }\n let model = models.get(key);\n\n if (event.part.type === \"text-start\") {\n if (model?.parts.has(event.part.id)) return yield* liveTextProtocolFailure();\n if (\n [...models.values()].reduce((size, value) => size + value.parts.size, 0) >=\n MAX_DRAFT_PARTS\n )\n return yield* liveTextProtocolFailure();\n if (model === undefined) {\n model = { attemptId: event.attemptId, parts: new Set() };\n models.set(key, model);\n }\n model.parts.add(event.part.id);\n\n return true;\n }\n if (!model?.parts.has(event.part.id)) return yield* liveTextProtocolFailure();\n if (event.part.type === \"text-end\") {\n model.parts.delete(event.part.id);\n if (model.parts.size === 0) models.delete(key);\n }\n\n return true;\n });\n\n return source.pipe(\n Stream.mapEffect(\n Effect.fnUntraced(function* (chunk) {\n if (!(chunk instanceof Uint8Array)) return yield* liveTextProtocolFailure();\n const frames: LiveTextFrame[] = [];\n\n for (let offset = 0; offset < chunk.byteLength;) {\n const newline = chunk.indexOf(10, offset);\n const end = newline < 0 ? chunk.byteLength : newline;\n\n pendingBytes += end - offset;\n if (pendingBytes > MAX_FRAME_BYTES) return yield* liveTextProtocolFailure();\n pending += yield* Effect.try({\n try: () => decoder.decode(chunk.subarray(offset, end), { stream: newline < 0 }),\n catch: liveTextProtocolFailure,\n });\n offset = end + 1;\n if (newline < 0) break;\n\n const frame = yield* Effect.try({\n try: () => decodeLiveTextFrame(pending),\n catch: liveTextProtocolFailure,\n });\n\n pending = \"\";\n pendingBytes = 0;\n if (yield* accept(frame)) frames.push(frame);\n }\n\n return frames;\n }),\n ),\n Stream.flatMap(Stream.fromArray),\n // This connection is open-ended. Clean EOF is also loss of provisional state.\n Stream.concat(Stream.fail(liveTextProtocolFailure())),\n );\n });\n\nconst outOfContract = (threadId: string, operation: string, observed: string): ThreadClientError =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `The Thread Object answered ${operation} with the out-of-contract ${observed}.`,\n ),\n });\n\nconst hostRpcMethods = {\n submit: \"submitEncoded\",\n awaitSettlement: \"awaitSettlementEncoded\",\n awaitSettlementRecord: \"awaitSettlementRecordEncoded\",\n submissionStatus: \"submissionStatusEncoded\",\n awaitProgress: \"awaitProgressEncoded\",\n cancelProgress: \"cancelProgressEncoded\",\n observePage: \"observePage\",\n abort: \"abortEncoded\",\n resolveApproval: \"resolveApprovalEncoded\",\n resolveUnknown: \"resolveUnknownEncoded\",\n} as const satisfies Record<string, keyof ThreadObjectRpc>;\n\n/** Worker-side client over the Thread Object namespace (DEPLOY-010). */\nexport class CloudflareThreadClient extends Context.Service<\n CloudflareThreadClient,\n {\n /** Encode the input client-side, then durably submit to the owning Object. */\n readonly submit: <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema[\"EncodingServices\"]>;\n /** Wake-hinted, poll-guaranteed settlement wait executed inside the owning Object. */\n readonly submissionStatus: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionStatus, ClientAwaitFailure>;\n /**\n * Wait for settlement; interruption spends at most one second cancelling the remote\n * observation best effort. Cancellation never aborts the admitted Run.\n */\n readonly awaitSettlement: (receipt: Receipt) => Effect.Effect<Settlement, ClientAwaitFailure>;\n /**\n * Wait for finalization and return this Receipt's canonical terminal record in one RPC.\n * Requires both settlement and observation authority. Decode an ordinary completed\n * record's result through the Agent output Schema; joined completion may have no result.\n * Interruption uses the same bounded observation cancellation as `awaitSettlement`.\n */\n readonly awaitSettlementRecord: (\n receipt: Receipt,\n ) => Effect.Effect<SubmissionSettledRecord, ClientAwaitFailure>;\n /**\n * Wait without polling until progress after `afterSequence` is already durable or hinted.\n * The result is deliberately void: canonical records remain authoritative and must be read.\n * Interruption waits at most one second for best-effort remote cancellation.\n */\n readonly awaitProgress: (\n threadId: ThreadId,\n afterSequence: CanonicalSequence,\n ) => Effect.Effect<void, ClientProgressFailure>;\n /**\n * Current provisional text followed by native deltas. Reset starts a replacement snapshot,\n * including when a slow consumer exceeds the fixed backlog. Reconcile by\n * Run/Turn identity to canonical records; discard drafts on Discard, AttemptEnded,\n * Reset or stream failure. Snapshots exist only in the Object incarnation's memory.\n * Scope the stream: interruption cancels its remote subscription.\n */\n readonly watchText: (threadId: ThreadId) => Stream.Stream<LiveTextFrame, ClientObserveFailure>;\n /**\n * Forward producer NDJSON bytes without decoding or re-encoding frames.\n * The final consumer must use `decodeLiveText` to validate untrusted frames.\n * Interruption cancels the remote subscription; buffers remain producer-bounded.\n */\n readonly watchTextBytes: (\n threadId: ThreadId,\n ) => Stream.Stream<Uint8Array, ClientObserveFailure>;\n /** One bounded page of canonical records. */\n readonly readPage: (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Every canonical record up to the CURRENT committed tail, via repeated pages. A\n * snapshot read, not a live observation — callers wanting liveness re-read after\n * `awaitSettlement`.\n */\n readonly readAll: (\n threadId: ThreadId,\n ) => Effect.Effect<ReadonlyArray<CanonicalRecordEnvelope>, ClientObserveFailure>;\n /**\n * Submission-addressed operations take the owning Thread explicitly (from the\n * Receipt): minted Submission identities stay OPAQUE outside the storage adapter that\n * minted them (D-P6-5), so the client never parses one to find the lane.\n */\n readonly abort: (\n threadId: ThreadId,\n command: AbortCommand,\n ) => Effect.Effect<AbortIntent, ClientAbortFailure>;\n readonly resolveApproval: (\n threadId: ThreadId,\n command: ApprovalDecisionCommand,\n ) => Effect.Effect<ApprovalDecisionIntent, ClientApprovalFailure>;\n readonly resolveUnknown: (\n threadId: ThreadId,\n command: UnknownResolutionCommand,\n ) => Effect.Effect<UnknownResolutionIntent, ClientUnknownFailure>;\n }\n>()(\"@effect-agent/platform-cloudflare/CloudflareThreadClient\") {\n /**\n * Assemble the client from a resolved namespace and the platform Crypto implementation.\n * rpcTracing is the binding name and remains opt-in. Caller authentication, principals,\n * idempotency keys, and definition digests are still explicit submission inputs.\n */\n static layerFromBinding(options: {\n readonly namespace: DurableObjectNamespace<ThreadObjectRpc>;\n readonly rpcTracing?: string;\n }): Layer.Layer<CloudflareThreadClient> {\n return CloudflareThreadClient.layer.pipe(\n Layer.provide([\n ThreadObjectNamespace.layer(options.namespace, options),\n cloudflareCryptoLayer,\n ]),\n );\n }\n\n static readonly layer: Layer.Layer<\n CloudflareThreadClient,\n never,\n ThreadObjectNamespace | Crypto.Crypto\n > = Layer.effect(CloudflareThreadClient)(\n Effect.gen(function* () {\n const namespace = yield* ThreadObjectNamespace;\n const { rpcTracing } = namespace;\n const crypto = yield* Crypto.Crypto;\n\n const call = Effect.fnUntraced(\n function* (\n threadId: ThreadId,\n operation: keyof typeof hostRpcMethods,\n encoded: unknown,\n ): Effect.fn.Return<HostResponse, ThreadClientError | HostProtocolError> {\n // Empty arguments preserve native arity. Passing `undefined` still adds an argument.\n const traceArgs =\n rpcTracing === undefined ? [] : yield* RpcTracing.withRpcTraceContext([]);\n\n const raw = yield* callThreadObject(\n threadId,\n (stub) => stub[hostRpcMethods[operation]](encoded, ...traceArgs),\n (cause) =>\n ThreadClientError.make({\n threadId,\n message: boundHostDiagnostic(\n `${operation} did not reach the Thread Object: ${safeCauseMessage(\n cause,\n \"the RPC failed without a diagnostic\",\n )}`,\n ),\n cause,\n ...cloudflareFailureSignals(cause),\n }),\n ).pipe(Effect.provideService(ThreadObjectNamespace, namespace));\n\n return yield* decodeHostResponse(raw).pipe(\n Effect.mapError((error): HostProtocolError =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `The ${operation} answer could not be decoded: ${error.message}`,\n ),\n }),\n ),\n );\n },\n (effect, threadId, operation) =>\n rpcTracing === undefined\n ? Effect.withSpan(effect, \"CloudflareThreadClient.call\", {\n attributes: { threadId, operation },\n })\n : RpcTracing.withRpcClientSpan(effect, rpcTracing, hostRpcMethods[operation]),\n );\n\n const expect = <ResultSchema extends Schema.Top, FailureSchema extends Schema.Top>(\n threadId: string,\n operation: string,\n resultSchema: ResultSchema,\n failureSchema: FailureSchema,\n ) => {\n const isExpectedResult = Schema.is(resultSchema);\n const isExpectedFailure = Schema.is(failureSchema);\n\n return (\n response: HostResponse,\n ): Effect.Effect<ResultSchema[\"Type\"], FailureSchema[\"Type\"] | ThreadClientError> => {\n if (response._tag === \"HostFailed\") {\n const failure = response.failure;\n\n return isExpectedFailure(failure)\n ? Effect.fail(failure)\n : Effect.fail(outOfContract(threadId, operation, `failure ${failure._tag}`));\n }\n if (!isExpectedResult(response)) {\n return Effect.fail(outOfContract(threadId, operation, `result ${response._tag}`));\n }\n\n return Effect.succeed(response);\n };\n };\n\n const readPage = Effect.fnUntraced(function* (\n threadId: ThreadId,\n options?: {\n readonly afterSequence?: CanonicalSequence | undefined;\n readonly limit?: number | undefined;\n },\n ) {\n const request = ObservePageRequest.make({\n ...(options?.afterSequence === undefined ? {} : { afterSequence: options.afterSequence }),\n limit: options?.limit ?? 256,\n });\n\n const encoded = yield* encodeObservePageRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`observePage request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"observePage\", encoded);\n\n const page = yield* expect(\n threadId,\n \"observePage\",\n ObservedPage,\n ClientObserveHostFailure,\n )(response);\n\n return page.records;\n });\n\n const cancelProgress = (threadId: ThreadId, waiterId: string): Effect.Effect<void> =>\n encodeCancelProgressRequest(CancelProgressRequest.make({ waiterId })).pipe(\n Effect.mapError(() => undefined),\n Effect.flatMap((encoded) => call(threadId, \"cancelProgress\", encoded)),\n // Finalizers are uninterruptible; only the foreign RPC branch must remain\n // interruptible so a lost cancellation reply cannot prevent local shutdown.\n Effect.interruptible,\n Effect.timeout(PROGRESS_CANCELLATION_TIMEOUT),\n Effect.asVoid,\n Effect.ignore,\n );\n\n const awaitSettlementCall = Effect.fnUntraced(function* (\n receipt: Receipt,\n operation: \"awaitSettlement\" | \"awaitSettlementRecord\",\n ): Effect.fn.Return<HostResponse, ClientAwaitFailure> {\n const waiterId = yield* crypto.randomUUIDv4().pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `${operation} cancellation identity generation failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const encoded = yield* encodeAwaitSettlementRequest(\n AwaitSettlementRequest.make({ ...receipt, waiterId }),\n ).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`${operation} request encode failed: ${error.message}`),\n }),\n ),\n );\n\n return yield* call(receipt.threadId, operation, encoded).pipe(\n Effect.onInterrupt(() => cancelProgress(receipt.threadId, waiterId)),\n );\n });\n\n const watchTextBytes = (\n threadId: ThreadId,\n ): Stream.Stream<Uint8Array, ClientObserveFailure> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const traceArgs =\n rpcTracing === undefined ? [] : yield* RpcTracing.withRpcTraceContext([]);\n\n const openingFailure = (cause: unknown) =>\n ThreadClientError.make({\n threadId,\n message: \"Provisional text observation could not reach the Thread Object\",\n cause,\n ...cloudflareFailureSignals(cause),\n });\n\n // Retain the original RPC promise: resolving through callThreadObject would\n // erase its optional native disposer before an interrupted opening can use it.\n const target = yield* RpcTargets.get(namespace, threadId, () =>\n namespace.get(threadId),\n ).pipe(Effect.mapError(openingFailure));\n\n let request: Promise<unknown> | undefined;\n let received: unknown;\n let closed = false;\n\n const cancel = () => {\n const value = received;\n\n received = undefined;\n\n const observation = Schema.is(LiveTextObservation)(value) ? value : undefined;\n\n // Native RPC disposes the capability with the request; also release\n // it for application-owned endpoints and late opening responses.\n try {\n observation?.lifetime[Symbol.dispose]();\n } catch {\n // A request disposer may already have revoked this stub.\n }\n const stream = observation?.stream ?? value;\n\n return stream instanceof ReadableStream && !stream.locked\n ? stream.cancel().catch(() => undefined)\n : Promise.resolve();\n };\n\n // Install ownership before invoking foreign code, not after its promise settles.\n yield* Effect.addFinalizer(() =>\n Effect.try({\n try: () => {\n closed = true;\n if (Predicate.hasProperty(request, Symbol.dispose)) {\n const dispose = request[Symbol.dispose];\n\n if (typeof dispose === \"function\") dispose.call(request);\n }\n },\n catch: () => undefined,\n }).pipe(\n Effect.ignore,\n Effect.andThen(\n Effect.tryPromise({ try: cancel, catch: () => undefined }).pipe(\n Effect.interruptible,\n Effect.timeout(PROGRESS_CANCELLATION_TIMEOUT),\n Effect.ignore,\n ),\n ),\n ),\n );\n\n const raw = yield* Effect.tryPromise({\n try: () => {\n request = target.watchTextEncoded(\n Schema.encodeSync(WatchTextRequest)({ schemaVersion: 1 }),\n ...traceArgs,\n );\n\n return request.then((value) => {\n received = value;\n\n // A custom endpoint may return a plain, non-cancellable promise. Keep\n // late cleanup on that native promise chain; it starts no Effect fiber.\n return closed ? cancel().then(() => value) : value;\n });\n },\n catch: openingFailure,\n }).pipe(\n Effect.interruptible,\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n );\n\n const stream = Schema.is(LiveTextObservation)(raw) ? raw.stream : raw;\n\n if (stream instanceof ReadableStream)\n return Stream.fromReadableStream<Uint8Array, ThreadClientError>({\n evaluate: () => stream,\n // The subscription Scope cancels after the reader releases its lock.\n releaseLockOnEnd: true,\n onError: (cause) =>\n ThreadClientError.make({\n threadId,\n message:\n \"Provisional text disconnected; discard drafts and read canonical records\",\n cause,\n }),\n });\n\n const response = yield* decodeHostResponse(raw).pipe(\n Effect.mapError(liveTextProtocolFailure),\n );\n\n if (\n response._tag === \"HostFailed\" &&\n Schema.is(ClientObserveHostFailure)(response.failure)\n )\n return yield* response.failure;\n\n return yield* liveTextProtocolFailure();\n }),\n );\n\n return CloudflareThreadClient.of({\n submit: Effect.fnUntraced(function* <InputSchema extends Schema.Top>(\n agent: DurableSubmitAgent<InputSchema>,\n input: InputSchema[\"Type\"],\n options: DurableSubmitOptions,\n ) {\n // Client-side half of `DurableAgentRuntime.submit`'s input boundary: encode\n // through the Agent's input schema and prove the canonical persistence bounds.\n const encodedInput = yield* Schema.encodeEffect(agent.definition.input)(input).pipe(\n Effect.mapError((cause) =>\n AgentInputError.make({ message: `Unable to encode Agent input: ${cause.message}` }),\n ),\n );\n\n const inputPayload = yield* Schema.decodeUnknownEffect(PersistedJson)(encodedInput).pipe(\n Effect.mapError(() =>\n AgentInputError.make({\n message: \"Agent input does not satisfy the canonical persistence bounds\",\n }),\n ),\n );\n\n const request = {\n agentId: agent.definition.id,\n principal: options.principal,\n idempotencyKey: options.idempotencyKey,\n ...(options.admissionGroup === undefined\n ? {}\n : { admissionGroup: options.admissionGroup }),\n ...(options.admissionFence === undefined\n ? {}\n : { admissionFence: options.admissionFence }),\n ...(options.workerAdmission === undefined\n ? {}\n : { workerAdmission: options.workerAdmission }),\n ...(options.messageAdmission === undefined\n ? {}\n : { messageAdmission: options.messageAdmission }),\n definitions: options.definitions,\n inputPayload,\n };\n\n const encoded = yield* encodeSubmitRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`submit request encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(options.threadId, \"submit\", encoded);\n\n const succeeded = yield* expect(\n options.threadId,\n \"submit\",\n SubmitSucceeded,\n ClientSubmitHostFailure,\n )(response);\n\n return succeeded.receipt;\n }),\n\n submissionStatus: Effect.fnUntraced(function* (receipt) {\n const encoded = yield* encodeReceipt(receipt).pipe(\n Effect.mapError(() => HostProtocolError.make({ message: \"Invalid receipt\" })),\n );\n\n const response = yield* call(receipt.threadId, \"submissionStatus\", encoded);\n\n const result = yield* expect(\n receipt.threadId,\n \"submissionStatus\",\n SubmissionStatusResponse,\n ClientAwaitHostFailure,\n )(response);\n\n return result.status;\n }),\n awaitSettlement: Effect.fnUntraced(function* (receipt) {\n const response = yield* awaitSettlementCall(receipt, \"awaitSettlement\");\n\n const settled = yield* expect(\n receipt.threadId,\n \"awaitSettlement\",\n SettlementReached,\n ClientAwaitHostFailure,\n )(response);\n\n return settled.settlement;\n }),\n\n awaitSettlementRecord: Effect.fnUntraced(function* (receipt) {\n const response = yield* awaitSettlementCall(receipt, \"awaitSettlementRecord\");\n\n const settled = yield* expect(\n receipt.threadId,\n \"awaitSettlementRecord\",\n SettlementRecordReached,\n ClientAwaitHostFailure,\n )(response);\n\n return settled.record;\n }),\n\n awaitProgress: Effect.fnUntraced(function* (threadId, afterSequence) {\n const waiterId = yield* crypto.randomUUIDv4().pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress cancellation identity generation failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const request = AwaitProgressRequest.make({ afterSequence, waiterId });\n\n const encoded = yield* encodeAwaitProgressRequest(request).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(\n `awaitProgress request encode failed: ${error.message}`,\n ),\n }),\n ),\n );\n\n const attempt = (retry: number): Effect.Effect<void, ClientProgressFailure> =>\n call(threadId, \"awaitProgress\", encoded).pipe(\n Effect.flatMap(\n expect(threadId, \"awaitProgress\", ProgressObserved, ClientObserveHostFailure),\n ),\n Effect.asVoid,\n Effect.catchTag(\"ThreadClientError\", (error) =>\n error.retryable === true && error.overloaded !== true && retry < 5\n ? Effect.sleep(Duration.millis(10 * 2 ** retry)).pipe(\n Effect.andThen(attempt(retry + 1)),\n )\n : Effect.fail(error),\n ),\n );\n\n yield* attempt(0).pipe(Effect.onInterrupt(() => cancelProgress(threadId, waiterId)));\n }),\n\n watchText: (threadId) => decodeLiveText(threadId, watchTextBytes(threadId)),\n watchTextBytes,\n\n readPage,\n\n readAll: Effect.fnUntraced(function* (threadId) {\n const all: Array<CanonicalRecordEnvelope> = [];\n let after: CanonicalSequence | undefined;\n\n for (;;) {\n const page = yield* readPage(threadId, { afterSequence: after, limit: 1_024 });\n\n all.push(...page);\n const last = page.at(-1);\n\n if (page.length < 1_024 || last === undefined) return all;\n after = last.sequence;\n }\n }),\n\n abort: Effect.fnUntraced(function* (threadId, command) {\n const encoded = yield* encodeAbortCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`abort command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"abort\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"abort\",\n AbortRecorded,\n ClientAbortHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveApproval: Effect.fnUntraced(function* (threadId, command) {\n const encoded = yield* encodeApprovalDecisionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`approval command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveApproval\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveApproval\",\n ApprovalRecorded,\n ClientApprovalHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n\n resolveUnknown: Effect.fnUntraced(function* (threadId, command) {\n const encoded = yield* encodeUnknownResolutionCommand(command).pipe(\n Effect.mapError((error) =>\n HostProtocolError.make({\n message: boundHostDiagnostic(`resolution command encode failed: ${error.message}`),\n }),\n ),\n );\n\n const response = yield* call(threadId, \"resolveUnknown\", encoded);\n\n const recorded = yield* expect(\n threadId,\n \"resolveUnknown\",\n UnknownResolutionRecorded,\n ClientUnknownHostFailure,\n )(response);\n\n return recorded.intent;\n }),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,wBAAoD,MAAM,OACrE,OAAO,QACP,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,OAAO;CAC3B,MAAM,YAAY,OAAO,cAAc;CACvC,MAAM,cAAsB;CAE5B,OAAO,OAAO,OAAO,GAAG;EACtB,GAAG;EACH,SAAS,WAAW,SAAS;GAC3B,IACE,cAAc,aACd,EAAE,YAAY,gBACd,cAAc,YAAY,UAC1B,OAAO,UAAU,QAAQ,WAAW,YAEpC,OAAO,KAAK,OAAO,WAAW,IAAI;GAEpC,OAAO,OAAO,IAAI;IAChB,WAAW,WAAW,KAAK,WAAW,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;IACrE,QAAQ,UACN,cAAc,YAAY;KACxB,QAAQ;KACR,QAAQ;KACR,MAAM;KACN,aAAa;KACb;IACF,CAAC;GACL,CAAC;EACH;CACF,CAAC;AACH,CAAC,CACH,CAAC,CAAC,KAAK,MAAM,QAAQ,cAAc,KAAK,CAAC;;;ACnCzC,MAAa,kBAAkB;AAE/B,MAAa,mBAAmB;AAIhC,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AAS,SAAS,KAAA,GAAW,OAAO;KACtD,QAAQ,KAAK;IACf;GACF,CAAC;GAED,OAAO,OAAO,WAAW,WAAW,UAAU,SAAS;IACrD,MAAM,UAAU,OAAO,mBAAmB,OAAO,CAAC,CAAC,KACjD,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBAAoB,gCAAgC,MAAM,SAAS,EAC9E,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,SAAS,OAAO;IASvD,QAAO,OAPiB,OACtB,UACA,SACA,eACA,sBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;GAED,iBAAiB,OAAO,WAAW,WAAW,UAAU,SAAS;IAC/D,MAAM,UAAU,OAAO,8BAA8B,OAAO,CAAC,CAAC,KAC5D,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBAAoB,mCAAmC,MAAM,SAAS,EACjF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,mBAAmB,OAAO;IASjE,QAAO,OAPiB,OACtB,UACA,mBACA,kBACA,yBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;GAED,gBAAgB,OAAO,WAAW,WAAW,UAAU,SAAS;IAC9D,MAAM,UAAU,OAAO,+BAA+B,OAAO,CAAC,CAAC,KAC7D,OAAO,UAAU,UACf,kBAAkB,KAAK,EACrB,SAAS,oBAAoB,qCAAqC,MAAM,SAAS,EACnF,CAAC,CACH,CACF;IAEA,MAAM,WAAW,OAAO,KAAK,UAAU,kBAAkB,OAAO;IAShE,QAAO,OAPiB,OACtB,UACA,kBACA,2BACA,wBACF,CAAC,CAAC,QAAQ,EAAA,CAEM;GAClB,CAAC;EACH,CAAC;CACH,CAAC,CACH;AACF"}
|
package/dist/{CloudflareThreadClient-Atp-Clb4.d.mts → CloudflareThreadClient-DNsFhgVu.d.mts}
RENAMED
|
@@ -4,6 +4,7 @@ import { DurableSubmitAgent, DurableSubmitOptions } from "@yielded/agent/durable
|
|
|
4
4
|
import { ThreadId } from "@yielded/agent/identifiers";
|
|
5
5
|
import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, JoinedToHost, LedgerError, OwnershipLost, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@yielded/agent/submission-ledger";
|
|
6
6
|
import { Context, Crypto, Effect, Layer, Schema, Stream } from "effect";
|
|
7
|
+
import { Rpc } from "effect-cf";
|
|
7
8
|
import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests, SubmissionSettledRecord } from "@yielded/agent/records";
|
|
8
9
|
import { AgentInputError } from "@yielded/agent/agent-error";
|
|
9
10
|
import { DigestError } from "@yielded/agent/digest";
|
|
@@ -14,6 +15,11 @@ import { SubmissionStatus } from "@yielded/agent/submission-status";
|
|
|
14
15
|
import { AppendConflict, ThreadNotMaterialized, ThreadStoreError } from "@yielded/agent/thread-store";
|
|
15
16
|
import { Event } from "@yielded/agent/provisional-text";
|
|
16
17
|
//#region src/internal/live-text-protocol.d.ts
|
|
18
|
+
/** The RPC lifetime survives an idle byte stream and is disposed on caller disconnect. */
|
|
19
|
+
declare const Observation: Schema.Struct<{
|
|
20
|
+
readonly stream: Schema.instanceOf<ReadableStream<Uint8Array<ArrayBufferLike>>, unknown>;
|
|
21
|
+
readonly lifetime: Schema.declare<Rpc.DisposableValue, unknown>;
|
|
22
|
+
}>;
|
|
17
23
|
/**
|
|
18
24
|
* Reset replaces all drafts with a snapshot, streamed as native Text parts before live deltas.
|
|
19
25
|
* Each snapshot starts a fresh streamId. Its sequences are unrelated to canonical sequences.
|
|
@@ -738,13 +744,13 @@ declare const encodeUnknownResolutionCommand: (input: UnknownResolutionCommand,
|
|
|
738
744
|
readonly author: string;
|
|
739
745
|
readonly reason: string;
|
|
740
746
|
readonly resolution: {
|
|
741
|
-
readonly _tag: "SafeToRetry";
|
|
742
|
-
} | {
|
|
743
747
|
readonly _tag: "CompletedWithResult";
|
|
744
748
|
readonly result: Schema.Json;
|
|
745
749
|
readonly isFailure: boolean;
|
|
746
750
|
} | {
|
|
747
751
|
readonly _tag: "NeverHappened";
|
|
752
|
+
} | {
|
|
753
|
+
readonly _tag: "SafeToRetry";
|
|
748
754
|
} | {
|
|
749
755
|
readonly _tag: "AbortSubmission";
|
|
750
756
|
};
|
|
@@ -2005,13 +2011,13 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
2005
2011
|
readonly author: string;
|
|
2006
2012
|
readonly reason: string;
|
|
2007
2013
|
readonly resolution: {
|
|
2008
|
-
readonly _tag: "SafeToRetry";
|
|
2009
|
-
} | {
|
|
2010
2014
|
readonly _tag: "CompletedWithResult";
|
|
2011
2015
|
readonly result: Schema.Json;
|
|
2012
2016
|
readonly isFailure: boolean;
|
|
2013
2017
|
} | {
|
|
2014
2018
|
readonly _tag: "NeverHappened";
|
|
2019
|
+
} | {
|
|
2020
|
+
readonly _tag: "SafeToRetry";
|
|
2015
2021
|
} | {
|
|
2016
2022
|
readonly _tag: "AbortSubmission";
|
|
2017
2023
|
};
|
|
@@ -2021,14 +2027,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
2021
2027
|
} | {
|
|
2022
2028
|
readonly _tag: "HostFailed";
|
|
2023
2029
|
readonly failure: {
|
|
2024
|
-
readonly _tag: "DurableAlarmError";
|
|
2025
|
-
readonly operation: string;
|
|
2026
|
-
readonly message: string;
|
|
2027
|
-
readonly cause?: Schema.Json | undefined;
|
|
2028
|
-
} | {
|
|
2029
|
-
readonly _tag: "HostProtocolError";
|
|
2030
|
-
readonly message: string;
|
|
2031
|
-
} | {
|
|
2032
2030
|
readonly _tag: "ThreadNotMaterialized";
|
|
2033
2031
|
readonly threadId: string;
|
|
2034
2032
|
} | {
|
|
@@ -2043,6 +2041,33 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
2043
2041
|
readonly issueTag?: string | undefined;
|
|
2044
2042
|
readonly sequence?: number | undefined;
|
|
2045
2043
|
} | undefined;
|
|
2044
|
+
} | {
|
|
2045
|
+
readonly _tag: "OwnershipLost";
|
|
2046
|
+
readonly submissionId: string;
|
|
2047
|
+
} | {
|
|
2048
|
+
readonly _tag: "DurableRuntimeFailpointError";
|
|
2049
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "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-duration-append" | "run:after-start-append" | "run:before-duration-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:before-publication" | "tools:after-dispatch-fence" | "tools:after-unavailable-append" | "tools:before-dispatch-fence" | "tools:before-unavailable-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-stop-append" | "worker:after-stop-seal" | "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-stop-append" | "worker:before-stop-seal" | "worker:before-subtree-append";
|
|
2050
|
+
} | {
|
|
2051
|
+
readonly _tag: "AdmissionConflict";
|
|
2052
|
+
readonly threadId: string;
|
|
2053
|
+
readonly principal: string;
|
|
2054
|
+
readonly idempotencyKey: string;
|
|
2055
|
+
readonly existingInputDigest: string;
|
|
2056
|
+
readonly attemptedInputDigest: string;
|
|
2057
|
+
} | {
|
|
2058
|
+
readonly _tag: "AdmissionPolicyError";
|
|
2059
|
+
readonly reason: "occupied" | "refused" | "unavailable";
|
|
2060
|
+
readonly code: string;
|
|
2061
|
+
readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
|
|
2062
|
+
readonly stack?: string | undefined;
|
|
2063
|
+
} | {
|
|
2064
|
+
readonly _tag: "SettlementConflict";
|
|
2065
|
+
readonly submissionId: string;
|
|
2066
|
+
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
2067
|
+
} | {
|
|
2068
|
+
readonly _tag: "JoinedToHost";
|
|
2069
|
+
readonly submissionId: string;
|
|
2070
|
+
readonly hostSubmissionId: string;
|
|
2046
2071
|
} | {
|
|
2047
2072
|
readonly _tag: "LedgerError";
|
|
2048
2073
|
readonly operation: string;
|
|
@@ -2054,39 +2079,16 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
2054
2079
|
readonly batchId: string;
|
|
2055
2080
|
readonly reason: "batch-content" | "record-identity" | "stale-command" | "tail";
|
|
2056
2081
|
readonly actualTailSequence?: number | undefined;
|
|
2057
|
-
} | {
|
|
2058
|
-
readonly _tag: "OwnershipLost";
|
|
2059
|
-
readonly submissionId: string;
|
|
2060
2082
|
} | {
|
|
2061
2083
|
readonly _tag: "OperationDenied";
|
|
2062
2084
|
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
2063
2085
|
readonly reason: string;
|
|
2064
2086
|
readonly threadId?: string | undefined;
|
|
2065
2087
|
readonly submissionId?: string | undefined;
|
|
2066
|
-
} | {
|
|
2067
|
-
readonly _tag: "SettlementConflict";
|
|
2068
|
-
readonly submissionId: string;
|
|
2069
|
-
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
2070
|
-
} | {
|
|
2071
|
-
readonly _tag: "AdmissionPolicyError";
|
|
2072
|
-
readonly reason: "occupied" | "refused" | "unavailable";
|
|
2073
|
-
readonly code: string;
|
|
2074
|
-
readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
|
|
2075
|
-
readonly stack?: string | undefined;
|
|
2076
2088
|
} | {
|
|
2077
2089
|
readonly _tag: "DigestError";
|
|
2078
2090
|
readonly message: string;
|
|
2079
2091
|
readonly cause?: Schema.Json | undefined;
|
|
2080
|
-
} | {
|
|
2081
|
-
readonly _tag: "DurableRuntimeFailpointError";
|
|
2082
|
-
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "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-duration-append" | "run:after-start-append" | "run:before-duration-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:before-publication" | "tools:after-dispatch-fence" | "tools:after-unavailable-append" | "tools:before-dispatch-fence" | "tools:before-unavailable-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-stop-append" | "worker:after-stop-seal" | "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-stop-append" | "worker:before-stop-seal" | "worker:before-subtree-append";
|
|
2083
|
-
} | {
|
|
2084
|
-
readonly _tag: "AdmissionConflict";
|
|
2085
|
-
readonly threadId: string;
|
|
2086
|
-
readonly principal: string;
|
|
2087
|
-
readonly idempotencyKey: string;
|
|
2088
|
-
readonly existingInputDigest: string;
|
|
2089
|
-
readonly attemptedInputDigest: string;
|
|
2090
2092
|
} | {
|
|
2091
2093
|
readonly _tag: "AgentInputError";
|
|
2092
2094
|
readonly message: string;
|
|
@@ -2096,9 +2098,13 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
2096
2098
|
readonly actual: number;
|
|
2097
2099
|
readonly maximum: number;
|
|
2098
2100
|
} | {
|
|
2099
|
-
readonly _tag: "
|
|
2100
|
-
readonly
|
|
2101
|
-
readonly
|
|
2101
|
+
readonly _tag: "DurableAlarmError";
|
|
2102
|
+
readonly operation: string;
|
|
2103
|
+
readonly message: string;
|
|
2104
|
+
readonly cause?: Schema.Json | undefined;
|
|
2105
|
+
} | {
|
|
2106
|
+
readonly _tag: "HostProtocolError";
|
|
2107
|
+
readonly message: string;
|
|
2102
2108
|
} | {
|
|
2103
2109
|
readonly _tag: "ApprovalConflict";
|
|
2104
2110
|
readonly submissionId: string;
|
|
@@ -2201,5 +2207,5 @@ declare class CloudflareThreadClient extends CloudflareThreadClient_base {
|
|
|
2201
2207
|
static readonly layer: Layer.Layer<CloudflareThreadClient, never, ThreadObjectNamespace | Crypto.Crypto>;
|
|
2202
2208
|
}
|
|
2203
2209
|
//#endregion
|
|
2204
|
-
export { boundHostDiagnostic as A, decodeSubmitRequest as B, SettlementReached as C, SubmitSucceeded as D, SubmitRequest as E, decodeCancelProgressRequest as F, encodeAwaitSettlementRequest as G, encodeAbortCommand as H, decodeHostResponse as I, encodeObservePageRequest as J, encodeCancelProgressRequest as K, decodeLiveText as L, decodeApprovalDecisionCommand as M, decodeAwaitProgressRequest as N, ThreadClientError as O, decodeAwaitSettlementRequest as P, Frame as Q, decodeObservePageRequest as R, ProgressObserved as S, SubmissionStatusResponse as T, encodeApprovalDecisionCommand as U, decodeUnknownResolutionCommand as V, encodeAwaitProgressRequest as W, encodeSubmitRequest as X, encodeReceipt as Y, encodeUnknownResolutionCommand as Z, HostProtocolError as _, CancelProgressRequest as a, ObservedPage as b, ClientAwaitFailure as c, ClientSubmitFailure as d, ClientUnknownFailure as f, HostFailure as g, HostFailed as h, AwaitSettlementRequest as i, decodeAbortCommand as j, UnknownResolutionRecorded as k, ClientObserveFailure as l, CloudflareThreadClient_d_exports as m, ApprovalRecorded as n, ClientAbortFailure as o, CloudflareThreadClient as p, encodeHostResponse as q, AwaitProgressRequest as r, ClientApprovalFailure as s, AbortRecorded as t, ClientProgressFailure as u, HostResponse as v, SettlementRecordReached as w, ProgressCancelled as x, ObservePageRequest as y, decodeReceipt as z };
|
|
2205
|
-
//# sourceMappingURL=CloudflareThreadClient-
|
|
2210
|
+
export { Observation as $, boundHostDiagnostic as A, decodeSubmitRequest as B, SettlementReached as C, SubmitSucceeded as D, SubmitRequest as E, decodeCancelProgressRequest as F, encodeAwaitSettlementRequest as G, encodeAbortCommand as H, decodeHostResponse as I, encodeObservePageRequest as J, encodeCancelProgressRequest as K, decodeLiveText as L, decodeApprovalDecisionCommand as M, decodeAwaitProgressRequest as N, ThreadClientError as O, decodeAwaitSettlementRequest as P, Frame as Q, decodeObservePageRequest as R, ProgressObserved as S, SubmissionStatusResponse as T, encodeApprovalDecisionCommand as U, decodeUnknownResolutionCommand as V, encodeAwaitProgressRequest as W, encodeSubmitRequest as X, encodeReceipt as Y, encodeUnknownResolutionCommand as Z, HostProtocolError as _, CancelProgressRequest as a, ObservedPage as b, ClientAwaitFailure as c, ClientSubmitFailure as d, ClientUnknownFailure as f, HostFailure as g, HostFailed as h, AwaitSettlementRequest as i, decodeAbortCommand as j, UnknownResolutionRecorded as k, ClientObserveFailure as l, CloudflareThreadClient_d_exports as m, ApprovalRecorded as n, ClientAbortFailure as o, CloudflareThreadClient as p, encodeHostResponse as q, AwaitProgressRequest as r, ClientApprovalFailure as s, AbortRecorded as t, ClientProgressFailure as u, HostResponse as v, SettlementRecordReached as w, ProgressCancelled as x, ObservePageRequest as y, decodeReceipt as z };
|
|
2211
|
+
//# sourceMappingURL=CloudflareThreadClient-DNsFhgVu.d.mts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as boundHostDiagnostic, B as decodeSubmitRequest, C as SettlementReached, D as SubmitSucceeded, E as SubmitRequest, F as decodeCancelProgressRequest, G as encodeAwaitSettlementRequest, H as encodeAbortCommand, I as decodeHostResponse, J as encodeObservePageRequest, K as encodeCancelProgressRequest, L as decodeLiveText, M as decodeApprovalDecisionCommand, N as decodeAwaitProgressRequest, O as ThreadClientError, P as decodeAwaitSettlementRequest, Q as Frame, R as decodeObservePageRequest, S as ProgressObserved, T as SubmissionStatusResponse, U as encodeApprovalDecisionCommand, V as decodeUnknownResolutionCommand, W as encodeAwaitProgressRequest, X as encodeSubmitRequest, Y as encodeReceipt, Z as encodeUnknownResolutionCommand, _ as HostProtocolError, a as CancelProgressRequest, b as ObservedPage, c as ClientAwaitFailure, d as ClientSubmitFailure, f as ClientUnknownFailure, g as HostFailure, h as HostFailed, i as AwaitSettlementRequest, j as decodeAbortCommand, k as UnknownResolutionRecorded, l as ClientObserveFailure, n as ApprovalRecorded, o as ClientAbortFailure, p as CloudflareThreadClient, q as encodeHostResponse, r as AwaitProgressRequest, s as ClientApprovalFailure, t as AbortRecorded, u as ClientProgressFailure, v as HostResponse, w as SettlementRecordReached, x as ProgressCancelled, y as ObservePageRequest, z as decodeReceipt } from "./CloudflareThreadClient-
|
|
1
|
+
import { A as boundHostDiagnostic, B as decodeSubmitRequest, C as SettlementReached, D as SubmitSucceeded, E as SubmitRequest, F as decodeCancelProgressRequest, G as encodeAwaitSettlementRequest, H as encodeAbortCommand, I as decodeHostResponse, J as encodeObservePageRequest, K as encodeCancelProgressRequest, L as decodeLiveText, M as decodeApprovalDecisionCommand, N as decodeAwaitProgressRequest, O as ThreadClientError, P as decodeAwaitSettlementRequest, Q as Frame, R as decodeObservePageRequest, S as ProgressObserved, T as SubmissionStatusResponse, U as encodeApprovalDecisionCommand, V as decodeUnknownResolutionCommand, W as encodeAwaitProgressRequest, X as encodeSubmitRequest, Y as encodeReceipt, Z as encodeUnknownResolutionCommand, _ as HostProtocolError, a as CancelProgressRequest, b as ObservedPage, c as ClientAwaitFailure, d as ClientSubmitFailure, f as ClientUnknownFailure, g as HostFailure, h as HostFailed, i as AwaitSettlementRequest, j as decodeAbortCommand, k as UnknownResolutionRecorded, l as ClientObserveFailure, n as ApprovalRecorded, o as ClientAbortFailure, p as CloudflareThreadClient, q as encodeHostResponse, r as AwaitProgressRequest, s as ClientApprovalFailure, t as AbortRecorded, u as ClientProgressFailure, v as HostResponse, w as SettlementRecordReached, x as ProgressCancelled, y as ObservePageRequest, z as decodeReceipt } from "./CloudflareThreadClient-DNsFhgVu.mjs";
|
|
2
2
|
export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, AwaitSettlementRequest, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, Frame as LiveTextFrame, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SettlementRecordReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeAwaitSettlementRequest, decodeCancelProgressRequest, decodeHostResponse, decodeLiveText, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeAwaitSettlementRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as decodeLiveText, B as encodeHostResponse, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, F as encodeAbortCommand, G as Frame, H as encodeReceipt, I as encodeApprovalDecisionCommand, L as encodeAwaitProgressRequest, M as decodeReceipt, N as decodeSubmitRequest, O as decodeCancelProgressRequest, P as decodeUnknownResolutionCommand, R as encodeAwaitSettlementRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, U as encodeSubmitRequest, V as encodeObservePageRequest, W as encodeUnknownResolutionCommand, _ as SettlementRecordReached, a as CancelProgressRequest, b as SubmitSucceeded, c as HostFailed, d as HostResponse, f as ObservePageRequest, g as SettlementReached, h as ProgressObserved, i as AwaitSettlementRequest, j as decodeObservePageRequest, k as decodeHostResponse, l as HostFailure, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, r as AwaitProgressRequest, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, x as ThreadClientError, y as SubmitRequest, z as encodeCancelProgressRequest } from "./CloudflareThreadClient-
|
|
1
|
+
import { A as decodeLiveText, B as encodeHostResponse, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, F as encodeAbortCommand, G as Frame, H as encodeReceipt, I as encodeApprovalDecisionCommand, L as encodeAwaitProgressRequest, M as decodeReceipt, N as decodeSubmitRequest, O as decodeCancelProgressRequest, P as decodeUnknownResolutionCommand, R as encodeAwaitSettlementRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, U as encodeSubmitRequest, V as encodeObservePageRequest, W as encodeUnknownResolutionCommand, _ as SettlementRecordReached, a as CancelProgressRequest, b as SubmitSucceeded, c as HostFailed, d as HostResponse, f as ObservePageRequest, g as SettlementReached, h as ProgressObserved, i as AwaitSettlementRequest, j as decodeObservePageRequest, k as decodeHostResponse, l as HostFailure, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, r as AwaitProgressRequest, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, x as ThreadClientError, y as SubmitRequest, z as encodeCancelProgressRequest } from "./CloudflareThreadClient-CnvMXPmV.mjs";
|
|
2
2
|
export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, AwaitSettlementRequest, CancelProgressRequest, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, Frame as LiveTextFrame, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SettlementRecordReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeAwaitSettlementRequest, decodeCancelProgressRequest, decodeHostResponse, decodeLiveText, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeAwaitSettlementRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurableAlarmError, DurableObjectContext, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement } from "./CloudflareBindings.mjs";
|
|
2
2
|
import { l as CloudflarePlatformConfigError, s as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded } from "./CloudflareConfig-C9MvPbX8.mjs";
|
|
3
3
|
import { DurableAlarmService, MaintenancePassFailure, ThreadMaintenance, ThreadMaintenanceAlarm, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMutationGate, ThreadPublication, ThreadRecoveryEvents } from "./Alarm.mjs";
|
|
4
|
-
import { E as SubmitRequest, _ as HostProtocolError } from "./CloudflareThreadClient-
|
|
4
|
+
import { $ as Observation, E as SubmitRequest, _ as HostProtocolError } from "./CloudflareThreadClient-DNsFhgVu.mjs";
|
|
5
5
|
import { AgentRegistration } from "@yielded/agent/agent-registration";
|
|
6
6
|
import { ApprovalSuspensionError, DurableAgentRuntime, DurableRuntimeConfig, RecoveryBlocked, RecoveryReport } from "@yielded/agent/durable-agent-runtime";
|
|
7
7
|
import { SubmissionId, ThreadId } from "@yielded/agent/identifiers";
|
|
@@ -30,7 +30,7 @@ import { SettlementPublisher } from "@yielded/agent/settlement-publisher";
|
|
|
30
30
|
import { ToolReconciler } from "@yielded/agent/tool-reconciler";
|
|
31
31
|
//#region src/internal/live-text.d.ts
|
|
32
32
|
declare const LiveTextHub_base: Context.ServiceClass<LiveTextHub, "@effect-agent/platform-cloudflare/LiveTextHub", {
|
|
33
|
-
readonly open: (threadId: ThreadId) => Effect.Effect<
|
|
33
|
+
readonly open: (threadId: ThreadId) => Effect.Effect<typeof Observation.Type, HostProtocolError>;
|
|
34
34
|
}>;
|
|
35
35
|
/** One Object incarnation; owns drafts and subscriptions independently of RPC event scopes. */
|
|
36
36
|
declare class LiveTextHub extends LiveTextHub_base {
|
|
@@ -379,4 +379,4 @@ interface Class<EventServices = never> {
|
|
|
379
379
|
declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never, AlarmServices = never, AlarmError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | ThreadMaintenanceAlarm | NoInfer<AlarmServices> | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError, AlarmServices, AlarmError>) => Class<ApplicationServices | EventServices | AlarmServices>;
|
|
380
380
|
//#endregion
|
|
381
381
|
export { ThreadHostMutation as A, make as C, CloudflareDurableRuntimeInitializationError as D, CloudflareBootstrapServices as E, layerHostConfig as F, layerInHost as I, ThreadPublicationOptions as M, layer$1 as N, CloudflareDurableRuntimeOptions as O, layerConfig as P, handleRpc as S, submit as T, decodeAdminResponse as _, AdminVerifyRequest as a, decodeRetryCommand as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminExplainRequest as g, alarms as h, AdminResponse as i, ThreadObjectPorts as j, CloudflareDurableRuntimeServices 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, decodeAdminVerifyRequest as v, portCall as w, encodeAdminResponse as x, decodeObligationThresholds as y };
|
|
382
|
-
//# sourceMappingURL=ThreadObject-
|
|
382
|
+
//# sourceMappingURL=ThreadObject-BVoyFKHN.d.mts.map
|