stitchkit 0.50.0 → 0.51.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.
@@ -48,6 +48,16 @@ export declare function defineMultipartStream<const E extends StreamingEndpoint,
48
48
  * handler only ever sees the loose `RuntimeContext`.
49
49
  */
50
50
  export declare function createMultipartStream<TCtx extends RuntimeContext>(): <const E extends StreamingEndpoint, const R extends ReceiverMap<E>>(endpoint: E, config: MultipartStreamConfig<E, R, TCtx>) => StreamingMultipartImplementation;
51
+ /**
52
+ * A `ServiceDef` whose handlers only throw — enough for everything that reads
53
+ * the mounted surface (names, exposure, kinds) without implementing anything.
54
+ *
55
+ * Internal on purpose (not re-exported from an entrypoint): a listing helper.
56
+ * Going through the real `bindContract` is the point — the produced methods are
57
+ * the same objects the real mounts see, so a name listing derived from here can
58
+ * never drift from the mounted surface.
59
+ */
60
+ export declare function contractOnlyService(contract: ContractDef): ServiceDef;
51
61
  export declare function implement<T extends Record<string, EndpointDef>, TCtx extends RuntimeContext = RuntimeContext>(contract: ContractDef<T, string>, handlers: Handlers<T, TCtx>): ServiceDef;
52
62
  /**
53
63
  * Fix the handler context type once — `const implement =
@@ -102,7 +112,7 @@ export type ExactScopedRegistryHandlers<TContracts extends ImplementationRegistr
102
112
  * endpoint's effective scope. Missing, extra and endpoint-incompatible entries
103
113
  * fail exactly as they do in `implementRegistry`.
104
114
  */
105
- export declare function createScopedImplementRegistry<TScopes extends ScopeContexts>(): <const TContracts extends ScopedImplementationRegistry<TScopes>, const THandlers extends ScopedRegistryHandlers<TContracts, TScopes>>(contracts: TContracts, handlers: ExactScopedRegistryHandlers<TContracts, THandlers, TScopes>) => ServiceDef[];
115
+ export declare function createScopedImplementRegistry<TScopes extends ScopeContexts>(): <const TContracts extends ScopedImplementationRegistry<TScopes>, const THandlers extends ScopedRegistryHandlers<TContracts, TScopes>>(contracts: TContracts, handlers: ExactScopedRegistryHandlers<TContracts, THandlers, TScopes>) => KeyedServices<TContracts>;
106
116
  export type ImplementationRegistry = Record<string, ContractDef<Record<string, EndpointDef>, string>>;
107
117
  /** Exact handlers map derived from a literal contract registry. */
108
118
  export type RegistryHandlers<TContracts extends ImplementationRegistry, TCtx extends RuntimeContext = RuntimeContext> = {
@@ -111,13 +121,30 @@ export type RegistryHandlers<TContracts extends ImplementationRegistry, TCtx ext
111
121
  export type ExactRegistryHandlers<TContracts extends ImplementationRegistry, THandlers extends RegistryHandlers<TContracts, TCtx>, TCtx extends RuntimeContext> = THandlers & RegistryHandlers<TContracts, TCtx> & Record<Exclude<keyof THandlers, keyof TContracts>, never> & {
112
122
  [K in keyof THandlers & keyof TContracts]: THandlers[K] & Record<Exclude<keyof THandlers[K], keyof RegistryHandlers<TContracts, TCtx>[K]>, never>;
113
123
  };
124
+ /**
125
+ * Registry results keep both shapes: the mount-ordered array a server consumes,
126
+ * and the same services by their registry key. Keys are load-bearing for
127
+ * consumers that filter a tool surface per caller ("these bots see only
128
+ * services X and Y") — dropping them forced a hand-rebuilt prefix lookup, and a
129
+ * silent one at that.
130
+ */
131
+ export type KeyedServices<TContracts extends ImplementationRegistry> = ServiceDef[] & {
132
+ /**
133
+ * The same services, by registry key. Same objects as the array entries.
134
+ * Non-enumerable: `Object.keys` / `Object.values` / object spread of the
135
+ * array see only the services, exactly as before.
136
+ */
137
+ readonly byKey: {
138
+ readonly [K in keyof TContracts]: ServiceDef;
139
+ };
140
+ };
114
141
  /**
115
142
  * Bind an exact `name → contract` registry to its exact handlers map. Missing,
116
143
  * extra and endpoint-incompatible implementations fail at compile time; loose
117
144
  * JavaScript callers receive the same checks at runtime.
118
145
  */
119
- export declare function implementRegistry<const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, RuntimeContext>): ServiceDef[];
146
+ export declare function implementRegistry<const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, RuntimeContext>): KeyedServices<TContracts>;
120
147
  /** Fix one handler context type for every entry in an implementation registry. */
