@effect-agent/platform-cloudflare 0.0.1-beta.0 → 0.0.1-beta.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel van der Merwe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.mts CHANGED
@@ -373,25 +373,12 @@ interface CloudflareDurableRuntimeOptions {
373
373
  readonly toolReconciler?: Layer.Layer<ToolReconciler> | undefined;
374
374
  /**
375
375
  * Registered worker Bindings resolved at durable claim time (S2, spec/subagents.md §11):
376
- * build each with `DurableWorkerBinding.make(binding, digests)`. An Effect or callback form is
377
- * accepted because capture can be effectful. The callback receives the live Object context and
378
- * derived identities and is evaluated once per incarnation during Layer construction. Defaults
379
- * to the empty registration (every resolved claim fails closed).
376
+ * build each with `DurableWorkerBinding.make(binding, digests)`. An Effect form is accepted
377
+ * because the capture is effectful; it runs once per incarnation during Layer construction.
378
+ * Defaults to the empty registration (every resolved claim fails closed).
380
379
  */
381
- readonly bindings?: CloudflareBindingSource | undefined;
380
+ readonly bindings?: ReadonlyArray<ResolvedBinding> | Effect.Effect<ReadonlyArray<ResolvedBinding>> | undefined;
382
381
  }
383
- /** Per-incarnation host values available while registered worker Bindings are captured. */
384
- interface CloudflareBindingSourceContext {
385
- readonly ctx: DurableObjectState;
386
- readonly env: unknown;
387
- readonly conversationId: ConversationId;
388
- readonly producerId: ProducerId;
389
- }
390
- /**
391
- * Registered worker Bindings, or a closed Effect/callback that captures them once for each
392
- * Durable Object incarnation. Callback Effects cannot require services or fail typed.
393
- */
394
- type CloudflareBindingSource = ReadonlyArray<ResolvedBinding> | Effect.Effect<ReadonlyArray<ResolvedBinding>, never, never> | ((context: CloudflareBindingSourceContext) => ReadonlyArray<ResolvedBinding> | Effect.Effect<ReadonlyArray<ResolvedBinding>, never, never>);
395
382
  /** Every construction failure of the assembled Cloudflare durable runtime stack. */
396
383
  type CloudflareDurableRuntimeInitializationError = CloudflarePlatformConfigError | DoStorageInitializationError;
397
384
  /** The services `CloudflareDurableRuntime.layer` provides. */
@@ -592,41 +579,13 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
592
579
  readonly createdAt: string;
593
580
  readonly deploymentId: string;
