@vite-hub/cli 0.4.1 → 0.5.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,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { spawn } from "node:child_process";
3
- import { readFileSync, statSync } from "node:fs";
3
+ import { existsSync, readFileSync, statSync } from "node:fs";
4
4
  import { dirname, resolve } from "pathe";
5
5
  import { defineDiagnostics } from "nostics";
6
6
  import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
@@ -10,17 +10,7 @@ import "node:url";
10
10
  import { tmpdir } from "node:os";
11
11
  import { createBirpc } from "birpc";
12
12
  import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
13
- //#region ../internal/dist/object.js
14
- /** A non-null object that is not an array. Functions do not pass. */
15
- function isRecord(value) {
16
- return typeof value === "object" && value !== null && !Array.isArray(value);
17
- }
18
- /** A non-null object or a function that is not an array. */
19
- function isRecordOrFunction(value) {
20
- return Object(value) === value && !Array.isArray(value);
21
- }
22
- //#endregion
23
- //#region ../internal/dist/error-diagnostics-D7txO3cV.js
13
+ // ../internal/dist/error-diagnostics-B5oT1e3D.js
24
14
  const dynamicError$1 = { why: ({ message }) => message === void 0 ? "" : String(message) };
25
15
  const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
26
16
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
@@ -46,7 +36,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
46
36
  why: ({ message }) => message === void 0 ? "" : String(message)
47
37
  },
48
38
  INTERNAL_R0022: {
49
- fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
39
+ fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
50
40
  why: ({ message }) => message === void 0 ? "" : String(message)
51
41
  },
52
42
  INTERNAL_R0024: {
@@ -265,6 +255,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
265
255
  why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
266
256
  fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
267
257
  },
258
+ INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
259
+ why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
260
+ fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
261
+ },
268
262
  INTERNAL_SECRET_PURPOSE_MISSING: {
269
263
  why: "[vitehub] A derived secret requires a purpose.",
270
264
  fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
@@ -273,6 +267,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
273
267
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
274
268
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
275
269
  },
270
+ INTERNAL_SITE_TOKEN_TOO_LONG: {
271
+ why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
272
+ fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
273
+ },
276
274
  INTERNAL_SQLITE_ARGUMENT_INVALID: {
277
275
  why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
278
276
  fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
@@ -287,8 +285,30 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
287
285
  }
288
286
  }
289
287
  });
290
- //#endregion
291
- //#region ../internal/dist/cli.js
288
+ // ../internal/dist/object.js
289
+ /** A non-null object that is not an array. Functions do not pass. */
290
+ function isRecord(value) {
291
+ return typeof value === "object" && value !== null && !Array.isArray(value);
292
+ }
293
+ /** A non-null object or a function that is not an array. */
294
+ function isRecordOrFunction(value) {
295
+ return Object(value) === value && !Array.isArray(value);
296
+ }
297
+ // ../internal/dist/cli.js
298
+ /** Validate an explicit `--url` before sending a Console request. The caller adds the RPC path. */
299
+ function appUrlError(url) {
300
+ let base;
301
+ try {
302
+ base = new URL(url);
303
+ } catch {
304
+ return "--url must be a URL.";
305
+ }
306
+ const local = base.hostname === "localhost" || base.hostname === "127.0.0.1" || base.hostname === "[::1]";
307
+ if (base.protocol !== "https:" && !(local && base.protocol === "http:")) return "--url must use HTTPS, except for localhost.";
308
+ if (base.username || base.password || base.search || base.hash) return "--url must not contain credentials, a query, or a fragment.";
309
+ const consolePath = /(?:^|\/)_vitehub(?:\/|$)/.exec(base.pathname);
310
+ if (consolePath) return `--url is the app URL, not the Console URL. Pass --url ${`${base.origin}${base.pathname.slice(0, consolePath.index).replace(/\/$/, "")}`}.`;
311
+ }
292
312
  const stdoutRedirectQueueKey = Symbol.for("vite-hub.internal.stdout-redirect-queue");
293
313
  const stdoutRedirectWriterKey = Symbol.for("vite-hub.internal.stdout-redirect-writer");
294
314
  const stdoutRedirectSourceKey = Symbol.for("vite-hub.internal.stdout-redirect-source");
@@ -355,6 +375,32 @@ function createCliDiscoveryNitroCloser() {
355
375
  }
356
376
  };
357
377
  }
378
+ /** Let Vite load its config normally, without overriding the root declared by the project. */
379
+ function viteCliProjectConfig(rootDir) {
380
+ const configFile = [
381
+ "js",
382
+ "mjs",
383
+ "ts",
384
+ "cjs",
385
+ "mts",
386
+ "cts"
387
+ ].map((extension) => resolve$1(rootDir, `vite.config.${extension}`)).find((file) => existsSync(file));
388
+ if (!configFile) return {
389
+ root: rootDir,
390
+ plugins: []
391
+ };
392
+ return {
393
+ configFile,
394
+ plugins: [{
395
+ name: "vite-hub/cli-discovery-root",
396
+ enforce: "pre",
397
+ config: {
398
+ order: "pre",
399
+ handler: ({ root }) => ({ root: resolve$1(rootDir, root || ".") })
400
+ }
401
+ }]
402
+ };
403
+ }
358
404
  /** Returns the unredirected process stdout writer for payload output. */
359
405
  function getStableStdoutWrite() {
360
406
  const current = process.stdout.write;
@@ -429,8 +475,813 @@ function findViteHubDevServerUrl(roots, env) {
429
475
  }
430
476
  return env["VITEHUB_DEV_SERVER_URL"] || void 0;
431
477
  }