121
- export declare function createImplementRegistry<TCtx extends RuntimeContext>(): <const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts, TCtx>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, TCtx>) => ServiceDef[];
148
+ export declare function createImplementRegistry<TCtx extends RuntimeContext>(): <const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts, TCtx>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, TCtx>) => KeyedServices<TContracts>;
122
149
  export {};
123
150
  //# sourceMappingURL=implement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/server/implement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EACV,sBAAsB,EACtB,QAAQ,EAER,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,UAAU,EACV,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB,KAAK,iBAAiB,GAAG,WAAW,GAAG;IACrC,SAAS,EAAE,mBAAmB,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;CACzD,CAAC;AACF,KAAK,WAAW,CAAC,CAAC,SAAS,iBAAiB,IAAI;KAC7C,CAAC,IAAI,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,iBAAiB;CACxD,CAAC;AACF,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACzE,KAAK,aAAa,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAA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G;IACpF;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,UAAU,GAAG,UAAU;KAAE,CAAC;CAClE,CAAC;AAgEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,UAAU,SAAS,sBAAsB,EAC/C,KAAK,CAAC,SAAS,SAAS,gBAAgB,CAAC,UAAU,CAAC,EAEpD,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC,GACrE,aAAa,CAAC,UAAU,CAAC,CAK3B;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,IAAI,SAAS,cAAc,MAE/D,KAAK,CAAC,UAAU,SAAS,sBAAsB,EAC/C,KAAK,CAAC,SAAS,SAAS,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,aAE/C,UAAU,YACX,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,KAC3D,aAAa,CAAC,UAAU,CAAC,CAG7B"}
@@ -7,9 +7,9 @@ export { createHandler } from './create';
7
7
  export { createErrorHook, type ErrorHookConfig, type ResolvedError, } from './error-hook';
8
8
  export { createEventBus, type DefaultEventMap, type EventBus, type EventBusOptions, type EventHandler, } from './event-bus';
9
9
  export { type ByteRange, parseByteRange, type ServeFileOptions, serveFile, staticRoute, weakETag, } from './file';
10
- export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './implement';
10
+ export { createImplement, createImplementRegistry, createMultipartStream, createScopedImplement, createScopedImplementRegistry, defineMultipartStream, type ExactRegistryHandlers, type ExactScopedRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type KeyedServices, type MultipartStreamConfig, type RegistryHandlers, type ScopedImplementationRegistry, type ScopedRegistryHandlers, type StreamScope, } from './implement';
11
11
  export type { LogFormat } from './logger';
12
- export { type AuthHook, type AuthHookConfig, type AuthRule, type BearerResolverConfig, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth';
12
+ export { type AuthHook, type AuthHookConfig, type AuthRule, type AuthRules, type AuthScopes, type BearerResolverConfig, createAuthHook, createBearerResolver, extractToken, type JwtPayload, type RuleScopes, type ScopedAuthHook, type ScopedAuthRule, type SignJwtOptions, signJwt, type VerifyJwtOptions, verifyJwt, } from './middleware/auth';
13
13
  export { type CookieDef, type CookieOptions, defineCookie, parseCookies, serializeCookie, } from './middleware/cookies';
14
14
  export { type CorsConfig, corsHeaders, corsPreflightResponse, DEFAULT_CORS_ALLOW_HEADERS, DEFAULT_CORS_EXPOSE_HEADERS, } from './middleware/cors';
15
15
  export { deriveCodeChallenge, type PkceMethod, verifyPkce } from './middleware/pkce';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe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M,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KA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EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
@@ -7,20 +7,12 @@ import {
7
7
  bindRealtimeServer,
8
8
  composeWebSocketHandlers,
9
9
  createHandler,
10
- createImplement,
11
- createImplementRegistry,
12
- createMultipartStream,
13
- createScopedImplement,
14
- createScopedImplementRegistry,
15
10
  createServerLifecycle,
16
11
  createSocketIOServer,
17
- defineMultipartStream,
18
- implement,
19
- implementRegistry,
20
12
  parseMultipart,
21
13
  socketIoLane,
22
14
  webSocketLane
23
- } from "../index-a4qmxybq.js";
15
+ } from "../index-8mt47qk7.js";
24
16
  import {
25
17
  createAuthHook,
26
18
  createBearerResolver,
@@ -32,13 +24,21 @@ import {
32
24
  signJwt,
33
25
  verifyJwt,
34
26
  verifyPkce
35
- } from "../index-03j2t778.js";
27
+ } from "../index-tw7mhqgy.js";
36
28
  import {
37
29
  DEFAULT_CORS_ALLOW_HEADERS,
38
30
  DEFAULT_CORS_EXPOSE_HEADERS,
39
31
  corsHeaders,
40
- corsPreflightResponse
41
- } from "../index-r1qp4rve.js";
32
+ corsPreflightResponse,
33
+ createImplement,
34
+ createImplementRegistry,
35
+ createMultipartStream,
36
+ createScopedImplement,
37
+ createScopedImplementRegistry,
38
+ defineMultipartStream,
39
+ implement,
40
+ implementRegistry
41
+ } from "../index-ynts85ew.js";
42
42
  import {
43
43
  isWithinDir,
44
44
  jsonSchemaFields,
@@ -69,11 +69,11 @@ import {
69
69
  resolveTraceId,
70
70
  unauthorized,
71
71
  zodIssues
72
- } from "../index-jewp9r0a.js";
72
+ } from "../index-8qghvg18.js";
73
73
  import {
74
74
  isRecord,
75
75
  parseTrailingWildcard
76
- } from "../index-h05ygjqx.js";
76
+ } from "../index-bmnhqtya.js";
77
77
  // src/server/bun.ts