594
581
  readonly payload: {
595
- readonly _tag: "ToolCallPrepared";
596
- readonly runId: string;
597
- readonly turnId: string;
598
- readonly turn: number;
599
- readonly toolCallId: string;
600
- readonly toolName: string;
601
- readonly parameters: Schema.Json;
602
- readonly parametersDigest: string;
603
- } | {
604
- readonly _tag: "ToolCallUnknown";
605
- readonly runId: string;
606
- readonly turn: number;
607
- readonly toolCallId: string;
608
- readonly toolName: string;
609
- readonly reason: string;
610
- } | {
611
- readonly _tag: "ToolApprovalDecided";
612
- readonly runId: string;
613
- readonly turn: number;
614
- readonly toolCallId: string;
615
- readonly decision: "approved" | "denied";
616
- readonly resolver: string;
617
- readonly reason: string;
618
- } | {
619
- readonly _tag: "ToolCallResolved";
582
+ readonly _tag: "SubagentStarted";
620
583
  readonly runId: string;
621
584
  readonly toolCallId: string;
622
- readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
623
- readonly author: string;
624
- readonly reason: string;
625
- } | {
626
- readonly _tag: "AbortRequested";
627
- readonly submissionId: string;
628
- readonly author: string;
629
- readonly reason: string;
585
+ readonly childConversationId: string;
586
+ readonly childSubmissionId: string;
587
+ readonly childReceiptId: string;
588
+ readonly childRunId: string;
630
589
  } | {
631
590
  readonly _tag: "ConversationCreated";
632
591
  readonly agentId: string;
@@ -652,6 +611,15 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
652
611
  readonly turn: number;
653
612
  readonly messages: Schema.Json;
654
613
  readonly messagesDigest: string;
614
+ } | {
615
+ readonly _tag: "ToolCallPrepared";
616
+ readonly runId: string;
617
+ readonly turnId: string;
618
+ readonly turn: number;
619
+ readonly toolCallId: string;
620
+ readonly toolName: string;
621
+ readonly parameters: Schema.Json;
622
+ readonly parametersDigest: string;
655
623
  } | {
656
624
  readonly _tag: "ToolCallSettled";
657
625
  readonly runId: string;
@@ -659,6 +627,20 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
659
627
  readonly toolName: string;
660
628
  readonly result: Schema.Json;
661
629
  readonly isFailure: boolean;
630
+ } | {
631
+ readonly _tag: "ToolCallUnknown";
632
+ readonly runId: string;
633
+ readonly turn: number;
634
+ readonly toolCallId: string;
635
+ readonly toolName: string;
636
+ readonly reason: string;
637
+ } | {
638
+ readonly _tag: "ToolCallResolved";
639
+ readonly runId: string;
640
+ readonly toolCallId: string;
641
+ readonly resolution: "completed-with-result" | "failed-with-error" | "never-started" | "safe-retry";
642
+ readonly author: string;
643
+ readonly reason: string;
662
644
  } | {
663
645
  readonly _tag: "ToolStepSettled";
664
646
  readonly runId: string;
@@ -674,6 +656,14 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
674
656
  readonly toolCallId: string;
675
657
  readonly toolName: string;
676
658
  readonly parametersDigest: string;
659
+ } | {
660
+ readonly _tag: "ToolApprovalDecided";
661
+ readonly runId: string;
662
+ readonly turn: number;
663
+ readonly toolCallId: string;
664
+ readonly decision: "approved" | "denied";
665
+ readonly resolver: string;
666
+ readonly reason: string;
677
667
  } | {
678
668
  readonly _tag: "ModelResponseInterrupted";
679
669
  readonly runId: string;
@@ -693,6 +683,11 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
693
683
  readonly _tag: "RunCompleted";
694
684
  readonly runId: string;
695
685
  readonly output: Schema.Json;
686
+ } | {
687
+ readonly _tag: "AbortRequested";
688
+ readonly submissionId: string;
689
+ readonly author: string;
690
+ readonly reason: string;
696
691
  } | {
697
692
  readonly _tag: "SubmissionSettled";
698
693
  readonly submissionId: string;
@@ -722,14 +717,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
722
717
  readonly childConversationId: string;
723
718
  readonly childPrincipal: string;
724
719
  readonly childIdempotencyKey: string;
725
- } | {
726
- readonly _tag: "SubagentStarted";
727
- readonly runId: string;
728
- readonly toolCallId: string;
729
- readonly childConversationId: string;
730
- readonly childSubmissionId: string;
731
- readonly childReceiptId: string;
732
- readonly childRunId: string;
733
720
  } | {
734
721
  readonly _tag: "SubagentJoined";
735
722
  readonly runId: string;
@@ -814,18 +801,41 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
814
801
  readonly _tag: "HostProtocolError";
815
802
  readonly message: string;
816
803
  } | {
817
- readonly _tag: "LedgerError";
818
- readonly operation: string;
804
+ readonly _tag: "AgentInputError";
819
805
  readonly message: string;
820
- readonly cause?: Schema.Json | undefined;
821
806
  } | {
822
807
  readonly _tag: "DigestError";
823
808
  readonly message: string;
824
809
  readonly cause?: Schema.Json | undefined;
810
+ } | {
811
+ readonly _tag: "AdmissionConflict";
812
+ readonly conversationId: string;
813
+ readonly principal: string;
814
+ readonly idempotencyKey: string;
815
+ readonly existingInputDigest: string;
816
+ readonly attemptedInputDigest: string;
825
817
  } | {
826
818
  readonly _tag: "SettlementConflict";
827
819
  readonly submissionId: string;
828
820
  readonly existingOutcome: "aborted" | "completed" | "failed";
821
+ } | {
822
+ readonly _tag: "ApprovalConflict";
823
+ readonly submissionId: string;
824
+ readonly toolCallId: string;
825
+ readonly existingDecision: "approved" | "denied";
826
+ } | {
827
+ readonly _tag: "UnknownResolutionConflict";
828
+ readonly submissionId: string;
829
+ readonly toolCallId: string;
830
+ } | {
831
+ readonly _tag: "JoinedToHost";
832
+ readonly submissionId: string;
833
+ readonly hostSubmissionId: string;
834
+ } | {
835
+ readonly _tag: "LedgerError";
836
+ readonly operation: string;
837
+ readonly message: string;
838
+ readonly cause?: Schema.Json | undefined;
829
839
  } | {
830
840
  readonly _tag: "ConversationStoreError";
831
841
  readonly operation: string;
@@ -849,39 +859,16 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
849
859
  } | {
850
860
  readonly _tag: "DurableRuntimeFailpointError";
851
861
  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";
852
- } | {
853
- readonly _tag: "DurableAlarmError";
854
- readonly operation: string;
855
- readonly message: string;
856
- readonly cause?: Schema.Json | undefined;
857
- } | {
858
- readonly _tag: "AgentInputError";
859
- readonly message: string;
860
- } | {
861
- readonly _tag: "AdmissionConflict";
862
- readonly conversationId: string;
863
- readonly principal: string;
864
- readonly idempotencyKey: string;
865
- readonly existingInputDigest: string;
866
- readonly attemptedInputDigest: string;
867
- } | {
868
- readonly _tag: "ApprovalConflict";
869
- readonly submissionId: string;
870
- readonly toolCallId: string;
871
- readonly existingDecision: "approved" | "denied";
872
- } | {
873
- readonly _tag: "UnknownResolutionConflict";
874
- readonly submissionId: string;
875
- readonly toolCallId: string;
876
- } | {
877
- readonly _tag: "JoinedToHost";
878
- readonly submissionId: string;
879
- readonly hostSubmissionId: string;
880
862
  } | {
881
863
  readonly _tag: "AdmissionLimitExceeded";
882
864
  readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
883
865
  readonly actual: number;
884
866
  readonly maximum: number;
867
+ } | {
868
+ readonly _tag: "DurableAlarmError";
869
+ readonly operation: string;
870
+ readonly message: string;
871
+ readonly cause?: Schema.Json | undefined;
885
872
  };