432
- //#endregion
433
- //#region ../internal/dist/console-signature.js
478
+ // ../internal/dist/invariant.js
479
+ const invariantDiagnostics = /*#__PURE__*/ defineDiagnostics({
480
+ docsBase: "https://vitehub.dev/docs/development/diagnostics",
481
+ codes: { INTERNAL_INVARIANT_FAILED: {
482
+ why: ({ what }) => `ViteHub reached a state that it does not expect: ${what}`,
483
+ fix: "This is a ViteHub bug. Open an issue at https://github.com/vite-hub/vitehub/issues with this error message and its stack trace."
484
+ } }
485
+ });
486
+ /**
487
+ * The error for a state that only a ViteHub bug can reach, such as an impossible branch. `what` says which rule broke.
488
+ * Use a code from the package catalog when a developer can cause the error or fix it.
489
+ */
490
+ function invariantError(what) {
491
+ return invariantDiagnostics.INTERNAL_INVARIANT_FAILED({ what });
492
+ }
493
+ /** Throws `INTERNAL_INVARIANT_FAILED` when `condition` is falsy. */
494
+ function invariant(condition, what) {
495
+ if (!condition) throw invariantError(what);
496
+ }
497
+ // ../internal/dist/features.js
498
+ /**
499
+ * The feature keys of `vitehub({...})`. `vitehub add <feature>` and `vitehub status` read this list before the owner
500
+ * package of a feature is installed, so the catalog is plain data with no owner imports.
501
+ */
502
+ const featureIds = [
503
+ "agent",
504
+ "auth",
505
+ "blob",
506
+ "browser",
507
+ "cache",
508
+ "channels",
509
+ "comments",
510
+ "connections",
511
+ "console",
512
+ "database",
513
+ "email",
514
+ "env",
515
+ "i18n",
516
+ "kv",
517
+ "mcp",
518
+ "observability",
519
+ "queue",
520
+ "rateLimit",
521
+ "realtime",
522
+ "sandboxTask",
523
+ "schedule",
524
+ "workflow",
525
+ "workspace"
526
+ ];
527
+ /** `dev` stores default Node development support. Use `featureSupport()` with the configured host for development lookups. */
528
+ const featureHosts = [
529
+ "dev",
530
+ "cloudflare",
531
+ "vercel",
532
+ "netlify",
533
+ "deno",
534
+ "node"
535
+ ];
536
+ const noHostLimit = "No host limit in ViteHub.";
537
+ function native(driver, display, detail, guarantee = "native") {
538
+ return {
539
+ detail,
540
+ display,
541
+ driver,
542
+ guarantee,
543
+ level: "native"
544
+ };
545
+ }
546
+ function explicit(option, display, detail) {
547
+ return {
548
+ detail,
549
+ display,
550
+ level: "explicit",
551
+ option
552
+ };
553
+ }
554
+ function unsupported(detail) {
555
+ return {
556
+ detail,
557
+ level: "unsupported"
558
+ };
559
+ }
560
+ function everywhere(driver, display, detail = noHostLimit) {
561
+ const support = native(driver, display, detail);
562
+ return {
563
+ cloudflare: support,
564
+ deno: support,
565
+ dev: support,
566
+ netlify: support,
567
+ node: support,
568
+ vercel: support
569
+ };
570
+ }
571
+ function feature(definition) {
572
+ return {
573
+ devPackages: [],
574
+ enabledByDefault: false,
575
+ implies: [],
576
+ packages: [],
577
+ ...definition
578
+ };
579
+ }
580
+ const sourceExtensions = [
581
+ "ts",
582
+ "mts",
583
+ "js",
584
+ "mjs",
585
+ "cts",
586
+ "cjs"
587
+ ];
588
+ /** `<base>.<ext>` for each source extension. */
589
+ function sourceFiles(base) {
590
+ return sourceExtensions.map((extension) => `${base}.${extension}`);
591
+ }
592
+ /**
593
+ * A starter for Definitions in `dir`, one `<name>.ts` file each. With `suffix`, the owner also discovers the Vite
594
+ * form `src/<name>.<suffix>.ts`, and a Definition folder `<dir>/<name>/` when `folder` names its entry file.
595
+ */
596
+ function starter(dir, template, options = {}) {
597
+ return {
598
+ conflicts: (name) => [
599
+ ...sourceFiles(`${dir}/${name}`).slice(1),
600
+ ...options.folder ? sourceFiles(`${dir}/${name}/${options.folder}`) : [],
601
+ ...options.suffix ? [...sourceFiles(`src/${name}.${options.suffix}`), ...sourceFiles(`${name}.${options.suffix}`)] : []
602
+ ],
603
+ dir,
604
+ file: (name) => `${dir}/${name}.ts`,
605
+ template
606
+ };
607
+ }
608
+ const features = {
609
+ agent: feature({
610
+ definition: starter("server/agents", (name) => `import { defineAgent } from "vite-hub/agent"
611
+
612
+ export default defineAgent({
613
+ driver: { run: () => ({ text: "Hello from ${name}." }) },
614
+ })
615
+ `, {
616
+ folder: "agent",
617
+ suffix: "agent"
618
+ }),
619
+ docs: "/docs/agents",
620
+ enabledByDiscovery: ["agents"],
621
+ hosts: {
622
+ ...everywhere("nitro", "Nitro"),
623
+ deno: native("nitro", "Nitro", "Agent routes run in the Nitro output. The Agent Deno runtime is not supported on this host."),
624
+ netlify: native("nitro", "Nitro", "Agent HTTP routes run in generated functions. `agent.invocations` is not supported, so `agent: true` fails the build. Set `agent: { invocations: false }` and configure invocations on each Agent Definition.")
625
+ },
626
+ id: "agent",
627
+ packages: ["@vite-hub/agent"],
628
+ summary: "Agents in `server/agents/` with tools, Capabilities, channels, and invocations.",
629
+ title: "Agent"
630
+ }),
631
+ auth: feature({
632
+ docs: "/docs/auth",
633
+ enabledByDiscovery: sourceFiles("auth"),
634
+ hosts: everywhere("better-auth", "Better Auth"),
635
+ id: "auth",
636
+ packages: [
637
+ "@vite-hub/auth",
638
+ "better-auth",
639
+ "drizzle-orm"
640
+ ],
641
+ summary: "Better Auth sign-in, sessions, and organizations, with tables that ViteHub owns.",
642
+ title: "Auth"
643
+ }),
644
+ blob: feature({
645
+ docs: "/docs/blob",
646
+ hosts: {
647
+ cloudflare: native("cloudflare", "R2", "Cloudflare R2 binding or S3-compatible HTTP access."),
648
+ deno: explicit("blob.driver", "S3", "Use a remote S3-compatible store. No Deno-native Blob driver is provided."),
649
+ dev: native("fs", "fs", "Local filesystem storage for development.", "single-host"),
650
+ netlify: native("netlify-blobs", "Netlify Blobs", "Netlify Blobs selected from the detected host."),
651
+ node: native("fs", "fs / S3", "Filesystem, S3-compatible, MinIO, or files-sdk drivers.", "single-host"),
652
+ vercel: native("vercel", "Vercel Blob", "Vercel Blob through the vercel driver.")
653
+ },
654
+ id: "blob",
655
+ packages: ["@vite-hub/blob"],
656
+ providerPackages: { driver: { s3: [
657
+ "@aws-sdk/client-s3",
658
+ "@aws-sdk/lib-storage",
659
+ "@aws-sdk/s3-presigned-post",
660
+ "@aws-sdk/s3-request-presigner"
661
+ ] } },
662
+ service: "blob",
663
+ summary: "Object storage for files and uploads, with one API on every host.",
664
+ title: "Blob"
665
+ }),
666
+ browser: feature({
667
+ docs: "/docs/browser",
668
+ enabledByDiscovery: ["browsers"],
669
+ hosts: {
670
+ cloudflare: native("cloudflare", "Browser Run", "Cloudflare Browser Run binding and provider output."),
671
+ deno: unsupported("Browser Definitions do not have a Deno provider."),
672
+ dev: unsupported("Browser Definitions need the Cloudflare host. Use createBrowser({ driver: localBrowser({ executablePath }) }) from code for a trusted local process."),
673
+ netlify: unsupported("Browser Definitions do not have a Netlify provider."),
674
+ node: unsupported("The Node host has no built-in Browser Provider. Use localBrowser() from code for a trusted process."),
675
+ vercel: unsupported("Browser Definitions do not have a Vercel provider.")
676
+ },
677
+ id: "browser",
678
+ packages: ["@vite-hub/browser"],
679
+ service: "browser",
680
+ summary: "Headless browser sessions for Agents and server code.",
681
+ title: "Browser"
682
+ }),
683
+ cache: feature({
684
+ developmentOverrides: [
685
+ "cloudflare",
686
+ "deno",
687
+ "vercel"
688
+ ],
689
+ docs: "/docs/reference/config-options",
690
+ hosts: {
691
+ cloudflare: native("cloudflare", "Workers KV", "Workers KV binding `CACHE`."),
692
+ deno: native("deno-kv", "Deno KV", "Native Deno KV."),
693
+ dev: native("fs-lite", "fs-lite", "`.vitehub/data/cache` during development.", "single-host"),
694
+ netlify: explicit("cache.driver", "KV", "`cache: true` has no default store on Netlify. Set `cache: { driver: \"kv\" }` and enable `kv`."),
695
+ node: native("fs-lite", "fs-lite", "`.vitehub/data/cache` on the server disk.", "single-host"),
696
+ vercel: native("vercel", "Runtime Cache", "Vercel Runtime Cache.")
697
+ },
698
+ id: "cache",
699
+ summary: "Storage for Nitro's cache mount, used by defineCachedFunction() and defineCachedEventHandler().",
700
+ title: "Cache"
701
+ }),
702
+ channels: feature({
703
+ docs: "/docs/channels",
704
+ enabledByDiscovery: ["channels"],
705
+ hosts: everywhere("nitro", "Nitro"),
706
+ id: "channels",
707
+ packages: ["@vite-hub/channels"],
708
+ summary: "Chat channels such as Slack, Discord, and GitHub that deliver messages to Agents.",
709
+ title: "Channels"
710
+ }),
711
+ comments: feature({
712
+ docs: "/docs/comments",
713
+ enabledByDiscovery: [
714
+ "comments.ts",
715
+ "comments.mts",
716
+ "comments.js",
717
+ "comments.mjs"
718
+ ],
719
+ hosts: everywhere("database", "Database"),
720
+ id: "comments",
721
+ implies: [{ feature: "database" }],
722
+ packages: ["@vite-hub/comments"],
723
+ summary: "Comments on the app's pages, stored in a ViteHub Database.",
724
+ title: "Comments"
725
+ }),
726
+ connections: feature({
727
+ docs: "/docs/connections",
728
+ enabledByDiscovery: ["connections"],
729
+ hosts: everywhere("database", "Database"),
730
+ id: "connections",
731
+ implies: [{ feature: "database" }],
732
+ packages: [
733
+ "@vite-hub/connections",
734
+ "@vite-hub/database",
735
+ "drizzle-orm"
736
+ ],
737
+ summary: "OAuth and API key Connections in `server/connections/`, with grants stored in a Database.",
738
+ title: "Connections"
739
+ }),
740
+ console: feature({
741
+ docs: "/docs/console",
742
+ hosts: everywhere("nitro", "Nitro"),
743
+ id: "console",
744
+ packages: [],
745
+ summary: "The Operations endpoint and MCP at `/_vitehub`, which the hosted Console at console.vitehub.dev and the CLI call.",
746
+ title: "Console"
747
+ }),
748
+ database: feature({
749
+ definition: {
750
+ conflicts: (name) => [
751
+ ...sourceFiles(`server/databases/${name}`).slice(1),
752
+ ...sourceFiles(`server/databases/${name}/index`),
753
+ ...name === "default" ? ["src/database.ts"] : [...sourceFiles(`src/${name}.database`), "src/database.ts"]
754
+ ],
755
+ dir: "server/databases",
756
+ file: (name) => `server/databases/${name}.ts`,
757
+ template: (name) => `import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"
758
+ import { defineDatabase } from "vite-hub/database"
759
+
760
+ export default defineDatabase({
761
+ ${name === "default" ? "" : ` name: ${JSON.stringify(name)},\n`} schema: {
762
+ notes: sqliteTable("notes", {
763
+ id: integer("id").primaryKey(),
764
+ title: text("title").notNull(),
765
+ }),
766
+ },
767
+ })
768
+ `
769
+ },
770
+ developmentOverrides: [
771
+ "deno",
772
+ "netlify",
773
+ "vercel"
774
+ ],
775
+ devPackages: ["drizzle-kit"],
776
+ docs: "/docs/database",
777
+ hosts: {
778
+ cloudflare: native("cloudflare", "D1", "Cloudflare D1 binding, with authenticated HTTP available for development. A PostgreSQL Database Definition connects through Hyperdrive or `connection.url`."),
779
+ deno: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. No Deno-native database driver is provided."),
780
+ dev: native("sqlite", "SQLite", "Local SQLite through libSQL and Drizzle.", "single-host"),
781
+ netlify: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. No Netlify-native database driver is provided."),
782
+ node: native("sqlite", "SQLite / libSQL / Postgres", "SQLite or hosted libSQL through the selected Database connection, or a PostgreSQL Database Definition. Several servers can share Postgres and migrate on start under one advisory lock.", "single-host"),
783
+ vercel: explicit("database.connection", "libSQL / D1 / Postgres", "Configure hosted libSQL, D1 over authenticated HTTP, or a PostgreSQL Database Definition. The default local SQLite file is not supported in Vercel functions.")
784
+ },
785
+ id: "database",
786
+ packages: ["@vite-hub/database", "drizzle-orm"],
787
+ summary: "Drizzle Databases in `server/databases/` with migrations and a local SQLite in development.",
788
+ title: "Database"
789
+ }),
790
+ email: feature({
791
+ docs: "/docs/email",
792
+ hosts: {
793
+ cloudflare: native("cloudflare", "Cloudflare Email", "The Cloudflare Email driver is the default. Resend is also supported."),
794
+ deno: explicit("email.driver", "Resend", "Configure the built-in fetch-based Resend driver."),
795
+ dev: native("log", "Log", "`email: true` keeps each message in the development outbox and sends nothing. Set `email.driver` for a production build.", "process-local"),
796
+ netlify: explicit("email.driver", "Resend", "Configure the built-in Resend driver."),
797
+ node: explicit("email.driver", "Resend / SMTP / custom", "Configure Resend, `smtp` with the `nodemailer` package, or a driver module for another provider."),
798
+ vercel: explicit("email.driver", "Resend", "Configure the built-in Resend driver.")
799
+ },
800
+ developmentOverrides: [
801
+ "deno",
802
+ "netlify",
803
+ "vercel"
804
+ ],
805
+ id: "email",
806
+ packages: ["@vite-hub/email"],
807
+ summary: "Send email from server code and Agents, with a development outbox.",
808
+ title: "Email"
809
+ }),
810
+ env: feature({
811
+ docs: "/docs/env",
812
+ enabledByDefault: true,
813
+ hosts: everywhere("nitro", "Nitro"),
814
+ id: "env",
815
+ summary: "Typed environment variables and secrets, validated at build and at runtime.",
816
+ title: "Env"
817
+ }),
818
+ i18n: feature({
819
+ docs: "/docs/i18n",
820
+ hosts: everywhere("nitro", "Nitro 3", "Requires Nitro 3 with request async context: Nuxt 4.7 or newer with the nitro package, Nuxt 5, or Vite with Nitro 3. On Nuxt 4, use i18n without i18n.workspace. Nitro 2 and Nuxt before 4.7 are unsupported."),
821
+ id: "i18n",
822
+ packages: ["@vite-hub/i18n"],
823
+ requiredOptions: [{
824
+ option: "i18n.locales",
825
+ detail: "Pass a nonempty JSON array of locale names or set locales in your I18n config."
826
+ }],
827
+ summary: "Messages with translation records for each locale and a locale for each request.",
828
+ title: "I18n"
829
+ }),
830
+ kv: feature({
831
+ developmentOverrides: ["netlify"],
832
+ docs: "/docs/kv",
833
+ hosts: {
834
+ cloudflare: native("cloudflare", "Workers KV", "Cloudflare Workers KV binding."),
835
+ deno: native("deno-kv", "Deno KV", "Native Deno KV through Deno.openKv()."),
836
+ dev: native("fs-lite", "fs-lite", "Local filesystem-backed KV for development.", "single-host"),
837
+ netlify: explicit("kv.driver", "Upstash / Redis", "Set `kv.driver` (or `kv.stores.default.driver` when using multiple stores) to `upstash`, `redis`, or `database`, or set Upstash REST credentials at build time. No Netlify-native KV output is provided. Without them, KV uses a Postgres Default Database, else `fs-lite` files that other function instances cannot read."),
838
+ node: native("fs-lite", "Redis / Postgres / fs-lite", "A table in a Postgres Default Database, else local files. Redis requires kv: { driver: 'redis' }; REDIS_URL supplies its URL on every server. Upstash with REST credentials at build time.", "single-host"),
839
+ vercel: native("upstash", "Upstash", "Upstash Redis with KV REST credentials.")
840
+ },
841
+ id: "kv",
842
+ packages: ["@vite-hub/kv"],
843
+ providerPackages: { driver: { upstash: ["@upstash/redis"] } },
844
+ summary: "Key-value storage with one API on every host.",
845
+ title: "KV"
846
+ }),
847
+ mcp: feature({
848
+ docs: "/docs/mcp",
849
+ hosts: everywhere("nitro", "Nitro"),
850
+ id: "mcp",
851
+ packages: ["@vite-hub/mcp"],
852
+ requiredOptions: [{
853
+ option: "mcp.auth",
854
+ detail: "Choose an access mode when Auth is disabled. With Auth enabled, MCP requires sign-in by default. The optional mode requires Auth and lets anyone call public tools. Set false only when anyone may call every tool."
855
+ }],
856
+ summary: "The app's own MCP server, with one tool per file in `server/mcp/tools/`.",
857
+ title: "MCP server"
858
+ }),
859
+ observability: feature({
860
+ docs: "/docs/agents/observability",
861
+ hosts: everywhere("evlog", "Evlog"),
862
+ id: "observability",
863
+ packages: ["evlog"],
864
+ summary: "Request logs through Evlog, the logs that the Console reads, and Agent telemetry with a service name.",
865
+ title: "Observability"
866
+ }),
867
+ queue: feature({
868
+ definition: starter("server/queues", (name) => `import { defineQueue } from "vite-hub/queue"
869
+
870
+ export default defineQueue<{ id: string }>({
871
+ handler: async ({ payload }) => {
872
+ console.log("${name}", payload.id)
873
+ },
874
+ })
875
+ `, { suffix: "queue" }),
876
+ docs: "/docs/queue",
877
+ enabledByDiscovery: ["queues"],
878
+ hosts: {
879
+ cloudflare: native("cloudflare", "Queues", "Cloudflare Queues bindings and consumers."),
880
+ deno: unsupported("No Deno Queue driver is provided."),
881
+ dev: native("local", "Local driver", "The local driver stores jobs in .vitehub/data/queue and runs them in the dev server process.", "single-host"),
882
+ netlify: unsupported("Netlify has no Queue driver, so `vitehub({ queue })` fails on Netlify."),
883
+ node: native("local", "Postgres / local driver", "With a Postgres Default Database, the postgres driver keeps jobs in Postgres and every instance runs them. Else the local driver keeps jobs on the disk of one host.", "single-host"),
884
+ vercel: native("vercel", "Vercel Queues", "Vercel Queues callbacks and runtime client.")
885
+ },
886
+ id: "queue",
887
+ packages: ["@vite-hub/queue"],
888
+ providerPackages: { driver: { postgres: ["postgres"] } },
889
+ service: "queue",
890
+ summary: "Background jobs in `server/queues/` with retries and delivery on every supported host.",
891
+ title: "Queue"
892
+ }),
893
+ rateLimit: feature({
894
+ developmentOverrides: ["cloudflare"],
895
+ docs: "/docs/rate-limit",
896
+ hosts: {
897
+ cloudflare: native("cloudflare", "Cloudflare", "Native Cloudflare Rate Limiting binding."),
898
+ deno: unsupported("ViteHub has no native Deno Rate Limit driver."),
899
+ dev: native("memory", "memory", "Process-local memory driver for development and tests.", "process-local"),
900
+ netlify: unsupported("ViteHub has no native Netlify Rate Limit driver."),
901
+ node: native("memory", "memory, or KV", "Without KV, each process counts alone. With KV on, ViteHub selects the kv provider, which shares the counts when KV uses Redis or a Postgres Database.", "process-local"),
902
+ vercel: unsupported("ViteHub has no native Vercel Rate Limit driver.")
903
+ },
904
+ id: "rateLimit",
905
+ packages: ["@vite-hub/rate-limit"],
906
+ service: "rateLimit",
907
+ summary: "Rate limits in `server/rate-limits/` that protect routes and Agent tools.",
908
+ title: "Rate Limit"
909
+ }),
910
+ realtime: feature({
911
+ definition: starter("server/realtime", (name) => `import { defineRealtime } from "vite-hub/realtime"
912
+
913
+ export default defineRealtime({
914
+ authorize: true,
915
+ document: { workspace: "${name}" },
916
+ })
917
+ `),
918
+ developmentOverrides: [
919
+ "cloudflare",
920
+ "deno",
921
+ "netlify",
922
+ "vercel"
923
+ ],
924
+ docs: "/docs/realtime",
925
+ enabledByDiscovery: ["realtime"],
926
+ hosts: {
927
+ cloudflare: native("cloudflare", "Durable Objects", "Cloudflare Durable Objects run the production rooms."),
928
+ deno: unsupported("Realtime has no distributed Deno driver, and process memory is rejected for the Deno host."),
929
+ dev: native("memory", "memory", "Process-memory driver for local development.", "process-local"),
930
+ netlify: unsupported("Realtime has no distributed Netlify driver, and process memory is rejected for the Netlify host."),
931
+ node: native("node", "Postgres or Redis", "Each instance keeps its rooms in memory and shares them through Redis with REDIS_URL, else Postgres on a Postgres Default Database. Without either, rooms stay in one process."),
932
+ vercel: unsupported("Realtime has no distributed Vercel driver, and process memory is rejected for the Vercel host.")
933
+ },
934
+ id: "realtime",
935
+ packages: ["@vite-hub/realtime"],
936
+ service: "realtime",
937
+ summary: "Shared rooms with presence and Yjs documents.",
938
+ title: "Realtime"
939
+ }),
940
+ sandboxTask: feature({
941
+ docs: "/docs/sandbox",
942
+ hosts: {
943
+ cloudflare: native("cloudflare", "CF Sandbox", "Cloudflare Sandbox execution provider."),
944
+ deno: unsupported("No Deno Sandbox driver is provided."),
945
+ dev: unsupported("The default Node host has no Sandbox Provider. With the Cloudflare or Vercel host, `vite dev` runs each Sandbox Task as a process on this machine, with no isolation and no provider account. `sandboxTask: { remote: true }` uses the host's Sandbox instead."),
946
+ netlify: explicit("sandboxTask.driver", "Vercel Sandbox", "The Netlify host has no Sandbox, so `sandboxTask: true` fails. Set `sandboxTask: { driver: \"vercel\" }` and Vercel credentials to use Vercel Sandbox."),
947
+ node: explicit("sandboxTask.driver", "Vercel Sandbox", "The Node host has no Sandbox, so `sandboxTask: true` fails. Set `sandboxTask: { driver: \"vercel\" }` and Vercel credentials to use Vercel Sandbox."),
948
+ vercel: native("vercel", "Vercel Sandbox", "Vercel Sandbox execution provider.")
949
+ },
950
+ id: "sandboxTask",
951
+ packages: ["@vite-hub/sandbox"],
952
+ service: "sandbox",
953
+ summary: "Sandbox Tasks in `server/sandbox-tasks/`. Each run starts an isolated Cloudflare or Vercel Sandbox.",
954
+ title: "Sandbox"
955
+ }),
956
+ schedule: feature({
957
+ definition: starter("server/schedules", (name) => `import { defineSchedule } from "vite-hub/schedule"
958
+
959
+ export default defineSchedule({
960
+ cron: "0 * * * *",
961
+ handler: () => {
962
+ console.log("${name}")
963
+ },
964
+ })
965
+ `, { suffix: "schedule" }),
966
+ developmentOverrides: [
967
+ "cloudflare",
968
+ "netlify",
969
+ "vercel"
970
+ ],
971
+ docs: "/docs/schedule",
972
+ enabledByDiscovery: ["schedules"],
973
+ hosts: {
974
+ cloudflare: native("cloudflare", "Cron triggers", "Cloudflare scheduled events and Nitro Provider Wake."),
975
+ deno: native("deno", "Deno.cron", "`Deno.cron` output that the generated `.output/main.ts` loads before the Nitro server."),
976
+ dev: native("local", "Local / process", "Local development runner and the explicit process runtime.", "single-host"),
977
+ netlify: native("netlify", "Scheduled fn", "One generated Netlify scheduled function per static Schedule."),
978
+ node: native("process", "process", "Process runtime in the server process. `schedule: true` uses it. Set `providerOutput: false` to wake Schedules yourself. With a Postgres or remote libSQL Default Database, servers claim occurrences in `vitehub_leases`. A run can repeat if its lease expires. Without a shared lease store, run one server.", "single-host"),
979
+ vercel: native("vercel", "Vercel Cron", "Vercel Cron Jobs provider output.")
980
+ },
981
+ id: "schedule",
982
+ packages: ["@vite-hub/schedule"],
983
+ summary: "Cron Schedules in `server/schedules/` that run on the host's scheduler.",
984
+ title: "Schedule"
985
+ }),
986
+ workflow: feature({
987
+ definition: starter("server/workflows", () => `import { defineWorkflow } from "vite-hub/workflow"
988
+
989
+ export default defineWorkflow<{ id: string }>({
990
+ handler: async ({ payload }) => {
991
+ return { id: payload.id }
992
+ },
993
+ })
994
+ `, {
995
+ folder: "index",
996
+ suffix: "workflow"
997
+ }),
998
+ docs: "/docs/workflows",
999
+ enabledByDiscovery: ["workflows"],
1000
+ hosts: {
1001
+ cloudflare: native("cloudflare", "CF Workflows", "Cloudflare Workflows provider."),
1002
+ deno: explicit("workflow.driver", "OpenWorkflow", "Set `workflow.driver` to \"openworkflow\" with `workflow.postgres.url`, and start its worker. A build without a driver fails."),
1003
+ dev: native("openworkflow", "OpenWorkflow", "The Node host runs OpenWorkflow and its worker in the dev server, on .vitehub/data/openworkflow.sqlite.db. workflow.remote lets it use the Postgres Default Database or OPENWORKFLOW_POSTGRES_URL."),
1004
+ netlify: explicit("workflow.driver", "OpenWorkflow", "Use OpenWorkflow explicitly. No Netlify-native Workflow driver is provided."),
1005
+ node: {
1006
+ ...native("openworkflow", "OpenWorkflow", "OpenWorkflow is the default, and each server runs its worker. It uses OPENWORKFLOW_POSTGRES_URL or the Postgres Default Database. Without them, runs use a SQLite file on one host.", "single-host"),
1007
+ envOverrides: ["OPENWORKFLOW_POSTGRES_URL"].map((env) => ({
1008
+ env,
1009
+ support: native("openworkflow", "OpenWorkflow (Postgres)", `${env} selects Postgres. Several servers can run the worker on the same database, and each run executes once.`)
1010
+ }))
1011
+ },
1012
+ vercel: native("vercel", "Vercel Workflow", "Vercel Workflow provider and Workflow DevKit output.")
1013
+ },
1014
+ id: "workflow",
1015
+ packages: ["@vite-hub/workflow"],
1016
+ summary: "Durable Workflows in `server/workflows/` with steps and driver retries.",
1017
+ title: "Workflow"
1018
+ }),
1019
+ workspace: feature({
1020
+ developmentOverrides: [
1021
+ "cloudflare",
1022
+ "deno",
1023
+ "netlify",
1024
+ "vercel"
1025
+ ],
1026
+ docs: "/docs/workspace",
1027
+ enabledByDiscovery: ["workspaces"],
1028
+ hosts: {
1029
+ cloudflare: native("memory", "Artifacts / GitHub", "Memory by default, or Cloudflare Artifacts beta and GitHub for durable state.", "process-local"),
1030
+ deno: explicit("workspace.store", "GitHub", "Select the GitHub Workspace Store explicitly for durable state."),
1031
+ dev: native("local", "local / memory", "Local filesystem or in-memory Workspace Store.", "single-host"),
1032
+ netlify: explicit("workspace.store", "GitHub", "Select the GitHub Workspace Store explicitly for durable state."),
1033
+ node: native("local", "local / GitHub", "Local filesystem, memory, or GitHub Workspace Store.", "single-host"),
1034
+ vercel: {
1035
+ ...native("memory", "memory / Blob / GitHub", "Process-local memory by default. BLOB_READ_WRITE_TOKEN selects Vercel Blob; GitHub can be selected explicitly for durable state.", "process-local"),
1036
+ envOverrides: [{
1037
+ env: "BLOB_READ_WRITE_TOKEN",
1038
+ support: native("vercel", "Blob / GitHub", "BLOB_READ_WRITE_TOKEN selects durable Vercel Blob storage by default.")
1039
+ }]
1040
+ }
1041
+ },
1042
+ id: "workspace",
1043
+ packages: ["@vite-hub/workspace"],
1044
+ summary: "File workspaces that Agents read and edit, backed by local, Blob, or GitHub stores.",
1045
+ title: "Workspace"
1046
+ })
1047
+ };
1048
+ /** Packages needed by a feature, its provider, and its enabled feature integrations. */
1049
+ function featurePackages(id, value, host, enabled = []) {
1050
+ const definition = features[id];
1051
+ const options = value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
1052
+ const stores = options?.stores;
1053
+ const selected = ((id === "blob" || id === "kv") && stores && typeof stores === "object" && !Array.isArray(stores) ? [value, ...Object.values(stores)] : [value]).flatMap((value) => Object.entries(definition.providerPackages ?? {}).flatMap(([key, choices]) => {
1054
+ const choice = value && typeof value === "object" && !Array.isArray(value) ? Reflect.get(value, key) : void 0;
1055
+ return typeof choice === "string" ? choices[choice] ?? [] : [];
1056
+ }));
1057
+ if (id === "observability" && typeof options?.service === "string") selected.push("@vite-hub/agent");
1058
+ if (id === "observability" && options?.posthog) selected.push("posthog-node");
1059
+ const sandboxDriver = typeof options?.driver === "string" ? options.driver : host;
1060
+ if (id === "sandboxTask" && (sandboxDriver === "vercel" || sandboxDriver === "cloudflare")) selected.push(sandboxDriverPackages[sandboxDriver]);
1061
+ if ((id === "queue" || id === "workflow") && host === "vercel" && (options?.driver ?? "vercel") === "vercel") selected.push(...vercelProviderPackages[id]);
1062
+ if (id === "email" && options?.driver === "smtp" && host !== "cloudflare") selected.push(...ownerCheckedPackages.email ?? []);
1063
+ if (id === "console" && enabled.includes("agent")) selected.push(...consoleFeaturePackages.agents);
1064
+ return [.../* @__PURE__ */ new Set([...definition.packages, ...selected])];
1065
+ }
1066
+ const ownerCheckedPackages = { email: ["nodemailer"] };
1067
+ const sandboxDriverPackages = {
1068
+ cloudflare: "@cloudflare/sandbox",
1069
+ vercel: "@vercel/sandbox"
1070
+ };
1071
+ /**
1072
+ * The SDKs of the Vercel provider. Native Vercel Workflows also need `workflow` and `@workflow/builders`, but only
1073
+ * `@vite-hub/workflow` knows when a Workflow is native, so it checks those two itself.
1074
+ */
1075
+ const vercelProviderPackages = {
1076
+ queue: ["@vercel/queue", "@vercel/functions"],
1077
+ workflow: ["@vercel/functions"]
1078
+ };
1079
+ const drizzleRange = "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0";
1080
+ const installRanges = {
1081
+ "drizzle-kit": drizzleRange,
1082
+ "drizzle-orm": drizzleRange
1083
+ };
1084
+ /**
1085
+ * The package manager argument that installs `name`, such as `drizzle-orm@1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0`. Drizzle tags 0.x as
1086
+ * `latest` and the next 1.0 candidate as `rc`, so a plain name installs a version that ViteHub cannot import. npm saves
1087
+ * the range as written, and an exact version would be saved as `^1.0.0-rc.5`, which also matches later candidates.
1088
+ * Other packages keep their name. Feature catalogs, status, and removal use the plain name.
1089
+ */
1090
+ function installSpecifier(name) {
1091
+ const range = installRanges[name];
1092
+ return range ? `${name}@${range}` : name;
1093
+ }
1094
+ function quoteSupportedInstallSpecifier(value) {
1095
+ const separator = value.indexOf("@", 1);
1096
+ if (separator < 0) return void 0;
1097
+ const name = value.slice(0, separator);
1098
+ return Object.hasOwn(installRanges, name) && value === installSpecifier(name) ? `"${value}"` : void 0;
1099
+ }
1100
+ function formatInstallArgument(value) {
1101
+ return quoteSupportedInstallSpecifier(value) ?? (/^[\w@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`);
1102
+ }
1103
+ /** Additional Console owners selected by its enabled Agent integration. */
1104
+ const consoleFeaturePackages = { agents: ["@libsql/client", "drizzle-orm"] };
1105
+ function featureSupport(id, host, appHost) {
1106
+ const definition = features[id];
1107
+ if (host !== "dev") return definition.hosts[host];
1108
+ invariant(appHost, "every caller of featureSupport() for the dev host passes the configured ViteHub host");
1109
+ if (id === "workflow" && appHost === "deno") return native("vercel", "Inline", "Development runs each Workflow inline unless OpenWorkflow storage or a provider is configured.", "process-local");
1110
+ return definition.hosts[appHost === "node" || definition.developmentOverrides?.includes(appHost) ? "dev" : appHost];
1111
+ }
1112
+ /**
1113
+ * The features that `enabled` turn on through implications, without the ones already in `enabled`.
1114
+ * This follows implications transitively.
1115
+ * `disabled` lists features that the app sets to `false`; an implication never turns them on.
1116
+ */
1117
+ function impliedFeatures(enabled, disabled = []) {
1118
+ const on = new Set(enabled);
1119
+ const implied = [];
1120
+ const pending = [...enabled];
1121
+ while (pending.length) {
1122
+ const id = pending.shift();
1123
+ for (const implication of features[id].implies) {
1124
+ if (on.has(implication.feature) || disabled.includes(implication.feature)) continue;
1125
+ on.add(implication.feature);
1126
+ implied.push(implication.feature);
1127
+ pending.push(implication.feature);
1128
+ }
1129
+ }
1130
+ return implied;
1131
+ }
1132
+ // ../internal/dist/vite-CELQZdD3.js
1133
+ const projectRootDirectoryMarkers = [
1134
+ ["server", "agents"],
1135
+ ["server", "channels"],
1136
+ ["server", "connections"],
1137
+ ["server", "browsers"],
1138
+ ["server", "emails"],
1139
+ ["server", "schedules"],
1140
+ ["server", "workspaces"]
1141
+ ];
1142
+ const projectRootFileMarkers = [
1143
+ ["package.json"],
1144
+ ["nuxt.config.ts"],
1145
+ ["nuxt.config.mts"],
1146
+ ["nuxt.config.js"],
1147
+ ["nuxt.config.mjs"]
1148
+ ];
1149
+ function resolveViteHubProjectRoot(root, options = {}) {
1150
+ const resolvedRoot = resolve$1(root);
1151
+ const temporaryRoot = resolve$1(tmpdir());
1152
+ const sharedTemporaryRoot = dirname$1(temporaryRoot) === parse(temporaryRoot).root ? temporaryRoot : void 0;
1153
+ if (options.projectRoot) return resolve$1(resolvedRoot, options.projectRoot);
1154
+ if (basename$1(resolvedRoot) === "app") {
1155
+ const parent = dirname$1(resolvedRoot);
1156
+ if (parent !== sharedTemporaryRoot && (hasProjectRootDirectoryMarker(parent) || hasProjectRootFileMarker(parent, [
1157
+ "nuxt.config.ts",
1158
+ "nuxt.config.mts",
1159
+ "nuxt.config.js",
1160
+ "nuxt.config.mjs"
1161
+ ]))) return parent;
1162
+ }
1163
+ let current = resolvedRoot;
1164
+ while (true) {
1165
+ if (current === sharedTemporaryRoot && resolvedRoot !== current) return resolvedRoot;
1166
+ if (hasProjectRootMarker(current)) return current;
1167
+ const parent = dirname$1(current);
1168
+ if (parent === current) return resolvedRoot;
1169
+ current = parent;
1170
+ }
1171
+ }
1172
+ function hasProjectRootDirectoryMarker(root) {
1173
+ for (const marker of projectRootDirectoryMarkers) try {
1174
+ if (statSync(resolve$1(root, ...marker)).isDirectory()) return true;
1175
+ } catch (error) {
1176
+ if (!isMissingProjectMarker(error)) throw error;
1177
+ }
1178
+ return false;
1179
+ }
1180
+ function hasProjectRootMarker(root) {
1181
+ if (hasProjectRootDirectoryMarker(root)) return true;
1182
+ return hasProjectRootFileMarker(root, projectRootFileMarkers.flat());
1183
+ }
1184
+ function hasProjectRootFileMarker(root, markers) {
1185
+ for (const marker of markers) {
1186
+ const path = Array.isArray(marker) ? marker : [marker];
1187
+ try {
1188
+ if (statSync(resolve$1(root, ...path)).isFile()) return true;
1189
+ } catch (error) {
1190
+ if (!isMissingProjectMarker(error)) throw error;
1191
+ }
1192
+ }
1193
+ return false;
1194
+ }
1195
+ function isMissingProjectMarker(error) {
1196
+ const code = error.code;
1197
+ return code === "ENOENT" || code === "ENOTDIR";
1198
+ }
1199
+ // ../internal/dist/operation-rpc.js
1200
+ /** Path of the operation RPC under the app. Dev servers and deployed apps serve it the same way, one birpc call per POST. */
1201
+ const operationRpcPath = "/_vitehub/rpc";
1202
+ function text(value) {
1203
+ return String(value) === value && value ? value : void 0;
1204
+ }
1205
+ /** Read an untrusted failure body. It keeps only the diagnostic fields, so a stack never passes through. */
1206
+ function readOperationRpcError(value) {
1207
+ if (!isRecord(value)) return void 0;
1208
+ const code = text(value.code);
1209
+ const message = text(value.message);
1210
+ const status = value.status;
1211
+ if (!code || !message || !Number.isInteger(status)) return void 0;
1212
+ const failure = {
1213
+ code,
1214
+ message,
1215
+ status: Number(status)
1216
+ };
1217
+ if (text(value.fix)) failure.fix = text(value.fix);
1218
+ if (text(value.docs)) failure.docs = text(value.docs);
1219
+ if (isRecord(value.details)) failure.details = value.details;
1220
+ return failure;
1221
+ }
1222
+ /** Read one response message. */
1223
+ function readOperationRpcReply(value) {
1224
+ if (!isRecord(value) || value.t !== "s") return void 0;
1225
+ const id = text(value.i);
1226
+ if (Object.hasOwn(value, "e")) {
1227
+ const error = readOperationRpcError(value.e);
1228
+ return error ? {
1229
+ t: "s",
1230
+ ...id ? { i: id } : {},
1231
+ e: error
1232
+ } : void 0;
1233
+ }
1234
+ return id ? {
1235
+ t: "s",
1236
+ i: id,
1237
+ r: value.r
1238
+ } : void 0;
1239
+ }
1240
+ /**
1241
+ * Call one operation with birpc over a request and answer transport, such as one HTTP POST per call. `send` posts the
1242
+ * JSON message and returns the parsed answer; its own failures, such as a network error or an abort, reject.
1243
+ */
1244
+ async function callOperationRpc(name, input, send) {
1245
+ let receive;
1246
+ let answer;
1247
+ const notReply = /* @__PURE__ */ new Error("The answer is not a reply to the operation call.");
1248
+ const rpc = createBirpc({}, {
1249
+ on: (listener) => {
1250
+ receive = listener;
1251
+ },
1252
+ post: async (message) => {
1253
+ answer = await send(JSON.stringify(message));
1254
+ const reply = readOperationRpcReply(answer.body);
1255
+ if (!reply || reply.i !== void 0 && reply.i !== message.i) throw notReply;
1256
+ await receive({
1257
+ ...reply,
1258
+ i: message.i
1259
+ });
1260
+ },
1261
+ proxify: false,
1262
+ timeout: -1
1263
+ });
1264
+ try {
1265
+ return {
1266
+ ok: true,
1267
+ value: await rpc.$call(name, ...input === void 0 ? [] : [input]),
1268
+ answer
1269
+ };
1270
+ } catch (error) {
1271
+ if (!answer) throw error;
1272
+ if (error === notReply) return {
1273
+ ok: false,
1274
+ error: void 0,
1275
+ answer
1276
+ };
1277
+ return {
1278
+ ok: false,
1279
+ error: readOperationRpcError(error),
1280
+ answer
1281
+ };
1282
+ }
1283
+ }
1284
+ // ../internal/dist/console-signature.js
434
1285
  /**
435
1286
  * Signed requests to the Console endpoint of an app, `POST /_vitehub/rpc`. Each caller, such as one Console link or one
436
1287
  * CI job, has an Ed25519 key pair. The app keeps only the public keys, in `VITEHUB_CONSOLE_KEY_<NAME>`, so a copy of
@@ -559,72 +1410,7 @@ function readConsoleSigningKey(env) {
559
1410
  privateKey
560
1411
  };
561
1412
  }
562
- //#endregion
563
- //#region ../internal/dist/build/vite.js
564
- const projectRootDirectoryMarkers = [
565
- ["server", "agents"],
566
- ["server", "channels"],
567
- ["server", "connections"],
568
- ["server", "browsers"],
569
- ["server", "emails"],
570
- ["server", "schedules"],
571
- ["server", "workspaces"]
572
- ];
573
- const projectRootFileMarkers = [
574
- ["package.json"],
575
- ["nuxt.config.ts"],
576
- ["nuxt.config.mts"],
577
- ["nuxt.config.js"],
578
- ["nuxt.config.mjs"]
579
- ];
580
- function resolveViteHubProjectRoot(root, options = {}) {
581
- const resolvedRoot = resolve$1(root);
582
- const temporaryRoot = resolve$1(tmpdir());
583
- const sharedTemporaryRoot = dirname$1(temporaryRoot) === parse(temporaryRoot).root ? temporaryRoot : void 0;
584
- if (options.projectRoot) return resolve$1(resolvedRoot, options.projectRoot);
585
- if (basename$1(resolvedRoot) === "app") {
586
- const parent = dirname$1(resolvedRoot);
587
- if (parent !== sharedTemporaryRoot && (hasProjectRootDirectoryMarker(parent) || hasProjectRootFileMarker(parent, [
588
- "nuxt.config.ts",
589
- "nuxt.config.mts",
590
- "nuxt.config.js",
591
- "nuxt.config.mjs"
592
- ]))) return parent;
593
- }
594
- let current = resolvedRoot;
595
- while (true) {
596
- if (current === sharedTemporaryRoot && resolvedRoot !== current) return resolvedRoot;
597
- if (hasProjectRootMarker(current)) return current;
598
- const parent = dirname$1(current);
599
- if (parent === current) return resolvedRoot;
600
- current = parent;
601
- }
602
- }
603
- function hasProjectRootDirectoryMarker(root) {
604
- for (const marker of projectRootDirectoryMarkers) try {
605
- if (statSync(resolve$1(root, ...marker)).isDirectory()) return true;
606
- } catch (error) {
607
- if (error.code !== "ENOENT") throw error;
608
- }
609
- return false;
610
- }
611
- function hasProjectRootMarker(root) {
612
- if (hasProjectRootDirectoryMarker(root)) return true;
613
- return hasProjectRootFileMarker(root, projectRootFileMarkers.flat());
614
- }
615
- function hasProjectRootFileMarker(root, markers) {
616
- for (const marker of markers) {
617
- const path = Array.isArray(marker) ? marker : [marker];
618
- try {
619
- if (statSync(resolve$1(root, ...path)).isFile()) return true;
620
- } catch (error) {
621
- if (error.code !== "ENOENT") throw error;
622
- }
623
- }
624
- return false;
625
- }
626
- //#endregion
627
- //#region ../internal/dist/standard-schema.js
1413
+ // ../internal/dist/standard-schema.js
628
1414
  function readOwn(value, key) {
629
1415
  if (value === null || Object(value) !== value) return;
630
1416
  try {
@@ -653,8 +1439,7 @@ function standardJsonSchema(schema, direction, target = "draft-2020-12", library
653
1439
  return;
654
1440
  }
655
1441
  }
656
- //#endregion
657
- //#region ../internal/dist/operation-definition.js
1442
+ // ../internal/dist/operation-definition.js
658
1443
  const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
659
1444
  const kinds = /* @__PURE__ */ new Set([
660
1445
  "read",
@@ -723,94 +1508,7 @@ function isSectionId(section) {
723
1508
  function operationInputJsonSchema(operation) {
724
1509
  return standardJsonSchema(operation.input, "input") ?? { type: "object" };
725
1510
  }
726
- //#endregion
727
- //#region ../internal/dist/operation-rpc.js
728
- /** Path of the operation RPC under the app. Dev servers and deployed apps serve it the same way, one birpc call per POST. */
729
- const operationRpcPath = "/_vitehub/rpc";
730
- function text(value) {
731
- return String(value) === value && value ? value : void 0;
732
- }
733
- /** Read an untrusted failure body. It keeps only the diagnostic fields, so a stack never passes through. */
734
- function readOperationRpcError(value) {
735
- if (!isRecord(value)) return void 0;
736
- const code = text(value.code);
737
- const message = text(value.message);
738
- const status = value.status;
739
- if (!code || !message || !Number.isInteger(status)) return void 0;
740
- const failure = {
741
- code,
742
- message,
743
- status: Number(status)
744
- };
745
- if (text(value.fix)) failure.fix = text(value.fix);
746
- if (text(value.docs)) failure.docs = text(value.docs);
747
- if (isRecord(value.details)) failure.details = value.details;
748
- return failure;
749
- }
750
- /** Read one response message. */
751
- function readOperationRpcReply(value) {
752
- if (!isRecord(value) || value.t !== "s") return void 0;
753
- const id = text(value.i);
754
- if (Object.hasOwn(value, "e")) {
755
- const error = readOperationRpcError(value.e);
756
- return error ? {
757
- t: "s",
758
- ...id ? { i: id } : {},
759
- e: error
760
- } : void 0;
761
- }
762
- return id ? {
763
- t: "s",
764
- i: id,
765
- r: value.r
766
- } : void 0;
767
- }
768
- /**
769
- * Call one operation with birpc over a request and answer transport, such as one HTTP POST per call. `send` posts the
770
- * JSON message and returns the parsed answer; its own failures, such as a network error or an abort, reject.
771
- */
772
- async function callOperationRpc(name, input, send) {
773
- let receive;
774
- let answer;
775
- const notReply = /* @__PURE__ */ new Error("The answer is not a reply to the operation call.");
776
- const rpc = createBirpc({}, {
777
- on: (listener) => {
778
- receive = listener;
779
- },
780
- post: async (message) => {
781
- answer = await send(JSON.stringify(message));
782
- const reply = readOperationRpcReply(answer.body);
783
- if (!reply || reply.i !== void 0 && reply.i !== message.i) throw notReply;
784
- await receive({
785
- ...reply,
786
- i: message.i
787
- });
788
- },
789
- proxify: false,
790
- timeout: -1
791
- });
792
- try {
793
- return {
794
- ok: true,
795
- value: await rpc.$call(name, ...input === void 0 ? [] : [input]),
796
- answer
797
- };
798
- } catch (error) {
799
- if (!answer) throw error;
800
- if (error === notReply) return {
801
- ok: false,
802
- error: void 0,
803
- answer
804
- };
805
- return {
806
- ok: false,
807
- error: readOperationRpcError(error),
808
- answer
809
- };
810
- }
811
- }
812
- //#endregion
813
- //#region ../internal/dist/operations.js
1511
+ // ../internal/dist/operations.js
814
1512
  /** Header that proves the caller is not a browser page. A foreign page cannot send it without a CORS preflight. */
815
1513
  const operationRpcHeader = "x-vitehub-console";
816
1514
  /** Response header of the local dev RPC. Its value is {@link projectRootHash} of the project that the server runs. */
@@ -877,11 +1575,16 @@ function operationsOf(value) {
877
1575
  /** The CLI namespace and command of an operation. Defaults: the section (or the name prefix) and the verb. */
878
1576
  function operationCliPath(operation) {
879
1577
  const dot = operation.name.indexOf(".");
1578
+ const cli = operationCliOptions(operation);
880
1579
  return {
881
- command: operation.cli?.command ?? operation.name.slice(dot + 1),
882
- namespace: operation.cli?.namespace ?? (typeof operation.section === "string" ? operation.section : operation.name.slice(0, dot))
1580
+ command: cli?.command ?? operation.name.slice(dot + 1),
1581
+ namespace: cli?.namespace ?? (typeof operation.section === "string" ? operation.section : operation.name.slice(0, dot))
883
1582
  };
884
1583
  }
1584
+ /** The CLI options of an operation, or undefined for an operation without options or with `cli: false`. */
1585
+ function operationCliOptions(operation) {
1586
+ return operation.cli || void 0;
1587
+ }
885
1588
  /**
886
1589
  * The MCP tool name of an operation: every character outside `[a-zA-Z0-9_-]` becomes `_`, since clients such as
887
1590
  * Claude reject a dot in a tool name. `content.publish` is `content_publish`.
@@ -906,6 +1609,7 @@ function createOperationRegistry(sources) {
906
1609
  const operations = [...byName.values()].map((entry) => entry.operation).sort((left, right) => left.name.localeCompare(right.name));
907
1610
  const commands = /* @__PURE__ */ new Map();
908
1611
  for (const operation of operations) {
1612
+ if (operation.cli === false) continue;
909
1613
  const { command, namespace } = operationCliPath(operation);
910
1614
  if (reservedOperationNamespaces.includes(namespace)) throw invalidDefinition(operation.name, `the CLI namespace ${JSON.stringify(namespace)} is reserved for built-in commands. Set cli.namespace to another name.`);
911
1615
  const key = `${namespace} ${command}`;
@@ -933,12 +1637,23 @@ function describeInputIssues(issues) {
933
1637
  return path ? `${path}: ${issue.message}` : issue.message;
934
1638
  }).join(" ");
935
1639
  }
1640
+ function describeInputFields(schema) {
1641
+ const shapes = (Array.isArray(schema.anyOf) ? schema.anyOf : [schema]).map((shape) => {
1642
+ if (!isRecordOrFunction(shape) || !isRecordOrFunction(shape.properties)) return void 0;
1643
+ const required = Array.isArray(shape.required) ? shape.required : [];
1644
+ const fields = Object.keys(shape.properties).map((field) => required.includes(field) ? field : `${field}?`);
1645
+ return fields.length ? `{ ${fields.join(", ")} }` : "{}";
1646
+ });
1647
+ return shapes.every((shape) => shape !== void 0) ? shapes.join(" or ") : void 0;
1648
+ }
936
1649
  /** Validate `input` with the schema of the operation. Throws `INTERNAL_R0022` with `status: 400`. */
937
1650
  async function parseOperationInput(operation, input) {
938
1651
  const result = await operation.input["~standard"].validate(input ?? {});
939
1652
  if (!result.issues) return result.value;
940
- const error = internalErrorDiagnostics.INTERNAL_R0022({ message: `Invalid input for ${operation.name}. ${describeInputIssues(result.issues)}` });
941
- throw Object.assign(error, { status: 400 });
1653
+ const fields = describeInputFields(operationInputJsonSchema(operation));
1654
+ const issues = describeInputIssues(result.issues);
1655
+ const message = `Invalid input for ${operation.name}. ${issues}${fields ? `${/[.!?]$/.test(issues) ? "" : "."} ${operation.name} takes ${fields}.` : ""}`;
1656
+ throw Object.assign(internalErrorDiagnostics.INTERNAL_R0022({ message }), { status: 400 });
942
1657
  }
943
1658
  /** The kind of one call of an operation: a `readOnlyWhen` match makes a write operation a read. */
944
1659
  function operationCall(operation, input) {
@@ -1090,8 +1805,7 @@ async function callOperationFromCli(call, name, input) {
1090
1805
  url
1091
1806
  }, name, input);
1092
1807
  }
1093
- //#endregion
1094
- //#region ../internal/dist/vite-stage.js
1808
+ // ../internal/dist/vite-stage.js
1095
1809
  /**
1096
1810
  * Vite's `loadEnv(mode, envDir, "")`: every `.env` value of the mode and the whole shell. With `DEBUG=vite:env`, Vite
1097
1811
  * logs that result to stderr, secrets included. loadEnv is synchronous, so this drops only the writes of this call.
@@ -1132,8 +1846,7 @@ async function withViteStageEnvironment(env, callback) {
1132
1846
  release();
1133
1847
  }
1134
1848
  }
1135
- //#endregion
1136
- //#region ../internal/dist/provision-state.js
1849
+ // ../internal/dist/provision-state.js
1137
1850
  const PROVISION_STATE_FILE = ".vitehub/provision.json";
1138
1851
  function getProvisionStatePath(rootDir) {
1139
1852
  return resolve(rootDir, PROVISION_STATE_FILE);
@@ -1214,8 +1927,7 @@ function sortKeys(value) {
1214
1927
  if (!value || typeof value !== "object" || Array.isArray(value)) return value;
1215
1928
  return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortKeys(value[key])]));
1216
1929
  }
1217
- //#endregion
1218
- //#region src/error-diagnostics.ts
1930
+ // src/error-diagnostics.ts
1219
1931
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
1220
1932
  const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1221
1933
  docsBase: "https://vitehub.dev/docs/cli/diagnostics",
@@ -1240,7 +1952,6 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1240
1952
  fix: "Check that the Console stores env values, that the key opens the project, and that you are an owner or admin of the team.",
1241
1953
  why: ({ code, message }) => `The Console refused the pull (${String(code)}). ${String(message)}`
1242
1954
  },
1243
- /** A host API answered with a shape that the CLI cannot read. */
1244
1955
  CLI_HOST_RESPONSE_INVALID: {
1245
1956
  fix: "Run the command again. If the error stays, check the status page of the host and update `@vite-hub/cli`.",
1246
1957
  why: ({ host }) => `[vitehub] The ${host} API returned an unexpected response.`
@@ -1261,7 +1972,6 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1261
1972
  fix: "Start `vite dev` in this project, or pass `--url <origin>` of a running or deployed app. `VITEHUB_DEV_SERVER_URL` also names a server.",
1262
1973
  why: ({ message }) => message === void 0 ? "" : String(message)
1263
1974
  },
1264
- /** A setup command failed with an error that has no code, and `--json` reports it. */
1265
1975
  CLI_SETUP_FAILED: {
1266
1976
  fix: "Fix the cause that the message names, then run the command again.",
1267
1977
  why: ({ message }) => message
@@ -1295,7 +2005,7 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1295
2005
  why: ({ root }) => `${String(root)} has no package.json, vite.config, or nuxt.config file.`
1296
2006
  },
1297
2007
  SETUP_CONFIG_MANUAL: {
1298
- fix: ({ snippet }) => `Add these keys to the vitehub() options by hand:\n${String(snippet)}`,
2008
+ fix: ({ fix, snippet }) => fix ?? `Add these keys to the vitehub() options by hand:\n${String(snippet)}`,
1299
2009
  why: ({ file, reason }) => `ViteHub cannot edit the vitehub() options in ${String(file)} without running the config (${String(reason)}).`
1300
2010
  },
1301
2011
  SETUP_FEATURE_UNSUPPORTED: {
@@ -1307,11 +2017,11 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1307
2017
  why: ({ definition, file, starter }) => starter === void 0 ? `${String(file)} exists and is not the starter Definition. ViteHub never overwrites a file.` : `${String(file)} already defines a ${String(definition)} Definition that conflicts with ${String(starter)}, so the build would reject both.`
1308
2018
  },
1309
2019
  SETUP_SERVER_DIR_MANUAL: {
1310
- fix: ({ command }) => command === "remove" ? "Use literal rootDir and serverDir options without layers, or pass --force to turn the features off without checking unresolved Definition files." : "Create the Definition in your evaluated Nuxt server directory and rerun without --name, or use literal rootDir and serverDir options without layers.",
2020
+ fix: ({ command }) => command === "remove" ? "Pass --force to turn the features off without checking unresolved Definition files, or use literal directory options without layers or directory overrides." : "Create the Definition in your evaluated Nuxt server directory and rerun without --name, or use literal directory options without layers or directory overrides.",
1311
2021
  why: "ViteHub cannot determine the Nuxt application server directory without running the config."
1312
2022
  },
1313
2023
  SETUP_INPUT_NEEDED: {
1314
- fix: "Run the `rerun` command, or pass the missing values with --option.",
2024
+ fix: ({ fix }) => fix ?? "Run the `rerun` command, or pass the missing values with --option.",
1315
2025
  why: ({ message }) => message === void 0 ? "" : String(message)
1316
2026
  },
1317
2027
  SETUP_INSTALL_FAILED: {
@@ -1363,7 +2073,7 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1363
2073
  why: () => "The project name is not known. vitehub() has no literal `name` and package.json has no name."
1364
2074
  },
1365
2075
  SETUP_LINK_PROJECT_NOT_FOUND: {
1366
- fix: ({ rerun }) => `Run \`${String(rerun)}\` to create it, or pass --project with the name of a project that exists.`,
2076
+ fix: ({ host, rerun }) => host === "deno" ? "Create the app in Deno Deploy first, then run `vitehub link --host deno`, or pass --project with the name of an existing app." : `Run \`${String(rerun)}\` to create it, or pass --project with the name of a project that exists.`,
1367
2077
  why: ({ host, project, account }) => `The ${String(host)} project ${JSON.stringify(String(project))} does not exist${account ? ` in account ${String(account)}` : ""}.`
1368
2078
  },
1369
2079
  SETUP_INIT_DIR_NOT_EMPTY: {
@@ -1378,9 +2088,13 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1378
2088
  fix: "Use the app's current host, or migrate its enabled features, providers and Definitions in the config before running init again.",
1379
2089
  why: ({ host }) => `init cannot change an enabled ViteHub stack to the ${String(host)} host.`
1380
2090
  },
2091
+ SETUP_INIT_NITRO_VERSION: {
2092
+ fix: ({ dir, range, scaffolded }) => `${scaffolded ? `The scaffold files remain in ${String(dir)}. ` : ""}Set nitro to \`${String(range)}\` in each section of package.json that declares it, then run init again.`,
2093
+ why: ({ dir, range }) => `${String(dir)} declares a Nitro version that init cannot verify against Nuxt 4.7's requirement (${String(range)}). ViteHub did not adopt it.`
2094
+ },
1381
2095
  SETUP_INIT_NUXT_VERSION: {
1382
- fix: ({ dir, scaffolded }) => `${scaffolded ? `The scaffold files remain in ${String(dir)}. ` : ""}Set nuxt to a Nuxt 5 version, then run init on that folder again.`,
1383
- why: ({ dir }) => `${String(dir)} does not declare a known Nuxt 5 version. ViteHub did not adopt it.`
2096
+ fix: ({ dir, scaffolded }) => `${scaffolded ? `The scaffold files remain in ${String(dir)}. ` : ""}Upgrade to Nuxt 4.7 with Nitro 3 (\`pnpm add nuxt@^4.7.0 nitro\`), or set nuxt to a Nuxt 5 version. Then run init on that folder again.`,
2097
+ why: ({ dir }) => `${String(dir)} does not declare a supported Nuxt version. ViteHub needs Nitro 3, which runs on Nuxt 4.7 with the nitro package, or on Nuxt 5. ViteHub did not adopt it.`
1384
2098
  },
1385
2099
  SETUP_DEPLOY_HOST_UNSUPPORTED: {
1386
2100
  fix: "Set `host` in vitehub() to cloudflare, vercel, netlify, or deno, or start the Node server from `.output` yourself.",
@@ -1390,6 +2104,10 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1390
2104
  fix: ({ fix }) => fix === void 0 ? "Log in with the host CLI, such as `npx wrangler login`, or set the host token, such as CLOUDFLARE_API_TOKEN, VERCEL_TOKEN, NETLIFY_AUTH_TOKEN, or DENO_DEPLOY_TOKEN, then run the command again." : String(fix),
1391
2105
  why: ({ host }) => `No ${String(host)} credentials were found in the environment or in the host CLI login.`
1392
2106
  },
2107
+ SETUP_DEPLOY_D1_MIGRATIONS_PENDING: {
2108
+ fix: ({ apply }) => `Set \`database.migrateOnDeploy: true\` so that \`vitehub deploy\` applies them before the Worker deploys. Or run \`${String(apply)}\` in the build output folder, then deploy again.`,
2109
+ why: ({ binding, migrations }) => `The build has D1 migrations that the remote database of the binding ${String(binding)} has not applied: ${String(migrations)}. The new code would query tables or columns that do not exist yet. Nothing was deployed.`
2110
+ },
1393
2111
  SETUP_DEPLOY_TEMPORARY_UNSUPPORTED: {
1394
2112
  fix: "Remove --temporary and deploy with your host login.",
1395
2113
  why: ({ reason }) => `--temporary cannot run here. ${String(reason)}`
@@ -1427,7 +2145,7 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1427
2145
  why: ({ firstDeploy, host, names, stage }) => firstDeploy ? `The app needs ${String(names)}, and no value was found. This is the first deploy to ${String(host)}: the project is not linked, so the host has no variables yet and every required name needs a local value for the ${String(stage)} stage. Nothing was deployed.` : `The app needs ${String(names)}, and neither ${String(host)} nor a local value for the ${String(stage)} stage has one. Nothing was deployed.`
1428
2146
  },
1429
2147
  SETUP_DEPLOY_ENV_NOT_LINKED: {
1430
- fix: ({ host }) => `Run \`vitehub link --host ${String(host)} --create\` to create the project, then deploy again.`,
2148
+ fix: ({ host }) => host === "deno" ? "Create the app in Deno Deploy if needed, run `vitehub link --host deno`, then deploy again." : `Run \`vitehub link --host ${String(host)} --create\` to create the project, then deploy again.`,
1431
2149
  why: ({ host, names }) => `The ${String(host)} project is not linked, so deploy cannot set ${String(names)} before the first deploy. Nothing was deployed.`
1432
2150
  },
1433
2151
  SETUP_DEPLOY_ENV_STAGE_UNSAFE: {
@@ -1524,8 +2242,7 @@ const cliErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
1524
2242
  }
1525
2243
  }
1526
2244
  });
