@effect-agent/platform-cloudflare 0.1.0-beta.24 → 0.1.0-beta.26
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 +43 -60
- package/dist/index.mjs +259 -216
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/alarm.ts +2 -1
- package/src/bindings.ts +31 -30
- package/src/boundary.ts +51 -0
- package/src/client.ts +86 -187
- package/src/code-mode-executor.ts +130 -115
- package/src/conversation-object.ts +46 -20
- package/src/layers.ts +17 -33
- package/src/wake-scheduler.ts +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Context, Crypto, Effect, Layer, Option, Schema, Scope } 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, OperationAuthorizerService, OperationDenied, OwnershipLost, ProducerId, Receipt, RecoveryExplanation, RecoveryReport, ResolvedBinding, RetryCommand, RetryRefused, RunJournalError, Settlement, SettlementConflict, SubmissionLedger, ToolReconciler, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent, WakeScheduler } from "@effect-agent/session";
|
|
3
|
-
import { ConversationPortTransport, DoStorageFailpointHandler, DoStorageInitializationError } from "@effect-agent/storage-cloudflare";
|
|
3
|
+
import { ConversationPortTransport, DoStorageFailpointHandler, DoStorageInitializationError, PortRequest, PortResponse } from "@effect-agent/storage-cloudflare";
|
|
4
4
|
import { AgentInputError, ConversationId } from "@effect-agent/core";
|
|
5
5
|
import { RunContextPreparation } from "@effect-agent/engine";
|
|
6
6
|
import { DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
|
|
7
7
|
import { CodeExecutor, SandboxImplementation } from "@effect-agent/sandbox";
|
|
8
|
-
import { DurableObject as DurableObject$1
|
|
8
|
+
import { DurableObject as DurableObject$1 } from "cloudflare:workers";
|
|
9
9
|
//#region src/bindings.d.ts
|
|
10
10
|
declare const CloudflareBindingError_base: Schema.Class<CloudflareBindingError, Schema.TaggedStruct<"CloudflareBindingError", {
|
|
11
11
|
readonly binding: Schema.String;
|
|
@@ -66,7 +66,7 @@ declare class ConversationObjectNamespace extends ConversationObjectNamespace_ba
|
|
|
66
66
|
* narrowest-boundary check (structural probe for the namespace surface the transport uses);
|
|
67
67
|
* a missing or misshaped binding fails typed before any Layer is built.
|
|
68
68
|
*/
|
|
69
|
-
declare const conversationNamespaceFromEnv: (env: unknown, binding: string) => Effect.Effect<DurableObjectNamespace<ConversationObjectRpc>, CloudflareBindingError>;
|
|
69
|
+
declare const conversationNamespaceFromEnv: (env: unknown, binding: string) => Effect.Effect<DurableObjectNamespace<ConversationObjectRpc>, CloudflareBindingError, never>;
|
|
70
70
|
/** `ConversationObjectNamespace` built from the untyped Worker `env` (fails typed). */
|
|
71
71
|
declare const conversationNamespaceLayer: (env: unknown, binding: string) => Layer.Layer<ConversationObjectNamespace, CloudflareBindingError>;
|
|
72
72
|
declare const DurableObjectContext_base: Context.ServiceClass<DurableObjectContext, "@effect-agent/platform-cloudflare/DurableObjectContext", {
|
|
@@ -401,10 +401,9 @@ interface CloudflareDurableRuntimeOptions {
|
|
|
401
401
|
readonly toolReconciler?: Layer.Layer<ToolReconciler> | undefined;
|
|
402
402
|
/**
|
|
403
403
|
* Registered worker Bindings resolved at durable claim time (S2, spec/subagents.md §11):
|
|
404
|
-
* build each with `DurableWorkerBinding.make(binding, digests)`.
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
* to the empty registration (every resolved claim fails closed).
|
|
404
|
+
* build each with `DurableWorkerBinding.make(binding, digests)`. The callback receives the live
|
|
405
|
+
* Object context and derived identities and is evaluated once per incarnation during Layer
|
|
406
|
+
* construction. Defaults to the empty registration (every resolved claim fails closed).
|
|
408
407
|
*/
|
|
409
408
|
readonly bindings?: CloudflareBindingSource | undefined;
|
|
410
409
|
/**
|
|
@@ -425,11 +424,8 @@ interface CloudflareRuntimeSourceContext {
|
|
|
425
424
|
}
|
|
426
425
|
/** Per-incarnation host values available while registered worker Bindings are captured. */
|
|
427
426
|
interface CloudflareBindingSourceContext extends CloudflareRuntimeSourceContext {}
|
|
428
|
-
/**
|
|
429
|
-
|
|
430
|
-
* Durable Object incarnation. Callback Effects cannot require services or fail typed.
|
|
431
|
-
*/
|
|
432
|
-
type CloudflareBindingSource = ReadonlyArray<ResolvedBinding> | Effect.Effect<ReadonlyArray<ResolvedBinding>, never, never> | ((context: CloudflareBindingSourceContext) => ReadonlyArray<ResolvedBinding> | Effect.Effect<ReadonlyArray<ResolvedBinding>, never, never>);
|
|
427
|
+
/** Captures registered worker Bindings once for each Durable Object incarnation. */
|
|
428
|
+
type CloudflareBindingSource = (context: CloudflareBindingSourceContext) => Effect.Effect<ReadonlyArray<ResolvedBinding>, never, never>;
|
|
433
429
|
/** A closed Run-context service whose only remaining requirement is platform Crypto. */
|
|
434
430
|
type CloudflareRunContextLayer = Layer.Layer<RunContextPreparation, never, Crypto.Crypto>;
|
|
435
431
|
/** One Layer or a per-incarnation factory over explicit Cloudflare host values. */
|
|
@@ -439,13 +435,13 @@ type CloudflareDurableRuntimeInitializationError = CloudflarePlatformConfigError
|
|
|
439
435
|
/** The services `CloudflareDurableRuntime.layer` provides. */
|
|
440
436
|
type CloudflareDurableRuntimeServices = DurableAgentRuntime | SubmissionLedger | ConversationStore | WakeScheduler | DurableRuntimeConfig | AgentBindingResolver | CloudflareDurableRuntimeConfig | ConversationObjectIdentity | DurableAlarmService | ConversationMaintenance | ConversationObjectPorts | ProgressWaitRegistry;
|
|
441
437
|
declare const ConversationObjectPorts_base: Context.ServiceClass<ConversationObjectPorts, "@effect-agent/platform-cloudflare/ConversationObjectPorts", {
|
|
442
|
-
readonly handle: (
|
|
438
|
+
readonly handle: (request: PortRequest) => Effect.Effect<PortResponse>;
|
|
443
439
|
}>;
|
|
444
440
|
/**
|
|
445
|
-
* Owner-side
|
|
446
|
-
*
|
|
447
|
-
* request cannot bounce between Objects — and
|
|
448
|
-
*
|
|
441
|
+
* Owner-side execution port for a `portCall` request the wire endpoint has already decoded.
|
|
442
|
+
* It executes against THIS Object's LOCAL port facets — never the routed decorators, so a
|
|
443
|
+
* request cannot bounce between Objects — and returns the typed response for the endpoint to
|
|
444
|
+
* encode.
|
|
449
445
|
*/
|
|
450
446
|
declare class ConversationObjectPorts extends ConversationObjectPorts_base {}
|
|
451
447
|
/**
|
|
@@ -668,14 +664,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
668
664
|
readonly createdAt: string;
|
|
669
665
|
readonly deploymentId: string;
|
|
670
666
|
readonly payload: {
|
|
671
|
-
readonly _tag: "SubagentStarted";
|
|
672
|
-
readonly runId: string;
|
|
673
|
-
readonly toolCallId: string;
|
|
674
|
-
readonly childConversationId: string;
|
|
675
|
-
readonly childSubmissionId: string;
|
|
676
|
-
readonly childReceiptId: string;
|
|
677
|
-
readonly childRunId: string;
|
|
678
|
-
} | {
|
|
679
667
|
readonly _tag: "ConversationCreated";
|
|
680
668
|
readonly agentId: string;
|
|
681
669
|
readonly definitions: {
|
|
@@ -815,6 +803,14 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
815
803
|
readonly childConversationId: string;
|
|
816
804
|
readonly childPrincipal: string;
|
|
817
805
|
readonly childIdempotencyKey: string;
|
|
806
|
+
} | {
|
|
807
|
+
readonly _tag: "SubagentStarted";
|
|
808
|
+
readonly runId: string;
|
|
809
|
+
readonly toolCallId: string;
|
|
810
|
+
readonly childConversationId: string;
|
|
811
|
+
readonly childSubmissionId: string;
|
|
812
|
+
readonly childReceiptId: string;
|
|
813
|
+
readonly childRunId: string;
|
|
818
814
|
} | {
|
|
819
815
|
readonly _tag: "SubagentJoined";
|
|
820
816
|
readonly runId: string;
|
|
@@ -981,13 +977,19 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
981
977
|
}, Schema.SchemaError, never>;
|
|
982
978
|
declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
|
|
983
979
|
/** Failure surface of `CloudflareConversationClient.submit`. */
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
type
|
|
980
|
+
declare const ClientSubmitHostFailure: Schema.Union<readonly [typeof AgentInputError, typeof DigestError, typeof AdmissionConflict, typeof LedgerError, typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof AppendConflict, typeof FenceRejected, typeof DurableRuntimeFailpointError, typeof AdmissionLimitExceeded, typeof DurableAlarmError, typeof HostProtocolError]>;
|
|
981
|
+
declare const ClientAwaitHostFailure: Schema.Union<readonly [typeof LedgerError, typeof SettlementConflict, typeof HostProtocolError]>;
|
|
982
|
+
declare const ClientObserveHostFailure: Schema.Union<readonly [typeof ConversationStoreError, typeof ConversationNotMaterialized, typeof OperationDenied, typeof HostProtocolError]>;
|
|
983
|
+
declare const ClientAbortHostFailure: Schema.Union<readonly [typeof LedgerError, typeof SettlementConflict, typeof JoinedToHost, typeof DurableRuntimeFailpointError, typeof DurableAlarmError, typeof HostProtocolError]>;
|
|
984
|
+
declare const ClientApprovalHostFailure: Schema.Union<readonly [typeof LedgerError, typeof SettlementConflict, typeof ApprovalConflict, typeof OperationDenied, typeof DurableAlarmError, typeof HostProtocolError]>;
|
|
985
|
+
declare const ClientUnknownHostFailure: Schema.Union<readonly [typeof LedgerError, typeof SettlementConflict, typeof UnknownResolutionConflict, typeof JoinedToHost, typeof DurableRuntimeFailpointError, typeof OperationDenied, typeof DurableAlarmError, typeof HostProtocolError]>;
|
|
986
|
+
type ClientSubmitFailure = typeof ClientSubmitHostFailure.Type | ConversationClientError;
|
|
987
|
+
type ClientAwaitFailure = typeof ClientAwaitHostFailure.Type | ConversationClientError;
|
|
988
|
+
type ClientObserveFailure = typeof ClientObserveHostFailure.Type | ConversationClientError;
|
|
989
|
+
type ClientProgressFailure = ClientObserveFailure;
|
|
990
|
+
type ClientAbortFailure = typeof ClientAbortHostFailure.Type | ConversationClientError;
|
|
991
|
+
type ClientApprovalFailure = typeof ClientApprovalHostFailure.Type | ConversationClientError;
|
|
992
|
+
type ClientUnknownFailure = typeof ClientUnknownHostFailure.Type | ConversationClientError;
|
|
991
993
|
declare const CloudflareConversationClient_base: Context.ServiceClass<CloudflareConversationClient, "@effect-agent/platform-cloudflare/CloudflareConversationClient", {
|
|
992
994
|
/** Encode the input client-side, then durably submit to the owning Object. */
|
|
993
995
|
readonly submit: <InputSchema extends Schema.Top>(agent: DurableSubmitAgent<InputSchema>, input: InputSchema["Type"], options: DurableSubmitOptions) => Effect.Effect<Receipt, ClientSubmitFailure, InputSchema["EncodingServices"]>;
|
|
@@ -1601,43 +1603,24 @@ declare const makeConversationObjectClass: <EventLayerError = never, EventServic
|
|
|
1601
1603
|
* The Cloudflare Dynamic Worker `CodeExecutor` adapter (C4 of ADR-0017;
|
|
1602
1604
|
* DEPLOY-011). Each pass loads one fresh Worker through the Worker Loader
|
|
1603
1605
|
* with `globalOutbound: null`, so generated code has no ambient network,
|
|
1604
|
-
* bindings, or secrets; its only authority is the pass-scoped
|
|
1605
|
-
* routes back
|
|
1606
|
-
*
|
|
1607
|
-
*
|
|
1608
|
-
*
|
|
1609
|
-
*
|
|
1610
|
-
* isolate.
|
|
1606
|
+
* bindings, or secrets; its only authority is the pass-scoped RPC target that
|
|
1607
|
+
* routes back into the owning event's `CodeExecutionHost` service. Platform
|
|
1608
|
+
* CPU limits stop synchronous runaway programs; the executor-owned wall-clock
|
|
1609
|
+
* deadline interrupts asynchronously suspended passes. Deployment class `E`
|
|
1610
|
+
* only: the adapter records no persistent state and a later pass may run in a
|
|
1611
|
+
* completely different isolate.
|
|
1611
1612
|
*/
|
|
1612
1613
|
declare const dynamicWorkerImplementation: SandboxImplementation;
|
|
1613
|
-
/**
|
|
1614
|
-
|
|
1615
|
-
readonly call: (passId: string, hostCall: unknown) => Promise<unknown>;
|
|
1616
|
-
}
|
|
1617
|
-
/**
|
|
1618
|
-
* The host-side RPC target for dynamic workers. The application exposes it
|
|
1619
|
-
* from its Worker entry (`export { CodeModeHostEntrypoint }`) and hands the
|
|
1620
|
-
* adapter a same-instance stub — `ctx.exports.CodeModeHostEntrypoint()` in
|
|
1621
|
-
* production (a self service binding may reach a different instance and must
|
|
1622
|
-
* not be used there); tests bind it through Miniflare's `kCurrentWorker`.
|
|
1623
|
-
*/
|
|
1624
|
-
declare class CodeModeHostEntrypoint extends WorkerEntrypoint {
|
|
1625
|
-
call(passId: unknown, hostCall: unknown): Promise<unknown>;
|
|
1626
|
-
}
|
|
1614
|
+
/** Dispose a Cloudflare RPC handle when the runtime supplies its untyped disposal hook. @internal */
|
|
1615
|
+
declare const disposeRpcHandle: (handle: unknown) => Effect.Effect<void>;
|
|
1627
1616
|
interface DynamicWorkerCodeExecutorOptions {
|
|
1628
1617
|
/** The `worker_loader` binding. */
|
|
1629
1618
|
readonly loader: WorkerLoader;
|
|
1630
|
-
/**
|
|
1631
|
-
* A SAME-INSTANCE stub of `CodeModeHostEntrypoint`. In production create it
|
|
1632
|
-
* with `ctx.exports.CodeModeHostEntrypoint()`; a cross-instance stub would
|
|
1633
|
-
* dispatch host calls into an isolate without this pass's registry entry.
|
|
1634
|
-
*/
|
|
1635
|
-
readonly hostStub: CodeModeHostStub;
|
|
1636
1619
|
/** Compatibility date for dynamic workers; defaults to `2025-05-01`. */
|
|
1637
1620
|
readonly compatibilityDate?: string | undefined;
|
|
1638
1621
|
}
|
|
1639
1622
|
/** Layer building the Dynamic Worker `CodeExecutor` from resolved bindings. */
|
|
1640
1623
|
declare const dynamicWorkerCodeExecutorLayer: (options: DynamicWorkerCodeExecutorOptions) => Layer.Layer<CodeExecutor>;
|
|
1641
1624
|
//#endregion
|
|
1642
|
-
export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, AwaitProgressRequest, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CloudflareRunContextLayer, CloudflareRunContextSource, CloudflareRuntimeSourceContext,
|
|
1625
|
+
export { AbortRecorded, AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, AdmissionLimitExceeded, ApprovalRecorded, AwaitProgressRequest, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareAdmissionLimitsValue, CloudflareBindingError, CloudflareBindingSource, CloudflareBindingSourceContext, CloudflareConversationClient, CloudflareDurableRuntime, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflareDurableRuntimeInitializationError, CloudflareDurableRuntimeOptions, CloudflareDurableRuntimeServices, CloudflarePlatformConfigError, CloudflareRunContextLayer, CloudflareRunContextSource, CloudflareRuntimeSourceContext, ConversationClientError, ConversationMaintenance, ConversationMaintenanceFailpoint, ConversationMaintenanceFailpointHandler, ConversationMaintenanceFailpointLocation, 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, ProgressCancelled, ProgressObserved, ProgressWaitRegistry, RetryExecuted, SettlementReached, SubmitRequest, SubmitSucceeded, UnknownResolutionRecorded, VerifiedIntegrity, boundHostDiagnostic, cloudflareWakeSchedulerLayer, conversationNamespaceFromEnv, conversationNamespaceLayer, conversationPortTransportLayer, decodeAbortCommand, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObligationThresholds, decodeObservePageRequest, decodeReceipt, decodeRetryCommand, decodeSubmitRequest, decodeUnknownResolutionCommand, disposeRpcHandle, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation, encodeAbortCommand, encodeAdminResponse, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand, makeConversationObjectClass };
|
|
1643
1626
|
//# sourceMappingURL=index.d.mts.map
|