886
873
  }, Schema.SchemaError, never>;
887
874
  declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
@@ -948,22 +935,6 @@ interface ConversationObjectOptions extends CloudflareDurableRuntimeOptions {
948
935
  */
949
936
  readonly namespaceBinding: string;
950
937
  }
951
- /**
952
- * Public instance surface of the class returned by `makeConversationObjectClass`. It includes
953
- * the Worker/sibling RPC contract, the administrative RPC entry points, the platform alarm
954
- * handler, and the inherited Object context used by application subclasses.
955
- */
956
- interface ConversationObjectInstance extends DurableObject<Cloudflare.Env>, ConversationObjectRpc {
957
- explainEncoded(encoded: unknown): Promise<unknown>;
958
- verifyEncoded(encoded: unknown): Promise<unknown>;
959
- retryEncoded(encoded: unknown): Promise<unknown>;
960
- obligationsEncoded(encoded: unknown): Promise<unknown>;
961
- alarm(): Promise<void>;
962
- }
963
- /** Public constructor returned by `makeConversationObjectClass`. */
964
- interface ConversationObjectConstructor {
965
- new (ctx: DurableObjectState, env: Cloudflare.Env): ConversationObjectInstance;
966
- }
967
938
  declare const AdminExplainRequest_base: Schema.Class<AdminExplainRequest, Schema.Struct<{
968
939
  readonly submissionId: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "@effect-agent/core/SubmissionId">>;
969
940
  }>, {}>;
