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

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>;
@@ -655,6 +618,8 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
655
618
  readonly turn: number;
656
619
  readonly messages: Schema.Json;
657
620
  readonly messagesDigest: string;
621
+ readonly inputTokens?: number | undefined;
622
+ readonly outputTokens?: number | undefined;
658
623
  } | {
659
624
  readonly _tag: "ToolCallPrepared";
660
625
  readonly runId: string;
@@ -717,8 +682,10 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
717
682
  } | {
718
683
  readonly _tag: "CompactionCreated";
719
684
  readonly runId: string;
720
- readonly sourceDigest: string;
721
- readonly summary: string;
685
+ readonly turn: number;
686
+ readonly kind: "clear-tool-results" | "summarize";
687
+ readonly coversThrough: number;
688
+ readonly summary?: string | undefined;
722
689
  } | {
723
690
  readonly _tag: "RunFailed";
724
691
  readonly runId: string;
@@ -740,6 +707,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
740
707
  readonly outcome: "aborted" | "completed" | "failed";
741
708
  readonly runId?: string | undefined;
742
709
  readonly result?: Schema.Json | undefined;
710
+ readonly finishReason?: "budget-exhausted" | undefined;
743
711
  } | {
744
712
  readonly _tag: "SubagentRequested";
745
713
  readonly runId: string;
@@ -910,7 +878,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
910
878
  readonly attemptedEpoch: number;
911
879
  } | {
912
880
  readonly _tag: "DurableRuntimeFailpointError";
913
- readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "resolve:after-intent" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append";
881
+ readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "compaction:after-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "resolve:after-intent" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append";
914
882
  } | {
915
883
  readonly _tag: "AdmissionLimitExceeded";
916
884
  readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
@@ -963,7 +931,8 @@ declare class CloudflareConversationClient extends CloudflareConversationClient_
963
931
  //#endregion
964
932
  //#region src/conversation-object.d.ts
965
933
  /**
966
- * `makeConversationObjectClass(options, telemetry?)` — the Conversation Durable Object (plan §1.4,
934
+ * `makeConversationObjectClass(options, observability?)` — the Conversation Durable Object
935
+ * (plan §1.4,
967
936
  * D-P6-1): a factory returning a class that applications export from their Worker entry.
968
937
  * One SQLite-backed Object per Conversation is the serialized owner (durability §6); the
969
938
  * Object never runs `runResolvedWorker`'s infinite loop — each ingress event or alarm runs
@@ -1490,7 +1459,7 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1490
1459
  readonly attemptedEpoch: number;
1491
1460
  } | {
1492
1461
  readonly _tag: "DurableRuntimeFailpointError";
1493
- readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "resolve:after-intent" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append";
1462
+ readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "claim:after-claim" | "compaction:after-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "resolve:after-intent" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append";
1494
1463
  } | {
1495
1464
  readonly _tag: "DurableAlarmError";
1496
1465
  readonly operation: string;
@@ -1503,7 +1472,7 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1503
1472
  }, Schema.SchemaError, never>;
1504
1473
  declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
1505
1474
  /** The public endpoint surface of one Conversation Object instance. */
1506
- interface ConversationObjectInstance extends DurableObject {
1475
+ interface ConversationObjectInstance extends DurableObject$1 {
1507
1476
  submitEncoded(encoded: unknown): Promise<unknown>;
1508
1477
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1509
1478
  observePage(encoded: unknown): Promise<unknown>;
@@ -1516,7 +1485,7 @@ interface ConversationObjectInstance extends DurableObject {
1516
1485
  obligationsEncoded(encoded: unknown): Promise<unknown>;
1517
1486
  portCall(encoded: unknown): Promise<unknown>;
1518
1487
  wake(): Promise<void>;
1519
- alarm(): Promise<void>;
1488
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> | void;
1520
1489
  }
1521
1490
  /** The constructor shape workerd instantiates for each Conversation Object. */
1522
1491
  interface ConversationObjectClass {
@@ -1524,14 +1493,12 @@ interface ConversationObjectClass {
1524
1493
  }
1525
1494
  /**
1526
1495
  * 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.
1496
+ * effect-cf owns the cached ManagedRuntime, native RPC methods, event scopes, and post-handler
1497
+ * OTLP flush scheduling for RPC and alarm events. The optional outer Layer is built per native
1498
+ * event, so a host can install Tracer/Logger/Metric services and `OtlpExporter.Flusher` without
1499
+ * Effect Agent owning exporter lifecycle machinery.
1533
1500
  */
1534
- declare const makeConversationObjectClass: <TelemetryError = never, AdditionalTelemetryOutputs = never>(options: ConversationObjectOptions, telemetry?: Layer.Layer<CloudflareRuntimeTelemetry | AdditionalTelemetryOutputs, TelemetryError, DurableObjectContext | ConversationObjectNamespace>) => ConversationObjectClass;
1501
+ declare const makeConversationObjectClass: <EventLayerError = never, EventServices = never>(options: ConversationObjectOptions, observability?: Layer.Layer<EventServices, EventLayerError, DurableObjectContext | ConversationObjectNamespace | DurableObjectState$1.DurableObjectState | WorkerEnvironment>) => ConversationObjectClass;
1535
1502
  //#endregion
1536
1503
  //#region src/code-mode-executor.d.ts
1537
1504
  /**
@@ -1576,5 +1543,5 @@ interface DynamicWorkerCodeExecutorOptions {
1576
1543
  /** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
1577
1544
  declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
1578
1545
  //#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 };
1546
+ 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
1547
  //# sourceMappingURL=index.d.mts.map