78
78
  function createServer(config) {
79
79
  const {
@@ -40,7 +40,48 @@ export declare function extractToken(req: Request, cookieName?: string): string
40
40
  * async — resource-scoped checks usually need a DB lookup.
41
41
  */
42
42
  export type AuthRule<TIdentity> = 'public' | 'authenticated' | ((identity: Awaited<TIdentity>, ctx: RuntimeContext) => boolean | Promise<boolean>);
43
- export interface AuthHookConfig<TIdentity> {
43
+ /**
44
+ * A rule that also DECLARES this scope's contribution to the handler context —
45
+ * by doing it. `inject` runs whenever an identity resolved (on `'public'` too:
46
+ * that rule admits the anonymous, it does not refuse to know the logged-in),
47
+ * and its returned fields are merged into the context.
48
+ *
49
+ * The return type is the point: {@link AuthScopes} derives the scope→context
50
+ * map from it, so `createScopedImplement<AuthScopes<typeof hook>>()` types
51
+ * handlers from the same declaration that fills the context. One source of
52
+ * truth instead of a hand-written map drifting beside the hook. → ADR 0078
53
+ *
54
+ * `inject` must be **synchronous** — the type forbids a thenable and the
55
+ * runtime throws on one, because `Object.assign(ctx, promise)` would merge
56
+ * nothing, silently. It also runs before the rule check (and so for an
57
+ * identity the rule may still reject), so keep it pure: derive fields, cause
58
+ * nothing.
59
+ */
60
+ export interface ScopedAuthRule<TIdentity, TFields extends object = object> {
61
+ rule: AuthRule<TIdentity>;
62
+ /** Fields this scope guarantees. Runs after the shared `inject`, only with an identity. */
63
+ inject?: (identity: Awaited<TIdentity>, ctx: RuntimeContext) => TFields & {
64
+ then?: never;
65
+ };
66
+ }
67
+ /** The `rules` map: a bare rule, or a rule carrying its context contribution. */
68
+ export type AuthRules<TIdentity> = Record<string, AuthRule<TIdentity> | ScopedAuthRule<TIdentity, object>>;
69
+ /**
70
+ * The scope→context map derived from a `rules` object. A rule whose TYPE can
71
+ * be `'public'` yields optional fields — public still resolves and injects for
72
+ * a logged-in caller, it just never rejects the anonymous one — so its
73
+ * handlers see `field?: T`, not a promise the runtime may break. The test is
74
+ * membership, not the exact literal: a union such as
75
+ * `flag ? 'public' : 'authenticated'` may skip the inject at runtime, so its
76
+ * fields must be optional too.
77
+ */
78
+ export type RuleScopes<TRules> = {
79
+ [K in keyof TRules & string]: TRules[K] extends {
80
+ rule: infer TRule;
81
+ inject: (...args: never[]) => infer TFields extends object;
82
+ } ? 'public' extends Extract<TRule, string> ? Partial<TFields> : TFields : object;
83
+ };
84
+ export interface AuthHookConfig<TIdentity, TRules extends AuthRules<TIdentity> = AuthRules<TIdentity>> {
44
85
  /** Resolve the request identity — cookie / bearer + DB lookup. */
45
86
  resolve: (ctx: RuntimeContext) => Promise<TIdentity | null>;
46
87
  /**
@@ -52,7 +93,7 @@ export interface AuthHookConfig<TIdentity> {
52
93
  */
53
94
  resolveFromContext?: (ctx: RuntimeContext) => TIdentity | null | Promise<TIdentity | null>;
54
95
  /** Access rule per scope; `endpoint.scope` is the key. */
55
- rules: Record<string, AuthRule<TIdentity>>;
96
+ rules: TRules;
56
97
  /** Scope applied when an endpoint declares none. */
57
98
  defaultScope?: string;
58
99
  /** Write the resolved identity onto the context for handlers. */
@@ -66,6 +107,25 @@ export interface AuthHook {
66
107
  (ctx: AuthorizationContext, endpoint: OperationIdentity): Promise<void>;
67
108
  (ctx: RuntimeContext, endpoint: OperationIdentity): Promise<void>;
68
109
  }
110
+ /**
111
+ * An auth hook that carries its derived scope→context map at the type level.
112
+ * The marker property never exists at runtime; it only lets {@link AuthScopes}
113
+ * recover the map.
114
+ */
115
+ export interface ScopedAuthHook<TScopes extends Record<string, object>> extends AuthHook {
116
+ /** Type-only carrier for {@link AuthScopes}; never present at runtime. */
117
+ readonly '~scopes'?: TScopes;
118
+ }
119
+ /**
120
+ * The scope→context map a hook derived from its rules — feed it straight to
121
+ * `createScopedImplement`:
122
+ *
123
+ * ```ts
124
+ * const hook = createAuthHook({ resolve, rules })
125
+ * export const implementFor = createScopedImplement<AuthScopes<typeof hook>>()
126
+ * ```
127
+ */
128
+ export type AuthScopes<THook extends ScopedAuthHook<Record<string, object>>> = THook extends ScopedAuthHook<infer TScopes> ? TScopes : never;
69
129
  /**
70
130
  * Build a scope authorization hook.
71
131
  *
@@ -79,7 +139,7 @@ export interface AuthHook {
79
139
  * `req` — it uses `resolveFromContext`. If `resolveFromContext` is omitted, a
80
140
  * scoped tool call has no identity and **fails closed** (never silently passes).
81
141
  */
82
- export declare function createAuthHook<TIdentity>(config: AuthHookConfig<TIdentity>): AuthHook;
142
+ export declare function createAuthHook<TIdentity, const TRules extends AuthRules<TIdentity> = AuthRules<TIdentity>>(config: AuthHookConfig<TIdentity, TRules>): ScopedAuthHook<RuleScopes<TRules>>;
83
143
  /**
84
144
  * Bearer-token identity resolver — the MCP / API-key counterpart of the
85
145
  * cookie session hook. Strips `Authorization: Bearer <token>` and hands the
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/server/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGxE,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,8BAA8B;AAC9B,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,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O,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;CACpE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAC5C,MAAM,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACtC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAM7C"}
package/dist/testing.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createClient,
3
3
  createClients
4
- } from "./index-p9d4cxt5.js";
4
+ } from "./index-gff2mxzk.js";
5
5
  import"./index-48ffdxgk.js";
6
- import"./index-h05ygjqx.js";
6
+ import"./index-bmnhqtya.js";
7
7
 
8
8
  // src/testing.ts
9
9
  function resolveTestBaseUrl(origin, pathPrefix) {
@@ -10,7 +10,7 @@
10
10
  * Built on the mixed-surface collector used by the mounts — the listing cannot
11
11
  * drift when pathless runtime tools sit beside contract operations.
12
12
  */
13
- import type { Transport } from '../contract';
13
+ import type { ContractDef, Transport } from '../contract';
14
14
  import { type ToolSurfaceDefinition } from './surface';
15
15
  /** One mounted tool name and where it comes from. */
16
16
  export interface ToolNameEntry {
@@ -33,4 +33,16 @@ export interface ToolNameEntry {
33
33
  * mirroring the real mounts.
34
34
  */
35
35
  export declare function listToolNames(surface: ToolSurfaceDefinition): ToolNameEntry[];
36
+ /**
37
+ * The same listing straight from contracts — no handlers required. Names, kinds
38
+ * and exposure are deterministic contract facts, so a surface snapshot should
39
+ * not force the caller to build (or stub) services; a stub factory left lying
40
+ * around is an untyped door out of `createScopedImplement`.
41
+ *
42
+ * Each contract runs through the real `implement` binding internally, so this
43
+ * produces exactly the entries `listToolNames` yields for the implemented
44
+ * services — structurally guaranteed (both read only the mounted method
45
+ * definitions) and pinned by a deep-equality test.
46
+ */
47
+ export declare function listContractToolNames(contracts: readonly ContractDef[]): ToolNameEntry[];
36
48
  //# sourceMappingURL=list-names.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-names.d.ts","sourceRoot":"","sources":["../../src/tools/list-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,WAAW,CAAC;AAEnB,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,EAAE,CA6B7E"}
1
+ {"version":3,"file":"list-names.d.ts","sourceRoot":"","sources":["../../src/tools/list-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,WAAW,CAAC;AAEnB,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,EAAE,CA6B7E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG,aAAa,EAAE,CAExF"}
package/dist/tools.d.ts CHANGED
@@ -8,7 +8,7 @@ export { coerceJsonArgs } from './tools/coerce';
8
8
  export type { AfterToolCallOptions, BeforeToolCallOptions, ErrorHintFn, ToolCallContext, ToolCallHooks, ToolErrorOptions, ToolLifecycle, ToolOperation, ToolResult, } from './tools/execute';
9
9
  export { flattenToolJsonSchema, type ToolPresentationSchema, } from './tools/flatten';
10
10
  export { createToolInvoker, type ToolInvocationOptions, type ToolInvoker, type ToolInvokerConfig, type ToolInvokerTransport, } from './tools/invoker';
11
- export { listToolNames, type ToolNameEntry } from './tools/list-names';
11
+ export { listContractToolNames, listToolNames, type ToolNameEntry, } from './tools/list-names';
12
12
  export { buildToolManifest, type ToolManifestConfig, type ToolManifestEntry, } from './tools/manifest';
13
13
  export { buildMcpServer, type DirectMcpSurfaceConfig, type FiniteMcpSurfaceConfig, type McpMountConfig, type McpServerBuildConfig, type McpServerSharedConfig, mountMcp, mountMcpResource, validateMcpSchemas, } from './tools/mcp';
14
14
  export { EXT_APPS_BUNDLE_PLACEHOLDER, inlineMcpAppBundle, type McpAppCsp, type McpAppResourceMeta, type McpResourceDef, RESOURCE_MIME_TYPE, } from './tools/mcp-app';
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;A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oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,aAAa,EACb,YAAY,EACZ,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC"}
package/dist/tools.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  signJwt,
3
3
  verifyPkce
4
- } from "./index-03j2t778.js";
4
+ } from "./index-tw7mhqgy.js";
5
5
  import {
6
- DEFAULT_CORS_ALLOW_HEADERS
7
- } from "./index-r1qp4rve.js";
6
+ DEFAULT_CORS_ALLOW_HEADERS,
7
+ contractOnlyService
8
+ } from "./index-ynts85ew.js";
8
9
  import {
9
10
  assertToolName,
10
11
  assertUniqueToolName,
@@ -25,7 +26,7 @@ import {
25
26
  toolErrorFromResult,
26
27
  toolResultFromError,
27
28
  writeDownload
28
- } from "./index-0hj37z43.js";
29
+ } from "./index-h55e1wyq.js";
29
30
  import {
30
31
  isWithinDir,
31
32
  realPathWithinDir,
@@ -34,22 +35,22 @@ import {
34
35
  import {
35
36
  ApiError,
36
37
  createClient
37
- } from "./index-p9d4cxt5.js";
38
+ } from "./index-gff2mxzk.js";
38
39
  import"./index-48ffdxgk.js";
39
40
  import {
40
41
  redact
41
- } from "./index-v58mwa19.js";
42
+ } from "./index-psrxjvbw.js";
42
43
  import {
43
44
  AppError,
44
45
  getRequestContext,
45
46
  getTraceId,
46
47
  mergeMeta,
47
48
  runWithRequestContext
48
- } from "./index-jewp9r0a.js";
49
+ } from "./index-8qghvg18.js";
49
50
  import {
50
51
  isRecord,
51
52
  resolvePropagationContext
52
- } from "./index-h05ygjqx.js";
53
+ } from "./index-bmnhqtya.js";
53
54
 
54
55
  // src/tools/agent.ts
55
56
  import { jsonSchema, tool } from "ai";
@@ -336,6 +337,9 @@ function listToolNames(surface) {
336
337
  }
337
338
  return [...entries.values()].sort((a, b) => a.name.localeCompare(b.name) || a.service.localeCompare(b.service));
338
339
  }
340
+ function listContractToolNames(contracts) {
341
+ return listToolNames({ services: contracts.map(contractOnlyService) });
342
+ }
339
343
  // src/tools/manifest.ts
340
344
  function buildToolManifest(config) {
341
345
  return collectToolSurface({
@@ -2506,6 +2510,7 @@ export {
2506
2510
  mountDownload,
2507
2511
  mountAgent,
2508
2512
  listToolNames,
2513
+ listContractToolNames,
2509
2514
  inlineMcpAppBundle,
2510
2515
  implementRemote,
2511
2516
  flattenToolJsonSchema,
package/llms-full.txt CHANGED
@@ -737,7 +737,12 @@ Three boundaries worth knowing:
737
737
  it). It degrades to `unknown`, so it can no longer pose as a `string`; using it
738
738
  in a typed position fails.
739
739
  - The map states what **your** `beforeHandle` / `createAuthHook.inject` puts on
740
- the context. The framework does not verify that claim (→ ADR 0075).
740
+ the context. The framework does not verify a hand-written claim (→ ADR 0075)
741
+ so prefer not to write one: scoped auth rules declare their contribution by
742
+ performing it, and `createScopedImplement<AuthScopes<typeof hook>>()` derives
743
+ the map from the hook
744
+ ([details](./auth-and-errors.md#scoped-rules--the-map-createscopedimplement-consumes),
745
+ → ADR 0078).
741
746
  - An endpoint hoisted out of the contract literal widens its `scope` to `string`,
742
747
  which is no key of any map, and lands in the error branch. An endpoint whose
743
748
  `scope` is added by a conditional spread is optional, so it resolves to **both**
@@ -785,7 +790,17 @@ export const apiServices = implementRegistry(apiContractRegistry, {
785
790
 
786
791
  Every registry key is required, extra keys fail, and each handler map is checked
787
792
  against its own contract. The returned service order follows the contract
788
- registry order. `createImplementRegistry<AppContext>()` fixes the application
793
+ registry order and the same services ride along under `.byKey`, so a consumer
794
+ whose registry keys are load-bearing (filtering a tool surface per caller) never
795
+ rebuilds a prefix lookup by hand:
796
+
797
+ ```ts
798
+ const services = implementRegistry(apiContractRegistry, handlers)
799
+ createServer({ services }) // the array, as before
800
+ const visible = [services.byKey.users] // the same objects, by key
801
+ ```
802
+
803
+ `createImplementRegistry<AppContext>()` fixes the application
789
804
  context once, like `createImplement` does for a single contract. Runtime callers
790
805
  also fail first on missing/extra keys and duplicate contract prefixes.
791
806
 
@@ -3755,7 +3770,61 @@ endpoints under the group declare `scope: 'tenant'`.
3755
3770
  | `onForbidden` | thrown when an identity is present but the rule rejects it (default 403) |
3756
3771
 
3757
3772
  Annotate `rules` with `satisfies Record<MyScope, AuthRule<User>>` so the compiler
3758
- catches a scope you forgot to cover.
3773
+ catches a scope you forgot to cover. With the scoped rule objects below, widen
3774
+ the annotation to
3775
+ `satisfies Record<MyScope, AuthRule<User> | ScopedAuthRule<User, object>>` — it
3776
+ keeps the coverage check and does not disturb the derivation. (When every scope
3777
+ comes from the derived map, the check is already implicit: a scope missing from
3778
+ `rules` is no key of the map, and a contract using it fails to compile.)
3779
+
3780
+ ### Scoped rules — the map `createScopedImplement` consumes
3781
+
3782
+ A rule may take an object form, `{ rule, inject }`, where `inject` **returns**
3783
+ the fields this scope contributes. That return type is a declaration the hook
3784
+ derives a scope→context map from — feed it to
3785
+ [`createScopedImplement`](./server.md#per-scope-handler-context--createscopedimplement)
3786
+ and the map can never drift from the hook, because it is computed from it:
3787
+
3788
+ ```ts
3789
+ const authHook = createAuthHook({
3790
+ resolve: sessionResolver, // no explicit generic — let it infer
3791
+ rules: {
3792
+ public: { rule: 'public', inject: (user) => ({ userId: user.id }) },
3793
+ user: { rule: 'authenticated', inject: (user) => ({ userId: user.id }) },
3794
+ admin: {
3795
+ rule: (user) => user.admin,
3796
+ inject: (user) => ({ userId: user.id, isAdmin: user.admin }),
3797
+ },
3798
+ },
3799
+ })
3800
+
3801
+ export const implementFor = createScopedImplement<AuthScopes<typeof authHook>>()
3802
+ ```
3803
+
3804
+ - A `'public'` rule's fields come out **optional**: public admits the anonymous
3805
+ caller, it does not refuse to know the logged-in one — `resolve` and `inject`
3806
+ still run, so a public `me` / `logout` handler reads `ctx.userId` as
3807
+ `string | undefined` and narrows, instead of being pushed toward a cast by a
3808
+ `public: object` map.
3809
+ - Any other rule's fields are required — the rule rejected the request before
3810
+ the handler if no identity resolved.
3811
+ - A scope with no rule is no key of the derived map, so a contract using it
3812
+ fails to compile — the type-level mirror of the hook's fail-closed
3813
+ `no rule for scope` throw.
3814
+
3815
+ The per-rule `inject` runs after the shared one, only when an identity
3816
+ resolved, and **before** the rule check — it may run for an identity the rule
3817
+ then rejects, so keep it pure and synchronous (an async `inject` is a compile
3818
+ error, and a runtime one for untyped callers: merging a Promise would merge
3819
+ nothing). Write rule objects inline in `rules` — a hoisted, annotated rule
3820
+ widens its inject and degrades that scope's fields to `object`.
3821
+
3822
+ Derivation needs the identity generic to be **inferred** (write no explicit
3823
+ `createAuthHook<User>` — TypeScript has no partial inference); with an explicit
3824
+ generic, or fields injected outside the hook, keep the hand-written map. Two
3825
+ hooks guarding different scopes compose by intersection:
3826
+ `createScopedImplement<AuthScopes<typeof userHook> & AuthScopes<typeof botHook>>()`.
3827
+ → ADR 0078
3759
3828
 
3760
3829
  ### Auth on the tool surface — `resolveFromContext`
3761
3830
 
@@ -4797,6 +4866,71 @@ closing one whose chain is already running leaves that chain to finish and keeps
4797
4866
  the handle claimed, since a second binding could not force it. `promise` is
4798
4867
  already observed internally, so ignoring it never raises an `unhandledRejection`.
4799
4868
 
4869
+ #### Composite shutdown target — parallel domain drains
4870
+
4871
+ `bindProcessSignals` takes `Pick<ManagedServerHandle, 'shutdown'>` — an
4872
+ **interface**, not the server. An application whose shutdown spans several
4873
+ domains (transport, bots, agent runs, broadcasts) composes them into one target;
4874
+ the signal machine stays the framework's, the composition stays yours:
4875
+
4876
+ ```ts
4877
+ const composite: ShutdownTarget = {
4878
+ async shutdown(options?: ShutdownOptions): Promise<ShutdownResult> {
4879
+ const { signal } = ShutdownOptionsSchema.parse(options ?? {})
4880
+ // Domain drains run in parallel with the transport drain, all watching the
4881
+ // same force signal the second OS signal aborts.
4882
+ const [transport, bots, agents, broadcasts] = await Promise.all([
4883
+ server.shutdown(options),
4884
+ drainBots(signal),
4885
+ drainAgents(signal),
4886
+ drainBroadcasts(signal),
4887
+ ])
4888
+ return {
4889
+ ...transport,
4890
+ // Fold domain leftovers into the transport result so `onComplete` sees
4891
+ // one honest outcome.
4892
+ outcome: transport.outcome === 'clean' && bots + agents + broadcasts === 0
4893
+ ? 'clean'
4894
+ : 'forced',
4895
+ }
4896
+ },
4897
+ }
4898
+
4899
+ bindProcessSignals(composite, { shutdown: { gracePeriodMs: 30_000 } })
4900
+ ```
4901
+
4902
+ The transport half inside stays the real managed handle — its admission gate and
4903
+ HTTP drain are not reimplemented, only composed. Domain drains must watch the
4904
+ `signal` themselves: it is the only channel a second OS signal has into a
4905
+ running chain.
4906
+
4907
+ #### The last line of defence is yours
4908
+
4909
+ The framework never calls `process.exit`, and `process.exitCode` only takes
4910
+ effect once the event loop empties — which is exactly what a stuck resource
4911
+ prevents. If the deployment must exit before the supervisor's `SIGKILL`, arm an
4912
+ application-side timer:
4913
+
4914
+ ```ts
4915
+ onShutdown: () => {
4916
+ setTimeout(() => process.exit(1), 60_000).unref()
4917
+ },
4918
+ ```
4919
+
4920
+ `unref()` keeps the timer from holding a healthy process open; it only fires if
4921
+ something else already is.
4922
+
4923
+ #### When NOT to use `bindProcessSignals`
4924
+
4925
+ - The application already runs a signal machine with states this one does not
4926
+ have (staged escalation policies, per-signal semantics beyond
4927
+ first/force/escalate). Two machines on the same signals is worse than either.
4928
+ - Signal policy must differ per signal (e.g. `SIGHUP` = reload, not shutdown) —
4929
+ bind only the terminating signals here and keep the rest yours.
4930
+ - Something else in the process must keep listening for the same signal: the
4931
+ escalation path restores the default disposition only when nothing else
4932
+ listens, and reports `onEscalationBlocked` otherwise.
4933
+
4800
4934
  The server owns HTTP/Socket.IO transport resources. MCP, databases, queues and
4801
4935
  domain run-state remain application resources and close explicitly after server
4802
4936
  drain. Do not call `runtime.stop()` or `socket.io.close()` in parallel with
@@ -6229,6 +6363,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
6229
6363
  | `implementRegistry` | function | bind one exact contract registry to one exact backend handler registry |
6230
6364
  | `createImplementRegistry` | function | context-typed factory for `implementRegistry` |
6231
6365
  | `ImplementationRegistry` | _type_ | flat literal registry of concrete contracts accepted by `implementRegistry` |
6366
+ | `KeyedServices` | _type_ | registry result: the mount-ordered `ServiceDef[]` carrying the same services under `.byKey` |
6232
6367
  | `RegistryHandlers` | _type_ | exact backend handler registry inferred from a contract registry |
6233
6368
  | `ExactRegistryHandlers` | _type_ | fail-first handler shape that rejects extra registry and endpoint keys |
6234
6369
  | `staticRoute` | function | a raw route that serves a directory |
@@ -6290,6 +6425,11 @@ Also re-exports the error helpers from `stitchkit/contract`.
6290
6425
  | `AuthHook` | _type_ | the hook `createAuthHook` returns |
6291
6426
  | `AuthHookConfig` | _type_ | config for `createAuthHook` |
6292
6427
  | `AuthRule` | _type_ | `'public' \| 'authenticated' \| predicate` |
6428
+ | `ScopedAuthRule` | _type_ | a rule plus its typed context contribution — `{ rule, inject? }` |
6429
+ | `AuthRules` | _type_ | the `rules` map: bare rules or scoped rules |
6430
+ | `RuleScopes` | _type_ | scope→context map derived from a `rules` object; `'public'` fields become optional |
6431
+ | `ScopedAuthHook` | _type_ | an auth hook carrying its derived scope map at the type level |
6432
+ | `AuthScopes` | _type_ | recover the derived map — `createScopedImplement<AuthScopes<typeof hook>>()` |
6293
6433
  | `BearerResolverConfig` | _type_ | config for `createBearerResolver` |
6294
6434
  | `JwtPayload` | _type_ | a decoded JWT payload |
6295
6435
  | `SignJwtOptions` | _type_ | options for `signJwt` (expiry, claims) |
@@ -6352,7 +6492,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
6352
6492
  | `ProcessSignalsErrorPhase` | _type_ | `'prepare' \| 'shutdown' \| 'complete'` — which phase an `onError` report came from |
6353
6493
  | `SignalSource` | _type_ | injectable signal source — `process` by default |
6354
6494
  | `ProcessSignalName` | _type_ | signal names the binding accepts (owned, so the published types need no `@types/node`) |
6355
- | `ShutdownTarget` | _type_ | the `shutdown`-only slice of a managed handle a binding needs |
6495
+ | `ShutdownTarget` | _type_ | the `shutdown`-only slice a binding needs — an interface, so a [composite target](../guide/testing-and-deployment.md#composite-shutdown-target--parallel-domain-drains) can drain several domains under one signal machine |
6356
6496
  | `createRateLimiter` | function | token-bucket rate limiting — [guide](../guide/server.md#rate-limiting) |
6357
6497
  | `createCache` | function | an in-memory TTL cache |
6358
6498
  | `CacheOptions` | _type_ | bounded-cache options, including the maximum retained entry count |
@@ -6481,6 +6621,7 @@ payload.
6481
6621
  | `resolveMedia` | function | resolve a media reference for a tool result |
6482
6622
  | `validateMcpSchemas` | function | object-shaped assertion over the exact advertised schema surface — compatibility, typed properties and portable formats ([guide](../guide/mcp-and-agents.md#mcp-schema-validation-profile)) |
6483
6623
  | `listToolNames` | function | every contract/runtime tool name with origin, identity and transports — for stable snapshots — [guide](../guide/mcp-and-agents.md#pinning-tool-names--listtoolnames) |
6624
+ | `listContractToolNames` | function | the same listing straight from contracts — no handlers or stub services needed |
6484
6625
  | `McpHandlerConfig` | _type_ | server surface plus stateless HTTP transport config |
6485
6626
  | `McpHttpConfig` | _type_ | HTTP auth, protected-resource, legacy-era and security options |
6486
6627
  | `McpHttpHandler` | _type_ | framework-owned `{ fetch(request), close() }` lifecycle |