@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.
Files changed (57) hide show
  1. package/dist/core-Crv8CV_r.js +1103 -0
  2. package/dist/core-auTkK4iZ.d.ts +298 -0
  3. package/dist/durability.d.ts +3 -5
  4. package/dist/durability.js +5 -3
  5. package/dist/{error-diagnostics-BM9W4pBg.js → error-diagnostics-Dj98U7ch.js} +1 -2
  6. package/dist/{error-diagnostics-0sYgKTT8.d.ts → error-diagnostics-DuusexaK.d.ts} +0 -2
  7. package/dist/{errors-BQ0ofIL4.js → errors-D2ixvqv3.js} +2 -3
  8. package/dist/{execution-budget-BPXbISEt.d.ts → execution-budget-Bv7h0-5V.d.ts} +0 -2
  9. package/dist/hosted-console-DTh9zwNz.d.ts +28 -0
  10. package/dist/index-hFKl7B_y.d.ts +345 -0
  11. package/dist/index.d.ts +7 -5
  12. package/dist/index.js +6 -5
  13. package/dist/internal/console.d.ts +5 -0
  14. package/dist/internal/console.js +1 -0
  15. package/dist/internal/context.d.ts +2 -0
  16. package/dist/internal/context.js +1 -0
  17. package/dist/internal/drain.d.ts +1 -3
  18. package/dist/internal/drain.js +3 -5
  19. package/dist/internal/error-diagnostics.d.ts +2 -0
  20. package/dist/internal/error-diagnostics.js +1 -0
  21. package/dist/internal/execution-budget.d.ts +2 -3
  22. package/dist/internal/execution-budget.js +226 -3
  23. package/dist/internal/grant.d.ts +1 -2
  24. package/dist/internal/grant.js +3 -4
  25. package/dist/internal/h3.d.ts +2 -4
  26. package/dist/internal/h3.js +4 -12
  27. package/dist/internal/node.d.ts +2 -3
  28. package/dist/internal/node.js +2 -3
  29. package/dist/internal/public-url.d.ts +2 -2
  30. package/dist/internal/public-url.js +1 -2
  31. package/dist/internal/response.d.ts +2 -0
  32. package/dist/internal/response.js +1 -0
  33. package/dist/internal/run-failed.d.ts +1 -3
  34. package/dist/internal/run-failed.js +1 -3
  35. package/dist/internal/run-scope.d.ts +1 -3
  36. package/dist/internal/run-scope.js +1 -2
  37. package/dist/internal/runtime-type.d.ts +1 -3
  38. package/dist/internal/runtime-type.js +2 -2
  39. package/dist/internal/shutdown.d.ts +1 -3
  40. package/dist/internal/shutdown.js +18 -21
  41. package/dist/internal/test-mode-setup.d.ts +1 -3
  42. package/dist/internal/test-mode-setup.js +1 -6
  43. package/dist/internal/test-mode.d.ts +1 -3
  44. package/dist/internal/test-mode.js +1 -2
  45. package/dist/internal/trace.d.ts +4 -0
  46. package/dist/internal/trace.js +1 -0
  47. package/dist/operations.d.ts +7 -4
  48. package/dist/operations.js +14 -11
  49. package/dist/{public-url-1WeOw54Z.d.ts → public-url-B4p8EOqr.d.ts} +6 -3
  50. package/dist/{public-url-ByAmAjbP.js → public-url-DDh_BHz3.js} +27 -22
  51. package/dist/request-context-Ci5FjuUY.js +680 -0
  52. package/dist/response-ClQ9ZSS_.d.ts +31 -0
  53. package/dist/response-DEyMvEBF.js +430 -0
  54. package/dist/{runtime-type-BftydMAf.js → runtime-type-EgaBGoVU.js} +2 -11
  55. package/package.json +29 -4
  56. package/dist/index-C1DoYfCf.d.ts +0 -733
  57. package/dist/request-context-uRQpodgl.js +0 -2433
