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

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,7 +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 } from "cloudflare:workers";
5
+ import { DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
6
+ import { CodeExecutor, SandboxImplementation } from "@effect-agent/sandbox";
7
+ import { DurableObject as DurableObject$1, WorkerEntrypoint } from "cloudflare:workers";
6
8
  //#region src/bindings.d.ts
7
9
  declare const CloudflareBindingError_base: Schema.Class<CloudflareBindingError, Schema.TaggedStruct<"CloudflareBindingError", {
8
10
  readonly binding: Schema.String;
@@ -616,6 +618,9 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
616
618
  readonly turn: number;
617
619
  readonly messages: Schema.Json;
618
620
  readonly messagesDigest: string;
621
+ readonly inputTokens?: number | undefined;
622
+ readonly outputTokens?: number | undefined;
623
+ readonly costMicrousd?: number | undefined;
619
624
  } | {
620
625
  readonly _tag: "ToolCallPrepared";
621
626
  readonly runId: string;
@@ -678,8 +683,10 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
678
683
  } | {
679
684
  readonly _tag: "CompactionCreated";
680
685
  readonly runId: string;
681
- readonly sourceDigest: string;
682
- readonly summary: string;
686
+ readonly turn: number;
687
+ readonly kind: "clear-tool-results" | "summarize";
688
+ readonly coversThrough: number;
689
+ readonly summary?: string | undefined;
683
690
  } | {
684
691
  readonly _tag: "RunFailed";
685
692
  readonly runId: string;
@@ -701,6 +708,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
701
708
  readonly outcome: "aborted" | "completed" | "failed";
702
709
  readonly runId?: string | undefined;
703
710
  readonly result?: Schema.Json | undefined;
711
+ readonly finishReason?: "budget-exhausted" | undefined;
704
712
  } | {
705
713
  readonly _tag: "SubagentRequested";
706
714
  readonly runId: string;
@@ -871,7 +879,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
871
879
  readonly attemptedEpoch: number;
872
880
  } | {
873
881
  readonly _tag: "DurableRuntimeFailpointError";
874
- 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";
875
883
  } | {
876
884
  readonly _tag: "AdmissionLimitExceeded";
877
885
  readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
@@ -924,7 +932,8 @@ declare class CloudflareConversationClient extends CloudflareConversationClient_
924
932
  //#endregion
925
933
  //#region src/conversation-object.d.ts
926
934
  /**
927
- * `makeConversationObjectClass(options)` — the Conversation Durable Object (plan §1.4,
935
+ * `makeConversationObjectClass(options, observability?)` — the Conversation Durable Object
936
+ * (plan §1.4,
928
937
  * D-P6-1): a factory returning a class that applications export from their Worker entry.
929
938
  * One SQLite-backed Object per Conversation is the serialized owner (durability §6); the
930
939
  * Object never runs `runResolvedWorker`'s infinite loop — each ingress event or alarm runs
@@ -1397,21 +1406,38 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1397
1406
  } | {
1398
1407
  readonly _tag: "AdminFailed";
1399
1408
  readonly failure: {
1400
- readonly _tag: "HostProtocolError";
1409
+ readonly _tag: "OperationDenied";
1410
+ readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1411
+ readonly reason: string;
1412
+ readonly conversationId?: string | undefined;
1413
+ readonly submissionId?: string | undefined;
1414
+ } | {
1415
+ readonly _tag: "RetryRefused";
1416
+ readonly submissionId: string;
1417
+ readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
1418
+ readonly decisionTag: string;
1419
+ readonly message: string;
1420
+ } | {
1421
+ readonly _tag: "LedgerError";
1422
+ readonly operation: string;
1423
+ readonly message: string;
1424
+ readonly cause?: Schema.Json | undefined;
1425
+ } | {
1426
+ readonly _tag: "RunJournalError";
1401
1427
  readonly message: string;
1428
+ readonly cause?: Schema.Json | undefined;
1402
1429
  } | {
1403
1430
  readonly _tag: "DigestError";
1404
1431
  readonly message: string;
1405
1432
  readonly cause?: Schema.Json | undefined;
1433
+ } | {
1434
+ readonly _tag: "OwnershipLost";
1435
+ readonly submissionId: string;
1436
+ readonly actualEpoch: number;
1406
1437
  } | {
1407
1438
  readonly _tag: "SettlementConflict";
1408
1439
  readonly submissionId: string;
1409
1440
  readonly existingOutcome: "aborted" | "completed" | "failed";
1410
- } | {
1411
- readonly _tag: "LedgerError";
1412
- readonly operation: string;
1413
- readonly message: string;
1414
- readonly cause?: Schema.Json | undefined;
1415
1441
  } | {
1416
1442
  readonly _tag: "ConversationStoreError";
1417
1443
  readonly operation: string;
@@ -1434,37 +1460,20 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1434
1460
  readonly attemptedEpoch: number;
1435
1461
  } | {
1436
1462
  readonly _tag: "DurableRuntimeFailpointError";
1437
- 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";
1438
1464
  } | {
1439
1465
  readonly _tag: "DurableAlarmError";
1440
1466
  readonly operation: string;
1441
1467
  readonly message: string;
1442
1468
  readonly cause?: Schema.Json | undefined;
1443
1469
  } | {
1444
- readonly _tag: "OperationDenied";
1445
- readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1446
- readonly reason: string;
1447
- readonly conversationId?: string | undefined;
1448
- readonly submissionId?: string | undefined;
1449
- } | {
1450
- readonly _tag: "RetryRefused";
1451
- readonly submissionId: string;
1452
- readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
1453
- readonly decisionTag: string;
1454
- readonly message: string;
1455
- } | {
1456
- readonly _tag: "RunJournalError";
1470
+ readonly _tag: "HostProtocolError";
1457
1471
  readonly message: string;
1458
- readonly cause?: Schema.Json | undefined;
1459
- } | {
1460
- readonly _tag: "OwnershipLost";
1461
- readonly submissionId: string;
1462
- readonly actualEpoch: number;
1463
1472
  };
1464
1473
  }, Schema.SchemaError, never>;
1465
1474
  declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
1466
1475
  /** The public endpoint surface of one Conversation Object instance. */
1467
- interface ConversationObjectInstance extends DurableObject {
1476
+ interface ConversationObjectInstance extends DurableObject$1 {
1468
1477
  submitEncoded(encoded: unknown): Promise<unknown>;
1469
1478
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1470
1479
  observePage(encoded: unknown): Promise<unknown>;
@@ -1477,19 +1486,63 @@ interface ConversationObjectInstance extends DurableObject {
1477
1486
  obligationsEncoded(encoded: unknown): Promise<unknown>;
1478
1487
  portCall(encoded: unknown): Promise<unknown>;
1479
1488
  wake(): Promise<void>;
1480
- alarm(): Promise<void>;
1489
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> | void;
1481
1490
  }
1482
1491
  /** The constructor shape workerd instantiates for each Conversation Object. */
1483
1492
  interface ConversationObjectClass {
1484
1493
  new (ctx: DurableObjectState, env: Cloudflare.Env): ConversationObjectInstance;
1485
1494
  }
1486
1495
  /**
1487
- * Build the application's Conversation Object class (export it from the
1488
- * Worker entry). The explicit return type is what makes declaration emit
1489
- * possible: the class body carries a private runtime field, and TS4094
1490
- * rejects inferring an exported anonymous class type around it.
1496
+ * Build the application's Conversation Object class (export it from the Worker entry).
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.
1501
+ */
1502
+ declare const makeConversationObjectClass: <EventLayerError = never, EventServices = never>(options: ConversationObjectOptions, observability?: Layer.Layer<EventServices, EventLayerError, DurableObjectContext | ConversationObjectNamespace | DurableObjectState$1.DurableObjectState | WorkerEnvironment>) => ConversationObjectClass;
1503
+ //#endregion
1504
+ //#region src/code-mode-executor.d.ts
1505
+ /**
1506
+ * The Cloudflare Dynamic Worker `CodeExecutor` adapter (C4 of ADR-0017;
1507
+ * DEPLOY-011). Each pass loads one fresh Worker through the Worker Loader
1508
+ * with `globalOutbound: null`, so generated code has no ambient network,
1509
+ * bindings, or secrets; its only authority is the pass-scoped host stub that
1510
+ * routes back to `CodeModeHostEntrypoint` and, from there, into the pass's
1511
+ * `CodeExecutionHost` service. Platform CPU limits stop synchronous runaway
1512
+ * programs; the executor-owned wall-clock deadline interrupts asynchronously
1513
+ * suspended passes. Deployment class `E` only: the adapter records no
1514
+ * persistent state and a later pass may run in a completely different
1515
+ * isolate.
1516
+ */
1517
+ declare const dynamicWorkerImplementation: SandboxImplementation;
1518
+ /** The narrow host stub the dynamic worker receives (Workers RPC). */
1519
+ interface CodeModeHostStub {
1520
+ readonly call: (passId: string, hostCall: unknown) => Promise<unknown>;
1521
+ }
1522
+ /**
1523
+ * The host-side RPC target for dynamic workers. The application exposes it
1524
+ * from its Worker entry (`export { CodeModeHostEntrypoint }`) and hands the
1525
+ * adapter a same-instance stub — `ctx.exports.CodeModeHostEntrypoint()` in
1526
+ * production (a self service binding may reach a different instance and must
1527
+ * not be used there); tests bind it through Miniflare's `kCurrentWorker`.
1491
1528
  */
1492
- declare const makeConversationObjectClass: (options: ConversationObjectOptions) => ConversationObjectClass;
1529
+ declare class CodeModeHostEntrypoint extends WorkerEntrypoint {
1530
+ call(passId: unknown, hostCall: unknown): Promise<unknown>;
1531
+ }
1532
+ interface DynamicWorkerCodeExecutorOptions {
1533
+ /** The `worker_loader` binding. */
1534
+ readonly loader: WorkerLoader;
1535
+ /**
1536
+ * A SAME-INSTANCE stub of `CodeModeHostEntrypoint`. In production create it
1537
+ * with `ctx.exports.CodeModeHostEntrypoint()`; a cross-instance stub would
1538
+ * dispatch host calls into an isolate without this pass's registry entry.
1539
+ */
1540
+ readonly hostStub: CodeModeHostStub;
1541
+ /** Compatibility date for dynamic workers; defaults to `2025-05-01`. */
1542
+ readonly compatibilityDate?: string | undefined;
1543
+ }
1544
+ /** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
1545
+ declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
1493
1546
  //#endregion
1494
- 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, 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 };
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 };
1495
1548
  //# sourceMappingURL=index.d.mts.map