@@ -1415,39 +1386,19 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1415
1386
  readonly failure: {
1416
1387
  readonly _tag: "HostProtocolError";
1417
1388
  readonly message: string;
1418
- } | {
1419
- readonly _tag: "OperationDenied";
1420
- readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1421
- readonly reason: string;
1422
- readonly conversationId?: string | undefined;
1423
- readonly submissionId?: string | undefined;
1424
- } | {
1425
- readonly _tag: "RetryRefused";
1426
- readonly submissionId: string;
1427
- readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
1428
- readonly decisionTag: string;
1429
- readonly message: string;
1430
- } | {
1431
- readonly _tag: "LedgerError";
1432
- readonly operation: string;
1433
- readonly message: string;
1434
- readonly cause?: Schema.Json | undefined;
1435
- } | {
1436
- readonly _tag: "RunJournalError";
1437
- readonly message: string;
1438
- readonly cause?: Schema.Json | undefined;
1439
1389
  } | {
1440
1390
  readonly _tag: "DigestError";
1441
1391
  readonly message: string;
1442
1392
  readonly cause?: Schema.Json | undefined;
1443
- } | {
1444
- readonly _tag: "OwnershipLost";
1445
- readonly submissionId: string;
1446
- readonly actualEpoch: number;
1447
1393
  } | {
1448
1394
  readonly _tag: "SettlementConflict";
1449
1395
  readonly submissionId: string;
1450
1396
  readonly existingOutcome: "aborted" | "completed" | "failed";
1397
+ } | {
1398
+ readonly _tag: "LedgerError";
1399
+ readonly operation: string;
1400
+ readonly message: string;
1401
+ readonly cause?: Schema.Json | undefined;
1451
1402
  } | {
1452
1403
  readonly _tag: "ConversationStoreError";
1453
1404
  readonly operation: string;
@@ -1476,11 +1427,56 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1476
1427
  readonly operation: string;
1477
1428
  readonly message: string;
1478
1429
  readonly cause?: Schema.Json | undefined;
1430
+ } | {
1431
+ readonly _tag: "OperationDenied";
1432
+ readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1433
+ readonly reason: string;
1434
+ readonly conversationId?: string | undefined;
1435
+ readonly submissionId?: string | undefined;
1436
+ } | {
1437
+ readonly _tag: "RetryRefused";
1438
+ readonly submissionId: string;
1439
+ readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
1440
+ readonly decisionTag: string;
1441
+ readonly message: string;
1442
+ } | {
1443
+ readonly _tag: "RunJournalError";
1444
+ readonly message: string;
1445
+ readonly cause?: Schema.Json | undefined;
1446
+ } | {
1447
+ readonly _tag: "OwnershipLost";
1448
+ readonly submissionId: string;
1449
+ readonly actualEpoch: number;
1479
1450
  };
1480
1451
  }, Schema.SchemaError, never>;
1481
1452
  declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
1482
- /** Build the application's Conversation Object class (export it from the Worker entry). */
1483
- declare const makeConversationObjectClass: (options: ConversationObjectOptions) => ConversationObjectConstructor;
1453
+ /** The public endpoint surface of one Conversation Object instance. */
1454
+ interface ConversationObjectInstance extends DurableObject {
1455
+ submitEncoded(encoded: unknown): Promise<unknown>;
1456
+ awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1457
+ observePage(encoded: unknown): Promise<unknown>;
1458
+ abortEncoded(encoded: unknown): Promise<unknown>;
1459
+ resolveApprovalEncoded(encoded: unknown): Promise<unknown>;
1460
+ resolveUnknownEncoded(encoded: unknown): Promise<unknown>;
1461
+ explainEncoded(encoded: unknown): Promise<unknown>;
1462
+ verifyEncoded(encoded: unknown): Promise<unknown>;
1463
+ retryEncoded(encoded: unknown): Promise<unknown>;
1464
+ obligationsEncoded(encoded: unknown): Promise<unknown>;
1465
+ portCall(encoded: unknown): Promise<unknown>;
1466
+ wake(): Promise<void>;
1467
+ alarm(): Promise<void>;
1468
+ }
1469
+ /** The constructor shape workerd instantiates for each Conversation Object. */
1470
+ interface ConversationObjectClass {
1471
+ new (ctx: DurableObjectState, env: Cloudflare.Env): ConversationObjectInstance;
1472
+ }
1473
+ /**
1474
+ * Build the application's Conversation Object class (export it from the
1475
+ * Worker entry). The explicit return type is what makes declaration emit
1476
+ * possible: the class body carries a private runtime field, and TS4094
1477
+ * rejects inferring an exported anonymous class type around it.
1478
+ */
1479
+ declare const makeConversationObjectClass: (options: ConversationObjectOptions) => ConversationObjectClass;
1484
1480
  //#endregion
