@effect-agent/platform-cloudflare 0.0.1-beta.6 → 0.1.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,8 +2,9 @@ import { Context, Effect, Layer, Option, Schema } from "effect";
2
2
  import { AbortCommand, AbortIntent, AdmissionConflict, AgentBindingResolver, AppendConflict, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, CanonicalRecordEnvelope, CanonicalSequence, ConversationNotMaterialized, ConversationStore, ConversationStoreError, DefinitionDigests, DigestError, DurableAgentRuntime, DurableBindingFailure, DurableRuntimeConfig, DurableRuntimeFailpointError, DurableRuntimeFailpointHandler, DurableSubmitAgent, DurableSubmitOptions, DurableWorkerFailure, FenceRejected, IntegrityReport, JoinedToHost, LedgerError, ObligationReport, ObligationThresholds, OperationDenied, OwnershipLost, ProducerId, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, RetryRefused, RunJournalError, Settlement, SettlementConflict, SubmissionLedger, ToolReconciler, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WakeScheduler } from "@effect-agent/session";
3
3
  import { ConversationPortTransport, DoStorageFailpointHandler, DoStorageInitializationError } from "@effect-agent/storage-cloudflare";
4
4
  import { AgentInputError, ConversationId } from "@effect-agent/core";
5
- import { DurableObject, WorkerEntrypoint } from "cloudflare:workers";
5
+ import { DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
6
6
  import { CodeExecutor, SandboxImplementation } from "@effect-agent/sandbox";
7
+ import { DurableObject as DurableObject$1, WorkerEntrypoint } from "cloudflare:workers";
7
8
  //#region src/bindings.d.ts
8
9
  declare const CloudflareBindingError_base: Schema.Class<CloudflareBindingError, Schema.TaggedStruct<"CloudflareBindingError", {
9
10
  readonly binding: Schema.String;
@@ -149,8 +150,6 @@ declare const CloudflareDurableRuntimeConfigValue_base: Schema.Class<CloudflareD
149
150
  readonly abortPollInterval: Schema.Int;
150
151
  /** Canonical observation poll cadence of the Durable Object store. */
151
152
  readonly observationPollInterval: Schema.Int;
152
- /** Cooperative background-export budget; native Object delivery never awaits the flush. */
153
- readonly telemetryFlushTimeout: Schema.Int;
154
153
  /** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */
155
154
  readonly maxStoredValueBytes: Schema.Int;
156
155
  /** Opt-in full payload/digest-chain audit while opening the store. */
@@ -177,7 +176,6 @@ declare const CLOUDFLARE_RUNTIME_DEFAULTS: {
177
176
  readonly leaseRenewalInterval: 10000;
178
177
  readonly abortPollInterval: 500;
179
178
  readonly observationPollInterval: 25;
180
- readonly telemetryFlushTimeout: 2000;
181
179
  readonly maxStoredValueBytes: 1900000;
182
180
  readonly verifyOnOpen: false;
183
181
  readonly maxQueueDepthPerLane: 256;
@@ -324,36 +322,6 @@ declare const cloudflareWakeSchedulerLayer: Layer.Layer<WakeScheduler, never, Du
324
322
  */
325
323
  declare const conversationPortTransportLayer: Layer.Layer<ConversationPortTransport, never, ConversationObjectNamespace>;
326
324
  //#endregion
327
- //#region src/telemetry.d.ts
328
- declare const CloudflareTelemetryExportError_base: Schema.Class<CloudflareTelemetryExportError, Schema.TaggedStruct<"CloudflareTelemetryExportError", {
329
- /** The original exporter failure, retained for host-side diagnostics. */
330
- readonly cause: Schema.Defect;
331
- }>, import("effect/Cause").YieldableError>;
332
- /** A host exporter failed during one coalesced background export attempt. */
333
- declare class CloudflareTelemetryExportError extends CloudflareTelemetryExportError_base {}
334
- declare const CloudflareRuntimeTelemetry_base: Context.ServiceClass<CloudflareRuntimeTelemetry, "@effect-agent/platform-cloudflare/CloudflareRuntimeTelemetry", {
335
- readonly flush: Effect.Effect<void, CloudflareTelemetryExportError>;
336
- }>;
337
- /**
338
- * Host-owned exporter lifecycle for one Cloudflare Conversation Object incarnation.
339
- *
340
- * The platform package creates measurements but deliberately does not select an exporter or
341
- * vendor. Native entrypoint instrumentation consumes this service at the Worker composition edge;
342
- * applications pass its provider as the second `makeConversationObjectClass` argument together
343
- * with their Effect Logger, Tracer, and Metric layers. That provider may read `DurableObjectContext` or
344
- * `ConversationObjectNamespace`, and its typed acquisition error remains visible in construction.
345
- * `flush` must attempt to export every configured signal. After the native span closes, the
346
- * Conversation Object reserves it into a shared post-settlement batch before `ctx.waitUntil` under
347
- * a cooperative timeout. Only each pending/trailing/queued batch's first owner registers its
348
- * shared Promise. Cycles remain capped at one first exporter attempt plus at most one trailing
349
- * attempt, with one queued cycle while trailing runs; exporter completion never holds endpoint
350
- * delivery open and exporter failure never replaces endpoint behavior.
351
- */
352
- declare class CloudflareRuntimeTelemetry extends CloudflareRuntimeTelemetry_base {
353
- /** Content-free default selected by `makeConversationObjectClass` when no host Layer is passed. */
354
- static readonly layerNoop: Layer.Layer<CloudflareRuntimeTelemetry, never, never>;
355
- }
356
- //#endregion
357
325
  //#region src/layers.d.ts
358
326
  /**
359
327
  * Raw (unvalidated) construction options for `CloudflareDurableRuntime.layer`, mirroring
@@ -381,11 +349,6 @@ interface CloudflareDurableRuntimeOptions {
381
349
  readonly abortPollInterval?: number | undefined;
382
350
  /** Milliseconds; default 25. */
383
351
  readonly observationPollInterval?: number | undefined;
384
- /**
385
- * Milliseconds; default 2000. Cooperative budget for the background exporter flush registered
386
- * after each native RPC, wake, or alarm span. Delivery never awaits the flush.
387
- */
388
- readonly telemetryFlushTimeout?: number | undefined;
389
352
  /** Bytes; default just under the 2 MB platform value limit. */
390
353
  readonly maxStoredValueBytes?: number | undefined;
391
354
  /** Default false. */
@@ -458,9 +421,9 @@ declare class ConversationObjectPorts extends ConversationObjectPorts_base {}
458
421
  * Storage compatibility is verified during construction: an incompatible database fails the
459
422
  * Layer typed (`DoStorageCompatibilityError`) before anything is mutated (DEPLOY-008).
460
423
  *
461
- * Requires the two binding services (`DurableObjectContext`, `ConversationObjectNamespace`).
462
- * Host observability belongs to the Worker composition edge because native entrypoint lifecycle
463
- * instrumentation, rather than this durable runtime assembly, consumes it (DEPLOY-010).
424
+ * Requires only the two binding services (`DurableObjectContext`,
425
+ * `ConversationObjectNamespace`) platform values enter exclusively through Layers
426
+ * (DEPLOY-010).
464
427
  */
465
428
  declare class CloudflareDurableRuntime {
466
429
  static layer(options: CloudflareDurableRuntimeOptions): Layer.Layer<CloudflareDurableRuntimeServices, CloudflareDurableRuntimeInitializationError, DurableObjectContext | ConversationObjectNamespace>;
@@ -740,6 +703,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
740
703
  readonly outcome: "aborted" | "completed" | "failed";
741
704
  readonly runId?: string | undefined;
742
705
  readonly result?: Schema.Json | undefined;
706
+ readonly finishReason?: "budget-exhausted" | undefined;
743
707
  } | {
744
708
  readonly _tag: "SubagentRequested";
745
709
  readonly runId: string;
@@ -963,7 +927,8 @@ declare class CloudflareConversationClient extends CloudflareConversationClient_
963
927
  //#endregion
964
928
  //#region src/conversation-object.d.ts
965
929
  /**
966
- * `makeConversationObjectClass(options, telemetry?)` — the Conversation Durable Object (plan §1.4,
930
+ * `makeConversationObjectClass(options, observability?)` — the Conversation Durable Object
931
+ * (plan §1.4,
967
932
  * D-P6-1): a factory returning a class that applications export from their Worker entry.
968
933
  * One SQLite-backed Object per Conversation is the serialized owner (durability §6); the
969
934
  * Object never runs `runResolvedWorker`'s infinite loop — each ingress event or alarm runs
@@ -1503,7 +1468,7 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1503
1468
  }, Schema.SchemaError, never>;
1504
1469
  declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
1505
1470
  /** The public endpoint surface of one Conversation Object instance. */
1506
- interface ConversationObjectInstance extends DurableObject {
1471
+ interface ConversationObjectInstance extends DurableObject$1 {
1507
1472
  submitEncoded(encoded: unknown): Promise<unknown>;
1508
1473
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1509
1474
  observePage(encoded: unknown): Promise<unknown>;
@@ -1516,7 +1481,7 @@ interface ConversationObjectInstance extends DurableObject {
1516
1481
  obligationsEncoded(encoded: unknown): Promise<unknown>;
1517
1482
  portCall(encoded: unknown): Promise<unknown>;
1518
1483
  wake(): Promise<void>;
1519
- alarm(): Promise<void>;
1484
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> | void;
1520
1485
  }
1521
1486
  /** The constructor shape workerd instantiates for each Conversation Object. */
1522
1487
  interface ConversationObjectClass {
@@ -1524,14 +1489,12 @@ interface ConversationObjectClass {
1524
1489
  }
1525
1490
  /**
1526
1491
  * Build the application's Conversation Object class (export it from the Worker entry).
1527
- * `telemetry` is the host composition boundary: it may require the Object context/namespace and
1528
- * retain a typed acquisition error, while any additional output services remain available to the
1529
- * cached runtime. `TelemetryError` stays the first explicit generic for source compatibility;
1530
- * additional outputs infer from the Layer. Omitting it installs the content-free no-op service.
1531
- * The explicit return type is what makes declaration emit possible: the class body carries a
1532
- * private runtime field, and TS4094 rejects inferring an exported anonymous class type around it.
1492
+ * effect-cf owns the cached ManagedRuntime, native RPC methods, event scopes, and post-handler
1493
+ * OTLP flush scheduling for RPC and alarm events. The optional outer Layer is built per native
1494
+ * event, so a host can install Tracer/Logger/Metric services and `OtlpExporter.Flusher` without
1495
+ * Effect Agent owning exporter lifecycle machinery.
1533
1496
  */
1534
- declare const makeConversationObjectClass: <TelemetryError = never, AdditionalTelemetryOutputs = never>(options: ConversationObjectOptions, telemetry?: Layer.Layer<CloudflareRuntimeTelemetry | AdditionalTelemetryOutputs, TelemetryError, DurableObjectContext | ConversationObjectNamespace>) => ConversationObjectClass;
1497
+ declare const makeConversationObjectClass: <EventLayerError = never, EventServices = never>(options: ConversationObjectOptions, observability?: Layer.Layer<EventServices, EventLayerError, DurableObjectContext | ConversationObjectNamespace | DurableObjectState$1.DurableObjectState | WorkerEnvironment>) => ConversationObjectClass;
1535
1498
  //#endregion
1536
1499
  //#region src/code-mode-executor.d.ts
1537
1500
  /**
@@ -1576,5 +1539,5 @@ interface DynamicWorkerCodeExecutorOptions {
1576
1539
  /** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
1577
1540
  declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
1578
1541
  //#endregion
1579
- export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CloudflareRuntimeTelemetry, CloudflareTelemetryExportError, CodeModeHostEntrypoint, CodeModeHostStub, ConversationClientError, ConversationMaintenance, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, DynamicWorkerCodeExecutorOptions, ExplainedRecovery, HostFailed, HostFailure, HostProtocolError, HostResponse, MaintenancePassFailure, MaintenancePassReport, ObligationsScanned, ObservePageRequest, ObservedPage, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1542
+ export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CodeModeHostEntrypoint, CodeModeHostStub, ConversationClientError, ConversationMaintenance, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, DynamicWorkerCodeExecutorOptions, ExplainedRecovery, HostFailed, HostFailure, HostProtocolError, HostResponse, MaintenancePassFailure, MaintenancePassReport, ObligationsScanned, ObservePageRequest, ObservedPage, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1580
1543
  //# sourceMappingURL=index.d.mts.map