@vite-hub/runtime 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/{core-DpLK9dQt.js → core-Crv8CV_r.js} +5 -7
  2. package/dist/{core-BfUEli_0.d.ts → core-auTkK4iZ.d.ts} +0 -6
  3. package/dist/detect-host-Du9saPsM.js +57 -0
  4. package/dist/detect-host-uTgoQ9i4.d.ts +17 -0
  5. package/dist/durability.d.ts +1 -3
  6. package/dist/durability.js +1 -2
  7. package/dist/{error-diagnostics-BM9W4pBg.js → error-diagnostics-Dj98U7ch.js} +1 -2
  8. package/dist/{error-diagnostics-0sYgKTT8.d.ts → error-diagnostics-DuusexaK.d.ts} +0 -2
  9. package/dist/{errors-BQ0ofIL4.js → errors-D2ixvqv3.js} +2 -3
  10. package/dist/{execution-budget-BPXbISEt.d.ts → execution-budget-Bv7h0-5V.d.ts} +0 -2
  11. package/dist/{hosted-console-ZfMo5MW4.d.ts → hosted-console-DInG3Xl9.d.ts} +3 -6
  12. package/dist/hosted-console-nLc1pL9J.js +71 -0
  13. package/dist/{index-DsisbCNa.d.ts → index-fSQ1ELEy.d.ts} +3 -38
  14. package/dist/index.d.ts +7 -6
  15. package/dist/index.js +7 -5
  16. package/dist/internal/console.d.ts +10 -5
  17. package/dist/internal/console.js +3 -2
  18. package/dist/internal/context.d.ts +1 -1
  19. package/dist/internal/context.js +1 -2
  20. package/dist/internal/detect-host.d.ts +2 -0
  21. package/dist/internal/detect-host.js +1 -0
  22. package/dist/internal/drain.d.ts +1 -3
  23. package/dist/internal/drain.js +3 -5
  24. package/dist/internal/error-diagnostics.d.ts +1 -1
  25. package/dist/internal/error-diagnostics.js +1 -2
  26. package/dist/internal/execution-budget.d.ts +1 -3
  27. package/dist/internal/execution-budget.js +3 -5
  28. package/dist/internal/grant.d.ts +1 -2
  29. package/dist/internal/grant.js +3 -4
  30. package/dist/internal/h3.d.ts +2 -4
  31. package/dist/internal/h3.js +4 -6
  32. package/dist/internal/node.d.ts +2 -3
  33. package/dist/internal/node.js +2 -3
  34. package/dist/internal/public-url.d.ts +1 -1
  35. package/dist/internal/public-url.js +1 -2
  36. package/dist/internal/response.d.ts +1 -1
  37. package/dist/internal/response.js +1 -2
  38. package/dist/internal/run-failed.d.ts +1 -3
  39. package/dist/internal/run-failed.js +1 -2
  40. package/dist/internal/run-scope.d.ts +1 -3
  41. package/dist/internal/run-scope.js +1 -2
  42. package/dist/internal/runtime-type.d.ts +1 -3
  43. package/dist/internal/runtime-type.js +2 -2
  44. package/dist/internal/shutdown.d.ts +1 -3
  45. package/dist/internal/shutdown.js +1 -2
  46. package/dist/internal/test-mode-setup.d.ts +1 -3
  47. package/dist/internal/test-mode-setup.js +1 -2
  48. package/dist/internal/test-mode.d.ts +1 -3
  49. package/dist/internal/test-mode.js +1 -2
  50. package/dist/internal/trace.d.ts +2 -4
  51. package/dist/internal/trace.js +1 -2
  52. package/dist/operations.d.ts +0 -3
  53. package/dist/operations.js +9 -10
  54. package/dist/{public-url-BCFhTiTM.d.ts → public-url-CaVJ4vFF.d.ts} +1 -2
  55. package/dist/{public-url-DizC8CFs.js → public-url-TlEVxNNh.js} +10 -72
  56. package/dist/{request-context-Dmsliqan.js → request-context-Dcf59Qh4.js} +11 -73
  57. package/dist/{response-iONbTI0E.d.ts → response-ClQ9ZSS_.d.ts} +0 -2
  58. package/dist/{response-Be5M4WIn.js → response-DEyMvEBF.js} +5 -7
  59. package/dist/{runtime-type-CHYQYwDx.js → runtime-type-EgaBGoVU.js} +2 -4
  60. package/package.json +9 -4
