@vite-hub/workspace 0.6.1 → 0.8.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.
Files changed (96) hide show
  1. package/README.md +6 -6
  2. package/dist/{asset-registry-0CdRAjIV.js → asset-registry-DJyE42kr.js} +1 -1
  3. package/dist/blob-database.d.ts +1 -1
  4. package/dist/blob-database.js +6 -6
  5. package/dist/checkout.js +2 -2
  6. package/dist/cloudflare.d.ts +1 -1
  7. package/dist/cloudflare.js +1 -1
  8. package/dist/{config-jo5QgE1w.js → config-Bze7OyvB.js} +15 -10
  9. package/dist/{config-DeA287c0.d.ts → config-DF6sqKXB.d.ts} +1 -1
  10. package/dist/durability.d.ts +1 -1
  11. package/dist/durability.js +2 -2
  12. package/dist/{error-diagnostics-B4me-ouV.js → error-diagnostics-CHgE8TQM.js} +16 -0
  13. package/dist/{error-diagnostics-kKXseq8d.js → error-diagnostics-CsiNo_oI.js} +3 -3
  14. package/dist/{file-BrNAXQgY.js → file-DIBPXqbk.js} +1 -1
  15. package/dist/{file-metadata-Bpsvjw_X.js → file-metadata-Dqpldj0h.js} +7 -2
  16. package/dist/{files--z2dLC5z.js → files-DAJyo7TU.js} +2 -2
  17. package/dist/files.d.ts +5 -5
  18. package/dist/files.js +5 -5
  19. package/dist/{github-k--_LCrX.js → github-DcrnEGNN.js} +4 -4
  20. package/dist/{glob-BreFjNAV.js → glob-BIg9O4yY.js} +2 -2
  21. package/dist/{glob-BEutagp1.js → glob-YVshR7WP.js} +1 -1
  22. package/dist/{host-C8yZizfk.js → host-BT7EnmZf.js} +7 -7
  23. package/dist/hosted-vercel-blob.d.ts +1 -1
  24. package/dist/hosted-vercel-blob.js +464 -1
  25. package/dist/hosted.d.ts +1 -1
  26. package/dist/hosted.js +917 -1
  27. package/dist/index.d.ts +6 -7
  28. package/dist/index.js +13 -13
  29. package/dist/internal/path.js +108 -1
  30. package/dist/internal/workspace.d.ts +2 -3
  31. package/dist/internal/workspace.js +2 -2
  32. package/dist/{lifecycle-IReZfi0b.js → lifecycle-B0ucHUum.js} +8 -8
  33. package/dist/loader.d.ts +1 -1
  34. package/dist/loader.js +2 -2
  35. package/dist/{mcp-resources-DeJnbOaw.js → mcp-resources-BDL0llKW.js} +2 -2
  36. package/dist/{memory-BlSRrBH1.js → memory-BCZl_ZsJ.js} +26 -4
  37. package/dist/{metadata-target-CaGLY4ay.js → metadata-target-mlHAv1p4.js} +59 -24
  38. package/dist/{object-CAK6UYR5.js → object-DNOrQSl5.js} +5 -1
  39. package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BALFFdKj.d.ts} +1 -0
  40. package/dist/{operations-BIaK_uYG.js → operations-D3mZArDi.js} +8 -7
  41. package/dist/operations.d.ts +2 -2
  42. package/dist/operations.js +1341 -2
  43. package/dist/{path-Bb9OIc_F.js → path-DYHw5KNk.js} +11 -3
  44. package/dist/plugins-BYxsPDBH.d.ts +12 -0
  45. package/dist/{provider-CN14ewvx.js → provider-DZY1cLP5.js} +281 -87
  46. package/dist/providers/github/store.d.ts +1 -1
  47. package/dist/providers/github/store.js +1994 -1
  48. package/dist/{registry-BbUg9vJB.js → registry-OonxXCbd.js} +3 -3
  49. package/dist/{registry-B0g19sdy.d.ts → registry-h1-cT-cE.d.ts} +1 -1
  50. package/dist/{registry-s2Ob9PeX.d.ts → registry-hnARUKNF.d.ts} +2 -2
  51. package/dist/replacement-CVZVsflC.js +76 -0
  52. package/dist/{request-scope-CXCI_wCb.js → request-scope-jH4H0Sbm.js} +3 -1
  53. package/dist/{rule-keys-BLEbi1h5.js → rule-keys-xMpiTLq1.js} +1 -1
  54. package/dist/{rules-BPDXypZV.js → rules-DYQCKYdt.js} +4 -4
  55. package/dist/runtime/assets.d.ts +1 -1
  56. package/dist/runtime/assets.js +4 -4
  57. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  58. package/dist/runtime/empty-registry.d.ts +2 -2
  59. package/dist/runtime/registry.d.ts +1 -1
  60. package/dist/runtime/request.js +1 -1
  61. package/dist/runtime/state.d.ts +17 -6
  62. package/dist/runtime/state.js +7 -7
  63. package/dist/runtime/workspace.d.ts +1 -1
  64. package/dist/runtime/workspace.js +1 -1
  65. package/dist/runtime.d.ts +8 -8
  66. package/dist/runtime.js +39 -24
  67. package/dist/{search-C_nVorq7.js → search-CG6UNOtn.js} +1 -1
  68. package/dist/server.d.ts +2 -2
  69. package/dist/server.js +301 -1
  70. package/dist/{shared-C20Wh1mp.js → shared-DCAyMX8U.js} +68 -21
  71. package/dist/source-metadata.d.ts +2 -2
  72. package/dist/source-metadata.js +3 -3
  73. package/dist/{sync-BBfR4g5y.js → sync-DkpTCr9u.js} +5 -5
  74. package/dist/test.d.ts +1 -1
  75. package/dist/test.js +1 -1
  76. package/dist/{types-Bel5IDmF.d.ts → types-BnSUug2v.d.ts} +13 -1
  77. package/dist/{use-CpphIBof.d.ts → use-CJ5rdIrW.d.ts} +1 -1
  78. package/dist/{use-D0DyTMxM.js → use-hLouCwGz.js} +15 -51
  79. package/dist/{use-tools-CAK10LTc.d.ts → use-tools-DFVqZwgc.d.ts} +2 -2
  80. package/dist/{use-tools-CHduR5k6.js → use-tools-NXEQt099.js} +4 -4
  81. package/dist/{utils-DXP9xfXo.js → utils-Bv1NBg8r.js} +5 -5
  82. package/dist/vite.d.ts +2 -2
  83. package/dist/vite.js +517 -121
  84. package/dist/{workspace-BOuxrZrP.d.ts → workspace-B6QreLJd.d.ts} +1 -1
  85. package/dist/{workspace-CLuPkyZR.js → workspace-Cz-5Ne1c.js} +340 -104
  86. package/dist/workspace-inspection-scanner-BlJ8bCAB.js +140 -0
  87. package/package.json +12 -12
  88. package/dist/errors-CnFDXxeJ.d.ts +0 -4
  89. package/dist/hosted-8BTKAtMX.js +0 -883
  90. package/dist/hosted-vercel-blob-B6kygYqn.js +0 -408
  91. package/dist/operations-DS1C4uXd.js +0 -1308
  92. package/dist/path-CuYE8-X6.js +0 -57
  93. package/dist/plugins-CLc32jvL.d.ts +0 -8
  94. package/dist/server-aa1a4rkV.js +0 -301
  95. package/dist/state-BdDfBtOR.d.ts +0 -17
  96. package/dist/store-cx3OqNTi.js +0 -1971
