@vite-hub/runtime 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-Crv8CV_r.js +1103 -0
- package/dist/core-auTkK4iZ.d.ts +298 -0
- package/dist/durability.d.ts +3 -5
- package/dist/durability.js +5 -3
- package/dist/{error-diagnostics-BM9W4pBg.js → error-diagnostics-Dj98U7ch.js} +1 -2
- package/dist/{error-diagnostics-0sYgKTT8.d.ts → error-diagnostics-DuusexaK.d.ts} +0 -2
- package/dist/{errors-BQ0ofIL4.js → errors-D2ixvqv3.js} +2 -3
- package/dist/{execution-budget-BPXbISEt.d.ts → execution-budget-Bv7h0-5V.d.ts} +0 -2
- package/dist/hosted-console-DTh9zwNz.d.ts +28 -0
- package/dist/index-hFKl7B_y.d.ts +345 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +6 -5
- package/dist/internal/console.d.ts +5 -0
- package/dist/internal/console.js +1 -0
- package/dist/internal/context.d.ts +2 -0
- package/dist/internal/context.js +1 -0
- package/dist/internal/drain.d.ts +1 -3
- package/dist/internal/drain.js +3 -5
- package/dist/internal/error-diagnostics.d.ts +2 -0
- package/dist/internal/error-diagnostics.js +1 -0
- package/dist/internal/execution-budget.d.ts +2 -3
- package/dist/internal/execution-budget.js +226 -3
- package/dist/internal/grant.d.ts +1 -2
- package/dist/internal/grant.js +3 -4
- package/dist/internal/h3.d.ts +2 -4
- package/dist/internal/h3.js +4 -12
- package/dist/internal/node.d.ts +2 -3
- package/dist/internal/node.js +2 -3
- package/dist/internal/public-url.d.ts +2 -2
- package/dist/internal/public-url.js +1 -2
- package/dist/internal/response.d.ts +2 -0
- package/dist/internal/response.js +1 -0
- package/dist/internal/run-failed.d.ts +1 -3
- package/dist/internal/run-failed.js +1 -3
- package/dist/internal/run-scope.d.ts +1 -3
- package/dist/internal/run-scope.js +1 -2
- package/dist/internal/runtime-type.d.ts +1 -3
- package/dist/internal/runtime-type.js +2 -2
- package/dist/internal/shutdown.d.ts +1 -3
- package/dist/internal/shutdown.js +18 -21
- package/dist/internal/test-mode-setup.d.ts +1 -3
- package/dist/internal/test-mode-setup.js +1 -6
- package/dist/internal/test-mode.d.ts +1 -3
- package/dist/internal/test-mode.js +1 -2
- package/dist/internal/trace.d.ts +4 -0
- package/dist/internal/trace.js +1 -0
- package/dist/operations.d.ts +7 -4
- package/dist/operations.js +14 -11
- package/dist/{public-url-1WeOw54Z.d.ts → public-url-B4p8EOqr.d.ts} +6 -3
- package/dist/{public-url-ByAmAjbP.js → public-url-DDh_BHz3.js} +27 -22
- package/dist/request-context-Ci5FjuUY.js +680 -0
- package/dist/response-ClQ9ZSS_.d.ts +31 -0
- package/dist/response-DEyMvEBF.js +430 -0
- package/dist/{runtime-type-BftydMAf.js → runtime-type-EgaBGoVU.js} +2 -11
- package/package.json +29 -4
- package/dist/index-C1DoYfCf.d.ts +0 -733
- package/dist/request-context-uRQpodgl.js +0 -2433
package/dist/operations.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
//#region ../internal/dist/operation-definition-BQGzmZRs.d.ts
|
|
3
|
-
//#region src/operation-definition.d.ts
|
|
4
2
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
5
3
|
type OperationKind = "read" | "write" | "destructive";
|
|
6
4
|
/** The signed-in user of a call. */
|
|
@@ -29,6 +27,11 @@ interface OperationAccess {
|
|
|
29
27
|
*/
|
|
30
28
|
readonly sections: "all" | readonly string[];
|
|
31
29
|
readonly user?: OperationUser;
|
|
30
|
+
/**
|
|
31
|
+
* Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
|
|
32
|
+
* account and not an app user, or `"cli"` for a key. Not set for other calls.
|
|
33
|
+
*/
|
|
34
|
+
readonly via?: "console" | "cli";
|
|
32
35
|
}
|
|
33
36
|
interface OperationContext {
|
|
34
37
|
/** The checked Console access of the call. */
|
|
@@ -91,7 +94,8 @@ interface OperationDefinition<Input, Output> {
|
|
|
91
94
|
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
92
95
|
input: StandardSchemaV1<unknown, Input>;
|
|
93
96
|
output?: StandardSchemaV1<unknown, Output>;
|
|
94
|
-
|
|
97
|
+
/** `false`: no `vitehub` command. The Console and MCP still call the operation. */
|
|
98
|
+
cli?: false | {
|
|
95
99
|
/** Defaults: namespace = section, command = verb. */
|
|
96
100
|
namespace?: string;
|
|
97
101
|
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
@@ -168,5 +172,4 @@ interface OperationContributingPlugin {
|
|
|
168
172
|
operations?: OperationContributions;
|
|
169
173
|
};
|
|
170
174
|
}
|
|
171
|
-
//#endregion
|
|
172
175
|
export { type OperationAccess, type OperationActor, type OperationContext, type OperationContributingPlugin, type OperationContributionEntry, type OperationContributions, type OperationDefinition, type OperationFailure, type OperationKind, type OperationResult, type OperationUser, defineOperation };
|
package/dist/operations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
2
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
3
|
-
|
|
3
|
+
// ../internal/dist/error-diagnostics-B5oT1e3D.js
|
|
4
4
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
5
5
|
const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
6
6
|
docsBase: "https://vitehub.dev/docs/development/diagnostics",
|
|
@@ -26,7 +26,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
26
26
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
27
27
|
},
|
|
28
28
|
INTERNAL_R0022: {
|
|
29
|
-
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
|
|
29
|
+
fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
|
|
30
30
|
why: ({ message }) => message === void 0 ? "" : String(message)
|
|
31
31
|
},
|
|
32
32
|
INTERNAL_R0024: {
|
|
@@ -245,6 +245,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
245
245
|
why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
|
|
246
246
|
fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
|
|
247
247
|
},
|
|
248
|
+
INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
|
|
249
|
+
why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
|
|
250
|
+
fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
|
|
251
|
+
},
|
|
248
252
|
INTERNAL_SECRET_PURPOSE_MISSING: {
|
|
249
253
|
why: "[vitehub] A derived secret requires a purpose.",
|
|
250
254
|
fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
|
|
@@ -253,6 +257,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
253
257
|
why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
|
|
254
258
|
fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
|
|
255
259
|
},
|
|
260
|
+
INTERNAL_SITE_TOKEN_TOO_LONG: {
|
|
261
|
+
why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
|
|
262
|
+
fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
|
|
263
|
+
},
|
|
256
264
|
INTERNAL_SQLITE_ARGUMENT_INVALID: {
|
|
257
265
|
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",
|
|
258
266
|
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."
|
|
@@ -267,14 +275,12 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
267
275
|
}
|
|
268
276
|
}
|
|
269
277
|
});
|
|
270
|
-
|
|
271
|
-
//#region ../internal/dist/object.js
|
|
278
|
+
// ../internal/dist/object.js
|
|
272
279
|
/** A non-null object or a function that is not an array. */
|
|
273
280
|
function isRecordOrFunction(value) {
|
|
274
281
|
return Object(value) === value && !Array.isArray(value);
|
|
275
282
|
}
|
|
276
|
-
|
|
277
|
-
//#region ../internal/dist/standard-schema.js
|
|
283
|
+
// ../internal/dist/standard-schema.js
|
|
278
284
|
function readOwn(value, key) {
|
|
279
285
|
if (value === null || Object(value) !== value) return;
|
|
280
286
|
try {
|
|
@@ -303,8 +309,7 @@ function standardJsonSchema(schema, direction, target = "draft-2020-12", library
|
|
|
303
309
|
return;
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
|
-
|
|
307
|
-
//#region ../internal/dist/valibot.js
|
|
312
|
+
// ../internal/dist/valibot.js
|
|
308
313
|
const valibotTargets = /* @__PURE__ */ new Set([
|
|
309
314
|
"draft-07",
|
|
310
315
|
"draft-2020-12",
|
|
@@ -345,8 +350,7 @@ function withValibotJsonSchema(schema, options = {}) {
|
|
|
345
350
|
}
|
|
346
351
|
};
|
|
347
352
|
}
|
|
348
|
-
|
|
349
|
-
//#region ../internal/dist/operation-definition.js
|
|
353
|
+
// ../internal/dist/operation-definition.js
|
|
350
354
|
const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
|
|
351
355
|
const kinds = /* @__PURE__ */ new Set([
|
|
352
356
|
"read",
|
|
@@ -406,5 +410,4 @@ function isSectionId(section) {
|
|
|
406
410
|
function operationInputJsonSchema(operation) {
|
|
407
411
|
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
408
412
|
}
|
|
409
|
-
//#endregion
|
|
410
413
|
export { defineOperation };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/public-url.d.ts
|
|
2
1
|
/** Public origins resolved from `vitehub({ publicUrl })` at build time. */
|
|
3
2
|
interface PublicUrlConfig {
|
|
4
3
|
/** One origin for the whole deployment. */
|
|
@@ -10,6 +9,11 @@ interface PublicUrlConfig {
|
|
|
10
9
|
declare function resetPublicUrlAgentNames(): void;
|
|
11
10
|
/** Associate an evaluated Agent name with the identity used by build-time URL configuration. */
|
|
12
11
|
declare function registerPublicUrlAgentName(name: string, discoveredName: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* The origins of `vitehub({ publicUrl })`: the one origin, or the origin of each Agent of the function form. Empty when
|
|
14
|
+
* `publicUrl` is not set, such as in `vite dev` without a signed Console.
|
|
15
|
+
*/
|
|
16
|
+
declare function configuredPublicOrigins(): string[];
|
|
13
17
|
/**
|
|
14
18
|
* Resolve the public origin of this deployment.
|
|
15
19
|
*
|
|
@@ -30,5 +34,4 @@ declare function resolvePublicUrl(options?: {
|
|
|
30
34
|
* `origin` must not include the application base path. The hosted Console checks the project URL when it opens the link.
|
|
31
35
|
*/
|
|
32
36
|
declare function consoleInvocationUrl(origin: string, agentName: string, invocationId: string): string;
|
|
33
|
-
|
|
34
|
-
export { resolvePublicUrl as a, resetPublicUrlAgentNames as i, consoleInvocationUrl as n, registerPublicUrlAgentName as r, PublicUrlConfig as t };
|
|
37
|
+
export { resetPublicUrlAgentNames as a, registerPublicUrlAgentName as i, configuredPublicOrigins as n, resolvePublicUrl as o, consoleInvocationUrl as r, PublicUrlConfig as t };
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { t as runtimeErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
|
|
3
|
-
const plainSegment = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
4
|
-
function encodeRouteSegment(value) {
|
|
5
|
-
if (plainSegment.test(value)) return value;
|
|
6
|
-
let encoded = "~";
|
|
7
|
-
for (let index = 0; index < value.length; index++) encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
|
|
8
|
-
return encoded;
|
|
9
|
-
}
|
|
10
|
-
function decodeRouteSegment(segment) {
|
|
11
|
-
if (plainSegment.test(segment)) return segment;
|
|
12
|
-
if (!/^~(?:[0-9a-f]{4})+$/.test(segment)) return;
|
|
13
|
-
let value = "";
|
|
14
|
-
for (let index = 1; index < segment.length; index += 4) value += String.fromCharCode(Number.parseInt(segment.slice(index, index + 4), 16));
|
|
15
|
-
return encodeRouteSegment(value) === segment ? value : void 0;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/hosted-console.ts
|
|
1
|
+
import { t as runtimeErrorDiagnostics } from "./error-diagnostics-Dj98U7ch.js";
|
|
2
|
+
// src/hosted-console.ts
|
|
19
3
|
/** The origin of the hosted Console. */
|
|
20
4
|
const hostedConsoleOrigin = "https://console.vitehub.dev";
|
|
21
5
|
const loopbackHosts = /* @__PURE__ */ new Set([
|
|
@@ -84,8 +68,22 @@ function hostedConsoleUrl(projectUrl, path, consoleOrigin = hostedConsoleOrigin)
|
|
|
84
68
|
}).toString();
|
|
85
69
|
return url.href;
|
|
86
70
|
}
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
// src/route-segment.ts
|
|
72
|
+
const plainSegment = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
73
|
+
function encodeRouteSegment(value) {
|
|
74
|
+
if (plainSegment.test(value)) return value;
|
|
75
|
+
let encoded = "~";
|
|
76
|
+
for (let index = 0; index < value.length; index++) encoded += value.charCodeAt(index).toString(16).padStart(4, "0");
|
|
77
|
+
return encoded;
|
|
78
|
+
}
|
|
79
|
+
function decodeRouteSegment(segment) {
|
|
80
|
+
if (plainSegment.test(segment)) return segment;
|
|
81
|
+
if (!/^~(?:[0-9a-f]{4})+$/.test(segment)) return;
|
|
82
|
+
let value = "";
|
|
83
|
+
for (let index = 1; index < segment.length; index += 4) value += String.fromCharCode(Number.parseInt(segment.slice(index, index + 4), 16));
|
|
84
|
+
return encodeRouteSegment(value) === segment ? value : void 0;
|
|
85
|
+
}
|
|
86
|
+
// src/public-url.ts
|
|
89
87
|
const publicUrlAgentNames = /* @__PURE__ */ new Map();
|
|
90
88
|
/** Replace aliases when a generated Agent registry is installed. */
|
|
91
89
|
function resetPublicUrlAgentNames() {
|
|
@@ -103,6 +101,14 @@ function applicationBasePath() {
|
|
|
103
101
|
const segments = (typeof __VITEHUB_APP_BASE_URL__ === "undefined" ? "/" : __VITEHUB_APP_BASE_URL__).split("/").filter(Boolean);
|
|
104
102
|
return segments.length ? `/${segments.join("/")}` : "";
|
|
105
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* The origins of `vitehub({ publicUrl })`: the one origin, or the origin of each Agent of the function form. Empty when
|
|
106
|
+
* `publicUrl` is not set, such as in `vite dev` without a signed Console.
|
|
107
|
+
*/
|
|
108
|
+
function configuredPublicOrigins() {
|
|
109
|
+
const config = publicUrlConfig();
|
|
110
|
+
return config.url ? [config.url] : [...new Set(Object.values(config.agents ?? {}))];
|
|
111
|
+
}
|
|
106
112
|
function configuredAgentUrl(config, name) {
|
|
107
113
|
return config.agents && Object.hasOwn(config.agents, name) ? config.agents[name] : void 0;
|
|
108
114
|
}
|
|
@@ -136,5 +142,4 @@ function consoleInvocationUrl(origin, agentName, invocationId) {
|
|
|
136
142
|
const path = `/agents/${encodeRouteSegment(agentName)}/invocations/${encodeURIComponent(invocationId)}`;
|
|
137
143
|
return `${hostedConsoleOrigin}/open?project=${encodeURIComponent(project)}&path=${encodeURIComponent(path)}`;
|
|
138
144
|
}
|
|
139
|
-
|
|
140
|
-
export { hostedConsoleOrigin as a, normalizeConsoleProjectUrl as c, resolvePublicUrl as i, decodeRouteSegment as l, registerPublicUrlAgentName as n, hostedConsoleUrl as o, resetPublicUrlAgentNames as r, normalizeConsolePath as s, consoleInvocationUrl as t, encodeRouteSegment as u };
|
|
145
|
+
export { resolvePublicUrl as a, hostedConsoleOrigin as c, normalizeConsoleProjectUrl as d, resetPublicUrlAgentNames as i, hostedConsoleUrl as l, consoleInvocationUrl as n, decodeRouteSegment as o, registerPublicUrlAgentName as r, encodeRouteSegment as s, configuredPublicOrigins as t, normalizeConsolePath as u };
|