@frontmcp/sdk 1.11.1-rc.2 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser/index.cjs CHANGED
@@ -40768,6 +40768,10 @@ var init_primary_auth_provider_interface = __esm({
40768
40768
  }
40769
40769
  return "unknown";
40770
40770
  }
40771
+ /** The connected store of a Redis or SQLite `auth.tokenStorage`, once this auth has opened one. */
40772
+ get tokenStorageAdapter() {
40773
+ return void 0;
40774
+ }
40771
40775
  /**
40772
40776
  * Cryptographically verify a gateway-issued access token (public/local/remote
40773
40777
  * "gateway" modes \u2014 i.e. NOT transparent). Gateway tokens are signed by this
@@ -54136,127 +54140,6 @@ var init_startup_report_helper = __esm({
54136
54140
  }
54137
54141
  });
54138
54142
 
54139
- // libs/sdk/src/auth/session-scope-identity.ts
54140
- function sessionScopeIdentity(ctx) {
54141
- const verified = ctx.verifiedSessionId;
54142
- if (verified) return verified;
54143
- const authInfo = ctx.authInfo ?? {};
54144
- const extraUser = authInfo.extra?.["user"];
54145
- const principal = [authInfo.user?.sub, extraUser?.sub, authInfo.clientId].find(
54146
- (candidate) => !(0, import_auth45.isAnonymousSubject)(candidate)
54147
- );
54148
- return principal ? `principal:${principal}` : void 0;
54149
- }
54150
- var import_auth45;
54151
- var init_session_scope_identity = __esm({
54152
- "libs/sdk/src/auth/session-scope-identity.ts"() {
54153
- "use strict";
54154
- import_auth45 = require("@frontmcp/auth");
54155
- }
54156
- });
54157
-
54158
- // libs/sdk/src/auth/vault/credential-cache.ts
54159
- var CREDENTIAL_CACHE;
54160
- var init_credential_cache = __esm({
54161
- "libs/sdk/src/auth/vault/credential-cache.ts"() {
54162
- "use strict";
54163
- CREDENTIAL_CACHE = /* @__PURE__ */ Symbol.for("frontmcp:CREDENTIAL_CACHE");
54164
- }
54165
- });
54166
-
54167
- // libs/sdk/src/auth/vault/auth-providers.providers.ts
54168
- var auth_providers_providers_exports = {};
54169
- __export(auth_providers_providers_exports, {
54170
- LAZY_CREDENTIAL_LOADER: () => LAZY_CREDENTIAL_LOADER,
54171
- createAuthProvidersProviders: () => createAuthProvidersProviders,
54172
- isAuthProvidersEnabled: () => isAuthProvidersEnabled,
54173
- registerAuthProvidersVault: () => registerAuthProvidersVault
54174
- });
54175
- function createAuthProvidersProviders(options, baseVault) {
54176
- const providers = [];
54177
- providers.push({
54178
- provide: import_auth46.AUTH_PROVIDERS_REGISTRY,
54179
- scope: import_di46.ProviderScope.GLOBAL,
54180
- name: "AuthProvidersRegistry",
54181
- useFactory: () => new import_auth46.AuthProvidersRegistry(options)
54182
- });
54183
- providers.push({
54184
- provide: import_auth46.AUTH_PROVIDERS_VAULT,
54185
- scope: import_di46.ProviderScope.GLOBAL,
54186
- name: "AuthProvidersVault",
54187
- useFactory: (logger) => new import_auth46.AuthProvidersVault(baseVault, options.namespace ?? "authproviders:", logger),
54188
- inject: () => [FrontMcpLogger]
54189
- });
54190
- providers.push({
54191
- provide: CREDENTIAL_CACHE,
54192
- scope: import_di46.ProviderScope.CONTEXT,
54193
- name: "CredentialCache",
54194
- useFactory: () => new import_auth46.CredentialCache(options.maxCredentialsPerSession ?? 100)
54195
- });
54196
- providers.push({
54197
- provide: LAZY_CREDENTIAL_LOADER,
54198
- scope: import_di46.ProviderScope.CONTEXT,
54199
- name: "LazyCredentialLoader",
54200
- useFactory: (logger) => new import_auth46.LazyCredentialLoader(logger),
54201
- inject: () => [FrontMcpLogger]
54202
- });
54203
- providers.push({
54204
- provide: import_auth46.AUTH_PROVIDERS_ACCESSOR,
54205
- scope: import_di46.ProviderScope.CONTEXT,
54206
- name: "AuthProvidersAccessor",
54207
- useFactory: (registry, vault, cache2, loader, ctx, logger) => {
54208
- const user = ctx.authInfo?.user;
54209
- const signedIn = user && !(0, import_auth46.isAnonymousSubject)(user.sub) ? user : void 0;
54210
- const factoryContext = {
54211
- sessionId: sessionScopeIdentity(ctx) ?? `unidentified:${(0, import_utils117.randomUUID)()}`,
54212
- userSub: signedIn?.sub,
54213
- userEmail: signedIn?.email,
54214
- userName: signedIn?.name,
54215
- // appId and toolId are not available in FrontMcpContext,
54216
- // they can be set by the tool flow when calling the accessor
54217
- vault: baseVault
54218
- };
54219
- return new import_auth46.AuthProvidersAccessorImpl(registry, vault, cache2, loader, factoryContext, logger);
54220
- },
54221
- inject: () => [
54222
- import_auth46.AUTH_PROVIDERS_REGISTRY,
54223
- import_auth46.AUTH_PROVIDERS_VAULT,
54224
- CREDENTIAL_CACHE,
54225
- LAZY_CREDENTIAL_LOADER,
54226
- FRONTMCP_CONTEXT,
54227
- FrontMcpLogger
54228
- ]
54229
- });
54230
- return providers;
54231
- }
54232
- function isAuthProvidersEnabled(options) {
54233
- if (options?.enabled === false) {
54234
- return false;
54235
- }
54236
- if (options?.enabled === true) {
54237
- return true;
54238
- }
54239
- return (options?.providers?.length ?? 0) > 0;
54240
- }
54241
- async function registerAuthProvidersVault(providers, options) {
54242
- if (!isAuthProvidersEnabled(options)) return;
54243
- await providers.addDynamicProviders(createAuthProvidersProviders(options, new import_auth46.InMemoryAuthorizationVault()));
54244
- }
54245
- var import_auth46, import_di46, import_utils117, LAZY_CREDENTIAL_LOADER;
54246
- var init_auth_providers_providers = __esm({
54247
- "libs/sdk/src/auth/vault/auth-providers.providers.ts"() {
54248
- "use strict";
54249
- import_auth46 = require("@frontmcp/auth");
54250
- import_di46 = require("@frontmcp/di");
54251
- import_utils117 = require("@frontmcp/utils");
54252
- init_common();
54253
- init_frontmcp_context_provider();
54254
- init_session_scope_identity();
54255
- init_credential_cache();
54256
- LAZY_CREDENTIAL_LOADER = /* @__PURE__ */ Symbol.for("frontmcp:LAZY_CREDENTIAL_LOADER");
54257
- }
54258
- });
54259
-
54260
54143
  // libs/sdk/src/server/security/resolve-allowed-hosts.ts
