effect-cf 0.27.0 → 0.28.1

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +6 -0
  3. package/dist/{Artifacts-DcoXcRP5.d.mts → Artifacts-DnHQA-Ax.d.mts} +42 -25
  4. package/dist/{Artifacts-BhWrdyqX.mjs → Artifacts-rq3hUKQE.mjs} +46 -30
  5. package/dist/{Binding-COCtoJXa.d.mts → Binding-xJJJPmiD.d.mts} +6 -5
  6. package/dist/ComputerArtifacts.d.mts +1 -1
  7. package/dist/ComputerArtifacts.mjs +9 -9
  8. package/dist/ComputerWorkspace.d.mts +5 -5
  9. package/dist/ComputerWorkspace.mjs +107 -75
  10. package/dist/ComputerWorkspaceHost.d.mts +1 -1
  11. package/dist/ComputerWorkspaceHost.mjs +18 -16
  12. package/dist/{DurableObjectState-Dux8KfjG.mjs → DurableObjectState-BjkK2kwH.mjs} +3 -3
  13. package/dist/{DurableObjectState-biHrHwrh.d.mts → DurableObjectState-OupNMMUl.d.mts} +89 -64
  14. package/dist/{ErrorMessage-_lg53p3W.mjs → ErrorMessage-BM0K-Nik.mjs} +1 -4
  15. package/dist/{Hyperdrive-6p59yyVk.d.mts → Hyperdrive-z-9fFz15.d.mts} +2 -2
  16. package/dist/HyperdrivePg.d.mts +2 -2
  17. package/dist/Vitest.d.mts +6 -5
  18. package/dist/Vitest.mjs +2 -2
  19. package/dist/{WorkflowBinding-zlRPCXVf.d.mts → WorkflowBinding-DUZtKCVM.d.mts} +5 -10
  20. package/dist/index.d.mts +88 -62
  21. package/dist/index.mjs +291 -181
  22. package/package.json +1 -1
  23. package/src/AiGateway.ts +62 -7
  24. package/src/AnalyticsEngine.ts +17 -13
  25. package/src/Artifacts.ts +111 -47
  26. package/src/Binding.ts +34 -23
  27. package/src/BrowserRendering.ts +72 -33
  28. package/src/CloudflareOtlp.ts +21 -11
  29. package/src/ComputerArtifacts.ts +17 -9
  30. package/src/ComputerWorkspace.ts +202 -98
  31. package/src/ComputerWorkspaceHost.ts +55 -27
  32. package/src/ContainerNamespace.ts +8 -9
  33. package/src/D1.ts +8 -14
  34. package/src/DurableObject.ts +33 -13
  35. package/src/DurableObjectAlarm.ts +17 -5
  36. package/src/DurableObjectDefinition.ts +89 -72
  37. package/src/DurableObjectNamespace.ts +26 -12
  38. package/src/DurableObjectRpcWebSocket.ts +9 -10
  39. package/src/DurableObjectState.ts +1 -0
  40. package/src/DurableObjectStorage.ts +5 -2
  41. package/src/DurableObjectWebSocket.ts +4 -1
  42. package/src/Email.ts +26 -25
  43. package/src/Hyperdrive.ts +4 -10
  44. package/src/Images.ts +12 -14
  45. package/src/Kv.ts +15 -17
  46. package/src/Queue.ts +2 -1
  47. package/src/QueueBinding.ts +7 -12
  48. package/src/QueueDefinition.ts +7 -2
  49. package/src/R2.ts +33 -24
  50. package/src/Rpc.ts +15 -21
  51. package/src/RpcDefinition.ts +33 -38
  52. package/src/ServiceBinding.ts +26 -8
  53. package/src/Vectorize.ts +45 -18
  54. package/src/Vitest.ts +9 -3
  55. package/src/WebTransport.ts +11 -5
  56. package/src/Worker.ts +97 -24
  57. package/src/WorkerDefinition.ts +143 -63
  58. package/src/WorkersAi.ts +50 -28
  59. package/src/Workflow.ts +66 -13
  60. package/src/WorkflowBinding.ts +18 -25
  61. package/src/WorkflowDefinition.ts +4 -2
  62. package/src/internal/Entrypoint.ts +29 -13
  63. package/src/internal/ErrorMessage.ts +7 -6
  64. package/src/internal/RpcInvocation.ts +34 -11
  65. package/src/internal/Runtime.ts +33 -22
  66. package/src/internal/Telemetry.ts +17 -10
  67. package/src/internal/WorkerContext.ts +3 -3
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { a as WorkerEnvironment, i as WorkerConfig, n as violationsMessage, r as Environment_exports, t as causeMessage } from "./ErrorMessage-_lg53p3W.mjs";
3
- import { a as layer$19, i as Service$2, n as Artifacts_exports, r as Binding_exports } from "./Artifacts-BhWrdyqX.mjs";
4
- import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-Dux8KfjG.mjs";
5
- import { Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
2
+ import { a as WorkerEnvironment, i as WorkerConfig, n as violationsMessage, r as Environment_exports, t as causeMessage } from "./ErrorMessage-BM0K-Nik.mjs";
3
+ import { a as layer$19, i as Service$2, n as Artifacts_exports, r as Binding_exports } from "./Artifacts-rq3hUKQE.mjs";
4
+ import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-BjkK2kwH.mjs";
5
+ import { Cause, Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function as Function$1, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
6
6
  import { FetchHttpClient, HttpClient, HttpClientRequest, HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
7
7
  import { OtlpExporter, OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
8
8
  import { D1Client } from "@effect/sql-d1";
@@ -11,6 +11,7 @@ import * as RpcMessage from "effect/unstable/rpc/RpcMessage";
11
11
  import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
12
12
  import * as RpcServer from "effect/unstable/rpc/RpcServer";
13
13
  import { SqliteClient } from "@effect/sql-sqlite-do";
14
+ import { NonRetryableError } from "cloudflare:workflows";
14
15
  //#region src/WorkersAi.ts
15
16
  var WorkersAi_exports = /* @__PURE__ */ __exportAll({
16
17
  Tag: () => Tag$16,
@@ -28,6 +29,7 @@ var WorkersAiOperationError = class extends Data.TaggedError("WorkersAiOperation
28
29
  return `Workers AI ${this.operation} failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
29
30
  }
30
31
  };
32
+ const embeddingDimensionsKey = "shape";
31
33
  const workersAiError = (binding, operation, cause) => new WorkersAiOperationError({
32
34
  binding,
33
35
  operation,
@@ -41,19 +43,31 @@ const tryWorkersAiSync = (binding, operation, evaluate) => Effect.try({
41
43
  try: evaluate,
42
44
  catch: (cause) => workersAiError(binding, operation, cause)
43
45
  });
44
- const hasFunction$3 = (value, key) => typeof Reflect.get(value, key) === "function";
45
- const isWorkersAiBinding = (value) => typeof value === "object" && value !== null && hasFunction$3(value, "run") && hasFunction$3(value, "gateway") && hasFunction$3(value, "models");
46
+ const WorkersAiBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "run") && Predicate.isFunction(value.run) && Predicate.hasProperty(value, "gateway") && Predicate.isFunction(value.gateway) && Predicate.hasProperty(value, "models") && Predicate.isFunction(value.models));
47
+ const decodeWorkersAiBinding = Schema.decodeUnknownOption(WorkersAiBindingSchema);
48
+ const isWorkersAiBinding = (value) => Option.isSome(decodeWorkersAiBinding(value));
46
49
  const embeddingResponse = (value) => ({
47
50
  data: value.data ?? [],
48
- shape: value.shape ?? []
51
+ [embeddingDimensionsKey]: value[embeddingDimensionsKey] ?? []
49
52
  });
53
+ const decodeEmbeddingResponse = Schema.decodeUnknownOption(Schema.Struct({
54
+ data: Schema.optional(Schema.Array(Schema.Array(Schema.Number))),
55
+ [embeddingDimensionsKey]: Schema.optional(Schema.Array(Schema.Number))
56
+ }));
50
57
  const makeClient$15 = (definition) => (ai) => {
51
- const run = Effect.fn("WorkersAi.run")((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () => ai.run(model, input, options)));
58
+ const run = Effect.fn("WorkersAi.run")((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () => {
59
+ return ai.run(model, input, options);
60
+ }));
52
61
  return {
53
62
  definition,
54
63
  aiGatewayLogId: tryWorkersAiSync(definition.binding, "aiGatewayLogId", () => ai.aiGatewayLogId),
55
64
  run,
56
- runEmbedding: Effect.fn("WorkersAi.runEmbedding")((model, input, options) => run(model, input, options).pipe(Effect.map((response) => embeddingResponse(response)))),
65
+ runEmbedding: Effect.fn("WorkersAi.runEmbedding")((model, input, options) => {
66
+ return run(model, input, options).pipe(Effect.map((response) => Option.match(decodeEmbeddingResponse(response), {
67
+ onNone: () => embeddingResponse({}),
68
+ onSome: embeddingResponse
69
+ })));
70
+ }),
57
71
  models: Effect.fn("WorkersAi.models")((params) => tryWorkersAiPromise(definition.binding, "models", () => ai.models(params))),
58
72
  gateway: (gatewayId) => tryWorkersAiSync(definition.binding, "gateway", () => ai.gateway(gatewayId)),
59
73
  rawUnsafe: Effect.succeed(ai)
@@ -88,6 +102,49 @@ var AiGatewayOperationError = class extends Data.TaggedError("AiGatewayOperation
88
102
  return `AI Gateway ${this.operation} failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
89
103
  }
90
104
  };
105
+ const AiGatewayMetadata = Schema.Record(Schema.String, Schema.Union([
106
+ Schema.String,
107
+ Schema.Number,
108
+ Schema.Boolean,
109
+ Schema.Null
110
+ ]));
111
+ const AiGatewayHttpMetadata = Schema.Union([AiGatewayMetadata, Schema.fromJsonString(AiGatewayMetadata)]);
112
+ const AiGatewayLogResponse = Schema.Struct({
113
+ success: Schema.Literal(true),
114
+ result: Schema.Struct({
115
+ id: Schema.String,
116
+ provider: Schema.String,
117
+ model: Schema.String,
118
+ model_type: Schema.optional(Schema.String),
119
+ path: Schema.String,
120
+ duration: Schema.Number,
121
+ request_type: Schema.optional(Schema.String),
122
+ request_content_type: Schema.optional(Schema.String),
123
+ status_code: Schema.Number,
124
+ response_content_type: Schema.optional(Schema.String),
125
+ success: Schema.Boolean,
126
+ cached: Schema.Boolean,
127
+ tokens_in: Schema.optional(Schema.Number),
128
+ tokens_out: Schema.optional(Schema.Number),
129
+ metadata: Schema.optional(AiGatewayHttpMetadata),
130
+ step: Schema.optional(Schema.Number),
131
+ cost: Schema.optional(Schema.Number),
132
+ custom_cost: Schema.optional(Schema.Boolean),
133
+ request_size: Schema.Number,
134
+ request_head: Schema.optional(Schema.String),
135
+ request_head_complete: Schema.Boolean,
136
+ response_size: Schema.Number,
137
+ response_head: Schema.optional(Schema.String),
138
+ response_head_complete: Schema.Boolean,
139
+ created_at: Schema.DateFromString
140
+ })
141
+ });
142
+ const AiGatewayPatchLogResponse = Schema.Struct({
143
+ success: Schema.Literal(true),
144
+ result: Schema.Unknown
145
+ });
146
+ const decodeAiGatewayLogResponse = Schema.decodeUnknownPromise(AiGatewayLogResponse);
147
+ const decodeAiGatewayPatchLogResponse = Schema.decodeUnknownPromise(AiGatewayPatchLogResponse);
91
148
  const aiGatewayError = (binding, operation, cause) => new AiGatewayOperationError({
92
149
  binding,
93
150
  operation,
@@ -108,6 +165,9 @@ const providerUrl = (baseUrl, path = "") => {
108
165
  return normalizedPath === "" ? url : new URL(normalizedPath, url);
109
166
  };
110
167
  const gatewayUrl = (definition) => `https://gateway.ai.cloudflare.com/v1/${definition.accountId}/${definition.gatewayId}/`;
168
+ const ensureSuccessfulResponse = (response) => {
169
+ if (!response.ok) throw new Error(`AI Gateway HTTP request failed with status ${response.status}`);
170
+ };
111
171
  const isAiGatewayBinding = (value) => isWorkersAiBinding(value);
112
172
  const makeClient$14 = (definition, gateway) => ({
113
173
  definition,
@@ -165,14 +225,20 @@ const makeHttpClient = (definition, request = fetch) => {
165
225
  ...options.init,
166
226
  signal: mergeAbortSignals(options.init?.signal, signal)
167
227
  }))))),
168
- patchLog: Effect.fn("AiGateway.patchLog")((logId, data) => tryAiGatewayPromise(binding, "patchLog", (signal) => request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, {
169
- method: "PATCH",
170
- body: JSON.stringify(data),
171
- headers: { "content-type": "application/json" },
172
- signal
173
- }).then(() => void 0))),
228
+ patchLog: Effect.fn("AiGateway.patchLog")((logId, data) => tryAiGatewayPromise(binding, "patchLog", async (signal) => {
229
+ const response = await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, {
230
+ method: "PATCH",
231
+ body: JSON.stringify(data),
232
+ headers: { "content-type": "application/json" },
233
+ signal
234
+ });
235
+ ensureSuccessfulResponse(response);
236
+ await decodeAiGatewayPatchLogResponse(await response.json());
237
+ })),
174
238
  getLog: Effect.fn("AiGateway.getLog")((logId) => tryAiGatewayPromise(binding, "getLog", async (signal) => {
175
- return await (await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, { signal })).json();
239
+ const response = await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, { signal });
240
+ ensureSuccessfulResponse(response);
241
+ return (await decodeAiGatewayLogResponse(await response.json())).result;
176
242
  })),
