@yielded/agent-platform-cloudflare 0.1.0-beta.174 → 0.1.0-beta.175
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/{Alarm-4J9B8Fg8.mjs → Alarm-B44efvB1.mjs} +111 -74
- package/dist/Alarm-B44efvB1.mjs.map +1 -0
- package/dist/Alarm.d.mts +2 -0
- package/dist/Alarm.mjs +1 -1
- package/dist/CloudflareScheduling.mjs +2 -2
- package/dist/CloudflareSubscriptions.mjs +2 -2
- package/dist/{CloudflareThreadClient-DU548EEj.mjs → CloudflareThreadClient-Ai3MTs3X.mjs} +4 -4
- package/dist/CloudflareThreadClient-Ai3MTs3X.mjs.map +1 -0
- package/dist/{CloudflareThreadClient-lTm6baDP.d.mts → CloudflareThreadClient-HO_3rkM7.d.mts} +362 -362
- package/dist/CloudflareThreadClient.d.mts +1 -1
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{ThreadObject-BLYgzcdT.d.mts → ThreadObject-CxNlhoPL.d.mts} +13 -13
- package/dist/{ThreadObject-C2LF3btz.mjs → ThreadObject-DGvlHWYi.mjs} +42 -43
- package/dist/ThreadObject-DGvlHWYi.mjs.map +1 -0
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/WakeScheduler.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{prepared-admission-BoUPHSNQ.mjs → prepared-admission-DYdffQ8K.mjs} +2 -2
- package/dist/{prepared-admission-BoUPHSNQ.mjs.map → prepared-admission-DYdffQ8K.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +211 -116
- package/src/CloudflareThreadClient.ts +3 -2
- package/src/ThreadObject.ts +17 -22
- package/src/internal/layers.ts +55 -34
- package/src/internal/message-delivery.ts +61 -37
- package/dist/Alarm-4J9B8Fg8.mjs.map +0 -1
- package/dist/CloudflareThreadClient-DU548EEj.mjs.map +0 -1
- package/dist/ThreadObject-C2LF3btz.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as boundHostDiagnostic, B as decodeUnknownResolutionCommand, C as SettlementReached, D as SubmitSucceeded, E as SubmitRequest, F as decodeCancelProgressRequest, G as encodeCancelProgressRequest, H as encodeApprovalDecisionCommand, I as decodeHostResponse, J as encodeReceipt, K as encodeHostResponse, L as decodeObservePageRequest, M as decodeApprovalDecisionCommand, N as decodeAwaitProgressRequest, O as ThreadClientError, P as decodeAwaitSettlementRequest, R as decodeReceipt, S as ProgressObserved, T as SubmissionStatusResponse, U as encodeAwaitProgressRequest, V as encodeAbortCommand, W as encodeAwaitSettlementRequest, X as encodeUnknownResolutionCommand, Y as encodeSubmitRequest, Z as Frame, _ as HostProtocolError, a as CancelProgressRequest, b as ObservedPage, c as ClientAwaitFailure, d as ClientSubmitFailure, f as ClientUnknownFailure, g as HostFailure, h as HostFailed, i as AwaitSettlementRequest, j as decodeAbortCommand, k as UnknownResolutionRecorded, l as ClientObserveFailure, n as ApprovalRecorded, o as ClientAbortFailure, p as CloudflareThreadClient, q as encodeObservePageRequest, r as AwaitProgressRequest, s as ClientApprovalFailure, t as AbortRecorded, u as ClientProgressFailure, v as HostResponse, w as SettlementRecordReached, x as ProgressCancelled, y as ObservePageRequest, z as decodeSubmitRequest } from "./CloudflareThreadClient-
|
|
1
|
+
import { A as boundHostDiagnostic, B as decodeUnknownResolutionCommand, C as SettlementReached, D as SubmitSucceeded, E as SubmitRequest, F as decodeCancelProgressRequest, G as encodeCancelProgressRequest, H as encodeApprovalDecisionCommand, I as decodeHostResponse, J as encodeReceipt, K as encodeHostResponse, L as decodeObservePageRequest, M as decodeApprovalDecisionCommand, N as decodeAwaitProgressRequest, O as ThreadClientError, P as decodeAwaitSettlementRequest, R as decodeReceipt, S as ProgressObserved, T as SubmissionStatusResponse, U as encodeAwaitProgressRequest, V as encodeAbortCommand, W as encodeAwaitSettlementRequest, X as encodeUnknownResolutionCommand, Y as encodeSubmitRequest, Z as Frame, _ as HostProtocolError, a as CancelProgressRequest, b as ObservedPage, c as ClientAwaitFailure, d as ClientSubmitFailure, f as ClientUnknownFailure, g as HostFailure, h as HostFailed, i as AwaitSettlementRequest, j as decodeAbortCommand, k as UnknownResolutionRecorded, l as ClientObserveFailure, n as ApprovalRecorded, o as ClientAbortFailure, p as CloudflareThreadClient, q as encodeObservePageRequest, r as AwaitProgressRequest, s as ClientApprovalFailure, t as AbortRecorded, u as ClientProgressFailure, v as HostResponse, w as SettlementRecordReached, x as ProgressCancelled, y as ObservePageRequest, z as decodeSubmitRequest } from "./CloudflareThreadClient-HO_3rkM7.mjs";
|
|
2
2
|
export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, AwaitSettlementRequest, CancelProgressRequest, ClientAbortFailure, ClientApprovalFailure, ClientAwaitFailure, ClientObserveFailure, ClientProgressFailure, ClientSubmitFailure, ClientUnknownFailure, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, Frame as LiveTextFrame, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SettlementRecordReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeAwaitSettlementRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeAwaitSettlementRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as decodeObservePageRequest, B as encodeObservePageRequest, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, F as encodeApprovalDecisionCommand, H as encodeSubmitRequest, I as encodeAwaitProgressRequest, L as encodeAwaitSettlementRequest, M as decodeSubmitRequest, N as decodeUnknownResolutionCommand, O as decodeCancelProgressRequest, P as encodeAbortCommand, R as encodeCancelProgressRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, U as encodeUnknownResolutionCommand, V as encodeReceipt, W as Frame, _ as SettlementRecordReached, a as CancelProgressRequest, b as SubmitSucceeded, c as HostFailed, d as HostResponse, f as ObservePageRequest, g as SettlementReached, h as ProgressObserved, i as AwaitSettlementRequest, j as decodeReceipt, k as decodeHostResponse, l as HostFailure, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, r as AwaitProgressRequest, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, x as ThreadClientError, y as SubmitRequest, z as encodeHostResponse } from "./CloudflareThreadClient-
|
|
1
|
+
import { A as decodeObservePageRequest, B as encodeObservePageRequest, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, F as encodeApprovalDecisionCommand, H as encodeSubmitRequest, I as encodeAwaitProgressRequest, L as encodeAwaitSettlementRequest, M as decodeSubmitRequest, N as decodeUnknownResolutionCommand, O as decodeCancelProgressRequest, P as encodeAbortCommand, R as encodeCancelProgressRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, U as encodeUnknownResolutionCommand, V as encodeReceipt, W as Frame, _ as SettlementRecordReached, a as CancelProgressRequest, b as SubmitSucceeded, c as HostFailed, d as HostResponse, f as ObservePageRequest, g as SettlementReached, h as ProgressObserved, i as AwaitSettlementRequest, j as decodeReceipt, k as decodeHostResponse, l as HostFailure, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, r as AwaitProgressRequest, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, x as ThreadClientError, y as SubmitRequest, z as encodeHostResponse } from "./CloudflareThreadClient-Ai3MTs3X.mjs";
|
|
2
2
|
export { AbortRecorded, ApprovalRecorded, AwaitProgressRequest, AwaitSettlementRequest, CancelProgressRequest, CloudflareThreadClient, HostFailed, HostFailure, HostProtocolError, HostResponse, Frame as LiveTextFrame, ObservePageRequest, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SettlementRecordReached, SubmissionStatusResponse, SubmitRequest, SubmitSucceeded, ThreadClientError, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeAwaitSettlementRequest, decodeCancelProgressRequest, decodeHostResponse, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeAbortCommand, encodeApprovalDecisionCommand, encodeAwaitProgressRequest, encodeAwaitSettlementRequest, encodeCancelProgressRequest, encodeHostResponse, encodeObservePageRequest, encodeReceipt, encodeSubmitRequest, encodeUnknownResolutionCommand };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DurableObjectContext, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement } from "./CloudflareBindings.mjs";
|
|
2
2
|
import { l as CloudflarePlatformConfigError, s as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded } from "./CloudflareConfig-C9MvPbX8.mjs";
|
|
3
3
|
import { DurableAlarmError, DurableAlarmService, MaintenancePassFailure, ThreadMaintenance, ThreadMaintenanceAlarm, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMutationGate, ThreadPublication, ThreadRecoveryEvents } from "./Alarm.mjs";
|
|
4
|
-
import { E as SubmitRequest, _ as HostProtocolError } from "./CloudflareThreadClient-
|
|
4
|
+
import { E as SubmitRequest, _ as HostProtocolError } from "./CloudflareThreadClient-HO_3rkM7.mjs";
|
|
5
5
|
import { AgentRegistration } from "@yielded/agent/agent-registration";
|
|
6
6
|
import { ApprovalSuspensionError, DurableAgentRuntime, DurableRuntimeConfig, RecoveryBlocked, RecoveryReport } from "@yielded/agent/durable-agent-runtime";
|
|
7
7
|
import { SubmissionId, ThreadId } from "@yielded/agent/identifiers";
|
|
@@ -400,13 +400,13 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
400
400
|
readonly author: string;
|
|
401
401
|
readonly reason: string;
|
|
402
402
|
readonly resolution: {
|
|
403
|
+
readonly _tag: "SafeToRetry";
|
|
404
|
+
} | {
|
|
403
405
|
readonly _tag: "CompletedWithResult";
|
|
404
406
|
readonly result: Schema.Json;
|
|
405
407
|
readonly isFailure: boolean;
|
|
406
408
|
} | {
|
|
407
409
|
readonly _tag: "NeverHappened";
|
|
408
|
-
} | {
|
|
409
|
-
readonly _tag: "SafeToRetry";
|
|
410
410
|
} | {
|
|
411
411
|
readonly _tag: "AbortSubmission";
|
|
412
412
|
};
|
|
@@ -736,13 +736,10 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
736
736
|
} | {
|
|
737
737
|
readonly _tag: "AdminFailed";
|
|
738
738
|
readonly failure: {
|
|
739
|
-
readonly _tag: "
|
|
739
|
+
readonly _tag: "LedgerError";
|
|
740
740
|
readonly operation: string;
|
|
741
741
|
readonly message: string;
|
|
742
|
-
readonly cause?:
|
|
743
|
-
} | {
|
|
744
|
-
readonly _tag: "ThreadNotMaterialized";
|
|
745
|
-
readonly threadId: string;
|
|
742
|
+
readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
|
|
746
743
|
} | {
|
|
747
744
|
readonly _tag: "ThreadStoreError";
|
|
748
745
|
readonly operation: string;
|
|
@@ -756,10 +753,8 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
756
753
|
readonly sequence?: number | undefined;
|
|
757
754
|
} | undefined;
|
|
758
755
|
} | {
|
|
759
|
-
readonly _tag: "
|
|
760
|
-
readonly
|
|
761
|
-
readonly message: string;
|
|
762
|
-
readonly cause?: import("@yielded/agent/failure-diagnostic").Diagnostic | undefined;
|
|
756
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
757
|
+
readonly threadId: string;
|
|
763
758
|
} | {
|
|
764
759
|
readonly _tag: "AppendConflict";
|
|
765
760
|
readonly threadId: string;
|
|
@@ -823,6 +818,11 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
823
818
|
readonly _tag: "RunJournalError";
|
|
824
819
|
readonly message: string;
|
|
825
820
|
readonly cause?: Schema.Json | undefined;
|
|
821
|
+
} | {
|
|
822
|
+
readonly _tag: "DurableAlarmError";
|
|
823
|
+
readonly operation: string;
|
|
824
|
+
readonly message: string;
|
|
825
|
+
readonly cause?: Schema.Json | undefined;
|
|
826
826
|
} | {
|
|
827
827
|
readonly _tag: "HostProtocolError";
|
|
828
828
|
readonly message: string;
|
|
@@ -888,4 +888,4 @@ interface Class<EventServices = never> {
|
|
|
888
888
|
declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never, AlarmServices = never, AlarmError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | ThreadMaintenanceAlarm | NoInfer<AlarmServices> | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError, AlarmServices, AlarmError>) => Class<ApplicationServices | EventServices | AlarmServices>;
|
|
889
889
|
//#endregion
|
|
890
890
|
export { ThreadHostMutation as A, make as C, CloudflareDurableRuntimeInitializationError as D, CloudflareBootstrapServices as E, layerHostConfig as F, layerInHost as I, ThreadPublicationOptions as M, layer$1 as N, CloudflareDurableRuntimeOptions as O, layerConfig as P, handleRpc as S, submit as T, decodeAdminResponse as _, AdminVerifyRequest as a, decodeRetryCommand as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminExplainRequest as g, alarms as h, AdminResponse as i, ThreadObjectPorts as j, CloudflareDurableRuntimeServices as k, ObligationsScanned as l, VerifiedIntegrity as m, AdminFailed as n, Class as o, ThreadRpcOperation as p, AdminFailure as r, ExplainedRecovery as s, AdminExplainRequest as t, Options as u, decodeAdminVerifyRequest as v, portCall as w, encodeAdminResponse as x, decodeObligationThresholds as y };
|
|
891
|
-
//# sourceMappingURL=ThreadObject-
|
|
891
|
+
//# sourceMappingURL=ThreadObject-CxNlhoPL.d.mts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { DurableObjectContext, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement, callThreadObject, threadNamespaceFromEnv } from "./CloudflareBindings.mjs";
|
|
3
3
|
import { AdmissionLimitExceeded, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError } from "./CloudflareConfig.mjs";
|
|
4
|
-
import { _ as Lifecycle, b as Projection, c as ThreadMaintenanceFailpoint, d as ThreadNativeMaintenance, f as ThreadPublication, g as HostLaneId, h as publishCommitted, l as ThreadMessageDelivery, n as DurableAlarmError, o as ThreadMaintenance, r as DurableAlarmService, s as ThreadMaintenanceAlarm, u as ThreadMutationGate, v as Messages, x as Publication, y as Native } from "./Alarm-
|
|
5
|
-
import { A as decodeObservePageRequest, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, G as MAX_DELTA_LENGTH, J as Request, M as decodeSubmitRequest, N as decodeUnknownResolutionCommand, O as decodeCancelProgressRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, W as Frame, X as cloudflareCryptoLayer, Y as isBoundedEvent, _ as SettlementRecordReached, b as SubmitSucceeded, c as HostFailed, g as SettlementReached, h as ProgressObserved, j as decodeReceipt, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, z as encodeHostResponse } from "./CloudflareThreadClient-
|
|
6
|
-
import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-
|
|
4
|
+
import { _ as Lifecycle, b as Projection, c as ThreadMaintenanceFailpoint, d as ThreadNativeMaintenance, f as ThreadPublication, g as HostLaneId, h as publishCommitted, l as ThreadMessageDelivery, n as DurableAlarmError, o as ThreadMaintenance, r as DurableAlarmService, s as ThreadMaintenanceAlarm, u as ThreadMutationGate, v as Messages, x as Publication, y as Native } from "./Alarm-B44efvB1.mjs";
|
|
5
|
+
import { A as decodeObservePageRequest, C as boundHostDiagnostic, D as decodeAwaitSettlementRequest, E as decodeAwaitProgressRequest, G as MAX_DELTA_LENGTH, J as Request, M as decodeSubmitRequest, N as decodeUnknownResolutionCommand, O as decodeCancelProgressRequest, S as UnknownResolutionRecorded, T as decodeApprovalDecisionCommand, W as Frame, X as cloudflareCryptoLayer, Y as isBoundedEvent, _ as SettlementRecordReached, b as SubmitSucceeded, c as HostFailed, g as SettlementReached, h as ProgressObserved, j as decodeReceipt, m as ProgressCancelled, n as ApprovalRecorded, o as CloudflareThreadClient, p as ObservedPage, t as AbortRecorded, u as HostProtocolError, v as SubmissionStatusResponse, w as decodeAbortCommand, z as encodeHostResponse } from "./CloudflareThreadClient-Ai3MTs3X.mjs";
|
|
6
|
+
import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-DYdffQ8K.mjs";
|
|
7
7
|
import { cloudflareWakeSchedulerLayer } from "./WakeScheduler.mjs";
|
|
8
8
|
import { ThreadPortTransport, executePortRequest, makeLocalSubmissionLookup, portTransportFailure, routedMessageDeliveryStoreLayer, routedSettlementPublisherLayer, routedSubmissionLedgerLayer, routedThreadStoreLayer, routedWorkerAdmissionLayer } from "@yielded/agent-storage-cloudflare/port-routing";
|
|
9
9
|
import { compileRegistrations } from "@yielded/agent/agent-registration";
|
|
@@ -230,10 +230,15 @@ const guardedMessageDeliveryStoreLayer = Layer.effect(MessageDeliveryStore, Effe
|
|
|
230
230
|
nextDeadline: (owner) => local(owner, store.nextDeadline(owner))
|
|
231
231
|
});
|
|
232
232
|
}));
|
|
233
|
-
/**
|
|
234
|
-
const
|
|
235
|
-
const
|
|
233
|
+
/** Build the driver in the Object's Scope only when retained delivery work is due. */
|
|
234
|
+
const lazyThreadMessageDeliveryLayer = (driver) => Layer.fromBuildMemo((memoMap, scope) => Effect.gen(function* () {
|
|
235
|
+
const context = yield* Effect.context();
|
|
236
236
|
const store = yield* MessageDeliveryStore;
|
|
237
|
+
const service = yield* Effect.cachedWithTTL(Layer.buildWithMemoMap(driver, memoMap, scope).pipe(Effect.provide(context), Effect.map(Context.get(MessageDeliveryDriver)), Effect.mapError((cause) => DurableAlarmError.make({
|
|
238
|
+
operation: "prepare message delivery",
|
|
239
|
+
message: "Durable message recovery remains pending",
|
|
240
|
+
cause
|
|
241
|
+
}))), (exit) => Exit.isSuccess(exit) ? Duration.infinity : Duration.zero);
|
|
237
242
|
const failure = (operation) => () => DurableAlarmError.make({
|
|
238
243
|
operation,
|
|
239
244
|
message: "Durable message recovery remains pending"
|
|
@@ -248,14 +253,15 @@ const threadMessageDeliveryLayer = Layer.effectContext(Effect.gen(function* () {
|
|
|
248
253
|
const records = yield* Effect.forEach(keys, (key) => store.get(key));
|
|
249
254
|
return {
|
|
250
255
|
timeoutMillis: Math.max(1, ...records.map((record) => record?.policy.attemptTimeoutMillis ?? 1)),
|
|
251
|
-
run: Effect.forEach(keys, (key) => driver.process(key), {
|
|
256
|
+
run: Effect.flatMap(service, (driver) => Effect.forEach(keys, (key) => driver.process(key), {
|
|
252
257
|
concurrency: 4,
|
|
253
258
|
discard: true
|
|
254
|
-
}).pipe(Effect.andThen(store.nextDeadline()), Effect.map(Option.fromNullishOr), Effect.mapError(failure("dispatch message delivery")))
|
|
259
|
+
})).pipe(Effect.andThen(store.nextDeadline()), Effect.map(Option.fromNullishOr), Effect.mapError(failure("dispatch message delivery")))
|
|
255
260
|
};
|
|
256
261
|
}).pipe(Effect.mapError(failure("prepare message delivery")));
|
|
257
262
|
return Context.make(ThreadMessageDelivery, { prepare });
|
|
258
263
|
}));
|
|
264
|
+
lazyThreadMessageDeliveryLayer(Layer.effect(MessageDeliveryDriver, MessageDeliveryDriver));
|
|
259
265
|
//#endregion
|
|
260
266
|
//#region src/internal/progress-wait.ts
|
|
261
267
|
/** Cancellation tombstones are bounded hints, never durable authority. */
|
|
@@ -458,7 +464,7 @@ const sharedLayer = (application, options = {}) => Layer.unwrap(Effect.gen(funct
|
|
|
458
464
|
maxStoredValueBytes: config.maxStoredValueBytes,
|
|
459
465
|
verifyOnOpen: config.verifyOnOpen
|
|
460
466
|
};
|
|
461
|
-
const infrastructure = Layer.mergeAll(options.lifecyclePublication === void 0 ? Layer.empty : lifecyclePublicationLayer, storageConfigLayer(storageOptions), Layer.effect(SqlClient)(SqlClient));
|
|
467
|
+
const infrastructure = Layer.suspend(() => Layer.mergeAll(options.lifecyclePublication === void 0 ? Layer.empty : lifecyclePublicationLayer, storageConfigLayer(storageOptions), Layer.effect(SqlClient)(SqlClient)));
|
|
462
468
|
const sourceOwner = Layer.effect(SqlStorageOwner)(Effect.gen(function* () {
|
|
463
469
|
const owner = yield* SqlStorageOwner;
|
|
464
470
|
const mutations = yield* ThreadMutationGate;
|
|
@@ -472,7 +478,7 @@ const sharedLayer = (application, options = {}) => Layer.unwrap(Effect.gen(funct
|
|
|
472
478
|
}) : Effect.void)))
|
|
473
479
|
};
|
|
474
480
|
})).pipe(Layer.provide(sqlOwnerLayer));
|
|
475
|
-
const localInfrastructure = Layer.mergeAll(infrastructure, sourceOwner);
|
|
481
|
+
const localInfrastructure = Layer.suspend(() => Layer.mergeAll(infrastructure, sourceOwner));
|
|
476
482
|
const sourceProgress = Layer.effect(SqlStorageProgress)(Effect.gen(function* () {
|
|
477
483
|
const mutations = yield* ThreadMutationGate;
|
|
478
484
|
return { committed: (kind) => {
|
|
@@ -488,16 +494,16 @@ const sharedLayer = (application, options = {}) => Layer.unwrap(Effect.gen(funct
|
|
|
488
494
|
})))));
|
|
489
495
|
} };
|
|
490
496
|
}));
|
|
491
|
-
const rawLocalPorts = Layer.mergeAll(threadStoreLayer, submissionLedgerLayer).pipe(Layer.provide(localInfrastructure), Layer.provide(sourceProgress));
|
|
492
|
-
const base = Layer.mergeAll(DurableAlarmService.layer, ProgressWaitRegistry.layer);
|
|
497
|
+
const rawLocalPorts = Layer.suspend(() => Layer.mergeAll(threadStoreLayer, submissionLedgerLayer).pipe(Layer.provide(localInfrastructure), Layer.provide(sourceProgress)));
|
|
498
|
+
const base = Layer.suspend(() => Layer.mergeAll(DurableAlarmService.layer, ProgressWaitRegistry.layer));
|
|
493
499
|
const wakes = cloudflareWakeSchedulerLayer.pipe(Layer.provide(base));
|
|
494
|
-
const messageStore = guardedMessageDeliveryStoreLayer.pipe(Layer.provide(doMessageDeliveryStoreLayer().pipe(Layer.provide(localInfrastructure), Layer.provide(sourceProgress))), Layer.provide(wakes));
|
|
495
|
-
const messageRecovery =
|
|
500
|
+
const messageStore = Layer.suspend(() => guardedMessageDeliveryStoreLayer.pipe(Layer.provide(doMessageDeliveryStoreLayer().pipe(Layer.provide(localInfrastructure), Layer.provide(sourceProgress))), Layer.provide(wakes)));
|
|
501
|
+
const messageRecovery = Layer.suspend(() => lazyThreadMessageDeliveryLayer(MessageDeliveryDriver.layer({
|
|
496
502
|
batchSize: 4,
|
|
497
503
|
concurrency: 4
|
|
498
|
-
})
|
|
499
|
-
const publication =
|
|
500
|
-
const projection =
|
|
504
|
+
}).pipe(Layer.provide(cloudflarePreparedInputAdmissionLayer), Layer.provide(CloudflareThreadClient.layer), Layer.provide(messageStore), Layer.provide(wakes))).pipe(Layer.provide(messageStore)));
|
|
505
|
+
const publication = options.publication === void 0 ? ThreadPublication.layer : options.publication.pipe(Layer.provide(Layer.mergeAll(rawLocalPorts, Layer.effect(SqlClient)(SqlClient))));
|
|
506
|
+
const projection = options.projection === void 0 ? ThreadProjectionMaintenance.layer : options.projection.pipe(Layer.provide(Layer.mergeAll(rawLocalPorts, Layer.effect(SqlClient)(SqlClient))));
|
|
501
507
|
const localPorts = options.publication === void 0 && options.projection === void 0 && options.hostLanesForMutation === void 0 && options.lifecyclePublication === void 0 ? rawLocalPorts : Layer.effectContext(Effect.gen(function* () {
|
|
502
508
|
const store = yield* ThreadStore;
|
|
503
509
|
const ledger = yield* SubmissionLedger;
|
|
@@ -553,10 +559,10 @@ const sharedLayer = (application, options = {}) => Layer.unwrap(Effect.gen(funct
|
|
|
553
559
|
})));
|
|
554
560
|
}) }), Context.add(SubmissionLedger, {
|
|
555
561
|
...ledger,
|
|
556
|
-
...options.hostLanesForMutation === void 0 ? {} : { admit: (
|
|
562
|
+
...options.hostLanesForMutation === void 0 && options.lifecyclePublication === void 0 ? {} : { admit: (...args) => observeMutation({
|
|
557
563
|
_tag: "Admission",
|
|
558
|
-
request
|
|
559
|
-
}, ledger.admit(
|
|
564
|
+
request: args[0]
|
|
565
|
+
}, ledger.admit(...args), false) },
|
|
560
566
|
...options.lifecyclePublication === void 0 ? {} : {
|
|
561
567
|
markReady: (request) => observeIntent(ledger.markReady(request), false),
|
|
562
568
|
suspend: (request) => observeIntent(ledger.suspend(request), false),
|
|
@@ -722,10 +728,10 @@ const gateAdmissionLimits = Effect.fnUntraced(function* (threadId, request) {
|
|
|
722
728
|
actual: inputBytes,
|
|
723
729
|
maximum: config.limits.maxInputBytes
|
|
724
730
|
}));
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
731
|
+
const queueDepth = yield* Stream.runFold(ledger.scanNonterminal, () => 0, (depth, submission) => depth + (submission.threadId === threadId ? 1 : 0));
|
|
732
|
+
if (queueDepth >= config.limits.maxQueueDepthPerLane) return yield* refuseFresh(AdmissionLimitExceeded.make({
|
|
727
733
|
limit: "queue-depth",
|
|
728
|
-
actual:
|
|
734
|
+
actual: queueDepth,
|
|
729
735
|
maximum: config.limits.maxQueueDepthPerLane
|
|
730
736
|
}));
|
|
731
737
|
const databaseBytes = yield* Effect.sync(() => ctx.storage.sql.databaseSize);
|
|
@@ -1100,25 +1106,18 @@ const gateEndpoint = Effect.gen(function* () {
|
|
|
1100
1106
|
* ports. effect-cf owns the cached ManagedRuntime and supplies these values once per Object
|
|
1101
1107
|
* incarnation; the durable runtime continues to depend only on the narrow services below.
|
|
1102
1108
|
*/
|
|
1103
|
-
const effectCfPlatformLayer = (namespaceBinding, rpcTracing = false) => {
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
return ThreadObjectNamespace.of({
|
|
1116
|
-
get: (threadId) => binding.get(binding.idFromName(threadId)),
|
|
1117
|
-
...rpcTracing === true ? { rpcTracing: namespaceBinding } : {}
|
|
1118
|
-
});
|
|
1119
|
-
}));
|
|
1120
|
-
return Layer.merge(context, namespace);
|
|
1121
|
-
};
|
|
1109
|
+
const effectCfPlatformLayer = (namespaceBinding, rpcTracing = false) => Layer.effectContext(Effect.gen(function* () {
|
|
1110
|
+
const state = yield* DurableObjectState.DurableObjectState;
|
|
1111
|
+
const env = yield* WorkerEnvironment;
|
|
1112
|
+
const binding = yield* threadNamespaceFromEnv(env, namespaceBinding);
|
|
1113
|
+
return Context.make(DurableObjectContext, {
|
|
1114
|
+
ctx: state.raw,
|
|
1115
|
+
env
|
|
1116
|
+
}).pipe(Context.add(ThreadObjectNamespace, ThreadObjectNamespace.of({
|
|
1117
|
+
get: (threadId) => binding.get(binding.idFromName(threadId)),
|
|
1118
|
+
...rpcTracing === true ? { rpcTracing: namespaceBinding } : {}
|
|
1119
|
+
})));
|
|
1120
|
+
}));
|
|
1122
1121
|
/**
|
|
1123
1122
|
* Export a composed application Layer as a native Durable Object class.
|
|
1124
1123
|
* Bootstrap services are provided to the whole graph before it acquires, so application Layers
|
|
@@ -1164,4 +1163,4 @@ const make = (applicationLayer, options) => {
|
|
|
1164
1163
|
//#endregion
|
|
1165
1164
|
export { ThreadObjectPorts as C, layerInHost as D, layerHostConfig as E, submit as S, layerConfig as T, decodeRetryCommand as _, AdminVerifyRequest as a, make as b, RetryExecuted as c, VerifiedIntegrity as d, alarms as f, decodeObligationThresholds as g, decodeAdminVerifyRequest as h, AdminResponse as i, ThreadObject_exports as l, decodeAdminResponse as m, AdminFailed as n, ExplainedRecovery as o, decodeAdminExplainRequest as p, AdminFailure as r, ObligationsScanned as s, AdminExplainRequest as t, ThreadRpcOperation as u, encodeAdminResponse as v, layer$1 as w, portCall as x, handleRpc as y };
|
|
1166
1165
|
|
|
1167
|
-
//# sourceMappingURL=ThreadObject-
|
|
1166
|
+
//# sourceMappingURL=ThreadObject-DGvlHWYi.mjs.map
|