@guren/server 2.28.1 → 2.29.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 (31) hide show
  1. package/dist/{DocsViewerServiceProvider-BMbcTYVw.js → DocsViewerServiceProvider-BVPZjwQp.js} +7 -1
  2. package/dist/{Gate-CYfoGQqh.js → Gate-DFiuutZm.js} +1 -25
  3. package/dist/{McpServiceProvider-PGFPlYTy.js → McpServiceProvider-CvFExxdJ.js} +45 -2
  4. package/dist/{MessageSigner-Bd25ZJAV.js → MessageSigner-DIUT1Yao.js} +4 -2
  5. package/dist/{Resource-BhOua2OB.js → Resource-ZMJH4lyD.js} +2 -1
  6. package/dist/auth/index.js +1 -1
  7. package/dist/{auth-DIugW0O-.js → auth-DRMeSwev.js} +1 -1
  8. package/dist/authorization/index.js +2 -2
  9. package/dist/{authorization-CKOLYWvi.js → authorization-DUjeyGWh.js} +2 -1
  10. package/dist/{dev-banner-DnaL8Ku6.js → dev-banner-wz0V_g0R.js} +1 -1
  11. package/dist/encryption/index.js +2 -2
  12. package/dist/{encryption-CWK5l22W.js → encryption-DF8lZkpj.js} +1 -1
  13. package/dist/http/Application.d.ts +10 -54
  14. package/dist/http/boot-sequence.d.ts +8 -0
  15. package/dist/http/server-lifecycle.d.ts +88 -0
  16. package/dist/index.js +171 -318
  17. package/dist/internal/testing.js +1 -1
  18. package/dist/introspection/types.d.ts +6 -0
  19. package/dist/mcp/McpServiceProvider.d.ts +7 -0
  20. package/dist/mcp/index.js +1 -1
  21. package/dist/mcp/runtime-error-capture.d.ts +24 -0
  22. package/dist/mcp/runtime-errors.d.ts +59 -0
  23. package/dist/mvc/Router.d.ts +2 -0
  24. package/dist/request-container-BbuH0JJy.js +25 -0
  25. package/dist/runtime/index.js +2 -2
  26. package/dist/runtime-error-capture-BclelWhA.js +48 -0
  27. package/dist/runtime-errors-DOPBX0Ox.js +135 -0
  28. package/dist/vite-manifest-DO0pU1vm.js +391 -0
  29. package/package.json +3 -3
  30. package/dist/endpoint-Coq0K_6I.js +0 -26
  31. package/dist/vite-manifest-wPxfAzjW.js +0 -146
@@ -27,7 +27,7 @@ var DocsViewerServiceProvider = class extends ServiceProvider {
27
27
  hono.use(`${DOCS_VIEWER_PATH}/*`, guard);
28
28
  let shell = null;
29
29
  hono.get(DOCS_VIEWER_PATH, async (ctx) => {
30
- shell ??= readFile(cli.docsViewerAssetPath(), "utf-8");
30
+ shell ??= cli.docsViewerShell ? Promise.resolve(cli.docsViewerShell()) : readFile(cli.docsViewerAssetPath(), "utf-8");
31
31
  return ctx.html(await shell);
32
32
  });
33
33
  let cached = null;
@@ -52,6 +52,12 @@ var DocsViewerServiceProvider = class extends ServiceProvider {
52
52
  ETag: etag
53
53
  });
54
54
  });
55
+ hono.get(`${DOCS_VIEWER_PATH}/plans/:slug`, async (ctx) => {
56
+ if (cli.docsViewerPlanPage === void 0) return ctx.json({ message: "This @guren/cli does not serve plan pages; upgrade it" }, 404);
57
+ const page = await cli.docsViewerPlanPage(cwd, ctx.req.param("slug"));
58
+ if (page === void 0) return ctx.json({ message: "No rendered page for this plan (bunx guren plan:render <plan>)" }, 404);
59
+ return ctx.html(page, 200, { "Cache-Control": "no-store" });
60
+ });
55
61
  let mermaid = null;