177
243
  rawUnsafe: Effect.fail(aiGatewayError(binding, "rawUnsafe", /* @__PURE__ */ new TypeError("HTTP AI Gateway clients have no raw binding")))
178
244
  };
@@ -281,7 +347,7 @@ const fieldPath = (prefix, field) => prefix === "" ? field : `${prefix}.${field}
281
347
  const indexedPath = (prefix, field, index) => `${fieldPath(prefix, field)}[${index}]`;
282
348
  const byteLength$1 = (value) => {
283
349
  if (value === null) return 0;
284
- return typeof value === "string" ? textEncoder$1.encode(value).byteLength : value.byteLength;
350
+ return Predicate.isString(value) ? textEncoder$1.encode(value).byteLength : value.byteLength;
285
351
  };
286
352
  const lengthViolation = (path, label, actual, limit) => ({
287
353
  path,
@@ -308,11 +374,13 @@ const schemaViolation = (pathPrefix, cause) => ({
308
374
  path: pathPrefix === "" ? "$" : pathPrefix,
309
375
  message: cause.message
310
376
  });
311
- const toAnalyticsEngineDataPoint = (dataPoint) => ({
312
- ...dataPoint.indexes === void 0 ? {} : { indexes: [...dataPoint.indexes] },
313
- ...dataPoint.doubles === void 0 ? {} : { doubles: [...dataPoint.doubles] },
314
- ...dataPoint.blobs === void 0 ? {} : { blobs: [...dataPoint.blobs] }
315
- });
377
+ const toAnalyticsEngineDataPoint = (dataPoint) => {
378
+ const result = {};
379
+ if (dataPoint.indexes !== void 0) result.indexes = [...dataPoint.indexes];
380
+ if (dataPoint.doubles !== void 0) result.doubles = [...dataPoint.doubles];
381
+ if (dataPoint.blobs !== void 0) result.blobs = [...dataPoint.blobs];
382
+ return result;
383
+ };
316
384
  const validateDataPoint = (binding, operation, dataPoint, pathPrefix = "") => Effect.gen(function* () {
317
385
  const decoded = yield* decodeDataPoint(dataPoint).pipe(Effect.mapError((cause) => analyticsEngineWriteValidationError(binding, operation, [schemaViolation(pathPrefix, cause)], cause)));
318
386
  const validated = toAnalyticsEngineDataPoint(decoded);
@@ -387,10 +455,7 @@ const makeQueryClientWith = (definition, httpClient) => {
387
455
  };
388
456
  };
389
457
  const makeQueryClient = (definition) => Effect.map(HttpClient.HttpClient, (httpClient) => makeQueryClientWith(definition, httpClient));
390
- const isAnalyticsEngineDataset = (value) => {
391
- if (typeof value !== "object" || value === null) return false;
392
- return typeof Reflect.get(value, "writeDataPoint") === "function";
393
- };
458
+ const isAnalyticsEngineDataset = (value) => Predicate.hasProperty(value, "writeDataPoint") && Predicate.isFunction(value.writeDataPoint);
394
459
  const makeClient$13 = (definition, defaults) => (dataset) => {
395
460
  return {
396
461
  definition,
@@ -482,9 +547,18 @@ const wrapPage = (binding, page) => ({
482
547
  goto: (url, options) => page.goto === void 0 ? missingMethod(binding, "goto") : tryBrowserRenderingPromise(binding, "goto", () => page.goto(url, options)),
483
548
  setContent: (html, options) => page.setContent === void 0 ? missingMethod(binding, "setContent") : tryBrowserRenderingPromise(binding, "setContent", () => page.setContent(html, options)),
484
549
  content: page.content === void 0 ? missingMethod(binding, "content") : tryBrowserRenderingPromise(binding, "content", () => page.content()),
485
- screenshot: (options) => page.screenshot === void 0 ? missingMethod(binding, "screenshot") : tryBrowserRenderingPromise(binding, "screenshot", () => page.screenshot(options)),
486
- pdf: (options) => page.pdf === void 0 ? missingMethod(binding, "pdf") : tryBrowserRenderingPromise(binding, "pdf", () => page.pdf(options)),
487
- evaluate: (pageFunction, ...args) => page.evaluate === void 0 ? missingMethod(binding, "evaluate") : tryBrowserRenderingPromise(binding, "evaluate", () => page.evaluate(pageFunction, ...args)),
550
+ screenshot: (options) => {
551
+ const screenshot = page.screenshot?.bind(page);
552
+ return screenshot === void 0 ? missingMethod(binding, "screenshot") : tryBrowserRenderingPromise(binding, "screenshot", () => screenshot(options));
553
+ },
554
+ pdf: (options) => {
555
+ const pdf = page.pdf?.bind(page);
556
+ return pdf === void 0 ? missingMethod(binding, "pdf") : tryBrowserRenderingPromise(binding, "pdf", () => pdf(options));
557
+ },
558
+ evaluate: (pageFunction, ...args) => {
559
+ const evaluate = page.evaluate?.bind(page);
560
+ return evaluate === void 0 ? missingMethod(binding, "evaluate") : tryBrowserRenderingPromise(binding, "evaluate", () => evaluate(pageFunction, ...args));
561
+ },
488
562
  close: (options) => page.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closePage", () => page.close(options))
489
563
  });
490
564
  const wrapBrowser = (binding, browser) => ({
@@ -494,7 +568,7 @@ const wrapBrowser = (binding, browser) => ({
494
568
  close: browser.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closeBrowser", () => browser.close()),
495
569
  disconnect: browser.disconnect === void 0 ? Effect.void : tryBrowserRenderingSync(binding, "disconnect", () => browser.disconnect())
496
570
  });
497
- const isBrowserRenderingBinding = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
571
+ const isBrowserRenderingBinding = (value) => Predicate.isObjectOrArray(value) || Predicate.isFunction(value);
498
572
  const makeClient$12 = (definition) => (binding) => ({
499
573
  definition,
500
574
  launchWith: (launch, options) => tryBrowserRenderingPromise(definition.binding, "launch", () => launch(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser)), Effect.withSpan("BrowserRendering.launchWith")),
@@ -569,16 +643,23 @@ const layer$14 = Layer.sync(CacheStorage, () => makeClient$11(caches));
569
643
  * telemetry on demand. Cloudflare isolates can freeze before the periodic
570
644
  * export interval fires. Effect-backed Worker fetch handlers, Worker or
571
645
  * Durable Object native RPC handlers, and Durable Object alarm handlers
572
- * schedule this flusher automatically.
573
- * Flush or scheduling failures do not replace the handler outcome and emit
574
- * only bounded framework diagnostics without attaching the foreign cause.
575
- * Other entrypoint lifecycles can flush explicitly or hand the flush to their
576
- * `waitUntil` mechanism:
646
+ * schedule this flusher automatically. These automatic flushes are capped at
647
+ * two seconds and silently discard timeouts and failures so telemetry cannot
648
+ * extend or fail the user event, or recursively log through an unhealthy
649
+ * exporter.
650
+ *
651
+ * Other entrypoint lifecycles, including queue handlers, do not flush
652
+ * automatically. Applications can flush explicitly or hand the flush to their
653
+ * `waitUntil` mechanism, and own the timeout and failure policy at that call
654
+ * site:
577
655
  *
578
656
  * ```ts
