@guren/server 2.25.1 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DocsViewerServiceProvider-CIRNHQ2I.js → DocsViewerServiceProvider-BMbcTYVw.js} +1 -1
- package/dist/{Gate-YOt54xGF.js → Gate-BL_zW82W.js} +1 -1
- package/dist/{Job-COMzBNOL.js → Job-DsFMcXVk.js} +35 -3
- package/dist/{McpServiceProvider-B-LioPSz.js → McpServiceProvider-PGFPlYTy.js} +1 -1
- package/dist/{Resource-BdYd4J9a.js → Resource-q3tJpJ0K.js} +194 -54
- package/dist/{ServiceProvider-DDW3MqQJ.js → ServiceProvider-G0YclITd.js} +60 -8
- package/dist/agent/dispatch.d.ts +4 -4
- package/dist/agent/public.js +1 -1
- package/dist/agent/scopes.d.ts +1 -3
- package/dist/agent-request-Caj6bnbj.js +18 -0
- package/dist/auth/AuthManager.d.ts +4 -0
- package/dist/auth/email-verification.d.ts +8 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/password/describe-hasher.d.ts +11 -0
- package/dist/auth/password-reset.d.ts +8 -2
- package/dist/{auth-vFeem6uM.js → auth-DIugW0O-.js} +108 -13
- package/dist/authorization/index.js +2 -2
- package/dist/authorization/middleware.d.ts +8 -0
- package/dist/{authorization-BLhwA2Yh.js → authorization-Daa6CxCg.js} +17 -2
- package/dist/broadcasting/BroadcastManager.d.ts +23 -6
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +13 -1
- package/dist/{broadcasting-BUBCPCnu.js → broadcasting-N4cRV42s.js} +205 -34
- package/dist/cache/CacheManager.d.ts +5 -0
- package/dist/cache/TaggedCache.d.ts +2 -0
- package/dist/cache/index.js +1 -1
- package/dist/cache/pending-computations.d.ts +22 -0
- package/dist/cache/stores/FileStore.d.ts +2 -0
- package/dist/cache/stores/MemoryStore.d.ts +1 -0
- package/dist/cache/stores/RedisStore.d.ts +1 -0
- package/dist/cache/stores/file-lock.d.ts +1 -0
- package/dist/cache/types.d.ts +2 -0
- package/dist/{cache-93n2PCnB.js → cache-BlXopnH1.js} +247 -38
- package/dist/contained-path-BkNSBljW.js +78 -0
- package/dist/container/Container.d.ts +6 -2
- package/dist/container/ServiceProvider.d.ts +27 -2
- package/dist/container/defineModule.d.ts +14 -5
- package/dist/container/definePlugin.d.ts +2 -0
- package/dist/{default-application-D5ezhhiV.js → default-application-DWwscxfW.js} +14 -18
- package/dist/dev-banner-CfQDnkfQ.js +51 -0
- package/dist/{dispatch-BAwzftws.js → dispatch-ENWpBxbE.js} +26 -4
- package/dist/driver-map-CkQc52j-.js +12 -0
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-D1dxfMqD.js → encryption-CWK5l22W.js} +1 -1
- package/dist/events/EventManager.d.ts +2 -0
- package/dist/events/index.js +1 -1
- package/dist/{events-c94CdUFc.js → events-DQavGm8W.js} +20 -7
- package/dist/health/HealthManager.d.ts +0 -1
- package/dist/health/index.js +1 -1
- package/dist/{health-CB0oS_UE.js → health-Bg0Xj3aD.js} +8 -8
- package/dist/host-port-t6wQFaRu.js +15 -0
- package/dist/hot-reload/testing.d.ts +2 -1
- package/dist/http/Application.d.ts +31 -2
- package/dist/http/dev-banner.d.ts +0 -8
- package/dist/http/host-port.d.ts +8 -0
- package/dist/http/middleware/force-https.d.ts +2 -1
- package/dist/http/middleware/index.d.ts +1 -0
- package/dist/http/middleware/rate-limit.d.ts +1 -4
- package/dist/http/middleware/session-manager.d.ts +5 -0
- package/dist/http/middleware/websocket-origin.d.ts +22 -0
- package/dist/http/public-assets.d.ts +6 -1
- package/dist/i18n/index.js +1 -1
- package/dist/{i18n-DqcRD4qL.js → i18n-DmMKcbqj.js} +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +744 -273
- package/dist/internal/agent-request.d.ts +18 -0
- package/dist/internal/app-conventions.d.ts +6 -0
- package/dist/internal/app-conventions.js +9 -0
- package/dist/internal/dispatched-request.d.ts +4 -0
- package/dist/internal/testing.d.ts +1 -1
- package/dist/internal/testing.js +3 -3
- package/dist/internal/zod-json-schema.js +1 -1
- package/dist/introspection/driver-map.d.ts +3 -0
- package/dist/introspection/flag.d.ts +12 -0
- package/dist/introspection/manifest.d.ts +17 -0
- package/dist/introspection/plain-json.d.ts +7 -0
- package/dist/introspection/types.d.ts +167 -0
- package/dist/lambda/index.js +66 -28
- package/dist/logging/index.js +1 -1
- package/dist/{logging-YbKmbAd7.js → logging-Ci0mBk5k.js} +1 -1
- package/dist/mail/index.js +1 -1
- package/dist/{mail-uRBrUl9q.js → mail-CI2Kfe8P.js} +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +3 -2
- package/dist/mvc/Router.d.ts +33 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +31 -0
- package/dist/mvc/inertia/props.d.ts +71 -0
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/registry.d.ts +2 -2
- package/dist/{notifications-LHuujttf.js → notifications-Bp2uamzD.js} +7 -5
- package/dist/providers/ConfigServiceProvider.d.ts +12 -5
- package/dist/queue/Job.d.ts +5 -0
- package/dist/queue/QueueManager.d.ts +3 -0
- package/dist/queue/Worker.d.ts +6 -1
- package/dist/queue/drivers/RedisDriver.d.ts +4 -2
- package/dist/queue/drivers/SqsDriver.d.ts +31 -2
- package/dist/queue/drivers/redis-queue-scripts.d.ts +83 -0
- package/dist/queue/index.js +2 -2
- package/dist/queue/serialize.d.ts +7 -0
- package/dist/queue/types.d.ts +13 -2
- package/dist/{queue-BiBn5Sff.js → queue-C8s3buYz.js} +299 -125
- package/dist/redis/RedisEmailVerificationStore.d.ts +2 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +2 -0
- package/dist/redis/auth-token-scripts.d.ts +4 -0
- package/dist/redis/index.js +50 -0
- package/dist/runtime/index.js +17 -37
- package/dist/scheduling/ScheduledTask.d.ts +2 -1
- package/dist/scheduling/index.js +1 -1
- package/dist/{scheduling-DhYfbJFj.js → scheduling-DNV5tj44.js} +32 -38
- package/dist/serialize-CKXek0Tr.js +17 -0
- package/dist/storage/StorageManager.d.ts +5 -0
- package/dist/storage/drivers/LocalDriver.d.ts +15 -0
- package/dist/storage/index.js +1 -1
- package/dist/storage/url-path.d.ts +2 -0
- package/dist/{storage-6HLaUf9j.js → storage-IlUesK2t.js} +91 -29
- package/dist/support/contained-path.d.ts +8 -0
- package/dist/support/registry-collision.d.ts +12 -0
- package/dist/{vite-manifest-DK55BTLk.js → vite-manifest-wPxfAzjW.js} +2 -58
- package/package.json +6 -2
- package/dist/trim-slashes-BLY9hKAa.js +0 -22
package/dist/index.js
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as setInertiaSsrRenderer, D as isDeferredProp, E as isAlwaysProp, O as ensureErrorStackTracePolyfill, S as setInertiaDocument, T as defer, a as renderDocument, b as inertia, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, w as always } from "./Resource-q3tJpJ0K.js";
|
|
2
2
|
import { a as parseRequestPayload, i as parseRequestBody, n as flattenRequestQueries, r as formatValidationErrors } from "./request-CLOYytGP.js";
|
|
3
3
|
import { i as setValidatedInput, n as getValidatedInput } from "./validated-input-D84J8wcC.js";
|
|
4
4
|
import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
|
|
5
5
|
import { n as ValidationException } from "./errors-JpkcCjjn.js";
|
|
6
|
-
import { a as withAuthorization, c as capabilitiesOf, i as
|
|
7
|
-
import { a as mapToolResponse, i as describeBuildFailure, n as advertisesStructuredOutput,
|
|
8
|
-
import {
|
|
6
|
+
import { a as withAuthorization, c as capabilitiesOf, i as derivableAbility, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-Daa6CxCg.js";
|
|
7
|
+
import { a as mapToolResponse, c as AGENT_PREFLIGHT_VERDICT_HEADER, i as describeBuildFailure, n as advertisesStructuredOutput, o as isDispatchedToolRequest, r as buildToolRequest, t as PREFLIGHT_ARGUMENT } from "./dispatch-ENWpBxbE.js";
|
|
8
|
+
import { i as trimSlashes } from "./contained-path-BkNSBljW.js";
|
|
9
9
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
10
10
|
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";
|
|
11
11
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
12
|
-
import { A as verifyOAuthState, B as
|
|
12
|
+
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as normalizeRedirectTarget, G as installAgentPrincipal, H as NodeHasher, I as AuthManager, J as createSessionMiddleware, K as readAgentPrincipal, L as DEFAULT_PROVIDER, M as jsonResponse, N as hostMatchesAllowlist, O as parseOAuthRedirectUrl, P as isAppRelativePath, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, V as DefaultHasher, W as BaseUserProvider, X as getSessionFromContext, Y as defaultCookieSecure, _ 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, j as defineMiddleware, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, q as MemorySessionStore, 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";
|
|
13
13
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
14
14
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
15
|
-
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, h as warnDeprecatedSetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-
|
|
16
|
-
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-
|
|
15
|
+
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, h as warnDeprecatedSetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-DWwscxfW.js";
|
|
16
|
+
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-G0YclITd.js";
|
|
17
17
|
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-af2n5abO.js";
|
|
18
18
|
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";
|
|
19
19
|
import { _ as verifyApiToken, a as getApiToken, c as hasBearerHeader, 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 } from "./api-token-BbgDEd6j.js";
|
|
20
20
|
import { a as runInRequestScope, i as keepAlive, n as filterSensitiveData, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
21
|
-
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-
|
|
21
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-BlXopnH1.js";
|
|
22
22
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
23
23
|
import { r as isMcpEndpointEnabled } from "./endpoint-Coq0K_6I.js";
|
|
24
24
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import { a as setBroadcastManager, c as PresenceChannel, d as createWebSocketOriginGuard, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "./broadcasting-N4cRV42s.js";
|
|
26
|
+
import { c as tc, d as Translator, f as getPluralizationRule, i as getI18n, l as tryGetI18n, m as selectPluralForm, n as I18nManager, o as setI18n, p as pluralizationRules, r as createI18n, s as t, t as MemoryLoader, u as JsonLoader } from "./i18n-DmMKcbqj.js";
|
|
27
|
+
import { a as cannot, f as setGate, g as tryGetRequestContainer, h as getRequestContainer, i as can, l as getGate, m as CONTAINER_CONTEXT_KEY, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-BL_zW82W.js";
|
|
28
|
+
import { n as isAgentToolRequest } from "./agent-request-Caj6bnbj.js";
|
|
27
29
|
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
28
|
-
import {
|
|
30
|
+
import { n as isWildcardHost, t as formatHostPort } from "./host-port-t6wQFaRu.js";
|
|
31
|
+
import { c as isViteProduction, d as startViteDevServer, i as clientManifestCandidates, l as loadViteManifest, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-wPxfAzjW.js";
|
|
29
32
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
30
|
-
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-
|
|
31
|
-
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-
|
|
32
|
-
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-
|
|
33
|
-
import { a as processJob, c as RedisDriver$1, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver$1 } from "./queue-
|
|
34
|
-
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "./mail-
|
|
33
|
+
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-DQavGm8W.js";
|
|
34
|
+
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-Bp2uamzD.js";
|
|
35
|
+
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-DsFMcXVk.js";
|
|
36
|
+
import { a as processJob, c as RedisDriver$1, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver$1 } from "./queue-C8s3buYz.js";
|
|
37
|
+
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "./mail-CI2Kfe8P.js";
|
|
35
38
|
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
36
|
-
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-
|
|
37
|
-
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "./broadcasting-BUBCPCnu.js";
|
|
39
|
+
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-Ci0mBk5k.js";
|
|
38
40
|
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";
|
|
39
|
-
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-
|
|
40
|
-
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-
|
|
41
|
-
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "./health-
|
|
42
|
-
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-
|
|
41
|
+
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";
|
|
42
|
+
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-IlUesK2t.js";
|
|
43
|
+
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "./health-Bg0Xj3aD.js";
|
|
44
|
+
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-DNV5tj44.js";
|
|
43
45
|
import { Hono } from "hono";
|
|
44
46
|
import { deleteCookie, getCookie } from "hono/cookie";
|
|
45
47
|
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
46
48
|
import { join, resolve as resolve$1 } from "node:path";
|
|
49
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
47
50
|
import { cors } from "hono/cors";
|
|
48
51
|
import { createMiddleware } from "hono/factory";
|
|
49
52
|
import { serialize } from "hono/utils/cookie";
|
|
@@ -416,12 +419,13 @@ var Router = class {
|
|
|
416
419
|
this.modelBindings.clear();
|
|
417
420
|
}
|
|
418
421
|
definitions() {
|
|
419
|
-
return this.registry.map(({ method, path, name, schemas, resource, openapi, routeMiddlewareNames, middlewares, scopedMiddlewares, handler, bindings, agent, prototype }) => ({
|
|
422
|
+
return this.registry.map(({ method, path, name, schemas, resource, openapi, routeMiddlewareNames, middlewares, scopedMiddlewares, handler, bindings, agent, prototype, module }) => ({
|
|
420
423
|
method,
|
|
421
424
|
path,
|
|
422
425
|
name,
|
|
423
426
|
schemas,
|
|
424
427
|
prototype,
|
|
428
|
+
...module === void 0 ? {} : { module },
|
|
425
429
|
resource: serializeResourceHint(resource),
|
|
426
430
|
agent: agent ? cloneAgentMetadata(agent) : void 0,
|
|
427
431
|
middlewareNames: [...routeMiddlewareNames],
|
|
@@ -436,6 +440,47 @@ var Router = class {
|
|
|
436
440
|
...openapi
|
|
437
441
|
}));
|
|
438
442
|
}
|
|
443
|
+
/** How many routes are registered, without building {@link definitions}. */
|
|
444
|
+
get routeCount() {
|
|
445
|
+
return this.registry.length;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Records `module` on every route registered from index `start` on. `mountModuleRoutes()` calls
|
|
449
|
+
* it once the registrar settled, so a route an async registrar adds after an `await` counts, and a
|
|
450
|
+
* module a registrar mounts itself is named after the outer one, which `manifest.modules` lists.
|
|
451
|
+
* @internal
|
|
452
|
+
*/
|
|
453
|
+
assignModule(start, module) {
|
|
454
|
+
for (let index = start; index < this.registry.length; index++) this.registry[index].module = module;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* The handler behind each {@link definitions} entry, index-aligned with it
|
|
458
|
+
* (RFC 0026 §3): the controller class there is reduced to its name.
|
|
459
|
+
*/
|
|
460
|
+
registeredHandlers() {
|
|
461
|
+
return this.registry.map(({ handler }, index) => isControllerAction(handler) ? {
|
|
462
|
+
index,
|
|
463
|
+
controller: handler[0],
|
|
464
|
+
action: String(handler[1])
|
|
465
|
+
} : { index });
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Every alias and group resolved, and each route's chain in `mount()` order,
|
|
469
|
+
* index-aligned with {@link definitions} (RFC 0026 §3). Like `definitions()`,
|
|
470
|
+
* an unregistered name is reported rather than thrown.
|
|
471
|
+
*/
|
|
472
|
+
describeMiddleware() {
|
|
473
|
+
const aliases = {};
|
|
474
|
+
for (const name of [...this.middlewareAliases.keys(), ...this.middlewareGroups.keys()].sort()) aliases[name] = this.describeNamedMiddleware(name);
|
|
475
|
+
return {
|
|
476
|
+
aliases,
|
|
477
|
+
routes: this.registry.map((route) => [...route.routeMiddlewareNames.map((name) => aliases[name] ?? this.describeNamedMiddleware(name)), ...[...route.scopedMiddlewares, ...route.middlewares].map((handler) => ({
|
|
478
|
+
kind: "inline",
|
|
479
|
+
name: handler.name || null,
|
|
480
|
+
capabilities: this.aggregateCapabilities([], [handler])
|
|
481
|
+
}))])
|
|
482
|
+
};
|
|
483
|
+
}
|
|
439
484
|
applyMiddlewareScope(items, callback) {
|
|
440
485
|
this.middlewareStack.push([...items]);
|
|
441
486
|
try {
|
|
@@ -516,6 +561,38 @@ var Router = class {
|
|
|
516
561
|
for (const handler of inline) absorbStamp(capabilitiesOf(handler));
|
|
517
562
|
return aggregated;
|
|
518
563
|
}
|
|
564
|
+
describeNamedMiddleware(name) {
|
|
565
|
+
const capabilities = this.aggregateCapabilities([name], []);
|
|
566
|
+
if (this.middlewareGroups.has(name)) {
|
|
567
|
+
const members = this.expandGroup(name, /* @__PURE__ */ new Set());
|
|
568
|
+
const unresolved = members.filter((member) => !this.middlewareAliases.has(member));
|
|
569
|
+
return {
|
|
570
|
+
kind: "group",
|
|
571
|
+
name,
|
|
572
|
+
members,
|
|
573
|
+
capabilities,
|
|
574
|
+
...unresolved.length > 0 ? { unresolvedMembers: unresolved } : {}
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
return this.middlewareAliases.has(name) ? {
|
|
578
|
+
kind: "alias",
|
|
579
|
+
name,
|
|
580
|
+
capabilities
|
|
581
|
+
} : {
|
|
582
|
+
kind: "alias",
|
|
583
|
+
name,
|
|
584
|
+
capabilities,
|
|
585
|
+
unresolved: true
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
/** A group's alias names through nested groups, each group expanded once whatever path reaches it. */
|
|
589
|
+
expandGroup(name, visited) {
|
|
590
|
+
visited.add(name);
|
|
591
|
+
return (this.middlewareGroups.get(name) ?? []).flatMap((member) => {
|
|
592
|
+
if (!this.middlewareGroups.has(member)) return [member];
|
|
593
|
+
return visited.has(member) ? [] : this.expandGroup(member, visited);
|
|
594
|
+
});
|
|
595
|
+
}
|
|
519
596
|
resolveMiddlewareNames(names, seen) {
|
|
520
597
|
const handlers = [];
|
|
521
598
|
const visited = seen ?? /* @__PURE__ */ new Set();
|
|
@@ -998,6 +1075,17 @@ const BUILT_IN_SESSION_DRIVERS = /* @__PURE__ */ new Map([
|
|
|
998
1075
|
["database", true],
|
|
999
1076
|
["redis", true]
|
|
1000
1077
|
]);
|
|
1078
|
+
/** Null for a driver outside {@link BUILT_IN_SESSION_DRIVERS}: a plugin's `gurenPlugin` manifest says which it is. */
|
|
1079
|
+
function sessionDriverIsPerProcess(driver) {
|
|
1080
|
+
const shared = BUILT_IN_SESSION_DRIVERS.get(driver);
|
|
1081
|
+
return shared === void 0 ? null : !shared;
|
|
1082
|
+
}
|
|
1083
|
+
/** drizzle's `getTableName()`, read through its registry symbol: server must not depend on the ORM. */
|
|
1084
|
+
function drizzleTableName(table) {
|
|
1085
|
+
if (!table || typeof table !== "object") return void 0;
|
|
1086
|
+
const name = table[Symbol.for("drizzle:Name")];
|
|
1087
|
+
return typeof name === "string" ? name : void 0;
|
|
1088
|
+
}
|
|
1001
1089
|
function isPrunable(store) {
|
|
1002
1090
|
return typeof store.deleteExpired === "function";
|
|
1003
1091
|
}
|
|
@@ -1054,6 +1142,23 @@ var SessionManager = class {
|
|
|
1054
1142
|
getStoreNames() {
|
|
1055
1143
|
return Array.from(this.configs.keys());
|
|
1056
1144
|
}
|
|
1145
|
+
/** The declared stores and the default, building none of them (RFC 0026 §1). */
|
|
1146
|
+
describe() {
|
|
1147
|
+
const stores = {};
|
|
1148
|
+
for (const [name, config] of this.configs) {
|
|
1149
|
+
const driver = config.driver;
|
|
1150
|
+
const table = driver === "database" ? drizzleTableName(config.table) : void 0;
|
|
1151
|
+
stores[name] = {
|
|
1152
|
+
driver,
|
|
1153
|
+
...table === void 0 ? {} : { table },
|
|
1154
|
+
perProcess: sessionDriverIsPerProcess(driver)
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
return {
|
|
1158
|
+
default: this.defaultStoreName,
|
|
1159
|
+
stores
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1057
1162
|
/**
|
|
1058
1163
|
* Sweep expired sessions from the default store and from any other store
|
|
1059
1164
|
* already built, on stores that support it (`deleteExpired`). Stores that
|
|
@@ -1346,15 +1451,13 @@ function validateSafe(schema, data) {
|
|
|
1346
1451
|
var BaseMemoryStore = class {
|
|
1347
1452
|
now;
|
|
1348
1453
|
cleanupInterval;
|
|
1349
|
-
/**
|
|
1350
|
-
* Unlike the cache sweep, this interval is not `unref()`ed, so a leaked one
|
|
1351
|
-
* both duplicates work and keeps the process alive on its own.
|
|
1352
|
-
*/
|
|
1454
|
+
/** A sweep leaked across a hot reload would run beside this one. */
|
|
1353
1455
|
hotReloadClaim;
|
|
1354
1456
|
constructor(cleanupIntervalMs = 6e4, now = () => Date.now()) {
|
|
1355
1457
|
this.now = now;
|
|
1356
1458
|
if (cleanupIntervalMs <= 0) return;
|
|
1357
1459
|
this.cleanupInterval = setInterval(() => this.cleanup(), cleanupIntervalMs);
|
|
1460
|
+
this.cleanupInterval.unref?.();
|
|
1358
1461
|
this.hotReloadClaim = claimHotDisposable("rate-limit-store", isHotReloadRuntime() ? (/* @__PURE__ */ new Error()).stack : void 0, this.constructor.name, () => this.destroy());
|
|
1359
1462
|
}
|
|
1360
1463
|
destroy() {
|
|
@@ -1375,21 +1478,21 @@ var MemoryRateLimitStore = class extends BaseMemoryStore {
|
|
|
1375
1478
|
this.entries.delete(key);
|
|
1376
1479
|
return null;
|
|
1377
1480
|
}
|
|
1378
|
-
return entry;
|
|
1481
|
+
return { ...entry };
|
|
1379
1482
|
}
|
|
1380
1483
|
async increment(key, windowMs) {
|
|
1381
1484
|
const now = this.now();
|
|
1382
1485
|
const existing = this.entries.get(key);
|
|
1383
1486
|
if (existing && now < existing.resetAt) {
|
|
1384
1487
|
existing.count++;
|
|
1385
|
-
return existing;
|
|
1488
|
+
return { ...existing };
|
|
1386
1489
|
}
|
|
1387
1490
|
const entry = {
|
|
1388
1491
|
count: 1,
|
|
1389
1492
|
resetAt: now + windowMs
|
|
1390
1493
|
};
|
|
1391
1494
|
this.entries.set(key, entry);
|
|
1392
|
-
return entry;
|
|
1495
|
+
return { ...entry };
|
|
1393
1496
|
}
|
|
1394
1497
|
async reset(key) {
|
|
1395
1498
|
this.entries.delete(key);
|
|
@@ -1795,7 +1898,8 @@ function isSafeRedirectUrl(url, requestUrl, allowedHosts = []) {
|
|
|
1795
1898
|
//#region src/http/middleware/force-https.ts
|
|
1796
1899
|
/**
|
|
1797
1900
|
* Redirects HTTP to HTTPS and sets Strict-Transport-Security. Equivalent to
|
|
1798
|
-
* Rails' `force_ssl`.
|
|
1901
|
+
* Rails' `force_ssl`. An agent tool call the dispatcher re-enters in process
|
|
1902
|
+
* passes through.
|
|
1799
1903
|
*/
|
|
1800
1904
|
function createForceHttpsMiddleware(options = {}) {
|
|
1801
1905
|
const { hstsMaxAge = 31536e3, hstsIncludeSubDomains = true, hstsPreload = false, exclude = [] } = options;
|
|
@@ -1806,12 +1910,7 @@ function createForceHttpsMiddleware(options = {}) {
|
|
|
1806
1910
|
const url = new URL(ctx.req.url);
|
|
1807
1911
|
if ((ctx.req.header("x-forwarded-proto") ?? url.protocol.replace(":", "")) !== "https") {
|
|
1808
1912
|
const path = url.pathname + url.search;
|
|
1809
|
-
|
|
1810
|
-
if (path.startsWith(pattern.slice(0, -1))) {
|
|
1811
|
-
await next();
|
|
1812
|
-
return;
|
|
1813
|
-
}
|
|
1814
|
-
} else if (path === pattern) {
|
|
1913
|
+
if (exclude.some((pattern) => pattern.endsWith("*") ? path.startsWith(pattern.slice(0, -1)) : path === pattern) || isDispatchedToolRequest(ctx.req.raw)) {
|
|
1815
1914
|
await next();
|
|
1816
1915
|
return;
|
|
1817
1916
|
}
|
|
@@ -1863,17 +1962,6 @@ function requestLoggingMiddleware() {
|
|
|
1863
1962
|
});
|
|
1864
1963
|
}
|
|
1865
1964
|
//#endregion
|
|
1866
|
-
//#region src/http/middleware/index.ts
|
|
1867
|
-
function defineMiddleware(handler) {
|
|
1868
|
-
return handler;
|
|
1869
|
-
}
|
|
1870
|
-
function jsonResponse(data, status = 200) {
|
|
1871
|
-
return new Response(JSON.stringify(data), {
|
|
1872
|
-
status,
|
|
1873
|
-
headers: { "Content-Type": "application/json; charset=utf-8" }
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
//#endregion
|
|
1877
1965
|
//#region src/http/middleware/auth.ts
|
|
1878
1966
|
const TESTING_USER_HEADER = "x-testing-user";
|
|
1879
1967
|
function resolveTestingUser(ctx) {
|
|
@@ -1915,29 +2003,25 @@ function attachAuthContext(contextFactory) {
|
|
|
1915
2003
|
await next();
|
|
1916
2004
|
};
|
|
1917
2005
|
}
|
|
2006
|
+
function refuse$1(ctx, options, status, message) {
|
|
2007
|
+
if (options.redirectTo) return isAgentToolRequest(ctx) ? jsonResponse({ message }, status) : ctx.redirect(options.redirectTo);
|
|
2008
|
+
return options.responseFactory ? options.responseFactory() : jsonResponse({ message }, status);
|
|
2009
|
+
}
|
|
1918
2010
|
function requireAuthenticated(options = {}) {
|
|
1919
|
-
const {
|
|
2011
|
+
const { status = 401 } = options;
|
|
1920
2012
|
return stampCapabilities(async (ctx, next) => {
|
|
1921
2013
|
const auth = getAuthContext(ctx);
|
|
1922
2014
|
if (!auth) throw new Error("Auth context has not been attached. Did you register the auth middleware?");
|
|
1923
|
-
if (!await auth.check())
|
|
1924
|
-
if (redirectTo) return ctx.redirect(redirectTo);
|
|
1925
|
-
if (responseFactory) return responseFactory();
|
|
1926
|
-
return jsonResponse({ message: "Unauthorized" }, status);
|
|
1927
|
-
}
|
|
2015
|
+
if (!await auth.check()) return refuse$1(ctx, options, status, "Unauthorized");
|
|
1928
2016
|
await next();
|
|
1929
2017
|
}, { authentication: { mode: "required" } });
|
|
1930
2018
|
}
|
|
1931
2019
|
function requireGuest(options = {}) {
|
|
1932
|
-
const {
|
|
2020
|
+
const { status = 403 } = options;
|
|
1933
2021
|
return stampCapabilities(async (ctx, next) => {
|
|
1934
2022
|
const auth = getAuthContext(ctx);
|
|
1935
2023
|
if (!auth) throw new Error("Auth context has not been attached. Did you register the auth middleware?");
|
|
1936
|
-
if (!await auth.guest())
|
|
1937
|
-
if (redirectTo) return ctx.redirect(redirectTo);
|
|
1938
|
-
if (responseFactory) return responseFactory();
|
|
1939
|
-
return jsonResponse({ message: "Already authenticated" }, status);
|
|
1940
|
-
}
|
|
2024
|
+
if (!await auth.guest()) return refuse$1(ctx, options, status, "Already authenticated");
|
|
1941
2025
|
await next();
|
|
1942
2026
|
}, { authentication: { mode: "guest-only" } });
|
|
1943
2027
|
}
|
|
@@ -2524,10 +2608,10 @@ var InertiaServiceProvider = class extends ServiceProvider {
|
|
|
2524
2608
|
const session = getSessionFromContext(ctx);
|
|
2525
2609
|
if (session) {
|
|
2526
2610
|
const errors = session.getFlash("errors");
|
|
2527
|
-
return errors && Object.keys(errors).length > 0 ? { errors } : {};
|
|
2611
|
+
return errors && Object.keys(errors).length > 0 ? { errors: always(errors) } : {};
|
|
2528
2612
|
}
|
|
2529
2613
|
const errors = readValidationErrorsCookie(ctx);
|
|
2530
|
-
return errors ? { errors } : {};
|
|
2614
|
+
return errors ? { errors: always(errors) } : {};
|
|
2531
2615
|
}, this.container);
|
|
2532
2616
|
}
|
|
2533
2617
|
};
|
|
@@ -2571,30 +2655,46 @@ function recordEnvReads(values) {
|
|
|
2571
2655
|
//#endregion
|
|
2572
2656
|
//#region src/providers/ConfigServiceProvider.ts
|
|
2573
2657
|
/**
|
|
2574
|
-
* Validates `createApp({ env })` and binds it as `env`, then resolves and binds
|
|
2575
|
-
*
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2658
|
+
* Validates `createApp({ env })` and binds it as `env`, then resolves and binds each
|
|
2659
|
+
* `createApp({ config })` definition, then each module's (RFC 0027 §1-§3, RFC 0002).
|
|
2660
|
+
* Registered first: a bad environment fails the boot before anything registers,
|
|
2661
|
+
* every later register() sees the configured managers, and a later provider that
|
|
2662
|
+
* rebinds one fails the boot through {@link ownedBindings}.
|
|
2579
2663
|
*/
|
|
2580
2664
|
var ConfigServiceProvider = class extends ServiceProvider {
|
|
2581
2665
|
env = {};
|
|
2582
2666
|
unset = /* @__PURE__ */ new Set();
|
|
2583
2667
|
resolved = [];
|
|
2584
2668
|
owned = /* @__PURE__ */ new Map();
|
|
2669
|
+
warnings = [];
|
|
2585
2670
|
register() {
|
|
2671
|
+
this.bindAll("throw");
|
|
2672
|
+
}
|
|
2673
|
+
/** Under introspection (RFC 0026) the environment has no secrets: problems are reported, not thrown. */
|
|
2674
|
+
introspect() {
|
|
2675
|
+
this.bindAll("report");
|
|
2676
|
+
}
|
|
2677
|
+
bindAll(mode) {
|
|
2586
2678
|
const app = this.container.make("app");
|
|
2587
|
-
this.
|
|
2679
|
+
this.warnings = [];
|
|
2680
|
+
this.env = this.parseEnv(app, mode);
|
|
2588
2681
|
this.resolved = [];
|
|
2589
2682
|
this.owned = /* @__PURE__ */ new Map();
|
|
2590
|
-
const
|
|
2591
|
-
assertDistinctKeys(
|
|
2592
|
-
for (const
|
|
2683
|
+
const entries = app.configEntries;
|
|
2684
|
+
assertDistinctKeys(entries);
|
|
2685
|
+
for (const entry of entries) {
|
|
2686
|
+
const { definition } = entry;
|
|
2593
2687
|
const { env, read } = recordEnvReads(this.env);
|
|
2594
2688
|
const config = definition.resolve(env);
|
|
2595
2689
|
const placeholders = [...read].filter((key) => this.unset.has(key));
|
|
2596
2690
|
if (placeholders.length > 0) {
|
|
2597
|
-
|
|
2691
|
+
const message = `the "${definition.key}" config reads ${placeholders.join(", ")}, which the environment does not set; it was left unbound.`;
|
|
2692
|
+
warnOnce(`config-unverified:${definition.key}`, `[guren] ${message}`);
|
|
2693
|
+
this.warnings.push({
|
|
2694
|
+
code: "config-unverified",
|
|
2695
|
+
message,
|
|
2696
|
+
key: definition.key
|
|
2697
|
+
});
|
|
2598
2698
|
continue;
|
|
2599
2699
|
}
|
|
2600
2700
|
const before = new Map(this.container.getBindings().map((key) => [key, this.container.bindingOf(key)]));
|
|
@@ -2603,7 +2703,7 @@ var ConfigServiceProvider = class extends ServiceProvider {
|
|
|
2603
2703
|
const binding = this.container.bindingOf(key);
|
|
2604
2704
|
if (binding !== before.get(key)) this.owned.set(key, {
|
|
2605
2705
|
binding,
|
|
2606
|
-
source: `config/${definition.key}.ts`
|
|
2706
|
+
source: `config/${definition.key}.ts${entry.module === void 0 ? "" : ` of the "${entry.module}" module`}`
|
|
2607
2707
|
});
|
|
2608
2708
|
}
|
|
2609
2709
|
this.resolved.push({
|
|
@@ -2615,30 +2715,463 @@ var ConfigServiceProvider = class extends ServiceProvider {
|
|
|
2615
2715
|
async boot() {
|
|
2616
2716
|
for (const { definition, config } of this.resolved) await definition.boot?.(this.container, config, this.env);
|
|
2617
2717
|
}
|
|
2718
|
+
/** @internal Env problems reported under introspection, and configs left unbound, for the manifest (RFC 0027 §1). */
|
|
2719
|
+
manifestWarnings() {
|
|
2720
|
+
return this.warnings;
|
|
2721
|
+
}
|
|
2618
2722
|
/** @internal The bindings the definitions made, for ProviderManager's twice-configured check. */
|
|
2619
2723
|
ownedBindings() {
|
|
2620
2724
|
return this.owned;
|
|
2621
2725
|
}
|
|
2622
|
-
parseEnv(app) {
|
|
2726
|
+
parseEnv(app, mode) {
|
|
2623
2727
|
const schema = app.envSchema;
|
|
2624
2728
|
this.unset = /* @__PURE__ */ new Set();
|
|
2625
2729
|
if (!schema) return {};
|
|
2626
2730
|
const source = this.container.makeOptional("env.source");
|
|
2627
|
-
const
|
|
2628
|
-
const
|
|
2629
|
-
|
|
2731
|
+
const parsed = schema.parse(source, { mode });
|
|
2732
|
+
for (const problem of parsed.problems) {
|
|
2733
|
+
warnOnce(`env-invalid:${problem.key}`, `[guren] Invalid environment: ${problem.key} ${problem.message} (reported under introspection).`);
|
|
2734
|
+
this.warnings.push({
|
|
2735
|
+
code: "env-invalid",
|
|
2736
|
+
message: `${problem.key} ${problem.message}`
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2630
2739
|
this.unset = parsed.unset;
|
|
2631
2740
|
this.container.instance("env", parsed.values);
|
|
2632
2741
|
return parsed.values;
|
|
2633
2742
|
}
|
|
2634
2743
|
};
|
|
2635
|
-
function assertDistinctKeys(
|
|
2744
|
+
function assertDistinctKeys(entries) {
|
|
2636
2745
|
const seen = /* @__PURE__ */ new Map();
|
|
2637
|
-
|
|
2638
|
-
const first = seen.get(definition.key);
|
|
2639
|
-
if (first !== void 0) throw new Error(`[guren]
|
|
2640
|
-
seen.set(definition.key,
|
|
2746
|
+
for (const entry of entries) {
|
|
2747
|
+
const first = seen.get(entry.definition.key);
|
|
2748
|
+
if (first !== void 0) throw new Error(`[guren] "${entry.definition.key}" has two config definitions, at ${listedAt(first)} and ${listedAt(entry)}. Keep one.`);
|
|
2749
|
+
seen.set(entry.definition.key, entry);
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
function listedAt(entry) {
|
|
2753
|
+
return entry.module === void 0 ? `createApp({ config })[${entry.index}]` : `the "${entry.module}" module's config[${entry.index}]`;
|
|
2754
|
+
}
|
|
2755
|
+
//#endregion
|
|
2756
|
+
//#region src/introspection/flag.ts
|
|
2757
|
+
/** Set by the CLI's introspection child before the app's module graph evaluates (RFC 0026 §2). */
|
|
2758
|
+
const INTROSPECT_ENV_FLAG = "GUREN_INTROSPECT";
|
|
2759
|
+
/** `code` on the error `listen()` throws under the flag; read by duck-typing, since the reader may load another server copy. */
|
|
2760
|
+
const INTROSPECT_LISTEN_REFUSED = "GUREN_INTROSPECT_LISTEN";
|
|
2761
|
+
/** Entered around an in-process `Application.introspect()`, so only that run's async work sees it. */
|
|
2762
|
+
const scope = new AsyncLocalStorage();
|
|
2763
|
+
/**
|
|
2764
|
+
* Whether this code runs for an introspection: the CLI child's `GUREN_INTROSPECT=1`,
|
|
2765
|
+
* or inside an `Application.introspect()` in this process. The one reader of both.
|
|
2766
|
+
*/
|
|
2767
|
+
function isIntrospecting() {
|
|
2768
|
+
return scope.getStore() === true || typeof process !== "undefined" && process.env?.[INTROSPECT_ENV_FLAG] === "1";
|
|
2769
|
+
}
|
|
2770
|
+
/** Runs `fn` with {@link isIntrospecting} true for it and everything it schedules, timers that outlive it included. */
|
|
2771
|
+
function runIntrospecting(fn) {
|
|
2772
|
+
return scope.run(true, fn);
|
|
2773
|
+
}
|
|
2774
|
+
/** `listen()` under the flag: an introspection run must never open a socket. */
|
|
2775
|
+
var IntrospectionListenError = class extends Error {
|
|
2776
|
+
code = INTROSPECT_LISTEN_REFUSED;
|
|
2777
|
+
constructor() {
|
|
2778
|
+
super(`Cannot listen under ${INTROSPECT_ENV_FLAG}=1: introspection registers providers and routes, and never serves. Unset the variable to serve the app.`);
|
|
2779
|
+
this.name = "IntrospectionListenError";
|
|
2780
|
+
}
|
|
2781
|
+
};
|
|
2782
|
+
//#endregion
|
|
2783
|
+
//#region src/agent/derive.ts
|
|
2784
|
+
/** HTTP methods whose semantics are read-only, per the MCP annotation defaults. */
|
|
2785
|
+
const READ_ONLY_METHODS = /* @__PURE__ */ new Set(["GET", "QUERY"]);
|
|
2786
|
+
/** HTTP methods that are idempotent whether or not they are read-only. */
|
|
2787
|
+
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
2788
|
+
"GET",
|
|
2789
|
+
"QUERY",
|
|
2790
|
+
"PUT",
|
|
2791
|
+
"DELETE"
|
|
2792
|
+
]);
|
|
2793
|
+
/**
|
|
2794
|
+
* Derive the agent tools a set of route definitions exposes.
|
|
2795
|
+
*
|
|
2796
|
+
* @param definitions Registered routes, as `Router.definitions()` hands them out.
|
|
2797
|
+
*/
|
|
2798
|
+
function deriveAgentTools(definitions) {
|
|
2799
|
+
const tools = [];
|
|
2800
|
+
const warnings = [];
|
|
2801
|
+
const claimed = /* @__PURE__ */ new Map();
|
|
2802
|
+
for (const definition of definitions) {
|
|
2803
|
+
const agent = definition.agent;
|
|
2804
|
+
if (!agent) continue;
|
|
2805
|
+
const method = definition.method.toUpperCase();
|
|
2806
|
+
const where = `${method} ${definition.path}`;
|
|
2807
|
+
if (definition.prototype) {
|
|
2808
|
+
warnings.push(`${where}: declares agent metadata while still on its prototype fixture, so it is not exposed as a tool.`);
|
|
2809
|
+
continue;
|
|
2810
|
+
}
|
|
2811
|
+
if (!definition.name) {
|
|
2812
|
+
warnings.push(`${where}: declares agent metadata but has no route name, so it is not exposed as a tool. Chain .name() on the route — the tool name is its identity.`);
|
|
2813
|
+
continue;
|
|
2814
|
+
}
|
|
2815
|
+
const routeName = definition.name;
|
|
2816
|
+
const toolName = agent.toolName ?? routeName;
|
|
2817
|
+
const existing = claimed.get(toolName);
|
|
2818
|
+
if (existing) {
|
|
2819
|
+
warnings.push(`${toolName}: ${where} (route "${routeName}") claims a tool name already derived from ${existing.method} ${existing.path} (route "${existing.routeName}") — the later route is not exposed. Give one of them a distinct agent toolName.`);
|
|
2820
|
+
continue;
|
|
2821
|
+
}
|
|
2822
|
+
const toolWarnings = [];
|
|
2823
|
+
const readOnlyHint = agent.readOnlyHint ?? READ_ONLY_METHODS.has(method);
|
|
2824
|
+
const input = buildInputSchema(definition, method, toolWarnings);
|
|
2825
|
+
const tool = {
|
|
2826
|
+
toolName,
|
|
2827
|
+
routeName,
|
|
2828
|
+
method,
|
|
2829
|
+
path: definition.path,
|
|
2830
|
+
description: agent.description ?? definition.description ?? definition.summary,
|
|
2831
|
+
inputSchema: input.schema,
|
|
2832
|
+
inputSources: input.sources,
|
|
2833
|
+
inputBodyNested: input.nestedBody,
|
|
2834
|
+
outputSchema: buildOutputSchema(definition, method, toolWarnings),
|
|
2835
|
+
resource: definition.schemas?.output ? void 0 : definition.resource,
|
|
2836
|
+
annotations: {
|
|
2837
|
+
readOnlyHint,
|
|
2838
|
+
destructiveHint: agent.destructiveHint ?? !readOnlyHint,
|
|
2839
|
+
idempotentHint: agent.idempotentHint ?? IDEMPOTENT_METHODS.has(method)
|
|
2840
|
+
},
|
|
2841
|
+
authorization: deriveAuthorization(definition, method),
|
|
2842
|
+
approval: agent.approval,
|
|
2843
|
+
redact: agent.redact ? [...agent.redact] : void 0,
|
|
2844
|
+
expose: {
|
|
2845
|
+
mcp: agent.expose?.mcp ?? true,
|
|
2846
|
+
webMcp: agent.expose?.webMcp ?? true
|
|
2847
|
+
},
|
|
2848
|
+
warnings: toolWarnings
|
|
2849
|
+
};
|
|
2850
|
+
claimed.set(toolName, tool);
|
|
2851
|
+
tools.push(tool);
|
|
2852
|
+
for (const warning of toolWarnings) warnings.push(`${toolName}: ${warning}`);
|
|
2853
|
+
}
|
|
2854
|
+
return {
|
|
2855
|
+
tools,
|
|
2856
|
+
warnings
|
|
2857
|
+
};
|
|
2858
|
+
}
|
|
2859
|
+
function buildInputSchema(definition, method, warnings) {
|
|
2860
|
+
const label = `${method} ${definition.path}`;
|
|
2861
|
+
const merged = {
|
|
2862
|
+
properties: Object.create(null),
|
|
2863
|
+
required: /* @__PURE__ */ new Set(),
|
|
2864
|
+
owner: /* @__PURE__ */ new Map()
|
|
2865
|
+
};
|
|
2866
|
+
const pathParamNames = extractPathParamNames(definition.path);
|
|
2867
|
+
const paramsDetails = definition.schemas?.params ? readObjectSchema(definition.schemas.params, warnings, `${label} params`, "input") : void 0;
|
|
2868
|
+
if (paramsDetails) mergeProperties(merged, paramsDetails.properties, paramsDetails.required, "params", warnings);
|
|
2869
|
+
const supplements = Object.create(null);
|
|
2870
|
+
const supplementRequired = /* @__PURE__ */ new Set();
|
|
2871
|
+
for (const name of pathParamNames) {
|
|
2872
|
+
if (merged.owner.has(name)) continue;
|
|
2873
|
+
supplements[name] = { type: "string" };
|
|
2874
|
+
supplementRequired.add(name);
|
|
2875
|
+
}
|
|
2876
|
+
mergeProperties(merged, supplements, supplementRequired, "path", warnings);
|
|
2877
|
+
const queryDetails = definition.schemas?.query ? readObjectSchema(definition.schemas.query, warnings, `${label} query`, "input") : void 0;
|
|
2878
|
+
if (queryDetails) mergeProperties(merged, queryDetails.properties, queryDetails.required, "query", warnings);
|
|
2879
|
+
let nestedBody = false;
|
|
2880
|
+
const body = definition.schemas?.body ? toJsonSchema(definition.schemas.body, warnings, `${label} body`, "input") : void 0;
|
|
2881
|
+
if (body) {
|
|
2882
|
+
if (body.type === "object" && body.properties) mergeProperties(merged, body.properties, new Set(body.required ?? []), "body", warnings);
|
|
2883
|
+
else {
|
|
2884
|
+
mergeProperties(merged, { body }, /* @__PURE__ */ new Set(["body"]), "body", warnings);
|
|
2885
|
+
nestedBody = true;
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
for (const name of pathParamNames) if (name in merged.properties) merged.required.add(name);
|
|
2889
|
+
const required = Array.from(merged.required);
|
|
2890
|
+
const sources = Object.create(null);
|
|
2891
|
+
for (const [name, source] of merged.owner) sources[name] = source;
|
|
2892
|
+
return {
|
|
2893
|
+
schema: {
|
|
2894
|
+
type: "object",
|
|
2895
|
+
properties: { ...merged.properties },
|
|
2896
|
+
...required.length > 0 ? { required } : {}
|
|
2897
|
+
},
|
|
2898
|
+
sources: { ...sources },
|
|
2899
|
+
nestedBody
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
/**
|
|
2903
|
+
* Fold one source's properties into the merge. A collision replaces both the
|
|
2904
|
+
* property *and* its required-ness — carrying a losing source's `required`
|
|
2905
|
+
* forward would demand a key the advertised schema does not describe.
|
|
2906
|
+
*/
|
|
2907
|
+
function mergeProperties(merged, properties, required, source, warnings) {
|
|
2908
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
2909
|
+
const previous = merged.owner.get(name);
|
|
2910
|
+
if (previous) warnings.push(`input key "${name}" is declared by both the ${previous} and the ${source} schema; the ${source} definition wins. Rename one — merged tool input has one namespace.`);
|
|
2911
|
+
merged.properties[name] = schema;
|
|
2912
|
+
merged.owner.set(name, source);
|
|
2913
|
+
merged.required.delete(name);
|
|
2914
|
+
if (required.has(name)) merged.required.add(name);
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
/**
|
|
2918
|
+
* The route's `output` schema — the only response shape validated at runtime,
|
|
2919
|
+
* so advertising it costs no new machinery. A `resource` hint is the next rung
|
|
2920
|
+
* of RFC 0016's ladder and is CLI-only: the type text behind its class names
|
|
2921
|
+
* exists solely in the CLI's AST extraction.
|
|
2922
|
+
*/
|
|
2923
|
+
function buildOutputSchema(definition, method, warnings) {
|
|
2924
|
+
const output = definition.schemas?.output;
|
|
2925
|
+
if (!output) return void 0;
|
|
2926
|
+
return toJsonSchema(output, warnings, `${method} ${definition.path} response`, "output");
|
|
2927
|
+
}
|
|
2928
|
+
/**
|
|
2929
|
+
* The ability a route's middleware chain checks, when the stamped capability
|
|
2930
|
+
* says so unambiguously (RFC 0007's `MiddlewareCapabilities.authorization`).
|
|
2931
|
+
* Everything else is omitted rather than guessed, so absence means
|
|
2932
|
+
* "undetermined" — which is what lets `guren check`'s "authn is not authz" rule
|
|
2933
|
+
* fail closed on it instead of reading a name that was never checked.
|
|
2934
|
+
*/
|
|
2935
|
+
function deriveAuthorization(definition, method) {
|
|
2936
|
+
const ability = derivableAbility(definition.capabilities?.authorization, method);
|
|
2937
|
+
return ability === void 0 ? void 0 : { ability };
|
|
2938
|
+
}
|
|
2939
|
+
//#endregion
|
|
2940
|
+
//#region src/introspection/plain-json.ts
|
|
2941
|
+
/**
|
|
2942
|
+
* A deep copy holding only JSON values, with `undefined` object keys dropped and
|
|
2943
|
+
* `undefined` array items turned into `null`, as `JSON.stringify` does. Anything
|
|
2944
|
+
* else (a function, a Map, a class instance, a bigint, a cycle) throws, so a
|
|
2945
|
+
* manifest field that would not survive `--json` fails here instead of vanishing.
|
|
2946
|
+
*/
|
|
2947
|
+
function toPlainJson(value) {
|
|
2948
|
+
return copy(value, "manifest", /* @__PURE__ */ new Set());
|
|
2949
|
+
}
|
|
2950
|
+
function refuse(path, what) {
|
|
2951
|
+
throw new TypeError(`${path} (${what}) cannot be carried by JSON`);
|
|
2952
|
+
}
|
|
2953
|
+
function copy(value, path, ancestors) {
|
|
2954
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
2955
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : refuse(path, String(value));
|
|
2956
|
+
if (typeof value !== "object") return refuse(path, typeof value);
|
|
2957
|
+
if (ancestors.has(value)) refuse(path, "a reference to its own ancestor");
|
|
2958
|
+
ancestors.add(value);
|
|
2959
|
+
try {
|
|
2960
|
+
if (Array.isArray(value)) return value.map((item, index) => item === void 0 ? null : copy(item, `${path}[${index}]`, ancestors));
|
|
2961
|
+
const proto = Object.getPrototypeOf(value);
|
|
2962
|
+
if (proto !== Object.prototype && proto !== null) refuse(path, value.constructor?.name ?? "object");
|
|
2963
|
+
const result = {};
|
|
2964
|
+
for (const [key, item] of Object.entries(value)) if (item !== void 0) result[key] = copy(item, `${path}.${key}`, ancestors);
|
|
2965
|
+
return result;
|
|
2966
|
+
} finally {
|
|
2967
|
+
ancestors.delete(value);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
//#endregion
|
|
2971
|
+
//#region src/introspection/manifest.ts
|
|
2972
|
+
const SCHEMA_KEYS = [
|
|
2973
|
+
"params",
|
|
2974
|
+
"query",
|
|
2975
|
+
"body",
|
|
2976
|
+
"output"
|
|
2977
|
+
];
|
|
2978
|
+
/** Builds the manifest from a registered, unmounted, unbooted app (RFC 0026 §1). */
|
|
2979
|
+
function buildAppManifest(sources) {
|
|
2980
|
+
const warnings = [...sources.providerWarnings];
|
|
2981
|
+
if (sources.hasBootCallback) warnings.push({
|
|
2982
|
+
code: "boot-callback-skipped",
|
|
2983
|
+
message: "createApp({ boot }) was not run: introspection stops before boot, so routes or middleware it adds are not in this manifest."
|
|
2641
2984
|
});
|
|
2985
|
+
const definitions = sources.router.definitions();
|
|
2986
|
+
const { aliases, routes: chains } = sources.router.describeMiddleware();
|
|
2987
|
+
const routes = describeRoutes(definitions, chains, warnings);
|
|
2988
|
+
const middlewareAliases = {};
|
|
2989
|
+
for (const [name, entry] of Object.entries(aliases)) middlewareAliases[name] = withAbility(entry);
|
|
2990
|
+
const derived = deriveAgentTools(definitions);
|
|
2991
|
+
for (const message of derived.warnings) warnings.push({
|
|
2992
|
+
code: "agent-tool",
|
|
2993
|
+
message
|
|
2994
|
+
});
|
|
2995
|
+
const manifest = {
|
|
2996
|
+
schemaVersion: 1,
|
|
2997
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2998
|
+
entry: {
|
|
2999
|
+
file: null,
|
|
3000
|
+
root: process.cwd(),
|
|
3001
|
+
stage: "register"
|
|
3002
|
+
},
|
|
3003
|
+
runtime: {
|
|
3004
|
+
bun: process.versions.bun ?? null,
|
|
3005
|
+
node: process.versions.node ?? null,
|
|
3006
|
+
platform: process.platform
|
|
3007
|
+
},
|
|
3008
|
+
providers: sources.providers,
|
|
3009
|
+
modules: sources.modules.map((gurenModule) => ({
|
|
3010
|
+
name: gurenModule.name,
|
|
3011
|
+
...gurenModule.prefix === void 0 ? {} : { prefix: gurenModule.prefix },
|
|
3012
|
+
providers: gurenModule.providers.map((provider) => provider.name),
|
|
3013
|
+
commands: gurenModule.commands.map((command) => command.name),
|
|
3014
|
+
routeCount: routes.filter((route) => route.module === gurenModule.name).length
|
|
3015
|
+
})),
|
|
3016
|
+
routes,
|
|
3017
|
+
middlewareAliases,
|
|
3018
|
+
bindings: sources.container.getBindings().sort(),
|
|
3019
|
+
agentTools: derived.tools,
|
|
3020
|
+
warnings
|
|
3021
|
+
};
|
|
3022
|
+
const section = (key) => {
|
|
3023
|
+
const read = readSection(sources, key, warnings);
|
|
3024
|
+
return read.status === "described" ? read.value : void 0;
|
|
3025
|
+
};
|
|
3026
|
+
const session = describeSession(sources, warnings);
|
|
3027
|
+
if (session) manifest.session = session;
|
|
3028
|
+
const auth = section("auth");
|
|
3029
|
+
if (auth) manifest.auth = auth;
|
|
3030
|
+
for (const key of [
|
|
3031
|
+
"cache",
|
|
3032
|
+
"storage",
|
|
3033
|
+
"queue"
|
|
3034
|
+
]) {
|
|
3035
|
+
const entry = section(key);
|
|
3036
|
+
if (entry) manifest[key] = entry;
|
|
3037
|
+
}
|
|
3038
|
+
const attachments = section("attachments");
|
|
3039
|
+
if (attachments) {
|
|
3040
|
+
const { delivery, ...rest } = attachments;
|
|
3041
|
+
manifest.attachments = delivery ? {
|
|
3042
|
+
...rest,
|
|
3043
|
+
delivery: {
|
|
3044
|
+
...delivery,
|
|
3045
|
+
mounted: sources.router.hasRoute(delivery.routeName)
|
|
3046
|
+
}
|
|
3047
|
+
} : rest;
|
|
3048
|
+
}
|
|
3049
|
+
return toPlainJson(manifest);
|
|
3050
|
+
}
|
|
3051
|
+
function describeRoutes(definitions, chains, warnings) {
|
|
3052
|
+
return definitions.map((definition, index) => {
|
|
3053
|
+
const { schemas, controller, middlewareNames, module, ...rest } = definition;
|
|
3054
|
+
const label = `${definition.method} ${definition.path}`;
|
|
3055
|
+
const entry = {
|
|
3056
|
+
...rest,
|
|
3057
|
+
module: module ?? null,
|
|
3058
|
+
middleware: (chains[index] ?? []).map((middleware) => withAbility(middleware, definition.method)),
|
|
3059
|
+
schemas: {}
|
|
3060
|
+
};
|
|
3061
|
+
for (const key of SCHEMA_KEYS) {
|
|
3062
|
+
const schema = schemas?.[key];
|
|
3063
|
+
if (!schema) continue;
|
|
3064
|
+
const notes = [];
|
|
3065
|
+
const json = toJsonSchema(schema, notes, `${label} ${key}`, key === "output" ? "output" : "input");
|
|
3066
|
+
entry.schemas[key] = json ?? { unreadable: notes.join(" ") || "not a readable Zod schema" };
|
|
3067
|
+
if (json) for (const message of notes) warnings.push({
|
|
3068
|
+
code: "schema-partial",
|
|
3069
|
+
message,
|
|
3070
|
+
route: label
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
if (controller) entry.controller = {
|
|
3074
|
+
name: controller.name,
|
|
3075
|
+
action: controller.action,
|
|
3076
|
+
file: null,
|
|
3077
|
+
exportName: null,
|
|
3078
|
+
resolved: "name-only"
|
|
3079
|
+
};
|
|
3080
|
+
return entry;
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
function withAbility(entry, method) {
|
|
3084
|
+
const ability = derivableAbility(entry.capabilities.authorization, method);
|
|
3085
|
+
return ability === void 0 ? entry : {
|
|
3086
|
+
...entry,
|
|
3087
|
+
ability
|
|
3088
|
+
};
|
|
3089
|
+
}
|
|
3090
|
+
function describeSession(sources, warnings) {
|
|
3091
|
+
const read = readSection(sources, "session", warnings);
|
|
3092
|
+
if (read.status === "described") {
|
|
3093
|
+
const auth = sources.authOptions;
|
|
3094
|
+
if (auth && auth.autoSession !== false && auth.sessionOptions?.store !== void 0) warnings.push({
|
|
3095
|
+
code: "session-configured-twice",
|
|
3096
|
+
message: "A \"session\" binding and createApp({ auth: { sessionOptions: { store } } }) both configure sessions; the app refuses to boot until one is removed."
|
|
3097
|
+
});
|
|
3098
|
+
return {
|
|
3099
|
+
source: "manager",
|
|
3100
|
+
...read.value
|
|
3101
|
+
};
|
|
3102
|
+
}
|
|
3103
|
+
if (read.status !== "absent") return void 0;
|
|
3104
|
+
const auth = sources.authOptions;
|
|
3105
|
+
if (!auth || auth.autoSession === false) return void 0;
|
|
3106
|
+
const store = auth.sessionOptions?.store;
|
|
3107
|
+
if (store === void 0) return {
|
|
3108
|
+
source: "none",
|
|
3109
|
+
...new SessionManager().describe()
|
|
3110
|
+
};
|
|
3111
|
+
const driver = typeof store === "function" ? null : store.constructor.name;
|
|
3112
|
+
return {
|
|
3113
|
+
source: "auth.sessionOptions.store",
|
|
3114
|
+
default: "sessionOptions.store",
|
|
3115
|
+
stores: { "sessionOptions.store": {
|
|
3116
|
+
driver,
|
|
3117
|
+
perProcess: perProcessOfStoreClass(driver)
|
|
3118
|
+
} }
|
|
3119
|
+
};
|
|
3120
|
+
}
|
|
3121
|
+
/** The framework's store classes by the driver that builds them; core's `DatabaseSessionStore` included. */
|
|
3122
|
+
const DRIVER_BY_STORE_CLASS = {
|
|
3123
|
+
MemorySessionStore: "memory",
|
|
3124
|
+
CookieSessionStore: "cookie",
|
|
3125
|
+
RedisSessionStore: "redis",
|
|
3126
|
+
DatabaseSessionStore: "database"
|
|
3127
|
+
};
|
|
3128
|
+
function perProcessOfStoreClass(storeClass) {
|
|
3129
|
+
const driver = storeClass === null ? void 0 : DRIVER_BY_STORE_CLASS[storeClass];
|
|
3130
|
+
return driver === void 0 ? null : sessionDriverIsPerProcess(driver);
|
|
3131
|
+
}
|
|
3132
|
+
/**
|
|
3133
|
+
* A section is read only when its container key exists after registration.
|
|
3134
|
+
* One a deferred provider supplies, or whose manager throws on construction,
|
|
3135
|
+
* is warned about and told apart from a plain absence.
|
|
3136
|
+
*/
|
|
3137
|
+
function readSection(sources, key, warnings) {
|
|
3138
|
+
const { container } = sources;
|
|
3139
|
+
if (!container.has(key)) {
|
|
3140
|
+
const deferred = sources.providers.find((provider) => provider.register === "skipped" && provider.provides.includes(key));
|
|
3141
|
+
if (deferred) {
|
|
3142
|
+
warnings.push({
|
|
3143
|
+
code: "section-unverified",
|
|
3144
|
+
message: `"${key}" is supplied by the deferred ${deferred.name}, which registers only after boot.`,
|
|
3145
|
+
provider: deferred.name
|
|
3146
|
+
});
|
|
3147
|
+
return { status: "unverified" };
|
|
3148
|
+
}
|
|
3149
|
+
const thrown = sources.providers.filter((provider) => provider.register === "threw");
|
|
3150
|
+
if (thrown.length === 0) return { status: "absent" };
|
|
3151
|
+
warnings.push({
|
|
3152
|
+
code: "section-unverified",
|
|
3153
|
+
message: `"${key}" is unbound, and ${thrown.map((provider) => provider.name).join(", ")} threw before it could be ruled out as its provider.`
|
|
3154
|
+
});
|
|
3155
|
+
return { status: "unverified" };
|
|
3156
|
+
}
|
|
3157
|
+
try {
|
|
3158
|
+
const service = container.make(key);
|
|
3159
|
+
if (typeof service?.describe === "function") return {
|
|
3160
|
+
status: "described",
|
|
3161
|
+
value: service.describe()
|
|
3162
|
+
};
|
|
3163
|
+
warnings.push({
|
|
3164
|
+
code: "section-unverified",
|
|
3165
|
+
message: `"${key}" is bound to something with no describe().`
|
|
3166
|
+
});
|
|
3167
|
+
return { status: "unverified" };
|
|
3168
|
+
} catch (error) {
|
|
3169
|
+
warnings.push({
|
|
3170
|
+
code: "section-unreadable",
|
|
3171
|
+
message: `"${key}" is bound but could not be described: ${error instanceof Error ? error.message : String(error)}`
|
|
3172
|
+
});
|
|
3173
|
+
return { status: "unreadable" };
|
|
3174
|
+
}
|
|
2642
3175
|
}
|
|
2643
3176
|
//#endregion
|
|
2644
3177
|
//#region src/http/Application.ts
|
|
@@ -2678,6 +3211,19 @@ function toConnectableUrl(hostname, port) {
|
|
|
2678
3211
|
const host = isWildcardHost(hostname) ? hostname === "::" ? "::1" : "127.0.0.1" : hostname;
|
|
2679
3212
|
return `http://${formatHostPort(host, port)}`;
|
|
2680
3213
|
}
|
|
3214
|
+
let devBanner;
|
|
3215
|
+
/**
|
|
3216
|
+
* The banner module brings figlet and chalk, so it is loaded outside production
|
|
3217
|
+
* only. The NODE_ENV test guards the import directly, in plain member access: a
|
|
3218
|
+
* deploy bundle's `--define` folds it to `false` and drops the module. Neither
|
|
3219
|
+
* Bun nor esbuild folds it behind a function call, or beside a runtime value in
|
|
3220
|
+
* `||` (as `shouldLogBanner` has); an `&&` with such a value still folds.
|
|
3221
|
+
*/
|
|
3222
|
+
async function loadDevBanner() {
|
|
3223
|
+
if (typeof process === "undefined") return devBanner;
|
|
3224
|
+
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-CfQDnkfQ.js").then((n) => n.n);
|
|
3225
|
+
return devBanner;
|
|
3226
|
+
}
|
|
2681
3227
|
function clearManagedViteEnv() {
|
|
2682
3228
|
if (typeof process === "undefined") return;
|
|
2683
3229
|
if (process.env[MANAGED_VITE_ENV_FLAG] === "1") {
|
|
@@ -2707,6 +3253,30 @@ function bunStopTimeoutMs() {
|
|
|
2707
3253
|
return shutdownTimeoutMs("GUREN_BUN_STOP_TIMEOUT_MS");
|
|
2708
3254
|
}
|
|
2709
3255
|
/**
|
|
3256
|
+
* How long a `bun --hot` reload waits on the server it replaces. That stop is
|
|
3257
|
+
* forced, and the hot-reload teardown has already server-closed every broadcast
|
|
3258
|
+
* WebSocket, so nothing is draining; on Bun 1.3.x `stop()` then never resolves
|
|
3259
|
+
* (1.4.0 resolves at once). Quoted in docs/{en,ja}/guides/architecture.md.
|
|
3260
|
+
*/
|
|
3261
|
+
const HOT_RELOAD_STOP_TIMEOUT_MS = 250;
|
|
3262
|
+
function defaultStopBound() {
|
|
3263
|
+
return {
|
|
3264
|
+
timeoutMs: bunStopTimeoutMs(),
|
|
3265
|
+
warn: true
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Silent: on Bun 1.3.x it is hit on every reload, and there is nothing to
|
|
3270
|
+
* report. `GUREN_BUN_STOP_TIMEOUT_MS` can only shorten it: it is set for a
|
|
3271
|
+
* production drain, which a reload never is.
|
|
3272
|
+
*/
|
|
3273
|
+
function hotReloadStopBound() {
|
|
3274
|
+
return {
|
|
3275
|
+
timeoutMs: Math.min(bunStopTimeoutMs(), HOT_RELOAD_STOP_TIMEOUT_MS),
|
|
3276
|
+
warn: false
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
2710
3280
|
* A positive integer of milliseconds, or 5000 when unset or unparseable. One
|
|
2711
3281
|
* parse for both bounds, so they cannot drift apart.
|
|
2712
3282
|
*/
|
|
@@ -2728,19 +3298,20 @@ async function awaitBounded(work, timeoutMs, onTimeout) {
|
|
|
2728
3298
|
clearTimeout(timer);
|
|
2729
3299
|
}
|
|
2730
3300
|
}
|
|
2731
|
-
/** `stop()` bounded by {@link bunStopTimeoutMs}, warning rather than throwing. */
|
|
2732
|
-
async function stopBunServerBounded(server, closeActiveConnections) {
|
|
3301
|
+
/** `stop()` bounded by `bound` ({@link bunStopTimeoutMs} by default), warning rather than throwing. */
|
|
3302
|
+
async function stopBunServerBounded(server, closeActiveConnections, bound = defaultStopBound()) {
|
|
2733
3303
|
await awaitBounded((async () => {
|
|
2734
3304
|
try {
|
|
2735
3305
|
await server.stop?.(closeActiveConnections);
|
|
2736
3306
|
} catch (error) {
|
|
2737
3307
|
console.warn("Failed to stop Bun server:", error);
|
|
2738
3308
|
}
|
|
2739
|
-
})(),
|
|
3309
|
+
})(), bound.timeoutMs, (timeoutMs) => {
|
|
3310
|
+
if (!bound.warn) return;
|
|
2740
3311
|
console.warn(`Bun server did not stop within ${timeoutMs}ms — no longer waiting on it. In-flight requests may still be draining.`);
|
|
2741
3312
|
});
|
|
2742
3313
|
}
|
|
2743
|
-
async function stopActiveBunServer(closeActiveConnections = false) {
|
|
3314
|
+
async function stopActiveBunServer(closeActiveConnections = false, bound) {
|
|
2744
3315
|
const state = getGlobalState();
|
|
2745
3316
|
const previous = state.__gurenActiveServer;
|
|
2746
3317
|
if (!previous?.stop) {
|
|
@@ -2748,7 +3319,7 @@ async function stopActiveBunServer(closeActiveConnections = false) {
|
|
|
2748
3319
|
return;
|
|
2749
3320
|
}
|
|
2750
3321
|
try {
|
|
2751
|
-
await stopBunServerBounded(previous, closeActiveConnections);
|
|
3322
|
+
await stopBunServerBounded(previous, closeActiveConnections, bound);
|
|
2752
3323
|
} finally {
|
|
2753
3324
|
releaseActiveBunServer(previous);
|
|
2754
3325
|
}
|
|
@@ -2871,10 +3442,22 @@ var Application = class {
|
|
|
2871
3442
|
disposeBunTeardown;
|
|
2872
3443
|
autoSessionAttached = false;
|
|
2873
3444
|
cookielessAuthPaths = /* @__PURE__ */ new Set();
|
|
3445
|
+
/** {@link configDefinitions} with where each was listed, which ConfigServiceProvider's errors name. */
|
|
3446
|
+
configEntries;
|
|
2874
3447
|
routesRegistered = false;
|
|
2875
3448
|
bootPromise;
|
|
3449
|
+
manifestPromise;
|
|
3450
|
+
bootAttempted = false;
|
|
2876
3451
|
constructor(options = {}) {
|
|
2877
3452
|
this.options = options;
|
|
3453
|
+
this.configEntries = [...(options.config ?? []).map((definition, index) => ({
|
|
3454
|
+
definition,
|
|
3455
|
+
index
|
|
3456
|
+
})), ...(options.modules ?? []).flatMap((gurenModule) => (gurenModule.config ?? []).map((definition, index) => ({
|
|
3457
|
+
definition,
|
|
3458
|
+
index,
|
|
3459
|
+
module: gurenModule.name
|
|
3460
|
+
})))];
|
|
2878
3461
|
this.hono = new Hono();
|
|
2879
3462
|
this.container = new Container();
|
|
2880
3463
|
this.router = new Router();
|
|
@@ -2888,7 +3471,8 @@ var Application = class {
|
|
|
2888
3471
|
if (options.inertia?.document) this.container.instance("inertia.document", options.inertia.document);
|
|
2889
3472
|
if (options.inertia?.ssrRenderer) this.container.instance("inertia.ssrRenderer", options.inertia.ssrRenderer);
|
|
2890
3473
|
if (options.inertia?.share) shareInertiaProps(options.inertia.share, this.container);
|
|
2891
|
-
|
|
3474
|
+
const framework = { source: "framework" };
|
|
3475
|
+
if (options.env || this.configEntries.length > 0) this.providerManager.register(ConfigServiceProvider, framework);
|
|
2892
3476
|
this.authManager.registerGuard("web", ({ session }) => {
|
|
2893
3477
|
const provider = this.authManager.hasProvider("users") ? this.authManager.getProvider(DEFAULT_PROVIDER) : unconfiguredUserProvider;
|
|
2894
3478
|
return new SessionGuard({
|
|
@@ -2897,16 +3481,20 @@ var Application = class {
|
|
|
2897
3481
|
});
|
|
2898
3482
|
});
|
|
2899
3483
|
this.authManager.setDefaultGuard("web");
|
|
2900
|
-
if (this.options.auth) this.providerManager.register(AuthServiceProvider);
|
|
3484
|
+
if (this.options.auth) this.providerManager.register(AuthServiceProvider, framework);
|
|
2901
3485
|
else this.hono.use("*", attachAuthContext((ctx) => this.authManager.createAuthContext(ctx)));
|
|
2902
|
-
this.providerManager.register(AuthorizationServiceProvider);
|
|
2903
|
-
const
|
|
2904
|
-
const userProviders = [...
|
|
3486
|
+
this.providerManager.register(AuthorizationServiceProvider, framework);
|
|
3487
|
+
const listedProviders = Array.isArray(this.options.providers) ? this.options.providers : [];
|
|
3488
|
+
const userProviders = [...listedProviders, ...(this.options.modules ?? []).flatMap((module) => module.providers)];
|
|
2905
3489
|
const hasUserProviderOf = (base) => userProviders.some((provider) => provider === base || provider.prototype instanceof base);
|
|
2906
|
-
if (this.options.i18n && !hasUserProviderOf(I18nServiceProvider)) this.providerManager.register(I18nServiceProvider);
|
|
2907
|
-
if (!hasUserProviderOf(ErrorServiceProvider)) this.providerManager.register(ErrorServiceProvider);
|
|
2908
|
-
|
|
2909
|
-
|
|
3490
|
+
if (this.options.i18n && !hasUserProviderOf(I18nServiceProvider)) this.providerManager.register(I18nServiceProvider, framework);
|
|
3491
|
+
if (!hasUserProviderOf(ErrorServiceProvider)) this.providerManager.register(ErrorServiceProvider, framework);
|
|
3492
|
+
this.providerManager.registerMany(listedProviders, { source: "options.providers" });
|
|
3493
|
+
for (const gurenModule of this.options.modules ?? []) this.providerManager.registerMany(gurenModule.providers, {
|
|
3494
|
+
source: "module",
|
|
3495
|
+
module: gurenModule.name
|
|
3496
|
+
});
|
|
3497
|
+
if (!hasUserProviderOf(InertiaServiceProvider)) this.providerManager.register(InertiaServiceProvider, framework);
|
|
2910
3498
|
adoptDefaultApplication(this);
|
|
2911
3499
|
}
|
|
2912
3500
|
get auth() {
|
|
@@ -2921,8 +3509,9 @@ var Application = class {
|
|
|
2921
3509
|
get envSchema() {
|
|
2922
3510
|
return this.options.env;
|
|
2923
3511
|
}
|
|
3512
|
+
/** `createApp({ config })`, then each module's `config` in `modules` order (RFC 0002, RFC 0027 §2). */
|
|
2924
3513
|
get configDefinitions() {
|
|
2925
|
-
return this.
|
|
3514
|
+
return this.configEntries.map((entry) => entry.definition);
|
|
2926
3515
|
}
|
|
2927
3516
|
markAutoSessionAttached() {
|
|
2928
3517
|
this.autoSessionAttached = true;
|
|
@@ -2954,13 +3543,17 @@ var Application = class {
|
|
|
2954
3543
|
return this.cookielessAuthPaths;
|
|
2955
3544
|
}
|
|
2956
3545
|
async mountRoutes() {
|
|
3546
|
+
await this.registerRoutes();
|
|
3547
|
+
await this.preparePrototypeRoutes();
|
|
3548
|
+
this.router.mount(this.hono, { container: this.container });
|
|
3549
|
+
}
|
|
3550
|
+
/** Runs the registrars once; `introspect()` stops here, since mounting refuses an unregistered alias it reports. */
|
|
3551
|
+
async registerRoutes() {
|
|
2957
3552
|
if (!this.routesRegistered) {
|
|
2958
3553
|
if (this.options.routes) await this.options.routes(this.router);
|
|
2959
3554
|
for (const gurenModule of this.options.modules ?? []) await mountModuleRoutes(this.router, gurenModule);
|
|
2960
3555
|
this.routesRegistered = true;
|
|
2961
3556
|
}
|
|
2962
|
-
await this.preparePrototypeRoutes();
|
|
2963
|
-
this.router.mount(this.hono, { container: this.container });
|
|
2964
3557
|
}
|
|
2965
3558
|
/**
|
|
2966
3559
|
* Every failure here is one a request would otherwise surface as a 500:
|
|
@@ -2994,6 +3587,11 @@ var Application = class {
|
|
|
2994
3587
|
* retries on the partially mounted app rather than starting clean.
|
|
2995
3588
|
*/
|
|
2996
3589
|
async boot() {
|
|
3590
|
+
if (isIntrospecting()) {
|
|
3591
|
+
await this.introspect();
|
|
3592
|
+
return;
|
|
3593
|
+
}
|
|
3594
|
+
if (this.manifestPromise) throw new Error("[guren] This application was introspected: its providers may have run introspect() in place of register(), so it cannot boot. Construct a new application to serve it.");
|
|
2997
3595
|
this.bootPromise ??= this.bootOnce();
|
|
2998
3596
|
try {
|
|
2999
3597
|
await this.bootPromise;
|
|
@@ -3011,13 +3609,37 @@ var Application = class {
|
|
|
3011
3609
|
async booted() {
|
|
3012
3610
|
await this.bootPromise;
|
|
3013
3611
|
}
|
|
3612
|
+
/**
|
|
3613
|
+
* Registers providers and routes, then describes the result (RFC 0026 §1).
|
|
3614
|
+
* Never mounts on Hono or runs `createApp({ boot })`, a provider's `boot()`
|
|
3615
|
+
* or `listen()`. Memoised; the application cannot boot afterwards.
|
|
3616
|
+
*/
|
|
3617
|
+
async introspect() {
|
|
3618
|
+
if (this.bootAttempted) throw new Error("[guren] Cannot introspect an application that has booted: introspection describes the registered, unbooted app.");
|
|
3619
|
+
this.manifestPromise ??= runIntrospecting(() => this.introspectOnce());
|
|
3620
|
+
return this.manifestPromise;
|
|
3621
|
+
}
|
|
3622
|
+
async introspectOnce() {
|
|
3623
|
+
const providers = await this.providerManager.registerAllForIntrospection();
|
|
3624
|
+
await this.registerRoutes();
|
|
3625
|
+
return buildAppManifest({
|
|
3626
|
+
router: this.router,
|
|
3627
|
+
container: this.container,
|
|
3628
|
+
providers,
|
|
3629
|
+
providerWarnings: this.providerManager.manifestWarnings(),
|
|
3630
|
+
modules: this.options.modules ?? [],
|
|
3631
|
+
authOptions: this.options.auth,
|
|
3632
|
+
hasBootCallback: this.options.boot !== void 0
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3014
3635
|
async bootOnce() {
|
|
3636
|
+
this.bootAttempted = true;
|
|
3015
3637
|
if (this.options.hostAuthorization !== void 0 && this.hasHttpConfig()) throw new Error("[guren] Host authorization is configured twice: createApp({ hostAuthorization }) and config/http.ts. Keep one.");
|
|
3016
3638
|
await this.providerManager.registerAll();
|
|
3017
3639
|
await this.options.boot?.(this.hono);
|
|
3018
3640
|
await this.mountRoutes();
|
|
3019
|
-
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-
|
|
3020
|
-
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-
|
|
3641
|
+
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-PGFPlYTy.js").then((n) => n.n)).McpServiceProvider, "GUREN_MCP=1 but the MCP endpoint could not load — is @guren/cli installed?");
|
|
3642
|
+
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-BMbcTYVw.js")).DocsViewerServiceProvider, "GUREN_DOCS=1 but the docs viewer could not load — is @guren/cli resolvable from this app?");
|
|
3021
3643
|
await this.providerManager.bootAll();
|
|
3022
3644
|
this.warnOnUnconfiguredAuth();
|
|
3023
3645
|
}
|
|
@@ -3097,12 +3719,16 @@ var Application = class {
|
|
|
3097
3719
|
return runInRequestScope(executionCtx, () => this.hono.fetch(request, env, executionCtx));
|
|
3098
3720
|
}
|
|
3099
3721
|
async listen(options = {}) {
|
|
3722
|
+
if (isIntrospecting()) throw new IntrospectionListenError();
|
|
3100
3723
|
if (!Bun) throw new Error("Bun runtime is required to call Application.listen");
|
|
3101
3724
|
const supersededServer = getGlobalState().__gurenActiveServer;
|
|
3102
|
-
await stopActiveBunServer(true);
|
|
3725
|
+
await stopActiveBunServer(true, isHotReloadRuntime() ? hotReloadStopBound() : void 0);
|
|
3103
3726
|
const { port = 3e3, hostname = "0.0.0.0", assetsUrl, vite, portFallback } = options;
|
|
3104
3727
|
const externalAssetsUrl = typeof process !== "undefined" && process.env?.[MANAGED_VITE_ENV_FLAG] !== "1" ? process.env?.VITE_DEV_SERVER_URL : void 0;
|
|
3105
3728
|
let resolvedAssetsUrl = assetsUrl ?? externalAssetsUrl;
|
|
3729
|
+
const shouldLogBanner = typeof process === "undefined" || process.env.NODE_ENV !== "production" && process.env?.GUREN_DEV_BANNER !== "0";
|
|
3730
|
+
if (shouldLogBanner) await loadDevBanner();
|
|
3731
|
+
const { websocket } = await import("hono/bun");
|
|
3106
3732
|
const shouldStartVite = vite !== false && typeof process !== "undefined" && process.env.NODE_ENV !== "production" && !resolvedAssetsUrl && process.env?.GUREN_DEV_VITE !== "0";
|
|
3107
3733
|
const adoptViteDevServer = (viteServer, localUrl) => {
|
|
3108
3734
|
const displaced = getGlobalState().__gurenActiveViteDevServer;
|
|
@@ -3145,7 +3771,8 @@ var Application = class {
|
|
|
3145
3771
|
server = Bun.serve({
|
|
3146
3772
|
port: attemptPort,
|
|
3147
3773
|
hostname,
|
|
3148
|
-
fetch: (request, server) => this.fetch(request, { server })
|
|
3774
|
+
fetch: (request, server) => this.fetch(request, { server }),
|
|
3775
|
+
websocket
|
|
3149
3776
|
});
|
|
3150
3777
|
break;
|
|
3151
3778
|
} catch (error) {
|
|
@@ -3177,7 +3804,7 @@ var Application = class {
|
|
|
3177
3804
|
this.boundAddress = address;
|
|
3178
3805
|
setActiveBunServer(server);
|
|
3179
3806
|
this.registerBunTeardown();
|
|
3180
|
-
if (
|
|
3807
|
+
if (shouldLogBanner) this.logDevServerBanner({
|
|
3181
3808
|
hostname: boundHostname,
|
|
3182
3809
|
port: boundPort,
|
|
3183
3810
|
assetsUrl: resolvedAssetsUrl ?? "http://localhost:5173"
|
|
@@ -3225,8 +3852,18 @@ var Application = class {
|
|
|
3225
3852
|
this.providerManager.registerMany(providers);
|
|
3226
3853
|
return this;
|
|
3227
3854
|
}
|
|
3855
|
+
/**
|
|
3856
|
+
* Prints the dev server banner. `listen()` loads the banner module first, so it
|
|
3857
|
+
* prints there at once; a call before anything has loaded it prints once the
|
|
3858
|
+
* import settles. The module is never loaded under `NODE_ENV=production`, which
|
|
3859
|
+
* keeps it out of deploy bundles, so a call there prints nothing.
|
|
3860
|
+
*/
|
|
3228
3861
|
logDevServerBanner(options) {
|
|
3229
|
-
|
|
3862
|
+
if (devBanner) {
|
|
3863
|
+
devBanner.logDevServerBanner(options);
|
|
3864
|
+
return;
|
|
3865
|
+
}
|
|
3866
|
+
loadDevBanner().then((loaded) => loaded?.logDevServerBanner(options), (error) => console.error("Failed to load the dev server banner:", error));
|
|
3230
3867
|
}
|
|
3231
3868
|
/**
|
|
3232
3869
|
* Closes the managed Vite dev server, but only while this application still
|
|
@@ -3318,170 +3955,6 @@ function viteAsset(entry, options = {}) {
|
|
|
3318
3955
|
return manifestAssetUrl(manifest, normalizedEntry);
|
|
3319
3956
|
}
|
|
3320
3957
|
//#endregion
|
|
3321
|
-
//#region src/agent/derive.ts
|
|
3322
|
-
/** HTTP methods whose semantics are read-only, per the MCP annotation defaults. */
|
|
3323
|
-
const READ_ONLY_METHODS = /* @__PURE__ */ new Set(["GET", "QUERY"]);
|
|
3324
|
-
/** HTTP methods that are idempotent whether or not they are read-only. */
|
|
3325
|
-
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
3326
|
-
"GET",
|
|
3327
|
-
"QUERY",
|
|
3328
|
-
"PUT",
|
|
3329
|
-
"DELETE"
|
|
3330
|
-
]);
|
|
3331
|
-
/**
|
|
3332
|
-
* Derive the agent tools a set of route definitions exposes.
|
|
3333
|
-
*
|
|
3334
|
-
* @param definitions Registered routes, as `Router.definitions()` hands them out.
|
|
3335
|
-
*/
|
|
3336
|
-
function deriveAgentTools(definitions) {
|
|
3337
|
-
const tools = [];
|
|
3338
|
-
const warnings = [];
|
|
3339
|
-
const claimed = /* @__PURE__ */ new Map();
|
|
3340
|
-
for (const definition of definitions) {
|
|
3341
|
-
const agent = definition.agent;
|
|
3342
|
-
if (!agent) continue;
|
|
3343
|
-
const method = definition.method.toUpperCase();
|
|
3344
|
-
const where = `${method} ${definition.path}`;
|
|
3345
|
-
if (definition.prototype) {
|
|
3346
|
-
warnings.push(`${where}: declares agent metadata while still on its prototype fixture, so it is not exposed as a tool.`);
|
|
3347
|
-
continue;
|
|
3348
|
-
}
|
|
3349
|
-
if (!definition.name) {
|
|
3350
|
-
warnings.push(`${where}: declares agent metadata but has no route name, so it is not exposed as a tool. Chain .name() on the route — the tool name is its identity.`);
|
|
3351
|
-
continue;
|
|
3352
|
-
}
|
|
3353
|
-
const routeName = definition.name;
|
|
3354
|
-
const toolName = agent.toolName ?? routeName;
|
|
3355
|
-
const existing = claimed.get(toolName);
|
|
3356
|
-
if (existing) {
|
|
3357
|
-
warnings.push(`${toolName}: ${where} (route "${routeName}") claims a tool name already derived from ${existing.method} ${existing.path} (route "${existing.routeName}") — the later route is not exposed. Give one of them a distinct agent toolName.`);
|
|
3358
|
-
continue;
|
|
3359
|
-
}
|
|
3360
|
-
const toolWarnings = [];
|
|
3361
|
-
const readOnlyHint = agent.readOnlyHint ?? READ_ONLY_METHODS.has(method);
|
|
3362
|
-
const input = buildInputSchema(definition, method, toolWarnings);
|
|
3363
|
-
const tool = {
|
|
3364
|
-
toolName,
|
|
3365
|
-
routeName,
|
|
3366
|
-
method,
|
|
3367
|
-
path: definition.path,
|
|
3368
|
-
description: agent.description ?? definition.description ?? definition.summary,
|
|
3369
|
-
inputSchema: input.schema,
|
|
3370
|
-
inputSources: input.sources,
|
|
3371
|
-
inputBodyNested: input.nestedBody,
|
|
3372
|
-
outputSchema: buildOutputSchema(definition, method, toolWarnings),
|
|
3373
|
-
resource: definition.schemas?.output ? void 0 : definition.resource,
|
|
3374
|
-
annotations: {
|
|
3375
|
-
readOnlyHint,
|
|
3376
|
-
destructiveHint: agent.destructiveHint ?? !readOnlyHint,
|
|
3377
|
-
idempotentHint: agent.idempotentHint ?? IDEMPOTENT_METHODS.has(method)
|
|
3378
|
-
},
|
|
3379
|
-
authorization: deriveAuthorization(definition, method),
|
|
3380
|
-
approval: agent.approval,
|
|
3381
|
-
redact: agent.redact ? [...agent.redact] : void 0,
|
|
3382
|
-
expose: {
|
|
3383
|
-
mcp: agent.expose?.mcp ?? true,
|
|
3384
|
-
webMcp: agent.expose?.webMcp ?? true
|
|
3385
|
-
},
|
|
3386
|
-
warnings: toolWarnings
|
|
3387
|
-
};
|
|
3388
|
-
claimed.set(toolName, tool);
|
|
3389
|
-
tools.push(tool);
|
|
3390
|
-
for (const warning of toolWarnings) warnings.push(`${toolName}: ${warning}`);
|
|
3391
|
-
}
|
|
3392
|
-
return {
|
|
3393
|
-
tools,
|
|
3394
|
-
warnings
|
|
3395
|
-
};
|
|
3396
|
-
}
|
|
3397
|
-
function buildInputSchema(definition, method, warnings) {
|
|
3398
|
-
const label = `${method} ${definition.path}`;
|
|
3399
|
-
const merged = {
|
|
3400
|
-
properties: Object.create(null),
|
|
3401
|
-
required: /* @__PURE__ */ new Set(),
|
|
3402
|
-
owner: /* @__PURE__ */ new Map()
|
|
3403
|
-
};
|
|
3404
|
-
const pathParamNames = extractPathParamNames(definition.path);
|
|
3405
|
-
const paramsDetails = definition.schemas?.params ? readObjectSchema(definition.schemas.params, warnings, `${label} params`, "input") : void 0;
|
|
3406
|
-
if (paramsDetails) mergeProperties(merged, paramsDetails.properties, paramsDetails.required, "params", warnings);
|
|
3407
|
-
const supplements = Object.create(null);
|
|
3408
|
-
const supplementRequired = /* @__PURE__ */ new Set();
|
|
3409
|
-
for (const name of pathParamNames) {
|
|
3410
|
-
if (merged.owner.has(name)) continue;
|
|
3411
|
-
supplements[name] = { type: "string" };
|
|
3412
|
-
supplementRequired.add(name);
|
|
3413
|
-
}
|
|
3414
|
-
mergeProperties(merged, supplements, supplementRequired, "path", warnings);
|
|
3415
|
-
const queryDetails = definition.schemas?.query ? readObjectSchema(definition.schemas.query, warnings, `${label} query`, "input") : void 0;
|
|
3416
|
-
if (queryDetails) mergeProperties(merged, queryDetails.properties, queryDetails.required, "query", warnings);
|
|
3417
|
-
let nestedBody = false;
|
|
3418
|
-
const body = definition.schemas?.body ? toJsonSchema(definition.schemas.body, warnings, `${label} body`, "input") : void 0;
|
|
3419
|
-
if (body) {
|
|
3420
|
-
if (body.type === "object" && body.properties) mergeProperties(merged, body.properties, new Set(body.required ?? []), "body", warnings);
|
|
3421
|
-
else {
|
|
3422
|
-
mergeProperties(merged, { body }, /* @__PURE__ */ new Set(["body"]), "body", warnings);
|
|
3423
|
-
nestedBody = true;
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
for (const name of pathParamNames) if (name in merged.properties) merged.required.add(name);
|
|
3427
|
-
const required = Array.from(merged.required);
|
|
3428
|
-
const sources = Object.create(null);
|
|
3429
|
-
for (const [name, source] of merged.owner) sources[name] = source;
|
|
3430
|
-
return {
|
|
3431
|
-
schema: {
|
|
3432
|
-
type: "object",
|
|
3433
|
-
properties: { ...merged.properties },
|
|
3434
|
-
...required.length > 0 ? { required } : {}
|
|
3435
|
-
},
|
|
3436
|
-
sources: { ...sources },
|
|
3437
|
-
nestedBody
|
|
3438
|
-
};
|
|
3439
|
-
}
|
|
3440
|
-
/**
|
|
3441
|
-
* Fold one source's properties into the merge. A collision replaces both the
|
|
3442
|
-
* property *and* its required-ness — carrying a losing source's `required`
|
|
3443
|
-
* forward would demand a key the advertised schema does not describe.
|
|
3444
|
-
*/
|
|
3445
|
-
function mergeProperties(merged, properties, required, source, warnings) {
|
|
3446
|
-
for (const [name, schema] of Object.entries(properties)) {
|
|
3447
|
-
const previous = merged.owner.get(name);
|
|
3448
|
-
if (previous) warnings.push(`input key "${name}" is declared by both the ${previous} and the ${source} schema; the ${source} definition wins. Rename one — merged tool input has one namespace.`);
|
|
3449
|
-
merged.properties[name] = schema;
|
|
3450
|
-
merged.owner.set(name, source);
|
|
3451
|
-
merged.required.delete(name);
|
|
3452
|
-
if (required.has(name)) merged.required.add(name);
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
/**
|
|
3456
|
-
* The route's `output` schema — the only response shape validated at runtime,
|
|
3457
|
-
* so advertising it costs no new machinery. A `resource` hint is the next rung
|
|
3458
|
-
* of RFC 0016's ladder and is CLI-only: the type text behind its class names
|
|
3459
|
-
* exists solely in the CLI's AST extraction.
|
|
3460
|
-
*/
|
|
3461
|
-
function buildOutputSchema(definition, method, warnings) {
|
|
3462
|
-
const output = definition.schemas?.output;
|
|
3463
|
-
if (!output) return void 0;
|
|
3464
|
-
return toJsonSchema(output, warnings, `${method} ${definition.path} response`, "output");
|
|
3465
|
-
}
|
|
3466
|
-
/**
|
|
3467
|
-
* The ability a route's middleware chain checks, when the stamped capability
|
|
3468
|
-
* says so unambiguously (RFC 0007's `MiddlewareCapabilities.authorization`).
|
|
3469
|
-
* Everything else is omitted rather than guessed, so absence means
|
|
3470
|
-
* "undetermined" — which is what lets `guren check`'s "authn is not authz" rule
|
|
3471
|
-
* fail closed on it instead of reading a name that was never checked.
|
|
3472
|
-
*/
|
|
3473
|
-
function deriveAuthorization(definition, method) {
|
|
3474
|
-
const authorization = definition.capabilities?.authorization;
|
|
3475
|
-
if (!authorization) return void 0;
|
|
3476
|
-
if (authorization.resource) {
|
|
3477
|
-
if (!authorization.resource.fromMethodMap) return void 0;
|
|
3478
|
-
if (authorization.abilities.length > 0 || authorization.mode !== "all") return void 0;
|
|
3479
|
-
const ability = resourceAbilityForMethod(method);
|
|
3480
|
-
return ability ? { ability } : void 0;
|
|
3481
|
-
}
|
|
3482
|
-
if (authorization.abilities.length === 1 && authorization.mode === "all") return { ability: authorization.abilities[0] };
|
|
3483
|
-
}
|
|
3484
|
-
//#endregion
|
|
3485
3958
|
//#region src/agent/meta-tools.ts
|
|
3486
3959
|
/**
|
|
3487
3960
|
* The names a protocol adapter may add to an application's tool catalogue on
|
|
@@ -3541,9 +4014,7 @@ function isReservedAgentToolName(name) {
|
|
|
3541
4014
|
*/
|
|
3542
4015
|
/**
|
|
3543
4016
|
* The MCP tool-name grammar (SEP-986), which a `tool:` scope names and a
|
|
3544
|
-
* `tools:<prefix>.*` scope must stay inside.
|
|
3545
|
-
* holds the same pattern; collapsing the two needs a built server, so it waits
|
|
3546
|
-
* for the PR doing that build-order work. `*` is not in the charset, so
|
|
4017
|
+
* `tools:<prefix>.*` scope must stay inside. `*` is not in the charset, so
|
|
3547
4018
|
* `tool:posts.*` is rejected with no special case.
|
|
3548
4019
|
*/
|
|
3549
4020
|
const AGENT_TOOL_NAME_PATTERN = /^[A-Za-z0-9._-]{1,128}$/;
|
|
@@ -7491,4 +7962,4 @@ function defineStorageConfig(resolve) {
|
|
|
7491
7962
|
//#region src/index.ts
|
|
7492
7963
|
ensureErrorStackTracePolyfill();
|
|
7493
7964
|
//#endregion
|
|
7494
|
-
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BUILT_IN_SESSION_DRIVERS, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CONTAINER_CONTEXT_KEY, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, Env, EnvSchema, EnvValidationError, EnvVar, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySchedulerLock, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PORTABLE_AGENT_TOOL_NAME_PATTERN, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, ambientBinding, ambientContainer, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, clearQueueDriver, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentCallBudget, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueEventDispatcher, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defaultApplication, defaultContainer, defineCacheConfig, defineConfig, defineEnv, defineFactory, defineGate, defineHttpConfig, defineMailConfig, defineMiddleware, defineModule, defineOAuthConfig, definePlugin, definePolicy, defineQueueConfig, defineStorageConfig, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestContainer, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isRawEnvKey, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, prototype, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, recordEnvReads, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetDefaultApplication, resetRateLimit, resolve, resolveAgentAuditSink, resolveJobName, resolveNotifiableType, resolveOptional, resolveQueueDriver, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, tryGetRequestContainer, unique, url as urlRule, urlSafeToken, useAsDefaultApplication, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|
|
7965
|
+
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BUILT_IN_SESSION_DRIVERS, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CONTAINER_CONTEXT_KEY, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, Env, EnvSchema, EnvValidationError, EnvVar, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySchedulerLock, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PORTABLE_AGENT_TOOL_NAME_PATTERN, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, always, ambientBinding, ambientContainer, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, clearQueueDriver, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentCallBudget, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueEventDispatcher, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, createWebSocketOriginGuard, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defaultApplication, defaultContainer, defer, defineCacheConfig, defineConfig, defineEnv, defineFactory, defineGate, defineHttpConfig, defineMailConfig, defineMiddleware, defineModule, defineOAuthConfig, definePlugin, definePolicy, defineQueueConfig, defineStorageConfig, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestContainer, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isAlwaysProp, isDeferredProp, isDue, isDueInTimezone, isEmailVerified, isIntrospecting, isRawEnvKey, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, prototype, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, recordEnvReads, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetDefaultApplication, resetRateLimit, resolve, resolveAgentAuditSink, resolveJobName, resolveNotifiableType, resolveOptional, resolveQueueDriver, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, tryGetRequestContainer, unique, url as urlRule, urlSafeToken, useAsDefaultApplication, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|