@vite-hub/env 0.1.0 → 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 +178 -33
- package/dist/{access-B3qzBHye.js → access-B8lSDip4.js} +1 -1
- package/dist/{bridge-CdNdTN1V.d.ts → bridge-Cs9YfQWk.d.ts} +111 -38
- package/dist/{bridge-error-CFuU5zIz.js → bridge-error-BhJ77age.js} +14 -13
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +168 -6
- package/dist/cli-BPp7rdcA.d.ts +159 -0
- package/dist/{cli-CMQPQbii.js → cli-DLpY0QAo.js} +212 -30
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +1 -1
- package/dist/database.d.ts +29 -3
- package/dist/database.js +106 -15
- package/dist/declarations-C5XR3aKw.d.ts +58 -0
- package/dist/error-diagnostics-B8RFjQ1V.js +56 -0
- package/dist/index.d.ts +145 -10
- package/dist/index.js +240 -7
- package/dist/internal/agent.d.ts +1 -1
- package/dist/internal/agent.js +2 -2
- package/dist/internal/connections.d.ts +1 -1
- package/dist/internal/connections.js +2 -2
- 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 +8 -5
- package/dist/seal.js +9 -6
- 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 -25
- package/dist/server.js +2 -2
- package/dist/virtual-module.d.ts +6 -6
- package/dist/vite.d.ts +59 -14
- package/dist/vite.js +304 -115
- package/package.json +27 -38
- package/dist/auth.d.ts +0 -32
- package/dist/auth.js +0 -44
- package/dist/cli-DEwcUIe0.d.ts +0 -81
- package/dist/declarations-CiRdb1qP.d.ts +0 -32
- package/dist/declarations-DAVgctKD.js +0 -236
- package/dist/error-diagnostics-CrxjYNYr.js +0 -43
- package/dist/http.d.ts +0 -2
- package/dist/http.js +0 -122
- package/dist/presets.d.ts +0 -20
- package/dist/presets.js +0 -44
- package/dist/provider.d.ts +0 -5
- package/dist/provider.js +0 -8
- package/dist/schema.d.ts +0 -15
- package/dist/schema.js +0 -55
- package/dist/secret-C2191nAa.d.ts +0 -11
- package/dist/secret.d.ts +0 -2
- package/dist/server-DufVswRJ.js +0 -670
- package/dist/values-D_r6V774.js +0 -148
|
@@ -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 };
|