@cloudflare/workers-utils 0.21.1 → 0.22.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.
@@ -1,4 +1,4 @@
1
- import { T as TailConsumer, av as WorkerMetadata, R as RawConfig } from './config-BH_2HMEf.mjs';
1
+ import { T as TailConsumer, az as WorkerMetadata, R as RawConfig } from './config-CXobNAeT.mjs';
2
2
  import { AssetConfig } from '@cloudflare/workers-shared';
3
3
  import { Cloudflare } from 'cloudflare';
4
4
 
package/dist/browser.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { constructWranglerConfig } from './chunk-BLWXWFJK.mjs';
1
+ export { constructWranglerConfig } from './chunk-UFU4JGIG.mjs';
2
2
  import './chunk-OZQVB3L3.mjs';
3
3
  import './chunk-DCOBXSFB.mjs';
@@ -38,8 +38,7 @@ function mapWorkerMetadataBindings(bindings) {
38
38
  {
39
39
  configObj.vars = {
40
40
  ...configObj.vars ?? {},
41
- name: binding.name,
42
- json: binding.json
41
+ [binding.name]: binding.json
43
42
  };
44
43
  }
45
44
  break;
@@ -300,6 +299,23 @@ function mapWorkerMetadataBindings(bindings) {
300
299
  }
301
300
  ];
302
301
  break;
302
+ case "web_search":
303
+ {
304
+ configObj.web_search = {
305
+ binding: binding.name
306
+ };
307
+ }
308
+ break;
309
+ case "agent_memory": {
310
+ configObj.agent_memory = [
311
+ ...configObj.agent_memory ?? [],
312
+ {
313
+ binding: binding.name,
314
+ namespace: binding.namespace
315
+ }
316
+ ];
317
+ break;
318
+ }
303
319
  case "hyperdrive":
304
320
  configObj.hyperdrive = [
305
321
  ...configObj.hyperdrive ?? [],
@@ -323,7 +339,9 @@ function mapWorkerMetadataBindings(bindings) {
323
339
  ...configObj.pipelines ?? [],
324
340
  {
325
341
  binding: binding.name,
326
- pipeline: binding.pipeline
342
+ // NOTE: stream is the primary field, but we also support pipeline for backward compatibility
343
+ ...binding.stream && { stream: binding.stream },
344
+ ...binding.pipeline && { pipeline: binding.pipeline }
327
345
  }
328
346
  ];
329
347
  break;
@@ -174,7 +174,7 @@ interface CfWorkflow {
174
174
  limits?: {
175
175
  steps?: number;
176
176
  };
177
- schedule?: string | string[];
177
+ schedules?: string | string[];
178
178
  }
179
179
  interface CfQueue {
180
180
  binding: string;
@@ -217,6 +217,15 @@ interface CfAISearch {
217
217
  instance_name: string;
218
218
  remote?: boolean;
219
219
  }
220
+ interface CfWebSearch {
221
+ binding: string;
222
+ remote?: boolean;
223
+ }
224
+ interface CfAgentMemory {
225
+ binding: string;
226
+ namespace: string | typeof INHERIT_SYMBOL;
227
+ remote?: boolean;
228
+ }
220
229
  interface CfSecretsStoreSecrets {
221
230
  binding: string;
222
231
  store_id: string;
@@ -303,7 +312,8 @@ interface CfAssetsBinding {
303
312
  }
304
313
  interface CfPipeline {
305
314
  binding: string;
306
- pipeline: string;
315
+ stream?: string;
316
+ pipeline?: string;
307
317
  remote?: boolean;
308
318
  }
309
319
  interface CfUnsafeBinding {
@@ -515,6 +525,13 @@ type WorkerMetadataBinding = {
515
525
  type: "ai_search";
516
526
  name: string;
517
527
  instance_name: string;
528
+ } | {
529
+ type: "web_search";
530
+ name: string;
531
+ } | {
532
+ type: "agent_memory";
533
+ name: string;
534
+ namespace: string;
518
535
  } | {
519
536
  type: "kv_namespace";
520
537
  name: string;
@@ -602,7 +619,8 @@ type WorkerMetadataBinding = {
602
619
  } | {
603
620
  type: "pipelines";
604
621
  name: string;
605
- pipeline: string;
622
+ stream?: string;
623
+ pipeline?: string;
606
624
  } | {
607
625
  type: "secrets_store_secret";
608
626
  name: string;
@@ -655,6 +673,38 @@ type AssetConfigMetadata = {
655
673
  _redirects?: string;
656
674
  _headers?: string;
657
675
  };
676
+ type AssetsOptions = {
677
+ directory: string;
678
+ binding?: string;
679
+ routerConfig: RouterConfig;
680
+ assetConfig: AssetConfig;
681
+ _redirects?: string;
682
+ _headers?: string;
683
+ run_worker_first?: boolean | string[];
684
+ };
685
+ /**
686
+ * Information about the assets that should be uploaded
687
+ */
688
+ interface LegacyAssetPaths {
689
+ /**
690
+ * Absolute path to the root of the project.
691
+ *
692
+ * This is the directory containing wrangler.toml or cwd if no config.
693
+ */
694
+ baseDirectory: string;
695
+ /**
696
+ * The path to the assets directory, relative to the `baseDirectory`.
697
+ */
698
+ assetDirectory: string;
699
+ /**
700
+ * An array of patterns that match files that should be uploaded.
701
+ */
702
+ includePatterns: string[];
703
+ /**
704
+ * An array of patterns that match files that should not be uploaded.
705
+ */
706
+ excludePatterns: string[];
707
+ }
658
708
  type WorkerMetadataPut = {
659
709
  /** The name of the entry point module. Only exists when the worker is in the ES module format */
660
710
  main_module?: string;
@@ -808,6 +858,10 @@ type Binding = {
808
858
  } & BindingOmit<CfAISearchNamespace>) | ({
809
859
  type: "ai_search";
810
860
  } & BindingOmit<CfAISearch>) | ({
861
+ type: "web_search";
862
+ } & BindingOmit<CfWebSearch>) | ({
863
+ type: "agent_memory";
864
+ } & BindingOmit<CfAgentMemory>) | ({
811
865
  type: "hyperdrive";
812
866
  } & BindingOmit<CfHyperdrive>) | ({
813
867
  type: "service";
@@ -849,6 +903,29 @@ type Binding = {
849
903
  } | {
850
904
  type: "inherit";
851
905
  };
906
+ /**
907
+ * An entry point for the Worker.
908
+ *
909
+ * It consists not just of a `file`, but also of a `directory` that is used to resolve relative paths.
910
+ */
911
+ type Entry = {
912
+ /** A worker's entrypoint */
913
+ file: string;
914
+ /** A worker's directory. Usually where the Wrangler configuration file is located */
915
+ projectRoot: string;
916
+ /** The path to the config file, if it exists. */
917
+ configPath: string | undefined;
918
+ /** Is this a module worker or a service worker? */
919
+ format: CfScriptFormat;
920
+ /** The directory that contains all of a `--no-bundle` worker's modules. Usually `${directory}/src`. Defaults to path.dirname(file) */
921
+ moduleRoot: string;
922
+ /**
923
+ * A worker's name
924
+ */
925
+ name?: string | undefined;
926
+ /** Export from a Worker's entrypoint */
927
+ exports: string[];
928
+ };
852
929
 
853
930
  /**
854
931
  * The `Environment` interface declares all the configuration fields that
@@ -1499,7 +1576,7 @@ type WorkflowBinding = {
1499
1576
  steps?: number;
1500
1577
  };
1501
1578
  /** Optional cron schedule(s) for automatically triggering workflow instances */
1502
- schedule?: string | string[];
1579
+ schedules?: string | string[];
1503
1580
  };
1504
1581
  /**
1505
1582
  * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
@@ -1797,6 +1874,40 @@ interface EnvironmentNonInheritable {
1797
1874
  /** Whether the AI Search instance binding should be remote in local development */
1798
1875
  remote?: boolean;
1799
1876
  }[];
1877
+ /**
1878
+ * Specifies Agent Memory namespace bindings that are bound to this Worker environment.
1879
+ *
1880
+ * NOTE: This field is not automatically inherited from the top level environment,
1881
+ * and so must be specified in every named environment.
1882
+ *
1883
+ * @default []
1884
+ * @nonInheritable
1885
+ */
1886
+ agent_memory: {
1887
+ /** The binding name used to refer to the Agent Memory namespace in the Worker. */
1888
+ binding: string;
1889
+ /** The user-chosen namespace name. Must exist in Cloudflare at deploy time. */
1890
+ namespace: string;
1891
+ /** Whether the Agent Memory binding should be remote in local development */
1892
+ remote?: boolean;
1893
+ }[];
1894
+ /**
1895
+ * Cloudflare Web Search binding. There is exactly one shared web corpus, so the
1896
+ * binding is zero-config -- only the variable name is required, declared as a
1897
+ * single object (not an array).
1898
+ *
1899
+ * NOTE: This field is not automatically inherited from the top level environment,
1900
+ * and so must be specified in every named environment.
1901
+ *
1902
+ * @default {}
1903
+ * @nonInheritable
1904
+ */
1905
+ web_search: {
1906
+ /** The binding name used to refer to Web Search in the Worker. */
1907
+ binding: string;
1908
+ /** Whether the Web Search binding should be remote or not in local development */
1909
+ remote?: boolean;
1910
+ } | undefined;
1800
1911
  /**
1801
1912
  * Specifies Hyperdrive configs that are bound to this Worker environment.
1802
1913
  *
@@ -2058,8 +2169,13 @@ interface EnvironmentNonInheritable {
2058
2169
  pipelines: {
2059
2170
  /** The binding name used to refer to the bound service. */
2060
2171
  binding: string;
2061
- /** Name of the Pipeline to bind */
2062
- pipeline: string;
2172
+ /** Id of the Stream to bind */
2173
+ stream?: string;
2174
+ /**
2175
+ * Id of the Stream to bind
2176
+ * @deprecated Use `stream` instead.
2177
+ */
2178
+ pipeline?: string;
2063
2179
  /** Whether the pipeline should be remote or not in local development */
2064
2180
  remote?: boolean;
2065
2181
  }[];
@@ -2583,4 +2699,4 @@ interface EnvironmentMap {
2583
2699
  }
2584
2700
  declare const defaultWranglerConfig: Config;
2585
2701
 
2586
- export { type CfVectorize as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectMigration as D, type Environment as E, type CfWasmModuleBindings as F, type CfTextBlobBindings as G, type CfBrowserBinding as H, type CfAIBinding as I, type CfImagesBinding as J, type CfMediaBinding as K, type CfStreamBinding as L, type CfVersionMetadataBinding as M, type CfDataBlobBindings as N, type Observability as O, type PreviewsConfig as P, type CfDurableObject as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfWorkflow as V, type WorkerMetadataBinding as W, type CfQueue as X, type CfR2Bucket as Y, type ZoneIdRoute as Z, type CfD1Database as _, type RedirectedRawConfig as a, type CfAISearchNamespace as a0, type CfAISearch as a1, type CfSecretsStoreSecrets as a2, type CfArtifacts as a3, type CfHelloWorld as a4, type CfFlagship as a5, type CfWorkerLoader as a6, type CfRateLimit as a7, type CfHyperdrive as a8, type CfService as a9, type Trigger as aA, INHERIT_SYMBOL as aB, SERVICE_TAG_PREFIX as aC, ENVIRONMENT_TAG_PREFIX as aD, PATH_TO_DEPLOY_CONFIG as aE, JSON_CONFIG_FORMATS as aF, type CfVpcService as aa, type CfVpcNetwork as ab, type CfAnalyticsEngineDataset as ac, type CfDispatchNamespace as ad, type CfMTlsCertificate as ae, type CfLogfwdr as af, type CfLogfwdrBinding as ag, type CfAssetsBinding as ah, type CfPipeline as ai, type CfUnsafeBinding as aj, type CfCapnp as ak, type CfUnsafe as al, type CfDurableObjectMigrations as am, type CfPlacement as an, type CfTailConsumer as ao, type CfUserLimits as ap, type CfWorkerInit as aq, type CfWorkerContext as ar, type CfWorkerSourceMap as as, type Json as at, type AssetConfigMetadata as au, type WorkerMetadata as av, type ServiceMetadataRes as aw, type ServiceFetch as ax, type File as ay, type BinaryFile as az, type Config as b, type RawDevConfig as c, type ConfigFields as d, type RawEnvironment as e, defaultWranglerConfig as f, type ZoneNameRoute as g, type CustomDomainRoute as h, type Route as i, type CloudchamberConfig as j, type ContainerApp as k, type DurableObjectBindings as l, type WorkflowBinding as m, type EnvironmentNonInheritable as n, type Rule as o, type ConfigModuleRuleType as p, type DispatchNamespaceOutbound as q, type CacheOptions as r, type DockerConfiguration as s, type ContainerEngine as t, type CfScriptFormat as u, type CfModuleType as v, type CfModule as w, type CfVars as x, type CfKvNamespace as y, type CfSendEmailBindings as z };
2702
+ export { type CfVectorize as $, type Assets as A, type Binding as B, type ComputedFields as C, type DurableObjectMigration as D, type Environment as E, type CfWasmModuleBindings as F, type CfTextBlobBindings as G, type CfBrowserBinding as H, type CfAIBinding as I, type CfImagesBinding as J, type CfMediaBinding as K, type CfStreamBinding as L, type CfVersionMetadataBinding as M, type CfDataBlobBindings as N, type Observability as O, type PreviewsConfig as P, type CfDurableObject as Q, type RawConfig as R, type StreamingTailConsumer as S, type TailConsumer as T, type UserLimits as U, type CfWorkflow as V, type WorkerMetadataBinding as W, type CfQueue as X, type CfR2Bucket as Y, type ZoneIdRoute as Z, type CfD1Database as _, type RedirectedRawConfig as a, type CfAISearchNamespace as a0, type CfAISearch as a1, type CfWebSearch as a2, type CfAgentMemory as a3, type CfSecretsStoreSecrets as a4, type CfArtifacts as a5, type CfHelloWorld as a6, type CfFlagship as a7, type CfWorkerLoader as a8, type CfRateLimit as a9, type ServiceMetadataRes as aA, type ServiceFetch as aB, type File as aC, type BinaryFile as aD, type Trigger as aE, type Entry as aF, INHERIT_SYMBOL as aG, SERVICE_TAG_PREFIX as aH, ENVIRONMENT_TAG_PREFIX as aI, PATH_TO_DEPLOY_CONFIG as aJ, JSON_CONFIG_FORMATS as aK, type CfHyperdrive as aa, type CfService as ab, type CfVpcService as ac, type CfVpcNetwork as ad, type CfAnalyticsEngineDataset as ae, type CfDispatchNamespace as af, type CfMTlsCertificate as ag, type CfLogfwdr as ah, type CfLogfwdrBinding as ai, type CfAssetsBinding as aj, type CfPipeline as ak, type CfUnsafeBinding as al, type CfCapnp as am, type CfUnsafe as an, type CfDurableObjectMigrations as ao, type CfPlacement as ap, type CfTailConsumer as aq, type CfUserLimits as ar, type CfWorkerInit as as, type CfWorkerContext as at, type CfWorkerSourceMap as au, type Json as av, type AssetConfigMetadata as aw, type AssetsOptions as ax, type LegacyAssetPaths as ay, type WorkerMetadata as az, type Config as b, type RawDevConfig as c, type ConfigFields as d, type RawEnvironment as e, defaultWranglerConfig as f, type ZoneNameRoute as g, type CustomDomainRoute as h, type Route as i, type CloudchamberConfig as j, type ContainerApp as k, type DurableObjectBindings as l, type WorkflowBinding as m, type EnvironmentNonInheritable as n, type Rule as o, type ConfigModuleRuleType as p, type DispatchNamespaceOutbound as q, type CacheOptions as r, type DockerConfiguration as s, type ContainerEngine as t, type CfScriptFormat as u, type CfModuleType as v, type CfModule as w, type CfVars as x, type CfKvNamespace as y, type CfSendEmailBindings as z };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,11 @@
1
- import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding } from './config-BH_2HMEf.mjs';
2
- export { au as AssetConfigMetadata, A as Assets, az as BinaryFile, r as CacheOptions, I as CfAIBinding, a1 as CfAISearch, a0 as CfAISearchNamespace, ac as CfAnalyticsEngineDataset, a3 as CfArtifacts, ah as CfAssetsBinding, H as CfBrowserBinding, ak as CfCapnp, _ as CfD1Database, N as CfDataBlobBindings, ad as CfDispatchNamespace, Q as CfDurableObject, am as CfDurableObjectMigrations, a5 as CfFlagship, a4 as CfHelloWorld, a8 as CfHyperdrive, J as CfImagesBinding, y as CfKvNamespace, af as CfLogfwdr, ag as CfLogfwdrBinding, ae as CfMTlsCertificate, K as CfMediaBinding, w as CfModule, v as CfModuleType, ai as CfPipeline, an as CfPlacement, X as CfQueue, Y as CfR2Bucket, a7 as CfRateLimit, u as CfScriptFormat, a2 as CfSecretsStoreSecrets, z as CfSendEmailBindings, a9 as CfService, L as CfStreamBinding, ao as CfTailConsumer, G as CfTextBlobBindings, al as CfUnsafe, aj as CfUnsafeBinding, ap as CfUserLimits, x as CfVars, $ as CfVectorize, M as CfVersionMetadataBinding, ab as CfVpcNetwork, aa as CfVpcService, F as CfWasmModuleBindings, ar as CfWorkerContext, aq as CfWorkerInit, a6 as CfWorkerLoader, as as CfWorkerSourceMap, V as CfWorkflow, j as CloudchamberConfig, d as ConfigFields, p as ConfigModuleRuleType, k as ContainerApp, t as ContainerEngine, h as CustomDomainRoute, q as DispatchNamespaceOutbound, s as DockerConfiguration, l as DurableObjectBindings, D as DurableObjectMigration, aD as ENVIRONMENT_TAG_PREFIX, E as Environment, n as EnvironmentNonInheritable, ay as File, aB as INHERIT_SYMBOL, aF as JSON_CONFIG_FORMATS, at as Json, O as Observability, aE as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, c as RawDevConfig, e as RawEnvironment, a as RedirectedRawConfig, i as Route, o as Rule, aC as SERVICE_TAG_PREFIX, ax as ServiceFetch, aw as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, aA as Trigger, U as UserLimits, av as WorkerMetadata, m as WorkflowBinding, Z as ZoneIdRoute, g as ZoneNameRoute, f as defaultWranglerConfig } from './config-BH_2HMEf.mjs';
1
+ import { C as ComputedFields, B as Binding, R as RawConfig, b as Config, W as WorkerMetadataBinding } from './config-CXobNAeT.mjs';
2
+ export { aw as AssetConfigMetadata, A as Assets, ax as AssetsOptions, aD as BinaryFile, r as CacheOptions, I as CfAIBinding, a1 as CfAISearch, a0 as CfAISearchNamespace, a3 as CfAgentMemory, ae as CfAnalyticsEngineDataset, a5 as CfArtifacts, aj as CfAssetsBinding, H as CfBrowserBinding, am as CfCapnp, _ as CfD1Database, N as CfDataBlobBindings, af as CfDispatchNamespace, Q as CfDurableObject, ao as CfDurableObjectMigrations, a7 as CfFlagship, a6 as CfHelloWorld, aa as CfHyperdrive, J as CfImagesBinding, y as CfKvNamespace, ah as CfLogfwdr, ai as CfLogfwdrBinding, ag as CfMTlsCertificate, K as CfMediaBinding, w as CfModule, v as CfModuleType, ak as CfPipeline, ap as CfPlacement, X as CfQueue, Y as CfR2Bucket, a9 as CfRateLimit, u as CfScriptFormat, a4 as CfSecretsStoreSecrets, z as CfSendEmailBindings, ab as CfService, L as CfStreamBinding, aq as CfTailConsumer, G as CfTextBlobBindings, an as CfUnsafe, al as CfUnsafeBinding, ar as CfUserLimits, x as CfVars, $ as CfVectorize, M as CfVersionMetadataBinding, ad as CfVpcNetwork, ac as CfVpcService, F as CfWasmModuleBindings, a2 as CfWebSearch, at as CfWorkerContext, as as CfWorkerInit, a8 as CfWorkerLoader, au as CfWorkerSourceMap, V as CfWorkflow, j as CloudchamberConfig, d as ConfigFields, p as ConfigModuleRuleType, k as ContainerApp, t as ContainerEngine, h as CustomDomainRoute, q as DispatchNamespaceOutbound, s as DockerConfiguration, l as DurableObjectBindings, D as DurableObjectMigration, aI as ENVIRONMENT_TAG_PREFIX, aF as Entry, E as Environment, n as EnvironmentNonInheritable, aC as File, aG as INHERIT_SYMBOL, aK as JSON_CONFIG_FORMATS, av as Json, ay as LegacyAssetPaths, O as Observability, aJ as PATH_TO_DEPLOY_CONFIG, P as PreviewsConfig, c as RawDevConfig, e as RawEnvironment, a as RedirectedRawConfig, i as Route, o as Rule, aH as SERVICE_TAG_PREFIX, aB as ServiceFetch, aA as ServiceMetadataRes, S as StreamingTailConsumer, T as TailConsumer, aE as Trigger, U as UserLimits, az as WorkerMetadata, m as WorkflowBinding, Z as ZoneIdRoute, g as ZoneNameRoute, f as defaultWranglerConfig } from './config-CXobNAeT.mjs';
3
3
  import * as jsoncParser from 'jsonc-parser';
4
4
  export { constructWranglerConfig } from './browser.mjs';
5
5
  export { Counter, MetricsRegistry } from './prometheus-metrics.mjs';
6
6
  import { ChildProcess } from 'node:child_process';
7
+ import { URLSearchParams } from 'node:url';
8
+ import { RequestInit, Response, Headers } from 'undici';
7
9
  import '@cloudflare/workers-shared';
8
10
  import 'cloudflare';
9
11
 
@@ -90,7 +92,7 @@ declare const bucketFormatMessage = "Bucket names must begin and end with an alp
90
92
  * Config field names for bindings (e.g., "kv_namespaces", "d1_databases").
91
93
  * These are the keys used in Wrangler's config file
92
94
  */
93
- type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
95
+ type ConfigBindingFieldName = "data_blobs" | "durable_objects" | "kv_namespaces" | "send_email" | "queues" | "d1_databases" | "vectorize" | "ai_search_namespaces" | "ai_search" | "web_search" | "agent_memory" | "hyperdrive" | "r2_buckets" | "logfwdr" | "services" | "analytics_engine_datasets" | "text_blobs" | "browser" | "ai" | "images" | "stream" | "media" | "version_metadata" | "unsafe" | "vars" | "wasm_modules" | "dispatch_namespaces" | "mtls_certificates" | "workflows" | "pipelines" | "secrets_store_secrets" | "artifacts" | "ratelimits" | "assets" | "unsafe_hello_world" | "flagship" | "worker_loaders" | "vpc_services" | "vpc_networks";
94
96
  /**
95
97
  * @deprecated new code should use getBindingTypeFriendlyName() instead
96
98
  */
@@ -329,6 +331,22 @@ declare function parseHumanDuration(s: string): number;
329
331
  declare function parseNonHyphenedUuid(uuid: string | null): string | null;
330
332
  declare function parseByteSize(s: string, base?: number | undefined): number;
331
333
 
334
+ /**
335
+ * Local-dev capability of each binding type. Source of truth for
336
+ * `pickRemoteBindings()` and `warnOrError()`.
337
+ *
338
+ * - `local-and-remote`: local simulator; `remote: true` opts into proxying.
339
+ * - `local-only`: local simulator only; `remote: true` is a config error.
340
+ * - `remote`: no local simulator *yet* — requires explicit `remote: true`.
341
+ * Move to `local-and-remote` once a simulator lands.
342
+ * - `DO-NOT-USE-this-resource-will-never-have-a-local-simulator`: no local
343
+ * simulator, *ever* — fundamentally remote-only. Always auto-routed; user
344
+ * is warned about usage charges. Adding here is permanent; prefer any
345
+ * other variant if a simulator is plausible.
346
+ */
347
+ type BindingLocalSupport = "local-and-remote" | "local-only" | "remote" | "DO-NOT-USE-this-resource-will-never-have-a-local-simulator";
348
+ declare function getBindingLocalSupport(type: Binding["type"]): BindingLocalSupport;
349
+
332
350
  /**
333
351
  * Pages now supports configuration via a Wrangler configuration file. As opposed to
334
352
  * Workers however, Pages only supports a limited subset of all available
@@ -569,9 +587,12 @@ declare const getC3CommandFromEnv: () => string;
569
587
  */
570
588
  declare const getWranglerSendMetricsFromEnv: () => boolean | undefined;
571
589
  /**
572
- * `WRANGLER_SEND_ERROR_REPORTS` can override whether we attempt to send error reports to Sentry.
590
+ * `WRANGLER_SEND_ERROR_REPORTS` controls whether we attempt to send error reports to Sentry.
591
+ *
592
+ * Defaults to `false` to avoid noisy false-positive reports. Users can opt in
593
+ * by setting `WRANGLER_SEND_ERROR_REPORTS=true`.
573
594
  */
574
- declare const getWranglerSendErrorReportsFromEnv: () => boolean | undefined;
595
+ declare const getWranglerSendErrorReportsFromEnv: () => boolean;
575
596
  /**
576
597
  * Set `WRANGLER_API_ENVIRONMENT` environment variable to "staging" to tell Wrangler to hit the staging APIs rather than production.
577
598
  */
@@ -838,6 +859,35 @@ declare function removeDir(dirPath: string, options?: {
838
859
  */
839
860
  declare function removeDirSync(dirPath: string): void;
840
861
 
862
+ /**
863
+ * A short-lived directory. Automatically removed when the process exits, but
864
+ * can be removed earlier by calling `remove()`.
865
+ */
866
+ interface EphemeralDirectory {
867
+ path: string;
868
+ remove(): void;
869
+ }
870
+ /**
871
+ * Gets the path to the project's `.wrangler` folder.
872
+ */
873
+ declare function getWranglerHiddenDirPath(projectRoot: string | undefined): string;
874
+ /**
875
+ * Removes stale `.wrangler/tmp/*` entries left behind by previous wrangler
876
+ * sessions that exited abnormally (SIGKILL, OOM, host crash) and so missed
877
+ * the `signal-exit` cleanup. Runs at most once per tmp root per process.
878
+ *
879
+ * Exported for tests.
880
+ */
881
+ declare function sweepStaleWranglerTmpDirs(tmpRoot: string): void;
882
+ /**
883
+ * Gets a temporary directory in the project's `.wrangler` folder with the
884
+ * specified prefix. We create temporary directories in `.wrangler` as opposed
885
+ * to the OS's temporary directory to avoid issues with different drive letters
886
+ * on Windows. For example, when `esbuild` outputs a file to a different drive
887
+ * than the input sources, the generated source maps are incorrect.
888
+ */
889
+ declare function getWranglerTmpDir(projectRoot: string | undefined, prefix: string, cleanup?: boolean): EphemeralDirectory;
890
+
841
891
  /**
842
892
  * cloudflared binary management for Wrangler tunnel commands.
843
893
  *
@@ -846,7 +896,7 @@ declare function removeDirSync(dirPath: string): void;
846
896
  * the latest version and download URL, matching cloudflared's own update mechanism.
847
897
  */
848
898
 
849
- interface Logger {
899
+ interface Logger$1 {
850
900
  log: typeof console.log;
851
901
  warn: typeof console.warn;
852
902
  debug: typeof console.debug;
@@ -859,7 +909,7 @@ declare function spawnCloudflared(args: string[], options?: {
859
909
  env?: Record<string, string>;
860
910
  skipVersionCheck?: boolean;
861
911
  confirmDownload?: (message: string) => Promise<boolean>;
862
- logger?: Logger;
912
+ logger?: Logger$1;
863
913
  }): Promise<ChildProcess>;
864
914
 
865
915
  interface QuickTunnelResult {
@@ -883,7 +933,7 @@ interface TunnelOptions {
883
933
  expiryMs?: number;
884
934
  reminderIntervalMs?: number;
885
935
  extendHint?: string;
886
- logger?: Logger;
936
+ logger?: Logger$1;
887
937
  }
888
938
  /**
889
939
  * Start a Cloudflare Quick Tunnel for a local dev origin.
@@ -895,4 +945,96 @@ interface TunnelOptions {
895
945
  */
896
946
  declare function startTunnel(options: TunnelOptions): Tunnel;
897
947
 
898
- export { APIError, Binding, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, FatalError, JsonFriendlyFatalError, type Location, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerMetadataBinding, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTodaysCompatDate, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, mapWorkerMetadataBindings, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, resolveWranglerConfigPath, searchLocation, spawnCloudflared, startTunnel, validatePagesConfig };
948
+ interface FetchError {
949
+ code: number;
950
+ documentation_url?: string;
951
+ message: string;
952
+ error_chain?: FetchError[];
953
+ }
954
+
955
+ type Logger = {
956
+ debug: (...args: unknown[]) => void;
957
+ debugWithSanitization: (label: string, ...args: unknown[]) => void;
958
+ log: (...args: unknown[]) => void;
959
+ info: (...args: unknown[]) => void;
960
+ warn: (...args: unknown[]) => void;
961
+ error: (...args: unknown[]) => void;
962
+ };
963
+
964
+ type ApiCredentials = {
965
+ apiToken: string;
966
+ } | {
967
+ authKey: string;
968
+ authEmail: string;
969
+ };
970
+ interface FetchResult<ResponseType = unknown> {
971
+ success: boolean;
972
+ result: ResponseType;
973
+ errors: FetchError[];
974
+ messages?: (string | {
975
+ code?: number;
976
+ message: string;
977
+ })[];
978
+ result_info?: unknown;
979
+ }
980
+ type FetchResultFetcher = <ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams, abortSignal?: AbortSignal) => Promise<ResponseType>;
981
+ /**
982
+ *
983
+ * Note this requires its caller to handle credentials
984
+ * (need to call requireLoggedIn and requireApiToken)
985
+ */
986
+ declare function performApiFetchBase(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<Response>;
987
+ declare function fetchInternalBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<{
988
+ response: ResponseType;
989
+ status: number;
990
+ }>;
991
+ declare function fetchResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, abortSignal?: AbortSignal, credentials?: ApiCredentials): Promise<ResponseType>;
992
+ declare function fetchListResultBase<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init: RequestInit | undefined, userAgent: string, logger: Logger, queryParams?: URLSearchParams, credentials?: ApiCredentials): Promise<ResponseType[]>;
993
+ declare function truncate(text: string, maxLength: number): string;
994
+ declare function isWAFBlockResponse(headers: Headers): boolean;
995
+ declare function extractWAFBlockRayId(headers: Headers): string | undefined;
996
+ declare function extractAccountTag(resource: string): string | undefined;
997
+ interface PageResultInfo {
998
+ page: number;
999
+ per_page: number;
1000
+ count: number;
1001
+ total_count: number;
1002
+ }
1003
+ declare function hasMorePages(result_info: unknown): result_info is PageResultInfo;
1004
+ declare function renderError(err: FetchError | {
1005
+ code?: number;
1006
+ message?: string;
1007
+ documentation_url?: string;
1008
+ }, level?: number): string;
1009
+ declare function addAuthorizationHeader(headers: Headers, auth: ApiCredentials, overrideExisting?: boolean): void;
1010
+ declare function throwFetchError(resource: string, response: FetchResult<unknown>, status: number): never;
1011
+ declare function hasCursor(result_info: unknown): result_info is {
1012
+ cursor: string;
1013
+ };
1014
+ declare function maybeAddTraceHeader(headers: Headers): void;
1015
+
1016
+ type NpmVersionCheckResult = {
1017
+ status: "up-to-date";
1018
+ } | {
1019
+ status: "update-available";
1020
+ latest: string;
1021
+ } | {
1022
+ status: "failed";
1023
+ };
1024
+ /**
1025
+ * Checks if a newer version of a package is available on npm.
1026
+ *
1027
+ * Uses the `update-check` library to query the npm registry for the latest
1028
+ * version. The dist tag used for comparison depends on the current version —
1029
+ * "beta" for pre-release versions (0.0.0-*) and "latest" for stable versions.
1030
+ *
1031
+ * @param name - The npm package name to check
1032
+ * @param version - The current version to compare against
1033
+ * @returns A discriminated result:
1034
+ * - `{ status: "update-available", latest: string }` if a newer version exists
1035
+ * - `{ status: "up-to-date" }` if the installed version is already the latest
1036
+ * - `{ status: "failed" }` if the check could not be completed (network error, timeout, etc.)
1037
+ */
1038
+ declare function fetchLatestNpmVersion(name: string, version: string): Promise<NpmVersionCheckResult>;
1039
+
1040
+ export { APIError, type ApiCredentials, Binding, type BindingLocalSupport, COMPLIANCE_REGION_CONFIG_PUBLIC, COMPLIANCE_REGION_CONFIG_UNKNOWN, CommandLineArgsError, type CompatDate, type ComplianceConfig, Config, type ConfigBindingFieldName, type ConfigBindingOptions, DeprecationError, Diagnostics, type EphemeralDirectory, FatalError, type FetchResult, type FetchResultFetcher, JsonFriendlyFatalError, type Location, type Logger, type Message, MissingConfigError, type NormalizeAndValidateConfigArgs, type NpmVersionCheckResult, type PackageJSON, ParseError, type ParseFile, PatchConfigError, RawConfig, type ResolveConfigPathOptions, type TelemetryMessage, type Tunnel, type TunnelOptions, UserError, WorkerMetadataBinding, addAuthorizationHeader, assertNever, bucketFormatMessage, configFileName, configFormat, createFatalError, experimental_patchConfig, experimental_readRawConfig, extractAccountTag, extractWAFBlockRayId, fetchInternalBase, fetchLatestNpmVersion, fetchListResultBase, fetchResultBase, findWranglerConfig, formatConfigSnippet, friendlyBindingNames, getBindingLocalSupport, getBindingTypeFriendlyName, getBooleanEnvironmentVariableFactory, getBrowserRenderingHeadfulFromEnv, getBuildConditionsFromEnv, getBuildPlatformFromEnv, getC3CommandFromEnv, getCIGeneratePreviewAlias, getCIMatchTag, getCIOverrideName, getCIOverrideNetworkModeHost, getCfFetchEnabledFromEnv, getCfFetchPathFromEnv, getCloudflareApiBaseUrl, getCloudflareApiEnvironmentFromEnv, getCloudflareComplianceRegion, getCloudflareEnv, getCloudflareIncludeProcessEnvFromEnv, getCloudflareLoadDevVarsFromDotEnv, getCloudflaredPathFromEnv, getComplianceRegionSubdomain, getD1ExtraLocationChoices, getDisableConfigWatching, getDockerPath, getEnvironmentVariableFactory, getGlobalWranglerConfigPath, getLocalExplorerEnabledFromEnv, getOpenNextDeployFromEnv, getOutputFileDirectoryFromEnv, getOutputFilePathFromEnv, getRegistryPath, getSanitizeLogs, getSubdomainMixedStateCheckDisabled, getTodaysCompatDate, getTraceHeader, getWorkersCIBranchName, getWranglerCacheDirFromEnv, getWranglerHiddenDirPath, getWranglerHideBanner, getWranglerSendErrorReportsFromEnv, getWranglerSendMetricsFromEnv, getWranglerTmpDir, hasCursor, hasMorePages, hasProperty, indexLocation, isCompatDate, isDirectory, isDockerfile, isOptionalProperty, isPagesConfig, isRedirectedConfig, isRequiredProperty, isValidR2BucketName, isWAFBlockResponse, mapWorkerMetadataBindings, maybeAddTraceHeader, normalizeAndValidateConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, performApiFetchBase, readFileSync, readFileSyncToBuffer, removeDir, removeDirSync, renderError, resolveWranglerConfigPath, searchLocation, spawnCloudflared, startTunnel, sweepStaleWranglerTmpDirs, throwFetchError, truncate, validatePagesConfig };