579
657
  * const flusher = yield* OtlpExporter.Flusher;
580
658
  *
581
- * yield* flusher.flush;
659
+ * yield* flusher.flush.pipe(
660
+ * Effect.timeoutOption("2 seconds"),
661
+ * Effect.ignoreCause,
662
+ * );
582
663
  * ```
583
664
  */
584
665
  var CloudflareOtlp_exports = /* @__PURE__ */ __exportAll({
@@ -768,7 +849,7 @@ const makeInstanceClient = (definition, instance, stub) => {
768
849
  removeDeniedHost: hostnameOperation("removeDeniedHost")
769
850
  };
770
851
  };
771
- const isContainerNamespaceResource = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "getByName") === "function";
852
+ const isContainerNamespaceResource = (value) => Predicate.hasProperty(value, "getByName") && Predicate.isFunction(value.getByName);
772
853
  const makeClient$10 = (definition) => (namespace) => {
773
854
  const getByName = (name, options) => Effect.try({
774
855
  try: () => makeInstanceClient(definition, name, namespace.getByName(name, options)),
@@ -805,7 +886,7 @@ const makeClient$10 = (definition) => (namespace) => {
805
886
  rawUnsafe: Effect.succeed(namespace)
806
887
  };
807
888
  };
808
- const layer$12 = (tag, definition) => layer$19(tag, definition.binding, isContainerNamespaceResource, makeClient$10(definition), { expected: expectedContainerNamespace });
889
+ const layer$12 = (tag, definition) => layer$19(tag, definition.binding, (value) => isContainerNamespaceResource(value), makeClient$10(definition), { expected: expectedContainerNamespace });
809
890
  const make$14 = (id) => Tag$12()(id);
810
891
  /** Creates a typed Effect service for a Cloudflare Container namespace. */
811
892
  const Tag$12 = () => (id) => {
@@ -848,11 +929,7 @@ var D1_exports = /* @__PURE__ */ __exportAll({
848
929
  });
849
930
  const TypeId$2 = "~effect-cf/D1";
850
931
  const expectedD1Database = "D1 database binding with prepare(), batch(), and exec()";
851
- const isD1Database = (value) => {
852
- if (typeof value !== "object" || value === null) return false;
853
- const resource = value;
854
- return typeof resource.prepare === "function" && typeof resource.batch === "function" && typeof resource.exec === "function";
855
- };
932
+ const isD1Database = (value) => Predicate.hasProperty(value, "prepare") && Predicate.isFunction(value.prepare) && Predicate.hasProperty(value, "batch") && Predicate.isFunction(value.batch) && Predicate.hasProperty(value, "exec") && Predicate.isFunction(value.exec);
856
933
  /**
857
934
  * Creates a typed D1 service tag plus Effect helpers.
858
935
  */
@@ -906,10 +983,7 @@ const tryQueuePromise = (binding, operation, evaluate) => Effect.tryPromise({
906
983
  message: `Cloudflare queue binding "${binding}" operation "${operation}" failed`
907
984
  })
908
985
  });
909
- const isQueue = (value) => {
910
- if (typeof value !== "object" || value === null) return false;
911
- return typeof value.send === "function";
912
- };
986
+ const isQueue = (value) => Predicate.hasProperty(value, "send") && Predicate.isFunction(value.send);
913
987
  const makeClient$9 = (definition) => {
914
988
  const encodeMessage = Schema.encodeEffect(definition.message);
915
989
  return (queue) => ({
@@ -1142,7 +1216,7 @@ const encodeWireError = (error) => {
1142
1216
  const decodeWireError = (cause) => {
1143
1217
  if (!(cause instanceof Error)) return cause;
1144
1218
  try {
1145
- const parsed = JSON.parse(cause.message);
1219
+ const parsed = Schema.decodeUnknownSync(Schema.Unknown)(JSON.parse(cause.message));
1146
1220
  if (!Predicate.hasProperty(parsed, wireErrorKey)) return cause;
1147
1221
  return Schema.decodeUnknownSync(WireErrorSchema)(parsed[wireErrorKey]);
1148
1222
  } catch {
@@ -1235,6 +1309,10 @@ const make$11 = (id, methods) => {
1235
1309
  };
1236
1310
  //#endregion
1237
1311
  //#region src/internal/Entrypoint.ts
1312
+ const invokeEntrypointRpcMethod = (self, method, args, run, onExit) => {
1313
+ const handler = Effect.suspend(() => method(...args)).pipe(Effect.mapError(encodeWireError));
1314
+ return run(self, onExit === void 0 ? handler : handler.pipe(Effect.onExit(() => onExit(self))));
1315
+ };
1238
1316
  const provideEntrypointServices = (layer, services) => layer.pipe(Layer.provideMerge(services));
1239
1317
  const defineEntrypointRpcMethods = (target, prototype, rpc, reservedMethodNames, run, onExit) => {
1240
1318
  const methods = rpc ?? {};
@@ -1242,12 +1320,13 @@ const defineEntrypointRpcMethods = (target, prototype, rpc, reservedMethodNames,
1242
1320
  for (const [key, method] of Object.entries(methods)) Object.defineProperty(prototype, key, {
1243
1321
  enumerable: true,
1244
1322
  value(...args) {
1245
- const handler = Effect.suspend(() => method(...args)).pipe(Effect.mapError(encodeWireError));
1246
- return run(this, onExit === void 0 ? handler : handler.pipe(Effect.onExit(() => onExit(this))));
1323
+ return invokeEntrypointRpcMethod(this, method, args, run, onExit);
1247
1324
  }
1248
1325
  });
1249
1326
  };
1250
- const assumeEntrypointClass = (entrypoint) => entrypoint;
1327
+ const assumeEntrypointClass = (entrypoint) => {
1328
+ return entrypoint;
1329
+ };
1251
1330
  //#endregion
1252
1331
  //#region src/internal/Runtime.ts
1253
1332
  /**
@@ -1263,30 +1342,27 @@ const makeEntrypointRuntime = (layer, env, services) => {
1263
1342
  const entrypointServices = Layer.mergeAll(services, ConfigProvider.layer(WorkerConfig.providerFromEnv(env)), Layer.succeed(WorkerEnvironment, env));
1264
1343
  return ManagedRuntime.make(provideEntrypointServices(layer, entrypointServices));
1265
1344
  };
1266
- /**
1267
- * Runs a Cloudflare event effect on an entrypoint runtime.
1268
- *
1269
- * When an event layer is given it is built inside the event's Effect scope
1270
- * (finalized when the event effect completes). The casts widen away the
1271
- * `REvent` requirement satisfied by the event layer; TypeScript cannot reduce
1272
- * `Exclude<...>` over the generic union.
1273
- */
1274
- const runEventPromise = (runtime, effect, eventLayer) => {
1275
- const withEventLayer = eventLayer === void 0 ? effect : effect.pipe(Effect.provide(eventLayer, { local: true }));
1276
- return runtime.runPromise(Effect.scoped(withEventLayer));
1277
- };
1345
+ function runEventPromise(...args) {
1346
+ const [runtime, effect, eventLayer] = args;
1347
+ if (eventLayer === void 0) return runtime.runPromise(Effect.scoped(effect));
1348
+ return runtime.runPromise(Effect.scoped(effect.pipe(Effect.provide(eventLayer, { local: true }))));
1349
+ }
1278
1350
  //#endregion
1279
1351
  //#region src/internal/Telemetry.ts
1280
- const logFlushFailure = Effect.logError("Telemetry flush failed").pipe(Effect.ignoreCause);
1281
- const logFlushSchedulingFailure = Effect.logError("Telemetry flush scheduling failed").pipe(Effect.ignoreCause);
1352
+ /** Maximum event lifetime spent on an internally scheduled telemetry flush. */
1353
+ const scheduledFlushTimeout = "2 seconds";
1282
1354
  /**
1283
1355
  * Schedules a configured OTLP flusher through the current Cloudflare event.
1356
+ *
1357
+ * The handed-off effect is best-effort: it settles within two seconds and
1358
+ * silently absorbs every failure cause so telemetry cannot extend or fail the
1359
+ * user event, or recursively log through an unhealthy exporter.
1284
1360
  */
1285
1361
  const scheduleTelemetryFlush$2 = (waitUntil) => Effect.gen(function* () {
1286
1362
  const flusher = yield* Effect.serviceOption(OtlpExporter.Flusher);
1287
1363
  if (Option.isNone(flusher)) return;
1288
- yield* waitUntil(flusher.value.flush.pipe(Effect.catchCause(() => logFlushFailure)));
1289
- }).pipe(Effect.catchCause(() => logFlushSchedulingFailure));
1364
+ yield* waitUntil(flusher.value.flush.pipe(Effect.timeoutOption(scheduledFlushTimeout), Effect.ignoreCause, Effect.asVoid));
1365
+ }).pipe(Effect.ignoreCause);
1290
1366
  //#endregion
1291
1367
  //#region src/Rpc.ts
1292
1368
  var Rpc_exports = /* @__PURE__ */ __exportAll({
@@ -1297,25 +1373,30 @@ var Rpc_exports = /* @__PURE__ */ __exportAll({
1297
1373
  resolve: () => resolve,
1298
1374
  scoped: () => scoped
1299
1375
  });
1300
- const isDisposable = (value) => (typeof value === "object" || typeof value === "function") && value !== null && Symbol.dispose in value && typeof value[Symbol.dispose] === "function";
1376
+ const isDisposable = (value) => Predicate.hasProperty(value, Symbol.dispose) && Predicate.isFunction(value[Symbol.dispose]);
1301
1377
  const dispose = (value) => Effect.sync(() => {
1302
1378
  if (isDisposable(value)) value[Symbol.dispose]();
1303
1379
  });
1304
- const resolve = (value) => isPromiseLike(value) ? Effect.tryPromise({
1305
- try: () => value,
1380
+ const resolve = (value) => Predicate.isPromiseLike(value) ? Effect.tryPromise({
1381
+ try: () => Promise.resolve(value),
1306
1382
  catch: (cause) => decodeWireError(cause)
1307
- }) : Effect.sync(() => value);
1383
+ }) : Effect.sync(() => {
1384
+ return value;
1385
+ });
1308
1386
  const scoped = (value) => Effect.acquireRelease(resolve(value), (resolved) => dispose(resolved));
1309
- const isPromiseLike = (value) => (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
1310
1387
  //#endregion
1311
1388
  //#region src/internal/RpcInvocation.ts
1312
- const isPropertyTarget = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
1389
+ const invokeWithReceiver = (value, receiver, args) => {
1390
+ return Function.prototype.apply.call(value, receiver, args);
1391
+ };
1313
1392
  const lookupRpcMethod = (target, method, makeError) => Effect.try({
1314
1393
  try: () => {
1315
- if (!isPropertyTarget(target)) throw new TypeError(`RPC target is not object-like`);
1316
- const value = Reflect.get(target, method);
1317
- if (typeof value !== "function") throw new TypeError(`RPC method "${String(method)}" is not callable`);
1318
- return ((...args) => Reflect.apply(value, target, args));
1394
+ if (!Predicate.isObjectKeyword(target)) throw new TypeError(`RPC target is not object-like`);
1395
+ const receiver = target;
1396
+ const value = receiver[method];
1397
+ if (!Predicate.isFunction(value)) throw new TypeError(`RPC method "${String(method)}" is not callable`);
1398
+ const callable = value;
1399
+ return (...args) => invokeWithReceiver(callable, receiver, args);
1319
1400
  },
1320
1401
  catch: makeError
1321
1402
  });
@@ -1355,7 +1436,9 @@ var ServiceBindingRpcError = class extends Data.TaggedError("ServiceBindingRpcEr
1355
1436
  return `Service binding "${this.binding}" RPC method "${this.method}" failed: ${causeMessage(this.cause)}`;
1356
1437
  }
1357
1438
  };
1358
- const isServiceBindingClient = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fetch") === "function";
1439
+ const ServiceBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "fetch") && Predicate.isFunction(value.fetch));
1440
+ const decodeServiceBinding = Schema.decodeUnknownOption(ServiceBindingSchema);
1441
+ const isServiceBindingClient = (value) => Option.isSome(decodeServiceBinding(value));
1359
1442
  const makeClient$8 = (definition) => {
1360
1443
  return (service) => {
1361
1444
  const fetch = Effect.fn("ServiceBinding.fetch")(function* (input, init) {
@@ -1468,7 +1551,10 @@ const Service = () => (id, definition) => {
1468
1551
  };
1469
1552
  const makeDirectMethods$1 = (rpcDefinition, call) => {
1470
1553
  const methods = {};
1471
- if (rpcDefinition !== void 0) for (const methodName of Object.keys(rpcDefinition.methods)) methods[methodName] = (...args) => call(methodName, ...args);
1554
+ if (rpcDefinition !== void 0) {
1555
+ const invoke = call;
1556
+ for (const methodName of Object.keys(rpcDefinition.methods)) methods[methodName] = (...args) => invoke(methodName, ...args);
1557
+ }
1472
1558
  return methods;
1473
1559
  };
1474
1560
  //#endregion
@@ -1496,6 +1582,9 @@ const reservedMethodNames$3 = /* @__PURE__ */ new Set([
1496
1582
  "webSocketClose",
1497
1583
  "webSocketError"
1498
1584
  ]);
1585
+ const assumeTagClass = (value) => {
1586
+ return value;
1587
+ };
1499
1588
  /**
1500
1589
  * Defines a single RPC method schema in a worker definition.
1501
1590
  */
@@ -1516,10 +1605,14 @@ const method$1 = method$2;
1516
1605
  const makeDefinition$3 = (id, methods) => {
1517
1606
  assertNoReservedMethods("Worker", methods, reservedMethodNames$3);
1518
1607
  const definition = make$11(id, methods);
1519
- return Object.assign(definition, { make: (layer, options) => make$9(layer, {
1520
- ...options,
1521
- rpc: wrapHandlers$1(definition, options.rpc)
1522
- }) });
1608
+ return Object.assign(definition, { make: (layer, options) => {
1609
+ const workerOptions = {
1610
+ ...options,
1611
+ rpc: wrapHandlers$1(definition, options.rpc)
1612
+ };
1613
+ if (workerOptions.eventLayer === void 0) return make$9(layer, workerOptions);
1614
+ return make$9(layer, workerOptions);
1615
+ } });
1523
1616
  };
1524
1617
  const make$10 = (id, methods) => Tag$9()(id, methods);
1525
1618
  const Tag$9 = () => (id, methods) => {
@@ -1543,7 +1636,7 @@ const Tag$9 = () => (id, methods) => {
1543
1636
  return yield* (yield* tag).scopedCall(method, ...args);
1544
1637
  });
1545
1638
  const directMethods = makeDirectMethods$1(definition, call);
1546
- return Object.assign(tag, directMethods, {
1639
+ return assumeTagClass(Object.assign(tag, directMethods, {
1547
1640
  id: definition.id,
1548
1641
  methods: definition.methods,
1549
1642
  make: definition.make,
@@ -1552,11 +1645,11 @@ const Tag$9 = () => (id, methods) => {
1552
1645
  rpc,
1553
1646
  call,
1554
1647
  scopedCall
1555
- });
1648
+ }));
1556
1649
  };
1557
1650
  const Worker = Tag$9;
1558
1651
  const wrapHandlers$1 = (definition, handlers) => {
1559
- const wrapped = {};
1652
+ const wrapped = Object.create(null);
1560
1653
  for (const key of Object.keys(definition.methods)) {
1561
1654
  const handler = handlers[key];
1562
1655
  wrapped[key] = (...args) => Effect.gen(function* () {
@@ -1655,7 +1748,8 @@ const isWorkerOptions = (options) => !Effect.isEffect(options);
1655
1748
  *
1656
1749
  * The flush is handed to `ctx.waitUntil` so it never delays the response
1657
1750
  * (including streaming bodies still being consumed). It is a no-op when the
1658
- * context does not contain an `OtlpExporter.Flusher`.
1751
+ * context does not contain an `OtlpExporter.Flusher`. The handed-off effect is
1752
+ * best-effort and silently settles within two seconds.
1659
1753
  */
1660
1754
  const scheduleTelemetryFlush$1 = scheduleTelemetryFlush$2((flush) => Effect.flatMap(WorkerContext, (workerContext) => workerContext.waitUntil(flush)));
1661
1755
  function make$9(layer, optionsOrFetch) {
@@ -1666,8 +1760,10 @@ function make$9(layer, optionsOrFetch) {
1666
1760
  super(ctx, env);
1667
1761
  this.runtime = makeEntrypointRuntime(layer, env, Layer.mergeAll(Layer.succeed(ExecutionContext, ctx), Layer.succeed(WorkerContext, fromExecutionContext(ctx))));
1668
1762
  }
1669
- [RunSymbol$1](effect, runOptions = {}) {
1670
- return runEventPromise(this.runtime, effect, runOptions.eventLayer === false ? void 0 : options.eventLayer);
1763
+ [RunSymbol$1](effect) {
1764
+ const eventLayer = options.eventLayer;
1765
+ if (eventLayer === void 0) return runEventPromise(this.runtime, effect);
1766
+ return runEventPromise(this.runtime, effect, eventLayer);
1671
1767
  }
1672
1768
  fetch(request) {
1673
1769
  return this[FetchSymbol](request);
@@ -1689,19 +1785,8 @@ function make$9(layer, optionsOrFetch) {
1689
1785
  defineEntrypointRpcMethods("Worker", EffectWorker.prototype, options.rpc, reservedMethodNames$2, (self, effect) => self[RunSymbol$1](effect), () => scheduleTelemetryFlush$1);
1690
1786
  return assumeEntrypointClass(EffectWorker);
1691
1787
  }
1692
- /**
1693
- * Creates an `ExportedHandler`-compatible `{ fetch }` object backed by
1694
- * {@link make}.
1695
- *
1696
- * The Effect runtime is cached per `env` identity, so the user layer builds
1697
- * once per isolate instead of once per request. `ExecutionContext`-backed
1698
- * services (`Worker.ExecutionContext`, `Worker.WorkerContext`) are still
1699
- * provided fresh for every request. Layer finalizers do not run when the
1700
- * isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
1701
- * for resources that must be finalized per event.
1702
- */
1703
- const makeFetchHandler = (layer, options) => {
1704
- const WorkerClass = make$9(layer, options);
1788
+ function makeFetchHandler(layer, options) {
1789
+ const WorkerClass = options.eventLayer === void 0 ? make$9(layer, options) : make$9(layer, options);
1705
1790
  const instances = /* @__PURE__ */ new WeakMap();
1706
1791
  return { fetch: (request, env, ctx) => {
1707
1792
  let instance = instances.get(env);
@@ -1711,7 +1796,7 @@ const makeFetchHandler = (layer, options) => {
1711
1796
  }
1712
1797
  return instance[FetchSymbol](request, ctx);
1713
1798
  } };
1714
- };
1799
+ }
1715
1800
  //#endregion
1716
1801
  //#region src/DurableObjectNamespace.ts
1717
1802
  var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
@@ -1739,8 +1824,8 @@ var DurableObjectFetchError = class extends Data.TaggedError("DurableObjectFetch
1739
1824
  return `Durable Object fetch failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
