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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,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;
@@ -701,6 +703,7 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
701
703
  readonly outcome: "aborted" | "completed" | "failed";
702
704
  readonly runId?: string | undefined;
703
705
  readonly result?: Schema.Json | undefined;
706
+ readonly finishReason?: "budget-exhausted" | undefined;
704
707
  } | {
705
708
  readonly _tag: "SubagentRequested";
706
709
  readonly runId: string;
@@ -924,7 +927,8 @@ declare class CloudflareConversationClient extends CloudflareConversationClient_
924
927
  //#endregion
925
928
  //#region src/conversation-object.d.ts
926
929
  /**
927
- * `makeConversationObjectClass(options)` — the Conversation Durable Object (plan §1.4,
930
+ * `makeConversationObjectClass(options, observability?)` — the Conversation Durable Object
931
+ * (plan §1.4,
928
932
  * D-P6-1): a factory returning a class that applications export from their Worker entry.
929
933
  * One SQLite-backed Object per Conversation is the serialized owner (durability §6); the
930
934
  * Object never runs `runResolvedWorker`'s infinite loop — each ingress event or alarm runs
@@ -1397,21 +1401,38 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1397
1401
  } | {
1398
1402
  readonly _tag: "AdminFailed";
1399
1403
  readonly failure: {
1400
- readonly _tag: "HostProtocolError";
1404
+ readonly _tag: "OperationDenied";
1405
+ readonly operation: "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
1406
+ readonly reason: string;
1407
+ readonly conversationId?: string | undefined;
1408
+ readonly submissionId?: string | undefined;
1409
+ } | {
1410
+ readonly _tag: "RetryRefused";
1411
+ readonly submissionId: string;
1412
+ readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
1413
+ readonly decisionTag: string;
1401
1414
  readonly message: string;
1415
+ } | {
1416
+ readonly _tag: "LedgerError";
1417
+ readonly operation: string;
1418
+ readonly message: string;
1419
+ readonly cause?: Schema.Json | undefined;
1420
+ } | {
1421
+ readonly _tag: "RunJournalError";
1422
+ readonly message: string;
1423
+ readonly cause?: Schema.Json | undefined;
1402
1424
  } | {
1403
1425
  readonly _tag: "DigestError";
1404
1426
  readonly message: string;
1405
1427
  readonly cause?: Schema.Json | undefined;
1428
+ } | {
1429
+ readonly _tag: "OwnershipLost";
1430
+ readonly submissionId: string;
1431
+ readonly actualEpoch: number;
1406
1432
  } | {
1407
1433
  readonly _tag: "SettlementConflict";
1408
1434
  readonly submissionId: string;
1409
1435
  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
1436
  } | {
1416
1437
  readonly _tag: "ConversationStoreError";
1417
1438
  readonly operation: string;
@@ -1441,30 +1462,13 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
1441
1462
  readonly message: string;
1442
1463
  readonly cause?: Schema.Json | undefined;
1443
1464
  } | {
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";
1465
+ readonly _tag: "HostProtocolError";
1457
1466
  readonly message: string;
1458
- readonly cause?: Schema.Json | undefined;
1459
- } | {
1460
- readonly _tag: "OwnershipLost";
1461
- readonly submissionId: string;
1462
- readonly actualEpoch: number;
1463
1467
  };
1464
1468
  }, Schema.SchemaError, never>;
1465
1469
  declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
1466
1470
  /** The public endpoint surface of one Conversation Object instance. */
1467
- interface ConversationObjectInstance extends DurableObject {
1471
+ interface ConversationObjectInstance extends DurableObject$1 {
1468
1472
  submitEncoded(encoded: unknown): Promise<unknown>;
1469
1473
  awaitSettlementEncoded(encoded: unknown): Promise<unknown>;
1470
1474
  observePage(encoded: unknown): Promise<unknown>;
@@ -1477,19 +1481,63 @@ interface ConversationObjectInstance extends DurableObject {
1477
1481
  obligationsEncoded(encoded: unknown): Promise<unknown>;
1478
1482
  portCall(encoded: unknown): Promise<unknown>;
1479
1483
  wake(): Promise<void>;
1480
- alarm(): Promise<void>;
1484
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> | void;
1481
1485
  }
1482
1486
  /** The constructor shape workerd instantiates for each Conversation Object. */
1483
1487
  interface ConversationObjectClass {
1484
1488
  new (ctx: DurableObjectState, env: Cloudflare.Env): ConversationObjectInstance;
1485
1489
  }
1486
1490
  /**
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.
1491
+ * Build the application's Conversation Object class (export it from the Worker entry).
1492
+ * effect-cf owns the cached ManagedRuntime, native RPC methods, event scopes, and post-handler
1493
+ * OTLP flush scheduling for RPC and alarm events. The optional outer Layer is built per native
1494
+ * event, so a host can install Tracer/Logger/Metric services and `OtlpExporter.Flusher` without
1495
+ * Effect Agent owning exporter lifecycle machinery.
1496
+ */
1497
+ declare const makeConversationObjectClass: <EventLayerError = never, EventServices = never>(options: ConversationObjectOptions, observability?: Layer.Layer<EventServices, EventLayerError, DurableObjectContext | ConversationObjectNamespace | DurableObjectState$1.DurableObjectState | WorkerEnvironment>) => ConversationObjectClass;
1498
+ //#endregion
1499
+ //#region src/code-mode-executor.d.ts
1500
+ /**
1501
+ * The Cloudflare Dynamic Worker `CodeExecutor` adapter (C4 of ADR-0017;
1502
+ * DEPLOY-011). Each pass loads one fresh Worker through the Worker Loader
1503
+ * with `globalOutbound: null`, so generated code has no ambient network,
1504
+ * bindings, or secrets; its only authority is the pass-scoped host stub that
1505
+ * routes back to `CodeModeHostEntrypoint` and, from there, into the pass's
1506
+ * `CodeExecutionHost` service. Platform CPU limits stop synchronous runaway
1507
+ * programs; the executor-owned wall-clock deadline interrupts asynchronously
1508
+ * suspended passes. Deployment class `E` only: the adapter records no
1509
+ * persistent state and a later pass may run in a completely different
1510
+ * isolate.
1511
+ */
1512
+ declare const dynamicWorkerImplementation: SandboxImplementation;
1513
+ /** The narrow host stub the dynamic worker receives (Workers RPC). */
1514
+ interface CodeModeHostStub {
1515
+ readonly call: (passId: string, hostCall: unknown) => Promise<unknown>;
1516
+ }
1517
+ /**
1518
+ * The host-side RPC target for dynamic workers. The application exposes it
1519
+ * from its Worker entry (`export { CodeModeHostEntrypoint }`) and hands the
1520
+ * adapter a same-instance stub — `ctx.exports.CodeModeHostEntrypoint()` in
1521
+ * production (a self service binding may reach a different instance and must
1522
+ * not be used there); tests bind it through Miniflare's `kCurrentWorker`.
1491
1523
  */
1492
- declare const makeConversationObjectClass: (options: ConversationObjectOptions) => ConversationObjectClass;
1524
+ declare class CodeModeHostEntrypoint extends WorkerEntrypoint {
1525
+ call(passId: unknown, hostCall: unknown): Promise<unknown>;
1526
+ }
1527
+ interface DynamicWorkerCodeExecutorOptions {
1528
+ /** The `worker_loader` binding. */
1529
+ readonly loader: WorkerLoader;
1530
+ /**
1531
+ * A SAME-INSTANCE stub of `CodeModeHostEntrypoint`. In production create it
1532
+ * with `ctx.exports.CodeModeHostEntrypoint()`; a cross-instance stub would
1533
+ * dispatch host calls into an isolate without this pass's registry entry.
1534
+ */
1535
+ readonly hostStub: CodeModeHostStub;
1536
+ /** Compatibility date for dynamic workers; defaults to `2025-05-01`. */
1537
+ readonly compatibilityDate?: string | undefined;
1538
+ }
1539
+ /** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
1540
+ declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
1493
1541
  //#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 };
1542
+ export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CodeModeHostEntrypoint, CodeModeHostStub, ConversationClientError, ConversationMaintenance, ConversationObjectClass, ConversationObjectIdentity, ConversationObjectInstance, ConversationObjectNamespace, ConversationObjectOptions, ConversationObjectPorts, ConversationObjectRpc, DEFAULT_MAX_DATABASE_BYTES, DurableAlarmError, DurableAlarmService, DurableObjectContext, DynamicWorkerCodeExecutorOptions, ExplainedRecovery, HostFailed, HostFailure, HostProtocolError, HostResponse, MaintenancePassFailure, MaintenancePassReport, ObligationsScanned, ObservePageRequest, ObservedPage, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
1495
1543
  //# sourceMappingURL=index.d.mts.map