@effect-agent/platform-cloudflare 0.1.0-beta.94 → 0.1.0-beta.95
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.d.mts +37 -18
- package/dist/Alarm.mjs +62 -29
- package/dist/Alarm.mjs.map +1 -1
- package/dist/{CloudflareConfig-f3CqTel1.d.mts → CloudflareConfig-D472JOQA.d.mts} +8 -3
- package/dist/CloudflareConfig.d.mts +2 -2
- package/dist/CloudflareConfig.mjs +7 -1
- package/dist/CloudflareConfig.mjs.map +1 -1
- package/dist/CloudflareThreadClient.d.mts +34 -34
- package/dist/{ThreadObject-8LfGzzz4.d.mts → ThreadObject-CZxuDWOb.d.mts} +37 -35
- package/dist/{ThreadObject-DvRG0dDz.mjs → ThreadObject-DXavwaU-.mjs} +34 -16
- package/dist/ThreadObject-DXavwaU-.mjs.map +1 -0
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/Alarm.ts +124 -50
- package/src/CloudflareConfig.ts +6 -0
- package/src/internal/layers.ts +7 -2
- package/src/internal/message-delivery.ts +69 -40
- package/dist/ThreadObject-DvRG0dDz.mjs.map +0 -1
|
@@ -6,6 +6,7 @@ import { DEFAULT_MAX_STORED_VALUE_BYTES } from "@effect-agent/storage-cloudflare
|
|
|
6
6
|
//#region src/CloudflareConfig.ts
|
|
7
7
|
var CloudflareConfig_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
AdmissionLimitExceeded: () => AdmissionLimitExceeded,
|
|
9
|
+
AuxiliaryDispatchMillis: () => AuxiliaryDispatchMillis,
|
|
9
10
|
CLOUDFLARE_DATABASE_CAP_BYTES: () => CLOUDFLARE_DATABASE_CAP_BYTES,
|
|
10
11
|
CLOUDFLARE_RUNTIME_DEFAULTS: () => CLOUDFLARE_RUNTIME_DEFAULTS,
|
|
11
12
|
CloudflareAdmissionLimitsValue: () => CloudflareAdmissionLimitsValue,
|
|
@@ -20,6 +21,8 @@ var CloudflareConfig_exports = /* @__PURE__ */ __exportAll({
|
|
|
20
21
|
* cadence is in milliseconds; every bound is finite and checked before any resource opens.
|
|
21
22
|
*/
|
|
22
23
|
const PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));
|
|
24
|
+
/** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */
|
|
25
|
+
const AuxiliaryDispatchMillis = PositiveMillis.check(Schema.isLessThanOrEqualTo(3e5));
|
|
23
26
|
const NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
24
27
|
/** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */
|
|
25
28
|
var CloudflarePlatformConfigError = class extends Schema.TaggedError()("CloudflarePlatformConfigError", {
|
|
@@ -92,6 +95,8 @@ var CloudflareDurableRuntimeConfigValue = class extends Schema.Class("@effect-ag
|
|
|
92
95
|
abortPollInterval: PositiveMillis,
|
|
93
96
|
/** Canonical observation poll cadence of the Durable Object store. */
|
|
94
97
|
observationPollInterval: NonNegativeMillis,
|
|
98
|
+
/** One disposable projection backfill wave; independent of required live applyCommitted. */
|
|
99
|
+
projectionDispatchTimeoutMillis: AuxiliaryDispatchMillis,
|
|
95
100
|
/** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */
|
|
96
101
|
maxStoredValueBytes: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2e6)),
|
|
97
102
|
/** Opt-in full payload/digest-chain audit while opening the store. */
|
|
@@ -110,6 +115,7 @@ const CLOUDFLARE_RUNTIME_DEFAULTS = {
|
|
|
110
115
|
leaseRenewalInterval: 1e4,
|
|
111
116
|
abortPollInterval: 500,
|
|
112
117
|
observationPollInterval: 25,
|
|
118
|
+
projectionDispatchTimeoutMillis: 3e4,
|
|
113
119
|
maxStoredValueBytes: DEFAULT_MAX_STORED_VALUE_BYTES,
|
|
114
120
|
verifyOnOpen: false,
|
|
115
121
|
maxQueueDepthPerLane: 256,
|
|
@@ -117,6 +123,6 @@ const CLOUDFLARE_RUNTIME_DEFAULTS = {
|
|
|
117
123
|
maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES
|
|
118
124
|
};
|
|
119
125
|
//#endregion
|
|
120
|
-
export { AdmissionLimitExceeded, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, CloudflareConfig_exports as t };
|
|
126
|
+
export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, CloudflareConfig_exports as t };
|
|
121
127
|
|
|
122
128
|
//# sourceMappingURL=CloudflareConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareConfig.mjs","names":[],"sources":["../src/CloudflareConfig.ts"],"sourcesContent":["import { DEFAULT_MAX_STORED_VALUE_BYTES } from \"@effect-agent/storage-cloudflare/do-storage-config\";\nimport { Context, Duration, Schema } from \"effect\";\nimport { DeploymentId } from \"effect-agent/records\";\nimport { DEFAULT_OWNERSHIP_LEASE_DURATION } from \"effect-agent/submission-ledger\";\n\n/**\n * Schema-validated configuration for the Cloudflare durable runtime (deployment spec §4:\n * decoded once during Layer construction, exposed as a typed service; DEPLOY-003). Every\n * cadence is in milliseconds; every bound is finite and checked before any resource opens.\n */\n\nconst PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));\nconst NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */\nexport class CloudflarePlatformConfigError extends Schema.TaggedError<CloudflarePlatformConfigError>()(\n \"CloudflarePlatformConfigError\",\n {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * An admission was refused by a host resource limit BEFORE any ledger row existed\n * (deployment spec §8, DEPLOY-007: \"Admission has explicit bounded quota and overload\n * behavior... a typed rejection\"). This is the DC analogue of `NodeDurableHost`'s\n * `AdmissionClosed` host gate: the port surface stays untouched, the refusal happens in the\n * Thread Object's submit entry point before `DurableAgentRuntime.submit` runs, and\n * nothing was admitted or written.\n */\nexport class AdmissionLimitExceeded extends Schema.TaggedError<AdmissionLimitExceeded>()(\n \"AdmissionLimitExceeded\",\n {\n limit: Schema.Literals([\"queue-depth\", \"input-bytes\", \"database-bytes\"]),\n actual: Schema.Int,\n maximum: Schema.Int,\n },\n) {\n override get message() {\n return (\n `Admission refused before any ledger row existed: ${this.limit} ${this.actual} exceeds ` +\n `the configured maximum ${this.maximum}. Accepted work is unaffected; retry after the ` +\n \"lane drains or raise the limit (DEPLOY-007).\"\n );\n }\n}\n\n/** The platform's hard per-Object database cap (10 GB, developers.cloudflare.com limits). */\nexport const CLOUDFLARE_DATABASE_CAP_BYTES = 10_000_000_000;\n\n/** Default database-size admission ceiling: a 1 GB safety margin under the platform cap. */\nexport const DEFAULT_MAX_DATABASE_BYTES = 9_000_000_000;\n\n/**\n * Explicit bounded admission quotas checked by the Thread Object BEFORE admission\n * (exit gate \"resource limits are checked before admission\").\n */\nexport class CloudflareAdmissionLimitsValue extends Schema.Class<CloudflareAdmissionLimitsValue>(\n \"@effect-agent/platform-cloudflare/CloudflareAdmissionLimitsValue\",\n)({\n /** Maximum nonterminal Submissions per Thread lane before new admissions refuse. */\n maxQueueDepthPerLane: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(100_000),\n ),\n /** Maximum encoded input bytes; never above the storage per-value bound. */\n maxInputBytes: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2_000_000)),\n /** Maximum `ctx.storage.sql.databaseSize` at admission; stays under the 10 GB platform cap. */\n maxDatabaseBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(CLOUDFLARE_DATABASE_CAP_BYTES),\n ),\n}) {}\n\n/**\n * Validated Cloudflare durable runtime configuration. The producer identity of one\n * Thread Object is `{producerPrefix}:{threadId}` — stable across incarnations of\n * the same deployment, distinct across deployments — and producer-epoch fencing (not the\n * producer name) remains the correctness authority (DUR-006).\n */\nexport class CloudflareDurableRuntimeConfigValue extends Schema.Class<CloudflareDurableRuntimeConfigValue>(\n \"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfigValue\",\n)({\n deploymentId: DeploymentId,\n /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */\n producerPrefix: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n /** Submission ownership lease duration (D5); fences work across Object incarnations. */\n ownershipLeaseDuration: PositiveMillis,\n /** Base delay of the alarm re-arm backoff when a pass makes no progress. */\n alarmBackoffBase: PositiveMillis,\n /** Ceiling of the alarm re-arm backoff. */\n alarmBackoffCap: PositiveMillis,\n /**\n * The maintenance-pass scan cadence and the ceiling of every re-arm delay: nonterminal\n * work is revisited at least this often (wake/scan pairing, persistence §14).\n */\n wakeScanInterval: PositiveMillis,\n /** `awaitSettlement` ledger re-check cadence when no wake arrives. */\n settlementPollInterval: PositiveMillis,\n /** Worker ownership-lease renewal cadence during an active Attempt. */\n leaseRenewalInterval: PositiveMillis,\n /** Active-Run abort-intent poll cadence. */\n abortPollInterval: PositiveMillis,\n /** Canonical observation poll cadence of the Durable Object store. */\n observationPollInterval: NonNegativeMillis,\n /** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */\n maxStoredValueBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(2_000_000),\n ),\n /** Opt-in full payload/digest-chain audit while opening the store. */\n verifyOnOpen: Schema.Boolean,\n limits: CloudflareAdmissionLimitsValue,\n}) {}\n\n/** Explicit configuration authority for the assembled Cloudflare durable runtime. */\nexport class CloudflareDurableRuntimeConfig extends Context.Service<\n CloudflareDurableRuntimeConfig,\n CloudflareDurableRuntimeConfigValue\n>()(\"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfig\") {}\n\n/** Documented production defaults applied by `ThreadObject.layer`. */\nexport const CLOUDFLARE_RUNTIME_DEFAULTS = {\n ownershipLeaseDuration: Duration.toMillis(DEFAULT_OWNERSHIP_LEASE_DURATION),\n alarmBackoffBase: 100,\n alarmBackoffCap: 5_000,\n wakeScanInterval: 1_000,\n settlementPollInterval: 500,\n leaseRenewalInterval: 10_000,\n abortPollInterval: 500,\n observationPollInterval: 25,\n maxStoredValueBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n verifyOnOpen: false,\n maxQueueDepthPerLane: 256,\n maxInputBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES,\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CloudflareConfig.mjs","names":[],"sources":["../src/CloudflareConfig.ts"],"sourcesContent":["import { DEFAULT_MAX_STORED_VALUE_BYTES } from \"@effect-agent/storage-cloudflare/do-storage-config\";\nimport { Context, Duration, Schema } from \"effect\";\nimport { DeploymentId } from \"effect-agent/records\";\nimport { DEFAULT_OWNERSHIP_LEASE_DURATION } from \"effect-agent/submission-ledger\";\n\n/**\n * Schema-validated configuration for the Cloudflare durable runtime (deployment spec §4:\n * decoded once during Layer construction, exposed as a typed service; DEPLOY-003). Every\n * cadence is in milliseconds; every bound is finite and checked before any resource opens.\n */\n\nconst PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));\n\n/** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */\nexport const AuxiliaryDispatchMillis = PositiveMillis.check(Schema.isLessThanOrEqualTo(300_000));\nconst NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */\nexport class CloudflarePlatformConfigError extends Schema.TaggedError<CloudflarePlatformConfigError>()(\n \"CloudflarePlatformConfigError\",\n {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * An admission was refused by a host resource limit BEFORE any ledger row existed\n * (deployment spec §8, DEPLOY-007: \"Admission has explicit bounded quota and overload\n * behavior... a typed rejection\"). This is the DC analogue of `NodeDurableHost`'s\n * `AdmissionClosed` host gate: the port surface stays untouched, the refusal happens in the\n * Thread Object's submit entry point before `DurableAgentRuntime.submit` runs, and\n * nothing was admitted or written.\n */\nexport class AdmissionLimitExceeded extends Schema.TaggedError<AdmissionLimitExceeded>()(\n \"AdmissionLimitExceeded\",\n {\n limit: Schema.Literals([\"queue-depth\", \"input-bytes\", \"database-bytes\"]),\n actual: Schema.Int,\n maximum: Schema.Int,\n },\n) {\n override get message() {\n return (\n `Admission refused before any ledger row existed: ${this.limit} ${this.actual} exceeds ` +\n `the configured maximum ${this.maximum}. Accepted work is unaffected; retry after the ` +\n \"lane drains or raise the limit (DEPLOY-007).\"\n );\n }\n}\n\n/** The platform's hard per-Object database cap (10 GB, developers.cloudflare.com limits). */\nexport const CLOUDFLARE_DATABASE_CAP_BYTES = 10_000_000_000;\n\n/** Default database-size admission ceiling: a 1 GB safety margin under the platform cap. */\nexport const DEFAULT_MAX_DATABASE_BYTES = 9_000_000_000;\n\n/**\n * Explicit bounded admission quotas checked by the Thread Object BEFORE admission\n * (exit gate \"resource limits are checked before admission\").\n */\nexport class CloudflareAdmissionLimitsValue extends Schema.Class<CloudflareAdmissionLimitsValue>(\n \"@effect-agent/platform-cloudflare/CloudflareAdmissionLimitsValue\",\n)({\n /** Maximum nonterminal Submissions per Thread lane before new admissions refuse. */\n maxQueueDepthPerLane: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(100_000),\n ),\n /** Maximum encoded input bytes; never above the storage per-value bound. */\n maxInputBytes: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2_000_000)),\n /** Maximum `ctx.storage.sql.databaseSize` at admission; stays under the 10 GB platform cap. */\n maxDatabaseBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(CLOUDFLARE_DATABASE_CAP_BYTES),\n ),\n}) {}\n\n/**\n * Validated Cloudflare durable runtime configuration. The producer identity of one\n * Thread Object is `{producerPrefix}:{threadId}` — stable across incarnations of\n * the same deployment, distinct across deployments — and producer-epoch fencing (not the\n * producer name) remains the correctness authority (DUR-006).\n */\nexport class CloudflareDurableRuntimeConfigValue extends Schema.Class<CloudflareDurableRuntimeConfigValue>(\n \"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfigValue\",\n)({\n deploymentId: DeploymentId,\n /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */\n producerPrefix: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n /** Submission ownership lease duration (D5); fences work across Object incarnations. */\n ownershipLeaseDuration: PositiveMillis,\n /** Base delay of the alarm re-arm backoff when a pass makes no progress. */\n alarmBackoffBase: PositiveMillis,\n /** Ceiling of the alarm re-arm backoff. */\n alarmBackoffCap: PositiveMillis,\n /**\n * The maintenance-pass scan cadence and the ceiling of every re-arm delay: nonterminal\n * work is revisited at least this often (wake/scan pairing, persistence §14).\n */\n wakeScanInterval: PositiveMillis,\n /** `awaitSettlement` ledger re-check cadence when no wake arrives. */\n settlementPollInterval: PositiveMillis,\n /** Worker ownership-lease renewal cadence during an active Attempt. */\n leaseRenewalInterval: PositiveMillis,\n /** Active-Run abort-intent poll cadence. */\n abortPollInterval: PositiveMillis,\n /** Canonical observation poll cadence of the Durable Object store. */\n observationPollInterval: NonNegativeMillis,\n /** One disposable projection backfill wave; independent of required live applyCommitted. */\n projectionDispatchTimeoutMillis: AuxiliaryDispatchMillis,\n /** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */\n maxStoredValueBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(2_000_000),\n ),\n /** Opt-in full payload/digest-chain audit while opening the store. */\n verifyOnOpen: Schema.Boolean,\n limits: CloudflareAdmissionLimitsValue,\n}) {}\n\n/** Explicit configuration authority for the assembled Cloudflare durable runtime. */\nexport class CloudflareDurableRuntimeConfig extends Context.Service<\n CloudflareDurableRuntimeConfig,\n CloudflareDurableRuntimeConfigValue\n>()(\"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfig\") {}\n\n/** Documented production defaults applied by `ThreadObject.layer`. */\nexport const CLOUDFLARE_RUNTIME_DEFAULTS = {\n ownershipLeaseDuration: Duration.toMillis(DEFAULT_OWNERSHIP_LEASE_DURATION),\n alarmBackoffBase: 100,\n alarmBackoffCap: 5_000,\n wakeScanInterval: 1_000,\n settlementPollInterval: 500,\n leaseRenewalInterval: 10_000,\n abortPollInterval: 500,\n observationPollInterval: 25,\n projectionDispatchTimeoutMillis: 30_000,\n maxStoredValueBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n verifyOnOpen: false,\n maxQueueDepthPerLane: 256,\n maxInputBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;;AAG/D,MAAa,0BAA0B,eAAe,MAAM,OAAO,oBAAoB,GAAO,CAAC;AAC/F,MAAM,oBAAoB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;;AAG3E,IAAa,gCAAb,cAAmD,OAAO,YAA2C,CAAC,CACpG,iCACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;;AAUH,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,OAAO,OAAO,SAAS;EAAC;EAAe;EAAe;CAAgB,CAAC;CACvE,QAAQ,OAAO;CACf,SAAS,OAAO;AAClB,CACF,CAAC,CAAC;CACA,IAAa,UAAU;EACrB,OACE,oDAAoD,KAAK,MAAM,GAAG,KAAK,OAAO,kCACpD,KAAK,QAAQ;CAG3C;AACF;;AAGA,MAAa,gCAAgC;;AAG7C,MAAa,6BAA6B;;;;;AAM1C,IAAa,iCAAb,cAAoD,OAAO,MACzD,kEACF,CAAC,CAAC;;CAEA,sBAAsB,OAAO,IAAI,MAC/B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAO,CACpC;;CAEA,eAAe,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,GAAG,OAAO,oBAAoB,GAAS,CAAC;;CAE9F,kBAAkB,OAAO,IAAI,MAC3B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,6BAA6B,CAC1D;AACF,CAAC,CAAC,CAAC,CAAC;;;;;;;AAQJ,IAAa,sCAAb,cAAyD,OAAO,MAC9D,uEACF,CAAC,CAAC;CACA,cAAc;;CAEd,gBAAgB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;;CAEnE,wBAAwB;;CAExB,kBAAkB;;CAElB,iBAAiB;;;;;CAKjB,kBAAkB;;CAElB,wBAAwB;;CAExB,sBAAsB;;CAEtB,mBAAmB;;CAEnB,yBAAyB;;CAEzB,iCAAiC;;CAEjC,qBAAqB,OAAO,IAAI,MAC9B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAS,CACtC;;CAEA,cAAc,OAAO;CACrB,QAAQ;AACV,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,iCAAb,cAAoD,QAAQ,QAG1D,CAAC,CAAC,kEAAkE,CAAC,CAAC,CAAC;;AAGzE,MAAa,8BAA8B;CACzC,wBAAwB,SAAS,SAAS,gCAAgC;CAC1E,kBAAkB;CAClB,iBAAiB;CACjB,kBAAkB;CAClB,wBAAwB;CACxB,sBAAsB;CACtB,mBAAmB;CACnB,yBAAyB;CACzB,iCAAiC;CACjC,qBAAqB;CACrB,cAAc;CACd,sBAAsB;CACtB,eAAe;CACf,kBAAkB;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThreadObjectNamespace, ThreadObjectRpc } from "./CloudflareBindings.mjs";
|
|
2
|
-
import { t as AdmissionLimitExceeded } from "./CloudflareConfig-
|
|
2
|
+
import { t as AdmissionLimitExceeded } from "./CloudflareConfig-D472JOQA.mjs";
|
|
3
3
|
import { DurableAlarmError } from "./Alarm.mjs";
|
|
4
4
|
import { Context, Crypto, Effect, Layer, Schema } from "effect";
|
|
5
5
|
import { DurableSubmitAgent, DurableSubmitOptions, Receipt } from "effect-agent/durable-agent-runtime";
|
|
@@ -454,13 +454,13 @@ declare const encodeUnknownResolutionCommand: (input: UnknownResolutionCommand,
|
|
|
454
454
|
readonly author: string;
|
|
455
455
|
readonly reason: string;
|
|
456
456
|
readonly resolution: {
|
|
457
|
+
readonly _tag: "SafeToRetry";
|
|
458
|
+
} | {
|
|
457
459
|
readonly _tag: "CompletedWithResult";
|
|
458
460
|
readonly result: Schema.Json;
|
|
459
461
|
readonly isFailure: boolean;
|
|
460
462
|
} | {
|
|
461
463
|
readonly _tag: "NeverHappened";
|
|
462
|
-
} | {
|
|
463
|
-
readonly _tag: "SafeToRetry";
|
|
464
464
|
} | {
|
|
465
465
|
readonly _tag: "AbortSubmission";
|
|
466
466
|
};
|
|
@@ -596,6 +596,11 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
596
596
|
readonly createdAt: string;
|
|
597
597
|
readonly deploymentId: string;
|
|
598
598
|
readonly payload: {
|
|
599
|
+
readonly _tag: "AbortRequested";
|
|
600
|
+
readonly submissionId: string;
|
|
601
|
+
readonly author: string;
|
|
602
|
+
readonly reason: string;
|
|
603
|
+
} | {
|
|
599
604
|
readonly _tag: "ThreadCreated";
|
|
600
605
|
readonly agentId: string;
|
|
601
606
|
readonly definitions: {
|
|
@@ -853,11 +858,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
853
858
|
readonly runDisposition?: Schema.Json | undefined;
|
|
854
859
|
readonly finishReason?: "budget-exhausted" | undefined;
|
|
855
860
|
readonly exhausted?: "tokens" | "tool-calls" | "turns" | undefined;
|
|
856
|
-
} | {
|
|
857
|
-
readonly _tag: "AbortRequested";
|
|
858
|
-
readonly submissionId: string;
|
|
859
|
-
readonly author: string;
|
|
860
|
-
readonly reason: string;
|
|
861
861
|
} | {
|
|
862
862
|
readonly _tag: "SubmissionSettled";
|
|
863
863
|
readonly submissionId: string;
|
|
@@ -1346,13 +1346,13 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1346
1346
|
readonly author: string;
|
|
1347
1347
|
readonly reason: string;
|
|
1348
1348
|
readonly resolution: {
|
|
1349
|
+
readonly _tag: "SafeToRetry";
|
|
1350
|
+
} | {
|
|
1349
1351
|
readonly _tag: "CompletedWithResult";
|
|
1350
1352
|
readonly result: Schema.Json;
|
|
1351
1353
|
readonly isFailure: boolean;
|
|
1352
1354
|
} | {
|
|
1353
1355
|
readonly _tag: "NeverHappened";
|
|
1354
|
-
} | {
|
|
1355
|
-
readonly _tag: "SafeToRetry";
|
|
1356
1356
|
} | {
|
|
1357
1357
|
readonly _tag: "AbortSubmission";
|
|
1358
1358
|
};
|
|
@@ -1362,21 +1362,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1362
1362
|
} | {
|
|
1363
1363
|
readonly _tag: "HostFailed";
|
|
1364
1364
|
readonly failure: {
|
|
1365
|
-
readonly _tag: "HostProtocolError";
|
|
1366
|
-
readonly message: string;
|
|
1367
|
-
} | {
|
|
1368
|
-
readonly _tag: "DurableAlarmError";
|
|
1369
|
-
readonly operation: string;
|
|
1370
|
-
readonly message: string;
|
|
1371
|
-
readonly cause?: Schema.Json | undefined;
|
|
1372
|
-
} | {
|
|
1373
|
-
readonly _tag: "AgentInputError";
|
|
1374
|
-
readonly message: string;
|
|
1375
|
-
} | {
|
|
1376
|
-
readonly _tag: "DigestError";
|
|
1377
|
-
readonly message: string;
|
|
1378
|
-
readonly cause?: Schema.Json | undefined;
|
|
1379
|
-
} | {
|
|
1380
1365
|
readonly _tag: "AdmissionConflict";
|
|
1381
1366
|
readonly threadId: string;
|
|
1382
1367
|
readonly principal: string;
|
|
@@ -1391,15 +1376,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1391
1376
|
readonly _tag: "SettlementConflict";
|
|
1392
1377
|
readonly submissionId: string;
|
|
1393
1378
|
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
1394
|
-
} | {
|
|
1395
|
-
readonly _tag: "ApprovalConflict";
|
|
1396
|
-
readonly submissionId: string;
|
|
1397
|
-
readonly toolCallId: string;
|
|
1398
|
-
readonly existingDecision: "approved" | "denied";
|
|
1399
|
-
} | {
|
|
1400
|
-
readonly _tag: "UnknownResolutionConflict";
|
|
1401
|
-
readonly submissionId: string;
|
|
1402
|
-
readonly toolCallId: string;
|
|
1403
1379
|
} | {
|
|
1404
1380
|
readonly _tag: "JoinedToHost";
|
|
1405
1381
|
readonly submissionId: string;
|
|
@@ -1429,6 +1405,21 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1429
1405
|
readonly threadId: string;
|
|
1430
1406
|
readonly actualEpoch: number;
|
|
1431
1407
|
readonly attemptedEpoch: number;
|
|
1408
|
+
} | {
|
|
1409
|
+
readonly _tag: "DurableAlarmError";
|
|
1410
|
+
readonly operation: string;
|
|
1411
|
+
readonly message: string;
|
|
1412
|
+
readonly cause?: Schema.Json | undefined;
|
|
1413
|
+
} | {
|
|
1414
|
+
readonly _tag: "HostProtocolError";
|
|
1415
|
+
readonly message: string;
|
|
1416
|
+
} | {
|
|
1417
|
+
readonly _tag: "AgentInputError";
|
|
1418
|
+
readonly message: string;
|
|
1419
|
+
} | {
|
|
1420
|
+
readonly _tag: "DigestError";
|
|
1421
|
+
readonly message: string;
|
|
1422
|
+
readonly cause?: Schema.Json | undefined;
|
|
1432
1423
|
} | {
|
|
1433
1424
|
readonly _tag: "DurableRuntimeFailpointError";
|
|
1434
1425
|
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "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" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
@@ -1443,6 +1434,15 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1443
1434
|
readonly reason: string;
|
|
1444
1435
|
readonly threadId?: string | undefined;
|
|
1445
1436
|
readonly submissionId?: string | undefined;
|
|
1437
|
+
} | {
|
|
1438
|
+
readonly _tag: "ApprovalConflict";
|
|
1439
|
+
readonly submissionId: string;
|
|
1440
|
+
readonly toolCallId: string;
|
|
1441
|
+
readonly existingDecision: "approved" | "denied";
|
|
1442
|
+
} | {
|
|
1443
|
+
readonly _tag: "UnknownResolutionConflict";
|
|
1444
|
+
readonly submissionId: string;
|
|
1445
|
+
readonly toolCallId: string;
|
|
1446
1446
|
};
|
|
1447
1447
|
}, Schema.SchemaError, never>;
|
|
1448
1448
|
declare const decodeHostResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AbortRecorded | ApprovalRecorded | HostFailed | ObservedPage | ProgressCancelled | ProgressObserved | SettlementReached | SubmissionStatusResponse | SubmitSucceeded | UnknownResolutionRecorded, Schema.SchemaError, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObjectContext, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement } from "./CloudflareBindings.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { l as CloudflarePlatformConfigError, s as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded } from "./CloudflareConfig-D472JOQA.mjs";
|
|
3
3
|
import { DurableAlarmError, DurableAlarmService, ThreadMaintenance, ThreadMaintenanceFailpoint, ThreadMaintenanceFailpointHandler, ThreadMutationGate, ThreadPublication } from "./Alarm.mjs";
|
|
4
4
|
import { HostProtocolError, SubmitRequest } from "./CloudflareThreadClient.mjs";
|
|
5
5
|
import { Context, Crypto, Effect, Layer, Option, Schema, Scope } from "effect";
|
|
@@ -71,6 +71,8 @@ interface CloudflareDurableRuntimeOptions {
|
|
|
71
71
|
readonly toolFailureObserver?: RunToolFailureObserver | undefined;
|
|
72
72
|
/** Milliseconds; default 25. */
|
|
73
73
|
readonly observationPollInterval?: number | undefined;
|
|
74
|
+
/** Whole disposable projection wave in milliseconds, 1..300000; default 30000. */
|
|
75
|
+
readonly projectionDispatchTimeoutMillis?: number | undefined;
|
|
74
76
|
/** Bytes; default just under the 2 MB platform value limit. */
|
|
75
77
|
readonly maxStoredValueBytes?: number | undefined;
|
|
76
78
|
/** Default false. */
|
|
@@ -344,13 +346,13 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
344
346
|
readonly author: string;
|
|
345
347
|
readonly reason: string;
|
|
346
348
|
readonly resolution: {
|
|
347
|
-
readonly _tag: "SafeToRetry";
|
|
348
|
-
} | {
|
|
349
349
|
readonly _tag: "CompletedWithResult";
|
|
350
350
|
readonly result: Schema.Json;
|
|
351
351
|
readonly isFailure: boolean;
|
|
352
352
|
} | {
|
|
353
353
|
readonly _tag: "NeverHappened";
|
|
354
|
+
} | {
|
|
355
|
+
readonly _tag: "SafeToRetry";
|
|
354
356
|
} | {
|
|
355
357
|
readonly _tag: "AbortSubmission";
|
|
356
358
|
};
|
|
@@ -690,7 +692,10 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
690
692
|
} | {
|
|
691
693
|
readonly _tag: "AdminFailed";
|
|
692
694
|
readonly failure: {
|
|
693
|
-
readonly _tag: "
|
|
695
|
+
readonly _tag: "HostProtocolError";
|
|
696
|
+
readonly message: string;
|
|
697
|
+
} | {
|
|
698
|
+
readonly _tag: "LedgerError";
|
|
694
699
|
readonly operation: string;
|
|
695
700
|
readonly message: string;
|
|
696
701
|
readonly cause?: Schema.Json | undefined;
|
|
@@ -699,34 +704,37 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
699
704
|
readonly reason: "occupied" | "refused" | "unavailable";
|
|
700
705
|
readonly code: string;
|
|
701
706
|
} | {
|
|
702
|
-
readonly _tag: "
|
|
703
|
-
readonly
|
|
704
|
-
readonly
|
|
707
|
+
readonly _tag: "AppendConflict";
|
|
708
|
+
readonly threadId: string;
|
|
709
|
+
readonly batchId: string;
|
|
710
|
+
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
711
|
+
readonly actualTailSequence?: number | undefined;
|
|
712
|
+
readonly actualTailDigest?: string | undefined;
|
|
705
713
|
} | {
|
|
706
|
-
readonly _tag: "
|
|
707
|
-
readonly operation: string;
|
|
714
|
+
readonly _tag: "DigestError";
|
|
708
715
|
readonly message: string;
|
|
709
716
|
readonly cause?: Schema.Json | undefined;
|
|
710
717
|
} | {
|
|
711
|
-
readonly _tag: "
|
|
718
|
+
readonly _tag: "DurableAlarmError";
|
|
712
719
|
readonly operation: string;
|
|
713
720
|
readonly message: string;
|
|
714
721
|
readonly cause?: Schema.Json | undefined;
|
|
715
722
|
} | {
|
|
716
|
-
readonly _tag: "
|
|
717
|
-
readonly
|
|
718
|
-
} | {
|
|
719
|
-
readonly _tag: "AppendConflict";
|
|
720
|
-
readonly threadId: string;
|
|
721
|
-
readonly batchId: string;
|
|
722
|
-
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
723
|
-
readonly actualTailSequence?: number | undefined;
|
|
724
|
-
readonly actualTailDigest?: string | undefined;
|
|
723
|
+
readonly _tag: "DurableRuntimeFailpointError";
|
|
724
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "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" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
725
725
|
} | {
|
|
726
726
|
readonly _tag: "FenceRejected";
|
|
727
727
|
readonly threadId: string;
|
|
728
728
|
readonly actualEpoch: number;
|
|
729
729
|
readonly attemptedEpoch: number;
|
|
730
|
+
} | {
|
|
731
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
732
|
+
readonly threadId: string;
|
|
733
|
+
} | {
|
|
734
|
+
readonly _tag: "ThreadStoreError";
|
|
735
|
+
readonly operation: string;
|
|
736
|
+
readonly message: string;
|
|
737
|
+
readonly cause?: Schema.Json | undefined;
|
|
730
738
|
} | {
|
|
731
739
|
readonly _tag: "OperationDenied";
|
|
732
740
|
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
@@ -734,29 +742,23 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
734
742
|
readonly threadId?: string | undefined;
|
|
735
743
|
readonly submissionId?: string | undefined;
|
|
736
744
|
} | {
|
|
737
|
-
readonly _tag: "
|
|
738
|
-
readonly message: string;
|
|
739
|
-
readonly cause?: Schema.Json | undefined;
|
|
740
|
-
} | {
|
|
741
|
-
readonly _tag: "DurableRuntimeFailpointError";
|
|
742
|
-
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "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" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "update:after-canonical-append" | "update:after-delivery-insert" | "update:before-canonical-append" | "update:before-delivery-insert" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
743
|
-
} | {
|
|
744
|
-
readonly _tag: "OwnershipLost";
|
|
745
|
+
readonly _tag: "RetryRefused";
|
|
745
746
|
readonly submissionId: string;
|
|
746
|
-
readonly
|
|
747
|
+
readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
|
|
748
|
+
readonly decisionTag: string;
|
|
749
|
+
readonly message: string;
|
|
747
750
|
} | {
|
|
748
751
|
readonly _tag: "RunJournalError";
|
|
749
752
|
readonly message: string;
|
|
750
753
|
readonly cause?: Schema.Json | undefined;
|
|
751
754
|
} | {
|
|
752
|
-
readonly _tag: "
|
|
753
|
-
readonly
|
|
755
|
+
readonly _tag: "OwnershipLost";
|
|
756
|
+
readonly submissionId: string;
|
|
757
|
+
readonly actualEpoch: number;
|
|
754
758
|
} | {
|
|
755
|
-
readonly _tag: "
|
|
759
|
+
readonly _tag: "SettlementConflict";
|
|
756
760
|
readonly submissionId: string;
|
|
757
|
-
readonly
|
|
758
|
-
readonly decisionTag: string;
|
|
759
|
-
readonly message: string;
|
|
761
|
+
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
760
762
|
};
|
|
761
763
|
}, Schema.SchemaError, never>;
|
|
762
764
|
declare const decodeAdminResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<AdminFailed | ExplainedRecovery | ObligationsScanned | RetryExecuted | VerifiedIntegrity, Schema.SchemaError, never>;
|
|
@@ -809,4 +811,4 @@ interface Class<EventServices = never> {
|
|
|
809
811
|
declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError>) => Class<ApplicationServices | EventServices>;
|
|
810
812
|
//#endregion
|
|
811
813
|
export { ThreadPublicationOptions as A, portCall as C, CloudflareDurableRuntimeOptions as D, CloudflareDurableRuntimeInitializationError as E, layerConfig as M, layerHostConfig as N, CloudflareDurableRuntimeServices as O, layerInHost as P, make as S, CloudflareBootstrapServices as T, decodeAdminVerifyRequest as _, AdminVerifyRequest as a, encodeAdminResponse as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminResponse as g, decodeAdminExplainRequest as h, AdminResponse as i, layer as j, ThreadObjectPorts 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, decodeObligationThresholds as v, submit as w, handleRpc as x, decodeRetryCommand as y };
|
|
812
|
-
//# sourceMappingURL=ThreadObject-
|
|
814
|
+
//# sourceMappingURL=ThreadObject-CZxuDWOb.d.mts.map
|
|
@@ -5,7 +5,7 @@ import { DurableAlarmError, DurableAlarmService, ThreadMaintenance, ThreadMainte
|
|
|
5
5
|
import { AbortRecorded, ApprovalRecorded, CloudflareThreadClient, HostFailed, HostProtocolError, ObservedPage, ProgressCancelled, ProgressObserved, SettlementReached, SubmissionStatusResponse, SubmitSucceeded, UnknownResolutionRecorded, boundHostDiagnostic, decodeAbortCommand, decodeApprovalDecisionCommand, decodeAwaitProgressRequest, decodeCancelProgressRequest, decodeObservePageRequest, decodeReceipt, decodeSubmitRequest, decodeUnknownResolutionCommand, encodeHostResponse } from "./CloudflareThreadClient.mjs";
|
|
6
6
|
import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-DU0_T-ev.mjs";
|
|
7
7
|
import { cloudflareWakeSchedulerLayer } from "./WakeScheduler.mjs";
|
|
8
|
-
import { Cause, Clock, Context, Deferred, Duration, Effect, Layer, Option, Ref, Schema, Semaphore, Stream } from "effect";
|
|
8
|
+
import { Cause, Clock, Context, DateTime, Deferred, Duration, Effect, Fiber, Layer, Option, Ref, Schema, Semaphore, Stream } from "effect";
|
|
9
9
|
import { compileRegistrations } from "effect-agent/agent-registration";
|
|
10
10
|
import { DurableAgentRuntime, DurableRuntimeConfig, RecoveryReport } from "effect-agent/durable-agent-runtime";
|
|
11
11
|
import { SubmissionId, ThreadId } from "effect-agent/identifiers";
|
|
@@ -75,27 +75,44 @@ const guardedMessageDeliveryStoreLayer = Layer.effect(MessageDeliveryStore, Effe
|
|
|
75
75
|
const threadMessageDeliveryLayer = Layer.effectContext(Effect.gen(function* () {
|
|
76
76
|
const driver = yield* MessageDeliveryDriver;
|
|
77
77
|
const store = yield* MessageDeliveryStore;
|
|
78
|
-
const wakes = yield* WakeScheduler;
|
|
79
|
-
const config = yield* CloudflareDurableRuntimeConfig;
|
|
80
78
|
const failure = (operation) => () => DurableAlarmError.make({
|
|
81
79
|
operation,
|
|
82
80
|
message: "Durable message recovery remains pending"
|
|
83
81
|
});
|
|
84
|
-
const
|
|
82
|
+
const wakes = yield* WakeScheduler;
|
|
83
|
+
const prepare = Effect.gen(function* () {
|
|
85
84
|
const deadline = yield* store.nextDeadline();
|
|
86
|
-
if (deadline
|
|
87
|
-
|
|
85
|
+
if (deadline === null || deadline > (yield* Clock.currentTimeMillis)) return {
|
|
86
|
+
timeoutMillis: 1,
|
|
87
|
+
run: Effect.void
|
|
88
|
+
};
|
|
89
|
+
const keys = yield* store.due(yield* Clock.currentTimeMillis, 4);
|
|
90
|
+
const records = yield* Effect.forEach(keys, (key) => store.get(key));
|
|
91
|
+
return {
|
|
92
|
+
timeoutMillis: Math.max(1, ...records.map((record) => record?.policy.attemptTimeoutMillis ?? 1)),
|
|
93
|
+
run: Effect.forEach(keys, (key) => driver.process(key), {
|
|
94
|
+
concurrency: 4,
|
|
95
|
+
discard: true
|
|
96
|
+
}).pipe(Effect.mapError(failure("dispatch message delivery")))
|
|
97
|
+
};
|
|
98
|
+
}).pipe(Effect.mapError(failure("prepare message delivery")));
|
|
88
99
|
return Context.make(ThreadMessageDelivery, {
|
|
89
|
-
|
|
90
|
-
drainUntil: Effect.fn("ThreadMessageDelivery.drainUntil")(function* (finished) {
|
|
100
|
+
drainUntil: (sourceFinished, dispatchUntil) => Effect.gen(function* () {
|
|
91
101
|
const notified = (yield* Stream.toPull(wakes.wakes)).pipe(Effect.catch(() => Effect.never));
|
|
92
|
-
yield* Effect.
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
const done = yield* Effect.forkScoped(sourceFinished);
|
|
103
|
+
const select = (initial = false) => Effect.gen(function* () {
|
|
104
|
+
const wave = yield* prepare;
|
|
105
|
+
const now = yield* Clock.currentTimeMillis;
|
|
106
|
+
if (!initial && done.pollUnsafe() !== void 0 || now + wave.timeoutMillis > DateTime.toEpochMillis(dispatchUntil)) return;
|
|
107
|
+
yield* wave.run;
|
|
108
|
+
});
|
|
109
|
+
yield* select(true);
|
|
110
|
+
while (done.pollUnsafe() === void 0) {
|
|
111
|
+
const wake = yield* Effect.raceFirst(notified.pipe(Effect.map(Option.some)), Fiber.join(done).pipe(Effect.as(Option.none())));
|
|
112
|
+
if (Option.isNone(wake)) return;
|
|
113
|
+
yield* Effect.forEach(wake.value, () => select(), { discard: true });
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
99
116
|
pendingDeadline: store.nextDeadline().pipe(Effect.map(Option.fromNullishOr), Effect.mapError(failure("read message deadline")))
|
|
100
117
|
});
|
|
101
118
|
}));
|
|
@@ -203,6 +220,7 @@ const configFromOptions = (options) => decodeConfigValue({
|
|
|
203
220
|
leaseRenewalInterval: options.leaseRenewalInterval ?? CLOUDFLARE_RUNTIME_DEFAULTS.leaseRenewalInterval,
|
|
204
221
|
abortPollInterval: options.abortPollInterval ?? CLOUDFLARE_RUNTIME_DEFAULTS.abortPollInterval,
|
|
205
222
|
observationPollInterval: options.observationPollInterval ?? CLOUDFLARE_RUNTIME_DEFAULTS.observationPollInterval,
|
|
223
|
+
projectionDispatchTimeoutMillis: options.projectionDispatchTimeoutMillis ?? CLOUDFLARE_RUNTIME_DEFAULTS.projectionDispatchTimeoutMillis,
|
|
206
224
|
maxStoredValueBytes: options.maxStoredValueBytes ?? CLOUDFLARE_RUNTIME_DEFAULTS.maxStoredValueBytes,
|
|
207
225
|
verifyOnOpen: options.verifyOnOpen ?? CLOUDFLARE_RUNTIME_DEFAULTS.verifyOnOpen,
|
|
208
226
|
limits: {
|
|
@@ -832,4 +850,4 @@ const make = (applicationLayer, options) => {
|
|
|
832
850
|
//#endregion
|
|
833
851
|
export { layer as C, layerInHost as E, ThreadObjectPorts as S, layerHostConfig as T, encodeAdminResponse as _, AdminVerifyRequest as a, portCall as b, RetryExecuted as c, VerifiedIntegrity as d, decodeAdminExplainRequest as f, decodeRetryCommand as g, decodeObligationThresholds as h, AdminResponse as i, ThreadObject_exports as l, decodeAdminVerifyRequest as m, AdminFailed as n, ExplainedRecovery as o, decodeAdminResponse as p, AdminFailure as r, ObligationsScanned as s, AdminExplainRequest as t, ThreadRpcOperation as u, handleRpc as v, layerConfig as w, submit as x, make as y };
|
|
834
852
|
|
|
835
|
-
//# sourceMappingURL=ThreadObject-
|
|
853
|
+
//# sourceMappingURL=ThreadObject-DXavwaU-.mjs.map
|