@@ -0,0 +1,345 @@
1
+ import { O as RuntimeContextInput, dt as ViteHubContext, g as MaybePromise, k as RuntimeHostContext, p as CreatedRuntimeContext, pt as ViteHubStandardProps } from "./core-auTkK4iZ.js";
2
+ import "./execution-budget-Bv7h0-5V.js";
3
+ import { Diagnostic, DiagnosticDefinition, DiagnosticJSON, Diagnostics } from "nostics";
4
+ /**
5
+ * Error of a ViteHub operation. It is a Nostics diagnostic with a typed `code`.
6
+ *
7
+ * - `code` names the failure, for example `KV_INVALID_CURSOR`. `name` has the same code.
8
+ * - `why` tells what went wrong. `message` has the same text.
9
+ * - `fix` tells what to do next.
10
+ * - `docs` links to the code on vitehub.dev.
11
+ * - `cause` keeps the lower-level error, for example the provider error.
12
+ * - `data` keeps catalog metadata in memory. Its type is inferred by `defineErrors()`.
13
+ * - `status` is the HTTP status that `toResponse(error)` answers, when the catalog code sets one. Without it, 500.
14
+ */
15
+ interface ResultError<TCode extends string = string, TData = unknown> extends Diagnostic<TData, TCode> {
16
+ /** HTTP status of the code, for example 409 for a conflict. `toResponse(error)` answers 500 without it. */
17
+ readonly status?: number;
18
+ /** Retains the Nostics serializer type for compatibility; runtime JSON is redacted. */
19
+ toJSON(): DiagnosticJSON<TData> & {
20
+ code: TCode;
21
+ name: TCode;
22
+ why: string;
23
+ fix: string | undefined;
24
+ docs: string | undefined;
25
+ };
26
+ }
27
+ /**
28
+ * `[error, data]` tuple that each ViteHub runtime operation returns.
29
+ * Check `error` first. When `error` is `undefined`, `data` has the value.
30
+ */
31
+ type Result<TData, TCode extends string = string> = [error: ResultError<TCode>, data: undefined] | [error: undefined, data: TData];
32
+ /**
33
+ * Code map that `defineErrors()` accepts. `is` is reserved for `ErrorCatalog.is`.
34
+ * `status` is the HTTP status that `toResponse(error)` answers for the code, such as 409 for a conflict. Without it, 500.
35
+ */
36
+ type ErrorCodes = Record<string, DiagnosticDefinition & {
37
+ status?: number;
38
+ }> & {
39
+ is?: never;
40
+ };
41
+ type CatalogCode<TCodes> = Exclude<keyof TCodes, "is"> & string;
42
+ type CatalogHandles<TCodes extends Record<string, DiagnosticDefinition>> = Diagnostics<TCodes, []>;
43
+ type CatalogData<TCodes extends Record<string, DiagnosticDefinition>, TCode extends CatalogCode<TCodes>> = ReturnType<CatalogHandles<TCodes>[TCode]>["data"];
44
+ /** One code of an error catalog. Call it to create the error, or use `is` to check an error. */
45
+ interface ErrorHandle<TArgs extends unknown[], TCode extends string, TData> {
46
+ (...args: TArgs): ResultError<TCode, TData>;
47
+ /**
48
+ * Checks if `error` is a live Nostics error with this code, and narrows its `data`.
49
+ * It reads `code`, so it also accepts an error from another copy of the package or another realm.
50
+ * Safe to pass unbound, for example `errors.filter(catalog.CODE.is)`.
51
+ */
52
+ is: (error: unknown) => error is ResultError<TCode, TData>;
53
+ }
54
+ /**
55
+ * Error catalog of one package. Each code creates a `ResultError` with that code.
56
+ * `is` checks if an error has a code of this catalog. `is` is not enumerable, so `Object.keys()` gives only the codes.
57
+ * Use `InferDiagnosticCodes<typeof catalog>` from `nostics` for the union of the codes.
58
+ */
59
+ type ErrorCatalog<TCodes extends Record<string, DiagnosticDefinition>> = {
60
+ /**
61
+ * Checks if `error` is a live Nostics error with a code of this catalog, and narrows its `code` and `data`.
62
+ * It reads `code`, so it also accepts an error from another copy of the package or another realm.
63
+ */
64
+ is: (error: unknown) => error is { [TCode in CatalogCode<TCodes>]: ResultError<TCode, CatalogData<TCodes, TCode>>; }[CatalogCode<TCodes>];
65
+ } & { [TCode in CatalogCode<TCodes>]: ErrorHandle<Parameters<CatalogHandles<TCodes>[TCode]>, TCode, CatalogData<TCodes, TCode>>; };
66
+ interface DefineErrorsOptions<TCodes extends Record<string, DiagnosticDefinition>> {
67
+ /** Each code with a `why` and a `fix`, and an optional HTTP `status`. */
68
+ codes: TCodes;
69
+ /** Base URL of the diagnostics pages, which have one page for each code. The `docs` URL of an error is `<docs>/<code in lowercase>`. */
70
+ docs: string;
71
+ }
72
+ /**
73
+ * Prepares a recognized diagnostic for a result, keeping its metadata in memory.
74
+ * Reuses mutable diagnostics; copies diagnostics whose name or serializer cannot be replaced.
75
+ * Sets name to code to match the result contract, including diagnostics renamed by their owner.
76
+ * The caller owns code allowlisting and the public text. JSON includes only the public fields.
77
+ */
78
+ declare function toResultError<TCode extends string, TData>(error: (Diagnostic<TData> | ResultError<string, TData>) & {
79
+ readonly code: TCode;
80
+ }): ResultError<TCode, TData>;
81
+ /**
82
+ * Defines the error catalog of a package with Nostics.
83
+ * Return runtime errors as `[error, undefined]`. Throw definition and config errors.
84
+ */
85
+ declare function defineErrors<const TCodes extends ErrorCodes>(options: DefineErrorsOptions<TCodes>): ErrorCatalog<TCodes>;
86
+ type LeaseOperation = "acquire" | "get" | "release" | "renew";
87
+ /** The codes that lease operations return. */
88
+ type LeaseErrorCode = "RUNTIME_LEASE_FAILED" | "RUNTIME_LEASE_INVALID_TTL";
89
+ /** One live lease as the store keeps it. */
90
+ interface LeaseRecord {
91
+ /** The value that the caller locks, such as `schedule:daily:2026-11-09`. */
92
+ key: string;
93
+ /** A new random ID for each acquire. Release and renew act only when the stored ID is still this one. */
94
+ id: string;
95
+ /** The label from `acquire()`, such as an instance name. It is for inspection only. */
96
+ owner?: string;
97
+ /** When the lease ends, from the clock of the store. */
98
+ expiresAt: Date;
99
+ }
100
+ /** A lease that this caller holds. */
101
+ interface Lease extends LeaseRecord {
102
+ /**
103
+ * Moves the end of the lease to `ttl` seconds from now. The default is the TTL of `acquire()`. Resolves `false` when
104
+ * the lease is no longer this caller's, because another caller acquired it after it expired. On `true`, `expiresAt`
105
+ * has the new end.
106
+ */
107
+ renew(options?: {
108
+ ttl?: number;
109
+ }): Promise<Result<boolean, LeaseErrorCode>>;
110
+ /** Frees the lease. Resolves `false` and changes nothing when another caller holds the key now. */
111
+ release(): Promise<Result<boolean, "RUNTIME_LEASE_FAILED">>;
112
+ }
113
+ interface LeaseAcquireOptions {
114
+ /** Seconds until the lease ends when the holder does not renew or release it. Fractions are allowed. */
115
+ ttl: number;
116
+ /** A label for the holder. The default is `getInstanceId()`. Acquire does not compare it. */
117
+ owner?: string;
118
+ }
119
+ /**
120
+ * Gives one caller at a time a lease on a key. A lease ends at `release()` or when its TTL passes, so a holder that
121
+ * crashes blocks the key only until then. Leases are not reentrant: a held key refuses every other acquire, also from
122
+ * the same owner.
123
+ */
124
+ interface LeaseStore {
125
+ /** Takes the lease when the key is free or its lease expired. Resolves `null` when another caller holds it. */
126
+ acquire(key: string, options: LeaseAcquireOptions): Promise<Result<Lease | null, LeaseErrorCode>>;
127
+ /** The live lease on the key, or `null`. */
128
+ get(key: string): Promise<Result<LeaseRecord | null, "RUNTIME_LEASE_FAILED">>;
129
+ }
130
+ /**
131
+ * Leases in the memory of this process. Use it for one instance and for tests. Several instances need a shared store,
132
+ * such as `createSqlLeaseStore()`.
133
+ */
134
+ declare function createMemoryLeaseStore(): LeaseStore;
135
+ /**
136
+ * The SQL connection that `createSqlLeaseStore()` uses. `query()` runs one statement with positional parameters and
137
+ * resolves its rows as objects keyed by column name.
138
+ *
139
+ * - `postgresql`: the SQL text uses `$1`, `$2`, and so on, like postgres.js `sql.unsafe(text, params)`.
140
+ * - `sqlite`: the SQL text uses `?`, like libSQL `client.execute({ sql, args })`. The store runs a statement that fails
141
+ * with `SQLITE_BUSY` again. Across several processes, use Postgres, remote libSQL, or `node:sqlite`. A local libSQL
142
+ * `file:` client is for one process only: after `SQLITE_BUSY` it can lose writes that it reported as done.
143
+ */
144
+ interface LeaseSqlClient {
145
+ dialect: "postgresql" | "sqlite";
146
+ query(sql: string, params: LeaseSqlParam[]): Promise<readonly Record<string, unknown>[]>;
147
+ }
148
+ /** The parameter values that the lease statements pass. */
149
+ type LeaseSqlParam = string | number | null;
150
+ /**
151
+ * Leases in a SQL table, shared by every process that uses the same Database. Each operation is one statement, so
152
+ * two processes that acquire a key at the same time get one winner. Expiry uses the clock of the Database, not the
153
+ * clocks of the hosts. Works on Postgres and on SQLite 3.35 or later, such as libSQL.
154
+ */
155
+ declare function createSqlLeaseStore(client: LeaseSqlClient): LeaseStore;
156
+ /** The environment variable that names this server instance. */
157
+ declare const instanceIdEnv = "VITEHUB_INSTANCE_ID";
158
+ /**
159
+ * The owner label of this server instance: `VITEHUB_INSTANCE_ID` when it is set, else `<hostname>:<pid>:<random>`, made
160
+ * once for each process. Leases record it as their `owner`, and Agent Invocation claims start with it, so you can see
161
+ * which instance holds a key or runs an Invocation. Give each instance its own value, such as the pod or machine name.
162
+ */
163
+ declare function getInstanceId(): string;
164
+ /** The units of a {@link Duration}, short and long. Case does not matter at runtime. */
165
+ type DurationUnit = "ms" | "millisecond" | "milliseconds" | "s" | "sec" | "secs" | "second" | "seconds" | "m" | "min" | "mins" | "minute" | "minutes" | "h" | "hr" | "hrs" | "hour" | "hours" | "d" | "day" | "days" | "w" | "week" | "weeks";
166
+ /** A length of time as a number and a unit, such as `"30s"`, `"5m"`, `"2 hours"`, or `"1 day"`. */
167
+ type Duration = `${number}${DurationUnit}` | `${number} ${DurationUnit}`;
168
+ /**
169
+ * Reads a {@link Duration} such as `"30s"`, `"5m"`, or `"1 day"` and returns its milliseconds. A number, a negative
170
+ * value, an unknown unit, or a value too large for a number throws `RUNTIME_DURATION_INVALID`. Pass `option`, such as
171
+ * `"debounce"`, so the error names the option. Pass `"ceil"` to round up to whole milliseconds before converting
172
+ * to a number. For a number, the fix shows the same time as a string. Pass `"s"` as `legacyUnit` when the option took a
173
+ * number of seconds before, so `60` gets the fix `"1m"` and not `"60ms"`. It changes only the fix text.
174
+ *
175
+ * ```ts
176
+ * parseDuration("90s") // 90000
177
+ * parseDuration("1 day") // 86400000
178
+ * ```
179
+ */
180
+ declare function parseDuration(value: Duration, option?: string, round?: "ceil", legacyUnit?: "ms" | "s"): number;
181
+ type RuntimeDiagnosticLevel = "debug" | "error" | "info" | "warn";
182
+ type RuntimeResourceScope = "container" | "host" | "process" | "service" | "workload";
183
+ type RuntimeResourceUnit = "bytes" | "count" | "microseconds" | "ratio";
184
+ interface RuntimeDiagnosticError {
185
+ cause?: RuntimeDiagnosticError;
186
+ code?: number | string;
187
+ details?: Readonly<Record<string, unknown>>;
188
+ docs?: string;
189
+ errors?: readonly RuntimeDiagnosticError[];
190
+ fix?: string;
191
+ message: string;
192
+ name?: string;
193
+ requestId?: string;
194
+ sources?: readonly string[];
195
+ stack?: string;
196
+ status?: number | string;
197
+ statusCode?: number | string;
198
+ }
199
+ interface RuntimeDiagnosticEvent {
200
+ attributes?: Readonly<Record<string, unknown>>;
201
+ component: string;
202
+ error?: RuntimeDiagnosticError;
203
+ level: RuntimeDiagnosticLevel;
204
+ name: string;
205
+ timestamp: string;
206
+ }
207
+ type RuntimeDiagnosticReporter = (event: RuntimeDiagnosticEvent) => MaybePromise<void>;
208
+ interface RuntimeResourceObservation {
209
+ name: string;
210
+ scope: RuntimeResourceScope;
211
+ source: string;
212
+ unit: RuntimeResourceUnit;
213
+ value: number;
214
+ }
215
+ interface RuntimeResourceSupport {
216
+ reason?: "collection-failed" | "not-isolated" | "permission-denied" | "unsupported-runtime" | (string & {});
217
+ scope: RuntimeResourceScope;
218
+ source: string;
219
+ supported: boolean;
220
+ }
221
+ interface RuntimeResourceSnapshot {
222
+ observedAt: string;
223
+ observations: readonly RuntimeResourceObservation[];
224
+ support?: readonly RuntimeResourceSupport[];
225
+ }
226
+ interface RuntimeResourceInspector {
227
+ inspect(options?: {
228
+ signal?: AbortSignal;
229
+ }): MaybePromise<RuntimeResourceSnapshot>;
230
+ }
231
+ interface RuntimeDiagnosticErrorOptions {
232
+ includeStack?: boolean;
233
+ maxDepth?: number;
234
+ maxErrors?: number;
235
+ maxStringLength?: number;
236
+ }
237
+ /**
238
+ * Recognizes a live Nostics error across bundled copies. This does not make its fields safe for public responses.
239
+ * nostics' own check matches only its own copy (https://github.com/vercel-labs/nostics/pull/40).
240
+ */
241
+ declare function isRuntimeDiagnostic(error: unknown): error is Diagnostic<unknown> | ResultError;
242
+ /** Formats bounded developer diagnostics without exposing causes or stacks. */
243
+ declare function formatRuntimeDiagnosticError(error: unknown): string;
244
+ declare function normalizeRuntimeDiagnosticError(error: unknown, options?: RuntimeDiagnosticErrorOptions): RuntimeDiagnosticError;
245
+ type ViteHubErrorDetail = boolean | null | number | string | readonly ViteHubErrorDetail[] | {
246
+ readonly [key: string]: ViteHubErrorDetail | undefined;
247
+ };
248
+ type ViteHubErrorDetails = Readonly<Record<string, ViteHubErrorDetail | undefined>>;
249
+ interface ViteHubErrorShape<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> {
250
+ code: TCode;
251
+ details?: TDetails;
252
+ message: string;
253
+ name: "ViteHubError";
254
+ requestId?: string;
255
+ }
256
+ interface ViteHubErrorOptions<TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends ErrorOptions {
257
+ details?: TDetails;
258
+ requestId?: string;
259
+ }
260
+ declare class ViteHubError<TCode extends string = string, TDetails extends ViteHubErrorDetails = ViteHubErrorDetails> extends Error {
261
+ readonly code: TCode;
262
+ readonly details?: TDetails;
263
+ readonly requestId?: string;
264
+ constructor(code: TCode, message: string, options?: ViteHubErrorOptions<TDetails>);
265
+ toJSON(): ViteHubErrorShape<TCode, TDetails>;
266
+ }
267
+ declare function getViteHubErrorShape(value: unknown): ViteHubErrorShape | undefined;
268
+ declare function isViteHubError(value: unknown): value is ViteHubErrorShape;
269
+ type RuntimeName = "cloudflare-agents" | "deno" | "unknown" | "vercel" | "vite";
270
+ type RuntimeContextOptions = Omit<RuntimeContextInput, "event" | "runtime"> & {
271
+ runtime?: RuntimeName;
272
+ };
273
+ type RequestRuntimeContext<TOptions extends RuntimeContextOptions = {}> = CreatedRuntimeContext<TOptions & {
274
+ cloudflare?: RuntimeHostContext["cloudflare"];
275
+ event: ViteHubContext;
276
+ request: Request;
277
+ runtime: RuntimeName;
278
+ vercel?: RuntimeHostContext["vercel"];
279
+ }>;
280
+ /** Keep one Standard Context per Request, even when it cannot be extended. A value set by the host stays. */
281
+ declare function installRequestStandardContext(request: Request, standard?: ViteHubStandardProps): ViteHubStandardProps;
282
+ /**
283
+ * Return the Standard Context of a web Request or of a request event. In a Fetchable server entry, pass the
284
+ * Request: `getStandardContext(request)`. In a ViteHub app, Nitro sets `~standard` on each event and on its
285
+ * Request, so ViteHub keeps the response headers that primitives set. Throws `RUNTIME_R0015` for an event without
286
+ * Standard Context.
287
+ */
288
+ declare function getStandardContext(value: Request | ViteHubContext): ViteHubStandardProps;
289
+ /**
290
+ * Adds the prepared response of a plain Fetch host to the Response that a ViteHub route returns, as H3 adds it in a
291
+ * ViteHub app: `set-cookie` values join the ones of the Response, and other headers replace them. The headers move,
292
+ * so a host that also copies `res.headers` does not send them twice. With another vendor, such as H3, the host adds
293
+ * the prepared response, and `response` comes back as it is.
294
+ */
295
+ declare function sendPreparedResponse(request: Request, response: Response): Response;
296
+ /**
297
+ * Adapt one request. Pass the Request of a Fetchable handler or the event of a ViteHub app.
298
+ * Await `flushWaitUntil()` when the host has no lifetime API.
299
+ */
300
+ declare function getRuntimeContext(value: Request | ViteHubContext): RequestRuntimeContext;
301
+ declare function getRuntimeContext<const TOptions extends RuntimeContextOptions>(value: Request | ViteHubContext, options: TOptions): RequestRuntimeContext<TOptions>;
302
+ /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
303
+ type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
304
+ declare global {
305
+ namespace Cloudflare {
306
+ interface Env {}
307
+ }
308
+ }
309
+ /** The codes that `getHostBinding()` returns. */
310
+ type HostBindingErrorCode = "RUNTIME_HOST_BINDING_NOT_FOUND" | "RUNTIME_HOST_BINDINGS_UNAVAILABLE";
311
+ /**
312
+ * Returns the host that this code builds or runs on, or `undefined` when nothing names one.
313
+ * It reads `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the build variables of Cloudflare Workers Builds
314
+ * (`WORKERS_CI`), Netlify, Vercel, and Deno Deploy. Inside a Cloudflare Worker, it returns `"cloudflare"`.
315
+ * `vitehub()` uses the same detection when `host` is omitted.
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * import { detectHost } from "vite-hub/runtime"
320
+ *
321
+ * const host = detectHost() ?? "node"
322
+ * ```
323
+ */
324
+ declare function detectHost(env?: Record<string, string | undefined>): ViteHubHost | undefined;
325
+ /**
326
+ * Reads one raw binding of the host, such as an R2 bucket, a Durable Object namespace, or a variable of a Cloudflare
327
+ * Worker. Use it for host features that no ViteHub primitive covers. It works in request handlers, Schedules, Queues,
328
+ * and Workflows. Pass the request `event` when you have one: an H3 event, a Standard Context, or a host context with `env`.
329
+ *
330
+ * Run `wrangler types` to type the result from the app's bindings.
331
+ * Returns `RUNTIME_HOST_BINDINGS_UNAVAILABLE` when the code runs without host bindings, such as on Node, and
332
+ * `RUNTIME_HOST_BINDING_NOT_FOUND` when the Worker has no binding with that name.
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * import { getHostBinding } from "vite-hub/runtime"
337
+ *
338
+ * const [error, bucket] = getHostBinding("VIDEOS", event)
339
+ * if (error) return new Response(null, { status: 404 })
340
+ * const object = await bucket.get("intro.mp4")
341
+ * ```
342
+ */
343
+ declare function getHostBinding<TName extends keyof Cloudflare.Env & string>(name: TName, event?: object): Result<Cloudflare.Env[TName], HostBindingErrorCode>;
344
+ declare function getHostBinding<T = unknown>(name: string, event?: object): Result<T, HostBindingErrorCode>;
345
+ export { ResultError as $, formatRuntimeDiagnosticError as A, LeaseErrorCode as B, RuntimeDiagnosticReporter as C, RuntimeResourceSnapshot as D, RuntimeResourceScope as E, parseDuration as F, LeaseStore as G, LeaseRecord as H, getInstanceId as I, DefineErrorsOptions as J, createMemoryLeaseStore as K, instanceIdEnv as L, normalizeRuntimeDiagnosticError as M, Duration as N, RuntimeResourceSupport as O, DurationUnit as P, Result as Q, Lease as R, RuntimeDiagnosticLevel as S, RuntimeResourceObservation as T, LeaseSqlClient as U, LeaseOperation as V, LeaseSqlParam as W, ErrorCodes as X, ErrorCatalog as Y, ErrorHandle as Z, getViteHubErrorShape as _, RequestRuntimeContext as a, RuntimeDiagnosticErrorOptions as b, getRuntimeContext as c, sendPreparedResponse as d, defineErrors as et, ViteHubError as f, ViteHubErrorShape as g, ViteHubErrorOptions as h, ViteHubHost as i, isRuntimeDiagnostic as j, RuntimeResourceUnit as k, getStandardContext as l, ViteHubErrorDetails as m, detectHost as n, RuntimeContextOptions as o, ViteHubErrorDetail as p, createSqlLeaseStore as q, getHostBinding as r, RuntimeName as s, HostBindingErrorCode as t, toResultError as tt, installRequestStandardContext as u, isViteHubError as v, RuntimeResourceInspector as w, RuntimeDiagnosticEvent as x, RuntimeDiagnosticError as y, LeaseAcquireOptions as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { t as runtimeErrorDiagnostics } from "./error-diagnostics-0sYgKTT8.js";
2
- import { $ as emitTraceEvent, $t as decodeRouteSegment, A as RuntimeWaitUntil, At as ViteHubErrorDetails, B as TraceEventLogOptions, Bt as RuntimeResourceInspector, C as PolicyDecision, Cn as isTraceContentAttributeKey, Ct as RuntimeName, D as RuntimeCapabilityHandle, E as RuntimeCapabilities, En as ViteHubStandardProps, F as TraceContext, Ft as RuntimeDiagnosticError, G as TraceStepStatus, Gt as RuntimeResourceUnit, H as TracePayloadVisibility, Ht as RuntimeResourceScope, I as TraceEvent, It as RuntimeDiagnosticErrorOptions, J as createRuntimeContext, Jt as normalizeRuntimeDiagnosticError, K as TraceStepView, Kt as formatRuntimeDiagnosticError, L as TraceEventContentPolicy, Lt as RuntimeDiagnosticEvent, M as TraceActivityContext, Mt as ViteHubErrorShape, N as TraceActivityOwner, Nt as getViteHubErrorShape, O as RuntimeContextInput, Ot as ViteHubError, P as TraceActivityPhase, Pt as isViteHubError, Q as deriveTraceRuns, Qt as normalizeConsoleProjectUrl, R as TraceEventLog, Rt as RuntimeDiagnosticLevel, S as PolicyContext, Sn as toResultError, St as RuntimeContextOptions, T as RunLifecycleHooks, Tn as ViteHubRuntime, Tt as getStandardContext, U as TraceRunStatus, Ut as RuntimeResourceSnapshot, V as TraceEventPayload, Vt as RuntimeResourceObservation, W as TraceRunView, Wt as RuntimeResourceSupport, X as createTraceEventLog, Xt as hostedConsoleUrl, Y as createRuntimeWaitUntilController, Yt as hostedConsoleOrigin, Z as defineCapability, Zt as normalizeConsolePath, _ as MaybeResolvable, _n as ErrorCodes, _t as isResponse, a as AnonymousAccessAuthorizationContext, an as LeaseAcquireOptions, at as normalizeExecutionAuthority, b as OpenTelemetrySpanView, bn as ResultError, bt as toResponse, c as ApprovalRequest, cn as LeaseRecord, ct as traceEventsToOpenTelemetryLogRecords, d as CapabilityHandle, dn as LeaseStore, dt as HostBindingErrorCode, en as encodeRouteSegment, et as getCapability, f as CapabilityPolicy, fn as createMemoryLeaseStore, ft as detectHost, g as MaybePromise, gn as ErrorCatalog, gt as deserializeResponse, h as ExecutionContext, hn as DefineErrorsOptions, ht as SerializedResponse, i as AccessAuthorizeResult, in as Lease, it as noExecutionAuthority, j as RuntimeWaitUntilController, jt as ViteHubErrorOptions, k as RuntimeHostContext, kt as ViteHubErrorDetail, l as ApprovalState, ln as LeaseSqlClient, lt as traceEventsToOpenTelemetrySpans, m as ExecutionAuthority, mn as leaseTable, mt as ViteHubHost, n as AccessAuthorize, nn as DurationUnit, nt as isExecutionAuthority, o as AnonymousAccessAuthorize, on as LeaseErrorCode, ot as resolveCapabilityPolicy, p as CreatedRuntimeContext, pn as createSqlLeaseStore, pt as getHostBinding, q as createExecutionContext, qt as isRuntimeDiagnostic, r as AccessAuthorizeOption, rn as parseDuration, rt as isResolvable, s as ApprovalDecision, sn as LeaseOperation, st as resolveRuntimeValue, t as AccessAuthorizationContext, tn as Duration, tt as hasCapability, u as CapabilityDefinition, un as LeaseSqlParam, ut as unknownExecutionAuthority, v as OpenTelemetryLogRecordView, vn as ErrorHandle, vt as isSerializedResponse, w as Resolvable, wn as ViteHubContext, wt as getRuntimeContext, x as OpenTelemetrySpanViewOptions, xn as defineErrors, xt as RequestRuntimeContext, y as OpenTelemetrySpanEventView, yn as Result, yt as serializeResponse, z as TraceEventLogEntry, zt as RuntimeDiagnosticReporter } from "./index-C1DoYfCf.js";
3
- import { a as ExecutionBudgetOptions, c as createExecutionBudget, i as ExecutionBudgetLimits, l as isExecutionBudgetExceededError, n as ExecutionBudgetCounter, o as ExecutionBudgetSnapshot, r as ExecutionBudgetExceededError, s as ExecutionBudgetUsage, t as ExecutionBudget } from "./execution-budget-BPXbISEt.js";
4
- import { a as resolvePublicUrl, n as consoleInvocationUrl, t as PublicUrlConfig } from "./public-url-1WeOw54Z.js";
5
- export { AccessAuthorizationContext, AccessAuthorize, AccessAuthorizeOption, AccessAuthorizeResult, AnonymousAccessAuthorizationContext, AnonymousAccessAuthorize, ApprovalDecision, ApprovalRequest, ApprovalState, CapabilityDefinition, CapabilityHandle, CapabilityPolicy, CreatedRuntimeContext, type DefineErrorsOptions, type Duration, type DurationUnit, type ErrorCatalog, type ErrorCodes, type ErrorHandle, ExecutionAuthority, type ExecutionBudget, type ExecutionBudgetCounter, type ExecutionBudgetExceededError, type ExecutionBudgetLimits, type ExecutionBudgetOptions, type ExecutionBudgetSnapshot, type ExecutionBudgetUsage, ExecutionContext, type HostBindingErrorCode, type Lease, type LeaseAcquireOptions, type LeaseErrorCode, type LeaseOperation, type LeaseRecord, type LeaseSqlClient, type LeaseSqlParam, type LeaseStore, MaybePromise, MaybeResolvable, OpenTelemetryLogRecordView, OpenTelemetrySpanEventView, OpenTelemetrySpanView, OpenTelemetrySpanViewOptions, PolicyContext, PolicyDecision, type PublicUrlConfig, type RequestRuntimeContext, Resolvable, type Result, type ResultError, RunLifecycleHooks, RuntimeCapabilities, RuntimeCapabilityHandle, RuntimeContextInput, type RuntimeContextOptions, type RuntimeDiagnosticError, type RuntimeDiagnosticErrorOptions, type RuntimeDiagnosticEvent, type RuntimeDiagnosticLevel, type RuntimeDiagnosticReporter, RuntimeHostContext, type RuntimeName, type RuntimeResourceInspector, type RuntimeResourceObservation, type RuntimeResourceScope, type RuntimeResourceSnapshot, type RuntimeResourceSupport, type RuntimeResourceUnit, RuntimeWaitUntil, RuntimeWaitUntilController, type SerializedResponse, TraceActivityContext, TraceActivityOwner, TraceActivityPhase, TraceContext, TraceEvent, TraceEventContentPolicy, TraceEventLog, TraceEventLogEntry, TraceEventLogOptions, TraceEventPayload, TracePayloadVisibility, TraceRunStatus, TraceRunView, TraceStepStatus, TraceStepView, type ViteHubContext, ViteHubError, type ViteHubErrorDetail, type ViteHubErrorDetails, type ViteHubErrorOptions, type ViteHubErrorShape, type ViteHubHost, type ViteHubRuntime, type ViteHubStandardProps, consoleInvocationUrl, createExecutionBudget, createExecutionContext, createMemoryLeaseStore, createRuntimeContext, createRuntimeWaitUntilController, createSqlLeaseStore, createTraceEventLog, decodeRouteSegment, defineCapability, defineErrors, deriveTraceRuns, deserializeResponse, detectHost, emitTraceEvent, encodeRouteSegment, formatRuntimeDiagnosticError, getCapability, getHostBinding, getRuntimeContext, getStandardContext, getViteHubErrorShape, hasCapability, hostedConsoleOrigin, hostedConsoleUrl, isExecutionAuthority, isExecutionBudgetExceededError, isResolvable, isResponse, isRuntimeDiagnostic, isSerializedResponse, isTraceContentAttributeKey, isViteHubError, leaseTable, noExecutionAuthority, normalizeConsolePath, normalizeConsoleProjectUrl, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, parseDuration, resolveCapabilityPolicy, resolvePublicUrl, resolveRuntimeValue, runtimeErrorDiagnostics, serializeResponse, toResponse, toResultError, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
1
+ import { A as RuntimeWaitUntil, B as TraceEventLogOptions, C as PolicyDecision, D as RuntimeCapabilityHandle, E as RuntimeCapabilities, F as TraceContext, G as TraceStepStatus, H as TracePayloadVisibility, I as TraceEvent, J as createRuntimeContext, K as TraceStepView, L as TraceEventContentPolicy, M as TraceActivityContext, N as TraceActivityOwner, O as RuntimeContextInput, P as TraceActivityPhase, Q as deriveTraceRuns, R as TraceEventLog, S as PolicyContext, T as RunLifecycleHooks, U as TraceRunStatus, V as TraceEventPayload, W as TraceRunView, X as createTraceEventLog, Z as defineCapability, _ as MaybeResolvable, a as AnonymousAccessAuthorizationContext, at as normalizeExecutionAuthority, b as OpenTelemetrySpanView, c as ApprovalRequest, d as CapabilityHandle, dt as ViteHubContext, et as getCapability, f as CapabilityPolicy, ft as ViteHubRuntime, g as MaybePromise, h as ExecutionContext, i as AccessAuthorizeResult, it as noExecutionAuthority, j as RuntimeWaitUntilController, k as RuntimeHostContext, l as ApprovalState, m as ExecutionAuthority, n as AccessAuthorize, nt as isExecutionAuthority, o as AnonymousAccessAuthorize, ot as resolveCapabilityPolicy, p as CreatedRuntimeContext, pt as ViteHubStandardProps, q as createExecutionContext, r as AccessAuthorizeOption, s as ApprovalDecision, t as AccessAuthorizationContext, tt as hasCapability, u as CapabilityDefinition, ut as unknownExecutionAuthority, v as OpenTelemetryLogRecordView, w as Resolvable, x as OpenTelemetrySpanViewOptions, y as OpenTelemetrySpanEventView, z as TraceEventLogEntry } from "./core-auTkK4iZ.js";
2
+ import { $ as ResultError, A as formatRuntimeDiagnosticError, B as LeaseErrorCode, C as RuntimeDiagnosticReporter, D as RuntimeResourceSnapshot, E as RuntimeResourceScope, F as parseDuration, G as LeaseStore, H as LeaseRecord, I as getInstanceId, J as DefineErrorsOptions, K as createMemoryLeaseStore, L as instanceIdEnv, M as normalizeRuntimeDiagnosticError, N as Duration, O as RuntimeResourceSupport, P as DurationUnit, Q as Result, R as Lease, S as RuntimeDiagnosticLevel, T as RuntimeResourceObservation, U as LeaseSqlClient, V as LeaseOperation, W as LeaseSqlParam, X as ErrorCodes, Y as ErrorCatalog, Z as ErrorHandle, _ as getViteHubErrorShape, a as RequestRuntimeContext, b as RuntimeDiagnosticErrorOptions, c as getRuntimeContext, et as defineErrors, f as ViteHubError, g as ViteHubErrorShape, h as ViteHubErrorOptions, i as ViteHubHost, j as isRuntimeDiagnostic, k as RuntimeResourceUnit, l as getStandardContext, m as ViteHubErrorDetails, n as detectHost, o as RuntimeContextOptions, p as ViteHubErrorDetail, q as createSqlLeaseStore, r as getHostBinding, s as RuntimeName, t as HostBindingErrorCode, tt as toResultError, v as isViteHubError, w as RuntimeResourceInspector, x as RuntimeDiagnosticEvent, y as RuntimeDiagnosticError, z as LeaseAcquireOptions } from "./index-hFKl7B_y.js";
3
+ import { n as hostedConsoleUrl } from "./hosted-console-DTh9zwNz.js";
4
+ import { o as resolvePublicUrl, t as PublicUrlConfig } from "./public-url-B4p8EOqr.js";
5
+ import { a as ExecutionBudgetOptions, i as ExecutionBudgetLimits, n as ExecutionBudgetCounter, o as ExecutionBudgetSnapshot, r as ExecutionBudgetExceededError, s as ExecutionBudgetUsage, t as ExecutionBudget } from "./execution-budget-Bv7h0-5V.js";
6
+ import { o as toResponse, t as SerializedResponse } from "./response-ClQ9ZSS_.js";
7
+ export { type AccessAuthorizationContext, type AccessAuthorize, type AccessAuthorizeOption, type AccessAuthorizeResult, type AnonymousAccessAuthorizationContext, type AnonymousAccessAuthorize, type ApprovalDecision, type ApprovalRequest, type ApprovalState, type CapabilityDefinition, type CapabilityHandle, type CapabilityPolicy, type CreatedRuntimeContext, type DefineErrorsOptions, type Duration, type DurationUnit, type ErrorCatalog, type ErrorCodes, type ErrorHandle, type ExecutionAuthority, type ExecutionBudget, type ExecutionBudgetCounter, type ExecutionBudgetExceededError, type ExecutionBudgetLimits, type ExecutionBudgetOptions, type ExecutionBudgetSnapshot, type ExecutionBudgetUsage, type ExecutionContext, type HostBindingErrorCode, type Lease, type LeaseAcquireOptions, type LeaseErrorCode, type LeaseOperation, type LeaseRecord, type LeaseSqlClient, type LeaseSqlParam, type LeaseStore, type MaybePromise, type MaybeResolvable, type OpenTelemetryLogRecordView, type OpenTelemetrySpanEventView, type OpenTelemetrySpanView, type OpenTelemetrySpanViewOptions, type PolicyContext, type PolicyDecision, type PublicUrlConfig, type RequestRuntimeContext, type Resolvable, type Result, type ResultError, type RunLifecycleHooks, type RuntimeCapabilities, type RuntimeCapabilityHandle, type RuntimeContextInput, type RuntimeContextOptions, type RuntimeDiagnosticError, type RuntimeDiagnosticErrorOptions, type RuntimeDiagnosticEvent, type RuntimeDiagnosticLevel, type RuntimeDiagnosticReporter, type RuntimeHostContext, type RuntimeName, type RuntimeResourceInspector, type RuntimeResourceObservation, type RuntimeResourceScope, type RuntimeResourceSnapshot, type RuntimeResourceSupport, type RuntimeResourceUnit, type RuntimeWaitUntil, type RuntimeWaitUntilController, type SerializedResponse, type TraceActivityContext, type TraceActivityOwner, type TraceActivityPhase, type TraceContext, type TraceEvent, type TraceEventContentPolicy, type TraceEventLog, type TraceEventLogEntry, type TraceEventLogOptions, type TraceEventPayload, type TracePayloadVisibility, type TraceRunStatus, type TraceRunView, type TraceStepStatus, type TraceStepView, type ViteHubContext, ViteHubError, type ViteHubErrorDetail, type ViteHubErrorDetails, type ViteHubErrorOptions, type ViteHubErrorShape, type ViteHubHost, type ViteHubRuntime, type ViteHubStandardProps, createExecutionContext, createMemoryLeaseStore, createRuntimeContext, createSqlLeaseStore, createTraceEventLog, defineCapability, defineErrors, deriveTraceRuns, detectHost, formatRuntimeDiagnosticError, getCapability, getHostBinding, getInstanceId, getRuntimeContext, getStandardContext, getViteHubErrorShape, hasCapability, hostedConsoleUrl, instanceIdEnv, isExecutionAuthority, isRuntimeDiagnostic, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, parseDuration, resolveCapabilityPolicy, resolvePublicUrl, toResponse, toResultError, unknownExecutionAuthority };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { A as isResponse, B as formatRuntimeDiagnosticError, C as resolveRuntimeValue, D as detectHost, E as unknownExecutionAuthority, F as createMemoryLeaseStore, G as isTraceContentAttributeKey, H as normalizeRuntimeDiagnosticError, I as createSqlLeaseStore, L as leaseTable, M as serializeResponse, N as toResponse, O as getHostBinding, P as parseDuration, R as defineErrors, S as resolveCapabilityPolicy, T as traceEventsToOpenTelemetrySpans, U as createExecutionBudget, V as isRuntimeDiagnostic, W as isExecutionBudgetExceededError, _ as hasCapability, b as noExecutionAuthority, d as createRuntimeWaitUntilController, f as createTraceEventLog, g as getCapability, h as emitTraceEvent, i as getStandardContext, j as isSerializedResponse, k as deserializeResponse, l as createExecutionContext, m as deriveTraceRuns, p as defineCapability, r as getRuntimeContext, u as createRuntimeContext, v as isExecutionAuthority, w as traceEventsToOpenTelemetryLogRecords, x as normalizeExecutionAuthority, y as isResolvable, z as toResultError } from "./request-context-uRQpodgl.js";
2
- import { t as runtimeErrorDiagnostics } from "./error-diagnostics-BM9W4pBg.js";
3
- import { n as getViteHubErrorShape, r as isViteHubError, t as ViteHubError } from "./errors-BQ0ofIL4.js";
4
- import { a as hostedConsoleOrigin, c as normalizeConsoleProjectUrl, i as resolvePublicUrl, l as decodeRouteSegment, o as hostedConsoleUrl, s as normalizeConsolePath, t as consoleInvocationUrl, u as encodeRouteSegment } from "./public-url-ByAmAjbP.js";
5
- export { ViteHubError, consoleInvocationUrl, createExecutionBudget, createExecutionContext, createMemoryLeaseStore, createRuntimeContext, createRuntimeWaitUntilController, createSqlLeaseStore, createTraceEventLog, decodeRouteSegment, defineCapability, defineErrors, deriveTraceRuns, deserializeResponse, detectHost, emitTraceEvent, encodeRouteSegment, formatRuntimeDiagnosticError, getCapability, getHostBinding, getRuntimeContext, getStandardContext, getViteHubErrorShape, hasCapability, hostedConsoleOrigin, hostedConsoleUrl, isExecutionAuthority, isExecutionBudgetExceededError, isResolvable, isResponse, isRuntimeDiagnostic, isSerializedResponse, isTraceContentAttributeKey, isViteHubError, leaseTable, noExecutionAuthority, normalizeConsolePath, normalizeConsoleProjectUrl, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, parseDuration, resolveCapabilityPolicy, resolvePublicUrl, resolveRuntimeValue, runtimeErrorDiagnostics, serializeResponse, toResponse, toResultError, traceEventsToOpenTelemetryLogRecords, traceEventsToOpenTelemetrySpans, unknownExecutionAuthority };
1
+ import { _ as instanceIdEnv, d as parseDuration, f as createMemoryLeaseStore, g as getInstanceId, h as toResultError, i as getStandardContext, l as detectHost, m as defineErrors, p as createSqlLeaseStore, r as getRuntimeContext, u as getHostBinding } from "./request-context-Ci5FjuUY.js";
2
+ import { n as getViteHubErrorShape, r as isViteHubError, t as ViteHubError } from "./errors-D2ixvqv3.js";
3
+ import { a as defineCapability, c as getCapability, f as noExecutionAuthority, i as createTraceEventLog, l as hasCapability, m as resolveCapabilityPolicy, n as createRuntimeContext, o as deriveTraceRuns, p as normalizeExecutionAuthority, t as createExecutionContext, u as isExecutionAuthority, v as unknownExecutionAuthority } from "./core-Crv8CV_r.js";
4
+ import { a as toResponse, c as normalizeRuntimeDiagnosticError, o as formatRuntimeDiagnosticError, s as isRuntimeDiagnostic } from "./response-DEyMvEBF.js";
5
+ import { a as resolvePublicUrl, l as hostedConsoleUrl } from "./public-url-DDh_BHz3.js";
6
+ export { ViteHubError, createExecutionContext, createMemoryLeaseStore, createRuntimeContext, createSqlLeaseStore, createTraceEventLog, defineCapability, defineErrors, deriveTraceRuns, detectHost, formatRuntimeDiagnosticError, getCapability, getHostBinding, getInstanceId, getRuntimeContext, getStandardContext, getViteHubErrorShape, hasCapability, hostedConsoleUrl, instanceIdEnv, isExecutionAuthority, isRuntimeDiagnostic, isViteHubError, noExecutionAuthority, normalizeExecutionAuthority, normalizeRuntimeDiagnosticError, parseDuration, resolveCapabilityPolicy, resolvePublicUrl, toResponse, toResultError, unknownExecutionAuthority };
@@ -0,0 +1,5 @@
1
+ import { i as normalizeConsoleProjectUrl, r as normalizeConsolePath, t as hostedConsoleOrigin } from "../hosted-console-DTh9zwNz.js";
2
+ import { r as consoleInvocationUrl } from "../public-url-B4p8EOqr.js";
3
+ export declare function encodeRouteSegment(value: string): string;
4
+ export declare function decodeRouteSegment(segment: string): string | undefined;
5
+ export { consoleInvocationUrl, hostedConsoleOrigin, normalizeConsolePath, normalizeConsoleProjectUrl };
@@ -0,0 +1 @@
1
+ export { n as consoleInvocationUrl, o as decodeRouteSegment, s as encodeRouteSegment, c as hostedConsoleOrigin, u as normalizeConsolePath, d as normalizeConsoleProjectUrl } from "../public-url-DDh_BHz3.js";
@@ -0,0 +1,2 @@
1
+ import { Y as createRuntimeWaitUntilController, rt as isResolvable, st as resolveRuntimeValue } from "../core-auTkK4iZ.js";
2
+ export { createRuntimeWaitUntilController, isResolvable, resolveRuntimeValue };
@@ -0,0 +1 @@
1
+ export { r as createRuntimeWaitUntilController, d as isResolvable, h as resolveRuntimeValue } from "../core-Crv8CV_r.js";
@@ -1,4 +1,3 @@
1
- //#region src/internal/drain.d.ts
2
1
  /** The streams that `vitehub drain` writes to. */
3
2
  export interface DrainOutput {
4
3
  stderr: {
@@ -13,5 +12,4 @@ export declare const drainUsage = "vitehub drain MAINPID [STATUS_URL]";
13
12
  * `vitehub drain MAINPID [STATUS_URL]`: sends the drain signal to a running server and waits until its status endpoint
14
13
  * reports `drained`. Returns 0 when it drained, 1 when it failed, and 2 for a usage error.
15
14
  */
16
- export declare function runDrain(args: readonly string[], output: DrainOutput): Promise<number>;
17
- //#endregion
15
+ export declare function runDrain(args: readonly string[], output: DrainOutput): Promise<number>;
@@ -1,5 +1,5 @@
1
- import { t as runtimeErrorDiagnostics } from "../error-diagnostics-BM9W4pBg.js";
2
- //#region src/internal/drain-process.ts
1
+ import { t as runtimeErrorDiagnostics } from "../error-diagnostics-Dj98U7ch.js";
2
+ // src/internal/drain-process.ts
3
3
  /** Check whether a process still exists without confusing access denial for exit. */
4
4
  function isProcessRunning(pid) {
5
5
  try {
@@ -23,8 +23,7 @@ function signalProcess(pid) {
23
23
  throw error;
24
24
  }
25
25
  }
26
- //#endregion
27
- //#region src/internal/drain.ts
26
+ // src/internal/drain.ts
28
27
  const drainUsage = "vitehub drain MAINPID [STATUS_URL]";
29
28
  async function readStatus(statusUrl) {
30
29
  try {
@@ -71,5 +70,4 @@ async function runDrain(args, output) {
71
70
  return 1;
72
71
  }
73
72
  }
74
- //#endregion
75
73
  export { drainUsage, runDrain };
@@ -0,0 +1,2 @@
1
+ import { t as runtimeErrorDiagnostics } from "../error-diagnostics-DuusexaK.js";
2
+ export { runtimeErrorDiagnostics };
@@ -0,0 +1 @@
1
+ export { t as runtimeErrorDiagnostics } from "../error-diagnostics-Dj98U7ch.js";
@@ -1,5 +1,4 @@
1
- import { t as ExecutionBudget } from "../execution-budget-BPXbISEt.js";
2
- //#region src/internal/execution-budget.d.ts
1
+ import { c as createExecutionBudget, l as isExecutionBudgetExceededError, t as ExecutionBudget } from "../execution-budget-Bv7h0-5V.js";
3
2
  /** Internal context key used when a budget-owned tool is reused by another Invocation. */
4
3
  export declare const executionBudgetOverride: unique symbol;
5
4
  /** Internal context key used when a policy wrapper already charged a call. */
@@ -7,4 +6,4 @@ export declare const executionBudgetCharged: unique symbol;
7
6
  export declare function markExecutionBudgetHandled(tool: object, budget: ExecutionBudget): void;
8
7
  export declare function isExecutionBudgetHandled(tool: object, budget: ExecutionBudget): boolean;
9
8
  export declare function executionBudgetHandledBy(tool: object): ExecutionBudget | undefined;
10
- //#endregion
9
+ export { createExecutionBudget, isExecutionBudgetExceededError };