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

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