1527
- //#endregion
1528
- //#region ../internal/dist/host-credentials.js
2245
+ // ../internal/dist/host-credentials.js
1529
2246
  const missingFixes = {
1530
2247
  cloudflare: {
1531
2248
  missing: ["CLOUDFLARE_API_TOKEN"],
@@ -1699,8 +2416,7 @@ function trimmed(value) {
1699
2416
  const result = value?.trim();
1700
2417
  return result ? result : void 0;
1701
2418
  }
1702
- //#endregion
1703
- //#region ../internal/dist/provider-failure.js
2419
+ // ../internal/dist/provider-failure.js
1704
2420
  const cloudflareCodes = {
1705
2421
  d1: {},
1706
2422
  kv: { 10014: "conflict" },
@@ -1802,8 +2518,7 @@ function readProviderErrorCodes(body) {
1802
2518
  const errors = Reflect.get(body, "errors");
1803
2519
  return [error && typeof error === "object" ? Reflect.get(error, "code") : void 0, ...Array.isArray(errors) ? errors.map((entry) => entry && typeof entry === "object" ? Reflect.get(entry, "code") : void 0) : []].filter((code) => typeof code === "number" && Number.isFinite(code) || typeof code === "string" && /^[\w.-]{1,128}$/.test(code));
1804
2520
  }
1805
- //#endregion
1806
- //#region ../internal/dist/provision.js
2521
+ // ../internal/dist/provision.js
1807
2522
  /** Plans one provider in step order and collects warnings and explicit unchecked state. */
1808
2523
  async function planProvisionSteps(provider, steps, context) {
1809
2524
  const warnings = [];
@@ -1940,8 +2655,7 @@ function createVercelProvisionClient(config, fetchImpl = globalThis.fetch) {
1940
2655
  function createNetlifyApiClient(token, fetchImpl = globalThis.fetch) {
1941
2656
  return createJsonClient(() => ({ host: "netlify" }), "https://api.netlify.com/api/v1", { authorization: `Bearer ${token}` }, fetchImpl);
1942
2657
  }
1943
- //#endregion
1944
- //#region src/provision.ts
2658
+ // src/provision.ts
1945
2659
  const PROVISION_HOSTS = ["cloudflare", "vercel"];
1946
2660
  const HOST_CREDENTIALS = {
1947
2661
  cloudflare: "CLOUDFLARE_ACCOUNT_ID and a Cloudflare login (`wrangler login` or CLOUDFLARE_API_TOKEN)",
@@ -2060,7 +2774,7 @@ async function resolveHost(command, parsed, context) {
2060
2774
  let host = parsed.host;
2061
2775
  let link;
2062
2776
  if (host === void 0) {
2063
- const { resolveDefaultDeployTarget } = await import("./deploy-C0RdI5OK.js").then((n) => n.n);
2777
+ const { resolveDefaultDeployTarget } = await import("./deploy-BZ2iQjZL.js").then((n) => n.n);
2064
2778
  try {
2065
2779
  const target = await resolveDefaultDeployTarget(resolveViteHubProjectRoot(context.rootDir), context.env, `vitehub provision ${command}`);
2066
2780
  host = target.host;
@@ -2087,7 +2801,6 @@ async function resolveHost(command, parsed, context) {
2087
2801
  function hasHostCredentials(host, env) {
2088
2802
  return Boolean(host === "cloudflare" ? resolveCloudflareProvisionConfig(env) : resolveVercelProvisionConfig(env));
2089
2803
  }
2090
- /** The context with the credentials of `resolveHostCredentials` in its env, so a `wrangler login` works as in deploy. */
2091
2804
  async function withHostCredentials(host, context, link) {
2092
2805
  const credentials = await resolveHostCredentials(host, {
2093
2806
  cwd: context.rootDir,
@@ -2319,5 +3032,4 @@ function createProvisionNamespace(load) {
2319
3032
  name: "provision"
2320
3033
  };
2321
3034
  }
2322
- //#endregion
2323
- export { operationInputJsonSchema as A, isRecord as B, callOperationFromCli as C, operationCliPath as D, operationCall as E, createCliDiscoveryNitroCloser as F, findViteHubDevServerUrl as I, getStableStdoutWrite as L, setupCommandNames as M, resolveViteHubProjectRoot as N, operationsOf as O, collectViteHubCliContribution as P, withStdoutOnStderr as R, callOperation as S, createOperationRegistry as T, readProvisionState as _, writeProvisionActions as a, loadAllEnv as b, createNetlifyApiClient as c, planProvisionSteps as d, resolveHostCredentials as f, mergeProvisionState as g, PROVISION_STATE_FILE as h, provisionEnv as i, reservedOperationNamespaces as j, parseOperationInput as k, createVercelProvisionClient as l, cliErrorDiagnostics as m, isProvisionHost as n, createCloudflareApiClient as o, runHostCli as p, provisionActionStatus as r, createCloudflareProvisionClient as s, createProvisionNamespace as t, isProvisionRequestError as u, readProvisionStateSync as v, collectOperationContributions as w, withViteStageEnvironment as x, writeProvisionState as y, internalErrorDiagnostics as z };
3035
+ export { internalErrorDiagnostics as $, parseOperationInput as A, formatInstallArgument as B, callOperationFromCli as C, operationCliOptions as D, operationCall as E, featureHosts as F, appUrlError as G, installSpecifier as H, featureIds as I, findViteHubDevServerUrl as J, collectViteHubCliContribution as K, featurePackages as L, reservedOperationNamespaces as M, setupCommandNames as N, operationCliPath as O, resolveViteHubProjectRoot as P, isRecord as Q, featureSupport as R, callOperation as S, createOperationRegistry as T, quoteSupportedInstallSpecifier as U, impliedFeatures as V, invariant as W, viteCliProjectConfig as X, getStableStdoutWrite as Y, withStdoutOnStderr as Z, readProvisionState as _, writeProvisionActions as a, loadAllEnv as b, createNetlifyApiClient as c, planProvisionSteps as d, resolveHostCredentials as f, mergeProvisionState as g, PROVISION_STATE_FILE as h, provisionEnv as i, operationInputJsonSchema as j, operationsOf as k, createVercelProvisionClient as l, cliErrorDiagnostics as m, isProvisionHost as n, createCloudflareApiClient as o, runHostCli as p, createCliDiscoveryNitroCloser as q, provisionActionStatus as r, createCloudflareProvisionClient as s, createProvisionNamespace as t, isProvisionRequestError as u, readProvisionStateSync as v, collectOperationContributions as w, withViteStageEnvironment as x, writeProvisionState as y, features as z };