effect-cf 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,236 @@
1
1
  import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
- import { a as WorkerConfig, i as layer$11, n as Binding_exports, o as WorkerEnvironment, r as Service$2, t as Hyperdrive_exports } from "./Hyperdrive-89hg_Fck.mjs";
3
- import { Cause, Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Layer, ManagedRuntime, Option, Queue, Schema } from "effect";
2
+ import { a as WorkerConfig, i as layer$15, n as Binding_exports, o as WorkerEnvironment, r as Service$2, t as Hyperdrive_exports } from "./Hyperdrive-89hg_Fck.mjs";
3
+ import { Cause, Clock, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Layer, ManagedRuntime, Option, Queue, Schema } from "effect";
4
4
  import { FetchHttpClient, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
5
- import { Otlp, OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
5
+ import { OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
6
6
  import { D1Client } from "@effect/sql-d1";
7
7
  import { DurableObject, RpcStub, RpcTarget, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
8
8
  import * as RpcMessage from "effect/unstable/rpc/RpcMessage";
9
9
  import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
10
10
  import * as RpcServer from "effect/unstable/rpc/RpcServer";
11
11
  import { SqliteClient } from "@effect/sql-sqlite-do";
12
+ //#region src/WorkersAi.ts
13
+ var WorkersAi_exports = /* @__PURE__ */ __exportAll({
14
+ Tag: () => Tag$14,
15
+ WorkersAiOperationError: () => WorkersAiOperationError,
16
+ embeddingResponse: () => embeddingResponse,
17
+ isWorkersAiBinding: () => isWorkersAiBinding,
18
+ layer: () => layer$14,
19
+ make: () => make$14,
20
+ makeClient: () => makeClient$10
21
+ });
22
+ const expectedWorkersAiBinding = "Workers AI binding with run(), gateway(), and models()";
23
+ /** Error raised when a Workers AI operation fails. */
24
+ var WorkersAiOperationError = class extends Data.TaggedError("WorkersAiOperationError") {};
25
+ const workersAiError = (binding, operation, cause) => new WorkersAiOperationError({
26
+ binding,
27
+ operation,
28
+ cause
29
+ });
30
+ const tryWorkersAiPromise = (binding, operation, evaluate) => Effect.tryPromise({
31
+ try: evaluate,
32
+ catch: (cause) => workersAiError(binding, operation, cause)
33
+ });
34
+ const tryWorkersAiSync = (binding, operation, evaluate) => Effect.try({
35
+ try: evaluate,
36
+ catch: (cause) => workersAiError(binding, operation, cause)
37
+ });
38
+ const hasFunction$3 = (value, key) => typeof Reflect.get(value, key) === "function";
39
+ const isWorkersAiBinding = (value) => typeof value === "object" && value !== null && hasFunction$3(value, "run") && hasFunction$3(value, "gateway") && hasFunction$3(value, "models");
40
+ const embeddingResponse = (value) => ({
41
+ data: value.data ?? [],
42
+ shape: value.shape ?? []
43
+ });
44
+ const makeClient$10 = (definition) => (ai) => {
45
+ const run = ((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () => ai.run(model, input, options)));
46
+ return {
47
+ definition,
48
+ aiGatewayLogId: tryWorkersAiSync(definition.binding, "aiGatewayLogId", () => ai.aiGatewayLogId),
49
+ run,
50
+ runEmbedding: (model, input, options) => run(model, input, options).pipe(Effect.map((response) => embeddingResponse(response))),
51
+ models: (params) => tryWorkersAiPromise(definition.binding, "models", () => ai.models(params)),
52
+ gateway: (gatewayId) => tryWorkersAiSync(definition.binding, "gateway", () => ai.gateway(gatewayId)),
53
+ unsafeRaw: Effect.succeed(ai)
54
+ };
55
+ };
56
+ const layer$14 = (tag, definition) => layer$15(tag, definition.binding, (value) => isWorkersAiBinding(value), makeClient$10(definition), { expected: expectedWorkersAiBinding });
57
+ const make$14 = (id) => Tag$14()(id);
58
+ const Tag$14 = () => (id) => {
59
+ const tag = Context.Service()(id);
60
+ const makeLayer = (definition) => layer$14(tag, definition);
61
+ return Object.assign(tag, {
62
+ id,
63
+ layer: makeLayer
64
+ });
65
+ };
66
+ //#endregion
67
+ //#region src/AiGateway.ts
68
+ var AiGateway_exports = /* @__PURE__ */ __exportAll({
69
+ AiGatewayOperationError: () => AiGatewayOperationError,
70
+ Tag: () => Tag$13,
71
+ isAiGatewayBinding: () => isAiGatewayBinding,
72
+ layer: () => layer$13,
73
+ make: () => make$13,
74
+ makeClient: () => makeClient$9,
75
+ makeClientFromAi: () => makeClientFromAi,
76
+ makeHttpClient: () => makeHttpClient
77
+ });
78
+ const expectedAiGatewayBinding = "Workers AI binding with gateway()";
79
+ /** Error raised when an AI Gateway operation fails. */
80
+ var AiGatewayOperationError = class extends Data.TaggedError("AiGatewayOperationError") {};
81
+ const aiGatewayError = (binding, operation, cause) => new AiGatewayOperationError({
82
+ binding,
83
+ operation,
84
+ cause
85
+ });
86
+ const tryAiGatewayPromise = (binding, operation, evaluate) => Effect.tryPromise({
87
+ try: evaluate,
88
+ catch: (cause) => aiGatewayError(binding, operation, cause)
89
+ });
90
+ const tryAiGatewaySync = (binding, operation, evaluate) => Effect.try({
91
+ try: evaluate,
92
+ catch: (cause) => aiGatewayError(binding, operation, cause)
93
+ });
94
+ const providerUrl = (baseUrl, path = "") => {
95
+ const url = new URL(baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`);
96
+ const normalizedPath = path.replace(/^\/+/, "");
97
+ return normalizedPath === "" ? url : new URL(normalizedPath, url);
98
+ };
99
+ const gatewayUrl = (definition) => `https://gateway.ai.cloudflare.com/v1/${definition.accountId}/${definition.gatewayId}/`;
100
+ const isAiGatewayBinding = (value) => isWorkersAiBinding(value);
101
+ const makeClient$9 = (definition, gateway) => ({
102
+ definition,
103
+ run: (data, options) => tryAiGatewayPromise(definition.binding, "run", () => gateway.run(Array.isArray(data) ? [...data] : data, options)),
104
+ getUrl: (provider) => tryAiGatewayPromise(definition.binding, "getUrl", () => gateway.getUrl(provider)),
105
+ fetch: (options) => Effect.gen(function* () {
106
+ const baseUrl = yield* tryAiGatewayPromise(definition.binding, "getUrl", () => gateway.getUrl(options.provider));
107
+ return yield* tryAiGatewayPromise(definition.binding, "fetch", () => fetch(providerUrl(baseUrl, options.path).href, options.init));
108
+ }),
109
+ patchLog: (logId, data) => tryAiGatewayPromise(definition.binding, "patchLog", () => gateway.patchLog(logId, data)),
110
+ getLog: (logId) => tryAiGatewayPromise(definition.binding, "getLog", () => gateway.getLog(logId)),
111
+ unsafeRaw: Effect.succeed(gateway)
112
+ });
113
+ const makeClientFromAi = (definition, ai) => {
114
+ const gateway = tryAiGatewaySync(definition.binding, "gateway", () => ai.gateway(definition.gatewayId));
115
+ const withGateway = (operation) => gateway.pipe(Effect.flatMap(operation));
116
+ return {
117
+ definition,
118
+ run: (data, options) => withGateway((raw) => makeClient$9(definition, raw).run(data, options)),
119
+ getUrl: (provider) => withGateway((raw) => makeClient$9(definition, raw).getUrl(provider)),
120
+ fetch: (options) => withGateway((raw) => makeClient$9(definition, raw).fetch(options)),
121
+ patchLog: (logId, data) => withGateway((raw) => makeClient$9(definition, raw).patchLog(logId, data)),
122
+ getLog: (logId) => withGateway((raw) => makeClient$9(definition, raw).getLog(logId)),
123
+ unsafeRaw: gateway
124
+ };
125
+ };
126
+ const makeHttpClient = (definition, request = fetch) => {
127
+ const binding = definition.binding ?? "AI_GATEWAY";
128
+ const clientDefinition = {
129
+ binding,
130
+ gatewayId: definition.gatewayId,
131
+ accountId: definition.accountId
132
+ };
133
+ const getUrl = (provider) => Effect.succeed(provider === void 0 ? gatewayUrl(definition) : providerUrl(gatewayUrl(definition), provider).href.replace(/\/$/, ""));
134
+ const extraHeaders = (options) => {
135
+ if (options?.extraHeaders === void 0 || Array.isArray(options.extraHeaders) || options.extraHeaders instanceof Headers) return options?.extraHeaders;
136
+ return Object.fromEntries(Object.entries(options.extraHeaders).map(([key, value]) => [key, String(value)]));
137
+ };
138
+ return {
139
+ definition: clientDefinition,
140
+ run: (data, options) => tryAiGatewayPromise(binding, "run", () => request(gatewayUrl(definition), {
141
+ method: "POST",
142
+ body: JSON.stringify(data),
143
+ headers: new Headers({
144
+ "content-type": "application/json",
145
+ ...Object.fromEntries(new Headers(extraHeaders(options)).entries())
146
+ }),
147
+ signal: options?.signal
148
+ })),
149
+ getUrl,
150
+ fetch: (options) => getUrl(options.provider).pipe(Effect.flatMap((baseUrl) => tryAiGatewayPromise(binding, "fetch", () => request(providerUrl(baseUrl, options.path).href, options.init)))),
151
+ patchLog: (logId, data) => tryAiGatewayPromise(binding, "patchLog", () => request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, {
152
+ method: "PATCH",
153
+ body: JSON.stringify(data),
154
+ headers: { "content-type": "application/json" }
155
+ }).then(() => void 0)),
156
+ getLog: (logId) => tryAiGatewayPromise(binding, "getLog", async () => {
157
+ return await (await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href)).json();
158
+ }),
159
+ unsafeRaw: Effect.fail(aiGatewayError(binding, "unsafeRaw", /* @__PURE__ */ new TypeError("HTTP AI Gateway clients have no raw binding")))
160
+ };
161
+ };
162
+ const layer$13 = (tag, definition) => layer$15(tag, definition.binding, isAiGatewayBinding, (ai) => makeClientFromAi(definition, ai), { expected: expectedAiGatewayBinding });
163
+ const make$13 = (id) => Tag$13()(id);
164
+ const Tag$13 = () => (id) => {
165
+ const tag = Context.Service()(id);
166
+ const makeLayer = (definition) => layer$13(tag, definition);
167
+ return Object.assign(tag, {
168
+ id,
169
+ layer: makeLayer
170
+ });
171
+ };
172
+ //#endregion
173
+ //#region src/BrowserRendering.ts
174
+ var BrowserRendering_exports = /* @__PURE__ */ __exportAll({
175
+ BrowserRenderingOperationError: () => BrowserRenderingOperationError,
176
+ Tag: () => Tag$12,
177
+ isBrowserRenderingBinding: () => isBrowserRenderingBinding,
178
+ layer: () => layer$12,
179
+ make: () => make$12,
180
+ makeClient: () => makeClient$8
181
+ });
182
+ const expectedBrowserRenderingBinding = "Browser Rendering binding resource";
183
+ /** Error raised when a Browser Rendering operation fails. */
184
+ var BrowserRenderingOperationError = class extends Data.TaggedError("BrowserRenderingOperationError") {};
185
+ const browserRenderingError = (binding, operation, cause) => new BrowserRenderingOperationError({
186
+ binding,
187
+ operation,
188
+ cause
189
+ });
190
+ const tryBrowserRenderingPromise = (binding, operation, evaluate) => Effect.tryPromise({
191
+ try: evaluate,
192
+ catch: (cause) => browserRenderingError(binding, operation, cause)
193
+ });
194
+ const tryBrowserRenderingSync = (binding, operation, evaluate) => Effect.try({
195
+ try: evaluate,
196
+ catch: (cause) => browserRenderingError(binding, operation, cause)
197
+ });
198
+ const missingMethod = (binding, operation) => Effect.fail(browserRenderingError(binding, operation, /* @__PURE__ */ new TypeError(`Browser Rendering object does not expose ${operation}()`)));
199
+ const wrapPage = (binding, page) => ({
200
+ raw: page,
201
+ goto: (url, options) => page.goto === void 0 ? missingMethod(binding, "goto") : tryBrowserRenderingPromise(binding, "goto", () => page.goto(url, options)),
202
+ setContent: (html, options) => page.setContent === void 0 ? missingMethod(binding, "setContent") : tryBrowserRenderingPromise(binding, "setContent", () => page.setContent(html, options)),
203
+ content: page.content === void 0 ? missingMethod(binding, "content") : tryBrowserRenderingPromise(binding, "content", () => page.content()),
204
+ screenshot: (options) => page.screenshot === void 0 ? missingMethod(binding, "screenshot") : tryBrowserRenderingPromise(binding, "screenshot", () => page.screenshot(options)),
205
+ pdf: (options) => page.pdf === void 0 ? missingMethod(binding, "pdf") : tryBrowserRenderingPromise(binding, "pdf", () => page.pdf(options)),
206
+ evaluate: (pageFunction, ...args) => page.evaluate === void 0 ? missingMethod(binding, "evaluate") : tryBrowserRenderingPromise(binding, "evaluate", () => page.evaluate(pageFunction, ...args)),
207
+ close: (options) => page.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closePage", () => page.close(options))
208
+ });
209
+ const wrapBrowser = (binding, browser) => ({
210
+ raw: browser,
211
+ newPage: tryBrowserRenderingPromise(binding, "newPage", () => browser.newPage()).pipe(Effect.map((page) => wrapPage(binding, page))),
212
+ version: browser.version === void 0 ? missingMethod(binding, "version") : tryBrowserRenderingPromise(binding, "version", () => browser.version()),
213
+ close: browser.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closeBrowser", () => browser.close()),
214
+ disconnect: browser.disconnect === void 0 ? Effect.void : tryBrowserRenderingSync(binding, "disconnect", () => browser.disconnect())
215
+ });
216
+ const isBrowserRenderingBinding = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
217
+ const makeClient$8 = (definition) => (binding) => ({
218
+ definition,
219
+ launchWith: (launch, options) => tryBrowserRenderingPromise(definition.binding, "launch", () => launch(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser))),
220
+ connectWith: (connect, options) => tryBrowserRenderingPromise(definition.binding, "connect", () => connect(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser))),
221
+ unsafeRaw: Effect.succeed(binding)
222
+ });
223
+ const layer$12 = (tag, definition) => layer$15(tag, definition.binding, isBrowserRenderingBinding, makeClient$8(definition), { expected: expectedBrowserRenderingBinding });
224
+ const make$12 = (id) => Tag$12()(id);
225
+ const Tag$12 = () => (id) => {
226
+ const tag = Context.Service()(id);
227
+ const makeLayer = (definition) => layer$12(tag, definition);
228
+ return Object.assign(tag, {
229
+ id,
230
+ layer: makeLayer
231
+ });
232
+ };
233
+ //#endregion
12
234
  //#region src/DurableObjectStorage.ts
13
235
  var DurableObjectStorage_exports = /* @__PURE__ */ __exportAll({
14
236
  StorageOperationError: () => StorageOperationError,
@@ -300,251 +522,77 @@ const runPromiseExitPreservingTypedFailures = async (effect) => {
300
522
  //#endregion
301
523
  //#region src/CloudflareOtlp.ts
302
524
  var CloudflareOtlp_exports = /* @__PURE__ */ __exportAll({
303
- CloudflareOtlpSettings: () => CloudflareOtlpSettings,
304
525
  durableObjectLayer: () => durableObjectLayer,
305
- layer: () => layer$10,
526
+ layer: () => layer$11,
306
527
  layerJson: () => layerJson,
307
528
  layerProtobuf: () => layerProtobuf,
308
- settingsConfig: () => settingsConfig,
309
- settingsLayer: () => settingsLayer,
310
529
  workerLayer: () => workerLayer
311
530
  });
312
- /**
313
- * Supported OpenTelemetry environment configuration for Cloudflare OTLP export.
314
- *
315
- * This config intentionally uses the conventional `OTEL_*` variable names so
316
- * deployments can share the same settings used by other OpenTelemetry SDKs.
317
- * It covers the OTLP HTTP settings supported by the Effect OTLP layers:
318
- *
319
- * - `OTEL_EXPORTER_OTLP_ENDPOINT`
320
- * - `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`
321
- * - `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`
322
- * - `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`
323
- * - `OTEL_EXPORTER_OTLP_HEADERS`
324
- * - `OTEL_EXPORTER_OTLP_LOGS_HEADERS`
325
- * - `OTEL_EXPORTER_OTLP_TRACES_HEADERS`
326
- * - `OTEL_EXPORTER_OTLP_METRICS_HEADERS`
327
- * - `OTEL_SERVICE_NAME`
328
- * - `OTEL_RESOURCE_ATTRIBUTES`
329
- *
330
- * `OTEL_SERVICE_VERSION` is also accepted as an effect-cf convenience alias.
331
- * The standard OpenTelemetry way to configure service version is
332
- * `OTEL_RESOURCE_ATTRIBUTES=service.version=...`.
333
- *
334
- * Consumers with non-standard binding names should map those names into
335
- * {@link CloudflareOtlpSettings} rather than changing this config globally.
336
- */
337
- const settingsConfig = Config.all({
338
- endpoint: Config.string("OTEL_EXPORTER_OTLP_ENDPOINT").pipe(Config.option),
339
- logsEndpoint: Config.string("OTEL_EXPORTER_OTLP_LOGS_ENDPOINT").pipe(Config.option),
340
- tracesEndpoint: Config.string("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT").pipe(Config.option),
341
- metricsEndpoint: Config.string("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT").pipe(Config.option),
342
- headers: Config.string("OTEL_EXPORTER_OTLP_HEADERS").pipe(Config.option),
343
- logsHeaders: Config.string("OTEL_EXPORTER_OTLP_LOGS_HEADERS").pipe(Config.option),
344
- tracesHeaders: Config.string("OTEL_EXPORTER_OTLP_TRACES_HEADERS").pipe(Config.option),
345
- metricsHeaders: Config.string("OTEL_EXPORTER_OTLP_METRICS_HEADERS").pipe(Config.option),
346
- serviceName: Config.string("OTEL_SERVICE_NAME").pipe(Config.option),
347
- serviceVersion: Config.string("OTEL_SERVICE_VERSION").pipe(Config.option),
348
- resourceAttributes: Config.schema(Config.Record(Schema.String, Schema.String), "OTEL_RESOURCE_ATTRIBUTES").pipe(Config.option)
349
- });
350
- /**
351
- * Service carrying already-resolved Cloudflare OTLP settings.
352
- *
353
- * Provide this service directly when an application needs to map custom
354
- * Cloudflare binding names, compute settings dynamically, or override settings
355
- * in tests. When this service is present, the OTLP layers use it instead of
356
- * reading {@link settingsConfig}.
357
- *
358
- * @example
359
- * ```ts
360
- * const CustomOtlpSettings = Layer.effect(
361
- * CloudflareOtlp.CloudflareOtlpSettings,
362
- * Config.all({
363
- * ...CloudflareOtlp.settingsConfig,
364
- * endpoint: Config.string("MY_OTLP_ENDPOINT").pipe(Config.option),
365
- * }),
366
- * ).pipe(Layer.provide(WorkerConfig.layer));
367
- * ```
368
- */
369
- var CloudflareOtlpSettings = class extends Context.Service()("effect-cf/CloudflareOtlpSettings") {};
370
531
  const allSignals = [
371
532
  "logs",
372
533
  "traces",
373
534
  "metrics"
374
535
  ];
375
- const optionToUndefined = (option) => Option.isSome(option) ? option.value : void 0;
376
- const nonEmptyStringOption = (option) => Option.flatMap(option, (value) => {
377
- const trimmed = value.trim();
378
- return trimmed === "" ? Option.none() : Option.some(trimmed);
379
- });
380
- const nonEmptyRecordOption = (option) => Option.filter(option, (value) => Object.keys(value).length > 0);
381
- const normalizeSettings = (settings) => ({
382
- endpoint: nonEmptyStringOption(settings.endpoint),
383
- logsEndpoint: nonEmptyStringOption(settings.logsEndpoint),
384
- tracesEndpoint: nonEmptyStringOption(settings.tracesEndpoint),
385
- metricsEndpoint: nonEmptyStringOption(settings.metricsEndpoint),
386
- headers: nonEmptyStringOption(settings.headers),
387
- logsHeaders: nonEmptyStringOption(settings.logsHeaders),
388
- tracesHeaders: nonEmptyStringOption(settings.tracesHeaders),
389
- metricsHeaders: nonEmptyStringOption(settings.metricsHeaders),
390
- serviceName: nonEmptyStringOption(settings.serviceName),
391
- serviceVersion: nonEmptyStringOption(settings.serviceVersion),
392
- resourceAttributes: nonEmptyRecordOption(settings.resourceAttributes)
393
- });
394
- /**
395
- * Layer that reads standard OpenTelemetry settings from the current Cloudflare
396
- * `env` object.
397
- *
398
- * The layer depends on {@link WorkerEnvironment} and installs a
399
- * Cloudflare-backed Effect `ConfigProvider`, so `settingsConfig` reads from
400
- * Worker vars/secrets instead of Node process environment variables.
401
- */
402
- const settingsLayer = Layer.effect(CloudflareOtlpSettings, settingsConfig.pipe(Config.map(normalizeSettings))).pipe(Layer.provide(WorkerConfig.layer));
536
+ const emptyConfigProvider = ConfigProvider.fromUnknown({});
537
+ const cloudflareConfigProviderLayer = ConfigProvider.layerAdd(Effect.map(Effect.serviceOption(WorkerEnvironment), (env) => Option.isSome(env) ? WorkerConfig.providerFromEnv(env.value) : emptyConfigProvider), { asPrimary: true });
403
538
  const selectedSignals = (signals) => new Set(signals ?? allSignals);
404
539
  const withDefinedAttributes = (attributes) => {
405
540
  const out = {};
406
541
  for (const [key, value] of Object.entries(attributes)) if (value !== void 0) out[key] = value;
407
542
  return out;
408
543
  };
409
- const parseHeaders = (input) => {
410
- if (Option.isNone(input) || input.value.trim() === "") return;
411
- const headers = {};
412
- for (const part of input.value.split(",")) {
413
- const index = part.indexOf("=");
414
- if (index <= 0) continue;
415
- const key = part.slice(0, index).trim();
416
- const value = part.slice(index + 1).trim();
417
- if (key !== "") headers[decodeHeaderComponent(key)] = decodeHeaderComponent(value);
418
- }
419
- return headers;
420
- };
421
- const mergeHeaders = (common, signalSpecific) => {
422
- const commonHeaders = parseHeaders(common);
423
- const signalHeaders = parseHeaders(signalSpecific);
424
- if (commonHeaders === void 0 && signalHeaders === void 0) return;
425
- return {
426
- ...commonHeaders,
427
- ...signalHeaders
428
- };
429
- };
430
- const decodeHeaderComponent = (value) => {
431
- try {
432
- return decodeURIComponent(value);
433
- } catch {
434
- return value;
435
- }
436
- };
437
- const appendOtlpPath = (baseUrl, path) => `${baseUrl.replace(/\/+$/, "")}${path}`;
438
- const makeResource = (settings, options, runtimeAttributes) => ({
439
- serviceName: options.serviceName ?? optionToUndefined(settings.serviceName),
440
- serviceVersion: options.serviceVersion ?? optionToUndefined(settings.serviceVersion),
544
+ const makeResource = (options, runtimeAttributes) => ({
545
+ serviceName: options.resource?.serviceName,
546
+ serviceVersion: options.resource?.serviceVersion,
441
547
  attributes: {
442
- ...optionToUndefined(settings.resourceAttributes),
443
548
  ...withDefinedAttributes(runtimeAttributes),
444
- ...options.attributes
549
+ ...options.resource?.attributes
445
550
  }
446
551
  });
447
- const commonOtlpOptions = (settings, options, runtimeAttributes) => ({
448
- resource: makeResource(settings, options, runtimeAttributes),
449
- maxBatchSize: options.maxBatchSize,
450
- loggerExportInterval: options.loggerExportInterval,
451
- loggerExcludeLogSpans: options.loggerExcludeLogSpans,
452
- loggerMergeWithExisting: options.loggerMergeWithExisting,
453
- tracerExportInterval: options.tracerExportInterval,
454
- tracerContext: options.tracerContext,
455
- metricsExportInterval: options.metricsExportInterval,
456
- metricsTemporality: options.metricsTemporality,
457
- shutdownTimeout: options.shutdownTimeout
458
- });
459
552
  const serializationLayer = (serialization) => serialization === "json" ? OtlpSerialization.layerJson : OtlpSerialization.layerProtobuf;
460
- const resolveSettings = Effect.gen(function* () {
461
- const settings = yield* Effect.serviceOption(CloudflareOtlpSettings);
462
- if (Option.isSome(settings)) return normalizeSettings(settings.value);
463
- const env = yield* Effect.serviceOption(WorkerEnvironment);
464
- if (Option.isSome(env)) return normalizeSettings(yield* settingsConfig.pipe(Effect.provide(ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env.value))))));
465
- return normalizeSettings(yield* settingsConfig);
466
- });
467
553
  const mergeSignalLayers = (layers) => {
468
554
  if (layers.length === 0) return Layer.empty;
469
555
  let merged = layers[0];
470
556
  for (let index = 1; index < layers.length; index++) merged = Layer.mergeAll(merged, layers[index]);
471
557
  return merged;
472
558
  };
473
- const emptyLayer = Layer.empty;
474
- const makeLayerFromSettings = (options = {}, runtimeAttributes = {}) => Layer.unwrap(Effect.map(resolveSettings, (settings) => {
559
+ const makeLayer = (options = {}, runtimeAttributes = {}) => {
475
560
  const signals = selectedSignals(options.signals);
476
- const endpoint = optionToUndefined(settings.endpoint);
477
- const logsEndpoint = optionToUndefined(settings.logsEndpoint);
478
- const tracesEndpoint = optionToUndefined(settings.tracesEndpoint);
479
- const metricsEndpoint = optionToUndefined(settings.metricsEndpoint);
480
- const hasSpecificEndpoint = logsEndpoint !== void 0 || tracesEndpoint !== void 0 || metricsEndpoint !== void 0;
481
- const hasSpecificHeaders = Option.isSome(settings.logsHeaders) || Option.isSome(settings.tracesHeaders) || Option.isSome(settings.metricsHeaders);
482
- const common = commonOtlpOptions(settings, options, runtimeAttributes);
483
- if (endpoint !== void 0 && !hasSpecificEndpoint && !hasSpecificHeaders && signals.size === 3) return Otlp.layer({
484
- baseUrl: endpoint,
485
- headers: parseHeaders(settings.headers),
486
- ...common
487
- }).pipe(Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer));
561
+ const resource = makeResource(options, runtimeAttributes);
488
562
  const layers = [];
489
- if (signals.has("logs")) {
490
- const url = logsEndpoint ?? (endpoint === void 0 ? void 0 : appendOtlpPath(endpoint, "/v1/logs"));
491
- if (url !== void 0) layers.push(OtlpLogger.layer({
492
- url,
493
- resource: common.resource,
494
- headers: mergeHeaders(settings.headers, settings.logsHeaders),
495
- exportInterval: common.loggerExportInterval,
496
- maxBatchSize: common.maxBatchSize,
497
- shutdownTimeout: common.shutdownTimeout,
498
- excludeLogSpans: common.loggerExcludeLogSpans,
499
- mergeWithExisting: common.loggerMergeWithExisting
500
- }).pipe(Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer)));
501
- }
502
- if (signals.has("traces")) {
503
- const url = tracesEndpoint ?? (endpoint === void 0 ? void 0 : appendOtlpPath(endpoint, "/v1/traces"));
504
- if (url !== void 0) layers.push(OtlpTracer.layer({
505
- url,
506
- resource: common.resource,
507
- headers: mergeHeaders(settings.headers, settings.tracesHeaders),
508
- exportInterval: common.tracerExportInterval,
509
- maxBatchSize: common.maxBatchSize,
510
- context: common.tracerContext,
511
- shutdownTimeout: common.shutdownTimeout
512
- }).pipe(Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer)));
513
- }
514
- if (signals.has("metrics")) {
515
- const url = metricsEndpoint ?? (endpoint === void 0 ? void 0 : appendOtlpPath(endpoint, "/v1/metrics"));
516
- if (url !== void 0) layers.push(OtlpMetrics.layer({
517
- url,
518
- resource: common.resource,
519
- headers: mergeHeaders(settings.headers, settings.metricsHeaders),
520
- exportInterval: common.metricsExportInterval,
521
- shutdownTimeout: common.shutdownTimeout,
522
- temporality: common.metricsTemporality
523
- }).pipe(Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer)));
524
- }
525
- return mergeSignalLayers(layers);
526
- }).pipe(Effect.catch((error) => Effect.logWarning("CloudflareOtlp disabled because OTLP configuration is invalid", { error: String(error) }).pipe(Effect.as(emptyLayer)))));
527
- const makeLayer = (options = {}, runtimeAttributes = {}) => makeLayerFromSettings(options, runtimeAttributes);
563
+ if (signals.has("logs")) layers.push(OtlpLogger.layerFromConfig({
564
+ resource,
565
+ headers: options.headers,
566
+ excludeLogSpans: options.loggerExcludeLogSpans,
567
+ mergeWithExisting: options.loggerMergeWithExisting
568
+ }));
569
+ if (signals.has("traces")) layers.push(OtlpTracer.layerFromConfig({
570
+ resource,
571
+ headers: options.headers,
572
+ context: options.tracerContext
573
+ }));
574
+ if (signals.has("metrics")) layers.push(OtlpMetrics.layerFromConfig({
575
+ resource,
576
+ headers: options.headers
577
+ }));
578
+ return mergeSignalLayers(layers).pipe(Layer.provide(cloudflareConfigProviderLayer), Layer.provide(serializationLayer(options.serialization)), Layer.provide(FetchHttpClient.layer));
579
+ };
528
580
  /**
529
581
  * Base OTLP telemetry layer for Cloudflare-compatible runtimes.
530
582
  *
531
- * The layer reads {@link CloudflareOtlpSettings} when provided. Otherwise it
532
- * reads standard OpenTelemetry config from `WorkerEnvironment` when available,
533
- * then falls back to the ambient Effect `ConfigProvider`.
534
- *
535
- * When only `OTEL_EXPORTER_OTLP_ENDPOINT` is configured, per-signal paths are
536
- * derived by appending `/v1/logs`, `/v1/traces`, and `/v1/metrics`. Signal
537
- * specific endpoints are used as-is, matching the OpenTelemetry OTLP exporter
538
- * convention.
583
+ * Standard OpenTelemetry environment variables are resolved by Effect's OTLP
584
+ * layers. In Cloudflare Workers and Durable Objects, the current `env` object is
585
+ * installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
586
+ * Effect `ConfigProvider` remains the fallback.
539
587
  */