@@ -1,1308 +0,0 @@
1
- import { t as workspaceCommitRequestBytes } from "./results-z-HpV9EP.js";
2
- import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
3
- import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
4
- import { basename, dirname, join, parse, resolve } from "node:path";
5
- import { mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
6
- import "node:fs/promises";
7
- import * as v from "valibot";
8
- import { tmpdir } from "node:os";
9
- import { fileURLToPath, pathToFileURL } from "node:url";
10
- import { createBirpc } from "birpc";
11
- import { toJsonSchema } from "@valibot/to-json-schema";
12
- // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
13
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
14
- function normalizeWindowsPath(input = "") {
15
- if (!input) return input;
16
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
17
- }
18
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
19
- const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
20
- const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
21
- function cwd() {
22
- if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
23
- return "/";
24
- }
25
- const resolve$1 = function(...arguments_) {
26
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
27
- let resolvedPath = "";
28
- let resolvedAbsolute = false;
29
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
30
- const path = index >= 0 ? arguments_[index] : cwd();
31
- if (!path || path.length === 0) continue;
32
- resolvedPath = `${path}/${resolvedPath}`;
33
- resolvedAbsolute = isAbsolute$1(path);
34
- }
35
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
36
- if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) return `/${resolvedPath}`;
37
- return resolvedPath.length > 0 ? resolvedPath : ".";
38
- };
39
- function normalizeString(path, allowAboveRoot) {
40
- let res = "";
41
- let lastSegmentLength = 0;
42
- let lastSlash = -1;
43
- let dots = 0;
44
- let char = null;
45
- for (let index = 0; index <= path.length; ++index) {
46
- if (index < path.length) char = path[index];
47
- else if (char === "/") break;
48
- else char = "/";
49
- if (char === "/") {
50
- if (lastSlash === index - 1 || dots === 1);
51
- else if (dots === 2) {
52
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
53
- if (res.length > 2) {
54
- const lastSlashIndex = res.lastIndexOf("/");
55
- if (lastSlashIndex === -1) {
56
- res = "";
57
- lastSegmentLength = 0;
58
- } else {
59
- res = res.slice(0, lastSlashIndex);
60
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
61
- }
62
- lastSlash = index;
63
- dots = 0;
64
- continue;
65
- } else if (res.length > 0) {
66
- res = "";
67
- lastSegmentLength = 0;
68
- lastSlash = index;
69
- dots = 0;
70
- continue;
71
- }
72
- }
73
- if (allowAboveRoot) {
74
- res += res.length > 0 ? "/.." : "..";
75
- lastSegmentLength = 2;
76
- }
77
- } else {
78
- if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
79
- else res = path.slice(lastSlash + 1, index);
80
- lastSegmentLength = index - lastSlash - 1;
81
- }
82
- lastSlash = index;
83
- dots = 0;
84
- } else if (char === "." && dots !== -1) ++dots;
85
- else dots = -1;
86
- }
87
- return res;
88
- }
89
- const isAbsolute$1 = function(p) {
90
- return _IS_ABSOLUTE_RE.test(p);
91
- };
92
- const relative$1 = function(from, to) {
93
- const _from = resolve$1(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
94
- const _to = resolve$1(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
95
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
96
- const _fromCopy = [..._from];
97
- for (const segment of _fromCopy) {
98
- if (_to[0] !== segment) break;
99
- _from.shift();
100
- _to.shift();
101
- }
102
- return [..._from.map(() => ".."), ..._to].join("/");
103
- };
104
- const dirname$1 = function(p) {
105
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
106
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
107
- return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
108
- };
109
- // ../internal/src/inspect.ts
110
- function relativeDefinitionFile(projectRoot, file) {
111
- return relative$1(projectRoot, file).replaceAll("\\", "/");
112
- }
113
- const redactedInspectionValue = "[redacted]";
114
- const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
115
- const secretValuePattern = /^(?:[a-z][a-z0-9+.-]*:\/\/[^/\s?#]*@|bearer\s)/i;
116
- /** Whether an inspection field names a credential, regardless of its value. */
117
- function isSecretInspectionKey(key) {
118
- return secretKeyPattern.test(key);
119
- }
120
- const embeddedUrlCredentialPattern = /\b([a-z][a-z0-9+.-]*:\/\/)[^/\s?#]*@/gi;
121
- const embeddedCookiePattern = /\b([\w-]*cookie[\w-]*["']?\s*[:=]\s*)(?:"(?:\\[^\r\n]|[^"\\\r\n])*"(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|'(?:\\[^\r\n]|[^'\\\r\n])*'(?:\s*;\s*[\w.-]+\s*=[^;\r\n]*)*|[^\r\n]+?(?=\s*(?:;\s*[^;=\r\n/]+\s*(?:\r?\n|$)|&|\r?\n|$)))/gi;
122
- const embeddedBearerPattern = /\bbearer\s+[^\s,;]+/gi;
123
- const embeddedAuthorizationPattern = new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
124
- const embeddedSecretAssignmentPattern = new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
125
- /**
126
- * Removes credentials inside free text, for example an error message. URL credentials, bearer tokens, and
127
- * `name=value` pairs with a secret name are replaced with `[redacted]`.
128
- */
129
- function redactInspectionText(value) {
130
- return value.replace(embeddedUrlCredentialPattern, `$1${redactedInspectionValue}@`).replace(embeddedAuthorizationPattern, `$1${redactedInspectionValue}`).replace(embeddedCookiePattern, `$1${redactedInspectionValue}`).replace(embeddedBearerPattern, `Bearer ${redactedInspectionValue}`).replace(embeddedSecretAssignmentPattern, `$1${redactedInspectionValue}`);
131
- }
132
- /**
133
- * Removes values that can carry credentials before inspection output leaves the process.
134
- * Keys that name secrets, plaintext Worker `vars`, and URLs with embedded credentials are redacted.
135
- */
136
- function redactInspectionValue(value, key) {
137
- const seen = /* @__PURE__ */ new WeakSet();
138
- let remaining = 1e3;
139
- function visit(entry, entryKey, depth = 0) {
140
- if (entryKey && isSecretInspectionKey(entryKey)) return redactedInspectionValue;
141
- if (--remaining < 0 || depth > 10) return "[truncated]";
142
- if (typeof entry === "string") {
143
- const text = entry.slice(0, 1e4);
144
- return secretValuePattern.test(text) ? redactedInspectionValue : redactInspectionText(text);
145
- }
146
- if (typeof entry === "bigint") return entry.toString();
147
- if (typeof entry === "number") return Number.isFinite(entry) ? entry : String(entry);
148
- if (entry === null || typeof entry === "boolean") return entry;
149
- if (typeof entry !== "object") return entry === void 0 ? null : "[unsupported]";
150
- if (seen.has(entry)) return "[circular]";
151
- seen.add(entry);
152
- try {
153
- let dateTime;
154
- try {
155
- dateTime = Date.prototype.getTime.call(entry);
156
- } catch {}
157
- if (dateTime !== void 0) return Number.isNaN(dateTime) ? "Invalid Date" : Date.prototype.toISOString.call(entry);
158
- if (Array.isArray(entry)) return entry.slice(0, 100).map((item) => visit(item, void 0, depth + 1));
159
- let setValues;
160
- try {
161
- setValues = [...Set.prototype.values.call(entry)];
162
- } catch {}
163
- if (setValues) return setValues.slice(0, 100).map((item) => visit(item, void 0, depth + 1));
164
- let mapEntries;
165
- try {
166
- mapEntries = [...Map.prototype.entries.call(entry)];
167
- } catch {}
168
- const entries = mapEntries ? mapEntries.map(([name, item]) => [String(name), item]) : Object.entries(entry);
169
- return Object.fromEntries(entries.slice(0, 100).map(([name, item]) => [name, name === "vars" && item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).slice(0, 100).map((variable) => [variable, redactedInspectionValue])) : visit(item, name, depth + 1)]));
170
- } finally {
171
- seen.delete(entry);
172
- }
173
- }
174
- return visit(value, key);
175
- }
176
- function parseViteHubDevTimeout(value, error) {
177
- if (!/^\d+$/.test(value)) throw error("--timeout must be an integer from 1 to 2147483647 milliseconds.");
178
- const timeout = Number(value);
179
- if (timeout > 2147483647) throw error("--timeout must be at most 2147483647 milliseconds.");
180
- if (!Number.isInteger(timeout) || timeout < 1) throw error("--timeout must be an integer from 1 to 2147483647 milliseconds.");
181
- return timeout;
182
- }
183
- /**
184
- * Reads one dev target option at `args[index]`: `--url <url>`, `--url=<url>`,
185
- * `--timeout <ms>` or `--timeout=<ms>`. `--url` is always the app, and `--server` fails with the fix.
186
- *
187
- * Returns the number of extra arguments that the option used (`0` or `1`), or
188
- * `undefined` when `args[index]` is not a dev target option.
189
- */
190
- function readViteHubDevTargetOption(args, index, target, errors) {
191
- const arg = args[index];
192
- if (arg === void 0) return;
193
- const readValue = () => {
194
- const value = args[index + 1];
195
- if (!value || value.startsWith("-")) throw errors.missingValue(`Missing value for ${arg}.`);
196
- return value;
197
- };
198
- if (arg === "--server" || arg.startsWith("--server=")) throw errors.unknownOption("--server is now --url. Pass --url with the app URL, such as --url http://localhost:3000.");
199
- if (arg === "--url") {
200
- target.url = readValue();
201
- return 1;
202
- }
203
- if (arg.startsWith("--url=")) {
204
- const value = arg.slice(6);
205
- if (!value) throw errors.missingValue(`Missing value for ${arg}.`);
206
- target.url = value;
207
- return 0;
208
- }
209
- if (arg === "--timeout") {
210
- target.timeout = parseViteHubDevTimeout(readValue(), errors.invalidTimeout);
211
- return 1;
212
- }
213
- if (arg.startsWith("--timeout=")) {
214
- target.timeout = parseViteHubDevTimeout(arg.slice(10), errors.invalidInlineTimeout);
215
- return 0;
216
- }
217
- }
218
- /**
219
- * Resolves a dev endpoint route against the dev server URL. Throws when the URL is not valid.
220
- */
221
- function viteHubDevEndpointUrl(serverUrl, route) {
222
- return new URL(route, serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`).href;
223
- }
224
- /**
225
- * Calls a guarded dev endpoint. Adds the endpoint guard header to `init.headers`.
226
- */
227
- async function fetchViteHubDevEndpoint(fetchImpl, url, endpoint, init = {}) {
228
- const headers = {
229
- ...Object.fromEntries(new Headers(init.headers)),
230
- [endpoint.header]: endpoint.headerValue
231
- };
232
- return await fetchImpl(url, {
233
- ...init,
234
- redirect: "manual",
235
- headers
236
- });
237
- }
238
- function redactInspectionUrlPart(value) {
239
- const separator = value[0];
240
- if (separator !== "?" && separator !== "#") return redactInspectionText(value);
241
- return `${separator}${redactInspectionText(value.slice(1).split("&").map((pair) => {
242
- const equals = pair.indexOf("=");
243
- if (equals < 0) return pair;
244
- const rawKey = pair.slice(0, equals);
245
- try {
246
- const entry = new URLSearchParams(pair).entries().next().value;
247
- if (entry && redactInspectionValue(entry[1], entry[0]) !== entry[1]) return `${rawKey}=[redacted]`;
248
- } catch {}
249
- return pair;
250
- }).join("&"))}`;
251
- }
252
- function devServerDisplayUrl(value) {
253
- try {
254
- const url = new URL(value);
255
- const query = redactInspectionUrlPart(url.search);
256
- const fragment = redactInspectionUrlPart(url.hash);
257
- const hasSecretQuery = query !== url.search;
258
- const hasSecretFragment = fragment !== url.hash;
259
- if (!url.username && !url.password && !hasSecretQuery && !hasSecretFragment) return redactInspectionText(url.origin === "null" ? value.replace(/^[\s\S]+@/, "[redacted]@") : value);
260
- if (url.username) url.username = "[redacted]";
261
- if (url.password) url.password = "[redacted]";
262
- const display = url.href.replace(/%5Bredacted%5D/g, "[redacted]");
263
- const queryStart = display.indexOf("?");
264
- const fragmentStart = display.indexOf("#");
265
- const pathEnd = [queryStart, fragmentStart].filter((index) => index >= 0).sort((a, b) => a - b)[0] ?? display.length;
266
- const path = display.slice(0, pathEnd);
267
- return `${redactInspectionText(url.origin === "null" ? path.replace(/^[\s\S]+@/, "[redacted]@") : path)}${queryStart >= 0 ? query : ""}${fragmentStart >= 0 ? fragment : ""}`;
268
- } catch {
269
- const redacted = value.replace(/\/\/[\s\S]+@/g, "//[redacted]@").replace(/^[\s\S]+@/, "[redacted]@");
270
- const queryStart = redacted.indexOf("?");
271
- const fragmentStart = redacted.indexOf("#");
272
- const pathEnd = [queryStart, fragmentStart].filter((index) => index >= 0).sort((a, b) => a - b)[0] ?? redacted.length;
273
- const path = redacted.slice(0, pathEnd);
274
- const queryEnd = fragmentStart >= 0 && fragmentStart > queryStart ? fragmentStart : void 0;
275
- const query = queryStart >= 0 ? redactInspectionUrlPart(redacted.slice(queryStart, queryEnd)) : "";
276
- const fragment = fragmentStart >= 0 ? redactInspectionUrlPart(redacted.slice(fragmentStart)) : "";
277
- return `${redactInspectionText(path)}${query}${fragment}`;
278
- }
279
- }
280
- /**
281
- * Finds a Compatible Vite Development Server through the discovery `GET` of a guarded dev endpoint.
282
- *
283
- * Writes the reason to `stderr` and returns `undefined` when the URL is not
284
- * valid, the server does not answer, or the server root does not match.
285
- */
286
- async function discoverViteHubDevServer(options) {
287
- let url;
288
- try {
289
- url = viteHubDevEndpointUrl(options.serverUrl, options.endpoint.route);
290
- } catch {
291
- options.stderr.write(`Invalid Vite Development Server URL: ${devServerDisplayUrl(options.serverUrl)}\n`);
292
- return;
293
- }
294
- let response;
295
- try {
296
- response = await fetchViteHubDevEndpoint(options.fetch, url, options.endpoint, {
297
- headers: { accept: "application/json" },
298
- ...options.signal ? { signal: options.signal } : {}
299
- });
300
- } catch {
301
- options.stderr.write(`No Compatible Vite Development Server found at ${devServerDisplayUrl(options.serverUrl)}.\n`);
302
- return;
303
- }
304
- if (!response.ok) {
305
- const message = response.status >= 500 ? redactInspectionText((await response.text().catch(() => "")).trim()) : "";
306
- options.stderr.write(message ? `The Vite Development Server at ${devServerDisplayUrl(options.serverUrl)} failed with HTTP ${response.status}: ${message}\n` : `No Compatible Vite Development Server found at ${devServerDisplayUrl(options.serverUrl)}.\n`);
307
- return;
308
- }
309
- const payload = await response.json().catch(() => ({}));
310
- const discovery = options.parseDiscovery ? options.parseDiscovery(payload) : isRecord(payload) ? payload : {};
311
- if (options.signal?.aborted) {
312
- options.stderr.write(`No Compatible Vite Development Server found at ${devServerDisplayUrl(options.serverUrl)}.\n`);
313
- return;
314
- }
315
- const isCompatibleRoot = options.isCompatibleRoot ?? ((rootDir, serverRoot) => serverRoot === rootDir);
316
- if (discovery.root !== void 0 && typeof discovery.root !== "string") {
317
- options.stderr.write("Invalid Vite Development Server discovery root.\n");
318
- return;
319
- }
320
- if (typeof discovery.root === "string" && !isCompatibleRoot(options.rootDir, discovery.root)) {
321
- options.stderr.write(`Compatible Vite Development Server root mismatch: ${devServerDisplayUrl(discovery.root)}\n`);
322
- return;
323
- }
324
- return {
325
- discovery,
326
- url
327
- };
328
- }
329
- /** File in the project root where the running dev server tells commands where it listens. */
330
- const viteHubDevServerFile = ".vitehub/dev-server.json";
331
- function writeViteHubDevServerFile(root, info) {
332
- const file = join(root, viteHubDevServerFile);
333
- mkdirSync(dirname(file), { recursive: true });
334
- writeFileSync(file, `${JSON.stringify(info)}\n`);
335
- }
336
- function removeViteHubDevServerFile(root) {
337
- rmSync(join(root, viteHubDevServerFile), { force: true });
338
- }
339
- /** The dev server that runs in `root`, or undefined when there is no file or it is not valid. */
340
- function readViteHubDevServerFile(root) {
341
- try {
342
- const value = JSON.parse(readFileSync(join(root, viteHubDevServerFile), "utf8"));
343
- const url = isRecord(value) ? value.url : void 0;
344
- const served = isRecord(value) ? value.root : void 0;
345
- return typeof url === "string" && url && typeof served === "string" && served ? {
346
- root: served,
347
- url
348
- } : void 0;
349
- } catch {
350
- return;
351
- }
352
- }
353
- /**
354
- * Where a command finds the dev server of its project: the file that the server wrote in a project root, else
355
- * `VITEHUB_DEV_SERVER_URL`. It never guesses a port, since another project may use it.
356
- */
357
- function findViteHubDevServerUrl(roots, env) {
358
- for (const root of roots) {
359
- const file = readViteHubDevServerFile(root);
360
- if (file && roots.some((candidate) => candidate.replace(/\/+$/, "") === file.root.replace(/\/+$/, ""))) return file.url;
361
- }
362
- return env["VITEHUB_DEV_SERVER_URL"] || void 0;
363
- }
364
- /**
365
- * The dev server of the project, as {@link findViteHubDevServerUrl} finds it. Without one, it throws
366
- * `INTERNAL_DEV_SERVER_NOT_FOUND` for `command`, such as `agent dev`, instead of guessing a port.
367
- */
368
- function requireViteHubDevServerUrl(roots, env, command) {
369
- const url = findViteHubDevServerUrl(roots, env);
370
- if (!url) throw internalErrorDiagnostics.INTERNAL_DEV_SERVER_NOT_FOUND({ command });
371
- return url;
372
- }
373
- // ../internal/src/build/vite.ts
374
- const generatedViteHubFilesPattern = "**/.vitehub/**";
375
- const projectRootDirectoryMarkers = [
376
- ["server", "agents"],
377
- ["server", "channels"],
378
- ["server", "connections"],
379
- ["server", "browsers"],
380
- ["server", "emails"],
381
- ["server", "schedules"],
382
- ["server", "workspaces"]
383
- ];
384
- const projectRootFileMarkers = [
385
- ["package.json"],
386
- ["nuxt.config.ts"],
387
- ["nuxt.config.mts"],
388
- ["nuxt.config.js"],
389
- ["nuxt.config.mjs"]
390
- ];
391
- const VITEHUB_ENV_PUBLIC_ID = "#vitehub/env/public";
392
- const VITEHUB_ENV_SERVER_ID = "#vitehub/env/server";
393
- const VITEHUB_ENV_DESCRIPTION_ID = "#vitehub/env/description";
394
- function createNoExternalAddition(...packageNames) {
395
- return (current) => {
396
- if (current === true) return;
397
- const values = Array.isArray(current) ? current : [current];
398
- const missing = packageNames.filter((packageName) => !values.includes(packageName));
399
- return missing.length ? missing : void 0;
400
- };
401
- }
402
- function isServerEnvironment(name, config) {
403
- return name === "ssr" || config.consumer === "server";
404
- }
405
- /**
406
- * Use one app's effective Nitro runner for both environment configuration and generated imports.
407
- * `configureEnvironment` reads the runner after Nitro's `build:before` hooks and saves the decision for `load`.
408
- */
409
- function createNativePackageLoading(ssrPackageEntries = []) {
410
- let nitro;
411
- let native = false;
412
- let nativeSsr = false;
413
- const ssrDistDirs = ssrPackageEntries.map((entry) => dirname(fileURLToPath(entry)).replace(/\\/g, "/") + "/");
414
- return {
415
- nitro: { setup(instance) {
416
- nitro = instance;
417
- } },
418
- configureEnvironment(name, env, options) {
419
- if (name === "ssr") nativeSsr = env.command === "serve" && !env.isSsrTargetWebworker && !options?.resolve?.conditions?.some((condition) => condition === "worker" || condition === "workerd" || condition === "browser" || condition === "edge-light" || condition === "deno");
420
- if (name !== "nitro") return false;
421
- const runner = nitro?.options.devServer?.runner || process.env.NITRO_DEV_RUNNER || "node-worker";
422
- native = env.command === "serve" && (runner === "node-worker" || runner === "node-process");
423
- return native;
424
- },
425
- load(id, environmentName) {
426
- if (environmentName === "nitro" && native) return loadNativePackageModule(id);
427
- if (environmentName === "ssr" && nativeSsr && ssrDistDirs.length) {
428
- const file = id.startsWith("file:") ? fileURLToPath(id) : id;
429
- const path = file.replace(/\\/g, "/");
430
- if (/^vitehub-grants(?:-[\w-]+)?\.js$/.test(basename(path)) && ssrDistDirs.some((dir) => dirname(path) + "/" === dir)) return reexportNativeModule(file);
431
- }
432
- }
433
- };
434
- }
435
- const nativePackageDistFile = /\/node_modules\/@vite-hub\/(?:agent|connections|runtime|workspace)\/dist\/.+\.js$/;
436
- /**
437
- * Generated code imports the runtime files of its owner by path. Vite gives Node only bare package names, so in the
438
- * Nitro environment of `vite dev` it would inline a second copy of a package that Node already loaded, with its own
439
- * registries. This returns a module that lets Node load the file instead, so the app and the generated code share one
440
- * instance. Use it as the `load` hook result for the file. It returns nothing for other files and environments.
441
- */
442
- function loadNativePackageModule(id) {
443
- const file = id.startsWith("file:") ? fileURLToPath(id) : id;
444
- if (!nativePackageDistFile.test(file.replace(/\\/g, "/"))) return;
445
- return reexportNativeModule(file);
446
- }
447
- function reexportNativeModule(file) {
448
- const url = JSON.stringify(pathToFileURL(realpathSync(file)).href);
449
- const hasDefault = /^export\s+default\b|^export\s*\{[^}]*\bdefault\s*[,}]/m.test(readFileSync(file, "utf8"));
450
- const native = JSON.stringify(`data:text/javascript,${encodeURIComponent(`export * from ${url}${hasDefault ? `\nexport { default } from ${url}` : ""}`)}`);
451
- return `export * from ${native}\n${hasDefault ? `export { default } from ${native}\n` : ""}`;
452
- }
453
- /**
454
- * Server directories that ViteHub scans for Definitions. The first entry is the application.
455
- * Later entries are Nuxt layers in Nuxt priority order.
456
- */
457
- const VITEHUB_SERVER_DIRS = "__vitehubServerDirs";
458
- /** Reports a Vite config hook call for a production build. `nuxt prepare` is not a build: it only writes types. */
459
- function isProductionBuild(config, environment) {
460
- return environment?.command === "build" && Reflect.get(config, "__vitehubPrepare") !== true;
461
- }
462
- function shouldSkipViteProviderBuild(command) {
463
- return command === "serve";
464
- }
465
- function generatedViteHubWatchIgnoredAddition(ignored) {
466
- return (Array.isArray(ignored) ? ignored : [ignored]).includes(generatedViteHubFilesPattern) ? void 0 : [generatedViteHubFilesPattern];
467
- }
468
- function resolveViteHubProjectRoot(root, options = {}) {
469
- const resolvedRoot = resolve(root);
470
- const temporaryRoot = resolve(tmpdir());
471
- const sharedTemporaryRoot = dirname(temporaryRoot) === parse(temporaryRoot).root ? temporaryRoot : void 0;
472
- if (options.projectRoot) return resolve(resolvedRoot, options.projectRoot);
473
- if (basename(resolvedRoot) === "app") {
474
- const parent = dirname(resolvedRoot);
475
- if (parent !== sharedTemporaryRoot && (hasProjectRootDirectoryMarker(parent) || hasProjectRootFileMarker(parent, [
476
- "nuxt.config.ts",
477
- "nuxt.config.mts",
478
- "nuxt.config.js",
479
- "nuxt.config.mjs"
480
- ]))) return parent;
481
- }
482
- let current = resolvedRoot;
483
- while (true) {
484
- if (current === sharedTemporaryRoot && resolvedRoot !== current) return resolvedRoot;
485
- if (hasProjectRootMarker(current)) return current;
486
- const parent = dirname(current);
487
- if (parent === current) return resolvedRoot;
488
- current = parent;
489
- }
490
- }
491
- function hasProjectRootDirectoryMarker(root) {
492
- for (const marker of projectRootDirectoryMarkers) try {
493
- if (statSync(resolve(root, ...marker)).isDirectory()) return true;
494
- } catch (error) {
495
- if (!isMissingProjectMarker(error)) throw error;
496
- }
497
- return false;
498
- }
499
- function hasProjectRootMarker(root) {
500
- if (hasProjectRootDirectoryMarker(root)) return true;
501
- return hasProjectRootFileMarker(root, projectRootFileMarkers.flat());
502
- }
503
- function hasProjectRootFileMarker(root, markers) {
504
- for (const marker of markers) {
505
- const path = Array.isArray(marker) ? marker : [marker];
506
- try {
507
- if (statSync(resolve(root, ...path)).isFile()) return true;
508
- } catch (error) {
509
- if (!isMissingProjectMarker(error)) throw error;
510
- }
511
- }
512
- return false;
513
- }
514
- function isMissingProjectMarker(error) {
515
- const code = error.code;
516
- return code === "ENOENT" || code === "ENOTDIR";
517
- }
518
- function viteHubEnvPublicModulePath(root) {
519
- return resolve(root, ".vitehub", "env", "public.mjs");
520
- }
521
- function viteHubEnvServerModulePath(root) {
522
- return resolve(root, ".vitehub", "env", "server.mjs");
523
- }
524
- function viteHubEnvDescriptionModulePath(root) {
525
- return resolve(root, ".vitehub", "env", "description.mjs");
526
- }
527
- function createViteHubEnvImportAliases(root) {
528
- return {
529
- [VITEHUB_ENV_PUBLIC_ID]: viteHubEnvPublicModulePath(root),
530
- [VITEHUB_ENV_SERVER_ID]: viteHubEnvServerModulePath(root),
531
- [VITEHUB_ENV_DESCRIPTION_ID]: viteHubEnvDescriptionModulePath(root)
532
- };
533
- }
534
- const publishedDevServers = /* @__PURE__ */ new WeakSet();
535
- /**
536
- * Tell `vitehub` commands where this dev server listens: `.vitehub/dev-server.json` in the project root, removed when
537
- * the server closes. A host that runs Vite in middleware mode has no listening server and writes nothing.
538
- */
539
- function publishViteHubDevServer(server) {
540
- const http = server.httpServer;
541
- if (!http || server.config.server.middlewareMode || publishedDevServers.has(http)) return;
542
- publishedDevServers.add(http);
543
- const root = resolve(server.config.root);
544
- let publishedUrl;
545
- const write = () => {
546
- const address = http.address();
547
- if (!address || typeof address === "string") return;
548
- const host = address.address === "::" || address.address === "0.0.0.0" ? "localhost" : address.family === "IPv6" ? `[${address.address}]` : address.address;
549
- const url = server.resolvedUrls?.local[0] ?? `${server.config.server.https ? "https" : "http"}://${host}:${address.port}${server.config.base}`;
550
- try {
551
- writeViteHubDevServerFile(root, {
552
- root,
553
- url
554
- });
555
- publishedUrl = url;
556
- } catch {}
557
- };
558
- const remove = () => {
559
- try {
560
- if (publishedUrl && readViteHubDevServerFile(root)?.url === publishedUrl) removeViteHubDevServerFile(root);
561
- } catch {}
562
- };
563
- if (http.listening) write();
564
- else http.once("listening", write);
565
- http.once("close", remove);
566
- }
567
- // ../internal/src/operation-rpc.ts
568
- /** Path of the operation RPC under the app. Dev servers and deployed apps serve it the same way, one birpc call per POST. */
569
- const operationRpcPath = "/_vitehub/rpc";
570
- function text(value) {
571
- return String(value) === value && value ? value : void 0;
572
- }
573
- /** Read an untrusted failure body. It keeps only the diagnostic fields, so a stack never passes through. */
574
- function readOperationRpcError(value) {
575
- if (!isRecord(value)) return void 0;
576
- const code = text(value.code);
577
- const message = text(value.message);
578
- const status = value.status;
579
- if (!code || !message || !Number.isInteger(status)) return void 0;
580
- const failure = {
581
- code,
582
- message,
583
- status: Number(status)
584
- };
585
- if (text(value.fix)) failure.fix = text(value.fix);
586
- if (text(value.docs)) failure.docs = text(value.docs);
587
- if (isRecord(value.details)) failure.details = value.details;
588
- return failure;
589
- }
590
- /** Read one response message. */
591
- function readOperationRpcReply(value) {
592
- if (!isRecord(value) || value.t !== "s") return void 0;
593
- const id = text(value.i);
594
- if (Object.hasOwn(value, "e")) {
595
- const error = readOperationRpcError(value.e);
596
- return error ? {
597
- t: "s",
598
- ...id ? { i: id } : {},
599
- e: error
600
- } : void 0;
601
- }
602
- return id ? {
603
- t: "s",
604
- i: id,
605
- r: value.r
606
- } : void 0;
607
- }
608
- /**
609
- * Call one operation with birpc over a request and answer transport, such as one HTTP POST per call. `send` posts the
610
- * JSON message and returns the parsed answer; its own failures, such as a network error or an abort, reject.
611
- */
612
- async function callOperationRpc(name, input, send) {
613
- let receive;
614
- let answer;
615
- const notReply = /* @__PURE__ */ new Error("The answer is not a reply to the operation call.");
616
- const rpc = createBirpc({}, {
617
- on: (listener) => {
618
- receive = listener;
619
- },
620
- post: async (message) => {
621
- answer = await send(JSON.stringify(message));
622
- const reply = readOperationRpcReply(answer.body);
623
- if (!reply || reply.i !== void 0 && reply.i !== message.i) throw notReply;
624
- await receive({
625
- ...reply,
626
- i: message.i
627
- });
628
- },
629
- proxify: false,
630
- timeout: -1
631
- });
632
- try {
633
- return {
634
- ok: true,
635
- value: await rpc.$call(name, ...input === void 0 ? [] : [input]),
636
- answer
637
- };
638
- } catch (error) {
639
- if (!answer) throw error;
640
- if (error === notReply) return {
641
- ok: false,
642
- error: void 0,
643
- answer
644
- };
645
- return {
646
- ok: false,
647
- error: readOperationRpcError(error),
648
- answer
649
- };
650
- }
651
- }
652
- // ../internal/src/console-signature.ts
653
- /**
654
- * Signed requests to the Console endpoint of an app, `POST /_vitehub/rpc`. Each caller, such as one Console link or one
655
- * CI job, has an Ed25519 key pair. The app keeps only the public keys, in `VITEHUB_CONSOLE_KEY_<NAME>`, so a copy of
656
- * its env cannot sign a request. The module uses only Web Crypto, so it runs in Node, Workers, Deno, and browsers.
657
- *
658
- * The signature covers this text, one field per line:
659
- *
660
- * ```txt
661
- * vitehub-signature-v1
662
- * POST
663
- * /_vitehub/rpc
664
- * https://app.example.com
665
- * 1794400000
666
- * CONSOLE_3F9A12BC
667
- * <SHA-256 of the body bytes, base64url>
668
- * <the x-vitehub-caller header>
669
- * ```
670
- */
671
- /** The signature header: `key=<NAME>, t=<seconds>, origin=<app origin>, body=<SHA-256>, v1=<signature>`. */
672
- const consoleSignatureHeader = "x-vitehub-signature";
673
- /** Who calls, as base64url JSON. The signature covers it. See {@link ConsoleCaller}. */
674
- const consoleCallerHeader = "x-vitehub-caller";
675
- /** The first line of the signed text. A new format gets a new tag. */
676
- const consoleSignatureVersion = "vitehub-signature-v1";
677
- /** The CLI reads its private key from `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>`. `<NAME>` is the key name that it signs with. */
678
- const consolePrivateKeyPrefix = "VITEHUB_CONSOLE_PRIVATE_KEY_";
679
- const keyNamePattern = /^[A-Z0-9_]{1,64}$/;
680
- const encoder = new TextEncoder();
681
- new TextDecoder();
682
- const ed25519 = { name: "Ed25519" };
683
- const pkcs8Prefix = Uint8Array.of(48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32);
684
- function base64url(bytes) {
685
- let binary = "";
686
- for (const byte of bytes) binary += String.fromCharCode(byte);
687
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
688
- }
689
- /** The bytes of a base64url value, or `undefined` when it is not canonical base64url without padding. */
690
- function fromBase64url(value) {
691
- if (!/^[\w-]*$/.test(value) || value.length % 4 === 1) return void 0;
692
- const bytes = Uint8Array.from(atob(value.replace(/-/g, "+").replace(/_/g, "/")), (character) => character.charCodeAt(0));
693
- return base64url(bytes) === value ? bytes : void 0;
694
- }
695
- function bytesOf(body) {
696
- if (typeof body === "string") return encoder.encode(body);
697
- return body instanceof Uint8Array ? Uint8Array.from(body) : new Uint8Array(body);
698
- }
699
- /** The SHA-256 of the exact body bytes, base64url. A request without a body hashes zero bytes. */
700
- async function consoleBodySha256(body = "") {
701
- return base64url(new Uint8Array(await crypto.subtle.digest("SHA-256", bytesOf(body))));
702
- }
703
- /** The text that the signature covers. Fields are joined with `\n`. */
704
- function consoleSignedText(fields) {
705
- return [
706
- consoleSignatureVersion,
707
- fields.method.toUpperCase(),
708
- fields.target,
709
- fields.origin,
710
- fields.timestamp,
711
- fields.key,
712
- fields.bodySha256,
713
- fields.caller
714
- ].join("\n");
715
- }
716
- /** The path and query of a URL, the part of the request target that the signature covers. */
717
- function requestTarget(url) {
718
- return `${url.pathname}${url.search}`;
719
- }
720
- /** Whether a name can be the `<NAME>` of `VITEHUB_CONSOLE_KEY_<NAME>`: up to 64 of `A-Z`, `0-9`, and `_`. */
721
- function isConsoleKeyName(name) {
722
- return keyNamePattern.test(name);
723
- }
724
- async function importPrivateKey(seed) {
725
- const bytes = fromBase64url(seed.trim());
726
- if (bytes?.length !== 32) throw internalErrorDiagnostics.INTERNAL_CONSOLE_PRIVATE_KEY_INVALID();
727
- const der = new Uint8Array(pkcs8Prefix.length + 32);
728
- der.set(pkcs8Prefix);
729
- der.set(bytes, pkcs8Prefix.length);
730
- return await crypto.subtle.importKey("pkcs8", der, ed25519, false, ["sign"]);
731
- }
732
- /** The `x-vitehub-caller` value of a caller: its JSON as base64url. */
733
- function encodeConsoleCaller(caller) {
734
- return base64url(encoder.encode(JSON.stringify(caller)));
735
- }
736
- /**
737
- * Sign one request. `url` is the full URL that the request goes to, and `body` is the exact body that it sends. Returns
738
- * the two headers to add: `x-vitehub-signature` and `x-vitehub-caller`.
739
- */
740
- async function signConsoleRequest(options) {
741
- if (!isConsoleKeyName(options.key.name)) throw internalErrorDiagnostics.INTERNAL_CONSOLE_KEY_NAME_INVALID({ name: options.key.name });
742
- const url = new URL(options.url);
743
- const timestamp = String(Math.floor((options.now ?? Date.now()) / 1e3));
744
- const bodySha256 = await consoleBodySha256(options.body);
745
- const caller = encodeConsoleCaller(options.caller);
746
- const text = consoleSignedText({
747
- bodySha256,
748
- caller,
749
- key: options.key.name,
750
- method: options.method,
751
- origin: url.origin,
752
- target: requestTarget(url),
753
- timestamp
754
- });
755
- const signature = new Uint8Array(await crypto.subtle.sign(ed25519, await importPrivateKey(options.key.privateKey), encoder.encode(text)));
756
- return {
757
- [consoleCallerHeader]: caller,
758
- [consoleSignatureHeader]: `key=${options.key.name}, t=${timestamp}, origin=${url.origin}, body=${bodySha256}, v1=${base64url(signature)}`
759
- };
760
- }
761
- /**
762
- * The signing key of a CLI from its env: the one `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` variable. Returns `undefined`
763
- * without one. Throws a coded error when there are several, or when the value is not a 32-byte seed.
764
- */
765
- function readConsoleSigningKey(env) {
766
- const variables = Object.keys(env).filter((name) => name.startsWith("VITEHUB_CONSOLE_PRIVATE_KEY_") && env[name]?.trim()).sort();
767
- if (!variables.length) return void 0;
768
- if (variables.length > 1) throw internalErrorDiagnostics.INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLES_MULTIPLE({
769
- prefix: consolePrivateKeyPrefix,
770
- variables: variables.join(", ")
771
- });
772
- const variable = variables[0];
773
- const name = variable.slice(28);
774
- const privateKey = env[variable].trim();
775
- if (!isConsoleKeyName(name) || fromBase64url(privateKey)?.length !== 32) throw internalErrorDiagnostics.INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLE_INVALID({ variable });
776
- return {
777
- name,
778
- privateKey
779
- };
780
- }
781
- // ../internal/src/standard-schema.ts
782
- function readOwn(value, key) {
783
- if (value === null || Object(value) !== value) return;
784
- try {
785
- return Reflect.get(Object(value), key);
786
- } catch {
787
- return;
788
- }
789
- }
790
- /**
791
- * Read a Standard JSON Schema projection without throwing.
792
- *
793
- * Returns `undefined` when the schema has no `~standard.jsonSchema`, when the library cannot represent the type
794
- * (Zod throws for `Date`), or when the projection is not an object. Callers decide how to fall back.
795
- */
796
- function standardJsonSchema(schema, direction, target = "draft-2020-12", libraryOptions) {
797
- const jsonSchema = readOwn(readOwn(schema, "~standard"), "jsonSchema");
798
- const project = readOwn(jsonSchema, direction);
799
- if (typeof project !== "function") return;
800
- try {
801
- const result = project.call(jsonSchema, libraryOptions ? {
802
- target,
803
- libraryOptions
804
- } : { target });
805
- return isRecordOrFunction(result) ? result : void 0;
806
- } catch {
807
- return;
808
- }
809
- }
810
- // ../internal/src/valibot.ts
811
- const valibotTargets = /* @__PURE__ */ new Set([
812
- "draft-07",
813
- "draft-2020-12",
814
- "openapi-3.0"
815
- ]);
816
- function isValibotTarget(value) {
817
- return valibotTargets.has(String(value));
818
- }
819
- /**
820
- * Add Standard JSON Schema conversion to a plain Valibot schema. Valibot schemas validate as Standard Schema but carry
821
- * no JSON Schema, so forms, tools, and model providers would get no shape for them. Other schemas, Valibot schemas that
822
- * already convert, and async Valibot schemas return unchanged. The copy keeps every Valibot property, so validation
823
- * does not change.
824
- *
825
- * `target` fixes the JSON Schema dialect. Without it, each conversion uses the dialect that the caller asks for.
826
- */
827
- function withValibotJsonSchema(schema, options = {}) {
828
- const standard = schema["~standard"];
829
- if (standard.vendor !== "valibot" || Reflect.get(schema, "async") === true) return schema;
830
- if (Object.hasOwn(standard, "jsonSchema") && standard.jsonSchema) return schema;
831
- const convert = (typeMode) => (request) => {
832
- const target = options.target ?? request.target;
833
- if (!isValibotTarget(target)) throw internalErrorDiagnostics.INTERNAL_VALIBOT_JSON_SCHEMA_TARGET_UNSUPPORTED({ target: String(target) });
834
- return toJsonSchema(schema, {
835
- target,
836
- typeMode,
837
- errorMode: "ignore"
838
- });
839
- };
840
- return {
841
- ...schema,
842
- "~standard": {
843
- ...standard,
844
- jsonSchema: {
845
- input: convert("input"),
846
- output: convert("output")
847
- }
848
- }
849
- };
850
- }
851
- // ../internal/src/operation-definition.ts
852
- const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
853
- const kinds = /* @__PURE__ */ new Set([
854
- "read",
855
- "write",
856
- "destructive"
857
- ]);
858
- function invalidDefinition(name, reason) {
859
- return internalErrorDiagnostics.INTERNAL_R0020({ message: `[vitehub] Operation ${JSON.stringify(name)} is invalid: ${reason}` });
860
- }
861
- function checkDefinition(definition) {
862
- if (!isRecordOrFunction(definition)) throw invalidDefinition(void 0, "defineOperation() takes an object.");
863
- const { name } = definition;
864
- if (String(name) !== name || !nameFormat.test(name)) throw invalidDefinition(name, "the name must look like `section.verb`, in lower case.");
865
- if (String(definition.description) !== definition.description || !definition.description) throw invalidDefinition(name, "add a one sentence description.");
866
- const { section } = definition;
867
- if (section !== false && !(section instanceof Function) && !isSectionId(section)) throw invalidDefinition(name, "section must be a Console section id, a function, or false; section ids cannot contain ':'.");
868
- if (definition.scope !== void 0 && (!(definition.scope instanceof Function) || String(section) !== section)) throw invalidDefinition(name, "scope must be a function, and it needs a section id.");
869
- if (!kinds.has(String(definition.kind))) throw invalidDefinition(name, "kind must be \"read\", \"write\", or \"destructive\".");
870
- const input = definition.input;
871
- if (!isRecordOrFunction(input) || !isRecordOrFunction(input["~standard"]) || !(input["~standard"].validate instanceof Function)) throw invalidDefinition(name, "input must be a Standard Schema, such as a valibot object.");
872
- if (!(definition.run instanceof Function)) throw invalidDefinition(name, "run must be a function.");
873
- const { maxRequestBytes } = definition;
874
- if (maxRequestBytes !== void 0 && (!Number.isInteger(maxRequestBytes) || Number(maxRequestBytes) < 65536)) throw invalidDefinition(name, `maxRequestBytes can only raise the limit above ${defaultRequestBytes} bytes (64 KiB).`);
875
- if (definition.readOnlyWhen !== void 0 && !(definition.readOnlyWhen instanceof Function)) throw invalidDefinition(name, "readOnlyWhen must be a function.");
876
- const { mcp } = definition;
877
- if (mcp !== void 0 && mcp !== false && (!isRecordOrFunction(mcp) || mcp.title !== void 0 && (String(mcp.title) !== mcp.title || !mcp.title) || mcp.format !== void 0 && !(mcp.format instanceof Function))) throw invalidDefinition(name, "mcp must be false, or an object with a title string and a format function.");
878
- }
879
- /** The default limit of a call, in bytes. */
880
- const defaultRequestBytes = 65536;
881
- /** Input keys that the generated CLI commands read themselves. */
882
- const reservedOperationFlags = [
883
- "input",
884
- "json",
885
- "timeout",
886
- "url",
887
- "yes"
888
- ];
889
- /**
890
- * Define one operation. The Console, the CLI, MCP, and agent tools call the same definition. Contribute it with
891
- * `vitehub: { operations: [{ module, export }] }` on a Vite plugin.
892
- */
893
- function defineOperation(definition) {
894
- checkDefinition(definition);
895
- const defined = {
896
- ...definition,
897
- input: withValibotJsonSchema(definition.input)
898
- };
899
- const properties = operationInputJsonSchema(defined).properties;
900
- const clashes = isRecordOrFunction(properties) ? Object.keys(properties).filter((key) => reservedOperationFlags.includes(key)) : [];
901
- if (clashes.length) throw invalidDefinition(definition.name, `the input key ${clashes.map((key) => JSON.stringify(key)).join(", ")} is a CLI flag of every command (${reservedOperationFlags.join(", ")}). Rename it.`);
902
- return defined;
903
- }
904
- function isSectionId(section) {
905
- return typeof section === "string" && section !== "" && !section.includes(":");
906
- }
907
- /** JSON Schema of the input, for CLI flags and MCP tool schemas. Falls back to an open object. */
908
- function operationInputJsonSchema(operation) {
909
- return standardJsonSchema(operation.input, "input") ?? { type: "object" };
910
- }
911
- // ../internal/src/operations.ts
912
- /** Header that proves the caller is not a browser page. A foreign page cannot send it without a CORS preflight. */
913
- const operationRpcHeader = "x-vitehub-console";
914
- /** Response header of the local dev RPC. Its value is {@link projectRootHash} of the project that the server runs. */
915
- const operationRootHeader = "x-vitehub-root";
916
- const operationExpectedRootsHeader = "x-vitehub-expected-roots";
917
- /** A short stable hash of a project root. The CLI uses it to see that the dev server runs its own project. */
918
- function projectRootHash(root) {
919
- const normalized = root.replace(/\\/g, "/").replace(/\/+$/, "");
920
- let first = 3735928559;
921
- let second = 1103547991;
922
- for (let index = 0; index < normalized.length; index++) {
923
- const code = normalized.charCodeAt(index);
924
- first = Math.imul(first ^ code, 2654435761);
925
- second = Math.imul(second ^ code, 1597334677);
926
- }
927
- first = Math.imul(first ^ first >>> 16, 2246822507) ^ Math.imul(second ^ second >>> 13, 3266489909);
928
- second = Math.imul(second ^ second >>> 16, 2246822507) ^ Math.imul(first ^ first >>> 13, 3266489909);
929
- return `${(second >>> 0).toString(16).padStart(8, "0")}${(first >>> 0).toString(16).padStart(8, "0")}`;
930
- }
931
- /** Header that names the tool behind a call. `cli` marks `vitehub` commands. */
932
- const operationSurfaceHeader = "x-vitehub-surface";
933
- /** Generated CLI commands ask the server to check confirmation after it parses the input. */
934
- const operationConfirmationHeader = "x-vitehub-confirmation";
935
- const operationCredentialHint = "Set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key that `vitehub secret console-key` printed, and its public key in VITEHUB_CONSOLE_KEY_<NAME> on the app.";
936
- /** Headers of an operation call, without a signature. */
937
- function operationHeaders() {
938
- const headers = new Headers();
939
- headers.set("accept", "application/json");
940
- headers.set("content-type", "application/json");
941
- headers.set(operationRpcHeader, "1");
942
- headers.set(operationSurfaceHeader, "cli");
943
- return headers;
944
- }
945
- /**
946
- * The headers of one operation call to a deployed app: {@link operationHeaders}, and the signature of `body` when the
947
- * env has a `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>`. The CLI signs as itself, `via: "cli"`. Throws a `TypeError` for a
948
- * malformed private key.
949
- */
950
- async function signedOperationHeaders(env, url, body) {
951
- const headers = operationHeaders();
952
- const key = readConsoleSigningKey(env);
953
- if (key) {
954
- const signed = await signConsoleRequest({
955
- body,
956
- caller: { via: "cli" },
957
- key,
958
- method: "POST",
959
- url
960
- });
961
- for (const [name, value] of Object.entries(signed)) headers.set(name, value);
962
- }
963
- return headers;
964
- }
965
- function unreachable(message, status = 503) {
966
- const error = internalErrorDiagnostics.INTERNAL_R0024({ message });
967
- return {
968
- ok: false,
969
- code: error.code,
970
- fix: error.fix,
971
- message,
972
- status
973
- };
974
- }
975
- function hasCredentials(env) {
976
- return Object.keys(env).some((name) => name.startsWith("VITEHUB_CONSOLE_PRIVATE_KEY_") && Boolean(env[name]));
977
- }
978
- /** Call one operation over the RPC of a dev server or a deployed app. Never throws. */
979
- async function callOperation(target, name, input) {
980
- let origin = "the ViteHub app";
981
- try {
982
- const base = new URL(target.url);
983
- if (!base.pathname.endsWith("/")) base.pathname = `${base.pathname}/`;
984
- const url = new URL(operationRpcPath.slice(1), base);
985
- origin = url.origin;
986
- const env = target.roots?.length ? {} : target.env;
987
- if (!target.authorization) try {
988
- readConsoleSigningKey(env);
989
- } catch (error) {
990
- return {
991
- ok: false,
992
- code: "INTERNAL_R0024",
993
- fix: "Run `vitehub secret console-key` for a new key pair. Set its private key here and its public key on the app.",
994
- message: error instanceof Error ? error.message : String(error),
995
- status: 401
996
- };
997
- }
998
- const outcome = await callOperationRpc(name, input ?? {}, async (body) => {
999
- const signal = target.signal ?? AbortSignal.timeout(target.timeout ?? 3e4);
1000
- const headers = target.authorization ? operationHeaders() : await signedOperationHeaders(env, url, body);
1001
- if (target.authorization) headers.set("authorization", target.authorization);
1002
- if (target.confirmed !== void 0) headers.set(operationConfirmationHeader, target.confirmed ? "confirmed" : "required");
1003
- if (target.roots?.length) headers.set(operationExpectedRootsHeader, target.roots.map(projectRootHash).join(","));
1004
- signal.throwIfAborted();
1005
- const response = await (target.fetch ?? fetch)(url.href, {
1006
- body,
1007
- headers,
1008
- method: "POST",
1009
- redirect: "manual",
1010
- signal
1011
- });
1012
- const text = await response.text();
1013
- let json;
1014
- try {
1015
- json = text ? JSON.parse(text) : void 0;
1016
- } catch {
1017
- json = void 0;
1018
- }
1019
- return {
1020
- body: json,
1021
- response
1022
- };
1023
- });
1024
- const { response } = outcome.answer;
1025
- const served = response.headers.get(operationRootHeader);
1026
- if (served && target.roots?.length && !target.roots.some((root) => projectRootHash(root) === served)) {
1027
- const message = `The server at ${url.origin} runs another project than ${target.roots[0]}.`;
1028
- const error = internalErrorDiagnostics.INTERNAL_R0025({ message });
1029
- return {
1030
- ok: false,
1031
- code: error.code,
1032
- fix: error.fix,
1033
- message,
1034
- status: 409
1035
- };
1036
- }
1037
- if (outcome.ok) return {
1038
- ok: true,
1039
- value: outcome.value
1040
- };
1041
- const failure = outcome.error ?? readOperationRpcError(isRecordOrFunction(outcome.answer.body) ? {
1042
- status: response.status,
1043
- ...outcome.answer.body
1044
- } : void 0);
1045
- if (failure) {
1046
- if (target.roots?.length && failure.status === 401) failure.fix = `Pass --url ${base.href.slice(0, -1)} to send credentials. A command sends none to the dev server that it finds. ${failure.fix ?? "Set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key that `vitehub secret console-key` printed, and its public key in VITEHUB_CONSOLE_KEY_<NAME> on the app."}`;
1047
- if ((failure.status === 401 || failure.status === 403) && !target.authorization && !hasCredentials(env) && !failure.fix) failure.fix = target.roots?.length ? `Pass --url <origin> to send deployment credentials. ${operationCredentialHint}` : operationCredentialHint;
1048
- return {
1049
- ok: false,
1050
- ...failure
1051
- };
1052
- }
1053
- if (response.status === 401 || response.status >= 300 && response.status < 400) return unreachable(`${url.origin} asked for authentication (HTTP ${response.status}).`, 401);
1054
- return unreachable(`${url.origin} did not answer as a ViteHub app (HTTP ${response.status}). Pass the origin of an app that runs ViteHub.`, response.status);
1055
- } catch (error) {
1056
- return unreachable(`The request to ${origin} failed: ${error instanceof Error ? error.message : String(error)}`);
1057
- }
1058
- }
1059
- /**
1060
- * Call one operation from a `vitehub` command: on `--url` when it is set, else on the dev server that the project
1061
- * started. Never throws. Without a dev server the result is an `INTERNAL_R0024` failure that says to start one.
1062
- */
1063
- async function callOperationFromCli(call, name, input) {
1064
- let roots;
1065
- try {
1066
- roots = [.../* @__PURE__ */ new Set([call.rootDir, resolveViteHubProjectRoot(call.rootDir)])];
1067
- } catch {
1068
- roots = [call.rootDir];
1069
- }
1070
- const url = call.url ?? findViteHubDevServerUrl(roots, call.env);
1071
- if (!url) return unreachable(`No dev server is running for ${roots.at(-1)}.`);
1072
- return await callOperation({
1073
- ...call.confirmed !== void 0 ? { confirmed: call.confirmed } : {},
1074
- env: call.env,
1075
- ...call.fetch ? { fetch: call.fetch } : {},
1076
- ...call.url ? {} : { roots },
1077
- ...call.timeout ? { timeout: call.timeout } : {},
1078
- url
1079
- }, name, input);
1080
- }
1081
- /** Align rows of text cells in columns for CLI output. The last column is not padded. */
1082
- function table(rows) {
1083
- const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
1084
- return rows.map((row) => row.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column])).join(" ")).join("\n");
1085
- }
1086
- // src/operations.ts
1087
- const runtime = () => import("./operations-BIaK_uYG.js");
1088
- const name = v.pipe(v.string(), v.check((value) => value.trim() !== "", "Name a Workspace."));
1089
- const nonEmpty = (message) => v.pipe(v.string(), v.check((value) => value !== "", message));
1090
- function defineWorkspaceOperation(definition, kind = "read") {
1091
- return defineOperation({
1092
- ...definition,
1093
- kind,
1094
- section: "workspaces",
1095
- ...kind === "read" ? { user: false } : {}
1096
- });
1097
- }
1098
- function oneLine(value) {
1099
- return value?.split(/\r?\n/, 1)[0]?.trim() || "-";
1100
- }
1101
- function formatHistory(result) {
1102
- if (!result.revisions.length) return result.ref ? `No revisions on ref ${result.ref}.\n` : "No revisions.\n";
1103
- const lines = [table([[
1104
- "REVISION",
1105
- "REF",
1106
- "CREATED AT",
1107
- "AUTHOR",
1108
- "FILES",
1109
- "MESSAGE"
1110
- ], ...result.revisions.map((revision) => [
1111
- revision.id,
1112
- revision.ref,
1113
- revision.createdAt,
1114
- revision.author ?? "-",
1115
- String(revision.files),
1116
- oneLine(revision.message)
1117
- ])])];
1118
- if (result.cursor && result.ref) lines.push(`More revisions: vitehub workspace history ${result.workspace} --ref ${result.ref} --cursor ${result.cursor}`);
1119
- else if (result.more) lines.push("More revisions exist. Use --ref <ref> to page through one ref.");
1120
- return `${lines.join("\n")}\n`;
1121
- }
1122
- function formatRefs(result) {
1123
- if (!result.refs.length) return "No refs. The Workspace has no retained revisions yet.\n";
1124
- return `${table([[
1125
- "REF",
1126
- "HEAD",
1127
- "CREATED AT",
1128
- "AUTHOR",
1129
- "MESSAGE"
1130
- ], ...result.refs.map((ref) => [
1131
- ref.name,
1132
- ref.head.id,
1133
- ref.head.createdAt,
1134
- ref.head.author ?? "-",
1135
- oneLine(ref.head.message)
1136
- ])])}\n`;
1137
- }
1138
- function formatFiles(files) {
1139
- if (!files.length) return "No files.";
1140
- return table([[
1141
- "PATH",
1142
- "SIZE",
1143
- "MEDIA TYPE",
1144
- "DIGEST"
1145
- ], ...files.map((file) => [
1146
- file.path,
1147
- file.size === void 0 ? "-" : String(file.size),
1148
- file.mediaType ?? "-",
1149
- file.digest ?? "-"
1150
- ])]);
1151
- }
1152
- function formatRevision(revision) {
1153
- return [
1154
- `Revision: ${revision.id}`,
1155
- `Ref: ${revision.ref}`,
1156
- `Parent: ${revision.parentId ?? "-"}`,
1157
- `Created at: ${revision.createdAt}`,
1158
- `Author: ${revision.author ?? "-"}`,
1159
- `Message: ${revision.message ?? "-"}`,
1160
- `Files: ${revision.files} (${revision.bytes} bytes)`
1161
- ];
1162
- }
1163
- function formatShow(result) {
1164
- if (result.file) {
1165
- if (result.file.encoding === "utf8") return result.file.content;
1166
- return `${result.file.path} is binary (${result.file.size ?? "unknown"} bytes). Run the command with --json to read its content as base64.\n`;
1167
- }
1168
- return `${[
1169
- ...formatRevision(result.revision),
1170
- ...result.path ? [`Path: ${result.path}`] : [],
1171
- "",
1172
- formatFiles(result.files ?? [])
1173
- ].join("\n")}\n`;
1174
- }
1175
- const history = defineWorkspaceOperation({
1176
- cli: {
1177
- command: "history",
1178
- format: formatHistory,
1179
- namespace: "workspace",
1180
- positional: ["workspace"]
1181
- },
1182
- description: `List the retained revisions of a Workspace, newest first. Without \`ref\`, the list merges every ref. \`limit\` defaults to 20.`,
1183
- input: v.object({
1184
- cursor: v.optional(nonEmpty("The cursor cannot be empty.")),
1185
- limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100))),
1186
- ref: v.optional(nonEmpty("The ref cannot be empty.")),
1187
- workspace: name
1188
- }),
1189
- name: "workspace.history",
1190
- run: async (input) => await (await runtime()).runWorkspaceOperation("history", input)
1191
- });
1192
- const refs = defineWorkspaceOperation({
1193
- cli: {
1194
- command: "refs",
1195
- format: formatRefs,
1196
- namespace: "workspace",
1197
- positional: ["workspace"]
1198
- },
1199
- description: "List the history refs of a Workspace and the head revision of each ref.",
1200
- input: v.object({ workspace: name }),
1201
- name: "workspace.refs",
1202
- run: async (input) => await (await runtime()).runWorkspaceOperation("refs", input)
1203
- });
1204
- const show = defineWorkspaceOperation({
1205
- cli: {
1206
- command: "get",
1207
- format: formatShow,
1208
- namespace: "workspace",
1209
- positional: [
1210
- "workspace",
1211
- "target",
1212
- "path"
1213
- ]
1214
- },
1215
- description: "Show one revision of a Workspace by ref or revision id, with its files. With `path`, return that file as it was in the revision.",
1216
- input: v.object({
1217
- path: v.optional(nonEmpty("The path cannot be empty.")),
1218
- target: nonEmpty("Name a ref or revision."),
1219
- workspace: name
1220
- }),
1221
- name: "workspace.show",
1222
- run: async (input) => await (await runtime()).runWorkspaceOperation("show", input)
1223
- });
1224
- function formatChanges(result) {
1225
- if (!result.head) return `Ref ${result.ref} has no revisions.\n`;
1226
- if (!result.files.length) return `No changes. Ref ${result.ref} is at ${result.head.id}.\n`;
1227
- return `${table([["PATH", "CHANGE"], ...result.files.map((file) => [file.path, file.deleted ? "deleted" : file.base ? "changed" : "added"])])}\nHead: ${result.head.id}\n`;
1228
- }
1229
- const encodedFile = v.object({
1230
- content: v.string(),
1231
- encoding: v.picklist(["base64", "utf8"])
1232
- });
1233
- const changes = defineWorkspaceOperation({
1234
- cli: {
1235
- command: "changes",
1236
- format: formatChanges,
1237
- namespace: "workspace",
1238
- positional: ["workspace"]
1239
- },
1240
- description: "List the files of a ref that changed since a revision, with their content at the head and at that revision. Without `since`, list every file of the head. `vitehub pull` reads it.",
1241
- input: v.object({
1242
- content: v.optional(v.boolean()),
1243
- ref: v.optional(nonEmpty("The ref cannot be empty.")),
1244
- since: v.optional(v.nullable(nonEmpty("The revision cannot be empty."))),
1245
- workspace: name
1246
- }),
1247
- name: "workspace.changes",
1248
- run: async (input) => await (await runtime()).runWorkspaceChanges(input)
1249
- });
1250
- const commit = defineWorkspaceOperation({
1251
- cli: {
1252
- command: "commit",
1253
- namespace: "workspace",
1254
- positional: ["workspace"]
1255
- },
1256
- description: "Commit files to a ref when its head is still `ifHead`, else fail with WORKSPACE_CONFLICT. `put` writes files and `delete` removes paths; other files keep their content. A replaced file keeps its media type and metadata. The revision records the signed-in user as its author. Workspace write rules and validators run, and a file that someone else holds an edit lease on fails the commit unless lease is override. `vitehub push` calls it.",
1257
- input: v.object({
1258
- delete: v.optional(v.array(nonEmpty("A path cannot be empty."))),
1259
- ifHead: v.nullable(nonEmpty("The head cannot be empty.")),
1260
- lease: v.optional(v.literal("override")),
1261
- message: v.optional(v.string()),
1262
- put: v.optional(v.record(nonEmpty("A path cannot be empty."), encodedFile)),
1263
- ref: v.optional(nonEmpty("The ref cannot be empty.")),
1264
- workspace: name
1265
- }),
1266
- maxRequestBytes: workspaceCommitRequestBytes,
1267
- name: "workspace.commit",
1268
- run: async (input, context) => await (await runtime()).runWorkspaceCommit(input, context)
1269
- }, "write");
1270
- function formatStale(result) {
1271
- if (!result.head) return `Ref ${result.ref} has no revisions.\n`;
1272
- if (!result.stale.length) return `No stale derived files on ${result.ref}.\n`;
1273
- return `${table([[
1274
- "PATH",
1275
- "SOURCE",
1276
- "REASON",
1277
- "SOURCE DIGEST"
1278
- ], ...result.stale.map((file) => [
1279
- file.path,
1280
- file.derivedFrom.path,
1281
- file.reason,
1282
- file.sourceDigest ?? "-"
1283
- ])])}\nWrite SOURCE DIGEST as derivedFrom.digest after you update a file.\n`;
1284
- }
1285
- /** The `workspace.*` operations: history, refs, show, changes, commit, and stale. The Console, `vitehub workspace`, and agents run them. */
1286
- const workspaceOperations = [
1287
- history,
1288
- refs,
1289
- show,
1290
- changes,
1291
- commit,
1292
- defineWorkspaceOperation({
1293
- cli: {
1294
- command: "stale",
1295
- format: formatStale,
1296
- namespace: "workspace",
1297
- positional: ["workspace"]
1298
- },
1299
- description: "List the derived files on a ref, such as translations, whose `derivedFrom` source changed or is gone. Each changed entry has `sourceDigest`: write it as `derivedFrom.digest` after you update the file.",
1300
- input: v.object({
1301
- ref: v.optional(nonEmpty("The ref cannot be empty.")),
1302
- workspace: name
1303
- }),
1304
- name: "workspace.stale",
1305
- run: async (input) => await (await runtime()).runWorkspaceStale(input)
1306
- })
1307
- ];
1308
- export { resolve$1 as S, redactInspectionText as _, createNoExternalAddition as a, isAbsolute$1 as b, isProductionBuild as c, resolveViteHubProjectRoot as d, shouldSkipViteProviderBuild as f, requireViteHubDevServerUrl as g, readViteHubDevTargetOption as h, createNativePackageLoading as i, isServerEnvironment as l, fetchViteHubDevEndpoint as m, callOperationFromCli as n, createViteHubEnvImportAliases as o, discoverViteHubDevServer as p, VITEHUB_SERVER_DIRS as r, generatedViteHubWatchIgnoredAddition as s, workspaceOperations as t, publishViteHubDevServer as u, relativeDefinitionFile as v, relative$1 as x, dirname$1 as y };