@@ -1,7 +1,7 @@
1
- import { t as runtimeErrorDiagnostics } from "./error-diagnostics-BM9W4pBg.js";
2
- import { r as isRuntimeObject } from "./runtime-type-CHYQYwDx.js";
3
- import { t as ViteHubError } from "./errors-BQ0ofIL4.js";
4
- //#region src/internal/trace-attributes.ts
1
+ import { r as isRuntimeObject } from "./runtime-type-EgaBGoVU.js";
2
+ import { t as ViteHubError } from "./errors-D2ixvqv3.js";
3
+ import { t as runtimeErrorDiagnostics } from "./error-diagnostics-Dj98U7ch.js";
4
+ // src/internal/trace-attributes.ts
5
5
  const contentAttributeKeys = /* @__PURE__ */ new Set([
6
6
  "args",
7
7
  "body",
@@ -107,8 +107,7 @@ function normalizeTraceAttributes(attributes, content) {
107
107
  }
108
108
  return Object.keys(source).length ? source : void 0;
109
109
  }
110
- //#endregion
111
- //#region src/core.ts
110
+ // src/core.ts
112
111
  function captureWebAssemblyModule() {
113
112
  const namespace = Object.getOwnPropertyDescriptor(globalThis, "WebAssembly")?.value;
114
113
  const constructor = typeof namespace === "object" ? Object.getOwnPropertyDescriptor(namespace, "Module")?.value : void 0;
@@ -1101,5 +1100,4 @@ async function resolveCapabilityPolicy(policy, context) {
1101
1100
  if (!policy) return "allow";
1102
1101
  return typeof policy === "function" ? await policy(context) : policy;
1103
1102
  }
1104
- //#endregion
1105
1103
  export { traceEventsToOpenTelemetrySpans as _, defineCapability as a, getCapability as c, isResolvable as d, noExecutionAuthority as f, traceEventsToOpenTelemetryLogRecords as g, resolveRuntimeValue as h, createTraceEventLog as i, hasCapability as l, resolveCapabilityPolicy as m, createRuntimeContext as n, deriveTraceRuns as o, normalizeExecutionAuthority as p, createRuntimeWaitUntilController as r, emitTraceEvent as s, createExecutionContext as t, isExecutionAuthority as u, unknownExecutionAuthority as v, isTraceContentAttributeKey as y };
@@ -1,10 +1,7 @@
1
1
  import { StandardContext } from "standard-context";
2
- //#region ../internal/dist/runtime/cloudflare-env.d.ts
3
2
  interface CloudflareWorkerExecutionContext {
4
3
  waitUntil?: (promise: Promise<unknown>) => void;
5
4
  }
6
- //#endregion
7
- //#region src/standard-context.d.ts
8
5
  /** The host data that ViteHub puts in `runtime` of a Standard Context. */
9
6
  interface ViteHubRuntime {
10
7
  /** The Cloudflare bindings and execution context of the request. A host can pass either one without the other. */
@@ -22,8 +19,6 @@ interface ViteHubRuntime {
22
19
  type ViteHubStandardProps = StandardContext.Props<ViteHubRuntime, void>;
23
20
  /** A request event in a ViteHub app: any server context with Standard Context properties. */
24
21
  type ViteHubContext<C = {}> = StandardContext<C, ViteHubRuntime, void>;
25
- //#endregion
26
- //#region src/core.d.ts
27
22
  type MaybePromise<T> = T | Promise<T>;
28
23
  declare global {
29
24
  namespace ViteHub {
@@ -300,5 +295,4 @@ declare function getCapability(context: RuntimeHostContext<any>, name: string):
300
295
  declare function isResolvable<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>): value is Resolvable<T, TContext>;
301
296
  declare function resolveRuntimeValue<T, TContext extends RuntimeHostContext<any>>(value: MaybeResolvable<T, TContext>, context: TContext): Promise<T>;
302
297
  declare function resolveCapabilityPolicy(policy: CapabilityPolicy | undefined, context: PolicyContext): Promise<PolicyDecision>;
303
- //#endregion
304
298
  export { emitTraceEvent as $, RuntimeWaitUntil as A, TraceEventLogOptions as B, PolicyDecision as C, RuntimeCapabilityHandle as D, RuntimeCapabilities as E, TraceContext as F, TraceStepStatus as G, TracePayloadVisibility as H, TraceEvent as I, createRuntimeContext as J, TraceStepView as K, TraceEventContentPolicy as L, TraceActivityContext as M, TraceActivityOwner as N, RuntimeContextInput as O, TraceActivityPhase as P, deriveTraceRuns as Q, TraceEventLog as R, PolicyContext as S, RunLifecycleHooks as T, TraceRunStatus as U, TraceEventPayload as V, TraceRunView as W, createTraceEventLog as X, createRuntimeWaitUntilController as Y, defineCapability as Z, MaybeResolvable as _, AnonymousAccessAuthorizationContext as a, normalizeExecutionAuthority as at, OpenTelemetrySpanView as b, ApprovalRequest as c, traceEventsToOpenTelemetryLogRecords as ct, CapabilityHandle as d, ViteHubContext as dt, getCapability as et, CapabilityPolicy as f, ViteHubRuntime as ft, MaybePromise as g, ExecutionContext as h, AccessAuthorizeResult as i, noExecutionAuthority as it, RuntimeWaitUntilController as j, RuntimeHostContext as k, ApprovalState as l, traceEventsToOpenTelemetrySpans as lt, ExecutionAuthority as m, AccessAuthorize as n, isExecutionAuthority as nt, AnonymousAccessAuthorize as o, resolveCapabilityPolicy as ot, CreatedRuntimeContext as p, ViteHubStandardProps as pt, createExecutionContext as q, AccessAuthorizeOption as r, isResolvable as rt, ApprovalDecision as s, resolveRuntimeValue as st, AccessAuthorizationContext as t, hasCapability as tt, CapabilityDefinition as u, unknownExecutionAuthority as ut, OpenTelemetryLogRecordView as v, Resolvable as w, OpenTelemetrySpanViewOptions as x, OpenTelemetrySpanEventView as y, TraceEventLogEntry as z };
@@ -0,0 +1,57 @@
1
+ /** Maps a host name or a Nitro preset name, such as `cloudflare-module` or `node-server`, to its ViteHub host. */
2
+ function hostFromNitroPreset(value) {
3
+ const normalized = value?.trim().toLowerCase().replaceAll("_", "-");
4
+ if (!normalized) return;
5
+ if (normalized.startsWith("cloudflare")) return "cloudflare";
6
+ if (normalized.startsWith("deno")) return "deno";
7
+ if (normalized.startsWith("netlify")) return "netlify";
8
+ if (normalized === "node" || normalized.startsWith("node-")) return "node";
9
+ if (normalized.startsWith("vercel")) return "vercel";
10
+ }
11
+ const providerHosts = [
12
+ ["WORKERS_CI", "cloudflare"],
13
+ ["NETLIFY", "netlify"],
14
+ ["NOW_BUILDER", "vercel"],
15
+ ["VERCEL", "vercel"],
16
+ ["VERCEL_ENV", "vercel"],
17
+ ["DENO_DEPLOY", "deno"],
18
+ ["DENO_DEPLOYMENT_ID", "deno"]
19
+ ];
20
+ /**
21
+ * Returns the ViteHub host that this process builds or runs on, or `undefined` when no variable names a host.
22
+ * The order is `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the provider variables:
23
+ * `WORKERS_CI` (Cloudflare Workers Builds), `NETLIFY`, `NOW_BUILDER`, `VERCEL` or `VERCEL_ENV`, then `DENO_DEPLOY` or `DENO_DEPLOYMENT_ID`.
24
+ * `vitehub()` uses this result when `host` is omitted, and `"node"` when it is `undefined`.
25
+ */
26
+ function detectHost$1(env = process.env) {
27
+ for (const name of [
28
+ "VITEHUB_HOST",
29
+ "NITRO_PRESET",
30
+ "SERVER_PRESET"
31
+ ]) {
32
+ const host = hostFromNitroPreset(env[name]);
33
+ if (host) return host;
34
+ }
35
+ return providerHosts.find(([name]) => env[name]?.trim())?.[1];
36
+ }
37
+ // src/internal/detect-host.ts
38
+ /**
39
+ * Returns the host that this code builds or runs on, or `undefined` when nothing names one.
40
+ * It reads `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the build variables of Cloudflare Workers Builds
41
+ * (`WORKERS_CI`), Netlify, Vercel, and Deno Deploy. Inside a Cloudflare Worker, it returns `"cloudflare"`.
42
+ * `vitehub()` uses the same detection when `host` is omitted.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { detectHost } from "vite-hub/runtime"
47
+ *
48
+ * const host = detectHost() ?? "node"
49
+ * ```
50
+ */
51
+ function detectHost(env = processEnv()) {
52
+ return detectHost$1(env) ?? (globalThis.navigator?.userAgent === "Cloudflare-Workers" ? "cloudflare" : void 0);
53
+ }
54
+ function processEnv() {
55
+ return globalThis.process?.env ?? {};
56
+ }
57
+ export { detectHost as t };
@@ -0,0 +1,17 @@
1
+ /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
2
+ type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
3
+ /**
4
+ * Returns the host that this code builds or runs on, or `undefined` when nothing names one.
5
+ * It reads `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the build variables of Cloudflare Workers Builds
6
+ * (`WORKERS_CI`), Netlify, Vercel, and Deno Deploy. Inside a Cloudflare Worker, it returns `"cloudflare"`.
7
+ * `vitehub()` uses the same detection when `host` is omitted.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { detectHost } from "vite-hub/runtime"
12
+ *
13
+ * const host = detectHost() ?? "node"
14
+ * ```
15
+ */
16
+ declare function detectHost(env?: Record<string, string | undefined>): ViteHubHost | undefined;
17
+ export { ViteHubHost as n, detectHost as t };
@@ -1,4 +1,3 @@
1
- //#region src/durability.d.ts
2
1
  /**
3
2
  * Where the state of a primitive lives.
4
3
  *
@@ -103,5 +102,4 @@ export declare function getDurabilityReport(): DurabilityReport | undefined;
103
102
  * Records the durability of each primitive, prints one line per primitive, and fails when several instances would
104
103
  * split state. A Node server runs it once at boot, from a Nitro plugin that ViteHub generates.
105
104
  */
106
- export declare function checkDurability(primitives: readonly Durability[], options?: DurabilityCheckOptions): DurabilityReport;
107
- //#endregion
105
+ export declare function checkDurability(primitives: readonly Durability[], options?: DurabilityCheckOptions): DurabilityReport;
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region src/durability.ts
2
+ // src/durability.ts
3
3
  /**
4
4
  * Runs every reporter once, in order. A reporter that calls `context.find()` runs the reporter of that primitive first,
5
5
  * so the order of the entries does not matter.
@@ -167,5 +167,4 @@ function checkDurability(primitives, options = {}) {
167
167
  if (options.enforce !== false && report.problems.length) throw durabilityError(report);
168
168
  return report;
169
169
  }
170
- //#endregion
171
170
  export { checkDurability, classifySqliteUrl, collectDurability, durabilityError, durabilityProblems, formatDurabilityTable, getDurabilityReport, instancesEnvName, readInstanceCount, resolveDurabilityValue, sqliteUrlInput };
@@ -1,5 +1,5 @@
1
1
  import { defineDiagnostics } from "nostics";
2
- //#region src/error-diagnostics.ts
2
+ // src/error-diagnostics.ts
3
3
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
4
4
  const codes = {
5
5
  RUNTIME_R0001: {
@@ -89,5 +89,4 @@ const runtimeErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
89
89
  docsBase: "https://vitehub.dev/docs/runtime/diagnostics",
90
90
  codes
91
91
  });
92
- //#endregion
93
92
  export { runtimeErrorDiagnostics as t };
@@ -1,5 +1,4 @@
1
1
  import { Diagnostics } from "nostics";
2
- //#region src/error-diagnostics.d.ts
3
2
  interface RuntimeCodeParams {
4
3
  counter?: string;
5
4
  message?: unknown;
@@ -15,5 +14,4 @@ interface RuntimeCodeDefinition {
15
14
  type RuntimeErrorCode = "RUNTIME_R0001" | "RUNTIME_R0002" | "RUNTIME_R0003" | "RUNTIME_R0004" | "RUNTIME_R0005" | "RUNTIME_R0006" | "RUNTIME_R0007" | "RUNTIME_R0009" | "RUNTIME_R0010" | "RUNTIME_R0011" | "RUNTIME_R0015" | "RUNTIME_R0016" | "RUNTIME_R0017" | "RUNTIME_R0018" | "RUNTIME_CONSOLE_PATH_INVALID" | "RUNTIME_CONSOLE_PROJECT_URL_INVALID" | "RUNTIME_DURATION_INVALID" | "RUNTIME_EXECUTION_BUDGET_AMOUNT_INVALID" | "RUNTIME_EXECUTION_BUDGET_EXCEEDED" | "RUNTIME_EXECUTION_BUDGET_LIMIT_INVALID" | "RUNTIME_HIDDEN_ERROR" | "RUNTIME_SERIALIZED_RESPONSE_INVALID";
16
15
  declare const codes: Record<RuntimeErrorCode, RuntimeCodeDefinition>;
17
16
  declare const runtimeErrorDiagnostics: Diagnostics<typeof codes, []>;
18
- //#endregion
19
17
  export { runtimeErrorDiagnostics as t };
@@ -1,5 +1,5 @@
1
- import { t as runtimeErrorDiagnostics } from "./error-diagnostics-BM9W4pBg.js";
2
- //#region src/errors.ts
1
+ import { t as runtimeErrorDiagnostics } from "./error-diagnostics-Dj98U7ch.js";
2
+ // src/errors.ts
3
3
  const MAX_DETAIL_DEPTH = 8;
4
4
  const MAX_DETAIL_ENTRIES = 128;
5
5
  const MAX_DETAIL_KEY_LENGTH = 128;
@@ -186,5 +186,4 @@ function getViteHubErrorShape(value) {
186
186
  function isViteHubError(value) {
187
187
  return getViteHubErrorShape(value) !== void 0;
188
188
  }
189
- //#endregion
190
189
  export { getViteHubErrorShape as n, isViteHubError as r, ViteHubError as t };
@@ -1,5 +1,4 @@
1
1
  import { Diagnostic } from "nostics";
2
- //#region src/execution-budget.d.ts
3
2
  /** Counters that an Invocation can spend while it runs. */
4
3
  type ExecutionBudgetCounter = "inputBytes" | "outputBytes" | "retries" | "toolCalls";
5
4
  interface ExecutionBudgetLimits {
@@ -52,5 +51,4 @@ interface ExecutionBudget {
52
51
  snapshot(): ExecutionBudgetSnapshot;
53
52
  }
54
53
  declare function createExecutionBudget(options?: ExecutionBudgetOptions): ExecutionBudget;
55
- //#endregion
56
54
  export { ExecutionBudgetOptions as a, createExecutionBudget as c, ExecutionBudgetLimits as i, isExecutionBudgetExceededError as l, ExecutionBudgetCounter as n, ExecutionBudgetSnapshot as o, ExecutionBudgetExceededError as r, ExecutionBudgetUsage as s, ExecutionBudget as t };
@@ -1,6 +1,3 @@
1
- //#region src/hosted-console.d.ts
2
- /** The origin of the hosted Console. */
3
- declare const hostedConsoleOrigin = "https://console.vitehub.dev";
4
1
  /**
5
2
  * The Console path of a link, such as `/agents/bot/invocations/abc?tab=trace`, or `undefined` when the value is not a
6
3
  * Console path. A Console path starts with one `/`. Absolute URLs, protocol-relative URLs, and backslashes are not
@@ -20,11 +17,11 @@ declare function normalizeConsoleProjectUrl(projectUrl: string): string | undefi
20
17
  *
21
18
  * `projectUrl` is the app origin with its application mount, such as `https://app.example.com/portal`. `path` is the
22
19
  * Console path, such as `/agents/bot/invocations/abc`. The hosted Console switches to the project when this browser
23
- * linked it, or asks the person to link it first. The URL holds no secret.
20
+ * linked it, or asks the person to link it first. The URL holds no secret. `consoleOrigin` defaults to the Console of
21
+ * `vitehub({ console: { url } })`, else `https://console.vitehub.dev`.
24
22
  *
25
23
  * Throws `RUNTIME_CONSOLE_PROJECT_URL_INVALID` when `projectUrl` is not `https:` (or `http:` on a loopback host), and
26
24
  * `RUNTIME_CONSOLE_PATH_INVALID` when `path` is not a Console path.
27
25
  */
28
26
  declare function hostedConsoleUrl(projectUrl: string, path: string, consoleOrigin?: string): string;
29
- //#endregion
30
- export { normalizeConsoleProjectUrl as i, hostedConsoleUrl as n, normalizeConsolePath as r, hostedConsoleOrigin as t };
27
+ export { normalizeConsolePath as n, normalizeConsoleProjectUrl as r, hostedConsoleUrl as t };
@@ -0,0 +1,71 @@
1
+ import { t as runtimeErrorDiagnostics } from "./error-diagnostics-Dj98U7ch.js";
2
+ import { c as configuredConsoleOrigin } from "./public-url-TlEVxNNh.js";
3
+ // src/hosted-console.ts
4
+ const loopbackHosts = /* @__PURE__ */ new Set([
5
+ "localhost",
6
+ "127.0.0.1",
7
+ "[::1]"
8
+ ]);
9
+ const pathBase = "https://console.invalid";
10
+ /**
11
+ * The Console path of a link, such as `/agents/bot/invocations/abc?tab=trace`, or `undefined` when the value is not a
12
+ * Console path. A Console path starts with one `/`. Absolute URLs, protocol-relative URLs, and backslashes are not
13
+ * Console paths, so a link cannot send the browser to another site. A path that starts with `/_vitehub`, as on a
14
+ * Console that the app serves, loses that prefix.
15
+ */
16
+ function normalizeConsolePath(path) {
17
+ if (!path.startsWith("/") || path.startsWith("//") || path.includes("\\")) return void 0;
18
+ let url;
19
+ try {
20
+ url = new URL(path, pathBase);
21
+ } catch {
22
+ return;
23
+ }
24
+ if (url.origin !== pathBase) return void 0;
25
+ const pathname = url.pathname.replace(/^\/_vitehub(?=\/|$)/, "") || "/";
26
+ if (pathname.startsWith("//")) return void 0;
27
+ return `${pathname}${url.search}${url.hash}`;
28
+ }
29
+ /**
30
+ * The project URL of a link: the app origin and its application mount, such as `https://app.example.com/portal`, or
31
+ * `undefined` when the URL cannot be a project. A project URL is `https:`, or `http:` on a loopback host, and has no
32
+ * user name or password.
33
+ */
34
+ function normalizeConsoleProjectUrl(projectUrl) {
35
+ let url;
36
+ try {
37
+ url = new URL(projectUrl);
38
+ } catch {
39
+ return;
40
+ }
41
+ if (url.username || url.password) return void 0;
42
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && loopbackHosts.has(url.hostname))) return void 0;
43
+ const mount = url.pathname.search(/\/_vitehub(?=\/|$)/);
44
+ const base = (mount === -1 ? url.pathname : url.pathname.slice(0, mount)).replace(/\/+$/, "");
45
+ return `${url.origin}${base}`;
46
+ }
47
+ /**
48
+ * The hosted Console URL that opens one page of a project, such as
49
+ * `https://console.vitehub.dev/open?project=https%3A%2F%2Fapp.example.com&path=%2Fkv`.
50
+ *
51
+ * `projectUrl` is the app origin with its application mount, such as `https://app.example.com/portal`. `path` is the
52
+ * Console path, such as `/agents/bot/invocations/abc`. The hosted Console switches to the project when this browser
53
+ * linked it, or asks the person to link it first. The URL holds no secret. `consoleOrigin` defaults to the Console of
54
+ * `vitehub({ console: { url } })`, else `https://console.vitehub.dev`.
55
+ *
56
+ * Throws `RUNTIME_CONSOLE_PROJECT_URL_INVALID` when `projectUrl` is not `https:` (or `http:` on a loopback host), and
57
+ * `RUNTIME_CONSOLE_PATH_INVALID` when `path` is not a Console path.
58
+ */
59
+ function hostedConsoleUrl(projectUrl, path, consoleOrigin = configuredConsoleOrigin()) {
60
+ const project = normalizeConsoleProjectUrl(projectUrl);
61
+ if (!project) throw runtimeErrorDiagnostics.RUNTIME_CONSOLE_PROJECT_URL_INVALID({ value: projectUrl });
62
+ const consolePath = normalizeConsolePath(path);
63
+ if (!consolePath) throw runtimeErrorDiagnostics.RUNTIME_CONSOLE_PATH_INVALID({ value: path });
64
+ const url = new URL("/open", consoleOrigin);
65
+ url.search = new URLSearchParams({
66
+ project,
67
+ path: consolePath
68
+ }).toString();
69
+ return url.href;
70
+ }
71
+ export { normalizeConsolePath as n, normalizeConsoleProjectUrl as r, hostedConsoleUrl as t };
@@ -1,7 +1,6 @@
1
- import { O as RuntimeContextInput, dt as ViteHubContext, g as MaybePromise, k as RuntimeHostContext, p as CreatedRuntimeContext, pt as ViteHubStandardProps } from "./core-BfUEli_0.js";
2
- import "./execution-budget-BPXbISEt.js";
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
3
  import { Diagnostic, DiagnosticDefinition, DiagnosticJSON, Diagnostics } from "nostics";
4
- //#region src/result.d.ts
5
4
  /**
6
5
  * Error of a ViteHub operation. It is a Nostics diagnostic with a typed `code`.
7
6
  *
@@ -84,8 +83,6 @@ declare function toResultError<TCode extends string, TData>(error: (Diagnostic<T
84
83
  * Return runtime errors as `[error, undefined]`. Throw definition and config errors.
85
84
  */
86
85
  declare function defineErrors<const TCodes extends ErrorCodes>(options: DefineErrorsOptions<TCodes>): ErrorCatalog<TCodes>;
87
- //#endregion
88
- //#region src/lease.d.ts
89
86
  type LeaseOperation = "acquire" | "get" | "release" | "renew";
90
87
  /** The codes that lease operations return. */
91
88
  type LeaseErrorCode = "RUNTIME_LEASE_FAILED" | "RUNTIME_LEASE_INVALID_TTL";
@@ -156,8 +153,6 @@ type LeaseSqlParam = string | number | null;
156
153
  * clocks of the hosts. Works on Postgres and on SQLite 3.35 or later, such as libSQL.
157
154
  */
158
155
  declare function createSqlLeaseStore(client: LeaseSqlClient): LeaseStore;
159
- //#endregion
160
- //#region src/instance.d.ts
161
156
  /** The environment variable that names this server instance. */
162
157
  declare const instanceIdEnv = "VITEHUB_INSTANCE_ID";
163
158
  /**
@@ -166,8 +161,6 @@ declare const instanceIdEnv = "VITEHUB_INSTANCE_ID";
166
161
  * which instance holds a key or runs an Invocation. Give each instance its own value, such as the pod or machine name.
167
162
  */
168
163
  declare function getInstanceId(): string;
169
- //#endregion
170
- //#region src/duration.d.ts
171
164
  /** The units of a {@link Duration}, short and long. Case does not matter at runtime. */
172
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";
173
166
  /** A length of time as a number and a unit, such as `"30s"`, `"5m"`, `"2 hours"`, or `"1 day"`. */
@@ -185,8 +178,6 @@ type Duration = `${number}${DurationUnit}` | `${number} ${DurationUnit}`;
185
178
  * ```
186
179
  */
187
180
  declare function parseDuration(value: Duration, option?: string, round?: "ceil", legacyUnit?: "ms" | "s"): number;
188
- //#endregion
189
- //#region src/diagnostics.d.ts
190
181
  type RuntimeDiagnosticLevel = "debug" | "error" | "info" | "warn";
191
182
  type RuntimeResourceScope = "container" | "host" | "process" | "service" | "workload";
192
183
  type RuntimeResourceUnit = "bytes" | "count" | "microseconds" | "ratio";
@@ -251,8 +242,6 @@ declare function isRuntimeDiagnostic(error: unknown): error is Diagnostic<unknow
251
242
  /** Formats bounded developer diagnostics without exposing causes or stacks. */
252
243
  declare function formatRuntimeDiagnosticError(error: unknown): string;
253
244
  declare function normalizeRuntimeDiagnosticError(error: unknown, options?: RuntimeDiagnosticErrorOptions): RuntimeDiagnosticError;
254
- //#endregion
255
- //#region src/errors.d.ts
256
245
  type ViteHubErrorDetail = boolean | null | number | string | readonly ViteHubErrorDetail[] | {
257
246
  readonly [key: string]: ViteHubErrorDetail | undefined;
258
247
  };
@@ -277,8 +266,6 @@ declare class ViteHubError<TCode extends string = string, TDetails extends ViteH
277
266
  }
278
267
  declare function getViteHubErrorShape(value: unknown): ViteHubErrorShape | undefined;
279
268
  declare function isViteHubError(value: unknown): value is ViteHubErrorShape;
280
- //#endregion
281
- //#region src/request-context.d.ts
282
269
  type RuntimeName = "cloudflare-agents" | "deno" | "unknown" | "vercel" | "vite";
283
270
  type RuntimeContextOptions = Omit<RuntimeContextInput, "event" | "runtime"> & {
284
271
  runtime?: RuntimeName;
@@ -312,13 +299,6 @@ declare function sendPreparedResponse(request: Request, response: Response): Res
312
299
  */
313
300
  declare function getRuntimeContext(value: Request | ViteHubContext): RequestRuntimeContext;
314
301
  declare function getRuntimeContext<const TOptions extends RuntimeContextOptions>(value: Request | ViteHubContext, options: TOptions): RequestRuntimeContext<TOptions>;
315
- //#endregion
316
- //#region ../internal/dist/deployment.d.ts
317
- //#region src/deployment.d.ts
318
- /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
319
- type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
320
- //#endregion
321
- //#region src/host.d.ts
322
302
  declare global {
323
303
  namespace Cloudflare {
324
304
  interface Env {}
@@ -326,20 +306,6 @@ declare global {
326
306
  }
327
307
  /** The codes that `getHostBinding()` returns. */
328
308
  type HostBindingErrorCode = "RUNTIME_HOST_BINDING_NOT_FOUND" | "RUNTIME_HOST_BINDINGS_UNAVAILABLE";
329
- /**
330
- * Returns the host that this code builds or runs on, or `undefined` when nothing names one.
331
- * It reads `VITEHUB_HOST`, `NITRO_PRESET`, `SERVER_PRESET`, then the build variables of Cloudflare Workers Builds
332
- * (`WORKERS_CI`), Netlify, Vercel, and Deno Deploy. Inside a Cloudflare Worker, it returns `"cloudflare"`.
333
- * `vitehub()` uses the same detection when `host` is omitted.
334
- *
335
- * @example
336
- * ```ts
337
- * import { detectHost } from "vite-hub/runtime"
338
- *
339
- * const host = detectHost() ?? "node"
340
- * ```
341
- */
342
- declare function detectHost(env?: Record<string, string | undefined>): ViteHubHost | undefined;
343
309
  /**
344
310
  * Reads one raw binding of the host, such as an R2 bucket, a Durable Object namespace, or a variable of a Cloudflare
345
311
  * Worker. Use it for host features that no ViteHub primitive covers. It works in request handlers, Schedules, Queues,
@@ -360,5 +326,4 @@ declare function detectHost(env?: Record<string, string | undefined>): ViteHubHo
360
326
  */
361
327
  declare function getHostBinding<TName extends keyof Cloudflare.Env & string>(name: TName, event?: object): Result<Cloudflare.Env[TName], HostBindingErrorCode>;
362
328
  declare function getHostBinding<T = unknown>(name: string, event?: object): Result<T, HostBindingErrorCode>;
363
- //#endregion
364
- 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 };
329
+ export { toResultError as $, normalizeRuntimeDiagnosticError as A, LeaseRecord as B, RuntimeResourceObservation as C, RuntimeResourceUnit as D, RuntimeResourceSupport as E, instanceIdEnv as F, createSqlLeaseStore as G, LeaseSqlParam as H, Lease as I, ErrorCodes as J, DefineErrorsOptions as K, LeaseAcquireOptions as L, DurationUnit as M, parseDuration as N, formatRuntimeDiagnosticError as O, getInstanceId as P, defineErrors as Q, LeaseErrorCode as R, RuntimeResourceInspector as S, RuntimeResourceSnapshot as T, LeaseStore as U, LeaseSqlClient as V, createMemoryLeaseStore as W, Result as X, ErrorHandle as Y, ResultError as Z, RuntimeDiagnosticError as _, RuntimeName as a, RuntimeDiagnosticLevel as b, installRequestStandardContext as c, ViteHubErrorDetail as d, ViteHubErrorDetails as f, isViteHubError as g, getViteHubErrorShape as h, RuntimeContextOptions as i, Duration as j, isRuntimeDiagnostic as k, sendPreparedResponse as l, ViteHubErrorShape as m, getHostBinding as n, getRuntimeContext as o, ViteHubErrorOptions as p, ErrorCatalog as q, RequestRuntimeContext as r, getStandardContext as s, HostBindingErrorCode as t, ViteHubError as u, RuntimeDiagnosticErrorOptions as v, RuntimeResourceScope as w, RuntimeDiagnosticReporter as x, RuntimeDiagnosticEvent as y, LeaseOperation as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
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-BfUEli_0.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-DsisbCNa.js";
3
- import { n as hostedConsoleUrl } from "./hosted-console-ZfMo5MW4.js";
4
- import { o as resolvePublicUrl, t as PublicUrlConfig } from "./public-url-BCFhTiTM.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-BPXbISEt.js";
6
- import { o as toResponse, t as SerializedResponse } from "./response-iONbTI0E.js";
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 toResultError, A as normalizeRuntimeDiagnosticError, B as LeaseRecord, C as RuntimeResourceObservation, D as RuntimeResourceUnit, E as RuntimeResourceSupport, F as instanceIdEnv, G as createSqlLeaseStore, H as LeaseSqlParam, I as Lease, J as ErrorCodes, K as DefineErrorsOptions, L as LeaseAcquireOptions, M as DurationUnit, N as parseDuration, O as formatRuntimeDiagnosticError, P as getInstanceId, Q as defineErrors, R as LeaseErrorCode, S as RuntimeResourceInspector, T as RuntimeResourceSnapshot, U as LeaseStore, V as LeaseSqlClient, W as createMemoryLeaseStore, X as Result, Y as ErrorHandle, Z as ResultError, _ as RuntimeDiagnosticError, a as RuntimeName, b as RuntimeDiagnosticLevel, d as ViteHubErrorDetail, f as ViteHubErrorDetails, g as isViteHubError, h as getViteHubErrorShape, i as RuntimeContextOptions, j as Duration, k as isRuntimeDiagnostic, m as ViteHubErrorShape, n as getHostBinding, o as getRuntimeContext, p as ViteHubErrorOptions, q as ErrorCatalog, r as RequestRuntimeContext, s as getStandardContext, t as HostBindingErrorCode, u as ViteHubError, v as RuntimeDiagnosticErrorOptions, w as RuntimeResourceScope, x as RuntimeDiagnosticReporter, y as RuntimeDiagnosticEvent, z as LeaseOperation } from "./index-fSQ1ELEy.js";
3
+ import { t as hostedConsoleUrl } from "./hosted-console-DInG3Xl9.js";
4
+ import { o as resolvePublicUrl, t as PublicUrlConfig } from "./public-url-CaVJ4vFF.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
+ import { n as ViteHubHost, t as detectHost } from "./detect-host-uTgoQ9i4.js";
7
8
  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,6 +1,8 @@
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-Dmsliqan.js";
2
- import { n as getViteHubErrorShape, r as isViteHubError, t as ViteHubError } from "./errors-BQ0ofIL4.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-DpLK9dQt.js";
4
- import { a as toResponse, c as normalizeRuntimeDiagnosticError, o as formatRuntimeDiagnosticError, s as isRuntimeDiagnostic } from "./response-Be5M4WIn.js";
5
- import { a as resolvePublicUrl, l as hostedConsoleUrl } from "./public-url-DizC8CFs.js";
1
+ import { d as createMemoryLeaseStore, f as createSqlLeaseStore, g as instanceIdEnv, h as getInstanceId, i as getStandardContext, l as getHostBinding, m as toResultError, p as defineErrors, r as getRuntimeContext, u as parseDuration } from "./request-context-Dcf59Qh4.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 } from "./public-url-TlEVxNNh.js";
6
+ import { t as hostedConsoleUrl } from "./hosted-console-nLc1pL9J.js";
7
+ import { t as detectHost } from "./detect-host-Du9saPsM.js";
6
8
  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 };
@@ -1,7 +1,12 @@
1
- import { i as normalizeConsoleProjectUrl, r as normalizeConsolePath, t as hostedConsoleOrigin } from "../hosted-console-ZfMo5MW4.js";
2
- import { r as consoleInvocationUrl } from "../public-url-BCFhTiTM.js";
3
- //#region src/route-segment.d.ts
1
+ import { n as normalizeConsolePath, r as normalizeConsoleProjectUrl, t as hostedConsoleUrl } from "../hosted-console-DInG3Xl9.js";
2
+ import { r as consoleInvocationUrl } from "../public-url-CaVJ4vFF.js";
3
+ /** The origin of the hosted Console. */
4
+ export declare const hostedConsoleOrigin = "https://console.vitehub.dev";
5
+ /**
6
+ * The origin of the ViteHub Console that opens this app: `vitehub({ console: { url } })` of a self-hosted Console, else
7
+ * the hosted Console.
8
+ */
9
+ export declare function configuredConsoleOrigin(): string;
4
10
  export declare function encodeRouteSegment(value: string): string;
5
11
  export declare function decodeRouteSegment(segment: string): string | undefined;
6
- //#endregion
7
- export { consoleInvocationUrl, hostedConsoleOrigin, normalizeConsolePath, normalizeConsoleProjectUrl };
12
+ export { consoleInvocationUrl, hostedConsoleUrl, normalizeConsolePath, normalizeConsoleProjectUrl };
@@ -1,2 +1,3 @@
1
- import { c as hostedConsoleOrigin, d as normalizeConsoleProjectUrl, n as consoleInvocationUrl, o as decodeRouteSegment, s as encodeRouteSegment, u as normalizeConsolePath } from "../public-url-DizC8CFs.js";
2
- export { consoleInvocationUrl, decodeRouteSegment, encodeRouteSegment, hostedConsoleOrigin, normalizeConsolePath, normalizeConsoleProjectUrl };
1
+ import { n as normalizeConsolePath, r as normalizeConsoleProjectUrl, t as hostedConsoleUrl } from "../hosted-console-nLc1pL9J.js";
2
+ import { c as configuredConsoleOrigin, l as hostedConsoleOrigin, n as consoleInvocationUrl, o as decodeRouteSegment, s as encodeRouteSegment } from "../public-url-TlEVxNNh.js";
3
+ export { configuredConsoleOrigin, consoleInvocationUrl, decodeRouteSegment, encodeRouteSegment, hostedConsoleOrigin, hostedConsoleUrl, normalizeConsolePath, normalizeConsoleProjectUrl };
@@ -1,2 +1,2 @@
1
- import { Y as createRuntimeWaitUntilController, rt as isResolvable, st as resolveRuntimeValue } from "../core-BfUEli_0.js";
1
+ import { Y as createRuntimeWaitUntilController, rt as isResolvable, st as resolveRuntimeValue } from "../core-auTkK4iZ.js";
2
2
  export { createRuntimeWaitUntilController, isResolvable, resolveRuntimeValue };
@@ -1,2 +1 @@
1
- import { d as isResolvable, h as resolveRuntimeValue, r as createRuntimeWaitUntilController } from "../core-DpLK9dQt.js";
2
- export { createRuntimeWaitUntilController, isResolvable, resolveRuntimeValue };
1
+ export { r as createRuntimeWaitUntilController, d as isResolvable, h as resolveRuntimeValue } from "../core-Crv8CV_r.js";
@@ -0,0 +1,2 @@
1
+ import { t as detectHost } from "../detect-host-uTgoQ9i4.js";
2
+ export { detectHost };
@@ -0,0 +1 @@
1
+ export { t as detectHost } from "../detect-host-Du9saPsM.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 };
@@ -1,2 +1,2 @@
1
- import { t as runtimeErrorDiagnostics } from "../error-diagnostics-0sYgKTT8.js";
1
+ import { t as runtimeErrorDiagnostics } from "../error-diagnostics-DuusexaK.js";
2
2
  export { runtimeErrorDiagnostics };
@@ -1,2 +1 @@
1
- import { t as runtimeErrorDiagnostics } from "../error-diagnostics-BM9W4pBg.js";
2
- export { runtimeErrorDiagnostics };
1
+ export { t as runtimeErrorDiagnostics } from "../error-diagnostics-Dj98U7ch.js";
@@ -1,5 +1,4 @@
1
- import { c as createExecutionBudget, l as isExecutionBudgetExceededError, 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,5 +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
11
9
  export { createExecutionBudget, isExecutionBudgetExceededError };
@@ -1,5 +1,5 @@
1
- import { t as runtimeErrorDiagnostics } from "../error-diagnostics-BM9W4pBg.js";
2
- //#region src/execution-budget.ts
1
+ import { t as runtimeErrorDiagnostics } from "../error-diagnostics-Dj98U7ch.js";
2
+ // src/execution-budget.ts
3
3
  function executionBudgetExceededError(counter, limit) {
4
4
  return Object.assign(runtimeErrorDiagnostics.RUNTIME_EXECUTION_BUDGET_EXCEEDED({ counter }), {
5
5
  counter,
@@ -222,8 +222,7 @@ function normalizeLimits(options) {
222
222
  maxToolCalls: normalize(options.maxToolCalls)
223
223
  };
224
224
  }
225
- //#endregion
226
- //#region src/internal/execution-budget.ts
225
+ // src/internal/execution-budget.ts
227
226
  const budgetHandledTools = /* @__PURE__ */ new WeakMap();
228
227
  /** Internal context key used when a budget-owned tool is reused by another Invocation. */
229
228
  const executionBudgetOverride = Symbol("vitehub.execution-budget-override");
@@ -238,5 +237,4 @@ function isExecutionBudgetHandled(tool, budget) {
238
237
  function executionBudgetHandledBy(tool) {
239
238
  return budgetHandledTools.get(tool);
240
239
  }
241
- //#endregion
242
240
  export { createExecutionBudget, executionBudgetCharged, executionBudgetHandledBy, executionBudgetOverride, isExecutionBudgetExceededError, isExecutionBudgetHandled, markExecutionBudgetHandled };
@@ -1,4 +1,3 @@
1
- //#region src/internal/grant.d.ts
2
1
  declare const grantKind: unique symbol;
3
2
  /**
4
3
  * Proof that one check passed. Only the definition that issued it can verify it.
@@ -33,4 +32,4 @@ export interface GrantDefinition<Kind extends string, Input, Value> {
33
32
  * another bundled copy, or a forged object fails closed. Grants are request-scoped. Never persist one.
34
33
  */
35
34
  export declare function defineGrant<const Kind extends string, Input, Value>(kind: Kind, bind: (input: Input) => Value): GrantDefinition<Kind, Input, Value>;
36
- //#endregion
35
+ export {};