540
- const layer$10 = (options = {}) => makeLayer(options);
588
+ const layer$11 = (options = {}) => makeLayer(options);
541
589
  /** Base OTLP telemetry layer forced to JSON serialization. */
542
- const layerJson = (options = {}) => layer$10({
590
+ const layerJson = (options = {}) => layer$11({
543
591
  ...options,
544
592
  serialization: "json"
545
593
  });
546
594
  /** Base OTLP telemetry layer forced to protobuf serialization. */
547
- const layerProtobuf = (options = {}) => layer$10({
595
+ const layerProtobuf = (options = {}) => layer$11({
548
596
  ...options,
549
597
  serialization: "protobuf"
550
598
  });
@@ -574,7 +622,7 @@ const durableObjectLayer = (options = {}) => Layer.unwrap(Effect.map(DurableObje
574
622
  //#region src/D1.ts
575
623
  var D1_exports = /* @__PURE__ */ __exportAll({
576
624
  Service: () => Service$1,
577
- make: () => make$10
625
+ make: () => make$11
578
626
  });
579
627
  const TypeId$2 = "effect-cf/D1";
580
628
  const expectedD1Database = "D1 database binding with prepare(), batch(), and exec()";
@@ -586,7 +634,7 @@ const isD1Database = (value) => {
586
634
  /**
587
635
  * Creates a typed D1 service tag plus Effect helpers.
588
636
  */
589
- const make$10 = (id, definition) => Service$1()(id, definition);
637
+ const make$11 = (id, definition) => Service$1()(id, definition);
590
638
  /**
591
639
  * Builds a D1 service around a Cloudflare D1 database binding.
592
640
  *
@@ -622,8 +670,8 @@ const Service$1 = () => (id, definition) => {
622
670
  var QueueBinding_exports = /* @__PURE__ */ __exportAll({
623
671
  QueueOperationError: () => QueueOperationError,
624
672
  isQueue: () => isQueue,
625
- layer: () => layer$9,
626
- makeClient: () => makeClient$6
673
+ layer: () => layer$10,
674
+ makeClient: () => makeClient$7
627
675
  });
628
676
  const expectedQueueProducer = "Queue producer binding with send(); optional sendBatch()/metrics()";
629
677
  var QueueOperationError = class extends Data.TaggedError("QueueOperationError") {};
@@ -640,7 +688,7 @@ const isQueue = (value) => {
640
688
  if (typeof value !== "object" || value === null) return false;
641
689
  return typeof value.send === "function";
642
690
  };
643
- const makeClient$6 = (definition) => {
691
+ const makeClient$7 = (definition) => {
644
692
  const encodeMessage = Schema.encodeEffect(definition.message);
645
693
  return (queue) => ({
646
694
  send: Effect.fnUntraced(function* (message, options) {
@@ -678,30 +726,30 @@ const makeClient$6 = (definition) => {
678
726
  unsafeRaw: Effect.succeed(queue)
679
727
  });
680
728
  };
681
- const layer$9 = (tag, definition) => layer$11(tag, definition.binding, (value) => isQueue(value), makeClient$6(definition), { expected: expectedQueueProducer });
729
+ const layer$10 = (tag, definition) => layer$15(tag, definition.binding, (value) => isQueue(value), makeClient$7(definition), { expected: expectedQueueProducer });
682
730
  //#endregion
683
731
  //#region src/QueueDefinition.ts
684
732
  var QueueDefinition_exports = /* @__PURE__ */ __exportAll({
685
733
  Queue: () => Queue$1,
686
- Tag: () => Tag$10,
734
+ Tag: () => Tag$11,
687
735
  implement: () => implement$7,
688
- make: () => make$9
736
+ make: () => make$10
689
737
  });
690
738
  const makeDefinition$4 = (id, definition) => {
691
739
  const queueDefinition = {
692
740
  id,
693
741
  message: definition.message
694
742
  };
695
- return Object.assign(queueDefinition, { make: (layer, options) => make$6(layer, {
743
+ return Object.assign(queueDefinition, { make: (layer, options) => make$7(layer, {
696
744
  ...options,
697
745
  queue: wrapHandler$1(queueDefinition, options.queue)
698
746
  }) });
699
747
  };
700
- const make$9 = (id, definition) => Tag$10()(id, definition);
701
- const Tag$10 = () => (id, definition) => {
748
+ const make$10 = (id, definition) => Tag$11()(id, definition);
749
+ const Tag$11 = () => (id, definition) => {
702
750
  const queueDefinition = makeDefinition$4(id, definition);
703
751
  const tag = Context.Service()(id);
704
- const layer = (binding) => layer$9(tag, {
752
+ const layer = (binding) => layer$10(tag, {
705
753
  ...binding,
706
754
  message: definition.message
707
755
  });
@@ -728,7 +776,7 @@ const Tag$10 = () => (id, definition) => {
728
776
  unsafeRaw
729
777
  });
730
778
  };
731
- const Queue$1 = Tag$10;
779
+ const Queue$1 = Tag$11;
732
780
  const wrapHandler$1 = (definition, handler) => {
733
781
  const decodeBody = Schema.decodeUnknownEffect(definition.message);
734
782
  return (batch) => Effect.gen(function* () {
@@ -740,7 +788,7 @@ const implement$7 = (_definition, handler) => handler;
740
788
  //#region src/Queue.ts
741
789
  var Queue_exports = /* @__PURE__ */ __exportAll({
742
790
  QueueMessageDecodeError: () => QueueMessageDecodeError,
743
- Tag: () => Tag$9,
791
+ Tag: () => Tag$10,
744
792
  decodeBatch: () => decodeBatch,
745
793
  fromMessage: () => fromMessage,
746
794
  fromMessageBatch: () => fromMessageBatch,
@@ -778,7 +826,7 @@ const decodeBatch = (batch, decodeBody) => Effect.gen(function* () {
778
826
  }
779
827
  return fromMessageBatch(batch, messages);
780
828
  });
781
- const Tag$9 = Tag$10;
829
+ const Tag$10 = Tag$11;
782
830
  const implement$6 = implement$7;
783
831
  //#endregion
784
832
  //#region src/RpcDefinition.ts
@@ -796,7 +844,7 @@ var RpcDefinition_exports = /* @__PURE__ */ __exportAll({
796
844
  decodeSuccess: () => decodeSuccess,
797
845
  encodeArgs: () => encodeArgs,
798
846
  encodeSuccess: () => encodeSuccess,
799
- make: () => make$8,
847
+ make: () => make$9,
800
848
  method: () => method$4,
801
849
  reservedMethodNames: () => reservedMethodNames$4
802
850
  });
@@ -899,7 +947,7 @@ const decodeSuccess = (definition, methodName, value) => {
899
947
  cause
900
948
  })));
901
949
  };
902
- const make$8 = (id, methods) => {
950
+ const make$9 = (id, methods) => {
903
951
  const definition = {
904
952
  id,
905
953
  methods
@@ -957,8 +1005,8 @@ var ServiceBinding_exports = /* @__PURE__ */ __exportAll({
957
1005
  ServiceBindingFetchError: () => ServiceBindingFetchError,
958
1006
  ServiceBindingRpcError: () => ServiceBindingRpcError,
959
1007
  isServiceBindingClient: () => isServiceBindingClient,
960
- layer: () => layer$8,
961
- makeClient: () => makeClient$5,
1008
+ layer: () => layer$9,
1009
+ makeClient: () => makeClient$6,
962
1010
  makeDirectMethods: () => makeDirectMethods$1
963
1011
  });
964
1012
  const TypeId$1 = "effect-cf/ServiceBinding";
@@ -972,7 +1020,7 @@ var ServiceBindingFetchError = class extends Data.TaggedError("ServiceBindingFet
972
1020
  */
973
1021
  var ServiceBindingRpcError = class extends Data.TaggedError("ServiceBindingRpcError") {};
974
1022
  const isServiceBindingClient = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fetch") === "function";
975
- const makeClient$5 = (definition) => {
1023
+ const makeClient$6 = (definition) => {
976
1024
  return (service) => {
977
1025
  const fetch = (input, init) => Effect.tryPromise({
978
1026
  try: () => service.fetch(input, init),
@@ -1021,7 +1069,7 @@ const makeClient$5 = (definition) => {
1021
1069
  });
1022
1070
  };
1023
1071
  };
1024
- const layer$8 = (tag, definition) => layer$11(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition), { expected: expectedServiceBinding });
1072
+ const layer$9 = (tag, definition) => layer$15(tag, definition.binding, (value) => isServiceBindingClient(value), makeClient$6(definition), { expected: expectedServiceBinding });
1025
1073
  /**
1026
1074
  * Creates a typed Effect service for a Worker service binding.
1027
1075
  *
@@ -1052,7 +1100,7 @@ const layer$8 = (tag, definition) => layer$11(tag, definition.binding, (value) =
1052
1100
  * ```
1053
1101
  */
1054
1102
  const Service = () => (id, definition) => {
1055
- const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$5(definition));
1103
+ const tag = Service$2()(id, definition.binding, (value) => isServiceBindingClient(value), makeClient$6(definition));
1056
1104
  const fetch = (input, init) => Effect.gen(function* () {
1057
1105
  return yield* (yield* tag).fetch(input, init);
1058
1106
  });
@@ -1083,10 +1131,10 @@ const makeDirectMethods$1 = (rpcDefinition, call) => {
1083
1131
  //#endregion
1084
1132
  //#region src/WorkerDefinition.ts
1085
1133
  var WorkerDefinition_exports = /* @__PURE__ */ __exportAll({
1086
- Tag: () => Tag$8,
1134
+ Tag: () => Tag$9,
1087
1135
  Worker: () => Worker,
1088
1136
  implement: () => implement$5,
1089
- make: () => make$7,
1137
+ make: () => make$8,
1090
1138
  method: () => method$3
1091
1139
  });
1092
1140
  const reservedMethodNames$3 = new Set([
@@ -1124,21 +1172,21 @@ const method$3 = method$4;
1124
1172
  */
1125
1173
  const makeDefinition$3 = (id, methods) => {
1126
1174
  assertNoReservedMethods("Worker", methods, reservedMethodNames$3);
1127
- const definition = make$8(id, methods);
1128
- return Object.assign(definition, { make: (layer, options) => make$6(layer, {
1175
+ const definition = make$9(id, methods);
1176
+ return Object.assign(definition, { make: (layer, options) => make$7(layer, {
1129
1177
  ...options,
1130
1178
  rpc: wrapHandlers$1(definition, options.rpc)
1131
1179
  }) });
1132
1180
  };
1133
- const make$7 = (id, methods) => Tag$8()(id, methods);
1134
- const Tag$8 = () => (id, methods) => {
1181
+ const make$8 = (id, methods) => Tag$9()(id, methods);
1182
+ const Tag$9 = () => (id, methods) => {
1135
1183
  const definition = makeDefinition$3(id, methods);
1136
1184
  const tag = Context.Service()(id);
1137
1185
  const bindingDefinition = (binding) => ({
1138
1186
  ...binding,
1139
1187
  definition
1140
1188
  });
1141
- const layer = (binding) => layer$8(tag, bindingDefinition(binding));
1189
+ const layer = (binding) => layer$9(tag, bindingDefinition(binding));
1142
1190
  const fetch = (input, init) => Effect.gen(function* () {
1143
1191
  return yield* (yield* tag).fetch(input, init);
1144
1192
  });
@@ -1163,7 +1211,7 @@ const Tag$8 = () => (id, methods) => {
1163
1211
  scopedCall
1164
1212
  });
1165
1213
  };
1166
- const Worker = Tag$8;
1214
+ const Worker = Tag$9;
1167
1215
  const wrapHandlers$1 = (definition, handlers) => {
1168
1216
  const wrapped = {};
1169
1217
  for (const key of Object.keys(definition.methods)) {
@@ -1197,7 +1245,7 @@ const clock = {
1197
1245
  });
1198
1246
  }
1199
1247
  };
1200
- const layer$7 = Layer.effect(Clock.Clock, Effect.succeed(clock));
1248
+ const layer$8 = Layer.effect(Clock.Clock, Effect.succeed(clock));
1201
1249
  //#endregion
1202
1250
  //#region src/internal/Entrypoint.ts
1203
1251
  const provideEntrypointServices = (layer, services) => layer.pipe(Layer.provideMerge(services));
@@ -1239,11 +1287,11 @@ const fromExecutionContext = (ctx, runPromiseExit) => {
1239
1287
  var Worker_exports = /* @__PURE__ */ __exportAll({
1240
1288
  ExecutionContext: () => ExecutionContext,
1241
1289
  NativeRequest: () => NativeRequest,
1242
- Tag: () => Tag$7,
1290
+ Tag: () => Tag$8,
1243
1291
  WorkerContext: () => WorkerContext,
1244
1292
  implement: () => implement$4,
1245
1293
  isWebSocketUpgrade: () => isWebSocketUpgrade,
1246
- make: () => make$6,
1294
+ make: () => make$7,
1247
1295
  makeFetchHandler: () => makeFetchHandler,
1248
1296
  method: () => method$2,
1249
1297
  renderHttpResponse: () => renderHttpResponse
@@ -1272,14 +1320,14 @@ const RunSymbol$1 = Symbol.for("effect-cf/Worker/run");
1272
1320
  const renderHttpResponse = (effect) => Effect.flatMap(effect, (response) => Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
1273
1321
  const renderFetchSuccess = (effect) => Effect.flatMap(effect, (response) => response instanceof Response ? Effect.succeed(response) : Effect.map(Effect.context(), (context) => HttpServerResponse.toWeb(response, { context })));
1274
1322
  const isWorkerOptions = (options) => typeof options === "object" && options !== null && ("eventLayer" in options || "fetch" in options || "queue" in options || "rpc" in options);
1275
- function make$6(layer, optionsOrFetch) {
1323
+ function make$7(layer, optionsOrFetch) {
1276
1324
  const options = isWorkerOptions(optionsOrFetch) ? optionsOrFetch : { fetch: optionsOrFetch };
1277
1325
  class EffectWorker extends WorkerEntrypoint {
1278
1326
  runtime;
1279
1327
  constructor(ctx, env) {
1280
1328
  super(ctx, env);
1281
1329
  let runWaitUntilEffect = () => Promise.reject(/* @__PURE__ */ new Error("WorkerContext runtime is not initialized"));
1282
- const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$7, Layer.succeed(ExecutionContext, ctx), ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(WorkerContext, fromExecutionContext(ctx, (effect) => runWaitUntilEffect(effect))), Layer.succeed(WorkerEnvironment, env)));
1330
+ const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$8, Layer.succeed(ExecutionContext, ctx), ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(WorkerContext, fromExecutionContext(ctx, (effect) => runWaitUntilEffect(effect))), Layer.succeed(WorkerEnvironment, env)));
1283
1331
  this.runtime = ManagedRuntime.make(runtimeLayer);
1284
1332
  runWaitUntilEffect = (effect) => this.runtime.runPromiseExit(effect);
1285
1333
  }
@@ -1304,10 +1352,10 @@ function make$6(layer, optionsOrFetch) {
1304
1352
  return assumeEntrypointClass(EffectWorker);
1305
1353
  }
1306
1354
  const makeFetchHandler = (layer, options) => {
1307
- const WorkerClass = make$6(layer, options);
1355
+ const WorkerClass = make$7(layer, options);
1308
1356
  return { fetch: (request, env, ctx) => Promise.resolve(new WorkerClass(ctx, env).fetch(request)) };
1309
1357
  };
1310
- const Tag$7 = Tag$8;
1358
+ const Tag$8 = Tag$9;
1311
1359
  const method$2 = method$3;
1312
1360
  const implement$4 = implement$5;
1313
1361
  //#endregion
@@ -1316,8 +1364,8 @@ var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
1316
1364
  DurableObjectFetchError: () => DurableObjectFetchError,
1317
1365
  DurableObjectRpcError: () => DurableObjectRpcError,
1318
1366
  isDurableObjectNamespaceClient: () => isDurableObjectNamespaceClient,
1319
- layer: () => layer$6,
1320
- makeClient: () => makeClient$4,
1367
+ layer: () => layer$7,
1368
+ makeClient: () => makeClient$5,
1321
1369
  makeDirectMethods: () => makeDirectMethods
1322
1370
  });
1323
1371
  const expectedDurableObjectNamespace = "Durable Object namespace binding with getByName(), get(), idFromName(), idFromString(), newUniqueId(), and jurisdiction()";
@@ -1329,9 +1377,9 @@ var DurableObjectRpcError = class extends Data.TaggedError("DurableObjectRpcErro
1329
1377
  * Failure raised when forwarding a request to a Durable Object stub.
1330
1378
  */
1331
1379
  var DurableObjectFetchError = class extends Data.TaggedError("DurableObjectFetchError") {};
1332
- const hasFunction$1 = (value, key) => typeof Reflect.get(value, key) === "function";
1333
- const isDurableObjectNamespaceClient = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "getByName") && hasFunction$1(value, "get") && hasFunction$1(value, "idFromName") && hasFunction$1(value, "idFromString") && hasFunction$1(value, "newUniqueId") && hasFunction$1(value, "jurisdiction");
1334
- const makeClient$4 = (definition) => {
1380
+ const hasFunction$2 = (value, key) => typeof Reflect.get(value, key) === "function";
1381
+ 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");
1382
+ const makeClient$5 = (definition) => {
1335
1383
  return (namespace) => {
1336
1384
  const newUniqueId = (options) => Effect.sync(() => namespace.newUniqueId(options));
1337
1385
  const idFromName = (name) => Effect.sync(() => namespace.idFromName(name));
@@ -1398,7 +1446,7 @@ const makeClient$4 = (definition) => {
1398
1446
  });
1399
1447
  };
1400
1448
  };
1401
- const layer$6 = (tag, definition) => layer$11(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$4(definition), { expected: expectedDurableObjectNamespace });
1449
+ const layer$7 = (tag, definition) => layer$15(tag, definition.binding, (value) => isDurableObjectNamespaceClient(value), makeClient$5(definition), { expected: expectedDurableObjectNamespace });
1402
1450
  const makeDirectMethods = (rpcDefinition, helpers) => {
1403
1451
  const methods = {};
1404
1452
  if (rpcDefinition !== void 0) {
@@ -1423,9 +1471,9 @@ const makeDirectMethods = (rpcDefinition, helpers) => {
1423
1471
  //#region src/DurableObjectDefinition.ts
1424
1472
  var DurableObjectDefinition_exports = /* @__PURE__ */ __exportAll({
1425
1473
  DurableObject: () => DurableObject$1,
1426
- Tag: () => Tag$6,
1474
+ Tag: () => Tag$7,
1427
1475
  implement: () => implement$3,
1428
- make: () => make$5,
1476
+ make: () => make$6,
1429
1477
  method: () => method$1
1430
1478
  });
1431
1479
  const reservedMethodNames$1 = new Set([
@@ -1456,21 +1504,21 @@ const method$1 = method$4;
1456
1504
  */
1457
1505
  const makeDefinition$2 = (id, methods) => {
1458
1506
  assertNoReservedMethods("Durable Object", methods, reservedMethodNames$1);
1459
- const definition = make$8(id, methods);
1460
- return Object.assign(definition, { make: (layer, options) => make$4(layer, {
1507
+ const definition = make$9(id, methods);
1508
+ return Object.assign(definition, { make: (layer, options) => make$5(layer, {
1461
1509
  ...options,
1462
1510
  rpc: wrapHandlers(definition, options.rpc)
1463
1511
  }) });
1464
1512
  };
1465
- const make$5 = (id, methods) => Tag$6()(id, methods);
1466
- const Tag$6 = () => (id, methods) => {
1513
+ const make$6 = (id, methods) => Tag$7()(id, methods);
1514
+ const Tag$7 = () => (id, methods) => {
1467
1515
  const definition = makeDefinition$2(id, methods);
1468
1516
  const tag = Context.Service()(id);
1469
1517
  const bindingDefinition = (binding) => ({
1470
1518
  ...binding,
1471
1519
  definition
1472
1520
  });
1473
- const layer = (binding) => layer$6(tag, bindingDefinition(binding));
1521
+ const layer = (binding) => layer$7(tag, bindingDefinition(binding));
1474
1522
  const newUniqueId = Effect.fnUntraced(function* (options) {
1475
1523
  return yield* (yield* tag).newUniqueId(options);
1476
1524
  });
@@ -1528,7 +1576,7 @@ const Tag$6 = () => (id, methods) => {
1528
1576
  unsafeRaw
1529
1577
  });
1530
1578
  };
1531
- const DurableObject$1 = Tag$6;
1579
+ const DurableObject$1 = Tag$7;
1532
1580
  const wrapHandlers = (definition, handlers) => {
1533
1581
  const wrapped = {};
1534
1582
  for (const key of Object.keys(definition.methods)) {
@@ -1546,9 +1594,9 @@ const implement$3 = (_definition, handlers) => handlers;
1546
1594
  //#endregion
1547
1595
  //#region src/DurableObject.ts
1548
1596
  var DurableObject_exports = /* @__PURE__ */ __exportAll({
1549
- Tag: () => Tag$5,
1597
+ Tag: () => Tag$6,
1550
1598
  implement: () => implement$2,
1551
- make: () => make$4,
1599
+ make: () => make$5,
1552
1600
  method: () => method
1553
1601
  });
1554
1602
  const reservedMethodNames = new Set([
@@ -1564,12 +1612,12 @@ const RunSymbol = Symbol.for("effect-cf/DurableObject/run");
1564
1612
  /**
1565
1613
  * Creates a Durable Object class backed by a single managed Effect runtime.
1566
1614
  */
1567
- const make$4 = (layer, options = {}) => {
1615
+ const make$5 = (layer, options = {}) => {
1568
1616
  class EffectDurableObject extends DurableObject {
1569
1617
  runtime;
1570
1618
  constructor(state, env) {
1571
1619
  super(state, env);
1572
- const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$7, Layer.succeed(DurableObjectState, fromDurableObjectState(state)), Layer.succeed(WorkerEnvironment, env)));
1620
+ const runtimeLayer = provideEntrypointServices(layer, Layer.mergeAll(layer$8, ConfigProvider.layer(Effect.succeed(WorkerConfig.providerFromEnv(env))), Layer.succeed(DurableObjectState, fromDurableObjectState(state)), Layer.succeed(WorkerEnvironment, env)));
1573
1621
  this.runtime = ManagedRuntime.make(runtimeLayer);
1574
1622
  const initialize = options.initialize;
1575
1623
  if (initialize !== void 0) state.waitUntil(this[RunSymbol](initialize, { eventLayer: false }));
@@ -1606,7 +1654,7 @@ const make$4 = (layer, options = {}) => {
1606
1654
  defineEntrypointRpcMethods("Durable Object", EffectDurableObject.prototype, options.rpc, reservedMethodNames, (self, effect) => self[RunSymbol](effect));
1607
1655
  return assumeEntrypointClass(EffectDurableObject);
1608
1656
  };
1609
- const Tag$5 = Tag$6;
1657
+ const Tag$6 = Tag$7;
1610
1658
  const method = method$1;
1611
1659
  const implement$2 = implement$3;
1612
1660
  //#endregion
@@ -1935,7 +1983,7 @@ var DurableObjectAlarm = class DurableObjectAlarm extends Context.Service()("eff
1935
1983
  //#region src/DurableObjectRpcWebSocket.ts
1936
1984
  var DurableObjectRpcWebSocket_exports = /* @__PURE__ */ __exportAll({
1937
1985
  DurableObjectRpcWebSocket: () => DurableObjectRpcWebSocket,
1938
- layer: () => layer$5
1986
+ layer: () => layer$6
1939
1987
  });
1940
1988
  const defaultAttachmentKey = "effectCloudflareRpcClientId";
1941
1989
  const defaultTag = "effect-cf-rpc";
@@ -1946,7 +1994,7 @@ var DurableObjectRpcWebSocket = class extends Context.Service()("effect-cf/Durab
1946
1994
  /**
1947
1995
  * Builds a layer that bridges Durable Object websocket events to `RpcServer.Protocol`.
1948
1996
  */
1949
- const layer$5 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1997
+ const layer$6 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
1950
1998
  const tag = options.tag ?? defaultTag;
1951
1999
  const attachmentKey = options.attachmentKey ?? defaultAttachmentKey;
1952
2000
  const durableObjectState = yield* DurableObjectState;
@@ -2059,7 +2107,7 @@ const writeAttachment = (socket, key, clientId) => {
2059
2107
  };
2060
2108
  //#endregion
2061
2109
  //#region src/DurableObjectSqlite.ts
2062
- var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$4 });
2110
+ var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$5 });
2063
2111
  /**
2064
2112
  * Provides `effect/unstable/sql` from the current Durable Object SQLite storage.
2065
2113
  *
@@ -2071,7 +2119,7 @@ var DurableObjectSqlite_exports = /* @__PURE__ */ __exportAll({ layer: () => lay
2071
2119
  * );
2072
2120
  * ```
2073
2121
  */
2074
- const layer$4 = (options) => Layer.unwrap(Effect.gen(function* () {
2122
+ const layer$5 = (options) => Layer.unwrap(Effect.gen(function* () {
2075
2123
  const state = yield* DurableObjectState;
2076
2124
  return SqliteClient.layer({
2077
2125
  ...options,
@@ -2082,13 +2130,13 @@ const layer$4 = (options) => Layer.unwrap(Effect.gen(function* () {
2082
2130
  //#region src/Images.ts
2083
2131
  var Images_exports = /* @__PURE__ */ __exportAll({
2084
2132
  ImagesOperationError: () => ImagesOperationError,
2085
- Tag: () => Tag$4,
2133
+ Tag: () => Tag$5,
2086
2134
  draw: () => draw,
2087
2135
  empty: () => empty,
2088
2136
  isImagesBinding: () => isImagesBinding,
2089
- layer: () => layer$3,
2090
- make: () => make$3,
2091
- makeClient: () => makeClient$3,
2137
+ layer: () => layer$4,
2138
+ make: () => make$4,
2139
+ makeClient: () => makeClient$4,
2092
2140
  transform: () => transform
2093
2141
  });
2094
2142
  const TypeId = "effect-cf/Images/Steps";
@@ -2129,9 +2177,9 @@ const tryImagesSync = (binding, operation, evaluate) => Effect.try({
2129
2177
  catch: (cause) => imagesError(binding, operation, cause)
2130
2178
  });
2131
2179
  const maybe$1 = (value) => value === null ? Option.none() : Option.some(value);
2132
- const hasFunction = (value, key) => typeof Reflect.get(value, key) === "function";
2133
- const isHostedImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction(value, "image") && hasFunction(value, "upload") && hasFunction(value, "list");
2134
- const isImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction(value, "info") && hasFunction(value, "input");
2180
+ const hasFunction$1 = (value, key) => typeof Reflect.get(value, key) === "function";
2181
+ const isHostedImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "image") && hasFunction$1(value, "upload") && hasFunction$1(value, "list");
2182
+ const isImagesBinding = (value) => typeof value === "object" && value !== null && hasFunction$1(value, "info") && hasFunction$1(value, "input");
2135
2183
  const wrapResult = (binding, result) => ({
2136
2184
  raw: result,
2137
2185
  response: tryImagesSync(binding, "response", () => result.response()),
@@ -2151,7 +2199,7 @@ const wrapHosted = (binding, hosted) => ({
2151
2199
  list: (options) => tryImagesPromise(binding, "list", () => hosted.list(options)),
2152
2200
  unsafeRaw: Effect.succeed(hosted)
2153
2201
  });
2154
- const makeClient$3 = (definition) => (images) => {
2202
+ const makeClient$4 = (definition) => (images) => {
2155
2203
  const input = (image, options) => tryImagesSync(definition.binding, "input", () => images.input(image, options));
2156
2204
  const process = (steps, options) => Effect.gen(function* () {
2157
2205
  let transformer = yield* input(options.stream, options.inputOptions);
@@ -2175,11 +2223,11 @@ const makeClient$3 = (definition) => (images) => {
2175
2223
  unsafeRaw: Effect.succeed(images)
2176
2224
  };
2177
2225
  };
2178
- const layer$3 = (tag, definition) => layer$11(tag, definition.binding, isImagesBinding, makeClient$3(definition), { expected: expectedImagesBinding });
2179
- const make$3 = (id) => Tag$4()(id);
2180
- const Tag$4 = () => (id) => {
2226
+ const layer$4 = (tag, definition) => layer$15(tag, definition.binding, isImagesBinding, makeClient$4(definition), { expected: expectedImagesBinding });
2227
+ const make$4 = (id) => Tag$5()(id);
2228
+ const Tag$5 = () => (id) => {
2181
2229
  const tag = Context.Service()(id);
2182
- const makeLayer = (definition) => layer$3(tag, definition);
2230
+ const makeLayer = (definition) => layer$4(tag, definition);
2183
2231
  return Object.assign(tag, {
2184
2232
  id,
2185
2233
  layer: makeLayer
@@ -2189,10 +2237,10 @@ const Tag$4 = () => (id) => {
2189
2237
  //#region src/Kv.ts
2190
2238
  var Kv_exports = /* @__PURE__ */ __exportAll({
2191
2239
  KvOperationError: () => KvOperationError,
2192
- Tag: () => Tag$3,
2240
+ Tag: () => Tag$4,
2193
2241
  isKvNamespace: () => isKvNamespace,
2194
- layer: () => layer$2,
2195
- makeClient: () => makeClient$2
2242
+ layer: () => layer$3,
2243
+ makeClient: () => makeClient$3
2196
2244
  });
2197
2245
  const expectedKvNamespace = "KV namespace binding with get(), put(), delete(), getWithMetadata(), and list()";
2198
2246
  /** Error raised when a KV operation fails. */
@@ -2213,7 +2261,7 @@ const isKvNamespace = (value) => {
2213
2261
  const resource = value;
2214
2262
  return typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.delete === "function" && typeof resource.getWithMetadata === "function" && typeof resource.list === "function";
2215
2263
  };
2216
- const makeClient$2 = (definition) => {
2264
+ const makeClient$3 = (definition) => {
2217
2265
  const encodeKey = Schema.encodeEffect(definition.key);
2218
2266
  const decodeKey = Schema.decodeUnknownEffect(definition.key);
2219
2267
  const encodeValue = Schema.encodeEffect(Schema.fromJsonString(Schema.toCodecJson(definition.value)));
@@ -2270,20 +2318,20 @@ const makeClient$2 = (definition) => {
2270
2318
  unsafeRaw: Effect.succeed(kv)
2271
2319
  });
2272
2320
  };
2273
- const layer$2 = (tag, definition) => layer$11(tag, definition.binding, isKvNamespace, makeClient$2(definition), { expected: expectedKvNamespace });
2321
+ const layer$3 = (tag, definition) => layer$15(tag, definition.binding, isKvNamespace, makeClient$3(definition), { expected: expectedKvNamespace });
2274
2322
  const makeDefinition$1 = (id, definition) => {
2275
2323
  const kvDefinition = {
2276
2324
  id,
2277
2325
  key: definition.key,
2278
2326
  value: definition.value
2279
2327
  };
2280
- return Object.assign(kvDefinition, { layer: (tag, binding) => layer$2(tag, {
2328
+ return Object.assign(kvDefinition, { layer: (tag, binding) => layer$3(tag, {
2281
2329
  ...binding,
2282
2330
  key: definition.key,
2283
2331
  value: definition.value
2284
2332
  }) });
2285
2333
  };
2286
- const Tag$3 = () => (id, definition) => {
2334
+ const Tag$4 = () => (id, definition) => {
2287
2335
  const kvDefinition = makeDefinition$1(id, definition);
2288
2336
  const tag = Context.Service()(id);
2289
2337
  const makeLayer = (binding) => kvDefinition.layer(tag, binding);
@@ -2298,11 +2346,11 @@ const Tag$3 = () => (id, definition) => {
2298
2346
  //#region src/R2.ts
2299
2347
  var R2_exports = /* @__PURE__ */ __exportAll({
2300
2348
  R2OperationError: () => R2OperationError,
2301
- Tag: () => Tag$2,
2349
+ Tag: () => Tag$3,
2302
2350
  isR2Bucket: () => isR2Bucket,
2303
- layer: () => layer$1,
2304
- make: () => make$2,
2305
- makeClient: () => makeClient$1
2351
+ layer: () => layer$2,
2352
+ make: () => make$3,
2353
+ makeClient: () => makeClient$2
2306
2354
  });
2307
2355
  const expectedR2Bucket = "R2 bucket binding with head(), get(), put(), createMultipartUpload(), resumeMultipartUpload(), delete(), and list()";
2308
2356
  /** Error raised when an R2 operation fails. */
@@ -2356,7 +2404,7 @@ const isR2Bucket = (value) => {
2356
2404
  const resource = value;
2357
2405
  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";
2358
2406
  };
2359
- const makeClient$1 = (definition) => {
2407
+ const makeClient$2 = (definition) => {
2360
2408
  const wrapUpload = (upload) => ({
2361
2409
  raw: upload,
2362
2410
  key: upload.key,
@@ -2387,11 +2435,11 @@ const makeClient$1 = (definition) => {
2387
2435
  };
2388
2436
  };
2389
2437
  };
2390
- const layer$1 = (tag, definition) => layer$11(tag, definition.binding, isR2Bucket, makeClient$1(definition), { expected: expectedR2Bucket });
2391
- const make$2 = (id) => Tag$2()(id);
2392
- const Tag$2 = () => (id) => {
2438
+ const layer$2 = (tag, definition) => layer$15(tag, definition.binding, isR2Bucket, makeClient$2(definition), { expected: expectedR2Bucket });
2439
+ const make$3 = (id) => Tag$3()(id);
2440
+ const Tag$3 = () => (id) => {
2393
2441
  const tag = Context.Service()(id);
2394
- const makeLayer = (definition) => layer$1(tag, definition);
2442
+ const makeLayer = (definition) => layer$2(tag, definition);
2395
2443
  return Object.assign(tag, {
2396
2444
  id,
2397
2445
  layer: makeLayer
@@ -2403,8 +2451,8 @@ var WorkflowBinding_exports = /* @__PURE__ */ __exportAll({
2403
2451
  WorkflowOperationError: () => WorkflowOperationError,
2404
2452
  WorkflowResultDecodeError: () => WorkflowResultDecodeError,
2405
2453
  isWorkflow: () => isWorkflow,
2406
- layer: () => layer,
2407
- makeClient: () => makeClient
2454
+ layer: () => layer$1,
2455
+ makeClient: () => makeClient$1
2408
2456
  });
2409
2457
  const expectedWorkflow = "Workflow binding with create(), createBatch(), and get()";
2410
2458
  var WorkflowOperationError = class extends Data.TaggedError("WorkflowOperationError") {};
@@ -2423,7 +2471,7 @@ const isWorkflow = (value) => {
2423
2471
  const resource = value;
2424
2472
  return typeof resource.create === "function" && typeof resource.createBatch === "function" && typeof resource.get === "function";
2425
2473
  };
2426
- const makeClient = (definition) => {
2474
+ const makeClient$1 = (definition) => {
2427
2475
  const encodePayload = Schema.encodeEffect(definition.payload);
2428
2476
  const decodeResult = Schema.decodeUnknownEffect(definition.result);
2429
2477
  const wrapInstance = (raw) => {
@@ -2473,14 +2521,14 @@ const makeClient = (definition) => {
2473
2521
  unsafeRaw: Effect.succeed(workflow)
2474
2522
  });
2475
2523
  };
2476
- const layer = (tag, definition) => layer$11(tag, definition.binding, (value) => isWorkflow(value), makeClient(definition), { expected: expectedWorkflow });
2524
+ const layer$1 = (tag, definition) => layer$15(tag, definition.binding, (value) => isWorkflow(value), makeClient$1(definition), { expected: expectedWorkflow });
2477
2525
  //#endregion
2478
2526
  //#region src/WorkflowDefinition.ts
2479
2527
  var WorkflowDefinition_exports = /* @__PURE__ */ __exportAll({
2480
- Tag: () => Tag$1,
2528
+ Tag: () => Tag$2,
2481
2529
  Workflow: () => Workflow,
2482
2530
  implement: () => implement$1,
2483
- make: () => make$1
2531
+ make: () => make$2
2484
2532
  });
2485
2533
  const makeDefinition = (id, definition) => {
2486
2534
  const workflowDefinition = {
@@ -2488,13 +2536,13 @@ const makeDefinition = (id, definition) => {
2488
2536
  payload: definition.payload,
2489
2537
  result: definition.result
2490
2538
  };
2491
- return Object.assign(workflowDefinition, { make: (layer, options) => make(layer, { run: wrapHandler(workflowDefinition, options.run) }) });
2539
+ return Object.assign(workflowDefinition, { make: (layer, options) => make$1(layer, { run: wrapHandler(workflowDefinition, options.run) }) });
2492
2540
  };
2493
- const make$1 = (id, definition) => Tag$1()(id, definition);
2494
- const Tag$1 = () => (id, definition) => {
2541
+ const make$2 = (id, definition) => Tag$2()(id, definition);
2542
+ const Tag$2 = () => (id, definition) => {
2495
2543
  const workflowDefinition = makeDefinition(id, definition);
2496
2544
  const tag = Context.Service()(id);
2497
- const layer$12 = (binding) => layer(tag, {
2545
+ const layer = (binding) => layer$1(tag, {
2498
2546
  ...binding,
2499
2547
  payload: definition.payload,
2500
2548
  result: definition.result
@@ -2516,14 +2564,14 @@ const Tag$1 = () => (id, definition) => {
2516
2564
  payload: workflowDefinition.payload,
2517
2565
  result: workflowDefinition.result,
2518
2566
  make: workflowDefinition.make,
2519
- layer: layer$12,
2567
+ layer,
2520
2568
  create,
2521
2569
  createBatch,
2522
2570
  get,
2523
2571
  unsafeRaw
2524
2572
  });
2525
2573
  };
2526
- const Workflow = Tag$1;
2574
+ const Workflow = Tag$2;
2527
2575
  const wrapHandler = (definition, handler) => {
2528
2576
  const decodePayload = Schema.decodeUnknownEffect(definition.payload);
2529
2577
  const encodeResult = Schema.encodeEffect(definition.result);
@@ -2540,12 +2588,12 @@ const implement$1 = (_definition, handler) => handler;
2540
2588
  //#endregion
2541
2589
  //#region src/Workflow.ts
2542
2590
  var Workflow_exports = /* @__PURE__ */ __exportAll({
2543
- Tag: () => Tag,
2591
+ Tag: () => Tag$1,
2544
2592
  WorkflowEvent: () => WorkflowEvent$1,
2545
2593
  WorkflowStep: () => WorkflowStep$1,
2546
2594
  WorkflowStepContext: () => WorkflowStepContext$1,
2547
2595
  implement: () => implement,
2548
- make: () => make,
2596
+ make: () => make$1,
2549
2597
  sleep: () => sleep,
2550
2598
  sleepUntil: () => sleepUntil,
2551
2599
  step: () => step,
@@ -2558,7 +2606,8 @@ const fromWorkflowEvent = (event) => ({
2558
2606
  raw: event,
2559
2607
  payload: event.payload,
2560
2608
  timestamp: event.timestamp,
2561
- instanceId: event.instanceId
2609
+ instanceId: event.instanceId,
2610
+ workflowName: event.workflowName
2562
2611
  });
2563
2612
  const fromWorkflowStep = (step, runPromise) => ({
2564
2613
  raw: step,
@@ -2583,7 +2632,7 @@ const fromWorkflowStep = (step, runPromise) => ({
2583
2632
  catch: (cause) => cause
2584
2633
  })
2585
2634
  });
2586
- const make = (layer, options) => {
2635
+ const make$1 = (layer, options) => {
2587
2636
  class EffectWorkflow extends WorkflowEntrypoint {
2588
2637
  runtime;
2589
2638
  constructor(ctx, env) {
@@ -2604,7 +2653,57 @@ const step = (name, effect, config) => Effect.flatMap(WorkflowStep$1, (workflowS
2604
2653
  const sleep = (name, duration) => Effect.flatMap(WorkflowStep$1, (workflowStep) => workflowStep.sleep(name, duration));
2605
2654
  const sleepUntil = (name, timestamp) => Effect.flatMap(WorkflowStep$1, (workflowStep) => workflowStep.sleepUntil(name, timestamp));
2606
2655
  const waitForEvent = (name, options) => Effect.flatMap(WorkflowStep$1, (workflowStep) => workflowStep.waitForEvent(name, options));
2607
- const Tag = Tag$1;
2656
+ const Tag$1 = Tag$2;
2608
2657
  const implement = implement$1;
2609
2658
  //#endregion
2610
- export { Binding_exports as Binding, CloudflareOtlp_exports as CloudflareOtlp, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
2659
+ //#region src/Vectorize.ts
2660
+ var Vectorize_exports = /* @__PURE__ */ __exportAll({
2661
+ Tag: () => Tag,
2662
+ VectorizeOperationError: () => VectorizeOperationError,
2663
+ isVectorizeBinding: () => isVectorizeBinding,
2664
+ layer: () => layer,
2665
+ make: () => make,
2666
+ makeClient: () => makeClient
2667
+ });
2668
+ const expectedVectorizeBinding = "Vectorize index binding with describe(), query(), insert(), upsert(), deleteByIds(), and getByIds()";
2669
+ /** Error raised when a Vectorize operation fails. */
2670
+ var VectorizeOperationError = class extends Data.TaggedError("VectorizeOperationError") {};
2671
+ const vectorizeError = (binding, operation, cause) => new VectorizeOperationError({
2672
+ binding,
2673
+ operation,
2674
+ cause
2675
+ });
2676
+ const tryVectorizePromise = (binding, operation, evaluate) => Effect.tryPromise({
2677
+ try: evaluate,
2678
+ catch: (cause) => vectorizeError(binding, operation, cause)
2679
+ });
2680
+ const hasFunction = (value, key) => typeof Reflect.get(value, key) === "function";
2681
+ 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");
2682
+ const makeClient = (definition) => (index) => {
2683
+ const runtime = index;
2684
+ const deleteByIds = (ids) => tryVectorizePromise(definition.binding, "deleteByIds", () => runtime.deleteByIds([...ids]));
2685
+ return {
2686
+ definition,
2687
+ describe: tryVectorizePromise(definition.binding, "describe", () => runtime.describe()),
2688
+ query: (vector, options) => tryVectorizePromise(definition.binding, "query", () => runtime.query(vector, options)),
2689
+ 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()"))),
2690
+ insert: (vectors) => tryVectorizePromise(definition.binding, "insert", () => runtime.insert([...vectors])),
2691
+ upsert: (vectors) => tryVectorizePromise(definition.binding, "upsert", () => runtime.upsert([...vectors])),
2692
+ deleteByIds,
2693
+ delete: deleteByIds,
2694
+ getByIds: (ids) => tryVectorizePromise(definition.binding, "getByIds", () => runtime.getByIds([...ids])),
2695
+ unsafeRaw: Effect.succeed(index)
2696
+ };
2697
+ };
2698
+ const layer = (tag, definition) => layer$15(tag, definition.binding, isVectorizeBinding, makeClient(definition), { expected: expectedVectorizeBinding });
2699
+ const make = (id) => Tag()(id);
2700
+ const Tag = () => (id) => {
2701
+ const tag = Context.Service()(id);
2702
+ const makeLayer = (definition) => layer(tag, definition);
2703
+ return Object.assign(tag, {
2704
+ id,
2705
+ layer: makeLayer
2706
+ });
2707
+ };
2708
+ //#endregion
2709
+ export { AiGateway_exports as AiGateway, Binding_exports as Binding, BrowserRendering_exports as BrowserRendering, CloudflareOtlp_exports as CloudflareOtlp, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, ServiceBinding_exports as ServiceBinding, Vectorize_exports as Vectorize, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, WorkersAi_exports as WorkersAi, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };