wrangler 4.99.0 → 4.101.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.
@@ -1,6 +1,6 @@
1
- import { Rule as Rule$1, CfModule, Environment as Environment$1, Entry, CfModuleType, ApiCredentials, Config as Config$1, Binding, DurableObjectMigration as DurableObjectMigration$1, ContainerApp as ContainerApp$1, Trigger, CfTailConsumer, ServiceFetch, ContainerEngine as ContainerEngine$1, CfUnsafe, CfScriptFormat, AssetsOptions as AssetsOptions$1, ConfigBindingFieldName, RawConfig as RawConfig$1, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, PackageJSON, ParseError, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
1
+ import { Rule as Rule$1, CfModule, Environment as Environment$1, Entry, CfModuleType, StartDevWorkerInput, NodeJSCompatMode, CfScriptFormat, Config as Config$1, AsyncHook, CfAccount as CfAccount$1, AssetsOptions as AssetsOptions$1, Binding, ConfigBindingFieldName, RawConfig as RawConfig$1, NormalizeAndValidateConfigArgs, ResolveConfigPathOptions, PackageJSON, ApiCredentials, ParseError, LoggerLevel, ComplianceConfig, UserError, FatalError } from '@cloudflare/workers-utils';
2
2
  export { Binding, experimental_patchConfig, experimental_readRawConfig, defaultWranglerConfig as unstable_defaultWranglerConfig } from '@cloudflare/workers-utils';
3
- import { Json as Json$1, WorkerRegistry, Miniflare, MiniflareOptions, Mutex, Response as Response$1, NodeJSCompatMode, WorkerdStructuredLog, DispatchFetch, RemoteProxyConnectionString, WorkerOptions, ModuleRule, Request } from 'miniflare';
3
+ import { Json as Json$1, WorkerdStructuredLog, DispatchFetch, Miniflare, WorkerRegistry, MiniflareOptions, Mutex, Response as Response$1, RemoteProxyConnectionString, WorkerOptions, ModuleRule, Request } from 'miniflare';
4
4
  import * as undici from 'undici';
5
5
  import { RequestInfo, RequestInit, Response, FormData } from 'undici';
6
6
  import { Metafile } from 'esbuild';
@@ -9,6 +9,7 @@ import { EventEmitter } from 'node:events';
9
9
  import { ContainerNormalizedConfig } from '@cloudflare/containers-shared';
10
10
  import { FetcherScheduledOptions, FetcherScheduledResult, IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
11
11
  import { RouterConfig, AssetConfig } from '@cloudflare/workers-shared';
12
+ export { printBindings as unstable_printBindings } from '@cloudflare/deploy-helpers';
12
13
  import { URLSearchParams } from 'node:url';
13
14
  import { Argv, PositionalOptions, Options, ArgumentsCamelCase, InferredOptionTypes, InferredOptionType } from 'yargs';
14
15
  import Cloudflare from 'cloudflare';
@@ -168,8 +169,8 @@ interface PagesDeployOptions {
168
169
  */
169
170
  declare function deploy({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, sourceMaps, args, }: PagesDeployOptions): Promise<{
170
171
  deploymentResponse: {
171
- url: string;
172
172
  id: string;
173
+ url: string;
173
174
  environment: "production" | "preview";
174
175
  build_config: {
175
176
  build_command: string;
@@ -192,14 +193,14 @@ declare function deploy({ directory, accountId, projectName, branch, skipCaching
192
193
  };
193
194
  };
194
195
  latest_stage: {
195
- status: "skipped" | "active" | "canceled" | "idle" | "success" | "failure";
196
- name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
196
+ status: "skipped" | "active" | "canceled" | "success" | "idle" | "failure";
197
+ name: "queued" | "build" | "deploy" | "initialize" | "clone_repo";
197
198
  started_on: string | null;
198
199
  ended_on: string | null;
199
200
  };
200
201
  stages: {
201
- status: "skipped" | "active" | "canceled" | "idle" | "success" | "failure";
202
- name: "build" | "queued" | "deploy" | "initialize" | "clone_repo";
202
+ status: "skipped" | "active" | "canceled" | "success" | "idle" | "failure";
203
+ name: "queued" | "build" | "deploy" | "initialize" | "clone_repo";
203
204
  started_on: string | null;
204
205
  ended_on: string | null;
205
206
  }[];
@@ -303,6 +304,13 @@ type Experimental_GenerateTypesResult = GenerateTypesResult;
303
304
  */
304
305
  declare function generateTypes(options: Experimental_GenerateTypesOptions): Promise<Experimental_GenerateTypesResult>;
305
306
 
307
+ type _Params<ParamsArray extends [unknown?]> = ParamsArray extends [infer P] ? P : undefined;
308
+ type _EventMethods = keyof Protocol.Events;
309
+ type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
310
+ method: Method;
311
+ params: _Params<Protocol.Events[Method]>;
312
+ } : never;
313
+
306
314
  /**
307
315
  * Information about Wrangler's bundling process that needs passed through
308
316
  * for DevTools sourcemap transformation
@@ -324,28 +332,64 @@ type EsbuildBundle = {
324
332
  sourceMapMetadata: SourceMapMetadata | undefined;
325
333
  };
326
334
 
327
- /**
328
- * A Cloudflare account.
329
- */
330
- interface CfAccount {
331
- /**
332
- * An API token.
333
- *
334
- * @link https://api.cloudflare.com/#user-api-tokens-properties
335
- */
336
- apiToken: ApiCredentials;
337
- /**
338
- * An account ID.
339
- */
340
- accountId: string;
335
+ declare class ConfigController extends Controller {
336
+ #private;
337
+ latestInput?: StartDevWorkerInput;
338
+ latestConfig?: StartDevWorkerOptions;
339
+ set(input: StartDevWorkerInput, throwErrors?: boolean): Promise<StartDevWorkerOptions | undefined>;
340
+ patch(input: Partial<StartDevWorkerInput>): Promise<StartDevWorkerOptions | undefined>;
341
+ onDevRegistryUpdate(event: DevRegistryUpdateEvent): void;
342
+ teardown(): Promise<void>;
343
+ emitConfigUpdateEvent(config: StartDevWorkerOptions): void;
341
344
  }
342
345
 
343
- type _Params<ParamsArray extends [unknown?]> = ParamsArray extends [infer P] ? P : undefined;
344
- type _EventMethods = keyof Protocol.Events;
345
- type DevToolsEvent<Method extends _EventMethods> = Method extends unknown ? {
346
- method: Method;
347
- params: _Params<Protocol.Events[Method]>;
348
- } : never;
346
+ type MiniflareWorker = Awaited<ReturnType<Miniflare["getWorker"]>>;
347
+ interface Worker {
348
+ ready: Promise<void>;
349
+ url: Promise<URL>;
350
+ inspectorUrl: Promise<URL | undefined>;
351
+ config: StartDevWorkerOptions;
352
+ setConfig: ConfigController["set"];
353
+ patchConfig: ConfigController["patch"];
354
+ fetch: DispatchFetch;
355
+ scheduled: MiniflareWorker["scheduled"];
356
+ queue: MiniflareWorker["queue"];
357
+ dispose(): Promise<void>;
358
+ raw: DevEnv;
359
+ }
360
+ type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "config" | "containers" | "dev"> & {
361
+ /** The configuration path of the worker */
362
+ config?: string;
363
+ /** A worker's directory. Usually where the Wrangler configuration file is located */
364
+ projectRoot: string;
365
+ build: StartDevWorkerInput["build"] & {
366
+ nodejsCompatMode: NodeJSCompatMode;
367
+ format: CfScriptFormat;
368
+ moduleRoot: string;
369
+ moduleRules: Rule$1[];
370
+ define: Record<string, string>;
371
+ additionalModules: CfModule[];
372
+ exports: string[];
373
+ processEntrypoint: boolean;
374
+ };
375
+ legacy: StartDevWorkerInput["legacy"] & {
376
+ site?: Config$1["site"];
377
+ };
378
+ dev: StartDevWorkerInput["dev"] & {
379
+ persist: string | false;
380
+ auth?: AsyncHook<CfAccount$1>;
381
+ /** Handles structured runtime logs. */
382
+ structuredLogsHandler?: (log: WorkerdStructuredLog) => void;
383
+ /** An undici MockAgent to declaratively mock fetch calls to particular resources. */
384
+ mockFetch?: undici.MockAgent;
385
+ };
386
+ entrypoint: string;
387
+ assets?: AssetsOptions$1;
388
+ containers?: ContainerNormalizedConfig[];
389
+ name: string;
390
+ complianceRegion: Config$1["compliance_region"];
391
+ };
392
+ type Bundle = EsbuildBundle;
349
393
 
350
394
  type ErrorEvent = BaseErrorEvent<"ConfigController" | "BundlerController" | "LocalRuntimeController" | "RemoteRuntimeController" | "ProxyWorker" | "InspectorProxyWorker" | "MultiworkerRuntimeController"> | BaseErrorEvent<"ProxyController", {
351
395
  config?: StartDevWorkerOptions;
@@ -476,17 +520,6 @@ declare abstract class RuntimeController extends Controller {
476
520
  protected emitDevRegistryUpdateEvent(data: DevRegistryUpdateEvent): void;
477
521
  }
478
522
 
479
- declare class ConfigController extends Controller {
480
- #private;
481
- latestInput?: StartDevWorkerInput;
482
- latestConfig?: StartDevWorkerOptions;
483
- set(input: StartDevWorkerInput, throwErrors?: boolean): Promise<StartDevWorkerOptions | undefined>;
484
- patch(input: Partial<StartDevWorkerInput>): Promise<StartDevWorkerOptions | undefined>;
485
- onDevRegistryUpdate(event: DevRegistryUpdateEvent): void;
486
- teardown(): Promise<void>;
487
- emitConfigUpdateEvent(config: StartDevWorkerOptions): void;
488
- }
489
-
490
523
  declare class BundlerController extends Controller {
491
524
  #private;
492
525
  onConfigUpdate(event: ConfigUpdateEvent): void;
@@ -495,6 +528,13 @@ declare class BundlerController extends Controller {
495
528
  emitBundleCompleteEvent(config: StartDevWorkerOptions, bundle: EsbuildBundle): void;
496
529
  }
497
530
 
531
+ type MaybePromise<T> = T | Promise<T>;
532
+ type DeferredPromise<T> = {
533
+ promise: Promise<T>;
534
+ resolve: (_: MaybePromise<T>) => void;
535
+ reject: (_: Error) => void;
536
+ };
537
+
498
538
  declare class ProxyController extends Controller {
499
539
  ready: DeferredPromise<ReadyEvent>;
500
540
  localServerReady: DeferredPromise<void>;
@@ -561,219 +601,131 @@ declare class DevEnv extends EventEmitter implements ControllerBus {
561
601
  teardown(): Promise<void>;
562
602
  }
563
603
 
564
- type MiniflareWorker = Awaited<ReturnType<Miniflare["getWorker"]>>;
565
- interface Worker {
566
- ready: Promise<void>;
567
- url: Promise<URL>;
568
- inspectorUrl: Promise<URL | undefined>;
569
- config: StartDevWorkerOptions;
570
- setConfig: ConfigController["set"];
571
- patchConfig: ConfigController["patch"];
572
- fetch: DispatchFetch;
573
- scheduled: MiniflareWorker["scheduled"];
574
- queue: MiniflareWorker["queue"];
575
- dispose(): Promise<void>;
576
- raw: DevEnv;
577
- }
578
- interface StartDevWorkerInput {
579
- /** The name of the worker. */
580
- name?: string;
581
- /**
582
- * The javascript or typescript entry-point of the worker.
583
- * This is the `main` property of a Wrangler configuration file.
584
- */
585
- entrypoint?: string;
586
- /** The configuration path of the worker, or a normalized configuration object. */
587
- config?: string | Config$1;
588
- /** The compatibility date for the workerd runtime. */
589
- compatibilityDate?: string;
590
- /** The compatibility flags for the workerd runtime. */
591
- compatibilityFlags?: string[];
592
- /** Specify the compliance region mode of the Worker. */
593
- complianceRegion?: Config$1["compliance_region"];
594
- /** Configuration for Python modules. */
595
- pythonModules?: {
596
- /** A list of glob patterns to exclude files from the python_modules directory when bundling. */
597
- exclude?: string[];
604
+ declare function startWorker(options: StartDevWorkerInput): Promise<Worker>;
605
+
606
+ declare const dev: {
607
+ args: {
608
+ v: boolean | undefined;
609
+ cwd: string | undefined;
610
+ config: string | undefined;
611
+ env: string | undefined;
612
+ envFile: string[] | undefined;
613
+ experimentalProvision: boolean | undefined;
614
+ experimentalAutoCreate: boolean;
615
+ installSkills: boolean;
616
+ script: string | undefined;
617
+ name: string | undefined;
618
+ compatibilityDate: string | undefined;
619
+ compatibilityFlags: string[] | undefined;
620
+ latest: boolean;
621
+ assets: string | undefined;
622
+ bundle: boolean | undefined;
623
+ noBundle: boolean;
624
+ ip: string | undefined;
625
+ port: number | undefined;
626
+ inspectorPort: number | undefined;
627
+ inspectorIp: string | undefined;
628
+ routes: string[] | undefined;
629
+ host: string | undefined;
630
+ localProtocol: "http" | "https" | undefined;
631
+ httpsKeyPath: string | undefined;
632
+ httpsCertPath: string | undefined;
633
+ localUpstream: string | undefined;
634
+ enableContainers: boolean | undefined;
635
+ site: string | undefined;
636
+ siteInclude: string[] | undefined;
637
+ siteExclude: string[] | undefined;
638
+ upstreamProtocol: "http" | "https" | undefined;
639
+ var: string[] | undefined;
640
+ define: string[] | undefined;
641
+ alias: string[] | undefined;
642
+ jsxFactory: string | undefined;
643
+ jsxFragment: string | undefined;
644
+ tsconfig: string | undefined;
645
+ remote: boolean;
646
+ local: boolean | undefined;
647
+ minify: boolean | undefined;
648
+ nodeCompat: boolean | undefined;
649
+ persistTo: string | undefined;
650
+ liveReload: boolean | undefined;
651
+ legacyEnv: boolean | undefined;
652
+ testScheduled: boolean;
653
+ logLevel: "debug" | "none" | "error" | "log" | "info" | "warn" | undefined;
654
+ showInteractiveDevSession: boolean | undefined;
655
+ types: boolean | undefined;
656
+ tunnel: boolean | undefined;
657
+ tunnelName: string | undefined;
658
+ experimentalNewConfig: boolean;
659
+ _: (string | number)[];
660
+ $0: string;
598
661
  };
599
- env?: string;
600
- /**
601
- * An array of paths to the .env files to load for this worker, relative to the project directory.
602
- *
603
- * If not specified, defaults to the standard `.env` files as given by `getDefaultEnvFiles()`.
604
- * The project directory is where the Wrangler configuration file is located or the current working directory otherwise.
605
- */
606
- envFiles?: string[];
607
- /** The bindings available to the worker. The specified bindind type will be exposed to the worker on the `env` object under the same key. */
608
- bindings?: Record<string, Binding>;
662
+ };
663
+ type AdditionalDevProps = {
609
664
  /**
610
- * Default bindings that can be overridden by config bindings.
665
+ * Default vars that can be overridden by config vars.
611
666
  * Useful for injecting environment-specific defaults like CF_PAGES variables.
612
667
  */
613
668
  defaultBindings?: Record<string, Extract<Binding, {
614
669
  type: "plain_text";
615
670
  }>>;
616
- migrations?: DurableObjectMigration$1[];
617
- containers?: ContainerApp$1[];
618
- /** The triggers which will cause the worker's exported default handlers to be called. */
619
- triggers?: Trigger[];
620
- tailConsumers?: CfTailConsumer[];
621
- streamingTailConsumers?: CfTailConsumer[];
622
- /**
623
- * Whether Wrangler should send usage metrics to Cloudflare for this project.
624
- *
625
- * When defined this will override any user settings.
626
- * Otherwise, Wrangler will use the user's preference.
627
- */
628
- sendMetrics?: boolean;
629
- /** Options applying to the worker's build step. Applies to deploy and dev. */
630
- build?: {
631
- /** Whether the worker and its dependencies are bundled. Defaults to true. */
632
- bundle?: boolean;
633
- additionalModules?: CfModule[];
634
- findAdditionalModules?: boolean;
635
- processEntrypoint?: boolean;
636
- /** Specifies types of modules matched by globs. */
637
- moduleRules?: Rule$1[];
638
- /** Replace global identifiers with constant expressions, e.g. { debug: 'true', version: '"1.0.0"' }. Only takes effect if bundle: true. */
639
- define?: Record<string, string>;
640
- /** Alias modules */
641
- alias?: Record<string, string>;
642
- /** Whether the bundled worker is minified. Only takes effect if bundle: true. */
643
- minify?: boolean;
644
- /** Whether to keep function names after JavaScript transpilations. */
645
- keepNames?: boolean;
646
- /** Options controlling a custom build step. */
647
- custom?: {
648
- /** Custom shell command to run before bundling. Runs even if bundle. */
649
- command?: string;
650
- /** The cwd to run the command in. */
651
- workingDirectory?: string;
652
- /** Filepath(s) to watch for changes. Upon changes, the command will be rerun. */
653
- watch?: string | string[];
654
- };
655
- jsxFactory?: string;
656
- jsxFragment?: string;
657
- tsconfig?: string;
658
- nodejsCompatMode?: Hook<NodeJSCompatMode, [Config$1]>;
659
- moduleRoot?: string;
660
- };
661
- /** Options applying to the worker's development preview environment. */
662
- dev?: {
663
- /** Options applying to the worker's inspector server. False disables the inspector server. */
664
- inspector?: {
665
- hostname?: string;
666
- port?: number;
667
- secure?: boolean;
668
- } | false;
669
- /** Whether the worker runs on the edge or locally. This has several options:
670
- * - true | "minimal": Run your Worker's code & bindings in a remote preview session, optionally using minimal mode as an internal detail
671
- * - false: Run your Worker's code & bindings in a local simulator
672
- * - undefined (default): Run your Worker's code locally, and any configured remote bindings remotely
673
- */
674
- remote?: boolean | "minimal";
675
- /** Cloudflare Account credentials. Can be provided upfront or as a function which will be called only when required. */
676
- auth?: AsyncHook<CfAccount, [Pick<Config$1, "account_id">]>;
677
- /** Whether local storage (KV, Durable Objects, R2, D1, etc) is persisted. You can also specify the directory to persist data to. Set to `false` to disable persistence. */
678
- persist?: string | false;
679
- /** Controls which logs are logged 🤙. */
680
- logLevel?: LogLevel;
681
- /** Whether the worker server restarts upon source/config file changes. */
682
- watch?: boolean;
683
- /** Whether a script tag is inserted on text/html responses which will reload the page upon file changes. Defaults to false. */
684
- liveReload?: boolean;
685
- /** The local address to reach your worker. Applies to remote: true (remote mode) and remote: false (local mode). */
686
- server?: {
687
- hostname?: string;
688
- port?: number;
689
- secure?: boolean;
690
- httpsKeyPath?: string;
691
- httpsCertPath?: string;
692
- };
693
- /** Controls what request.url looks like inside the worker. */
694
- origin?: {
695
- hostname?: string;
696
- secure?: boolean;
697
- };
698
- /** A hook for outbound fetch calls from within the worker. */
699
- outboundService?: ServiceFetch;
700
- /** Handles structured runtime logs. */
701
- structuredLogsHandler?: (log: WorkerdStructuredLog) => void;
702
- /** An undici MockAgent to declaratively mock fetch calls to particular resources. */
703
- mockFetch?: undici.MockAgent;
704
- testScheduled?: boolean;
705
- /** Treat this as the primary worker in a multiworker setup (i.e. the first Worker in Miniflare's options) */
706
- multiworkerPrimary?: boolean;
707
- /** Whether to infer the local request origin from configured routes. */
708
- inferOriginFromRoutes?: boolean;
709
- containerBuildId?: string;
710
- /** Whether to build and connect to containers during local dev. Requires Docker daemon to be running. Defaults to true. */
711
- enableContainers?: boolean;
712
- /** Path to the dev registry directory */
713
- registry?: string;
714
- /** Path to the docker executable. Defaults to 'docker' */
715
- dockerPath?: string;
716
- /** Options for the container engine */
717
- containerEngine?: ContainerEngine$1;
718
- /** Re-generate your worker types when your Wrangler configuration file changes */
719
- generateTypes?: boolean;
720
- /** Tunnel configuration for this dev session. */
721
- tunnel?: {
722
- enabled: boolean;
723
- name?: string;
724
- };
725
- };
726
- legacy?: {
727
- site?: Hook<Config$1["site"], [Config$1]>;
728
- useServiceEnvironments?: boolean;
729
- };
730
- unsafe?: Omit<CfUnsafe, "bindings">;
731
- assets?: string;
732
- experimental?: Record<string, never>;
733
- }
734
- type StartDevWorkerOptions = Omit<StartDevWorkerInput, "assets" | "config" | "containers" | "dev"> & {
735
- /** The configuration path of the worker */
736
- config?: string;
737
- /** A worker's directory. Usually where the Wrangler configuration file is located */
738
- projectRoot: string;
739
- build: StartDevWorkerInput["build"] & {
740
- nodejsCompatMode: NodeJSCompatMode;
741
- format: CfScriptFormat;
742
- moduleRoot: string;
743
- moduleRules: Rule$1[];
744
- define: Record<string, string>;
745
- additionalModules: CfModule[];
746
- exports: string[];
747
- processEntrypoint: boolean;
671
+ vars?: Record<string, string | Json$1>;
672
+ kv?: {
673
+ binding: string;
674
+ id?: string;
675
+ preview_id?: string;
676
+ }[];
677
+ durableObjects?: {
678
+ name: string;
679
+ class_name: string;
680
+ script_name?: string | undefined;
681
+ environment?: string | undefined;
682
+ }[];
683
+ services?: {
684
+ binding: string;
685
+ service: string;
686
+ environment?: string;
687
+ entrypoint?: string;
688
+ }[];
689
+ r2?: {
690
+ binding: string;
691
+ bucket_name?: string;
692
+ preview_bucket_name?: string;
693
+ jurisdiction?: string;
694
+ }[];
695
+ ai?: {
696
+ binding: string;
748
697
  };
749
- legacy: StartDevWorkerInput["legacy"] & {
750
- site?: Config$1["site"];
698
+ stream?: {
699
+ binding: string;
700
+ remote?: boolean;
751
701
  };
752
- dev: StartDevWorkerInput["dev"] & {
753
- persist: string | false;
754
- auth?: AsyncHook<CfAccount>;
702
+ version_metadata?: {
703
+ binding: string;
755
704
  };
756
- entrypoint: string;
757
- assets?: AssetsOptions$1;
758
- containers?: ContainerNormalizedConfig[];
759
- name: string;
760
- complianceRegion: Config$1["compliance_region"];
705
+ d1Databases?: Array<Omit<Environment$1["d1_databases"][number], "database_id"> & {
706
+ database_id?: string;
707
+ }>;
708
+ processEntrypoint?: boolean;
709
+ additionalModules?: CfModule[];
710
+ moduleRoot?: string;
711
+ rules?: Rule$1[];
712
+ showInteractiveDevSession?: boolean;
761
713
  };
762
- type HookValues = string | number | boolean | object | undefined | null;
763
- type Hook<T extends HookValues, Args extends unknown[] = []> = T | ((...args: Args) => T);
764
- type AsyncHook<T extends HookValues, Args extends unknown[] = []> = Hook<T, Args> | Hook<Promise<T>, Args>;
765
- type Bundle = EsbuildBundle;
766
- type LogLevel = "debug" | "info" | "log" | "warn" | "error" | "none";
767
-
768
- type MaybePromise<T> = T | Promise<T>;
769
- type DeferredPromise<T> = {
770
- promise: Promise<T>;
771
- resolve: (_: MaybePromise<T>) => void;
772
- reject: (_: Error) => void;
714
+ type DevArguments = Omit<(typeof dev)["args"], "installSkills">;
715
+ type StartDevOptions = DevArguments & AdditionalDevProps & {
716
+ forceLocal?: boolean;
717
+ accountId?: string;
718
+ disableDevRegistry?: boolean;
719
+ enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
720
+ onReady?: (ip: string, port: number) => void;
721
+ enableIpc?: boolean;
722
+ dockerPath?: string;
723
+ containerEngine?: string;
724
+ /** Set to `false` to disable persistence. When `true` or `undefined`, uses default persistence path. */
725
+ persist?: boolean;
773
726
  };
774
- declare function convertConfigBindingsToStartWorkerBindings(configBindings: Partial<Pick<Config$1, ConfigBindingFieldName>>): StartDevWorkerOptions["bindings"];
775
727
 
776
- declare function startWorker(options: StartDevWorkerInput): Promise<Worker>;
728
+ declare function convertConfigBindingsToStartWorkerBindings(configBindings: Partial<Pick<Config$1, ConfigBindingFieldName>>): StartDevWorkerOptions["bindings"];
777
729
 
778
730
  type TestHarnessOptions = {
779
731
  /**
@@ -812,6 +764,47 @@ type WorkerHandle = {
812
764
  * ```
813
765
  */
814
766
  scheduled(options: FetcherScheduledOptions): Promise<FetcherScheduledResult>;
767
+ /**
768
+ * Returns a KV namespace binding configured on this Worker.
769
+ *
770
+ * @example
771
+ * ```ts
772
+ * const store = await worker.getKVNamespace("STORE");
773
+ * const value = await store.get("key");
774
+ * ```
775
+ */
776
+ getKVNamespace(bindingName: string): ReturnType<Miniflare["getKVNamespace"]>;
777
+ /**
778
+ * Returns an R2 bucket binding configured on this Worker.
779
+ *
780
+ * @example
781
+ * ```ts
782
+ * const bucket = await worker.getR2Bucket("BUCKET");
783
+ * const object = await bucket.get("key");
784
+ * ```
785
+ */
786
+ getR2Bucket(bindingName: string): ReturnType<Miniflare["getR2Bucket"]>;
787
+ /**
788
+ * Returns a D1 database binding configured on this Worker.
789
+ *
790
+ * @example
791
+ * ```ts
792
+ * const db = await worker.getD1Database("DB");
793
+ * const value = await db.prepare("SELECT value FROM entries").first("value");
794
+ * ```
795
+ */
796
+ getD1Database(bindingName: string): ReturnType<Miniflare["getD1Database"]>;
797
+ /**
798
+ * Returns a Durable Object namespace binding configured on this Worker.
799
+ *
800
+ * @example
801
+ * ```ts
802
+ * const namespace = await worker.getDurableObjectNamespace("OBJECT");
803
+ * const stub = namespace.getByName("counter");
804
+ * const response = await stub.fetch("http://example.com/");
805
+ * ```
806
+ */
807
+ getDurableObjectNamespace(bindingName: string): ReturnType<Miniflare["getDurableObjectNamespace"]>;
815
808
  };
816
809
  type TestHarness = {
817
810
  /**
@@ -3125,6 +3118,22 @@ declare function unstable_getMiniflareWorkerOptions(config: Config, env?: string
3125
3118
  containerBuildId?: string;
3126
3119
  }): Unstable_MiniflareWorkerOptions;
3127
3120
 
3121
+ /**
3122
+ * A Cloudflare account.
3123
+ */
3124
+ interface CfAccount {
3125
+ /**
3126
+ * An API token.
3127
+ *
3128
+ * @link https://api.cloudflare.com/#user-api-tokens-properties
3129
+ */
3130
+ apiToken: ApiCredentials;
3131
+ /**
3132
+ * An account ID.
3133
+ */
3134
+ accountId: string;
3135
+ }
3136
+
3128
3137
  type StartRemoteProxySessionOptions = {
3129
3138
  workerName?: string;
3130
3139
  auth?: NonNullable<StartDevWorkerInput["dev"]>["auth"];
@@ -3174,23 +3183,14 @@ declare function maybeStartOrUpdateRemoteProxySession(wranglerOrWorkerConfigObje
3174
3183
  auth?: AsyncHook<CfAccount> | undefined;
3175
3184
  } | null>;
3176
3185
 
3177
- declare const LOGGER_LEVELS: {
3178
- readonly none: -1;
3179
- readonly error: 0;
3180
- readonly warn: 1;
3181
- readonly info: 2;
3182
- readonly log: 3;
3183
- readonly debug: 4;
3184
- };
3185
- type LoggerLevel = keyof typeof LOGGER_LEVELS;
3186
3186
  type TableRow<Keys extends string> = Record<Keys, string>;
3187
3187
  declare class Logger {
3188
3188
  #private;
3189
3189
  constructor();
3190
3190
  private overrideLoggerLevel?;
3191
3191
  private onceHistory;
3192
- get loggerLevel(): "debug" | "none" | "error" | "info" | "log" | "warn";
3193
- set loggerLevel(val: "debug" | "none" | "error" | "info" | "log" | "warn");
3192
+ get loggerLevel(): "debug" | "none" | "error" | "log" | "info" | "warn";
3193
+ set loggerLevel(val: "debug" | "none" | "error" | "log" | "info" | "warn");
3194
3194
  resetLoggerLevel(): void;
3195
3195
  columns: number;
3196
3196
  json: (data: unknown) => void;
@@ -3220,23 +3220,6 @@ declare class Logger {
3220
3220
  private formatMessage;
3221
3221
  }
3222
3222
 
3223
- type PrintContext = {
3224
- log?: (message: string) => void;
3225
- registry?: WorkerRegistry | null;
3226
- local?: boolean;
3227
- isMultiWorker?: boolean;
3228
- remoteBindingsDisabled?: boolean;
3229
- name?: string;
3230
- provisioning?: boolean;
3231
- warnIfNoBindings?: boolean;
3232
- unsafeMetadata?: Record<string, unknown>;
3233
- };
3234
- /**
3235
- * Print all the bindings a worker would have access to.
3236
- * Accepts StartDevWorkerInput["bindings"] format
3237
- */
3238
- declare function printBindings(bindings: StartDevWorkerInput["bindings"], tailConsumers?: CfTailConsumer[], streamingTailConsumers?: CfTailConsumer[], containers?: ContainerApp$1[], context?: PrintContext): void;
3239
-
3240
3223
  /**
3241
3224
  * Resolves the named tunnel to hostnames whose ingress rules
3242
3225
  * target the current local dev origin and the token needed
@@ -3250,6 +3233,28 @@ declare function resolveNamedTunnel(name: string, origin: URL, options: {
3250
3233
  token: string;
3251
3234
  }>;
3252
3235
 
3236
+ /**
3237
+ * Run the dev server until it tears down (a hotkey quit in a TTY, or a
3238
+ * signal from a non-interactive parent). Mirrors `wrangler dev`'s command
3239
+ * handler and installs no signal handlers of its own, so signal handling
3240
+ * and exit codes match `wrangler dev` exactly.
3241
+ *
3242
+ * @param options Fully-built `StartDevOptions` (built in `bin/cf-wrangler.js`).
3243
+ * @returns `0` on a clean teardown.
3244
+ */
3245
+ declare function runCfWranglerDev(options: StartDevOptions): Promise<number>;
3246
+
3247
+ interface DevArgs {
3248
+ mode?: string;
3249
+ port?: number;
3250
+ host?: string;
3251
+ local?: boolean;
3252
+ }
3253
+ declare class ArgParseError extends Error {
3254
+ constructor(message: string);
3255
+ }
3256
+ declare function parseArgs(argv: string[]): DevArgs;
3257
+
3253
3258
  /**
3254
3259
  * Split an SQLQuery into an array of statements
3255
3260
  */
@@ -3257,6 +3262,18 @@ declare function splitSqlQuery(sql: string): string[];
3257
3262
 
3258
3263
  declare function runAutoConfig(autoConfigDetails: AutoConfigDetails, autoConfigOptions?: AutoConfigOptions): Promise<AutoConfigSummary>;
3259
3264
 
3265
+ /**
3266
+ * The implementation for fetching a kv value from the cloudflare API.
3267
+ * We special-case this one call, because it's the only API call that
3268
+ * doesn't return json. We inline the implementation and try not to share
3269
+ * any code with the other calls. We should push back on any new APIs that
3270
+ * try to introduce non-"standard" response structures.
3271
+ *
3272
+ * Note: any calls to fetchKVGetValue must call encodeURIComponent on key
3273
+ * before passing it
3274
+ */
3275
+ declare function fetchKVGetValue(complianceConfig: ComplianceConfig, accountId: string, namespaceId: string, key: string): Promise<ArrayBuffer>;
3276
+
3260
3277
  /**
3261
3278
  * Make a fetch request, and extract the `result` from the JSON response.
3262
3279
  */
@@ -3267,6 +3284,14 @@ declare function fetchResult<ResponseType>(complianceConfig: ComplianceConfig, r
3267
3284
  * and repeating the request if the results are paginated.
3268
3285
  */
3269
3286
  declare function fetchListResult<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams): Promise<ResponseType[]>;
3287
+ /**
3288
+ * Make a fetch request for a list of values,
3289
+ * extracting the `result` from the JSON response,
3290
+ * and repeating the request if the results are paginated.
3291
+ *
3292
+ * This is similar to fetchListResult, but it uses the `page` query parameter instead of `cursor`.
3293
+ */
3294
+ declare function fetchPagedListResult<ResponseType>(complianceConfig: ComplianceConfig, resource: string, init?: RequestInit, queryParams?: URLSearchParams): Promise<ResponseType[]>;
3270
3295
 
3271
3296
  interface ConfirmOptions {
3272
3297
  defaultValue?: boolean;
@@ -3395,6 +3420,8 @@ type HandlerContext = {
3395
3420
  */
3396
3421
  fetchResult: typeof fetchResult;
3397
3422
  fetchListResult: typeof fetchListResult;
3423
+ fetchPagedListResult: typeof fetchPagedListResult;
3424
+ fetchKVGetValue: typeof fetchKVGetValue;
3398
3425
  /**
3399
3426
  * Interactive prompts
3400
3427
  */
@@ -3476,12 +3503,25 @@ type CommandDefinition<NamedArgDefs extends NamedArgDefinitions = NamedArgDefini
3476
3503
  */
3477
3504
  sendMetrics?: boolean;
3478
3505
  /**
3479
- * Skip the AI coding agent skills installation prompt for this command.
3480
- * Set to `true` for commands whose stdout is captured by the shell (e.g. `complete`),
3481
- * where interactive prompts would corrupt the output.
3506
+ * After the command handler completes successfully, suggest installing
3507
+ * Cloudflare skills for detected AI coding agents that don't have them.
3508
+ *
3509
+ * When set to `true`, the suggestion always runs after the handler.
3510
+ * When set to a function, it receives the parsed args and should return
3511
+ * `true` to enable the suggestion — use this to skip the prompt in modes
3512
+ * where interactive output is inappropriate (e.g. `--json`).
3513
+ *
3482
3514
  * @default false
3483
3515
  */
3484
- skipSkillsPrompt?: boolean;
3516
+ suggestSkillsAfterHandler?: boolean | ((args: HandlerArgs<NamedArgDefs>) => boolean);
3517
+ /**
3518
+ * Whether this command can authenticate with a temporary preview account
3519
+ * (via the hidden `--temporary` flag) when no real credentials are available.
3520
+ * Only enable this for commands whose API calls are covered by the temporary
3521
+ * preview-account deploy token (Workers, KV, D1, Hyperdrive, Queues, SSL/Certs).
3522
+ * @default false
3523
+ */
3524
+ supportTemporary?: boolean;
3485
3525
  };
3486
3526
  /**
3487
3527
  * A plain key-value object describing the CLI args for this command.
@@ -3499,8 +3539,11 @@ type CommandDefinition<NamedArgDefs extends NamedArgDefinitions = NamedArgDefini
3499
3539
  * A hook to implement custom validation of the args before the handler is called.
3500
3540
  * Throw `CommandLineArgsError` with actionable error message if args are invalid.
3501
3541
  * The return value is ignored.
3542
+ *
3543
+ * @param args - The parsed CLI arguments
3544
+ * @param def - The command definition, useful for passing to helpers like `demandOneOfOption`
3502
3545
  */
3503
- validateArgs?: (args: HandlerArgs<NamedArgDefs>) => void | Promise<void>;
3546
+ validateArgs?: (args: HandlerArgs<NamedArgDefs>, def: CommandDefinition<NamedArgDefs>) => void | Promise<void>;
3504
3547
  /**
3505
3548
  * The implementation of the command which is given camelCase'd args
3506
3549
  * and a ctx object of convenience properties
@@ -3644,7 +3687,7 @@ declare function createCLIParser(argv: string[]): {
3644
3687
  readonly alias: "x-auto-create";
3645
3688
  };
3646
3689
  readonly "install-skills": {
3647
- readonly describe: "Install Cloudflare agents skills, if not already present, without asking the user for confirmation";
3690
+ readonly describe: "Install Cloudflare skills for detected AI coding agents before running the command";
3648
3691
  readonly type: "boolean";
3649
3692
  readonly default: false;
3650
3693
  };
@@ -3676,4 +3719,4 @@ interface Unstable_ASSETSBindingsOptions {
3676
3719
  }
3677
3720
  declare const unstable_generateASSETSBinding: (opts: Unstable_ASSETSBindingsOptions) => (request: Request) => Promise<Response$1>;
3678
3721
 
3679
- export { type Experimental_GenerateTypesOptions, type Experimental_GenerateTypesResult, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type TestHarness, type TestHarnessOptions, type Unstable_ASSETSBindingsOptions, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, type WorkerHandle, createTestHarness, Framework as experimental_AutoConfigFramework, generateTypes as experimental_generateTypes, getDetailsForAutoConfig as experimental_getDetailsForAutoConfig, experimental_getWranglerCommands, runAutoConfig as experimental_runAutoConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, unstable_generateASSETSBinding, unstable_getDevCompatibilityDate, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, getWorkerNameFromProject as unstable_getWorkerNameFromProject, unstable_pages, printBindings as unstable_printBindings, readConfig as unstable_readConfig, resolveNamedTunnel as unstable_resolveNamedTunnel, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };
3722
+ export { ArgParseError, type Experimental_GenerateTypesOptions, type Experimental_GenerateTypesResult, type GetPlatformProxyOptions, type PlatformProxy, type RemoteProxySession, type SourcelessWorkerOptions, type StartRemoteProxySessionOptions, type TestHarness, type TestHarnessOptions, type Unstable_ASSETSBindingsOptions, type Config as Unstable_Config, type Unstable_DevOptions, type Unstable_DevWorker, type Unstable_MiniflareWorkerOptions, type RawConfig as Unstable_RawConfig, type RawEnvironment as Unstable_RawEnvironment, type WorkerHandle, createTestHarness, Framework as experimental_AutoConfigFramework, generateTypes as experimental_generateTypes, getDetailsForAutoConfig as experimental_getDetailsForAutoConfig, experimental_getWranglerCommands, runAutoConfig as experimental_runAutoConfig, getPlatformProxy, maybeStartOrUpdateRemoteProxySession, parseArgs as parseCfWranglerArgs, runCfWranglerDev, startRemoteProxySession, DevEnv as unstable_DevEnv, convertConfigBindingsToStartWorkerBindings as unstable_convertConfigBindingsToStartWorkerBindings, unstable_dev, unstable_generateASSETSBinding, unstable_getDevCompatibilityDate, getDurableObjectClassNameToUseSQLiteMap as unstable_getDurableObjectClassNameToUseSQLiteMap, unstable_getMiniflareWorkerOptions, getVarsForDev as unstable_getVarsForDev, getWorkerNameFromProject as unstable_getWorkerNameFromProject, unstable_pages, readConfig as unstable_readConfig, resolveNamedTunnel as unstable_resolveNamedTunnel, splitSqlQuery as unstable_splitSqlQuery, startWorker as unstable_startWorker };