1485
- 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, ConversationClientError, ConversationMaintenance, ConversationObjectConstructor, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, 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, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1481
+ export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, ConversationClientError, ConversationMaintenance, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, 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, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1486
1482
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ import { DurableObject } from "cloudflare:workers";
13
13
  * per incarnation and everything downstream consumes the services.
14
14
  */
15
15
  /** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */
16
- var CloudflareBindingError = class extends Schema.TaggedError()("CloudflareBindingError", {
16
+ var CloudflareBindingError = class extends Schema.TaggedErrorClass()("CloudflareBindingError", {
17
17
  binding: Schema.String,
18
18
  message: Schema.String
19
19
  }) {};
@@ -76,7 +76,7 @@ var ConversationObjectIdentity = class extends Context.Service()("@effect-agent/
76
76
  const PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));
77
77
  const NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
78
78
  /** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */
79
- var CloudflarePlatformConfigError = class extends Schema.TaggedError()("CloudflarePlatformConfigError", {
79
+ var CloudflarePlatformConfigError = class extends Schema.TaggedErrorClass()("CloudflarePlatformConfigError", {
80
80
  message: Schema.String,
81
81
  cause: Schema.optionalKey(Schema.Defect())
82
82
  }) {};
@@ -88,7 +88,7 @@ var CloudflarePlatformConfigError = class extends Schema.TaggedError()("Cloudfla
88
88
  * Conversation Object's submit entry point before `DurableAgentRuntime.submit` runs, and
89
89
  * nothing was admitted or written.
90
90
  */
91
- var AdmissionLimitExceeded = class extends Schema.TaggedError()("AdmissionLimitExceeded", {
91
+ var AdmissionLimitExceeded = class extends Schema.TaggedErrorClass()("AdmissionLimitExceeded", {
92
92
  limit: Schema.Literals([
93
93
  "queue-depth",
94
94
  "input-bytes",
@@ -185,7 +185,7 @@ const CLOUDFLARE_RUNTIME_DEFAULTS = {
185
185
  * alarms are harmless by design: a pass over an all-settled lane simply deletes the slot.
186
186
  */
187
187
  /** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */
188
- var DurableAlarmError = class extends Schema.TaggedError()("DurableAlarmError", {
188
+ var DurableAlarmError = class extends Schema.TaggedErrorClass()("DurableAlarmError", {
189
189
  operation: Schema.String,
190
190
  message: Schema.String,
191
191
  cause: Schema.optionalKey(Schema.Defect())
@@ -351,7 +351,7 @@ var ConversationMaintenance = class ConversationMaintenance extends Context.Serv
351
351
  */
352
352
  const WAKE_BUFFER_CAPACITY = 1024;
353
353
  /** A remote wake stub call failed; always swallowed and logged (hints are droppable). */
354
- var RemoteWakeDropped = class extends Schema.TaggedError()("RemoteWakeDropped", {
354
+ var RemoteWakeDropped = class extends Schema.TaggedErrorClass()("RemoteWakeDropped", {
355
355
  conversationId: Schema.String,
356
356
  message: Schema.String,
357
357
  cause: Schema.optionalKey(Schema.Defect())
@@ -453,10 +453,7 @@ const conversationIdFromState = (ctx) => ctx.id.name === void 0 ? Effect.fail(Cl
453
453
  message: `The Durable Object name is not a valid ConversationId: ${error.message}`,
454
454
  cause: error
455
455
  })));
456
- const resolveBindings = (source, context) => source === void 0 ? Effect.succeed([]) : Effect.isEffect(source) ? source : typeof source === "function" ? Effect.suspend(() => {
457
- const bindings = source(context);
458
- return Effect.isEffect(bindings) ? bindings : Effect.succeed(bindings);
459
- }) : Effect.succeed(source);
456
+ const resolveBindings = (bindings) => bindings === void 0 ? Effect.succeed([]) : Effect.isEffect(bindings) ? bindings : Effect.succeed(bindings);
460
457
  /**
461
458
  * The DC Layer assembly (deployment §12: a Layer-assembly library, not an app entrypoint;
462
459
  * plan §1.4). `layer(options)` decodes the configuration, derives this Object's Conversation
@@ -477,7 +474,7 @@ const resolveBindings = (source, context) => source === void 0 ? Effect.succeed(
477
474
  var CloudflareDurableRuntime = class {
478
475
  static layer(options) {
479
476
  return Layer.unwrap(Effect.gen(function* () {
480
- const { ctx, env } = yield* DurableObjectContext;
477
+ const { ctx } = yield* DurableObjectContext;
481
478
  const config = yield* configFromOptions(options);
482
479
  const conversationId = yield* conversationIdFromState(ctx);
483
480
  const producerId = yield* decodeProducerId(`${config.producerPrefix}:${conversationId}`).pipe(Effect.mapError((error) => CloudflarePlatformConfigError.make({
@@ -518,12 +515,7 @@ var CloudflareDurableRuntime = class {
518
515
  }));
519
516
  const runtimeFailpointLayer = options.runtimeFailpoint === void 0 ? DurableRuntimeFailpoint.layer : Layer.succeed(DurableRuntimeFailpoint)({ hit: options.runtimeFailpoint(ctx) });
520
517
  const reconcilerLayer = options.toolReconciler ?? ToolReconciler.uncertain;
521
- const bindingResolverLayer = Layer.effect(AgentBindingResolver)(Effect.map(resolveBindings(options.bindings, {
522
- ctx,
523
- env,
524
- conversationId,
525
- producerId
526
- }), (bindings) => AgentBindingResolver.fromBindings(bindings)));
518
+ const bindingResolverLayer = Layer.effect(AgentBindingResolver)(Effect.map(resolveBindings(options.bindings), AgentBindingResolver.fromBindings));
527
519
  const base = Layer.mergeAll(identityLayer, cloudflareConfigLayer, DurableAlarmService.layer);
528
520
  const runtimeStack = DurableAgentRuntime.layer.pipe(Layer.provideMerge(routedPorts), Layer.provideMerge(cloudflareWakeSchedulerLayer), Layer.provideMerge(runtimeConfigLayer), Layer.provideMerge(bindingResolverLayer), Layer.provide(Layer.mergeAll(runtimeFailpointLayer, reconcilerLayer, BrowserCrypto.layer)), Layer.provideMerge(base));
529
521
  return Layer.mergeAll(runtimeStack, ConversationMaintenance.layer.pipe(Layer.provide(runtimeStack)), portsEndpointLayer);
@@ -549,9 +541,9 @@ const boundHostDiagnostic = (value) => value.length > MAX_HOST_DIAGNOSTIC_LENGTH
549
541
  * The envelope itself could not be honored: the Object could not decode the request, or a
550
542
  * response could not be encoded/decoded. Never carries operation semantics.
551
543
  */
552
- var HostProtocolError = class extends Schema.TaggedError()("HostProtocolError", { message: BoundedDiagnostic }) {};
544
+ var HostProtocolError = class extends Schema.TaggedErrorClass()("HostProtocolError", { message: BoundedDiagnostic }) {};
553
545
  /** The Worker-side stub call itself failed (RPC rejection, overload, eviction mid-call). */
554
- var ConversationClientError = class extends Schema.TaggedError()("ConversationClientError", {
546
+ var ConversationClientError = class extends Schema.TaggedErrorClass()("ConversationClientError", {
555
547
  conversationId: Schema.String,
556
548
  message: Schema.String,
557
549
  cause: Schema.optionalKey(Schema.Defect())
@@ -1016,7 +1008,12 @@ const alarmEndpoint = Effect.gen(function* () {
1016
1008
  const gateEndpoint = Effect.gen(function* () {
1017
1009
  yield* (yield* ConversationMaintenance).ensureAlarm;
1018
1010
  });
1019
- /** Build the application's Conversation Object class (export it from the Worker entry). */
1011
+ /**
1012
+ * Build the application's Conversation Object class (export it from the
1013
+ * Worker entry). The explicit return type is what makes declaration emit
1014
+ * possible: the class body carries a private runtime field, and TS4094
1015
+ * rejects inferring an exported anonymous class type around it.
1016
+ */
1020
1017
  const makeConversationObjectClass = (options) => {
1021
1018
  class ConversationObject extends DurableObject {
1022
1019
  #runtime;