56
62
  hono.get(`${DOCS_VIEWER_PATH}/assets/mermaid.js`, async (ctx) => {
57
63
  try {
@@ -1,30 +1,6 @@
1
1
  import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
2
2
  import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
3
3
  import { r as getAuthContext } from "./context-af2n5abO.js";
4
- //#region src/http/request-container.ts
5
- /**
6
- * Context variable the serving Application's container is stamped under
7
- * (RFC 0023 §2). The stamp is the first middleware `Application` mounts, so
8
- * nothing an app registers runs ahead of it. The one place a middleware
9
- * reaches its app's container without holding the app.
10
- */
11
- const CONTAINER_CONTEXT_KEY = "guren.container";
12
- /**
13
- * The container of the Application serving `ctx`, or undefined off an
14
- * Application (bare Hono). Judged by shape rather than `instanceof`: a test
15
- * double answering every key must not pass as a container.
16
- */
17
- function tryGetRequestContainer(ctx) {
18
- const container = ctx.get(CONTAINER_CONTEXT_KEY);
19
- return typeof container?.makeOptional === "function" ? container : void 0;
20
- }
21
- /** The container of the Application serving `ctx`; throws off an Application (bare Hono). */
22
- function getRequestContainer(ctx) {
23
- const container = tryGetRequestContainer(ctx);
24
- if (!container) throw new Error("No Application container on this request. The container is stamped by Application; a bare Hono app has none — pass the service explicitly there.");
25
- return container;
26
- }
27
- //#endregion
28
4
  //#region src/errors/exceptions/AuthorizationException.ts
29
5
  /** 403: the user is authenticated but not allowed to perform the action. */
30
6
  var AuthorizationException = class AuthorizationException extends HttpException {
@@ -291,4 +267,4 @@ async function authorize(ability, ...args) {
291
267
  return resolveGate().authorize(ability, ...args);
292
268
  }
293
269
  //#endregion
294
- export { cannot as a, denialToException as c, resolveGate as d, setGate as f, tryGetRequestContainer as g, getRequestContainer as h, can as i, getGate as l, CONTAINER_CONTEXT_KEY as m, Response as n, createGate as o, AuthorizationException as p, authorize as r, defineGate as s, Gate as t, isAuthorizationResponse as u };
270
+ export { cannot as a, denialToException as c, resolveGate as d, setGate as f, can as i, getGate as l, Response as n, createGate as o, AuthorizationException as p, authorize as r, defineGate as s, Gate as t, isAuthorizationResponse as u };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
2
  import { n as ServiceProvider } from "./ServiceProvider-G0YclITd.js";
3
- import { n as createMcpAccessGuard, r as isMcpEndpointEnabled, t as MCP_ENDPOINT_PATH } from "./endpoint-Coq0K_6I.js";
3
+ import { a as MCP_ENDPOINT_PATH, n as RUNTIME_ERRORS_PATH, o as createMcpAccessGuard, s as isMcpEndpointEnabled, t as RUNTIME_ERRORS_BINDING } from "./runtime-error-capture-BclelWhA.js";
4
4
  //#region src/mcp/McpServiceProvider.ts
5
5
  var McpServiceProvider_exports = /* @__PURE__ */ __exportAll({
6
6
  DEV_MCP_CLI_TOO_OLD: () => DEV_MCP_CLI_TOO_OLD,
@@ -34,7 +34,50 @@ var McpServiceProvider = class extends ServiceProvider {
34
34
  console.warn(`[guren] ${DEV_MCP_CLI_TOO_OLD}`);
35
35
  return;
36
36
  }
37
- const handler = cli.createDevMcpHandler({ cwd: process.cwd() });
37
+ if (cli.createDevCenterHandler) {
38
+ const center = cli.createDevCenterHandler({ cwd: process.cwd() });
39
+ for (const path of [
40
+ "/_guren",
41
+ "/_guren/",
42
+ "/_guren/graph.json"
43
+ ]) {
44
+ hono.use(path, createMcpAccessGuard());
45
+ hono.get(path, (ctx) => isMcpEndpointEnabled() ? center.fetch(ctx.req.raw) : ctx.notFound());
46
+ }
47
+ }
48
+ const buffer = this.container.makeOptional(RUNTIME_ERRORS_BINDING);
49
+ const runtimeErrors = buffer ? (query) => isMcpEndpointEnabled() ? buffer.read(query) : {
50
+ schemaVersion: 1,
51
+ status: "unavailable",
52
+ reason: "Runtime collection is disabled."
53
+ } : void 0;
54
+ const handler = cli.createDevMcpHandler({
55
+ cwd: process.cwd(),
56
+ runtimeErrors
57
+ });
58
+ hono.use(RUNTIME_ERRORS_PATH, createMcpAccessGuard());
59
+ hono.get(RUNTIME_ERRORS_PATH, (ctx) => {
60
+ ctx.header("Cache-Control", "no-store");
61
+ if (!isMcpEndpointEnabled()) return ctx.notFound();
62
+ if (!runtimeErrors) return ctx.json({
63
+ schemaVersion: 1,
64
+ status: "unavailable",
65
+ reason: "Runtime collector is not available."
66
+ });
67
+ try {
68
+ return ctx.json(runtimeErrors({
69
+ sessionId: ctx.req.query("sessionId"),
70
+ ...ctx.req.query("after") !== void 0 ? { after: Number(ctx.req.query("after")) } : {},
71
+ ...ctx.req.query("limit") !== void 0 ? { limit: Number(ctx.req.query("limit")) } : {}
72
+ }));
73
+ } catch {
74
+ return ctx.json({
75
+ schemaVersion: 1,
76
+ status: "unavailable",
77
+ reason: "Invalid runtime cursor or limit."
78
+ }, 400);
79
+ }
80
+ });
38
81
  hono.use(MCP_ENDPOINT_PATH, createMcpAccessGuard());
39
82
  hono.all(MCP_ENDPOINT_PATH, (c) => handler.fetch(c.req.raw));
40
83
  }
@@ -75,8 +75,10 @@ var MessageSigner = class {
75
75
  return `${encodedPayload}.${createSignature(encodedPayload, this.keyring.current)}`;
76
76
  }
77
77
  verify(token, options = {}) {
78
- const [encodedPayload, signature, extra] = token.split(".");
79
- if (!encodedPayload || !signature || extra) return null;
78
+ const segments = token.split(".");
79
+ if (segments.length !== 2) return null;
80
+ const [encodedPayload, signature] = segments;
81
+ if (!encodedPayload || !signature) return null;
80
82
  if (![this.keyring.current, ...this.keyring.previous].some((key) => signaturesMatch(signature, createSignature(encodedPayload, key)))) return null;
81
83
  let payload;
82
84
  try {
@@ -8,7 +8,8 @@ import { n as ServiceProvider } from "./ServiceProvider-G0YclITd.js";
8
8
  import { r as getAuthContext } from "./context-af2n5abO.js";
9
9
  import { o as getApiTokenOrFail } from "./api-token-BbgDEd6j.js";
10
10
  import { a as resolveI18n } from "./i18n-DmMKcbqj.js";
11
- import { d as resolveGate, g as tryGetRequestContainer } from "./Gate-CYfoGQqh.js";
11
+ import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
12
+ import { d as resolveGate } from "./Gate-DFiuutZm.js";
12
13
  import { t as jsx_runtime_exports } from "./jsx-runtime.js";
13
14
  import { getCookie } from "hono/cookie";
14
15
  import { isAbsolute, resolve } from "node:path";
@@ -1,3 +1,3 @@
1
- import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as NodeHasher, I as AuthManager, O as parseOAuthRedirectUrl, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "../auth-DIugW0O-.js";
1
+ import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as NodeHasher, I as AuthManager, O as parseOAuthRedirectUrl, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "../auth-DRMeSwev.js";
2
2
  import { C as secureCompare, S as parseTokenUrl, _ as verifyApiToken, a as getApiToken, b as generateToken, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAny, h as tokenCanAll, i as createBearerTokenMiddleware, l as parseApiToken, m as tokenCan, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as buildTokenUrl, w as secureStringCompare, x as hashToken, y as generateId } from "../api-token-BbgDEd6j.js";
3
3
  export { API_TOKEN_KEY, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, AuthenticatableModel, BaseUserProvider, MemoryApiTokenStore, MemoryEmailVerificationStore, MemoryOAuthStateStore, MemoryPasswordResetStore, ModelUserProvider, NodeHasher, OAUTH_SESSION_BINDING_KEY, OAuthManager, SessionGuard, TokenGuard, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildTokenUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createApiToken, createBearerTokenMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createOAuthManager, createOAuthState, createPasswordResetToken, exchangeOAuthCode, fetchOAuthUserProfile, generateId, generateToken, getApiToken, getApiTokenOrFail, getUserApiTokens, hashToken, isEmailVerified, parseApiToken, parseOAuthRedirectUrl, parsePasswordResetUrl, parseTokenUrl, parseVerificationUrl, readBearerToken, requireVerifiedEmail, revokeAllApiTokens, revokeApiToken, sanitizeOAuthRedirect, secureCompare, secureStringCompare, tokenCan, tokenCanAll, tokenCanAny, verifyApiToken, verifyEmailToken, verifyOAuthState, verifyPasswordResetToken };
@@ -1,4 +1,4 @@
1
- import { o as getAppKeyringFromEnv, r as deriveAppKeyring, t as MessageSigner } from "./MessageSigner-Bd25ZJAV.js";
1
+ import { o as getAppKeyringFromEnv, r as deriveAppKeyring, t as MessageSigner } from "./MessageSigner-DIUT1Yao.js";
2
2
  import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
3
3
  import { a as setResolvedPrincipal, i as getResolvedPrincipal, o as AuthenticationException, r as getAuthContext } from "./context-af2n5abO.js";
4
4
  import { d as verifyPassword, o as needsRehash, r as hashPassword } from "./Hash-D2DFd8xX.js";
@@ -1,3 +1,3 @@
1
- import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-CKOLYWvi.js";
2
- import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-CYfoGQqh.js";
1
+ import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-DUjeyGWh.js";
2
+ import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-DFiuutZm.js";
3
3
  export { Gate, Policy, Response, authorize, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, can, cannot, createGate, defineGate, definePolicy, getGate, isAuthorizationResponse, setGate, withAuthorization };
@@ -1,4 +1,5 @@
1
- import { c as denialToException, d as resolveGate, g as tryGetRequestContainer, n as Response, p as AuthorizationException } from "./Gate-CYfoGQqh.js";
1
+ import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
2
+ import { c as denialToException, d as resolveGate, n as Response, p as AuthorizationException } from "./Gate-DFiuutZm.js";
2
3
  //#region src/http/middleware/capabilities.ts
3
4
  /**
4
5
  * Internal security-capability marker (RFC 0007): built-in middleware
@@ -4,7 +4,7 @@ import chalk from "chalk";
4
4
  import figlet from "figlet";
5
5
  import standard from "figlet/importable-fonts/Standard.js";
6
6
  //#region package.json
7
- var version = "2.28.1";
7
+ var version = "2.29.1";
8
8
  //#endregion
9
9
  //#region src/http/dev-banner.ts
10
10
  var dev_banner_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
- import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "../MessageSigner-Bd25ZJAV.js";
1
+ import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "../MessageSigner-DIUT1Yao.js";
2
2
  import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "../Hash-D2DFd8xX.js";
3
3
  import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "../Random-S0OvCuR8.js";
4
- import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "../encryption-CWK5l22W.js";
4
+ import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "../encryption-DF8lZkpj.js";
5
5
  export { Encrypter, MessageSigner, check, createEncrypter, decrypt, deriveAppKey, deriveAppKeyring, encodeDerivedKey, encrypt, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getAppKeyringFromEnv, getEncrypter, hash, hashPassword, hmac, md5, needsRehash, normalizeAppKey, parseAppKey, parsePreviousAppKeys, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, setEncrypter, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl };
@@ -1,4 +1,4 @@
1
- import { a as generateAppKey, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-Bd25ZJAV.js";
1
+ import { a as generateAppKey, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-DIUT1Yao.js";
2
2
  import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
3
3
  import { createCipheriv, createDecipheriv, createHmac, randomBytes } from "crypto";
4
4
  //#region src/encryption/Encrypter.ts
@@ -12,47 +12,13 @@ import type { TranslationLoader } from '../i18n/index.js';
12
12
  import { type SecurityHeadersOptions } from './middleware/security-headers.js';
13
13
  import { type HostAuthorizationOptions } from './middleware/host-authorization.js';
14
14
  import type { DevBannerOptions } from './dev-banner.js';
15
- import { startViteDevServer, type StartViteDevServerOptions } from './vite-dev-server.js';
15
+ import { type StartViteDevServerOptions } from './vite-dev-server.js';
16
16
  import type { InertiaDocumentOptions, InertiaSsrRenderer } from '../mvc/inertia/InertiaEngine.js';
17
17
  import { type SharedInertiaPropsResolver } from '../mvc/inertia/shared.js';
18
18
  import type { EnvSchema } from '../config/env.js';
19
19
  import type { ConfigDefinition } from '../config/define.js';
20
20
  import type { AppManifest } from '../introspection/types.js';
21
- type BunServer = {
22
- stop?: (closeConnections?: boolean) => void | Promise<void>;
23
- requestIP?: (request: Request) => {
24
- address?: string;
25
- } | null;
26
- port?: number;
27
- hostname?: string;
28
- };
29
- type ViteServer = Awaited<ReturnType<typeof startViteDevServer>>['server'];
30
- /**
31
- * The one managed Vite dev server this process runs, and who owns it. A server
32
- * outlives the `listen()` that started it — a `bun --hot` reload adopts it, so
33
- * two applications hold the same object and instance identity cannot tell them
34
- * apart. The slot names exactly one owner at a time instead.
35
- */
36
- export interface ActiveViteDevServer {
37
- readonly server: ViteServer;
38
- readonly localUrl: string;
39
- readonly owner: Application;
40
- /**
41
- * Detaches the owner's process teardown handlers. Whoever replaces this record
42
- * calls it: the outgoing owner is only reachable from here, and handlers left
43
- * attached would still close this server on the next signal.
44
- */
45
- readonly disposeTeardown: () => void;
46
- }
47
- /**
48
- * The ambient slots `listen()` plants on `globalThis`, which a `bun --hot`
49
- * reload keeps, so the next run can find what the previous one left running.
50
- * Exported for the tests that plant stand-ins; not part of the public API.
51
- */
52
- export interface GurenGlobalSlots {
53
- __gurenActiveServer?: BunServer;
54
- __gurenActiveViteDevServer?: ActiveViteDevServer;
55
- }
21
+ export type { ActiveViteDevServer, GurenGlobalSlots } from './server-lifecycle.js';
56
22
  export type BootCallback = (app: Hono) => void | Promise<void>;
57
23
  export type { ServiceProviderConstructor } from '../container/ServiceProvider.js';
58
24
  export type RouteRegistration = (router: Router) => void | Promise<void>;
@@ -194,10 +160,13 @@ export declare class Application {
194
160
  private readonly cookielessAuthPaths;
195
161
  /** {@link configDefinitions} with where each was listed, which ConfigServiceProvider's errors name. */
196
162
  readonly configEntries: ReadonlyArray<ConfiguredDefinition>;
197
- private routesRegistered;
163
+ private routeRegistration?;
164
+ private bootSequence?;
198
165
  private bootPromise?;
199
166
  private manifestPromise?;
200
167
  private bootAttempted;
168
+ /** Settles once the dev-only runtime error buffer is bound; boot waits for it so McpServiceProvider sees the binding. */
169
+ private runtimeErrorsLoaded?;
201
170
  constructor(options?: ApplicationOptions);
202
171
  get auth(): AuthManager;
203
172
  get authOptions(): AuthPluginOptions | undefined;
@@ -234,9 +203,9 @@ export declare class Application {
234
203
  /**
235
204
  * Registers providers, runs the boot callback, mounts routes, boots providers.
236
205
  *
237
- * Booting twice is a no-op — the first call's promise is reused, concurrent
238
- * callers included. A boot that throws is not remembered, so a later call
239
- * retries on the partially mounted app rather than starting clean.
206
+ * Concurrent callers share a boot. On failure, a later call resumes at the
207
+ * failed step; completed steps stay complete. A throwing hook must undo its
208
+ * own partial effects or be safe to retry; otherwise construct a fresh app.
240
209
  */
241
210
  boot(): Promise<void>;
242
211
  /**
@@ -293,7 +262,7 @@ export declare class Application {
293
262
  * or when called twice. `closeActiveConnections` forces in-flight requests
294
263
  * closed, matching Bun's own `stop()`. The managed Vite dev server goes too,
295
264
  * unless a later `listen()` adopted it. Both closes are bounded
296
- * ({@link bunStopTimeoutMs}, {@link viteCloseTimeoutMs}) and then abandoned.
265
+ * (GUREN_BUN_STOP_TIMEOUT_MS and GUREN_VITE_CLOSE_TIMEOUT_MS) and then abandoned.
297
266
  */
298
267
  stop(closeActiveConnections?: boolean): Promise<void>;
299
268
  register(provider: ServiceProviderConstructor): this;
@@ -305,19 +274,6 @@ export declare class Application {
305
274
  * keeps it out of deploy bundles, so a call there prints nothing.
306
275
  */
307
276
  logDevServerBanner(options: DevBannerOptions): void;
308
- /**
309
- * Closes the managed Vite dev server, but only while this application still
310
- * owns it: another `listen()` may have adopted the same object, and closing it
311
- * then would take the asset server out from under an app serving from it. The
312
- * slot's record is the one place that distinction exists.
313
- */
314
- private closeViteDevServer;
315
- /**
316
- * Attaches this application's Vite teardown handlers and returns the disposer.
317
- * It is stored in the active-record slot, not on this instance, because
318
- * whoever takes ownership next is the one that has to call it.
319
- */
320
- private registerViteTeardown;
321
277
  private registerBunTeardown;
322
278
  }
323
279
  export declare function createApp(options?: ApplicationOptions): Application;
@@ -0,0 +1,8 @@
1
+ /** Successful steps stay complete; a rejected step must be safe for its owner to retry. */
2
+ export declare class BootSequence {
3
+ private readonly steps;
4
+ private next;
5
+ private pending?;
6
+ constructor(steps: ReadonlyArray<() => void | Promise<void>>);
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,88 @@
1
+ import type { Application, ApplicationListenOptions } from './Application.js';
2
+ import type { startViteDevServer } from './vite-dev-server.js';
3
+ export type BunServer = {
4
+ stop?: (closeConnections?: boolean) => void | Promise<void>;
5
+ requestIP?: (request: Request) => {
6
+ address?: string;
7
+ } | null;
8
+ port?: number;
9
+ hostname?: string;
10
+ };
11
+ export type ViteServer = Awaited<ReturnType<typeof startViteDevServer>>['server'];
12
+ export declare const MANAGED_VITE_ENV_FLAG = "GUREN_MANAGED_VITE_DEV_SERVER";
13
+ /**
14
+ * The one managed Vite dev server this process runs, and who owns it. A server
15
+ * outlives the `listen()` that started it — a `bun --hot` reload adopts it, so
16
+ * two applications hold the same object and instance identity cannot tell them
17
+ * apart. The slot names exactly one owner at a time instead.
18
+ */
19
+ export interface ActiveViteDevServer {
20
+ readonly server: ViteServer;
21
+ readonly localUrl: string;
22
+ readonly owner: Application;
23
+ /**
24
+ * Detaches the owner's process teardown handlers. Whoever replaces this record
25
+ * calls it: the outgoing owner is only reachable from here, and handlers left
26
+ * attached would still close this server on the next signal.
27
+ */
28
+ readonly disposeTeardown: () => void;
29
+ }
30
+ /**
31
+ * The ambient slots `listen()` plants on `globalThis`, which a `bun --hot`
32
+ * reload keeps, so the next run can find what the previous one left running.
33
+ * Exported for the tests that plant stand-ins; not part of the public API.
34
+ */
35
+ export interface GurenGlobalSlots {
36
+ __gurenActiveServer?: BunServer;
37
+ __gurenActiveViteDevServer?: ActiveViteDevServer;
38
+ }
39
+ type GurenGlobal = typeof globalThis & GurenGlobalSlots;
40
+ export declare function getGlobalState(): GurenGlobal;
41
+ /** The bound on one server `stop()`, and whether hitting it is reported. */
42
+ interface StopBound {
43
+ timeoutMs: number;
44
+ warn: boolean;
45
+ }
46
+ /**
47
+ * Silent: on Bun 1.3.x it is hit on every reload, and there is nothing to
48
+ * report. `GUREN_BUN_STOP_TIMEOUT_MS` can only shorten it: it is set for a
49
+ * production drain, which a reload never is.
50
+ */
51
+ export declare function hotReloadStopBound(): StopBound;
52
+ /** `stop()` bounded by `bound` ({@link bunStopTimeoutMs} by default), warning rather than throwing. */
53
+ export declare function stopBunServerBounded(server: BunServer, closeActiveConnections: boolean, bound?: StopBound): Promise<void>;
54
+ export declare function stopActiveBunServer(closeActiveConnections?: boolean, bound?: StopBound): Promise<void>;
55
+ export declare function setActiveBunServer(server?: BunServer): void;
56
+ /**
57
+ * Gives up the process-wide slot, but only while it still holds `server`: a
58
+ * `listen()` that completed inside the caller's await has repointed it at a
59
+ * live server, which clearing would strip of its exit teardown.
60
+ */
61
+ export declare function releaseActiveBunServer(server: BunServer): void;
62
+ /**
63
+ * `close()` bounded by {@link viteCloseTimeoutMs}: resolves once the server
64
+ * closed, failed (warned), or ran out the clock (warned, abandoned).
65
+ */
66
+ export declare function closeViteDevServerBounded(server: ViteServer): Promise<void>;
67
+ /**
68
+ * Closes the managed Vite dev server whoever owns it. Only `listen()`'s restart
69
+ * path calls this — the one case where an owner's claim does not survive.
70
+ */
71
+ export declare function stopActiveViteDevServer(): Promise<void>;
72
+ /**
73
+ * The managed Vite dev server a previous `listen()` left running. Reusing it
74
+ * keeps the browser's HMR socket connected and skips the
75
+ * {@link viteCloseTimeoutMs} wait. Explicit `vite` options veto reuse: the
76
+ * running server was built from the *previous* call's options.
77
+ */
78
+ export declare function reusableActiveViteDevServer(viteOption: ApplicationListenOptions['vite']): ActiveViteDevServer | undefined;
79
+ /**
80
+ * Closes the managed Vite dev server, but only while this application still
81
+ * owns it: another `listen()` may have adopted the same object, and closing it
82
+ * then would take the asset server out from under an app serving from it. The
83
+ * slot's record is the one place that distinction exists.
84
+ */
85
+ export declare function closeOwnedViteDevServer(owner: Application): Promise<void>;
86
+ export declare function registerBunTeardown(): () => void;
87
+ export declare function adoptViteDevServer(owner: Application, viteServer: ViteServer, localUrl: string): void;
88
+ export {};