1740
1825
  }
1741
1826
  };
1742
- const hasFunction$2 = (value, key) => typeof Reflect.get(value, key) === "function";
1743
- const isDurableObjectNamespaceClient = (value) => typeof value === "object" && value !== null && hasFunction$2(value, "getByName") && hasFunction$2(value, "get") && hasFunction$2(value, "idFromName") && hasFunction$2(value, "idFromString") && hasFunction$2(value, "newUniqueId") && hasFunction$2(value, "jurisdiction");
1827
+ const hasFunction$1 = (value, key) => Predicate.hasProperty(value, key) && Predicate.isFunction(value[key]);
1828
+ const isDurableObjectNamespaceClient = (value) => hasFunction$1(value, "getByName") && hasFunction$1(value, "get") && hasFunction$1(value, "idFromName") && hasFunction$1(value, "idFromString") && hasFunction$1(value, "newUniqueId") && hasFunction$1(value, "jurisdiction");
1744
1829
  const makeClient$7 = (definition) => {
1745
1830
  return (namespace) => {
1746
1831
  const newUniqueId = (options) => Effect.sync(() => namespace.newUniqueId(options));
@@ -1852,10 +1937,9 @@ const reservedMethodNames$1 = /* @__PURE__ */ new Set([
1852
1937
  "webSocketClose",
1853
1938
  "webSocketError"
1854
1939
  ]);
1855
- /**
1856
- * Defines a single RPC method schema in a Durable Object definition.
1857
- */
1858
- const method = method$2;
1940
+ function method(definition) {
1941
+ return method$2(definition);
1942
+ }
1859
1943
  /**
1860
1944
  * Creates a Durable Object RPC definition plus implementation/binding helpers.
1861
1945
  *
@@ -1908,14 +1992,17 @@ const Tag$8 = () => (id, methods) => {
1908
1992
  const fetch = Effect.fn("DurableObject.fetch")(function* (stub, input, init) {
1909
1993
  return yield* (yield* tag).fetch(stub, input, init);
1910
1994
  });
1911
- const rpc = Effect.fn("DurableObject.rpc")(function* (stub, method, ...args) {
1912
- return yield* (yield* tag).rpc(stub, method, ...args);
1995
+ const rpc = Effect.fn("DurableObject.rpc")(function* (stub, methodName, ...args) {
1996
+ const invokeRpc = (yield* tag).rpc;
1997
+ return yield* invokeRpc(stub, methodName, ...args);
1913
1998
  });
1914
- const call = Effect.fn("DurableObject.call")(function* (stub, method, ...args) {
1915
- return yield* (yield* tag).call(stub, method, ...args);
1999
+ const call = Effect.fn("DurableObject.call")(function* (stub, methodName, ...args) {
2000
+ const invokeCall = (yield* tag).call;
2001
+ return yield* invokeCall(stub, methodName, ...args);
1916
2002
  });
1917
- const scopedCall = Effect.fn("DurableObject.scopedCall")(function* (stub, method, ...args) {
1918
- return yield* (yield* tag).scopedCall(stub, method, ...args);
2003
+ const scopedCall = Effect.fn("DurableObject.scopedCall")(function* (stub, methodName, ...args) {
2004
+ const invokeScopedCall = (yield* tag).scopedCall;
2005
+ return yield* invokeScopedCall(stub, methodName, ...args);
1919
2006
  });
1920
2007
  const rawUnsafe = Effect.fnUntraced(function* () {
1921
2008
  return yield* (yield* tag).rawUnsafe;
@@ -1946,7 +2033,7 @@ const Tag$8 = () => (id, methods) => {
1946
2033
  };
1947
2034
  const DurableObject$1 = Tag$8;
1948
2035
  const wrapHandlers = (definition, handlers) => {
1949
- const wrapped = {};
2036
+ const wrapped = Object.create(Object.prototype);
1950
2037
  for (const key of Object.keys(definition.methods)) {
1951
2038
  const handler = handlers[key];
1952
2039
  wrapped[key] = (...args) => Effect.gen(function* () {
@@ -1993,7 +2080,9 @@ const make$7 = (layer, options = {}) => {
1993
2080
  if (initialize !== void 0) state.waitUntil(this[RunSymbol](initialize, { eventLayer: false }));
1994
2081
  }
1995
2082
  [RunSymbol](effect, runOptions = {}) {
1996
- return runEventPromise(this.runtime, effect, runOptions.eventLayer === false ? void 0 : options.eventLayer);
2083
+ const eventLayer = runOptions.eventLayer === false ? void 0 : options.eventLayer;
2084
+ if (eventLayer === void 0) return runEventPromise(this.runtime, effect);
2085
+ return runEventPromise(this.runtime, effect, eventLayer);
1997
2086
  }
1998
2087
  fetch(request) {
1999
2088
  const fetchHandler = options.fetch;
@@ -2015,8 +2104,8 @@ const make$7 = (layer, options = {}) => {
2015
2104
  webSocketClose(socket, code, reason, wasClean) {
2016
2105
  if (options.webSocketClose !== void 0) return this[RunSymbol](options.webSocketClose(fromWebSocket(socket), code, reason, wasClean));
2017
2106
  }
2018
- webSocketError(socket, error) {
2019
- if (options.webSocketError !== void 0) return this[RunSymbol](options.webSocketError(fromWebSocket(socket), error));
2107
+ webSocketError(socket, cause) {
2108
+ if (options.webSocketError !== void 0) return this[RunSymbol](options.webSocketError(fromWebSocket(socket), cause));
2020
2109
  }
2021
2110
  }
2022
2111
  defineEntrypointRpcMethods("Durable Object", EffectDurableObject.prototype, options.rpc, reservedMethodNames, (self, effect) => self[RunSymbol](effect), () => scheduleTelemetryFlush);
@@ -2152,12 +2241,12 @@ const toFailureRescheduleMillis = (input) => Effect.try({
2152
2241
  catch: (cause) => new InvalidProcessDueAlarmsOptionsError({ cause })
2153
2242
  });
2154
2243
  const getFailureRetryDelay = (options) => toFailureRescheduleMillis(options?.retryFailedAfter ?? DEFAULT_PROCESS_DUE_ALARMS_FAILURE_RESCHEDULE_AFTER);
2155
- const getFailureActionMode = (action) => typeof action === "string" ? action : action.mode;
2156
- const getFailureActionRetryDelay = (action) => typeof action === "string" || action.mode !== "retry" ? void 0 : action.retryFailedAfter;
2244
+ const getFailureActionMode = (action) => Predicate.isString(action) ? action : action.mode;
2245
+ const getFailureActionRetryDelay = (action) => Predicate.isString(action) || action.mode !== "retry" ? void 0 : action.retryFailedAfter;
2157
2246
  const processDue = (handle, options = {}) => Effect.gen(function* () {
2158
2247
  return yield* (yield* DurableObjectAlarm).processDueAlarms(handle, options);
2159
2248
  });
2160
- const isAlarmDefinitionConfig = (definition) => typeof definition === "object" && definition !== null && "payload" in definition;
2249
+ const isAlarmDefinitionConfig = (definition) => Predicate.isObject(definition) && "payload" in definition;
2161
2250
  const getAlarmDefinitionSchema = (definition) => isAlarmDefinitionConfig(definition) ? definition.payload : definition;
2162
2251
  const getAlarmDefinitionFailureAction = (definition) => {
2163
2252
  if (definition === void 0 || !isAlarmDefinitionConfig(definition)) return;
@@ -2470,21 +2559,21 @@ const layer$8 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
2470
2559
  return Predicate.isTagged(cause, "MaxBufferSizeExceeded") ? Effect.ignore(connection.socket.close(1009, String(cause))) : send(connection, RpcMessage.ResponseDefectEncoded(cause));
2471
2560
  })),
2472
2561
  close: unregister,
2473
- error: (socket, error) => Effect.gen(function* () {
2474
- yield* Effect.logDebug("Durable Object RPC websocket error", error);
2562
+ error: (socket, cause) => Effect.gen(function* () {
2563
+ yield* Effect.logDebug("Durable Object RPC websocket error", cause);
2475
2564
  yield* unregister(socket);
2476
2565
  })
2477
2566
  });
2478
2567
  return Context.mergeAll(Context.make(RpcServer.Protocol, protocol), Context.make(DurableObjectRpcWebSocket, service));
2479
2568
  }));
2480
- const normalizeMessage = (message) => typeof message === "string" ? message : new Uint8Array(message);
2569
+ const normalizeMessage = (message) => Predicate.isString(message) ? message : new Uint8Array(message);
2481
2570
  const readAttachment = (socket, key) => {
2482
2571
  const value = socket.deserializeAttachment();
2483
- if (value !== null && typeof value === "object" && key in value && typeof value[key] === "number") return value[key];
2572
+ if (Predicate.isObjectOrArray(value) && Predicate.hasProperty(value, key) && Predicate.isNumber(value[key])) return value[key];
2484
2573
  };
2485
2574
  const writeAttachment = (socket, key, clientId) => {
2486
2575
  const current = socket.deserializeAttachment();
2487
- const attachment = current !== null && typeof current === "object" && !Array.isArray(current) ? current : {};
2576
+ const attachment = Predicate.isObject(current) ? current : {};
2488
2577
  socket.serializeAttachment({
2489
2578
  ...attachment,
2490
2579
  [key]: clientId
@@ -2590,9 +2679,9 @@ var EmailValidationError = class extends Data.TaggedError("EmailValidationError"
2590
2679
  * error and strips non-standard properties.
2591
2680
  */
2592
2681
  const emailErrorCode = (cause) => {
2593
- if (typeof cause !== "object" || cause === null) return;
2594
- const code = Reflect.get(cause, "code");
2595
- return typeof code === "string" ? code : void 0;
2682
+ if (!Predicate.isObject(cause)) return;
2683
+ const code = Predicate.hasProperty(cause, "code") ? cause.code : void 0;
2684
+ return Predicate.isString(code) ? code : void 0;
2596
2685
  };
2597
2686
  const emailError = (binding, operation, cause) => new EmailOperationError({
2598
2687
  binding,
@@ -2621,16 +2710,16 @@ const addressList = (value) => {
2621
2710
  return Array.isArray(value) ? value : [value];
2622
2711
  };
2623
2712
  const addressViolations = (path, value) => {
2624
- if (typeof value === "string") return value.includes("@") ? [] : [{
2713
+ if (Predicate.isString(value)) return value.includes("@") ? [] : [{
2625
2714
  path,
2626
2715
  message: "Email address must contain an @ symbol"
2627
2716
  }];
2628
- if (typeof value !== "object" || value === null) return [{
2717
+ if (!Predicate.isObject(value)) return [{
2629
2718
  path,
2630
2719
  message: "Email address must be a string or { name, email } object"
2631
2720
  }];
2632
- const email = Reflect.get(value, "email");
2633
- if (typeof email !== "string" || !email.includes("@")) return [{
2721
+ const email = Predicate.hasProperty(value, "email") ? value.email : void 0;
2722
+ if (!Predicate.isString(email) || !email.includes("@")) return [{
2634
2723
  path: `${path}.email`,
2635
2724
  message: "Email address must contain an @ symbol"
2636
2725
  }];
@@ -2643,18 +2732,18 @@ const attachmentViolations = (attachments) => {
2643
2732
  for (let index = 0; index < attachments.length; index++) {
2644
2733
  const attachment = attachments[index];
2645
2734
  const path = `attachments[${index}]`;
2646
- if (typeof attachment !== "object" || attachment === null) {
2735
+ if (!Predicate.isObject(attachment)) {
2647
2736
  violations.push({
2648
2737
  path,
2649
2738
  message: "Attachment must be an object"
2650
2739
  });
2651
2740
  continue;
2652
2741
  }
2653
- if (typeof attachment.filename !== "string" || attachment.filename === "") violations.push({
2742
+ if (!Predicate.isString(attachment.filename) || attachment.filename === "") violations.push({
2654
2743
  path: `${path}.filename`,
2655
2744
  message: "Attachment filename is required"
2656
2745
  });
2657
- if (typeof attachment.type !== "string" || attachment.type === "") violations.push({
2746
+ if (!Predicate.isString(attachment.type) || attachment.type === "") violations.push({
2658
2747
  path: `${path}.type`,
2659
2748
  message: "Attachment MIME type is required"
2660
2749
  });
@@ -2662,7 +2751,7 @@ const attachmentViolations = (attachments) => {
2662
2751
  path: `${path}.content`,
2663
2752
  message: "Attachment content is required"
2664
2753
  });
2665
- if (attachment.disposition === "inline" && typeof attachment.contentId !== "string") violations.push({
2754
+ if (attachment.disposition === "inline" && !Predicate.isString(attachment.contentId)) violations.push({
2666
2755
  path: `${path}.contentId`,
2667
2756
  message: "Inline attachments require a contentId"
2668
2757
  });
@@ -2678,7 +2767,7 @@ const headerViolations = (headers) => {
2678
2767
  const path = `headers["${name}"]`;
2679
2768
  const nameBytes = byteLength(name);
2680
2769
  if (nameBytes > sendLimits.maxHeaderNameBytes) violations.push(limitViolation(path, "header name bytes", nameBytes, sendLimits.maxHeaderNameBytes));
2681
- if (typeof value !== "string") {
2770
+ if (!Predicate.isString(value)) {
2682
2771
  violations.push({
2683
2772
  path,
2684
2773
  message: "Header value must be a string"
@@ -2708,11 +2797,11 @@ const validateMessage = (message) => {
2708
2797
  });
2709
2798
  else violations.push(...addressViolations("from", fields.from));
2710
2799
  if (fields.replyTo !== void 0) violations.push(...addressViolations("replyTo", fields.replyTo));
2711
- if (typeof fields.subject !== "string" || fields.subject === "") violations.push({
2800
+ if (!Predicate.isString(fields.subject) || fields.subject === "") violations.push({
2712
2801
  path: "subject",
2713
2802
  message: "A subject is required"
2714
2803
  });
2715
- if (typeof fields.text !== "string" && typeof fields.html !== "string") violations.push({
2804
+ if (!Predicate.isString(fields.text) && !Predicate.isString(fields.html)) violations.push({
2716
2805
  path: "$",
2717
2806
  message: "A message requires either text or html content"
2718
2807
  });
@@ -2733,10 +2822,7 @@ const validateSendInput = (binding, operation, message) => {
2733
2822
  const violations = validateMessage(message);
2734
2823
  return violations.length > 0 ? Effect.fail(emailValidationError(binding, operation, violations)) : Effect.succeed(message);
2735
2824
  };
2736
- const isEmailBinding = (value) => {
2737
- if (typeof value !== "object" || value === null) return false;
2738
- return typeof value.send === "function";
2739
- };
2825
+ const isEmailBinding = (value) => Predicate.hasProperty(value, "send") && Predicate.isFunction(value.send);
2740
2826
  const makeClient$6 = (definition, options) => (email) => {
2741
2827
  const runtime = email;
2742
2828
  const validate = options?.validate ?? true;
@@ -2769,10 +2855,7 @@ var Hyperdrive_exports = /* @__PURE__ */ __exportAll({
2769
2855
  makeClient: () => makeClient$5
2770
2856
  });
2771
2857
  const expectedHyperdrive = "Hyperdrive binding with connectionString";
2772
- const isHyperdrive = (value) => {
2773
- if (typeof value !== "object" || value === null) return false;
2774
- return typeof value.connectionString === "string";
2775
- };
2858
+ const isHyperdrive = (value) => Predicate.hasProperty(value, "connectionString") && Predicate.isString(value.connectionString);
2776
2859
  const makeClient$5 = (definition) => (hyperdrive) => ({
2777
2860
  definition,
2778
2861
  connectionString: hyperdrive.connectionString,
@@ -2817,8 +2900,8 @@ const makeSteps = (steps) => ({
2817
2900
  });
2818
2901
  /** Empty Images transformation pipeline. */
2819
2902
  const empty = makeSteps([]);
2820
- const transform = Function.dual(2, (steps, transformValue) => makeSteps([...steps.steps, Step.Transform({ transform: transformValue })]));
2821
- const draw = Function.dual(2, (steps, drawValue) => makeSteps([...steps.steps, Step.Draw(drawValue)]));
2903
+ const transform = Function$1.dual(2, (steps, transformValue) => makeSteps([...steps.steps, Step.Transform({ transform: transformValue })]));
2904
+ const draw = Function$1.dual(2, (steps, drawValue) => makeSteps([...steps.steps, Step.Draw(drawValue)]));
2822
2905
  const imagesError = (binding, operation, cause) => new ImagesOperationError({
2823
2906
  binding,
2824
2907
  operation,
@@ -2833,9 +2916,9 @@ const tryImagesSync = (binding, operation, evaluate) => Effect.try({
2833
2916
  catch: (cause) => imagesError(binding, operation, cause)
2834
2917
  });
2835
2918
  const maybe = (value) => value === null ? Option.none() : Option.some(value);
2836
- const hasFunction$1 = (value, key) => typeof Reflect.get(value, key) === "function";
2837
- const isHostedImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "image") && hasFunction$1(value, "upload") && hasFunction$1(value, "list");
2838
- const isImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "info") && hasFunction$1(value, "input");
2919
+ const hasFunction = (value, key) => Predicate.hasProperty(value, key) && Predicate.isFunction(value[key]);
2920
+ const isHostedImagesBinding = (value) => hasFunction(value, "image") && hasFunction(value, "upload") && hasFunction(value, "list");
2921
+ const isImagesBinding = (value) => hasFunction(value, "info") && hasFunction(value, "input");
2839
2922
  const wrapResult = (binding, result) => ({
2840
2923
  raw: result,
2841
2924
  response: tryImagesSync(binding, "response", () => result.response()),
@@ -2910,11 +2993,7 @@ const tryKvPromise = (binding, operation, evaluate) => Effect.tryPromise({
2910
2993
  try: evaluate,
2911
2994
  catch: (cause) => kvError(binding, operation, cause)
2912
2995
  });
2913
- const isKvNamespace = (value) => {
2914
- if (typeof value !== "object" || value === null) return false;
2915
- const resource = value;
2916
- return typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.delete === "function" && typeof resource.getWithMetadata === "function" && typeof resource.list === "function";
2917
- };
2996
+ const isKvNamespace = (value) => Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get) && Predicate.hasProperty(value, "put") && Predicate.isFunction(value.put) && Predicate.hasProperty(value, "delete") && Predicate.isFunction(value.delete) && Predicate.hasProperty(value, "getWithMetadata") && Predicate.isFunction(value.getWithMetadata) && Predicate.hasProperty(value, "list") && Predicate.isFunction(value.list);
2918
2997
  const makeClient$3 = (definition) => {
2919
2998
  const encodeKey = Schema.encodeEffect(definition.key);
2920
2999
  const decodeKey = Schema.decodeUnknownEffect(definition.key);
@@ -3046,7 +3125,7 @@ const spanOptions$1 = (binding, operation) => ({ attributes: {
3046
3125
  binding,
3047
3126
  operation
3048
3127
  } });
3049
- const isR2ObjectBody = (value) => "body" in value && typeof value.arrayBuffer === "function" && typeof value.bytes === "function" && typeof value.text === "function" && typeof value.json === "function" && typeof value.blob === "function";
3128
+ const isR2ObjectBody = (value) => "body" in value && Predicate.isFunction(value.arrayBuffer) && Predicate.isFunction(value.bytes) && Predicate.isFunction(value.text) && Predicate.isFunction(value.json) && Predicate.isFunction(value.blob);
3050
3129
  const wrapObjectBody = (binding, object) => ({
3051
3130
  key: object.key,
3052
3131
  version: object.version,
@@ -3076,11 +3155,9 @@ const wrapGetResult = (binding, object) => {
3076
3155
  if (object === null || !isR2ObjectBody(object)) return object;
3077
3156
  return wrapObjectBody(binding, object);
3078
3157
  };
3079
- const isR2Bucket = (value) => {
3080
- if (typeof value !== "object" || value === null) return false;
3081
- const resource = value;
3082
- return typeof resource.head === "function" && typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.createMultipartUpload === "function" && typeof resource.resumeMultipartUpload === "function" && typeof resource.delete === "function" && typeof resource.list === "function";
3083
- };
3158
+ const R2BucketSchema = Schema.declare((value) => Predicate.hasProperty(value, "head") && Predicate.isFunction(value.head) && Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get) && Predicate.hasProperty(value, "put") && Predicate.isFunction(value.put) && Predicate.hasProperty(value, "createMultipartUpload") && Predicate.isFunction(value.createMultipartUpload) && Predicate.hasProperty(value, "resumeMultipartUpload") && Predicate.isFunction(value.resumeMultipartUpload) && Predicate.hasProperty(value, "delete") && Predicate.isFunction(value.delete) && Predicate.hasProperty(value, "list") && Predicate.isFunction(value.list));
3159
+ const decodeR2Bucket = Schema.decodeUnknownOption(R2BucketSchema);
3160
+ const isR2Bucket = (value) => Option.isSome(decodeR2Bucket(value));
3084
3161
  const makeClient$2 = (definition) => {
3085
3162
  const wrapUpload = (upload) => ({
3086
3163
  raw: upload,
@@ -3104,7 +3181,7 @@ const makeClient$2 = (definition) => {
3104
3181
  createMultipartUpload: Effect.fn("R2.createMultipartUpload", spanOptions$1(definition.binding, "createMultipartUpload"))((key, options) => tryR2Promise(definition.binding, "createMultipartUpload", () => bucket.createMultipartUpload(key, options)).pipe(Effect.map(wrapUpload))),
3105
3182
  resumeMultipartUpload: Effect.fn("R2.resumeMultipartUpload", spanOptions$1(definition.binding, "resumeMultipartUpload"))((key, uploadId) => tryR2Sync(definition.binding, "resumeMultipartUpload", () => wrapUpload(bucket.resumeMultipartUpload(key, uploadId)))),
3106
3183
  delete: Effect.fn("R2.delete", spanOptions$1(definition.binding, "delete"))((keys) => {
3107
- const nativeKeys = typeof keys === "string" ? keys : [...keys];
3184
+ const nativeKeys = Predicate.isString(keys) ? keys : [...keys];
3108
3185
  return tryR2Promise(definition.binding, "delete", () => bucket.delete(nativeKeys));
3109
3186
  }),
3110
3187
  list: Effect.fn("R2.list", spanOptions$1(definition.binding, "list"))((options) => tryR2Promise(definition.binding, "list", () => bucket.list(options))),
@@ -3152,16 +3229,25 @@ const spanOptions = (binding, operation) => ({ attributes: {
3152
3229
  binding,
3153
3230
  operation
3154
3231
  } });
3155
- const hasFunction = (value, key) => typeof Reflect.get(value, key) === "function";
3156
- const isVectorizeBinding = (value) => typeof value === "object" && value !== null && hasFunction(value, "describe") && hasFunction(value, "query") && hasFunction(value, "insert") && hasFunction(value, "upsert") && hasFunction(value, "deleteByIds") && hasFunction(value, "getByIds");
3232
+ const invokeVectorizeMethod = (method, receiver, args) => {
3233
+ return Function.prototype.apply.call(method, receiver, args);
3234
+ };
3235
+ const VectorizeBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "describe") && Predicate.isFunction(value.describe) && Predicate.hasProperty(value, "query") && Predicate.isFunction(value.query) && Predicate.hasProperty(value, "insert") && Predicate.isFunction(value.insert) && Predicate.hasProperty(value, "upsert") && Predicate.isFunction(value.upsert) && Predicate.hasProperty(value, "deleteByIds") && Predicate.isFunction(value.deleteByIds) && Predicate.hasProperty(value, "getByIds") && Predicate.isFunction(value.getByIds));
3236
+ const decodeVectorizeBinding = Schema.decodeUnknownOption(VectorizeBindingSchema);
3237
+ const isVectorizeBinding = (value) => Option.isSome(decodeVectorizeBinding(value));
3157
3238
  const makeClient$1 = (definition) => (index) => {
3158
3239
  const runtime = index;
3159
3240
  const deleteByIds = Effect.fn("Vectorize.deleteByIds", spanOptions(definition.binding, "deleteByIds"))((ids) => tryVectorizePromise(definition.binding, "deleteByIds", () => runtime.deleteByIds([...ids])));
3160
3241
  return {
3161
3242
  definition,
3162
3243
  describe: tryVectorizePromise(definition.binding, "describe", () => runtime.describe()).pipe(Effect.withSpan("Vectorize.describe", spanOptions(definition.binding, "describe"))),
3163
- query: Effect.fn("Vectorize.query", spanOptions(definition.binding, "query"))((vector, options) => tryVectorizePromise(definition.binding, "query", () => runtime.query(vector, options))),
3164
- queryById: Effect.fn("Vectorize.queryById", spanOptions(definition.binding, "queryById"))((vectorId, options) => runtime.queryById !== void 0 ? tryVectorizePromise(definition.binding, "queryById", () => runtime.queryById(vectorId, options)) : Effect.fail(vectorizeError(definition.binding, "queryById", /* @__PURE__ */ new TypeError("Vectorize binding does not expose queryById()")))),
3244
+ query: Effect.fn("Vectorize.query", spanOptions(definition.binding, "query"))((vector, options) => tryVectorizePromise(definition.binding, "query", () => {
3245
+ return runtime.query(vector, options);
3246
+ })),
3247
+ queryById: Effect.fn("Vectorize.queryById", spanOptions(definition.binding, "queryById"))((vectorId, options) => runtime.queryById !== void 0 ? tryVectorizePromise(definition.binding, "queryById", () => {
3248
+ const queryById = runtime.queryById;
3249
+ return queryById === void 0 ? Promise.reject(/* @__PURE__ */ new TypeError("Vectorize binding does not expose queryById()")) : invokeVectorizeMethod(queryById, runtime, [vectorId, options]);
3250
+ }) : Effect.fail(vectorizeError(definition.binding, "queryById", /* @__PURE__ */ new TypeError("Vectorize binding does not expose queryById()")))),
3165
3251
  insert: Effect.fn("Vectorize.insert", spanOptions(definition.binding, "insert"))((vectors) => tryVectorizePromise(definition.binding, "insert", () => runtime.insert([...vectors]))),
3166
3252
  upsert: Effect.fn("Vectorize.upsert", spanOptions(definition.binding, "upsert"))((vectors) => tryVectorizePromise(definition.binding, "upsert", () => runtime.upsert([...vectors]))),
3167
3253
  deleteByIds,
@@ -3226,10 +3312,13 @@ const inboundTransport = (request) => Result.getSuccess(decodeInboundTransport(r
3226
3312
  */
3227
3313
  const isHttp3 = (transport) => transport.clientQuicRtt !== void 0 || transport.httpProtocol === "HTTP/3";
3228
3314
  /** Feature-detects the WebTransport capabilities of the current runtime. */
3229
- const capabilities = Effect.sync(() => ({
3230
- inboundSessions: false,
3231
- outboundSessions: typeof globalThis["WebTransport"] === "function"
3232
- }));
3315
+ const capabilities = Effect.sync(() => {
3316
+ const runtime = globalThis;
3317
+ return {
3318
+ inboundSessions: false,
3319
+ outboundSessions: Predicate.hasProperty(runtime, "WebTransport") && Predicate.isFunction(runtime["WebTransport"])
3320
+ };
3321
+ });
3233
3322
  /** Raised when a WebTransport capability is unavailable in this runtime. */
3234
3323
  var WebTransportUnsupportedError = class extends Data.TaggedError("WebTransportUnsupportedError") {
3235
3324
  get message() {
@@ -3274,11 +3363,9 @@ const tryWorkflowPromise = (binding, operation, evaluate) => Effect.tryPromise({
3274
3363
  try: evaluate,
3275
3364
  catch: (cause) => workflowError(binding, operation, cause)
3276
3365
  });
3277
- const isWorkflow = (value) => {
3278
- if (typeof value !== "object" || value === null) return false;
3279
- const resource = value;
3280
- return typeof resource.create === "function" && typeof resource.createBatch === "function" && typeof resource.get === "function";
3281
- };
3366
+ const WorkflowBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "create") && Predicate.isFunction(value.create) && Predicate.hasProperty(value, "createBatch") && Predicate.isFunction(value.createBatch) && Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get));
3367
+ const decodeWorkflowBinding = Schema.decodeUnknownOption(WorkflowBindingSchema);
3368
+ const isWorkflow = (value) => Option.isSome(decodeWorkflowBinding(value));
3282
3369
  const makeClient = (definition) => {
3283
3370
  const encodePayload = Schema.encodeEffect(definition.payload);
3284
3371
  const decodeResult = Schema.decodeUnknownEffect(definition.result);
@@ -3411,6 +3498,7 @@ var Workflow_exports = /* @__PURE__ */ __exportAll({
3411
3498
  WorkflowStep: () => WorkflowStep$1,
3412
3499
  WorkflowStepContext: () => WorkflowStepContext$1,
3413
3500
  WorkflowStepError: () => WorkflowStepError,
3501
+ WorkflowStepNonRetryableError: () => WorkflowStepNonRetryableError,
3414
3502
  implement: () => implement,
3415
3503
  make: () => make,
3416
3504
  sleep: () => sleep,
@@ -3426,6 +3514,17 @@ var WorkflowStepError = class extends Data.TaggedError("WorkflowStepError") {
3426
3514
  return `Workflow ${this.operation} failed${step}: ${causeMessage(this.cause)}`;
3427
3515
  }
3428
3516
  };
3517
+ /**
3518
+ * Typed step failure that Cloudflare must treat as terminal instead of retrying.
3519
+ *
3520
+ * The workflow boundary converts this value into Cloudflare's native
3521
+ * `NonRetryableError` while preserving the original cause and its message.
3522
+ */
3523
+ var WorkflowStepNonRetryableError = class extends Data.TaggedError("WorkflowStepNonRetryableError") {
3524
+ get message() {
3525
+ return `Workflow step failed without retry: ${causeMessage(this.cause)}`;
3526
+ }
3527
+ };
3429
3528
  var WorkflowStep$1 = class extends Context.Service()("effect-cf/WorkflowStep") {};
3430
3529
  var WorkflowStepContext$1 = class extends Context.Service()("effect-cf/WorkflowStepContext") {};
3431
3530
  const fromWorkflowEvent = (event) => ({
@@ -3435,11 +3534,20 @@ const fromWorkflowEvent = (event) => ({
3435
3534
  instanceId: event.instanceId,
3436
3535
  workflowName: event.workflowName
3437
3536
  });
3537
+ const toCloudflareNonRetryableError = (error) => {
3538
+ const cloudflareError = new NonRetryableError(error.message);
3539
+ cloudflareError.cause = error.cause;
3540
+ return cloudflareError;
3541
+ };
3542
+ const exposeCloudflareNonRetryableError = (effect) => Effect.catchCause(effect, (cause) => {
3543
+ const error = Cause.findErrorOption(cause);
3544
+ return Option.isSome(error) && error.value instanceof WorkflowStepNonRetryableError ? Effect.die(toCloudflareNonRetryableError(error.value)) : Effect.failCause(cause);
3545
+ });
3438
3546
  const fromWorkflowStep = (step, runPromise) => ({
3439
3547
  raw: step,
3440
3548
  do: (name, effect, config) => Effect.context().pipe(Effect.flatMap((context) => Effect.tryPromise({
3441
3549
  try: () => {
3442
- const run = (stepContext) => runPromise(Effect.scoped(Effect.provideService(Effect.provideContext(effect, context), WorkflowStepContext$1, stepContext)));
3550
+ const run = (stepContext) => runPromise(exposeCloudflareNonRetryableError(Effect.scoped(Effect.provideService(Effect.provideContext(effect, context), WorkflowStepContext$1, stepContext))));
3443
3551
  const rawStep = step;
3444
3552
  return config === void 0 ? rawStep.do(name, run) : rawStep.do(name, config, run);
3445
3553
  },
@@ -3466,7 +3574,9 @@ const fromWorkflowStep = (step, runPromise) => ({
3466
3574
  })
3467
3575
  }),
3468
3576
  waitForEvent: (name, options) => Effect.tryPromise({
3469
- try: () => step.waitForEvent(name, options),
3577
+ try: () => {
3578
+ return step.waitForEvent(name, options);
3579
+ },
3470
3580
  catch: (cause) => new WorkflowStepError({
3471
3581
  step: name,
3472
3582
  operation: "waitForEvent",