@vite-hub/env 0.0.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +288 -23
- package/dist/access-B8lSDip4.js +54 -0
- package/dist/bridge-Cs9YfQWk.d.ts +447 -0
- package/dist/bridge-error-BhJ77age.js +66 -0
- package/dist/bridge.d.ts +2 -0
- package/dist/bridge.js +354 -0
- package/dist/cli-BPp7rdcA.d.ts +159 -0
- package/dist/cli-DLpY0QAo.js +669 -0
- package/dist/cli.d.ts +41 -0
- package/dist/cli.js +2 -0
- package/dist/database.d.ts +47 -0
- package/dist/database.js +274 -0
- package/dist/declarations-C5XR3aKw.d.ts +58 -0
- package/dist/error-diagnostics-B8RFjQ1V.js +56 -0
- package/dist/index.d.ts +146 -11
- package/dist/index.js +240 -7
- package/dist/internal/agent.d.ts +5 -0
- package/dist/internal/agent.js +22 -0
- package/dist/internal/connections.d.ts +18 -0
- package/dist/internal/connections.js +31 -0
- package/dist/internal/server.d.ts +3 -0
- package/dist/internal/server.js +2 -0
- package/dist/object-_dlsZ4lP.js +276 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-X1w--wds.js +30 -0
- package/dist/operations.d.ts +37 -0
- package/dist/operations.js +833 -0
- package/dist/runtime/public-env.d.ts +5 -0
- package/dist/runtime/public-env.js +8 -0
- package/dist/runtime/server-env.d.ts +22 -0
- package/dist/runtime/server-env.js +35 -0
- package/dist/schema-DMZ1_yhY.js +360 -0
- package/dist/seal.d.ts +17 -0
- package/dist/seal.js +52 -0
- package/dist/{secret.js → secret-DJd-fy5T.js} +1 -1
- package/dist/server-ChNL_Xc3.js +1279 -0
- package/dist/server-Dd8bjIKd.d.ts +145 -0
- package/dist/server.d.ts +3 -8
- package/dist/server.js +2 -3
- package/dist/virtual-module.d.ts +9 -5
- package/dist/virtual.d.ts +1 -1
- package/dist/vite.d.ts +79 -21
- package/dist/vite.js +1095 -339
- package/package.json +81 -28
- package/dist/declarations-CoMmvRqH.js +0 -159
- package/dist/declarations-U6P3rvxC.d.ts +0 -24
- package/dist/errors-C4Xcs6Fi.js +0 -121
- package/dist/presets.d.ts +0 -11
- package/dist/presets.js +0 -25
- package/dist/provider.d.ts +0 -6
- package/dist/provider.js +0 -7
- package/dist/schema.d.ts +0 -16
- package/dist/schema.js +0 -37
- package/dist/secret-C2191nAa.d.ts +0 -11
- package/dist/secret.d.ts +0 -2
- package/dist/server-C16sFc1E.js +0 -303
- package/dist/types-CsB6DTGE.d.ts +0 -190
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
//#region ../internal/src/error-diagnostics.ts
|
|
3
|
+
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
4
|
+
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
5
|
+
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
6
|
+
codes: {
|
|
7
|
+
INTERNAL_R0012: {
|
|
8
|
+
...dynamicError,
|
|
9
|
+
fix: "Check the URL, the headers, and the credentials of the HTTP request. `error.status` holds the status that the server sent."
|
|
10
|
+
},
|
|
11
|
+
INTERNAL_R0013: {
|
|
12
|
+
...dynamicError,
|
|
13
|
+
fix: "Check that the provider token can manage the resource in the path that the message names. `error.kind` and `error.codes` hold the provider failure."
|
|
14
|
+
},
|
|
15
|
+
INTERNAL_R0014: {
|
|
16
|
+
why: ({ path }) => `Cannot read Provision State from "${path}".`,
|
|
17
|
+
fix: "Check file access and restore valid JSON while preserving existing resource IDs."
|
|
18
|
+
},
|
|
19
|
+
INTERNAL_R0020: {
|
|
20
|
+
fix: "Give the operation a name like `content.publish`, a description, a section, a kind, an input schema, and a run function.",
|
|
21
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
22
|
+
},
|
|
23
|
+
INTERNAL_R0021: {
|
|
24
|
+
fix: "Run `vitehub inspect definitions --kind operation` to list the operations of this app.",
|
|
25
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
26
|
+
},
|
|
27
|
+
INTERNAL_R0022: {
|
|
28
|
+
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
29
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
30
|
+
},
|
|
31
|
+
INTERNAL_R0024: {
|
|
32
|
+
fix: "Start the dev server with `vite dev`, or pass `--url <origin>` of a deployed app and set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key whose public key the app has in VITEHUB_CONSOLE_KEY_<NAME>.",
|
|
33
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
34
|
+
},
|
|
35
|
+
INTERNAL_R0023: {
|
|
36
|
+
fix: "Ask for access to the section of this operation.",
|
|
37
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
38
|
+
},
|
|
39
|
+
INTERNAL_B0001: {
|
|
40
|
+
...dynamicError,
|
|
41
|
+
fix: "Give the resource that the message names another name or binding in the `vitehub()` options of its feature, so that two different Cloudflare resources do not share one name."
|
|
42
|
+
},
|
|
43
|
+
INTERNAL_B0015: {
|
|
44
|
+
...dynamicError,
|
|
45
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
|
|
46
|
+
},
|
|
47
|
+
INTERNAL_B0016: {
|
|
48
|
+
...dynamicError,
|
|
49
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
50
|
+
},
|
|
51
|
+
INTERNAL_B0017: {
|
|
52
|
+
...dynamicError,
|
|
53
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
54
|
+
},
|
|
55
|
+
INTERNAL_B0018: {
|
|
56
|
+
...dynamicError,
|
|
57
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
58
|
+
},
|
|
59
|
+
INTERNAL_B0019: {
|
|
60
|
+
...dynamicError,
|
|
61
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
62
|
+
},
|
|
63
|
+
INTERNAL_B0020: {
|
|
64
|
+
...dynamicError,
|
|
65
|
+
fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
|
|
66
|
+
},
|
|
67
|
+
INTERNAL_B0021: {
|
|
68
|
+
...dynamicError,
|
|
69
|
+
fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
|
|
70
|
+
},
|
|
71
|
+
INTERNAL_B0022: {
|
|
72
|
+
...dynamicError,
|
|
73
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
|
|
74
|
+
},
|
|
75
|
+
INTERNAL_B0025: {
|
|
76
|
+
...dynamicError,
|
|
77
|
+
fix: "Replace the `new URL(\"./...\", import.meta.url)` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` of that file."
|
|
78
|
+
},
|
|
79
|
+
INTERNAL_B0026: {
|
|
80
|
+
...dynamicError,
|
|
81
|
+
fix: "Replace the computed `import()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` or with `import(\"<literal path>\")`."
|
|
82
|
+
},
|
|
83
|
+
INTERNAL_B0027: {
|
|
84
|
+
...dynamicError,
|
|
85
|
+
fix: "Replace the computed `require()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import`."
|
|
86
|
+
},
|
|
87
|
+
INTERNAL_B0028: {
|
|
88
|
+
...dynamicError,
|
|
89
|
+
fix: "Wait for the other build of this app to finish, or stop the process that the message names, then build again."
|
|
90
|
+
},
|
|
91
|
+
INTERNAL_B0029: {
|
|
92
|
+
...dynamicError,
|
|
93
|
+
fix: "Stop the other builds that write the same Deno output folder, delete the `.vitehub-lock` folder next to that output folder, such as `.output.vitehub-lock`, then build again."
|
|
94
|
+
},
|
|
95
|
+
INTERNAL_B0031: {
|
|
96
|
+
...dynamicError,
|
|
97
|
+
fix: "Import `./schedule/deno-cron.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./schedule/deno-cron.mjs\", import.meta.url).href)` outside any condition."
|
|
98
|
+
},
|
|
99
|
+
INTERNAL_B0032: {
|
|
100
|
+
...dynamicError,
|
|
101
|
+
fix: "Import `./server/index.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./server/index.mjs\", import.meta.url).href)` outside any condition."
|
|
102
|
+
},
|
|
103
|
+
INTERNAL_B0035: {
|
|
104
|
+
...dynamicError,
|
|
105
|
+
fix: "Delete the provider output folder that holds the file that the message names, such as `dist/<app>` for Cloudflare, and build again."
|
|
106
|
+
},
|
|
107
|
+
INTERNAL_B0039: {
|
|
108
|
+
...dynamicError,
|
|
109
|
+
fix: "Fix the build error that ViteHub showed before this one. ViteHub stops writing the provider output when another part of the build fails."
|
|
110
|
+
},
|
|
111
|
+
INTERNAL_B0040: {
|
|
112
|
+
...dynamicError,
|
|
113
|
+
fix: "Remove the custom Nitro `output.serverDir`, so that the Nitro preset of the host writes the server entry that the message names."
|
|
114
|
+
},
|
|
115
|
+
INTERNAL_B0043: {
|
|
116
|
+
...dynamicError,
|
|
117
|
+
fix: "Delete the build output folder, such as `.output` or `.vercel/output`, and build again."
|
|
118
|
+
},
|
|
119
|
+
INTERNAL_B0046: {
|
|
120
|
+
...dynamicError,
|
|
121
|
+
fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
|
|
122
|
+
},
|
|
123
|
+
INTERNAL_B0047: {
|
|
124
|
+
...dynamicError,
|
|
125
|
+
fix: "Correct the `package.json` file that the message names so that it holds one JSON object, or run `pnpm install` again to restore an installed package."
|
|
126
|
+
},
|
|
127
|
+
INTERNAL_B0048: {
|
|
128
|
+
fix: "Rename one of the two operations. A name is `<section>.<verb>` and is unique in the app.",
|
|
129
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
130
|
+
},
|
|
131
|
+
INTERNAL_B0049: {
|
|
132
|
+
fix: "Set `cli: { namespace, command }` on one of the two operations.",
|
|
133
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
134
|
+
},
|
|
135
|
+
INTERNAL_B0050: {
|
|
136
|
+
fix: "Rename one of the two operations, or set `mcp: false` on it. MCP tool names replace every character outside letters, digits, `_`, and `-` with `_`.",
|
|
137
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
138
|
+
},
|
|
139
|
+
INTERNAL_B0051: {
|
|
140
|
+
why: ({ field, generated, name, path, project, scope }) => `The Cloudflare ${path} entry "${name}"${scope} is written by ViteHub and by the project's Wrangler config with a different ${field}: ${generated} and ${project}.`,
|
|
141
|
+
fix: "Remove the entry from the project's Wrangler config, since ViteHub writes it, or give one of them another name."
|
|
142
|
+
},
|
|
143
|
+
INTERNAL_B0052: {
|
|
144
|
+
why: ({ column, section }) => `The column "${column}" of the Console section "${section}" needs both \`format: "switch"\` and a \`switch\` operation name such as "skills.set".`,
|
|
145
|
+
fix: "Give a switch column `format: \"switch\"` and `switch: { operation, input }` with a registered operation name, or remove both."
|
|
146
|
+
},
|
|
147
|
+
INTERNAL_R0025: {
|
|
148
|
+
fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
|
|
149
|
+
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
150
|
+
},
|
|
151
|
+
INTERNAL_R0026: {
|
|
152
|
+
why: "The server parsed a destructive operation that the CLI did not confirm.",
|
|
153
|
+
fix: "Review the operation, then run it again with --yes to confirm the change."
|
|
154
|
+
},
|
|
155
|
+
INTERNAL_C0001: {
|
|
156
|
+
...dynamicError,
|
|
157
|
+
fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
|
|
158
|
+
},
|
|
159
|
+
INTERNAL_C0002: {
|
|
160
|
+
...dynamicError,
|
|
161
|
+
fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
|
|
162
|
+
},
|
|
163
|
+
INTERNAL_R0001: {
|
|
164
|
+
...dynamicError,
|
|
165
|
+
fix: "Set `host` in `vitehub()`, or in the `vitehub` options of `nuxt.config.ts`, to `cloudflare`, `deno`, `netlify`, `node`, or `vercel`. Or remove `host` so that ViteHub finds the host from the environment."
|
|
166
|
+
},
|
|
167
|
+
INTERNAL_R0002: {
|
|
168
|
+
...dynamicError,
|
|
169
|
+
fix: "Stop using the feature that the message names, or set `host` in `vitehub()` to a host that provides it. For Blob, you can also set `blob: { driver: \"s3\" }` with a remote store."
|
|
170
|
+
},
|
|
171
|
+
INTERNAL_R0004: {
|
|
172
|
+
...dynamicError,
|
|
173
|
+
fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
|
|
174
|
+
},
|
|
175
|
+
INTERNAL_R0005: {
|
|
176
|
+
...dynamicError,
|
|
177
|
+
fix: "Set `method` of the HTTP request to `GET`, `HEAD`, or `POST`."
|
|
178
|
+
},
|
|
179
|
+
INTERNAL_R0006: {
|
|
180
|
+
...dynamicError,
|
|
181
|
+
fix: "Set `timeout` of the HTTP request to a number of milliseconds from 1 to 2147483647, or remove it to use the default."
|
|
182
|
+
},
|
|
183
|
+
INTERNAL_R0007: {
|
|
184
|
+
...dynamicError,
|
|
185
|
+
fix: "Set `maxResponseBytes` of the HTTP request to a positive integer no greater than the limit that the message names, or remove it to use the default."
|
|
186
|
+
},
|
|
187
|
+
INTERNAL_R0008: {
|
|
188
|
+
...dynamicError,
|
|
189
|
+
fix: "Make the value that the message names match its schema: the input, query, or body that you send, or the response schema that you declare for the request."
|
|
190
|
+
},
|
|
191
|
+
INTERNAL_R0009: {
|
|
192
|
+
...dynamicError,
|
|
193
|
+
fix: "Use a Standard Schema whose `validate()` returns `{ value }` or `{ issues }` for the value that the message names."
|
|
194
|
+
},
|
|
195
|
+
INTERNAL_R0010: {
|
|
196
|
+
...dynamicError,
|
|
197
|
+
fix: "Run the command again. If the error stays, check the Cloudflare API status, because Cloudflare sent a response that ViteHub cannot read."
|
|
198
|
+
},
|
|
199
|
+
INTERNAL_R0011: {
|
|
200
|
+
...dynamicError,
|
|
201
|
+
fix: "Pass an h3 app, an object with a `fetch(request)` method, or a fetch function as `app`."
|
|
202
|
+
},
|
|
203
|
+
INTERNAL_CONSOLE_KEY_NAME_INVALID: {
|
|
204
|
+
why: ({ name }) => `[vitehub] The Console key name ${JSON.stringify(name)} must be 1 to 64 of A-Z, 0-9, and _.`,
|
|
205
|
+
fix: "Name the Console key with 1 to 64 characters from A-Z, 0-9, and _, such as `CI`. The app reads its public key from `VITEHUB_CONSOLE_KEY_<NAME>`."
|
|
206
|
+
},
|
|
207
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_INVALID: {
|
|
208
|
+
why: "[vitehub] A Console private key is the 32-byte Ed25519 seed as base64url (43 characters). `vitehub secret console-key` makes one.",
|
|
209
|
+
fix: "Run `vitehub secret console-key` and use the 43-character private key that it prints, without spaces or quotes."
|
|
210
|
+
},
|
|
211
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLES_MULTIPLE: {
|
|
212
|
+
why: ({ prefix, variables }) => `[vitehub] Set one ${prefix}<NAME> variable. This environment has ${variables}.`,
|
|
213
|
+
fix: "Keep one `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` variable in the environment of the command, and unset the others that the message names."
|
|
214
|
+
},
|
|
215
|
+
INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLE_INVALID: {
|
|
216
|
+
why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
|
|
217
|
+
fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
|
|
218
|
+
},
|
|
219
|
+
INTERNAL_FORGE_NOT_INSTALLED: {
|
|
220
|
+
why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
|
|
221
|
+
fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
|
|
222
|
+
},
|
|
223
|
+
INTERNAL_MCP_ARGUMENTS_INVALID: {
|
|
224
|
+
why: ({ detail }) => detail,
|
|
225
|
+
fix: "Pass the prompt or resource the arguments that `prompts/list` or `resources/templates/list` describes for it."
|
|
226
|
+
},
|
|
227
|
+
INTERNAL_MCP_METHOD_FAILED: {
|
|
228
|
+
why: ({ name }) => `${name} failed on the server.`,
|
|
229
|
+
fix: "Read the server log for the error of the MCP prompt or resource that the message names, and fix its handler."
|
|
230
|
+
},
|
|
231
|
+
INTERNAL_MCP_RESOURCE_NOT_FOUND: {
|
|
232
|
+
why: ({ uri }) => `Resource not found: ${uri}. Call resources/list or resources/templates/list for the resources of this server.`,
|
|
233
|
+
fix: "Call `resources/list` or `resources/templates/list`, and read a URI that one of them returns."
|
|
234
|
+
},
|
|
235
|
+
INTERNAL_PRESET_OPTION_UNKNOWN: {
|
|
236
|
+
why: ({ key, label }) => `[vitehub] Unknown ${label} option "${key}".`,
|
|
237
|
+
fix: "Remove the option that the message names from the preset options, or correct its spelling to an option that the preset declares."
|
|
238
|
+
},
|
|
239
|
+
INTERNAL_PRESET_TUPLE_INVALID: {
|
|
240
|
+
why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
|
|
241
|
+
fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
|
|
242
|
+
},
|
|
243
|
+
INTERNAL_SECRET_PURPOSE_MISSING: {
|
|
244
|
+
why: "[vitehub] A derived secret requires a purpose.",
|
|
245
|
+
fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
|
|
246
|
+
},
|
|
247
|
+
INTERNAL_SECRET_TOO_SHORT: {
|
|
248
|
+
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
249
|
+
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
250
|
+
},
|
|
251
|
+
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
252
|
+
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",
|
|
253
|
+
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."
|
|
254
|
+
},
|
|
255
|
+
INTERNAL_SQLITE_INTEGER_UNSAFE: {
|
|
256
|
+
why: "Received integer which cannot be safely represented as a JavaScript number",
|
|
257
|
+
fix: "Create the client with `intMode: \"bigint\"` or `intMode: \"string\"`, or read the column with `CAST(column AS TEXT)` in the query."
|
|
258
|
+
},
|
|
259
|
+
INTERNAL_VALIBOT_JSON_SCHEMA_TARGET_UNSUPPORTED: {
|
|
260
|
+
why: ({ target }) => `[vitehub] Valibot cannot convert a schema to the ${target} JSON Schema target.`,
|
|
261
|
+
fix: "Ask for the `draft-07`, `draft-2020-12`, or `openapi-3.0` JSON Schema target, or pass one of them as `withValibotJsonSchema(schema, { target })`."
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region ../internal/src/object.ts
|
|
267
|
+
/** A non-null object that is not an array. Functions do not pass. */
|
|
268
|
+
function isRecord(value) {
|
|
269
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
270
|
+
}
|
|
271
|
+
/** A non-null object or a function that is not an array. */
|
|
272
|
+
function isRecordOrFunction(value) {
|
|
273
|
+
return Object(value) === value && !Array.isArray(value);
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { isRecordOrFunction as n, internalErrorDiagnostics as r, isRecord as t };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
2
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
3
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
4
|
+
/** The Standard properties. */
|
|
5
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
declare namespace StandardTypedV1 {
|
|
8
|
+
/** The Standard Typed properties interface. */
|
|
9
|
+
interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
/** Inferred types associated with the schema. */
|
|
15
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** The Standard Typed types interface. */
|
|
18
|
+
interface Types<Input = unknown, Output = Input> {
|
|
19
|
+
/** The input type of the schema. */
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
/** The output type of the schema. */
|
|
22
|
+
readonly output: Output;
|
|
23
|
+
}
|
|
24
|
+
/** Infers the input type of a Standard Typed. */
|
|
25
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
26
|
+
/** Infers the output type of a Standard Typed. */
|
|
27
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
28
|
+
}
|
|
29
|
+
/** The Standard Schema interface. */
|
|
30
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
31
|
+
/** The Standard Schema properties. */
|
|
32
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
33
|
+
}
|
|
34
|
+
declare namespace StandardSchemaV1 {
|
|
35
|
+
/** The Standard Schema properties interface. */
|
|
36
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
37
|
+
/** Validates unknown input values. */
|
|
38
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
39
|
+
}
|
|
40
|
+
/** The result interface of the validate function. */
|
|
41
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
42
|
+
/** The result interface if validation succeeds. */
|
|
43
|
+
interface SuccessResult<Output> {
|
|
44
|
+
/** The typed output value. */
|
|
45
|
+
readonly value: Output;
|
|
46
|
+
/** A falsy value for `issues` indicates success. */
|
|
47
|
+
readonly issues?: undefined;
|
|
48
|
+
}
|
|
49
|
+
interface Options {
|
|
50
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
51
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
52
|
+
}
|
|
53
|
+
/** The result interface if validation fails. */
|
|
54
|
+
interface FailureResult {
|
|
55
|
+
/** The issues of failed validation. */
|
|
56
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
57
|
+
}
|
|
58
|
+
/** The issue interface of the failure output. */
|
|
59
|
+
interface Issue {
|
|
60
|
+
/** The error message of the issue. */
|
|
61
|
+
readonly message: string;
|
|
62
|
+
/** The path of the issue, if any. */
|
|
63
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** The path segment interface of the issue. */
|
|
66
|
+
interface PathSegment {
|
|
67
|
+
/** The key representing a path segment. */
|
|
68
|
+
readonly key: PropertyKey;
|
|
69
|
+
}
|
|
70
|
+
/** The Standard types interface. */
|
|
71
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
72
|
+
/** Infers the input type of a Standard. */
|
|
73
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
74
|
+
/** Infers the output type of a Standard. */
|
|
75
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ../internal/src/operation-definition.d.ts
|
|
79
|
+
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
80
|
+
type OperationKind = "read" | "write" | "destructive";
|
|
81
|
+
/** The signed-in user of a call. */
|
|
82
|
+
interface OperationUser {
|
|
83
|
+
id: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
email?: string;
|
|
86
|
+
image?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/** The Agent Actor when an agent calls through a capability or MCP on behalf of a user. */
|
|
90
|
+
interface OperationActor {
|
|
91
|
+
id: string;
|
|
92
|
+
kind?: string;
|
|
93
|
+
label?: string;
|
|
94
|
+
meta?: object;
|
|
95
|
+
}
|
|
96
|
+
/** The checked Console access of a call. `vite-hub` issues it. `ConsoleAccess` has this shape. */
|
|
97
|
+
interface OperationAccess {
|
|
98
|
+
readonly mode: string;
|
|
99
|
+
/**
|
|
100
|
+
* The sections that the call may use. `"all"` when no section filter applies. An entry is a section id (`"kv"`, every
|
|
101
|
+
* operation of the section), `"<section>:read"` (only the operations that read), or `"<section>:<scope>"` (only the
|
|
102
|
+
* calls of a scoped operation for that scope, such as `"blob:media"` for one Blob store). `"<section>:<scope>:read"`
|
|
103
|
+
* allows only the reads of that scope.
|
|
104
|
+
*/
|
|
105
|
+
readonly sections: "all" | readonly string[];
|
|
106
|
+
readonly user?: OperationUser;
|
|
107
|
+
}
|
|
108
|
+
interface OperationContext {
|
|
109
|
+
/** The checked Console access of the call. */
|
|
110
|
+
access: OperationAccess;
|
|
111
|
+
/** The signed-in user, or null. */
|
|
112
|
+
user: OperationUser | null;
|
|
113
|
+
/** The Agent Actor when an agent calls on behalf of `user`. */
|
|
114
|
+
actor?: OperationActor;
|
|
115
|
+
surface: "console" | "cli" | "mcp" | "agent";
|
|
116
|
+
/** Set by the host from generated build identity, never from request input or runtime NODE_ENV. */
|
|
117
|
+
development?: boolean;
|
|
118
|
+
env?: Record<string, unknown>;
|
|
119
|
+
waitUntil?: (task: Promise<unknown>) => void;
|
|
120
|
+
request?: Request;
|
|
121
|
+
/**
|
|
122
|
+
* The request event of the HTTP request that carries the call, when there is one: the Request of the Console route,
|
|
123
|
+
* with its Standard Context. Operations hand it to app hooks that read the request's own session, such as `identify`
|
|
124
|
+
* of Comments.
|
|
125
|
+
*/
|
|
126
|
+
event?: unknown;
|
|
127
|
+
/** Operations set a success status here, such as 202 for an accepted call. */
|
|
128
|
+
response?: {
|
|
129
|
+
status?: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* An agent or an MCP client may pass `lease: "override"` to `content.save`, `content.remove`, and `content.restore`
|
|
133
|
+
* only when the developer allowed it. Defaults to false, so a model cannot take over a document that a person is editing.
|
|
134
|
+
*/
|
|
135
|
+
overrideLeases?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* What an Agent may read of the Channel conversations, set by `operations({ conversations })`. `participant`: only the
|
|
138
|
+
* threads that the Actor takes part in. `all`: every thread. Unset: none.
|
|
139
|
+
*/
|
|
140
|
+
conversations?: "all" | "participant";
|
|
141
|
+
}
|
|
142
|
+
interface OperationDefinition<Input, Output> {
|
|
143
|
+
/** `<section>.<verb>`, such as `content.publish`. Unique per app. */
|
|
144
|
+
name: string;
|
|
145
|
+
/** One sentence. Becomes the CLI help line and the MCP tool description. */
|
|
146
|
+
description: string;
|
|
147
|
+
/**
|
|
148
|
+
* Console section that grants access, such as `content`. `false`: any Console user. A function reads the section
|
|
149
|
+
* from the input, for operations that serve several sections. Section ids cannot contain `:`; it is reserved for
|
|
150
|
+
* scope and read-only grants. A function that returns an invalid id denies the call.
|
|
151
|
+
*/
|
|
152
|
+
section: string | false | ((input: Input) => string | undefined);
|
|
153
|
+
/**
|
|
154
|
+
* The part of a string `section` that one call uses, such as the Blob store that the input names. The call then needs
|
|
155
|
+
* the section (every scope) or `"<section>:<scope>"` (only this scope). A scope that is empty, is `read`, or has a
|
|
156
|
+
* `:` needs the whole section.
|
|
157
|
+
*/
|
|
158
|
+
scope?: (input: Input) => string | undefined;
|
|
159
|
+
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes; the CLI asks for `--yes`, MCP marks `destructiveHint`, agents require approval by default. */
|
|
160
|
+
kind: OperationKind;
|
|
161
|
+
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
162
|
+
input: StandardSchemaV1<unknown, Input>;
|
|
163
|
+
output?: StandardSchemaV1<unknown, Output>;
|
|
164
|
+
cli?: {
|
|
165
|
+
/** Defaults: namespace = section, command = verb. */
|
|
166
|
+
namespace?: string;
|
|
167
|
+
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
168
|
+
command?: string;
|
|
169
|
+
/** Input keys read from positional arguments, in order. */
|
|
170
|
+
positional?: string[];
|
|
171
|
+
/** Human output, written verbatim. Without it the CLI prints JSON. `--json` always prints JSON. */
|
|
172
|
+
format?: (output: Output) => string;
|
|
173
|
+
/** `vitehub <namespace>` runs this command when no command is named. */
|
|
174
|
+
default?: boolean;
|
|
175
|
+
};
|
|
176
|
+
/** Largest request body in bytes. It can raise the 64 KiB default but not lower it. */
|
|
177
|
+
maxRequestBytes?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Returns true when this call only reads, such as a dry run of a `destructive` operation. The CLI then skips the
|
|
180
|
+
* confirmation, and agents run it without approval. Without it, every call of a `destructive` operation asks.
|
|
181
|
+
*/
|
|
182
|
+
readOnlyWhen?: (input: Input) => boolean;
|
|
183
|
+
/**
|
|
184
|
+
* How MCP offers the operation as a tool. `false`: MCP does not offer it, such as an editor transport that only the
|
|
185
|
+
* Console uses. `title`: the short title that clients show, instead of the name in words. `format`: the text of a
|
|
186
|
+
* result for the Agent, such as a list of lines. The result stays the structured content. Without `format`, the text
|
|
187
|
+
* is the result as JSON.
|
|
188
|
+
*/
|
|
189
|
+
mcp?: false | {
|
|
190
|
+
title?: string;
|
|
191
|
+
format?: (output: NoInfer<Output>) => string;
|
|
192
|
+
};
|
|
193
|
+
/** `false`: the operation never reads `context.user`, so the Console skips the session lookup for it. */
|
|
194
|
+
user?: false;
|
|
195
|
+
/**
|
|
196
|
+
* The operation runs code of the app, such as a workflow, a job, a task, or a schedule. The Console registers it only
|
|
197
|
+
* when `console.invoke` is on, which is the default in development and off in a production build.
|
|
198
|
+
*/
|
|
199
|
+
invoke?: true;
|
|
200
|
+
run: (input: Input, context: OperationContext) => Output | Promise<Output>;
|
|
201
|
+
}
|
|
202
|
+
/** An operation of any input and output, as a registry holds it. */
|
|
203
|
+
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
|
|
204
|
+
readOnlyWhen?: (input: never) => boolean;
|
|
205
|
+
cli?: {
|
|
206
|
+
namespace?: string;
|
|
207
|
+
command?: string;
|
|
208
|
+
default?: boolean;
|
|
209
|
+
positional?: string[];
|
|
210
|
+
format?: (output: never) => string;
|
|
211
|
+
};
|
|
212
|
+
mcp?: false | {
|
|
213
|
+
title?: string;
|
|
214
|
+
format?: (output: never) => string;
|
|
215
|
+
};
|
|
216
|
+
input: StandardSchemaV1;
|
|
217
|
+
output?: StandardSchemaV1;
|
|
218
|
+
run: (input: never, context: OperationContext) => unknown;
|
|
219
|
+
scope?: (input: never) => string | undefined;
|
|
220
|
+
section: string | false | ((input: never) => string | undefined);
|
|
221
|
+
}
|
|
222
|
+
/** The contribution of one plugin: operations, or a module that exports them. */
|
|
223
|
+
interface OperationContributionEntry {
|
|
224
|
+
/** The absolute path of the module that generated code imports, such as `ownModule(import.meta.url, "operations")`. */
|
|
225
|
+
module: string;
|
|
226
|
+
/** Named export that holds an operation or an array of operations. Defaults to `default`. */
|
|
227
|
+
export?: string;
|
|
228
|
+
/** Loads the export in the tool process, for a module that the tool cannot resolve by name. */
|
|
229
|
+
load?: () => Promise<unknown>;
|
|
230
|
+
/** `false`: the app already has these operations at runtime. Only tools such as the CLI and `vitehub inspect` read the entry. */
|
|
231
|
+
runtime?: false;
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
export { OperationContributionEntry as n, AnyOperation as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { a as isBlockingServerEnvEntry, c as runWithCloudflareEnv } from "./server-ChNL_Xc3.js";
|
|
2
|
+
import { detectHost } from "@vite-hub/runtime";
|
|
3
|
+
import { inspectServerEnv } from "#vitehub/env/server";
|
|
4
|
+
//#region src/runtime/operations.ts
|
|
5
|
+
function entryOf(entry) {
|
|
6
|
+
return {
|
|
7
|
+
...entry.path === void 0 ? {} : { path: entry.path },
|
|
8
|
+
...entry.names === void 0 ? {} : { names: [...entry.names] },
|
|
9
|
+
...entry.name === void 0 ? {} : { name: entry.name },
|
|
10
|
+
source: entry.source,
|
|
11
|
+
...entry.provider === void 0 ? {} : { provider: entry.provider },
|
|
12
|
+
required: entry.required,
|
|
13
|
+
secret: entry.masked,
|
|
14
|
+
status: entry.status,
|
|
15
|
+
blocking: isBlockingServerEnvEntry(entry),
|
|
16
|
+
...entry.conflict ? { conflict: true } : {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Runs `env.inspect`: the Server Env status of the app, with the Worker bindings of the call on Cloudflare. */
|
|
20
|
+
async function inspectEnvOperation(context) {
|
|
21
|
+
const entries = (await (context.env ? runWithCloudflareEnv(context.env, () => inspectServerEnv()) : inspectServerEnv())).entries.map(entryOf);
|
|
22
|
+
const host = detectHost();
|
|
23
|
+
return {
|
|
24
|
+
entries,
|
|
25
|
+
ok: !entries.some((entry) => entry.blocking),
|
|
26
|
+
...host ? { host } : {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { inspectEnvOperation };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { K as ServerEnvInspectionEntry, q as ServerEnvInspectionStatus } from "./bridge-Cs9YfQWk.js";
|
|
2
|
+
import { t as AnyOperation } from "./operation-definition-8gOe-ubD.js";
|
|
3
|
+
import { ViteHubHost } from "@vite-hub/runtime";
|
|
4
|
+
//#region src/runtime/operations.d.ts
|
|
5
|
+
/** One Server Env declaration as the running app sees it. It never holds a value, a preview, or a length. */
|
|
6
|
+
interface EnvInspectEntry {
|
|
7
|
+
/** The declaration path, such as `env.server.stripe.key`. */
|
|
8
|
+
path?: string;
|
|
9
|
+
/** The host variable names that the declaration reads, in read order. */
|
|
10
|
+
names?: readonly string[];
|
|
11
|
+
/** The host variable name that supplied the value. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Where the value comes from: a host variable, a literal, or a provider. */
|
|
14
|
+
source: ServerEnvInspectionEntry["source"];
|
|
15
|
+
/** The provider alias of a provider-backed declaration. */
|
|
16
|
+
provider?: string;
|
|
17
|
+
required: boolean;
|
|
18
|
+
secret: boolean;
|
|
19
|
+
status: ServerEnvInspectionStatus;
|
|
20
|
+
/** The entry makes `loadServerEnv()` fail. */
|
|
21
|
+
blocking: boolean;
|
|
22
|
+
/** The canonical name and a conventional name hold different values. The canonical name wins. */
|
|
23
|
+
conflict?: true;
|
|
24
|
+
}
|
|
25
|
+
interface EnvInspectResult {
|
|
26
|
+
entries: EnvInspectEntry[];
|
|
27
|
+
/** No entry is blocking. */
|
|
28
|
+
ok: boolean;
|
|
29
|
+
/** The host that the app runs on, such as `cloudflare`, so a fix can name `vitehub env push --host <host>`. */
|
|
30
|
+
host?: ViteHubHost;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/operations.d.ts
|
|
34
|
+
/** The `env.*` operations. The Console, the CLI, and agents run them on the signed `POST /_vitehub/rpc` endpoint. */
|
|
35
|
+
export declare const envOperations: readonly AnyOperation[];
|
|
36
|
+
//#endregion
|
|
37
|
+
export type { EnvInspectEntry, EnvInspectResult };
|