54261
54144
  function canonicalizeAddress(address) {
54262
54145
  const bare = address.trim().toLowerCase().replace(/^\[|\]$/g, "");
@@ -54493,13 +54376,13 @@ var init_sse_route_stream = __esm({
54493
54376
  });
54494
54377
 
54495
54378
  // libs/sdk/src/http-route/flows/http.route.flow.ts
54496
- var import_auth47, import_lazy_zod101, import_utils118, plan20, httpRouteStateSchema, name20, Stage20, MUTATIONS, RESPONSE_KINDS, HttpRouteFlow;
54379
+ var import_auth45, import_lazy_zod101, import_utils117, plan20, httpRouteStateSchema, name20, Stage20, MUTATIONS, RESPONSE_KINDS, HttpRouteFlow;
54497
54380
  var init_http_route_flow = __esm({
54498
54381
  "libs/sdk/src/http-route/flows/http.route.flow.ts"() {
54499
54382
  "use strict";
54500
- import_auth47 = require("@frontmcp/auth");
54383
+ import_auth45 = require("@frontmcp/auth");
54501
54384
  import_lazy_zod101 = require("@frontmcp/lazy-zod");
54502
- import_utils118 = require("@frontmcp/utils");
54385
+ import_utils117 = require("@frontmcp/utils");
54503
54386
  init_common();
54504
54387
  init_errors();
54505
54388
  init_flow_context_providers();
@@ -54612,7 +54495,7 @@ var init_http_route_flow = __esm({
54612
54495
  }
54613
54496
  /** The person signed in for routes of `auth`: a session for a subject opens `'subject'` routes only. */
54614
54497
  verifyPerson(auth) {
54615
- const cookie = (0, import_utils118.getCookie)(this.httpRequest.headers["cookie"], import_auth47.PEOPLE_SESSION_COOKIE);
54498
+ const cookie = (0, import_utils117.getCookie)(this.httpRequest.headers["cookie"], import_auth45.PEOPLE_SESSION_COOKIE);
54616
54499
  const person = this.scope.httpRouteTable?.people?.verifySession(cookie);
54617
54500
  return person && person.subject !== void 0 === (auth === "subject") ? person : void 0;
54618
54501
  }
@@ -54693,7 +54576,7 @@ function stderrIsTerminal() {
54693
54576
  return typeof process !== "undefined" && process.stderr?.isTTY === true;
54694
54577
  }
54695
54578
  function printQuestionInboxLink(context) {
54696
- const people = context.tryGet(import_auth48.LoopbackTokenAuth);
54579
+ const people = context.tryGet(import_auth46.LoopbackTokenAuth);
54697
54580
  if (!people) throw new ElicitationNotSupportedError("The question inbox needs people auth: set http.auth.people");
54698
54581
  const questions = context.scope.persistentQuestions;
54699
54582
  if (!questions) throw new ElicitationNotSupportedError("The question inbox needs elicitation.persistent");
@@ -54763,7 +54646,7 @@ function questionInboxRoutes(store) {
54763
54646
  ], QuestionAnswerRoute);
54764
54647
  let QuestionInboxPageRoute = class extends HttpRouteContext {
54765
54648
  handle() {
54766
- const nonce = (0, import_utils119.base64urlEncode)((0, import_utils119.randomBytes)(16));
54649
+ const nonce = (0, import_utils118.base64urlEncode)((0, import_utils118.randomBytes)(16));
54767
54650
  return httpRespond.html(inboxPage(nonce), 200, {
54768
54651
  ...NO_STORE_HEADERS,
54769
54652
  "Referrer-Policy": "no-referrer",
@@ -54819,13 +54702,13 @@ function render(view) {
54819
54702
  new EventSource('${QUESTIONS_PATH}/events').onmessage = (event) => render(JSON.parse(event.data));
54820
54703
  </script></body></html>`;
54821
54704
  }
54822
- var import_auth48, import_lazy_zod102, import_utils119, QUESTION_INBOX_PATH, QUESTIONS_PATH, PEOPLE_LOGIN_PATH, answerBodySchema;
54705
+ var import_auth46, import_lazy_zod102, import_utils118, QUESTION_INBOX_PATH, QUESTIONS_PATH, PEOPLE_LOGIN_PATH, answerBodySchema;
54823
54706
  var init_question_inbox_routes = __esm({
54824
54707
  "libs/sdk/src/elicitation/questions/question-inbox.routes.ts"() {
54825
54708
  "use strict";
54826
- import_auth48 = require("@frontmcp/auth");
54709
+ import_auth46 = require("@frontmcp/auth");
54827
54710
  import_lazy_zod102 = require("@frontmcp/lazy-zod");
54828
- import_utils119 = require("@frontmcp/utils");
54711
+ import_utils118 = require("@frontmcp/utils");
54829
54712
  init_common();
54830
54713
  init_errors();
54831
54714
  init_question_subject();
@@ -54850,7 +54733,7 @@ function isReadyzEnabled(config) {
54850
54733
  if (config.readyz?.enabled !== void 0) {
54851
54734
  return config.readyz.enabled;
54852
54735
  }
54853
- const ctx = (0, import_utils120.getRuntimeContext)();
54736
+ const ctx = (0, import_utils119.getRuntimeContext)();
54854
54737
  return ctx.runtime !== "edge" && ctx.deployment !== "serverless";
54855
54738
  }
54856
54739
  function registerHealthRoutes(server, healthService, config) {
@@ -54873,11 +54756,11 @@ function registerHealthRoutes(server, healthService, config) {
54873
54756
  });
54874
54757
  }
54875
54758
  }
54876
- var import_utils120;
54759
+ var import_utils119;
54877
54760
  var init_health_routes = __esm({
54878
54761
  "libs/sdk/src/health/health.routes.ts"() {
54879
54762
  "use strict";
54880
- import_utils120 = require("@frontmcp/utils");
54763
+ import_utils119 = require("@frontmcp/utils");
54881
54764
  }
54882
54765
  });
54883
54766
 
@@ -55027,11 +54910,11 @@ function refusal3(result) {
55027
54910
  function page(title, body, head = "") {
55028
54911
  return `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title>${head}</head><body>${body}</body></html>`;
55029
54912
  }
55030
- var import_auth49, PEOPLE_CODE_PATH, PEOPLE_LOGIN_PATH2, CODE, SAME_SITE_PATH, PAGE_HEADERS, PeopleCodeRoute, PeopleLoginPageRoute, PeopleLoginRoute, PEOPLE_SIGN_IN_ROUTES;
54913
+ var import_auth47, PEOPLE_CODE_PATH, PEOPLE_LOGIN_PATH2, CODE, SAME_SITE_PATH, PAGE_HEADERS, PeopleCodeRoute, PeopleLoginPageRoute, PeopleLoginRoute, PEOPLE_SIGN_IN_ROUTES;
55031
54914
  var init_people_sign_in_routes = __esm({
55032
54915
  "libs/sdk/src/http-route/people-sign-in.routes.ts"() {
55033
54916
  "use strict";
55034
- import_auth49 = require("@frontmcp/auth");
54917
+ import_auth47 = require("@frontmcp/auth");
55035
54918
  init_form_body_utils();
55036
54919
  init_common();
55037
54920
  init_errors();
@@ -55042,7 +54925,7 @@ var init_people_sign_in_routes = __esm({
55042
54925
  PAGE_HEADERS = { ...NO_STORE_HEADERS, "Referrer-Policy": "no-referrer" };
55043
54926
  PeopleCodeRoute = class extends HttpRouteContext {
55044
54927
  handle() {
55045
- const issued = this.get(import_auth49.LoopbackTokenAuth).exchangeToken(bearerToken(this.request), clientOf(this));
54928
+ const issued = this.get(import_auth47.LoopbackTokenAuth).exchangeToken(bearerToken(this.request), clientOf(this));
55046
54929
  if (!issued.ok) throw refusal3(issued);
55047
54930
  const { code, expiresAt } = issued;
55048
54931
  return httpRespond.json(
@@ -55065,7 +54948,7 @@ var init_people_sign_in_routes = __esm({
55065
54948
  contentType: "text/plain; charset=utf-8"
55066
54949
  };
55067
54950
  }
55068
- const form = `<form method="post" action="${PEOPLE_LOGIN_PATH2}"><input type="hidden" name="code" value="${code}"><input type="hidden" name="next" value="${(0, import_auth49.escapeHtml)(nextPath(this.request.query["next"]))}"><button type="submit">Sign in</button></form>`;
54951
+ const form = `<form method="post" action="${PEOPLE_LOGIN_PATH2}"><input type="hidden" name="code" value="${code}"><input type="hidden" name="next" value="${(0, import_auth47.escapeHtml)(nextPath(this.request.query["next"]))}"><button type="submit">Sign in</button></form>`;
55069
54952
  return httpRespond.html(page("Sign in", form), 200, PAGE_HEADERS);
55070
54953
  }
55071
54954
  };
@@ -55075,11 +54958,11 @@ var init_people_sign_in_routes = __esm({
55075
54958
  PeopleLoginRoute = class extends HttpRouteContext {
55076
54959
  handle() {
55077
54960
  const fields = parseFormBody(this.request.body);
55078
- const auth = this.get(import_auth49.LoopbackTokenAuth);
54961
+ const auth = this.get(import_auth47.LoopbackTokenAuth);
55079
54962
  const session = auth.exchangeCode(first2(fields["code"]), clientOf(this));
55080
54963
  if (!session.ok) throw refusal3(session);
55081
- const next = (0, import_auth49.escapeHtml)(nextPath(fields["next"]));
55082
- const cookie = (0, import_auth49.peopleSessionCookie)(session.cookieValue, {
54964
+ const next = (0, import_auth47.escapeHtml)(nextPath(fields["next"]));
54965
+ const cookie = (0, import_auth47.peopleSessionCookie)(session.cookieValue, {
55083
54966
  path: auth.options.cookiePath,
55084
54967
  secure: getRequestBaseUrl(this.request).startsWith("https:"),
55085
54968
  maxAgeMs: auth.options.sessionTtlMs
@@ -55117,19 +55000,19 @@ function printSignInToken(token) {
55117
55000
  function peopleAuthFor(server, option, scopeProviders) {
55118
55001
  let auth = peopleAuthByServer.get(server);
55119
55002
  if (!auth) {
55120
- const parsed = (0, import_auth50.peopleAuthOptionsSchema)().safeParse(option);
55003
+ const parsed = (0, import_auth48.peopleAuthOptionsSchema)().safeParse(option);
55121
55004
  if (!parsed.success) throw new InvalidPeopleAuthOptionsError(parsed.error.issues.map((issue) => issue.message));
55122
- auth = new import_auth50.LoopbackTokenAuth(parsed.data);
55005
+ auth = new import_auth48.LoopbackTokenAuth(parsed.data);
55123
55006
  peopleAuthByServer.set(server, auth);
55124
55007
  const token = auth.takeToken();
55125
55008
  if (token) printSignInToken(token);
55126
55009
  }
55127
55010
  scopeProviders.injectProvider({
55128
- provide: import_auth50.LoopbackTokenAuth,
55011
+ provide: import_auth48.LoopbackTokenAuth,
55129
55012
  value: auth,
55130
55013
  metadata: {
55131
55014
  name: "LoopbackTokenAuth",
55132
- scope: import_di47.ProviderScope.GLOBAL,
55015
+ scope: import_di46.ProviderScope.GLOBAL,
55133
55016
  description: "People sign-in for @HttpRoute pages"
55134
55017
  }
55135
55018
  });
@@ -55201,12 +55084,12 @@ function attachHttpRoutes(scope, server) {
55201
55084
  scope.httpRouteTable = table;
55202
55085
  scope.onDispose(() => table.closeStreams());
55203
55086
  }
55204
- var import_auth50, import_di47, HttpRouteTable, peopleAuthByServer;
55087
+ var import_auth48, import_di46, HttpRouteTable, peopleAuthByServer;
55205
55088
  var init_http_route_table = __esm({
55206
55089
  "libs/sdk/src/http-route/http-route.table.ts"() {
55207
55090
  "use strict";
55208
- import_auth50 = require("@frontmcp/auth");
55209
- import_di47 = require("@frontmcp/di");
55091
+ import_auth48 = require("@frontmcp/auth");
55092
+ import_di46 = require("@frontmcp/di");
55210
55093
  init_common();
55211
55094
  init_question_inbox_routes();
55212
55095
  init_errors();
@@ -55249,7 +55132,7 @@ var init_http_route_table = __esm({
55249
55132
  // libs/sdk/src/auth/flows/session.verify.flow.ts
55250
55133
  function constantTimeEquals(a, b) {
55251
55134
  const encoder10 = new TextEncoder();
55252
- return (0, import_utils121.timingSafeEqual)((0, import_utils121.sha256)(encoder10.encode(a)), (0, import_utils121.sha256)(encoder10.encode(b)));
55135
+ return (0, import_utils120.timingSafeEqual)((0, import_utils120.sha256)(encoder10.encode(a)), (0, import_utils120.sha256)(encoder10.encode(b)));
55253
55136
  }
55254
55137
  function quoteHeaderParam(value) {
55255
55138
  return value.replace(/[^\x20-\x21\x23-\x7e]/g, "");
@@ -55263,15 +55146,15 @@ function buildStaticChallenge(options, description) {
55263
55146
  }
55264
55147
  return parts.join(", ");
55265
55148
  }
55266
- var import_reflect_metadata21, import_auth51, import_lazy_zod103, import_utils121, inputSchema20, stateSchema20, UnauthorizedSchema, AuthorizedSchema, ForbiddenSchema, sessionVerifyOutputSchema, plan21, name21, Stage21, warnedUnpinnedAudience, SessionVerifyFlow;
55149
+ var import_reflect_metadata21, import_auth49, import_lazy_zod103, import_utils120, inputSchema20, stateSchema20, UnauthorizedSchema, AuthorizedSchema, ForbiddenSchema, sessionVerifyOutputSchema, plan21, name21, Stage21, warnedUnpinnedAudience, SessionVerifyFlow;
55267
55150
  var init_session_verify_flow = __esm({
55268
55151
  "libs/sdk/src/auth/flows/session.verify.flow.ts"() {
55269
55152
  "use strict";
55270
55153
  init_common();
55271
55154
  import_reflect_metadata21 = require("reflect-metadata");
55272
- import_auth51 = require("@frontmcp/auth");
55155
+ import_auth49 = require("@frontmcp/auth");
55273
55156
  import_lazy_zod103 = require("@frontmcp/lazy-zod");
55274
- import_utils121 = require("@frontmcp/utils");
55157
+ import_utils120 = require("@frontmcp/utils");
55275
55158
  init_notification_service();
55276
55159
  init_skill_mode_utils();
55277
55160
  init_session_id_utils();
@@ -55345,11 +55228,11 @@ var init_session_verify_flow = __esm({
55345
55228
  if (this.rawInput.sessionless) {
55346
55229
  this.respond({
55347
55230
  kind: "authorized",
55348
- authorization: { token: "", user: (0, import_auth51.anonymousCallerClaims)(options, (0, import_utils121.randomUUID)()) }
55231
+ authorization: { token: "", user: (0, import_auth49.anonymousCallerClaims)(options, (0, import_utils120.randomUUID)()) }
55349
55232
  });
55350
55233
  return;
55351
55234
  }
55352
- const machineId = (0, import_utils121.getMachineId)();
55235
+ const machineId = (0, import_utils120.getMachineId)();
55353
55236
  const authSignature = subject ? `${authMode}:${subject}` : authMode;
55354
55237
  if (sessionIdHeader) {
55355
55238
  const body = this.rawInput.request.body;
@@ -55358,7 +55241,7 @@ var init_session_verify_flow = __esm({
55358
55241
  const existingPayload = decrypted && isInitialize2 && decrypted.nodeId !== machineId ? void 0 : decrypted;
55359
55242
  if (existingPayload) {
55360
55243
  const anonId = existingPayload.uuid ?? `${existingPayload.iat * 1e3}`;
55361
- const user2 = (0, import_auth51.anonymousCallerClaims)(options, anonId);
55244
+ const user2 = (0, import_auth49.anonymousCallerClaims)(options, anonId);
55362
55245
  this.respond({
55363
55246
  kind: "authorized",
55364
55247
  authorization: {
@@ -55372,8 +55255,8 @@ var init_session_verify_flow = __esm({
55372
55255
  this.logger.verbose("createAnonymousSession: ignoring unrecognized client session id; minting a fresh one");
55373
55256
  }
55374
55257
  const now = Date.now();
55375
- const uuid = (0, import_utils121.randomUUID)();
55376
- const user = (0, import_auth51.anonymousCallerClaims)(options, uuid);
55258
+ const uuid = (0, import_utils120.randomUUID)();
55259
+ const user = (0, import_auth49.anonymousCallerClaims)(options, uuid);
55377
55260
  const platformDetectionConfig = this.scope.metadata.transport?.platformDetection;
55378
55261
  const platformType = detectPlatformFromUserAgent(this.state.userAgent, platformDetectionConfig);
55379
55262
  const payload = {
@@ -55386,7 +55269,7 @@ var init_session_verify_flow = __esm({
55386
55269
  ...platformType !== "unknown" && { platformType },
55387
55270
  ...detectSkillsOnlyMode(this.rawInput.request.query) && { skillsOnlyMode: true }
55388
55271
  };
55389
- const sessionId = (0, import_auth51.encryptJson)(payload);
55272
+ const sessionId = (0, import_auth49.encryptJson)(payload);
55390
55273
  this.respond({
55391
55274
  kind: "authorized",
55392
55275
  authorization: {
@@ -55407,11 +55290,11 @@ var init_session_verify_flow = __esm({
55407
55290
  const sessionIdQuery = request.query["sessionId"];
55408
55291
  const sessionIdHeader = sessionIdRawHeader ?? sessionIdQuery ?? void 0;
55409
55292
  const sessionProtocol = httpTransportHeader ? "http" : sessionIdRawHeader ? "streamable-http" : sessionIdQuery ? "sse" : void 0;
55410
- const token = (0, import_auth51.extractBearerToken)(authorizationHeader);
55293
+ const token = (0, import_auth49.extractBearerToken)(authorizationHeader);
55411
55294
  const userAgent = request.headers?.["user-agent"] ?? void 0;
55412
55295
  const prmMetadataPath = `/.well-known/oauth-protected-resource${entryPath}${routeBase}`;
55413
55296
  const prmUrl = `${getRequestBaseUrl(request)}${prmMetadataPath}`;
55414
- const prmMetadataHeader = (0, import_auth51.buildUnauthorizedHeader)(prmUrl);
55297
+ const prmMetadataHeader = (0, import_auth49.buildUnauthorizedHeader)(prmUrl);
55415
55298
  this.logger.verbose("parseInput", {
55416
55299
  hasAuthHeader: !!authorizationHeader,
55417
55300
  hasToken: !!token,
@@ -55460,7 +55343,7 @@ var init_session_verify_flow = __esm({
55460
55343
  authMode: "static",
55461
55344
  issuer: "static",
55462
55345
  scopes: options.scopes,
55463
- subject: `static:${(0, import_utils121.sha256Hex)(matched).slice(0, 12)}`,
55346
+ subject: `static:${(0, import_utils120.sha256Hex)(matched).slice(0, 12)}`,
55464
55347
  sessionIdHeader: this.state.sessionIdHeader
55465
55348
  });
55466
55349
  }
@@ -55484,7 +55367,7 @@ var init_session_verify_flow = __esm({
55484
55367
  if (!authOptions || !(0, import_auth13.isPublicMode)(authOptions)) {
55485
55368
  return;
55486
55369
  }
55487
- if (this.state.token && (0, import_auth51.isJwt)(this.state.token)) {
55370
+ if (this.state.token && (0, import_auth49.isJwt)(this.state.token)) {
55488
55371
  return;
55489
55372
  }
55490
55373
  if (this.state.token) {
@@ -55519,7 +55402,7 @@ var init_session_verify_flow = __esm({
55519
55402
  });
55520
55403
  }
55521
55404
  async verifyIfJwt() {
55522
- const jwks = this.get(import_auth51.JwksService);
55405
+ const jwks = this.get(import_auth49.JwksService);
55523
55406
  const token = this.state.token;
55524
55407
  if (!token) {
55525
55408
  this.logger.warn("verifyIfJwt: missing or empty bearer token, returning 401");
@@ -55529,11 +55412,11 @@ var init_session_verify_flow = __esm({
55529
55412
  });
55530
55413
  return;
55531
55414
  }
55532
- if (!(0, import_auth51.isJwt)(token)) {
55415
+ if (!(0, import_auth49.isJwt)(token)) {
55533
55416
  this.logger.warn("verifyIfJwt: token is not a JWT, returning 401");
55534
55417
  this.respond({
55535
55418
  kind: "unauthorized",
55536
- prmMetadataHeader: (0, import_auth51.buildInvalidTokenHeader)(this.state.required.prmUrl, "Token is not a valid JWT")
55419
+ prmMetadataHeader: (0, import_auth49.buildInvalidTokenHeader)(this.state.required.prmUrl, "Token is not a valid JWT")
55537
55420
  });
55538
55421
  return;
55539
55422
  }
@@ -55581,8 +55464,8 @@ var init_session_verify_flow = __esm({
55581
55464
  "transparent audience validation is deriving the expected audience from the request Host: set auth.expectedAudience or FRONTMCP_PUBLIC_URL to bind tokens to a fixed resource. X-Forwarded-Host is ignored unless FRONTMCP_TRUST_PROXY is enabled."
55582
55465
  );
55583
55466
  }
55584
- const expectedAudiences = configuredAudience ? Array.isArray(configuredAudience) ? configuredAudience : [configuredAudience] : (0, import_auth51.deriveExpectedAudience)(this.state.required.baseUrl);
55585
- const audResult = (0, import_auth51.validateAudience)(result.payload?.["aud"], {
55467
+ const expectedAudiences = configuredAudience ? Array.isArray(configuredAudience) ? configuredAudience : [configuredAudience] : (0, import_auth49.deriveExpectedAudience)(this.state.required.baseUrl);
55468
+ const audResult = (0, import_auth49.validateAudience)(result.payload?.["aud"], {
55586
55469
  expectedAudiences,
55587
55470
  // By default accept tokens with no `aud` claim: many IdPs omit it, and
55588
55471
  // rejecting them here would break existing transparent deployments.
@@ -55596,7 +55479,7 @@ var init_session_verify_flow = __esm({
55596
55479
  this.logger.warn("verifyIfJwt: audience validation failed", { error: audResult.error });
55597
55480
  this.respond({
55598
55481
  kind: "unauthorized",
55599
- prmMetadataHeader: (0, import_auth51.buildInvalidTokenHeader)(
55482
+ prmMetadataHeader: (0, import_auth49.buildInvalidTokenHeader)(
55600
55483
  this.state.required.prmUrl,
55601
55484
  audResult.error ?? "Token audience is not valid for this resource"
55602
55485
  )
@@ -55606,7 +55489,7 @@ var init_session_verify_flow = __esm({
55606
55489
  }
55607
55490
  const requiredScopes = authOptions?.["requiredScopes"];
55608
55491
  if (requiredScopes && requiredScopes.length > 0) {
55609
- const tokenScopes = (0, import_auth51.scopesFromClaims)(result.payload);
55492
+ const tokenScopes = (0, import_auth49.scopesFromClaims)(result.payload);
55610
55493
  const hasAll = requiredScopes.every((s) => tokenScopes.includes(s));
55611
55494
  if (!hasAll) {
55612
55495
  this.logger.warn("verifyIfJwt: insufficient scopes", {
@@ -55615,7 +55498,7 @@ var init_session_verify_flow = __esm({
55615
55498
  });
55616
55499
  this.respond({
55617
55500
  kind: "forbidden",
55618
- prmMetadataHeader: (0, import_auth51.buildInsufficientScopeHeader)(this.state.required.prmUrl, requiredScopes)
55501
+ prmMetadataHeader: (0, import_auth49.buildInsufficientScopeHeader)(this.state.required.prmUrl, requiredScopes)
55619
55502
  });
55620
55503
  return;
55621
55504
  }
@@ -55625,19 +55508,19 @@ var init_session_verify_flow = __esm({
55625
55508
  this.logger.warn("verifyIfJwt: JWT verification failed", { error: result.error });
55626
55509
  this.respond({
55627
55510
  kind: "unauthorized",
55628
- prmMetadataHeader: (0, import_auth51.buildInvalidTokenHeader)(
55511
+ prmMetadataHeader: (0, import_auth49.buildInvalidTokenHeader)(
55629
55512
  this.state.required.prmUrl,
55630
55513
  result.error ?? "Token verification failed"
55631
55514
  )
55632
55515
  });
55633
55516
  }
55634
55517
  async deriveUser() {
55635
- const user = (0, import_auth51.deriveTypedUser)(this.state.required.jwtPayload ?? {});
55518
+ const user = (0, import_auth49.deriveTypedUser)(this.state.required.jwtPayload ?? {});
55636
55519
  if (!user.sub) {
55637
55520
  this.logger.warn("deriveUser: verified token has no sub, client_id or azp claim, returning 401");
55638
55521
  this.respond({
55639
55522
  kind: "unauthorized",
55640
- prmMetadataHeader: (0, import_auth51.buildInvalidTokenHeader)(
55523
+ prmMetadataHeader: (0, import_auth49.buildInvalidTokenHeader)(
55641
55524
  this.state.required.prmUrl,
55642
55525
  "Token has no subject: the sub, client_id and azp claims are all missing"
55643
55526
  )
@@ -55749,8 +55632,8 @@ var init_ha_constants = __esm({
55749
55632
 
55750
55633
  // libs/sdk/src/ha/ha-headers.ts
55751
55634
  function machineIdHeader() {
55752
- if ((0, import_utils122.getRuntimeContext)().deployment !== "distributed") return void 0;
55753
- return [DEFAULT_FRONTMCP_MACHINE_ID_HEADER, (0, import_utils122.getMachineId)()];
55635
+ if ((0, import_utils121.getRuntimeContext)().deployment !== "distributed") return void 0;
55636
+ return [DEFAULT_FRONTMCP_MACHINE_ID_HEADER, (0, import_utils121.getMachineId)()];
55754
55637
  }
55755
55638
  function applyMachineIdHeader(response) {
55756
55639
  const header2 = machineIdHeader();
@@ -55759,25 +55642,25 @@ function applyMachineIdHeader(response) {
55759
55642
  return true;
55760
55643
  }
55761
55644
  function affinityCookieOptions() {
55762
- const name49 = (0, import_utils122.getEnv)("FRONTMCP_AFFINITY_COOKIE")?.trim() || DEFAULT_FRONTMCP_NODE_COOKIE;
55763
- const domain = (0, import_utils122.getEnv)("FRONTMCP_AFFINITY_COOKIE_DOMAIN")?.trim() || void 0;
55764
- const rawSameSite = (0, import_utils122.getEnv)("FRONTMCP_AFFINITY_COOKIE_SAMESITE")?.trim().toLowerCase();
55645
+ const name49 = (0, import_utils121.getEnv)("FRONTMCP_AFFINITY_COOKIE")?.trim() || DEFAULT_FRONTMCP_NODE_COOKIE;
55646
+ const domain = (0, import_utils121.getEnv)("FRONTMCP_AFFINITY_COOKIE_DOMAIN")?.trim() || void 0;
55647
+ const rawSameSite = (0, import_utils121.getEnv)("FRONTMCP_AFFINITY_COOKIE_SAMESITE")?.trim().toLowerCase();
55765
55648
  const sameSite = rawSameSite === "strict" ? "Strict" : rawSameSite === "lax" ? "Lax" : rawSameSite === "none" ? "None" : void 0;
55766
55649
  return { name: name49, ...domain ? { domain } : {}, ...sameSite ? { sameSite } : {} };
55767
55650
  }
55768
55651
  function applyNodeAffinity(response, request) {
55769
55652
  if (!applyMachineIdHeader(response)) return;
55770
- const cookie = (0, import_utils122.buildSetCookie)({ ...affinityCookieOptions(), value: (0, import_utils122.getMachineId)() }, request);
55653
+ const cookie = (0, import_utils121.buildSetCookie)({ ...affinityCookieOptions(), value: (0, import_utils121.getMachineId)() }, request);
55771
55654
  if (!cookie) return;
55772
55655
  const existing = response.getHeader("Set-Cookie");
55773
55656
  const existingArr = Array.isArray(existing) ? existing : existing ? [String(existing)] : [];
55774
55657
  response.setHeader("Set-Cookie", [...existingArr, cookie]);
55775
55658
  }
55776
- var import_utils122;
55659
+ var import_utils121;
55777
55660
  var init_ha_headers = __esm({
55778
55661
  "libs/sdk/src/ha/ha-headers.ts"() {
55779
55662
  "use strict";
55780
- import_utils122 = require("@frontmcp/utils");
55663
+ import_utils121 = require("@frontmcp/utils");
55781
55664
  init_ha_constants();
55782
55665
  }
55783
55666
  });
@@ -55839,11 +55722,11 @@ __export(persistent_session_owner_exports, {
55839
55722
  });
55840
55723
  function persistentSessionCallerKey(authorization) {
55841
55724
  const sub = authorization?.user?.sub;
55842
- if (!(0, import_auth52.isAnonymousSubject)(sub)) {
55725
+ if (!(0, import_auth50.isAnonymousSubject)(sub)) {
55843
55726
  const iss = authorization?.user?.iss;
55844
- return `sub:${(0, import_utils123.sha256Hex)(JSON.stringify([typeof iss === "string" ? iss : "", sub]))}`;
55727
+ return `sub:${(0, import_utils122.sha256Hex)(JSON.stringify([typeof iss === "string" ? iss : "", sub]))}`;
55845
55728
  }
55846
- if (authorization?.token) return `token:${(0, import_utils123.sha256Hex)(authorization.token)}`;
55729
+ if (authorization?.token) return `token:${(0, import_utils122.sha256Hex)(authorization.token)}`;
55847
55730
  return null;
55848
55731
  }
55849
55732
  function claimPersistentSession(session, callerKey, store) {
@@ -55856,12 +55739,12 @@ function claimPersistentSession(session, callerKey, store) {
55856
55739
  }
55857
55740
  return owners.get(session) === callerKey ? "owner" : "refused";
55858
55741
  }
55859
- var import_auth52, import_utils123, owners;
55742
+ var import_auth50, import_utils122, owners;
55860
55743
  var init_persistent_session_owner = __esm({
55861
55744
  "libs/sdk/src/transport/persistent-session-owner.ts"() {
55862
55745
  "use strict";
55863
- import_auth52 = require("@frontmcp/auth");
55864
- import_utils123 = require("@frontmcp/utils");
55746
+ import_auth50 = require("@frontmcp/auth");
55747
+ import_utils122 = require("@frontmcp/utils");
55865
55748
  owners = /* @__PURE__ */ new WeakMap();
55866
55749
  }
55867
55750
  });
@@ -55924,7 +55807,7 @@ async function runWebStandardMcp(scope, request, options) {
55924
55807
  return options.persistent.transport.handleRequest(request, { authInfo: options.authInfo });
55925
55808
  }
55926
55809
  if (!STATELESS_METHODS.includes(request.method)) return methodNotAllowed();
55927
- const sessionId = `web:${(0, import_utils124.randomUUID)()}`;
55810
+ const sessionId = `web:${(0, import_utils123.randomUUID)()}`;
55928
55811
  const accept = request.headers.get("accept") ?? "";
55929
55812
  const wantsStream = options.sse && accept.includes("text/event-stream");
55930
55813
  const { mcpServer, transport } = await wireServer(scope, options.serverOptions, sessionId, void 0, !wantsStream);
@@ -55945,12 +55828,12 @@ function methodNotAllowed() {
55945
55828
  const headers = { allow: STATELESS_METHODS.join(", ") };
55946
55829
  return Response.json({ jsonrpc: "2.0", error, id: null }, { status: 405, headers });
55947
55830
  }
55948
- var import_protocol51, import_utils124, STATELESS_METHODS;
55831
+ var import_protocol51, import_utils123, STATELESS_METHODS;
55949
55832
  var init_web_standard_mcp = __esm({
55950
55833
  "libs/sdk/src/transport/web-standard-mcp.ts"() {
55951
55834
  "use strict";
55952
55835
  import_protocol51 = require("@frontmcp/protocol");
55953
- import_utils124 = require("@frontmcp/utils");
55836
+ import_utils123 = require("@frontmcp/utils");
55954
55837
  init_skill_instructions_helper();
55955
55838
  init_body_limit();
55956
55839
  init_build_scoped_server_options();
@@ -55960,14 +55843,14 @@ var init_web_standard_mcp = __esm({
55960
55843
  });
55961
55844
 
55962
55845
  // libs/sdk/src/scope/flows/http.request.flow.ts
55963
- var import_auth53, import_guard8, import_lazy_zod104, import_utils125, plan22, httpRequestStateSchema, name22, Stage22, HttpRequestFlow;
55846
+ var import_auth51, import_guard8, import_lazy_zod104, import_utils124, plan22, httpRequestStateSchema, name22, Stage22, HttpRequestFlow;
55964
55847
  var init_http_request_flow = __esm({
55965
55848
  "libs/sdk/src/scope/flows/http.request.flow.ts"() {
55966
55849
  "use strict";
55967
- import_auth53 = require("@frontmcp/auth");
55850
+ import_auth51 = require("@frontmcp/auth");
55968
55851
  import_guard8 = require("@frontmcp/guard");
55969
55852
  import_lazy_zod104 = require("@frontmcp/lazy-zod");
55970
- import_utils125 = require("@frontmcp/utils");
55853
+ import_utils124 = require("@frontmcp/utils");
55971
55854
  init_session_verify_flow();
55972
55855
  init_common();
55973
55856
  init_schema7();
@@ -56053,7 +55936,7 @@ var init_http_request_flow = __esm({
56053
55936
  const { request } = this.rawInput;
56054
55937
  this.requestStartTime = Date.now();
56055
55938
  const ctx = this.tryGetContext();
56056
- this.requestId = ctx?.requestId ?? `req-${(0, import_utils125.randomUUID)()}`;
55939
+ this.requestId = ctx?.requestId ?? `req-${(0, import_utils124.randomUUID)()}`;
56057
55940
  const headers = request.headers ?? {};
56058
55941
  const body = request.body;
56059
55942
  const userAgent = headers["user-agent"];
@@ -56221,13 +56104,13 @@ var init_http_request_flow = __esm({
56221
56104
  const tokenStore = auth.orchestratedTokenStore;
56222
56105
  let providers;
56223
56106
  try {
56224
- const authorizationId = (0, import_auth53.deriveAuthorizationId)(token);
56107
+ const authorizationId = (0, import_auth51.deriveAuthorizationId)(token);
56225
56108
  const providerIds = await tokenStore.getProviderIds(authorizationId);
56226
56109
  providers = Object.fromEntries(providerIds.map((id) => [id, { id }]));
56227
56110
  } catch (err) {
56228
56111
  this.logger.warn(`[${this.requestId}] failed to load orchestrated providers: ${String(err)}`);
56229
56112
  }
56230
- const authorization = import_auth53.OrchestratedAuthorization.create({
56113
+ const authorization = import_auth51.OrchestratedAuthorization.create({
56231
56114
  token,
56232
56115
  user: { sub: user.sub ?? "unknown", name: user.name, email: user.email, picture: user.picture },
56233
56116
  expiresAt: user.exp ? user.exp * 1e3 : void 0,
@@ -56236,7 +56119,7 @@ var init_http_request_flow = __esm({
56236
56119
  onTokenRefresh: auth.providerTokenRefresher?.(),
56237
56120
  providers
56238
56121
  });
56239
- ctx.setContextToken(import_auth53.ORCHESTRATED_AUTH_ACCESSOR, new import_auth53.OrchestratedAuthAccessorAdapter(authorization));
56122
+ ctx.setContextToken(import_auth51.ORCHESTRATED_AUTH_ACCESSOR, new import_auth51.OrchestratedAuthAccessorAdapter(authorization));
56240
56123
  }
56241
56124
  /**
56242
56125
  * Whether this request is served under MCP protocol 2026-07-28.
@@ -56847,7 +56730,7 @@ async function createSessionStore(options, logger) {
56847
56730
  return createRedisSessionStore(options, logger);
56848
56731
  }
56849
56732
  async function createRedisSessionStore(options, logger) {
56850
- return new import_auth54.RedisSessionStore(
56733
+ return new import_auth52.RedisSessionStore(
56851
56734
  {
56852
56735
  host: options.host,
56853
56736
  port: options.port,
@@ -56861,7 +56744,7 @@ async function createRedisSessionStore(options, logger) {
56861
56744
  );
56862
56745
  }
56863
56746
  async function createVercelKvSessionStore(options, logger) {
56864
- const store = new import_auth54.VercelKvSessionStore(
56747
+ const store = new import_auth52.VercelKvSessionStore(
56865
56748
  {
56866
56749
  url: options.url,
56867
56750
  token: options.token,
@@ -56878,32 +56761,32 @@ function createSqliteSessionStore(options, logger) {
56878
56761
  logger?.info("[SessionStoreFactory] Creating SQLite session store", { path: options.path });
56879
56762
  return new SqliteSessionStore(options);
56880
56763
  }
56881
- var import_auth54, import_utils126;
56764
+ var import_auth52, import_utils125;
56882
56765
  var init_session_store_factory = __esm({
56883
56766
  "libs/sdk/src/auth/session/session-store.factory.ts"() {
56884
56767
  "use strict";
56885
- import_auth54 = require("@frontmcp/auth");
56886
- import_utils126 = require("@frontmcp/utils");
56768
+ import_auth52 = require("@frontmcp/auth");
56769
+ import_utils125 = require("@frontmcp/utils");
56887
56770
  init_common();
56888
56771
  }
56889
56772
  });
56890
56773
 
56891
56774
  // libs/sdk/src/transport/transport.error.ts
56892
- var import_utils127, JSON_RPC2, rpcError, rpcRequest;
56775
+ var import_utils126, JSON_RPC2, rpcError, rpcRequest;
56893
56776
  var init_transport_error = __esm({
56894
56777
  "libs/sdk/src/transport/transport.error.ts"() {
56895
56778
  "use strict";
56896
- import_utils127 = require("@frontmcp/utils");
56779
+ import_utils126 = require("@frontmcp/utils");
56897
56780
  JSON_RPC2 = "2.0";
56898
56781
  rpcError = (message, requestId) => ({
56899
56782
  jsonrpc: JSON_RPC2,
56900
56783
  error: { code: -32e3, message },
56901
- id: requestId ?? (0, import_utils127.randomUUID)()
56784
+ id: requestId ?? (0, import_utils126.randomUUID)()
56902
56785
  // change it to request id + random
56903
56786
  });
56904
56787
  rpcRequest = (requestId, method, params) => ({
56905
56788
  jsonrpc: JSON_RPC2,
56906
- id: requestId ?? (0, import_utils127.randomUUID)(),
56789
+ id: requestId ?? (0, import_utils126.randomUUID)(),
56907
56790
  method,
56908
56791
  ...params !== void 0 && { params }
56909
56792
  });
@@ -58038,7 +57921,7 @@ async function* streamMessageResponse(options, sink, requestId, runInContext) {
58038
57921
  }
58039
57922
  function isAnonymousCaller(auth) {
58040
57923
  if (!auth) return true;
58041
- if (!(0, import_auth55.isAnonymousSubject)(auth.user?.sub)) return false;
57924
+ if (!(0, import_auth53.isAnonymousSubject)(auth.user?.sub)) return false;
58042
57925
  return !auth.token || auth.session?.payload?.isPublic === true;
58043
57926
  }
58044
57927
  function errorResponse(status, error, id) {
@@ -58056,14 +57939,14 @@ function toClientInfo(value) {
58056
57939
  const { name: name49, version } = value;
58057
57940
  return typeof name49 === "string" && typeof version === "string" ? { name: name49, version } : void 0;
58058
57941
  }
58059
- var import_auth55, import_lazy_zod107, import_protocol54, import_utils128, plan24, MAX_RESOURCE_SUBSCRIPTIONS, subscriptionParamsSchema, requestIdSchema, stateSchema21, name24, Stage24, encoder6, TRACE_META_KEYS, HandleMcp20260728Flow;
57942
+ var import_auth53, import_lazy_zod107, import_protocol54, import_utils127, plan24, MAX_RESOURCE_SUBSCRIPTIONS, subscriptionParamsSchema, requestIdSchema, stateSchema21, name24, Stage24, encoder6, TRACE_META_KEYS, HandleMcp20260728Flow;
58060
57943
  var init_handle_mcp_20260728_flow = __esm({
58061
57944
  "libs/sdk/src/transport/flows/handle.mcp-20260728.flow.ts"() {
58062
57945
  "use strict";
58063
- import_auth55 = require("@frontmcp/auth");
57946
+ import_auth53 = require("@frontmcp/auth");
58064
57947
  import_lazy_zod107 = require("@frontmcp/lazy-zod");
58065
57948
  import_protocol54 = require("@frontmcp/protocol");
58066
- import_utils128 = require("@frontmcp/utils");
57949
+ import_utils127 = require("@frontmcp/utils");
58067
57950
  init_common();
58068
57951
  init_tool_lookup_utils();
58069
57952
  init_context();
@@ -58162,7 +58045,7 @@ var init_handle_mcp_20260728_flow = __esm({
58162
58045
  if (!context) return (fn) => fn();
58163
58046
  const storage = this.scope.providers.get(FrontMcpContextStorage);
58164
58047
  return async (fn) => {
58165
- await (0, import_utils128.runRequestExclusive)(() => storage.runWithContext(context, fn));
58048
+ await (0, import_utils127.runRequestExclusive)(() => storage.runWithContext(context, fn));
58166
58049
  };
58167
58050
  }
58168
58051
  /**
@@ -58764,11 +58647,11 @@ var init_ext_apps_types = __esm({
58764
58647
  function createExtAppsMessageHandler(options) {
58765
58648
  return new ExtAppsMessageHandler(options);
58766
58649
  }
58767
- var import_utils129, MCP_LOG_LEVELS, ExtAppsMessageHandler, ExtAppsError, ExtAppsMethodNotFoundError, ExtAppsInvalidParamsError, ExtAppsNotSupportedError, ExtAppsToolNotFoundError;
58650
+ var import_utils128, MCP_LOG_LEVELS, ExtAppsMessageHandler, ExtAppsError, ExtAppsMethodNotFoundError, ExtAppsInvalidParamsError, ExtAppsNotSupportedError, ExtAppsToolNotFoundError;
58768
58651
  var init_ext_apps_handler = __esm({
58769
58652
  "libs/sdk/src/ext-apps/ext-apps.handler.ts"() {
58770
58653
  "use strict";
58771
- import_utils129 = require("@frontmcp/utils");
58654
+ import_utils128 = require("@frontmcp/utils");
58772
58655
  init_ext_apps_types();
58773
58656
  MCP_LOG_LEVELS = {
58774
58657
  debug: "debug",
@@ -58822,7 +58705,7 @@ var init_ext_apps_handler = __esm({
58822
58705
  code: errorCode,
58823
58706
  message: errorMessage2,
58824
58707
  // Only include stack traces in development to avoid leaking internals in production
58825
- data: (0, import_utils129.isDevelopment)() && error instanceof Error ? { stack: error.stack } : void 0
58708
+ data: (0, import_utils128.isDevelopment)() && error instanceof Error ? { stack: error.stack } : void 0
58826
58709
  }
58827
58710
  };
58828
58711
  }
@@ -59865,7 +59748,7 @@ function encodeBytes(bytes) {
59865
59748
  try {
59866
59749
  return { data: utf8Decoder.decode(bytes), encoding: "utf8" };
59867
59750
  } catch {
59868
- return { data: (0, import_utils130.base64Encode)(bytes), encoding: "base64" };
59751
+ return { data: (0, import_utils129.base64Encode)(bytes), encoding: "base64" };
59869
59752
  }
59870
59753
  }
59871
59754
  function encodeRelayChunk(chunk, encoding) {
@@ -59881,16 +59764,16 @@ function encodeRelayChunk(chunk, encoding) {
59881
59764
  return text.length > 0 ? { data: text, encoding: "utf8" } : void 0;
59882
59765
  }
59883
59766
  function decodeRelayChunk(chunk) {
59884
- return chunk.encoding === "base64" ? (0, import_utils130.base64Decode)(chunk.data) : chunk.data;
59767
+ return chunk.encoding === "base64" ? (0, import_utils129.base64Decode)(chunk.data) : chunk.data;
59885
59768
  }
59886
59769
  function isFlatHeaderList(headers) {
59887
59770
  return Array.isArray(headers);
59888
59771
  }
59889
- var import_utils130, RelayEmitter, utf8Decoder, HOP_BY_HOP_HEADERS2, RelayServerResponse;
59772
+ var import_utils129, RelayEmitter, utf8Decoder, HOP_BY_HOP_HEADERS2, RelayServerResponse;
59890
59773
  var init_relay_http = __esm({
59891
59774
  "libs/sdk/src/transport/relay/relay-http.ts"() {
59892
59775
  "use strict";
59893
- import_utils130 = require("@frontmcp/utils");
59776
+ import_utils129 = require("@frontmcp/utils");
59894
59777
  init_common();
59895
59778
  init_http_location_utils();
59896
59779
  RelayEmitter = class {
@@ -60253,11 +60136,11 @@ var init_transport_remote = __esm({
60253
60136
  });
60254
60137
 
60255
60138
  // libs/sdk/src/transport/transport.registry.ts
60256
- var import_utils131, SESSION_STORE_RETRY_BASE_MS, SESSION_STORE_RETRY_MAX_MS, DEFAULT_SESSION_CHECK_TIMEOUT_MS, BUS_REFRESH_INTERVAL_MS, MAX_ROUTABLE_SESSION_ID_LENGTH, RELAYABLE_TYPES, TransportService;
60139
+ var import_utils130, SESSION_STORE_RETRY_BASE_MS, SESSION_STORE_RETRY_MAX_MS, DEFAULT_SESSION_CHECK_TIMEOUT_MS, BUS_REFRESH_INTERVAL_MS, MAX_ROUTABLE_SESSION_ID_LENGTH, RELAYABLE_TYPES, TransportService;
60257
60140
  var init_transport_registry = __esm({
60258
60141
  "libs/sdk/src/transport/transport.registry.ts"() {
60259
60142
  "use strict";
60260
- import_utils131 = require("@frontmcp/utils");
60143
+ import_utils130 = require("@frontmcp/utils");
60261
60144
  init_session_store_factory();
60262
60145
  init_session_id_utils();
60263
60146
  init_auth_info_utils();
@@ -60626,7 +60509,7 @@ var init_transport_registry = __esm({
60626
60509
  try {
60627
60510
  if (this.localSessionIds.has(sessionId) && await this.holdsLocalSession(sessionId)) return void 0;
60628
60511
  const owner = await this.lookupSessionOwner(sessionId);
60629
- if (!owner || owner.nodeId === (0, import_utils131.getMachineId)()) return void 0;
60512
+ if (!owner || owner.nodeId === (0, import_utils130.getMachineId)()) return void 0;
60630
60513
  return await this.isNodeAlive(owner.nodeId) ? owner : void 0;
60631
60514
  } catch (error) {
60632
60515
  this.scope.logger.warn("[HA] Could not resolve the session owner \u2014 serving the request here", {
@@ -60713,7 +60596,7 @@ var init_transport_registry = __esm({
60713
60596
  });
60714
60597
  return true;
60715
60598
  }
60716
- if (!ownerNodeId || ownerNodeId === (0, import_utils131.getMachineId)()) {
60599
+ if (!ownerNodeId || ownerNodeId === (0, import_utils130.getMachineId)()) {
60717
60600
  if (generation !== void 0) this.ownershipGeneration.set(sessionId, generation);
60718
60601
  return true;
60719
60602
  }
@@ -60896,7 +60779,7 @@ var init_transport_registry = __esm({
60896
60779
  protocol: storedSession.session.protocol,
60897
60780
  createdAt: storedSession.createdAt
60898
60781
  });
60899
- const currentNodeId = (0, import_utils131.getMachineId)();
60782
+ const currentNodeId = (0, import_utils130.getMachineId)();
60900
60783
  const ownerNodeId = storedSession.session.nodeId;
60901
60784
  let latestSession = storedSession;
60902
60785
  if (this.scope.haManager && ownerNodeId && ownerNodeId !== currentNodeId) {
@@ -61000,7 +60883,7 @@ var init_transport_registry = __esm({
61000
60883
  authorizationId: key.tokenHash,
61001
60884
  protocol: type === "sse" ? "sse" : "streamable-http",
61002
60885
  createdAt: Date.now(),
61003
- nodeId: (0, import_utils131.getMachineId)()
60886
+ nodeId: (0, import_utils130.getMachineId)()
61004
60887
  },
61005
60888
  authorizationId: key.tokenHash,
61006
60889
  createdAt: Date.now(),
@@ -61181,7 +61064,7 @@ var init_transport_registry = __esm({
61181
61064
  }
61182
61065
  /* --------------------------------- internals -------------------------------- */
61183
61066
  sha256(value) {
61184
- return (0, import_utils131.sha256Hex)(value);
61067
+ return (0, import_utils130.sha256Hex)(value);
61185
61068
  }
61186
61069
  /**
61187
61070
  * Create a history key from components.
@@ -61398,11 +61281,11 @@ var init_health_probes = __esm({
61398
61281
  });
61399
61282
 
61400
61283
  // libs/sdk/src/health/health.service.ts
61401
- var import_utils132, processStartTime, HealthService;
61284
+ var import_utils131, processStartTime, HealthService;
61402
61285
  var init_health_service = __esm({
61403
61286
  "libs/sdk/src/health/health.service.ts"() {
61404
61287
  "use strict";
61405
- import_utils132 = require("@frontmcp/utils");
61288
+ import_utils131 = require("@frontmcp/utils");
61406
61289
  init_health_probes();
61407
61290
  processStartTime = Date.now();
61408
61291
  HealthService = class {
@@ -61479,7 +61362,7 @@ var init_health_service = __esm({
61479
61362
  * Get liveness response. Synchronous, no I/O.
61480
61363
  */
61481
61364
  getHealthz() {
61482
- const ctx = (0, import_utils132.getRuntimeContext)();
61365
+ const ctx = (0, import_utils131.getRuntimeContext)();
61483
61366
  return {
61484
61367
  status: "ok",
61485
61368
  server: {
@@ -61586,7 +61469,7 @@ var init_health_service = __esm({
61586
61469
  }
61587
61470
  const tools = this.scopeView.tools.getTools(true);
61588
61471
  const toolNames = tools.map((t) => t.name).sort();
61589
- const toolsHash = (0, import_utils132.sha256Hex)(toolNames.join(","));
61472
+ const toolsHash = (0, import_utils131.sha256Hex)(toolNames.join(","));
61590
61473
  return {
61591
61474
  toolsHash,
61592
61475
  toolCount: tools.length,
@@ -61600,7 +61483,7 @@ var init_health_service = __esm({
61600
61483
  if (this.config.includeDetails !== void 0) {
61601
61484
  return this.config.includeDetails;
61602
61485
  }
61603
- const ctx = (0, import_utils132.getRuntimeContext)();
61486
+ const ctx = (0, import_utils131.getRuntimeContext)();
61604
61487
  return ctx.env !== "production";
61605
61488
  }
61606
61489
  };
@@ -62137,7 +62020,7 @@ var init_relay_messages = __esm({
62137
62020
 
62138
62021
  // libs/sdk/src/ha/ha-config.ts
62139
62022
  function positiveInt(name49) {
62140
- const raw = (0, import_utils133.getEnv)(name49);
62023
+ const raw = (0, import_utils132.getEnv)(name49);
62141
62024
  if (raw === void 0 || raw.trim() === "") return void 0;
62142
62025
  const value = Number(raw);
62143
62026
  return Number.isInteger(value) && value > 0 ? value : void 0;
@@ -62150,15 +62033,15 @@ function resolveHaConfigFromEnv() {
62150
62033
  if (heartbeatTtlMs !== void 0) config.heartbeatTtlMs = heartbeatTtlMs;
62151
62034
  const takeoverGracePeriodMs = positiveInt(HA_ENV.takeoverGracePeriodMs);
62152
62035
  if (takeoverGracePeriodMs !== void 0) config.takeoverGracePeriodMs = takeoverGracePeriodMs;
62153
- const redisKeyPrefix = (0, import_utils133.getEnv)(HA_ENV.redisKeyPrefix)?.trim();
62036
+ const redisKeyPrefix = (0, import_utils132.getEnv)(HA_ENV.redisKeyPrefix)?.trim();
62154
62037
  if (redisKeyPrefix) config.redisKeyPrefix = redisKeyPrefix;
62155
62038
  return config;
62156
62039
  }
62157
- var import_utils133, HA_ENV;
62040
+ var import_utils132, HA_ENV;
62158
62041
  var init_ha_config = __esm({
62159
62042
  "libs/sdk/src/ha/ha-config.ts"() {
62160
62043
  "use strict";
62161
- import_utils133 = require("@frontmcp/utils");
62044
+ import_utils132 = require("@frontmcp/utils");
62162
62045
  HA_ENV = {
62163
62046
  heartbeatIntervalMs: "FRONTMCP_HA_HEARTBEAT_INTERVAL_MS",
62164
62047
  heartbeatTtlMs: "FRONTMCP_HA_HEARTBEAT_TTL_MS",
@@ -62493,11 +62376,11 @@ var init_memory_event_store = __esm({
62493
62376
  });
62494
62377
 
62495
62378
  // libs/sdk/src/transport/event-stores/redis.event-store.ts
62496
- var import_utils134, RedisEventStore;
62379
+ var import_utils133, RedisEventStore;
62497
62380
  var init_redis_event_store = __esm({
62498
62381
  "libs/sdk/src/transport/event-stores/redis.event-store.ts"() {
62499
62382
  "use strict";
62500
- import_utils134 = require("@frontmcp/utils");
62383
+ import_utils133 = require("@frontmcp/utils");
62501
62384
  init_sdk_errors();
62502
62385
  RedisEventStore = class {
62503
62386
  client;
@@ -62541,7 +62424,7 @@ var init_redis_event_store = __esm({
62541
62424
  enableReadyCheck: false,
62542
62425
  maxRetriesPerRequest: 3
62543
62426
  });
62544
- (0, import_utils134.attachRedisErrorListener)(this.client, {
62427
+ (0, import_utils133.attachRedisErrorListener)(this.client, {
62545
62428
  label: "RedisEventStore"
62546
62429
  });
62547
62430
  await this.client.connect();
@@ -63122,12 +63005,12 @@ var init_encrypted_elicitation_store = __esm({
63122
63005
  });
63123
63006
 
63124
63007
  // libs/sdk/src/elicitation/store/storage-elicitation.store.ts
63125
- var import_utils135, import_utils136, RESOLVED_RESULT_TTL_SECONDS, RESULT_CHANNEL_PREFIX, FALLBACK_RESULT_CHANNEL_PREFIX, StorageElicitationStore;
63008
+ var import_utils134, import_utils135, RESOLVED_RESULT_TTL_SECONDS, RESULT_CHANNEL_PREFIX, FALLBACK_RESULT_CHANNEL_PREFIX, StorageElicitationStore;
63126
63009
  var init_storage_elicitation_store = __esm({
63127
63010
  "libs/sdk/src/elicitation/store/storage-elicitation.store.ts"() {
63128
63011
  "use strict";
63012
+ import_utils134 = require("@frontmcp/utils");
63129
63013
  import_utils135 = require("@frontmcp/utils");
63130
- import_utils136 = require("@frontmcp/utils");
63131
63014
  RESOLVED_RESULT_TTL_SECONDS = 300;
63132
63015
  RESULT_CHANNEL_PREFIX = "result:";
63133
63016
  FALLBACK_RESULT_CHANNEL_PREFIX = "fallback-result:";
@@ -63152,9 +63035,9 @@ var init_storage_elicitation_store = __esm({
63152
63035
  constructor(storage, logger) {
63153
63036
  this.storage = storage;
63154
63037
  this.logger = logger;
63155
- this.pending = new import_utils135.TypedStorage(storage.namespace("pending"));
63156
- this.fallback = new import_utils135.TypedStorage(storage.namespace("fallback"));
63157
- this.resolved = new import_utils135.TypedStorage(storage.namespace("resolved"));
63038
+ this.pending = new import_utils134.TypedStorage(storage.namespace("pending"));
63039
+ this.fallback = new import_utils134.TypedStorage(storage.namespace("fallback"));
63040
+ this.resolved = new import_utils134.TypedStorage(storage.namespace("resolved"));
63158
63041
  }
63159
63042
  // ============================================
63160
63043
  // Pending Elicitation Methods
@@ -63164,7 +63047,7 @@ var init_storage_elicitation_store = __esm({
63164
63047
  */
63165
63048
  async setPending(record) {
63166
63049
  const { sessionId, expiresAt } = record;
63167
- const ttlSeconds = (0, import_utils136.expiresAtToTTL)(expiresAt);
63050
+ const ttlSeconds = (0, import_utils135.expiresAtToTTL)(expiresAt);
63168
63051
  if (ttlSeconds <= 0) {
63169
63052
  this.logger?.warn("[StorageElicitationStore] Record already expired, not storing", {
63170
63053
  sessionId,
@@ -63342,7 +63225,7 @@ var init_storage_elicitation_store = __esm({
63342
63225
  */
63343
63226
  async setPendingFallback(record) {
63344
63227
  const { elicitId, expiresAt } = record;
63345
- const ttlSeconds = (0, import_utils136.expiresAtToTTL)(expiresAt);
63228
+ const ttlSeconds = (0, import_utils135.expiresAtToTTL)(expiresAt);
63346
63229
  if (ttlSeconds <= 0) {
63347
63230
  this.logger?.warn("[StorageElicitationStore] Fallback record already expired, not storing", { elicitId });
63348
63231
  return;
@@ -63611,10 +63494,10 @@ function detectStorageType(storage, configuredType) {
63611
63494
  if (backend === "redis" || backend === "upstash" || backend === "memory") {
63612
63495
  return backend;
63613
63496
  }
63614
- if ((0, import_utils137.getEnv)("UPSTASH_REDIS_REST_URL")) {
63497
+ if ((0, import_utils136.getEnv)("UPSTASH_REDIS_REST_URL")) {
63615
63498
  return "upstash";
63616
63499
  }
63617
- if ((0, import_utils137.getEnv)("REDIS_URL") || (0, import_utils137.getEnv)("REDIS_HOST")) {
63500
+ if ((0, import_utils136.getEnv)("REDIS_URL") || (0, import_utils136.getEnv)("REDIS_HOST")) {
63618
63501
  return "redis";
63619
63502
  }
63620
63503
  return "memory";
@@ -63677,7 +63560,7 @@ async function createElicitationStore(options = {}) {
63677
63560
  logger?.debug("[ElicitationStoreFactory] Converted redis option to storage config", { host, port });
63678
63561
  }
63679
63562
  const explicitBackend = Boolean(storageConfig || redis);
63680
- if (finalStorageConfig?.type === "vercel-kv" || !explicitBackend && (0, import_utils137.getEnv)("KV_REST_API_URL")) {
63563
+ if (finalStorageConfig?.type === "vercel-kv" || !explicitBackend && (0, import_utils136.getEnv)("KV_REST_API_URL")) {
63681
63564
  throw new ElicitationNotSupportedError(
63682
63565
  "Vercel KV is not supported for elicitation stores. Elicitation requires pub/sub for cross-node result routing, which Vercel KV does not support. Use Redis or Upstash instead."
63683
63566
  );
@@ -63687,7 +63570,7 @@ async function createElicitationStore(options = {}) {
63687
63570
  "Elicitation requires distributed storage when running on Edge runtime. Edge functions are stateless and cannot use in-memory elicitation. Configure Redis or Upstash storage."
63688
63571
  );
63689
63572
  }
63690
- const storage = await (0, import_utils137.createStorage)({
63573
+ const storage = await (0, import_utils136.createStorage)({
63691
63574
  ...finalStorageConfig,
63692
63575
  prefix: keyPrefix,
63693
63576
  fallback: isEdgeRuntime3 ? "error" : "memory"
@@ -63725,7 +63608,7 @@ async function createElicitationStore(options = {}) {
63725
63608
  }
63726
63609
  function createMemoryElicitationStore(options = {}) {
63727
63610
  const { keyPrefix = "mcp:elicit:", logger, encryption } = options;
63728
- const storage = (0, import_utils137.createMemoryStorage)({ prefix: keyPrefix });
63611
+ const storage = (0, import_utils136.createMemoryStorage)({ prefix: keyPrefix });
63729
63612
  let store = new StorageElicitationStore(storage, logger);
63730
63613
  const encryptionEnabled = encryption?.enabled ?? "auto";
63731
63614
  const encryptionSecret = encryption?.secret;
@@ -63781,11 +63664,11 @@ function createSqliteElicitationStore(sqliteConfig, storeOptions = {}) {
63781
63664
  keyPrefix
63782
63665
  });
63783
63666
  }
63784
- var import_utils137;
63667
+ var import_utils136;
63785
63668
  var init_elicitation_store_factory = __esm({
63786
63669
  "libs/sdk/src/elicitation/store/elicitation-store.factory.ts"() {
63787
63670
  "use strict";
63788
- import_utils137 = require("@frontmcp/utils");
63671
+ import_utils136 = require("@frontmcp/utils");
63789
63672
  init_common();
63790
63673
  init_schema5();
63791
63674
  init_elicitation_error();
@@ -63803,11 +63686,11 @@ function slotKey(sessionId, slot) {
63803
63686
  return `${sessionId}:${slot}`;
63804
63687
  }
63805
63688
  function encodeCursor(offset) {
63806
- return (0, import_utils138.base64urlEncode)(new TextEncoder().encode(JSON.stringify({ offset })));
63689
+ return (0, import_utils137.base64urlEncode)(new TextEncoder().encode(JSON.stringify({ offset })));
63807
63690
  }
63808
63691
  function decodeCursor(cursor) {
63809
63692
  try {
63810
- const bytes = (0, import_utils138.base64urlDecode)(cursor);
63693
+ const bytes = (0, import_utils137.base64urlDecode)(cursor);
63811
63694
  const parsed = JSON.parse(new TextDecoder().decode(bytes));
63812
63695
  if (typeof parsed?.offset === "number" && parsed.offset >= 0 && Number.isInteger(parsed.offset)) {
63813
63696
  return parsed.offset;
@@ -63816,11 +63699,11 @@ function decodeCursor(cursor) {
63816
63699
  }
63817
63700
  return 0;
63818
63701
  }
63819
- var import_utils138, TERMINAL_CHANNEL_PREFIX, CANCEL_CHANNEL_PREFIX, RECORDS_NAMESPACE, SLOTS_NAMESPACE, DEFAULT_PAGE_SIZE2, StorageTaskStore;
63702
+ var import_utils137, TERMINAL_CHANNEL_PREFIX, CANCEL_CHANNEL_PREFIX, RECORDS_NAMESPACE, SLOTS_NAMESPACE, DEFAULT_PAGE_SIZE2, StorageTaskStore;
63820
63703
  var init_storage_task_store = __esm({
63821
63704
  "libs/sdk/src/task/store/storage-task.store.ts"() {
63822
63705
  "use strict";
63823
- import_utils138 = require("@frontmcp/utils");
63706
+ import_utils137 = require("@frontmcp/utils");
63824
63707
  init_process_liveness();
63825
63708
  init_task_types();
63826
63709
  TERMINAL_CHANNEL_PREFIX = "terminal:";
@@ -63840,11 +63723,11 @@ var init_storage_task_store = __esm({
63840
63723
  constructor(storage, logger) {
63841
63724
  this.storage = storage;
63842
63725
  this.logger = logger;
63843
- this.records = new import_utils138.TypedStorage(storage.namespace(RECORDS_NAMESPACE));
63726
+ this.records = new import_utils137.TypedStorage(storage.namespace(RECORDS_NAMESPACE));
63844
63727
  this.slots = storage.namespace(SLOTS_NAMESPACE);
63845
63728
  }
63846
63729
  async create(record) {
63847
- const ttlSeconds = (0, import_utils138.expiresAtToTTL)(record.expiresAt);
63730
+ const ttlSeconds = (0, import_utils137.expiresAtToTTL)(record.expiresAt);
63848
63731
  if (ttlSeconds <= 0) {
63849
63732
  this.logger?.warn("[StorageTaskStore] create: record already expired, skipping", {
63850
63733
  taskId: record.taskId
@@ -63857,7 +63740,7 @@ var init_storage_task_store = __esm({
63857
63740
  }
63858
63741
  /** A task holds one of its owner's `maxActive` slot keys, claimed by a write-if-absent, until it finishes. */
63859
63742
  async createWithinLimit(record, maxActive) {
63860
- const ttlSeconds = (0, import_utils138.expiresAtToTTL)(record.expiresAt);
63743
+ const ttlSeconds = (0, import_utils137.expiresAtToTTL)(record.expiresAt);
63861
63744
  if (ttlSeconds <= 0) {
63862
63745
  await this.create(record);
63863
63746
  return true;
@@ -63895,7 +63778,7 @@ var init_storage_task_store = __esm({
63895
63778
  createdAt: existing.createdAt,
63896
63779
  lastUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
63897
63780
  };
63898
- const ttlSeconds = (0, import_utils138.expiresAtToTTL)(merged.expiresAt);
63781
+ const ttlSeconds = (0, import_utils137.expiresAtToTTL)(merged.expiresAt);
63899
63782
  if (ttlSeconds <= 0) {
63900
63783
  await this.delete(taskId, sessionId);
63901
63784
  return null;
@@ -64161,8 +64044,8 @@ function detectStorageType2(storage, configuredType) {
64161
64044
  if (storageBackend === "redis" || storageBackend === "upstash" || storageBackend === "memory") {
64162
64045
  return storageBackend;
64163
64046
  }
64164
- if ((0, import_utils139.getEnv)("UPSTASH_REDIS_REST_URL")) return "upstash";
64165
- if ((0, import_utils139.getEnv)("REDIS_URL") || (0, import_utils139.getEnv)("REDIS_HOST")) return "redis";
64047
+ if ((0, import_utils138.getEnv)("UPSTASH_REDIS_REST_URL")) return "upstash";
64048
+ if ((0, import_utils138.getEnv)("REDIS_URL") || (0, import_utils138.getEnv)("REDIS_HOST")) return "redis";
64166
64049
  return "memory";
64167
64050
  }
64168
64051
  async function createTaskStore(options = {}) {
@@ -64204,7 +64087,7 @@ async function createTaskStore(options = {}) {
64204
64087
  finalStorageConfig = { type: "redis", redis: { config: { host, port, password, db, tls } } };
64205
64088
  }
64206
64089
  const explicitBackend = isExplicitStorage(storageConfig) || Boolean(redis);
64207
- if (finalStorageConfig?.type === "vercel-kv" || !explicitBackend && (0, import_utils139.getEnv)("KV_REST_API_URL")) {
64090
+ if (finalStorageConfig?.type === "vercel-kv" || !explicitBackend && (0, import_utils138.getEnv)("KV_REST_API_URL")) {
64208
64091
  throw new TaskStoreNotSupportedError(
64209
64092
  "Vercel KV is not supported for task stores (pub/sub required). Use Redis or Upstash."
64210
64093
  );
@@ -64214,7 +64097,7 @@ async function createTaskStore(options = {}) {
64214
64097
  "Tasks require distributed storage on Edge runtime. Configure Redis or Upstash."
64215
64098
  );
64216
64099
  }
64217
- const storage = await (0, import_utils139.createStorage)({
64100
+ const storage = await (0, import_utils138.createStorage)({
64218
64101
  ...finalStorageConfig,
64219
64102
  prefix: keyPrefix,
64220
64103
  fallback: isEdgeRuntime3 ? "error" : "memory"
@@ -64230,14 +64113,14 @@ async function createTaskStore(options = {}) {
64230
64113
  }
64231
64114
  function createMemoryTaskStore(options = {}) {
64232
64115
  const { keyPrefix = "mcp:task:", logger } = options;
64233
- const storage = (0, import_utils139.createMemoryStorage)({ prefix: keyPrefix });
64116
+ const storage = (0, import_utils138.createMemoryStorage)({ prefix: keyPrefix });
64234
64117
  return { store: new StorageTaskStore(storage, logger), type: "memory", storage };
64235
64118
  }
64236
- var import_utils139, TaskStoreNotSupportedError;
64119
+ var import_utils138, TaskStoreNotSupportedError;
64237
64120
  var init_task_store_factory = __esm({
64238
64121
  "libs/sdk/src/task/store/task-store.factory.ts"() {
64239
64122
  "use strict";
64240
- import_utils139 = require("@frontmcp/utils");
64123
+ import_utils138 = require("@frontmcp/utils");
64241
64124
  init_common();
64242
64125
  init_schema5();
64243
64126
  init_storage_task_store();
@@ -64334,7 +64217,7 @@ var init_task_registry = __esm({
64334
64217
 
64335
64218
  // libs/sdk/src/task/helpers/task-runner.ts
64336
64219
  function runTaskInBackground(params) {
64337
- return Promise.resolve().then(() => (0, import_utils140.runRequestExclusive)(() => executeTask(params)));
64220
+ return Promise.resolve().then(() => (0, import_utils139.runRequestExclusive)(() => executeTask(params)));
64338
64221
  }
64339
64222
  async function executeTask(params) {
64340
64223
  const { record, cleanedRequestParams, ctx, scope, store, registry, notifier, logger } = params;
@@ -64452,11 +64335,11 @@ function toJsonRpcError2(err) {
64452
64335
  const message = sdkError.message.replace(/^MCP error -?\d+: /, "");
64453
64336
  return sdkError.data === void 0 ? { code: sdkError.code, message } : { code: sdkError.code, message, data: sdkError.data };
64454
64337
  }
64455
- var import_utils140;
64338
+ var import_utils139;
64456
64339
  var init_task_runner = __esm({
64457
64340
  "libs/sdk/src/task/helpers/task-runner.ts"() {
64458
64341
  "use strict";
64459
- import_utils140 = require("@frontmcp/utils");
64342
+ import_utils139 = require("@frontmcp/utils");
64460
64343
  init_errors();
64461
64344
  init_call_tool_error_utils();
64462
64345
  init_mcp_error_utils();
@@ -64965,6 +64848,144 @@ var init_task_scope_runtime = __esm({
64965
64848
  }
64966
64849
  });
64967
64850
 
64851
+ // libs/sdk/src/auth/session-scope-identity.ts
64852
+ function sessionScopeIdentity(ctx) {
64853
+ const verified = ctx.verifiedSessionId;
64854
+ if (verified) return verified;
64855
+ const authInfo = ctx.authInfo ?? {};
64856
+ const extraUser = authInfo.extra?.["user"];
64857
+ const principal = [authInfo.user?.sub, extraUser?.sub, authInfo.clientId].find(
64858
+ (candidate) => !(0, import_auth54.isAnonymousSubject)(candidate)
64859
+ );
64860
+ return principal ? `principal:${principal}` : void 0;
64861
+ }
64862
+ var import_auth54;
64863
+ var init_session_scope_identity = __esm({
64864
+ "libs/sdk/src/auth/session-scope-identity.ts"() {
64865
+ "use strict";
64866
+ import_auth54 = require("@frontmcp/auth");
64867
+ }
64868
+ });
64869
+
64870
+ // libs/sdk/src/auth/vault/credential-cache.ts
64871
+ var CREDENTIAL_CACHE;
64872
+ var init_credential_cache = __esm({
64873
+ "libs/sdk/src/auth/vault/credential-cache.ts"() {
64874
+ "use strict";
64875
+ CREDENTIAL_CACHE = /* @__PURE__ */ Symbol.for("frontmcp:CREDENTIAL_CACHE");
64876
+ }
64877
+ });
64878
+
64879
+ // libs/sdk/src/auth/vault/auth-providers.providers.ts
64880
+ var auth_providers_providers_exports = {};
64881
+ __export(auth_providers_providers_exports, {
64882
+ LAZY_CREDENTIAL_LOADER: () => LAZY_CREDENTIAL_LOADER,
64883
+ createAuthProvidersProviders: () => createAuthProvidersProviders,
64884
+ isAuthProvidersEnabled: () => isAuthProvidersEnabled,
64885
+ registerAuthProvidersVault: () => registerAuthProvidersVault
64886
+ });
64887
+ function createAuthProvidersProviders(options, store, baseVault = new import_auth55.InMemoryAuthorizationVault()) {
64888
+ const providers = [];
64889
+ providers.push({
64890
+ provide: import_auth55.AUTH_PROVIDERS_REGISTRY,
64891
+ scope: import_di47.ProviderScope.GLOBAL,
64892
+ name: "AuthProvidersRegistry",
64893
+ useFactory: () => new import_auth55.AuthProvidersRegistry(options)
64894
+ });
64895
+ providers.push({
64896
+ provide: import_auth55.AUTH_PROVIDERS_VAULT,
64897
+ scope: import_di47.ProviderScope.GLOBAL,
64898
+ name: "AuthProvidersVault",
64899
+ useFactory: (logger) => new import_auth55.AuthProvidersVault(store.storage, {
64900
+ namespace: options.namespace,
64901
+ defaultCacheTtl: options.defaultCacheTtl,
64902
+ pepper: store.pepper,
64903
+ logger
64904
+ }),
64905
+ inject: () => [FrontMcpLogger]
64906
+ });
64907
+ providers.push({
64908
+ provide: CREDENTIAL_CACHE,
64909
+ scope: import_di47.ProviderScope.CONTEXT,
64910
+ name: "CredentialCache",
64911
+ useFactory: () => new import_auth55.CredentialCache(options.maxCredentialsPerSession ?? 100)
64912
+ });
64913
+ providers.push({
64914
+ provide: LAZY_CREDENTIAL_LOADER,
64915
+ scope: import_di47.ProviderScope.CONTEXT,
64916
+ name: "LazyCredentialLoader",
64917
+ useFactory: (logger) => new import_auth55.LazyCredentialLoader(logger),
64918
+ inject: () => [FrontMcpLogger]
64919
+ });
64920
+ providers.push({
64921
+ provide: import_auth55.AUTH_PROVIDERS_ACCESSOR,
64922
+ scope: import_di47.ProviderScope.CONTEXT,
64923
+ name: "AuthProvidersAccessor",
64924
+ useFactory: (registry, vault, cache2, loader, ctx, logger) => {
64925
+ const user = ctx.authInfo?.user;
64926
+ const signedIn = user && !(0, import_auth55.isAnonymousSubject)(user.sub) ? user : void 0;
64927
+ const factoryContext = {
64928
+ sessionId: sessionScopeIdentity(ctx) ?? `${import_auth55.UNIDENTIFIED_SESSION_PREFIX}${(0, import_utils140.randomUUID)()}`,
64929
+ userSub: signedIn?.sub,
64930
+ userEmail: signedIn?.email,
64931
+ userName: signedIn?.name,
64932
+ // appId and toolId are not available in FrontMcpContext,
64933
+ // they can be set by the tool flow when calling the accessor
64934
+ vault: baseVault
64935
+ };
64936
+ return new import_auth55.AuthProvidersAccessorImpl(registry, vault, cache2, loader, factoryContext, logger);
64937
+ },
64938
+ inject: () => [
64939
+ import_auth55.AUTH_PROVIDERS_REGISTRY,
64940
+ import_auth55.AUTH_PROVIDERS_VAULT,
64941
+ CREDENTIAL_CACHE,
64942
+ LAZY_CREDENTIAL_LOADER,
64943
+ FRONTMCP_CONTEXT,
64944
+ FrontMcpLogger
64945
+ ]
64946
+ });
64947
+ return providers;
64948
+ }
64949
+ function isAuthProvidersEnabled(options) {
64950
+ if (options?.enabled === false) {
64951
+ return false;
64952
+ }
64953
+ if (options?.enabled === true) {
64954
+ return true;
64955
+ }
64956
+ return (options?.providers?.length ?? 0) > 0;
64957
+ }
64958
+ async function registerAuthProvidersVault(providers, options, tokenStorage, logger) {
64959
+ if (!isAuthProvidersEnabled(options)) return void 0;
64960
+ if (tokenStorage && options.useSharedStorage !== false) {
64961
+ const pepper = (0, import_utils140.getEnv)("VAULT_SECRET") || (0, import_utils140.getEnv)("JWT_SECRET");
64962
+ if (!pepper) {
64963
+ logger.warn(
64964
+ "authProvidersVault keeps credentials in auth.tokenStorage, but neither VAULT_SECRET nor JWT_SECRET is set: they are encrypted with a random key of this process, so other instances and a restart do not find them."
64965
+ );
64966
+ }
64967
+ await providers.addDynamicProviders(createAuthProvidersProviders(options, { storage: tokenStorage, pepper }));
64968
+ return void 0;
64969
+ }
64970
+ const storage = await (0, import_utils140.createStorage)({ type: "memory" });
64971
+ await providers.addDynamicProviders(createAuthProvidersProviders(options, { storage }));
64972
+ return () => storage.disconnect();
64973
+ }
64974
+ var import_auth55, import_di47, import_utils140, LAZY_CREDENTIAL_LOADER;
64975
+ var init_auth_providers_providers = __esm({
64976
+ "libs/sdk/src/auth/vault/auth-providers.providers.ts"() {
64977
+ "use strict";
64978
+ import_auth55 = require("@frontmcp/auth");
64979
+ import_di47 = require("@frontmcp/di");
64980
+ import_utils140 = require("@frontmcp/utils");
64981
+ init_common();
64982
+ init_frontmcp_context_provider();
64983
+ init_session_scope_identity();
64984
+ init_credential_cache();
64985
+ LAZY_CREDENTIAL_LOADER = /* @__PURE__ */ Symbol.for("frontmcp:LAZY_CREDENTIAL_LOADER");
64986
+ }
64987
+ });
64988
+
64968
64989
  // libs/sdk/src/scope/tracer-provider.utils.ts
64969
64990
  function hasRegisteredTracerProvider({ trace, ProxyTracerProvider }) {
64970
64991
  const provider = trace.getTracerProvider();
@@ -74100,6 +74121,9 @@ var init_instance_local_primary_auth = __esm({
74100
74121
  }
74101
74122
  return void 0;
74102
74123
  }
74124
+ get tokenStorageAdapter() {
74125
+ return this.storageAdapter;
74126
+ }
74103
74127
  /**
74104
74128
  * When a persistent token-storage backend (Redis/SQLite) is configured, build
74105
74129
  * a shared `StorageAdapter` and swap the three in-memory stores for their
@@ -75865,10 +75889,6 @@ var init_scope_instance = __esm({
75865
75889
  const mark = perf ? (label) => this.logger.info(`[PERF] ${label}: ${(performance.now() - t0).toFixed(1)}ms`) : () => {
75866
75890
  };
75867
75891
  await refuseStoresInBrowser(this.metadata);
75868
- if (this.metadata.authProvidersVault) {
75869
- const { registerAuthProvidersVault: registerAuthProvidersVault2 } = await Promise.resolve().then(() => (init_auth_providers_providers(), auth_providers_providers_exports));
75870
- await registerAuthProvidersVault2(scopeProviders, this.metadata.authProvidersVault);
75871
- }
75872
75892
  const httpServing = this.directOnly ? void 0 : await Promise.resolve().then(() => (init_http_scope_helper(), http_scope_helper_exports));
75873
75893
  const createPrimaryAuth2 = await this.primaryAuthFactory();
75874
75894
  this.scopeHooks = new HookRegistry(scopeProviders, []);
@@ -76116,6 +76136,16 @@ var init_scope_instance = __esm({
76116
76136
  if (tasksPromise) batch1.push(tasksPromise);
76117
76137
  if (rateLimitPromise) batch1.push(rateLimitPromise);
76118
76138
  await Promise.all(batch1);
76139
+ if (this.metadata.authProvidersVault) {
76140
+ const { registerAuthProvidersVault: registerAuthProvidersVault2 } = await Promise.resolve().then(() => (init_auth_providers_providers(), auth_providers_providers_exports));
76141
+ const closeVaultStorage = await registerAuthProvidersVault2(
76142
+ scopeProviders,
76143
+ this.metadata.authProvidersVault,
76144
+ this.auth.tokenStorageAdapter,
76145
+ this.logger
76146
+ );
76147
+ if (closeVaultStorage) this.onDispose(closeVaultStorage);
76148
+ }
76119
76149
  const serverHooks = serverProviderHooks(this.scopeProviders, this.metadata.providers, scopeRef);
76120
76150
  if (serverHooks.length > 0) await this.scopeHooks.registerHooks(false, ...serverHooks);
76121
76151
  this.logger.verbose("HookRegistry initialized");