@frontmcp/sdk 1.0.0-beta.10 → 1.0.0-beta.12

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/index.js CHANGED
@@ -6592,12 +6592,12 @@ var init_provider_registry = __esm({
6592
6592
  */
6593
6593
  getProviderInfo(token) {
6594
6594
  const def = this.defs.get(token);
6595
- const instance = this.instances.get(token);
6596
- if (!def || !instance)
6595
+ if (!def)
6597
6596
  throw new ProviderNotRegisteredError(
6598
6597
  (0, import_di7.tokenName)(token),
6599
6598
  "not a registered DEFAULT provider and not a constructable class"
6600
6599
  );
6600
+ const instance = this.instances.get(token);
6601
6601
  return {
6602
6602
  token,
6603
6603
  def,
@@ -10994,15 +10994,22 @@ var init_resource_instance = __esm({
10994
10994
  init_mcp_error();
10995
10995
  init_errors();
10996
10996
  ResourceInstance = class extends ResourceEntry2 {
10997
- providers;
10997
+ _providers;
10998
10998
  scope;
10999
10999
  hooks;
11000
+ /**
11001
+ * Get the provider registry for this resource.
11002
+ * Used by flows to build context-aware providers for CONTEXT-scoped dependencies.
11003
+ */
11004
+ get providers() {
11005
+ return this._providers;
11006
+ }
11000
11007
  /** Parsed URI template info for template resources */
11001
11008
  templateInfo;
11002
11009
  constructor(record, providers, owner) {
11003
11010
  super(record);
11004
11011
  this.owner = owner;
11005
- this.providers = providers;
11012
+ this._providers = providers;
11006
11013
  this.name = record.metadata.name;
11007
11014
  this.fullName = this.owner.id + ":" + this.name;
11008
11015
  this.scope = this.providers.getActiveScope();
@@ -11037,6 +11044,18 @@ var init_resource_instance = __esm({
11037
11044
  getMetadata() {
11038
11045
  return this.record.metadata;
11039
11046
  }
11047
+ /**
11048
+ * Get an argument completer from the resource class prototype.
11049
+ * Returns a completer function if the resource class overrides getArgumentCompleter,
11050
+ * or null if no completer is available.
11051
+ */
11052
+ getArgumentCompleter(argName) {
11053
+ const cls = this.record.provide;
11054
+ if (typeof cls === "function" && cls.prototype && typeof cls.prototype.getArgumentCompleter === "function") {
11055
+ return cls.prototype.getArgumentCompleter.call(cls.prototype, argName);
11056
+ }
11057
+ return null;
11058
+ }
11040
11059
  /**
11041
11060
  * Match a URI against this resource.
11042
11061
  * For static resources: exact match against uri
@@ -11150,7 +11169,7 @@ var init_resource_types = __esm({
11150
11169
  });
11151
11170
 
11152
11171
  // libs/sdk/src/resource/flows/read-resource.flow.ts
11153
- var import_zod40, import_protocol9, inputSchema4, outputSchema3, stateSchema3, plan3, name3, Stage3, ReadResourceFlow;
11172
+ var import_zod40, import_protocol9, import_utils22, inputSchema4, outputSchema3, stateSchema3, plan3, name3, Stage3, ReadResourceFlow;
11154
11173
  var init_read_resource_flow = __esm({
11155
11174
  "libs/sdk/src/resource/flows/read-resource.flow.ts"() {
11156
11175
  "use strict";
@@ -11160,6 +11179,7 @@ var init_read_resource_flow = __esm({
11160
11179
  init_errors();
11161
11180
  init_ui();
11162
11181
  init_flow_context_providers();
11182
+ import_utils22 = require("@frontmcp/utils");
11163
11183
  inputSchema4 = import_zod40.z.object({
11164
11184
  request: import_protocol9.ReadResourceRequestSchema,
11165
11185
  // z.any() used because ctx is the MCP SDK's ResourceReadExtra type which varies by SDK version
@@ -11304,7 +11324,15 @@ var init_read_resource_flow = __esm({
11304
11324
  const { ctx } = this.input;
11305
11325
  const { resource, input, params } = this.state.required;
11306
11326
  try {
11307
- const contextProviders = new FlowContextProviders(this.scope.providers, this.deps);
11327
+ const sessionKey = this.state.sessionId ?? ctx.authInfo?.sessionId ?? `req-${Date.now()}-${Buffer.from((0, import_utils22.randomBytes)(16)).toString("hex")}`;
11328
+ const resourceViews = await resource.providers.buildViews(sessionKey, new Map(this.deps));
11329
+ const mergedContextDeps = new Map(this.deps);
11330
+ for (const [token, instance] of resourceViews.context) {
11331
+ if (!mergedContextDeps.has(token)) {
11332
+ mergedContextDeps.set(token, instance);
11333
+ }
11334
+ }
11335
+ const contextProviders = new FlowContextProviders(resource.providers, mergedContextDeps);
11308
11336
  const context = resource.create(input.uri, params, { ...ctx, contextProviders });
11309
11337
  const resourceHooks = this.scope.hooks.getClsHooks(resource.record.provide).map((hook) => {
11310
11338
  hook.run = async () => {
@@ -12059,13 +12087,13 @@ function dedupLineage2(l) {
12059
12087
  }
12060
12088
  return out;
12061
12089
  }
12062
- var import_di12, import_utils22, ResourceRegistry;
12090
+ var import_di12, import_utils23, ResourceRegistry;
12063
12091
  var init_resource_registry = __esm({
12064
12092
  "libs/sdk/src/resource/resource.registry.ts"() {
12065
12093
  "use strict";
12066
12094
  import_di12 = require("@frontmcp/di");
12067
12095
  init_resource_events();
12068
- import_utils22 = require("@frontmcp/utils");
12096
+ import_utils23 = require("@frontmcp/utils");
12069
12097
  init_naming_utils();
12070
12098
  init_lineage_utils();
12071
12099
  init_resource_utils();
@@ -12359,31 +12387,31 @@ var init_resource_registry = __esm({
12359
12387
  for (const [base, group] of byBase.entries()) {
12360
12388
  if (group.length === 1) {
12361
12389
  const g = group[0];
12362
- out.set((0, import_utils22.ensureMaxLen)(base, cfg.maxLen), g.row.instance);
12390
+ out.set((0, import_utils23.ensureMaxLen)(base, cfg.maxLen), g.row.instance);
12363
12391
  continue;
12364
12392
  }
12365
12393
  const locals = group.filter((g) => g.isLocal);
12366
12394
  const children = group.filter((g) => !g.isLocal);
12367
12395
  if (cfg.prefixChildrenOnConflict && locals.length > 0) {
12368
12396
  if (locals.length === 1) {
12369
- const localName = (0, import_utils22.ensureMaxLen)(base, cfg.maxLen);
12397
+ const localName = (0, import_utils23.ensureMaxLen)(base, cfg.maxLen);
12370
12398
  out.set(disambiguate(localName, out, cfg), locals[0].row.instance);
12371
12399
  } else {
12372
12400
  for (const l of locals) {
12373
12401
  const pref = normalizeOwnerPath(l.ownerPath, cfg.case);
12374
- const name33 = (0, import_utils22.ensureMaxLen)(`${pref}${(0, import_utils22.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12402
+ const name33 = (0, import_utils23.ensureMaxLen)(`${pref}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12375
12403
  out.set(disambiguate(name33, out, cfg), l.row.instance);
12376
12404
  }
12377
12405
  }
12378
12406
  for (const c of children) {
12379
12407
  const pre = cfg.prefixSource === "provider" ? c.provider ?? c.ownerPath : c.ownerPath;
12380
- const name33 = (0, import_utils22.ensureMaxLen)(`${pre}${(0, import_utils22.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12408
+ const name33 = (0, import_utils23.ensureMaxLen)(`${pre}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12381
12409
  out.set(disambiguate(name33, out, cfg), c.row.instance);
12382
12410
  }
12383
12411
  } else {
12384
12412
  for (const r of group) {
12385
12413
  const pre = cfg.prefixSource === "provider" ? r.provider ?? r.ownerPath : r.ownerPath;
12386
- const name33 = (0, import_utils22.ensureMaxLen)(`${pre}${(0, import_utils22.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12414
+ const name33 = (0, import_utils23.ensureMaxLen)(`${pre}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
12387
12415
  out.set(disambiguate(name33, out, cfg), r.row.instance);
12388
12416
  }
12389
12417
  }
@@ -12394,7 +12422,7 @@ var init_resource_registry = __esm({
12394
12422
  const maxAttempts = 1e4;
12395
12423
  let n = 2;
12396
12424
  while (n <= maxAttempts) {
12397
- const withN = (0, import_utils22.ensureMaxLen)(`${candidate}${(0, import_utils22.sepFor)(cfg2.case)}${n}`, cfg2.maxLen);
12425
+ const withN = (0, import_utils23.ensureMaxLen)(`${candidate}${(0, import_utils23.sepFor)(cfg2.case)}${n}`, cfg2.maxLen);
12398
12426
  if (!pool.has(withN)) return withN;
12399
12427
  n++;
12400
12428
  }
@@ -13303,13 +13331,13 @@ function dedupLineage3(l) {
13303
13331
  }
13304
13332
  return out;
13305
13333
  }
13306
- var import_di14, import_utils23, MAX_DISAMBIGUATE_ATTEMPTS, PromptRegistry;
13334
+ var import_di14, import_utils24, MAX_DISAMBIGUATE_ATTEMPTS, PromptRegistry;
13307
13335
  var init_prompt_registry = __esm({
13308
13336
  "libs/sdk/src/prompt/prompt.registry.ts"() {
13309
13337
  "use strict";
13310
13338
  import_di14 = require("@frontmcp/di");
13311
13339
  init_prompt_events();
13312
- import_utils23 = require("@frontmcp/utils");
13340
+ import_utils24 = require("@frontmcp/utils");
13313
13341
  init_utils();
13314
13342
  init_lineage_utils();
13315
13343
  init_prompt_utils();
@@ -13562,31 +13590,31 @@ var init_prompt_registry = __esm({
13562
13590
  for (const [base, group] of byBase.entries()) {
13563
13591
  if (group.length === 1) {
13564
13592
  const g = group[0];
13565
- out.set((0, import_utils23.ensureMaxLen)(base, cfg.maxLen), g.row.instance);
13593
+ out.set((0, import_utils24.ensureMaxLen)(base, cfg.maxLen), g.row.instance);
13566
13594
  continue;
13567
13595
  }
13568
13596
  const locals = group.filter((g) => g.isLocal);
13569
13597
  const children = group.filter((g) => !g.isLocal);
13570
13598
  if (cfg.prefixChildrenOnConflict && locals.length > 0) {
13571
13599
  if (locals.length === 1) {
13572
- const localName = (0, import_utils23.ensureMaxLen)(base, cfg.maxLen);
13600
+ const localName = (0, import_utils24.ensureMaxLen)(base, cfg.maxLen);
13573
13601
  out.set(disambiguate(localName, out, cfg), locals[0].row.instance);
13574
13602
  } else {
13575
13603
  for (const l of locals) {
13576
13604
  const pref = normalizeOwnerPath(l.ownerPath, cfg.case);
13577
- const name33 = (0, import_utils23.ensureMaxLen)(`${pref}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13605
+ const name33 = (0, import_utils24.ensureMaxLen)(`${pref}${(0, import_utils24.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13578
13606
  out.set(disambiguate(name33, out, cfg), l.row.instance);
13579
13607
  }
13580
13608
  }
13581
13609
  for (const c of children) {
13582
13610
  const pre = cfg.prefixSource === "provider" ? c.provider ?? c.ownerPath : c.ownerPath;
13583
- const name33 = (0, import_utils23.ensureMaxLen)(`${pre}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13611
+ const name33 = (0, import_utils24.ensureMaxLen)(`${pre}${(0, import_utils24.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13584
13612
  out.set(disambiguate(name33, out, cfg), c.row.instance);
13585
13613
  }
13586
13614
  } else {
13587
13615
  for (const r of group) {
13588
13616
  const pre = cfg.prefixSource === "provider" ? r.provider ?? r.ownerPath : r.ownerPath;
13589
- const name33 = (0, import_utils23.ensureMaxLen)(`${pre}${(0, import_utils23.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13617
+ const name33 = (0, import_utils24.ensureMaxLen)(`${pre}${(0, import_utils24.sepFor)(cfg.case)}${base}`, cfg.maxLen);
13590
13618
  out.set(disambiguate(name33, out, cfg), r.row.instance);
13591
13619
  }
13592
13620
  }
@@ -13596,7 +13624,7 @@ var init_prompt_registry = __esm({
13596
13624
  if (!pool.has(candidate)) return candidate;
13597
13625
  let n = 2;
13598
13626
  while (n <= MAX_DISAMBIGUATE_ATTEMPTS) {
13599
- const withN = (0, import_utils23.ensureMaxLen)(`${candidate}${(0, import_utils23.sepFor)(cfg2.case)}${n}`, cfg2.maxLen);
13627
+ const withN = (0, import_utils24.ensureMaxLen)(`${candidate}${(0, import_utils24.sepFor)(cfg2.case)}${n}`, cfg2.maxLen);
13600
13628
  if (!pool.has(withN)) return withN;
13601
13629
  n++;
13602
13630
  }
@@ -14202,12 +14230,12 @@ function stripFrontmatter(content) {
14202
14230
  const { body } = parseSkillMdFrontmatter(content);
14203
14231
  return body;
14204
14232
  }
14205
- var yaml, import_utils25;
14233
+ var yaml, import_utils26;
14206
14234
  var init_skill_md_parser = __esm({
14207
14235
  "libs/sdk/src/skill/skill-md-parser.ts"() {
14208
14236
  "use strict";
14209
14237
  yaml = __toESM(require("js-yaml"));
14210
- import_utils25 = require("@frontmcp/utils");
14238
+ import_utils26 = require("@frontmcp/utils");
14211
14239
  }
14212
14240
  });
14213
14241
 
@@ -14279,7 +14307,7 @@ async function loadInstructions(source, basePath) {
14279
14307
  }
14280
14308
  if (isFileInstructions(source)) {
14281
14309
  const filePath = basePath ? `${basePath}/${source.file}` : source.file;
14282
- const content = await (0, import_utils26.readFile)(filePath, "utf-8");
14310
+ const content = await (0, import_utils27.readFile)(filePath, "utf-8");
14283
14311
  return stripFrontmatter(content);
14284
14312
  }
14285
14313
  if (isUrlInstructions(source)) {
@@ -14291,12 +14319,16 @@ async function loadInstructions(source, basePath) {
14291
14319
  }
14292
14320
  throw new InvalidInstructionSourceError();
14293
14321
  }
14294
- function buildSkillContent(metadata, instructions) {
14322
+ function buildSkillContent(metadata, instructions, resolvedReferences) {
14323
+ let finalInstructions = instructions;
14324
+ if (resolvedReferences && resolvedReferences.length > 0) {
14325
+ finalInstructions += buildReferencesTable(resolvedReferences);
14326
+ }
14295
14327
  return {
14296
14328
  id: metadata.id ?? metadata.name,
14297
14329
  name: metadata.name,
14298
14330
  description: metadata.description,
14299
- instructions,
14331
+ instructions: finalInstructions,
14300
14332
  tools: normalizeToolRefs(metadata.tools),
14301
14333
  parameters: metadata.parameters,
14302
14334
  examples: metadata.examples,
@@ -14304,9 +14336,73 @@ function buildSkillContent(metadata, instructions) {
14304
14336
  compatibility: metadata.compatibility,
14305
14337
  specMetadata: metadata.specMetadata,
14306
14338
  allowedTools: metadata.allowedTools,
14307
- resources: metadata.resources
14339
+ resources: metadata.resources,
14340
+ resolvedReferences
14308
14341
  };
14309
14342
  }
14343
+ function buildReferencesTable(refs) {
14344
+ const lines = ["", "", "## References", "", "| Reference | Description |", "| --------- | ----------- |"];
14345
+ for (const ref of refs) {
14346
+ lines.push(`| \`${ref.name}\` | ${ref.description} |`);
14347
+ }
14348
+ return lines.join("\n");
14349
+ }
14350
+ async function resolveReferences(refsDir) {
14351
+ if (!await (0, import_utils27.fileExists)(refsDir)) return void 0;
14352
+ let files;
14353
+ try {
14354
+ files = (await (0, import_utils27.readdir)(refsDir)).filter((f) => f.endsWith(".md")).sort();
14355
+ } catch {
14356
+ return void 0;
14357
+ }
14358
+ if (files.length === 0) return void 0;
14359
+ const refs = [];
14360
+ for (const file of files) {
14361
+ const content = await (0, import_utils27.readFile)(`${refsDir}/${file}`, "utf-8");
14362
+ const filenameWithoutExt = file.replace(/\.md$/, "");
14363
+ let name33 = filenameWithoutExt;
14364
+ let description = "";
14365
+ const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
14366
+ if (fmMatch) {
14367
+ const fmLines = fmMatch[1].split(/\r?\n/);
14368
+ for (const line of fmLines) {
14369
+ const colonIdx = line.indexOf(":");
14370
+ if (colonIdx === -1) continue;
14371
+ const key = line.slice(0, colonIdx).trim();
14372
+ const val = line.slice(colonIdx + 1).trim().replace(/^["']|["']$/g, "");
14373
+ if (key === "name" && val) name33 = val;
14374
+ if (key === "description" && val) description = val;
14375
+ }
14376
+ }
14377
+ if (!description) {
14378
+ const body = fmMatch ? content.substring(content.indexOf("---", 3) + 3).trim() : content.trim();
14379
+ description = extractFirstParagraph(body);
14380
+ }
14381
+ refs.push({ name: name33, description, filename: file });
14382
+ }
14383
+ return refs;
14384
+ }
14385
+ function extractFirstParagraph(body) {
14386
+ const lines = body.split(/\r?\n/);
14387
+ let foundHeading = false;
14388
+ const paragraphLines = [];
14389
+ for (const line of lines) {
14390
+ const trimmed = line.trim();
14391
+ if (!foundHeading && trimmed.startsWith("#")) {
14392
+ foundHeading = true;
14393
+ continue;
14394
+ }
14395
+ if (foundHeading) {
14396
+ if (trimmed === "") {
14397
+ if (paragraphLines.length > 0) break;
14398
+ continue;
14399
+ }
14400
+ if (trimmed.startsWith("#") || trimmed.startsWith("|") || trimmed.startsWith("-")) break;
14401
+ paragraphLines.push(trimmed);
14402
+ }
14403
+ }
14404
+ return paragraphLines.join(" ").slice(0, 200) || "";
14405
+ }
14310
14406
  function normalizeToolRefs(tools) {
14311
14407
  if (!tools) return [];
14312
14408
  return tools.map((tool) => {
@@ -14415,13 +14511,13 @@ function generateSearchGuidance(skills, query) {
14415
14511
  }
14416
14512
  return `Found ${skills.length} skill(s), but some tools are missing. Try loadSkills({ skillIds: ["${topSkill.name}"] }) to see which tools are available. You may be able to partially execute the workflow.`;
14417
14513
  }
14418
- var import_di18, import_utils26;
14514
+ var import_di18, import_utils27;
14419
14515
  var init_skill_utils = __esm({
14420
14516
  "libs/sdk/src/skill/skill.utils.ts"() {
14421
14517
  "use strict";
14422
14518
  import_di18 = require("@frontmcp/di");
14423
14519
  init_common();
14424
- import_utils26 = require("@frontmcp/utils");
14520
+ import_utils27 = require("@frontmcp/utils");
14425
14521
  init_errors();
14426
14522
  init_skill_md_parser();
14427
14523
  }
@@ -14431,12 +14527,13 @@ var init_skill_utils = __esm({
14431
14527
  function createSkillInstance(record, providers, owner) {
14432
14528
  return new SkillInstance(record, providers, owner);
14433
14529
  }
14434
- var SkillInstance;
14530
+ var import_utils28, SkillInstance;
14435
14531
  var init_skill_instance = __esm({
14436
14532
  "libs/sdk/src/skill/skill.instance.ts"() {
14437
14533
  "use strict";
14438
14534
  init_common();
14439
14535
  init_skill_utils();
14536
+ import_utils28 = require("@frontmcp/utils");
14440
14537
  SkillInstance = class extends SkillEntry {
14441
14538
  /** The provider registry this skill is bound to */
14442
14539
  providersRef;
@@ -14499,12 +14596,33 @@ var init_skill_instance = __esm({
14499
14596
  * Load the full skill content.
14500
14597
  * Results are cached after the first load.
14501
14598
  */
14599
+ /**
14600
+ * Resolve the base directory for this skill (for file/reference resolution).
14601
+ */
14602
+ getBaseDir() {
14603
+ if (this.record.kind === "FILE" /* FILE */) {
14604
+ return (0, import_utils28.dirname)(this.record.filePath) || void 0;
14605
+ }
14606
+ if (this.record.kind === "VALUE" /* VALUE */ && this.record.callerDir) {
14607
+ return this.record.callerDir;
14608
+ }
14609
+ return void 0;
14610
+ }
14502
14611
  async load() {
14503
14612
  if (this.cachedContent !== void 0) {
14504
14613
  return this.cachedContent;
14505
14614
  }
14506
14615
  const instructions = await this.loadInstructions();
14507
- const baseContent = buildSkillContent(this.metadata, instructions);
14616
+ const refsPath = this.metadata.resources?.references;
14617
+ let resolvedRefs;
14618
+ if (refsPath) {
14619
+ const baseDir = this.getBaseDir();
14620
+ const refsDir = refsPath.startsWith("/") ? refsPath : baseDir ? (0, import_utils28.pathResolve)(baseDir, refsPath) : void 0;
14621
+ if (refsDir) {
14622
+ resolvedRefs = await resolveReferences(refsDir);
14623
+ }
14624
+ }
14625
+ const baseContent = buildSkillContent(this.metadata, instructions, resolvedRefs);
14508
14626
  this.cachedContent = {
14509
14627
  ...baseContent,
14510
14628
  tags: this.tags,
@@ -17492,7 +17610,7 @@ function resolveApiKey(config, configResolver, entityContext) {
17492
17610
  return config;
17493
17611
  }
17494
17612
  if ("env" in config) {
17495
- const value = (0, import_utils27.getEnv)(config.env);
17613
+ const value = (0, import_utils29.getEnv)(config.env);
17496
17614
  if (!value) {
17497
17615
  throw new LlmAdapterError(`Environment variable ${config.env} is not set`, "config", "missing_env_var");
17498
17616
  }
@@ -17620,11 +17738,11 @@ function createBuiltinAdapter(config, configResolver, entityContext) {
17620
17738
  maxTokens
17621
17739
  });
17622
17740
  }
17623
- var import_utils27;
17741
+ var import_utils29;
17624
17742
  var init_adapter_factory = __esm({
17625
17743
  "libs/sdk/src/agent/adapters/adapter.factory.ts"() {
17626
17744
  "use strict";
17627
- import_utils27 = require("@frontmcp/utils");
17745
+ import_utils29 = require("@frontmcp/utils");
17628
17746
  init_base_adapter();
17629
17747
  init_providers();
17630
17748
  init_config_resolver();
@@ -17690,16 +17808,16 @@ function parseEnvContent(content) {
17690
17808
  }
17691
17809
  return result;
17692
17810
  }
17693
- async function loadEnvFiles(basePath = (0, import_utils28.getCwd)(), envPath = ".env", localEnvPath = ".env.local") {
17811
+ async function loadEnvFiles(basePath = (0, import_utils30.getCwd)(), envPath = ".env", localEnvPath = ".env.local") {
17694
17812
  const result = {};
17695
- const envFile = (0, import_utils28.pathResolve)(basePath, envPath);
17696
- if (await (0, import_utils28.fileExists)(envFile)) {
17697
- const content = await (0, import_utils28.readFile)(envFile);
17813
+ const envFile = (0, import_utils30.pathResolve)(basePath, envPath);
17814
+ if (await (0, import_utils30.fileExists)(envFile)) {
17815
+ const content = await (0, import_utils30.readFile)(envFile);
17698
17816
  Object.assign(result, parseEnvContent(content));
17699
17817
  }
17700
- const localFile = (0, import_utils28.pathResolve)(basePath, localEnvPath);
17701
- if (await (0, import_utils28.fileExists)(localFile)) {
17702
- const content = await (0, import_utils28.readFile)(localFile);
17818
+ const localFile = (0, import_utils30.pathResolve)(basePath, localEnvPath);
17819
+ if (await (0, import_utils30.fileExists)(localFile)) {
17820
+ const content = await (0, import_utils30.readFile)(localFile);
17703
17821
  Object.assign(result, parseEnvContent(content));
17704
17822
  }
17705
17823
  return result;
@@ -17709,8 +17827,8 @@ function parseEnvContentSync(content) {
17709
17827
  }
17710
17828
  function populateProcessEnv(env, override = false) {
17711
17829
  for (const [key, value] of Object.entries(env)) {
17712
- if (override || (0, import_utils28.getEnv)(key) === void 0) {
17713
- (0, import_utils28.setEnv)(key, value);
17830
+ if (override || (0, import_utils30.getEnv)(key) === void 0) {
17831
+ (0, import_utils30.setEnv)(key, value);
17714
17832
  }
17715
17833
  }
17716
17834
  }
@@ -17809,11 +17927,11 @@ function mapEnvToNestedConfig(env, paths) {
17809
17927
  }
17810
17928
  return result;
17811
17929
  }
17812
- var import_utils28, UNSAFE_KEYS;
17930
+ var import_utils30, UNSAFE_KEYS;
17813
17931
  var init_env_loader = __esm({
17814
17932
  "libs/sdk/src/builtin/config/providers/env-loader.ts"() {
17815
17933
  "use strict";
17816
- import_utils28 = require("@frontmcp/utils");
17934
+ import_utils30 = require("@frontmcp/utils");
17817
17935
  UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
17818
17936
  }
17819
17937
  });
@@ -17821,7 +17939,7 @@ var init_env_loader = __esm({
17821
17939
  // libs/sdk/src/builtin/config/providers/config-loader.ts
17822
17940
  async function loadConfig(schema, options = {}) {
17823
17941
  const {
17824
- basePath = (0, import_utils29.getCwd)(),
17942
+ basePath = (0, import_utils31.getCwd)(),
17825
17943
  envPath = ".env",
17826
17944
  localEnvPath = ".env.local",
17827
17945
  configPath = "config.yml",
@@ -17859,9 +17977,9 @@ async function loadYamlConfig(basePath, configPath) {
17859
17977
  const extensions = ["", ".yml", ".yaml"];
17860
17978
  const baseName = configPath.replace(/\.(ya?ml)$/, "");
17861
17979
  for (const ext of extensions) {
17862
- const fullPath = (0, import_utils29.pathResolve)(basePath, baseName + ext);
17863
- if (await (0, import_utils29.fileExists)(fullPath)) {
17864
- const content = await (0, import_utils29.readFile)(fullPath);
17980
+ const fullPath = (0, import_utils31.pathResolve)(basePath, baseName + ext);
17981
+ if (await (0, import_utils31.fileExists)(fullPath)) {
17982
+ const content = await (0, import_utils31.readFile)(fullPath);
17865
17983
  const parsed = yaml2.load(content);
17866
17984
  if (parsed && typeof parsed === "object") {
17867
17985
  return parsed;
@@ -17886,24 +18004,24 @@ function deepMerge(target, source) {
17886
18004
  }
17887
18005
  return result;
17888
18006
  }
17889
- var yaml2, import_utils29;
18007
+ var yaml2, import_utils31;
17890
18008
  var init_config_loader = __esm({
17891
18009
  "libs/sdk/src/builtin/config/providers/config-loader.ts"() {
17892
18010
  "use strict";
17893
18011
  yaml2 = __toESM(require("js-yaml"));
17894
- import_utils29 = require("@frontmcp/utils");
18012
+ import_utils31 = require("@frontmcp/utils");
17895
18013
  init_env_loader();
17896
18014
  init_config_service();
17897
18015
  }
17898
18016
  });
17899
18017
 
17900
18018
  // libs/sdk/src/builtin/config/config.plugin.ts
17901
- var import_utils30, ConfigPlugin;
18019
+ var import_utils32, ConfigPlugin;
17902
18020
  var init_config_plugin = __esm({
17903
18021
  "libs/sdk/src/builtin/config/config.plugin.ts"() {
17904
18022
  "use strict";
17905
18023
  init_common();
17906
- import_utils30 = require("@frontmcp/utils");
18024
+ import_utils32 = require("@frontmcp/utils");
17907
18025
  init_config_symbols();
17908
18026
  init_config_service();
17909
18027
  init_config_loader();
@@ -17961,7 +18079,7 @@ var init_config_plugin = __esm({
17961
18079
  }
17962
18080
  let env = {};
17963
18081
  if (pluginConfig.loadEnv) {
17964
- const basePath = pluginConfig.basePath ?? (0, import_utils30.getCwd)();
18082
+ const basePath = pluginConfig.basePath ?? (0, import_utils32.getCwd)();
17965
18083
  env = await loadEnvFiles(basePath, pluginConfig.envPath, pluginConfig.localEnvPath);
17966
18084
  }
17967
18085
  const merged = { ...env };
@@ -18174,7 +18292,7 @@ function stringToBytes(str, encoding) {
18174
18292
  return new TextEncoder().encode(str);
18175
18293
  }
18176
18294
  try {
18177
- return (0, import_utils31.base64Decode)(str);
18295
+ return (0, import_utils33.base64Decode)(str);
18178
18296
  } catch (err) {
18179
18297
  throw new Error(`Invalid base64 body: ${err instanceof Error ? err.message : String(err)}`);
18180
18298
  }
@@ -18300,12 +18418,12 @@ async function writeHttpResponse(res, value) {
18300
18418
  }
18301
18419
  }
18302
18420
  }
18303
- var import_utils31;
18421
+ var import_utils33;
18304
18422
  var init_server_validation = __esm({
18305
18423
  "libs/sdk/src/server/server.validation.ts"() {
18306
18424
  "use strict";
18307
18425
  init_common();
18308
- import_utils31 = require("@frontmcp/utils");
18426
+ import_utils33 = require("@frontmcp/utils");
18309
18427
  }
18310
18428
  });
18311
18429
 
@@ -18318,7 +18436,7 @@ function parseTypedKey(k) {
18318
18436
  return { base: k.slice(6, 7).toLowerCase() + k.slice(7), type: "around" };
18319
18437
  return { base: k };
18320
18438
  }
18321
- var import_reflect_metadata11, import_utils32, CAP, WILL, DID, AROUND, FlowInstance;
18439
+ var import_reflect_metadata11, import_utils34, CAP, WILL, DID, AROUND, FlowInstance;
18322
18440
  var init_flow_instance = __esm({
18323
18441
  "libs/sdk/src/flows/flow.instance.ts"() {
18324
18442
  "use strict";
@@ -18328,7 +18446,7 @@ var init_flow_instance = __esm({
18328
18446
  init_server_validation();
18329
18447
  init_context();
18330
18448
  init_errors();
18331
- import_utils32 = require("@frontmcp/utils");
18449
+ import_utils34 = require("@frontmcp/utils");
18332
18450
  CAP = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
18333
18451
  WILL = (s) => `will${CAP(s)}`;
18334
18452
  DID = (s) => `did${CAP(s)}`;
@@ -18438,7 +18556,7 @@ var init_flow_instance = __esm({
18438
18556
  }
18439
18557
  const headers = request.headers ?? {};
18440
18558
  const headerSessionId = typeof headers["mcp-session-id"] === "string" ? headers["mcp-session-id"].trim() : "";
18441
- const sessionId = headerSessionId.length > 0 ? headerSessionId : `anon:${(0, import_utils32.randomUUID)()}`;
18559
+ const sessionId = headerSessionId.length > 0 ? headerSessionId : `anon:${(0, import_utils34.randomUUID)()}`;
18442
18560
  const scope = this.globalProviders.getActiveScope();
18443
18561
  return storage.runFromHeaders(
18444
18562
  headers,
@@ -18682,7 +18800,7 @@ var init_flow_instance = __esm({
18682
18800
  });
18683
18801
 
18684
18802
  // libs/sdk/src/flows/flow.registry.ts
18685
- var import_di22, import_utils33, FlowRegistry;
18803
+ var import_di22, import_utils35, FlowRegistry;
18686
18804
  var init_flow_registry = __esm({
18687
18805
  "libs/sdk/src/flows/flow.registry.ts"() {
18688
18806
  "use strict";
@@ -18692,7 +18810,7 @@ var init_flow_registry = __esm({
18692
18810
  init_flow_utils2();
18693
18811
  init_flow_instance();
18694
18812
  init_context();
18695
- import_utils33 = require("@frontmcp/utils");
18813
+ import_utils35 = require("@frontmcp/utils");
18696
18814
  init_errors();
18697
18815
  FlowRegistry = class extends RegistryAbstract {
18698
18816
  constructor(providers, list) {
@@ -18771,7 +18889,7 @@ var init_flow_registry = __esm({
18771
18889
  const mcpCtx = input?.ctx;
18772
18890
  const authInfo = mcpCtx?.authInfo;
18773
18891
  const rawSessionId = authInfo?.sessionId;
18774
- const sessionId = typeof rawSessionId === "string" && rawSessionId.trim().length > 0 ? rawSessionId.trim() : `anon:${(0, import_utils33.randomUUID)()}`;
18892
+ const sessionId = typeof rawSessionId === "string" && rawSessionId.trim().length > 0 ? rawSessionId.trim() : `anon:${(0, import_utils35.randomUUID)()}`;
18775
18893
  const scope = this.providers.getActiveScope();
18776
18894
  return Promise.resolve(
18777
18895
  contextStorage.run(
@@ -20159,12 +20277,12 @@ var init_agent_registry = __esm({
20159
20277
  });
20160
20278
 
20161
20279
  // libs/sdk/src/app/instances/app.local.instance.ts
20162
- var import_utils34, AppLocalInstance;
20280
+ var import_utils36, AppLocalInstance;
20163
20281
  var init_app_local_instance = __esm({
20164
20282
  "libs/sdk/src/app/instances/app.local.instance.ts"() {
20165
20283
  "use strict";
20166
20284
  init_common();
20167
- import_utils34 = require("@frontmcp/utils");
20285
+ import_utils36 = require("@frontmcp/utils");
20168
20286
  init_provider_registry();
20169
20287
  init_tool_registry();
20170
20288
  init_resource_registry();
@@ -20188,7 +20306,7 @@ var init_app_local_instance = __esm({
20188
20306
  constructor(record, scopeProviders) {
20189
20307
  super(record);
20190
20308
  this.scopeProviders = scopeProviders;
20191
- this.id = this.metadata.id ?? (0, import_utils34.idFromString)(this.metadata.name);
20309
+ this.id = this.metadata.id ?? (0, import_utils36.idFromString)(this.metadata.name);
20192
20310
  try {
20193
20311
  this.logger = scopeProviders.get(FrontMcpLogger)?.child("AppLocalInstance");
20194
20312
  } catch {
@@ -21892,12 +22010,12 @@ var init_remote_mcp = __esm({
21892
22010
  });
21893
22011
 
21894
22012
  // libs/sdk/src/app/instances/app.remote.instance.ts
21895
- var import_utils35, EmptyPluginRegistry, EmptyAdapterRegistry, EmptySkillRegistry, AppRemoteInstance;
22013
+ var import_utils37, EmptyPluginRegistry, EmptyAdapterRegistry, EmptySkillRegistry, AppRemoteInstance;
21896
22014
  var init_app_remote_instance = __esm({
21897
22015
  "libs/sdk/src/app/instances/app.remote.instance.ts"() {
21898
22016
  "use strict";
21899
22017
  init_common();
21900
- import_utils35 = require("@frontmcp/utils");
22018
+ import_utils37 = require("@frontmcp/utils");
21901
22019
  init_tool_registry();
21902
22020
  init_resource_registry();
21903
22021
  init_prompt_registry();
@@ -21998,7 +22116,7 @@ var init_app_remote_instance = __esm({
21998
22116
  _unsubscribeCapability;
21999
22117
  constructor(record, scopeProviders) {
22000
22118
  super(record);
22001
- this.id = this.metadata.id ?? (0, import_utils35.idFromString)(this.metadata.name);
22119
+ this.id = this.metadata.id ?? (0, import_utils37.idFromString)(this.metadata.name);
22002
22120
  this.scopeProviders = scopeProviders;
22003
22121
  this.appOwner = {
22004
22122
  kind: "app",
@@ -22400,11 +22518,11 @@ function getDefaultCacheDir() {
22400
22518
  return "";
22401
22519
  }
22402
22520
  }
22403
- var import_utils36, DEFAULT_CACHE_DIR, DEFAULT_MAX_AGE_MS, EsmCacheManager;
22521
+ var import_utils38, DEFAULT_CACHE_DIR, DEFAULT_MAX_AGE_MS, EsmCacheManager;
22404
22522
  var init_esm_cache = __esm({
22405
22523
  "libs/sdk/src/esm-loader/esm-cache.ts"() {
22406
22524
  "use strict";
22407
- import_utils36 = require("@frontmcp/utils");
22525
+ import_utils38 = require("@frontmcp/utils");
22408
22526
  DEFAULT_CACHE_DIR = getDefaultCacheDir();
22409
22527
  DEFAULT_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
22410
22528
  EsmCacheManager = class {
@@ -22430,10 +22548,10 @@ var init_esm_cache = __esm({
22430
22548
  if (!this.cacheDir) return void 0;
22431
22549
  try {
22432
22550
  const path = require("node:path");
22433
- const { fileExists: fileExists5, readJSON } = require("@frontmcp/utils");
22551
+ const { fileExists: fileExists6, readJSON } = require("@frontmcp/utils");
22434
22552
  const entryDir = this.getEntryDir(packageName, version);
22435
22553
  const metaPath = path.join(entryDir, "meta.json");
22436
- if (!await fileExists5(metaPath)) {
22554
+ if (!await fileExists6(metaPath)) {
22437
22555
  return void 0;
22438
22556
  }
22439
22557
  const meta = await readJSON(metaPath);
@@ -22443,7 +22561,7 @@ var init_esm_cache = __esm({
22443
22561
  if (Date.now() - meta.cachedAt > this.maxAgeMs) {
22444
22562
  return void 0;
22445
22563
  }
22446
- if (!await fileExists5(meta.bundlePath)) {
22564
+ if (!await fileExists6(meta.bundlePath)) {
22447
22565
  return void 0;
22448
22566
  }
22449
22567
  this.memoryStore.set(memKey, meta);
@@ -22456,7 +22574,7 @@ var init_esm_cache = __esm({
22456
22574
  * Store an ESM bundle in the cache.
22457
22575
  */
22458
22576
  async put(packageName, version, bundleContent, packageUrl, etag) {
22459
- if (!(0, import_utils36.isValidMcpUri)(packageUrl)) {
22577
+ if (!(0, import_utils38.isValidMcpUri)(packageUrl)) {
22460
22578
  throw new Error("URI must have a valid scheme (e.g., file://, https://, custom://)");
22461
22579
  }
22462
22580
  const memKey = `${packageName}@${version}`;
@@ -22507,20 +22625,20 @@ var init_esm_cache = __esm({
22507
22625
  if (!this.cacheDir) return;
22508
22626
  try {
22509
22627
  const path = require("node:path");
22510
- const { fileExists: fileExists5, readJSON, rm } = require("@frontmcp/utils");
22511
- const { readdir } = require("@frontmcp/utils");
22512
- if (!await fileExists5(this.cacheDir)) {
22628
+ const { fileExists: fileExists6, readJSON, rm } = require("@frontmcp/utils");
22629
+ const { readdir: readdir2 } = require("@frontmcp/utils");
22630
+ if (!await fileExists6(this.cacheDir)) {
22513
22631
  return;
22514
22632
  }
22515
22633
  let entries;
22516
22634
  try {
22517
- entries = await readdir(this.cacheDir);
22635
+ entries = await readdir2(this.cacheDir);
22518
22636
  } catch {
22519
22637
  return;
22520
22638
  }
22521
22639
  for (const dirEntry of entries) {
22522
22640
  const metaPath = path.join(this.cacheDir, dirEntry, "meta.json");
22523
- if (await fileExists5(metaPath)) {
22641
+ if (await fileExists6(metaPath)) {
22524
22642
  const meta = await readJSON(metaPath);
22525
22643
  if (meta?.packageName === packageName) {
22526
22644
  await rm(path.join(this.cacheDir, dirEntry), { recursive: true, force: true });
@@ -22546,20 +22664,20 @@ var init_esm_cache = __esm({
22546
22664
  if (!this.cacheDir) return removed;
22547
22665
  try {
22548
22666
  const path = require("node:path");
22549
- const { fileExists: fileExists5, readJSON, rm } = require("@frontmcp/utils");
22550
- const { readdir } = require("@frontmcp/utils");
22551
- if (!await fileExists5(this.cacheDir)) {
22667
+ const { fileExists: fileExists6, readJSON, rm } = require("@frontmcp/utils");
22668
+ const { readdir: readdir2 } = require("@frontmcp/utils");
22669
+ if (!await fileExists6(this.cacheDir)) {
22552
22670
  return removed;
22553
22671
  }
22554
22672
  let entries;
22555
22673
  try {
22556
- entries = await readdir(this.cacheDir);
22674
+ entries = await readdir2(this.cacheDir);
22557
22675
  } catch {
22558
22676
  return removed;
22559
22677
  }
22560
22678
  for (const dirEntry of entries) {
22561
22679
  const metaPath = path.join(this.cacheDir, dirEntry, "meta.json");
22562
- if (await fileExists5(metaPath)) {
22680
+ if (await fileExists6(metaPath)) {
22563
22681
  const meta = await readJSON(metaPath);
22564
22682
  if (meta && now - meta.cachedAt > threshold) {
22565
22683
  await rm(path.join(this.cacheDir, dirEntry), { recursive: true, force: true });
@@ -22586,7 +22704,7 @@ var init_esm_cache = __esm({
22586
22704
  */
22587
22705
  getEntryDir(packageName, version) {
22588
22706
  const path = require("node:path");
22589
- const hash = (0, import_utils36.sha256Hex)(`${packageName}@${version}`);
22707
+ const hash = (0, import_utils38.sha256Hex)(`${packageName}@${version}`);
22590
22708
  return path.join(this.cacheDir, hash);
22591
22709
  }
22592
22710
  };
@@ -22637,7 +22755,7 @@ function normalizeResourceFromEsmExport(raw) {
22637
22755
  const obj = raw;
22638
22756
  if (typeof obj["read"] === "function" && typeof obj["name"] === "string" && typeof obj["uri"] === "string") {
22639
22757
  const uri = obj["uri"];
22640
- if (!(0, import_utils37.isValidMcpUri)(uri)) return void 0;
22758
+ if (!(0, import_utils39.isValidMcpUri)(uri)) return void 0;
22641
22759
  const description = obj["description"];
22642
22760
  const mimeType = obj["mimeType"];
22643
22761
  return {
@@ -22665,12 +22783,12 @@ function normalizePromptFromEsmExport(raw) {
22665
22783
  }
22666
22784
  return void 0;
22667
22785
  }
22668
- var import_di25, import_utils37;
22786
+ var import_di25, import_utils39;
22669
22787
  var init_esm_normalize_utils = __esm({
22670
22788
  "libs/sdk/src/app/instances/esm-normalize.utils.ts"() {
22671
22789
  "use strict";
22672
22790
  import_di25 = require("@frontmcp/di");
22673
- import_utils37 = require("@frontmcp/utils");
22791
+ import_utils39 = require("@frontmcp/utils");
22674
22792
  init_tokens();
22675
22793
  }
22676
22794
  });
@@ -23441,12 +23559,12 @@ var init_esm_loader = __esm({
23441
23559
  });
23442
23560
 
23443
23561
  // libs/sdk/src/app/instances/app.esm.instance.ts
23444
- var import_utils38, EmptyPluginRegistry2, EmptyAdapterRegistry2, EmptySkillRegistry2, AppEsmInstance;
23562
+ var import_utils40, EmptyPluginRegistry2, EmptyAdapterRegistry2, EmptySkillRegistry2, AppEsmInstance;
23445
23563
  var init_app_esm_instance = __esm({
23446
23564
  "libs/sdk/src/app/instances/app.esm.instance.ts"() {
23447
23565
  "use strict";
23448
23566
  init_common();
23449
- import_utils38 = require("@frontmcp/utils");
23567
+ import_utils40 = require("@frontmcp/utils");
23450
23568
  init_tool_registry();
23451
23569
  init_resource_registry();
23452
23570
  init_prompt_registry();
@@ -23547,7 +23665,7 @@ var init_app_esm_instance = __esm({
23547
23665
  _skills;
23548
23666
  constructor(record, scopeProviders) {
23549
23667
  super(record);
23550
- this.id = this.metadata.id ?? (0, import_utils38.idFromString)(this.metadata.name);
23668
+ this.id = this.metadata.id ?? (0, import_utils40.idFromString)(this.metadata.name);
23551
23669
  this.scopeProviders = scopeProviders;
23552
23670
  this.appOwner = {
23553
23671
  kind: "app",
@@ -24313,7 +24431,7 @@ function createSessionId(protocol, token, options) {
24313
24431
  const payload = {
24314
24432
  nodeId: (0, import_auth14.getMachineId)(),
24315
24433
  authSig,
24316
- uuid: (0, import_utils39.randomUUID)(),
24434
+ uuid: (0, import_utils41.randomUUID)(),
24317
24435
  iat: nowSec(),
24318
24436
  protocol,
24319
24437
  platformType,
@@ -24342,11 +24460,11 @@ function updateSessionPayload(sessionId, updates) {
24342
24460
  cache.set(newSessionId, payload);
24343
24461
  return newSessionId;
24344
24462
  }
24345
- var import_utils39, import_auth13, import_auth14, cache;
24463
+ var import_utils41, import_auth13, import_auth14, cache;
24346
24464
  var init_session_id_utils = __esm({
24347
24465
  "libs/sdk/src/auth/session/utils/session-id.utils.ts"() {
24348
24466
  "use strict";
24349
- import_utils39 = require("@frontmcp/utils");
24467
+ import_utils41 = require("@frontmcp/utils");
24350
24468
  import_auth13 = require("@frontmcp/auth");
24351
24469
  init_notification_service();
24352
24470
  import_auth14 = require("@frontmcp/auth");
@@ -24355,7 +24473,7 @@ var init_session_id_utils = __esm({
24355
24473
  });
24356
24474
 
24357
24475
  // libs/sdk/src/auth/flows/session.verify.flow.ts
24358
- var import_reflect_metadata17, import_zod54, import_auth15, import_auth16, import_auth17, import_auth18, import_utils40, inputSchema14, stateSchema12, UnauthorizedSchema, AuthorizedSchema, sessionVerifyOutputSchema, plan12, name13, Stage13, SessionVerifyFlow;
24476
+ var import_reflect_metadata17, import_zod54, import_auth15, import_auth16, import_auth17, import_auth18, import_utils42, inputSchema14, stateSchema12, UnauthorizedSchema, AuthorizedSchema, sessionVerifyOutputSchema, plan12, name13, Stage13, SessionVerifyFlow;
24359
24477
  var init_session_verify_flow = __esm({
24360
24478
  "libs/sdk/src/auth/flows/session.verify.flow.ts"() {
24361
24479
  "use strict";
@@ -24367,7 +24485,7 @@ var init_session_verify_flow = __esm({
24367
24485
  init_session_id_utils();
24368
24486
  import_auth17 = require("@frontmcp/auth");
24369
24487
  import_auth18 = require("@frontmcp/auth");
24370
- import_utils40 = require("@frontmcp/utils");
24488
+ import_utils42 = require("@frontmcp/utils");
24371
24489
  init_notification_service();
24372
24490
  inputSchema14 = httpRequestInputSchema;
24373
24491
  stateSchema12 = import_zod54.z.object({
@@ -24418,7 +24536,7 @@ var init_session_verify_flow = __esm({
24418
24536
  const machineId = (0, import_auth18.getMachineId)();
24419
24537
  if (sessionIdHeader) {
24420
24538
  const existingPayload = decryptPublicSession(sessionIdHeader);
24421
- const user2 = existingPayload ? { sub: `anon:${existingPayload.iat * 1e3}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") } : { sub: `anon:${(0, import_utils40.randomUUID)()}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") };
24539
+ const user2 = existingPayload ? { sub: `anon:${existingPayload.iat * 1e3}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") } : { sub: `anon:${(0, import_utils42.randomUUID)()}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") };
24422
24540
  const finalPayload = existingPayload && existingPayload.nodeId === machineId ? existingPayload : void 0;
24423
24541
  this.respond({
24424
24542
  kind: "authorized",
@@ -24435,12 +24553,12 @@ var init_session_verify_flow = __esm({
24435
24553
  }
24436
24554
  const now = Date.now();
24437
24555
  const user = {
24438
- sub: `anon:${(0, import_utils40.randomUUID)()}`,
24556
+ sub: `anon:${(0, import_utils42.randomUUID)()}`,
24439
24557
  iss: issuer,
24440
24558
  name: "Anonymous",
24441
24559
  scope: scopes.join(" ")
24442
24560
  };
24443
- const uuid = (0, import_utils40.randomUUID)();
24561
+ const uuid = (0, import_utils42.randomUUID)();
24444
24562
  const platformDetectionConfig = this.scope.metadata.transport?.platformDetection;
24445
24563
  const platformType = detectPlatformFromUserAgent(this.state.userAgent, platformDetectionConfig);
24446
24564
  const payload = {
@@ -25517,13 +25635,13 @@ var init_oauth_authorize_flow = __esm({
25517
25635
  });
25518
25636
 
25519
25637
  // libs/sdk/src/auth/flows/oauth.register.flow.ts
25520
- var import_zod56, import_utils41, CLIENTS, inputSchema16, outputSchema14, registrationRequestSchema, stateSchema14, plan14, name15, Stage15, OauthRegisterFlow;
25638
+ var import_zod56, import_utils43, CLIENTS, inputSchema16, outputSchema14, registrationRequestSchema, stateSchema14, plan14, name15, Stage15, OauthRegisterFlow;
25521
25639
  var init_oauth_register_flow = __esm({
25522
25640
  "libs/sdk/src/auth/flows/oauth.register.flow.ts"() {
25523
25641
  "use strict";
25524
25642
  init_common();
25525
25643
  import_zod56 = require("zod");
25526
- import_utils41 = require("@frontmcp/utils");
25644
+ import_utils43 = require("@frontmcp/utils");
25527
25645
  CLIENTS = /* @__PURE__ */ new Map();
25528
25646
  inputSchema16 = httpInputSchema;
25529
25647
  outputSchema14 = HttpJsonSchema;
@@ -25550,7 +25668,7 @@ var init_oauth_register_flow = __esm({
25550
25668
  OauthRegisterFlow = class extends FlowBase {
25551
25669
  registered;
25552
25670
  async parseInput() {
25553
- const isDev = !(0, import_utils41.isProduction)();
25671
+ const isDev = !(0, import_utils43.isProduction)();
25554
25672
  const { request } = this.rawInput;
25555
25673
  const parsed = registrationRequestSchema.parse(request.body || {});
25556
25674
  this.state.set({
@@ -25617,10 +25735,10 @@ var init_oauth_register_flow = __esm({
25617
25735
  async registerClient() {
25618
25736
  const now = Math.floor(Date.now() / 1e3);
25619
25737
  const { token_endpoint_auth_method, grant_types, response_types, redirect_uris, client_name, scope } = this.state.required.body;
25620
- const client_id = (0, import_utils41.randomUUID)();
25738
+ const client_id = (0, import_utils43.randomUUID)();
25621
25739
  let client_secret;
25622
25740
  if (token_endpoint_auth_method === "client_secret_post" || token_endpoint_auth_method === "client_secret_basic") {
25623
- client_secret = (0, import_utils41.base64urlEncode)((0, import_utils41.randomBytes)(24));
25741
+ client_secret = (0, import_utils43.base64urlEncode)((0, import_utils43.randomBytes)(24));
25624
25742
  }
25625
25743
  this.registered = {
25626
25744
  client_id,
@@ -25689,13 +25807,13 @@ var init_oauth_register_flow = __esm({
25689
25807
  });
25690
25808
 
25691
25809
  // libs/sdk/src/auth/flows/oauth.token.flow.ts
25692
- var import_zod57, import_utils42, inputSchema17, pkceVerifierRegex, authorizationCodeGrant, refreshTokenGrant, anonymousGrant, tokenRequestSchema, stateSchema15, outputSchema15, plan15, name16, Stage16, OauthTokenFlow;
25810
+ var import_zod57, import_utils44, inputSchema17, pkceVerifierRegex, authorizationCodeGrant, refreshTokenGrant, anonymousGrant, tokenRequestSchema, stateSchema15, outputSchema15, plan15, name16, Stage16, OauthTokenFlow;
25693
25811
  var init_oauth_token_flow = __esm({
25694
25812
  "libs/sdk/src/auth/flows/oauth.token.flow.ts"() {
25695
25813
  "use strict";
25696
25814
  init_common();
25697
25815
  import_zod57 = require("zod");
25698
- import_utils42 = require("@frontmcp/utils");
25816
+ import_utils44 = require("@frontmcp/utils");
25699
25817
  inputSchema17 = httpInputSchema;
25700
25818
  pkceVerifierRegex = /^[A-Za-z0-9_.~-]{43,128}$/;
25701
25819
  authorizationCodeGrant = import_zod57.z.object({
@@ -25802,7 +25920,7 @@ var init_oauth_token_flow = __esm({
25802
25920
  access_token: accessToken,
25803
25921
  token_type: "Bearer",
25804
25922
  expires_in: 86400,
25805
- refresh_token: (0, import_utils42.randomUUID)()
25923
+ refresh_token: (0, import_utils44.randomUUID)()
25806
25924
  });
25807
25925
  return;
25808
25926
  }
@@ -25839,7 +25957,7 @@ var init_oauth_token_flow = __esm({
25839
25957
  access_token: accessToken,
25840
25958
  token_type: "Bearer",
25841
25959
  expires_in: 86400,
25842
- refresh_token: (0, import_utils42.randomUUID)()
25960
+ refresh_token: (0, import_utils44.randomUUID)()
25843
25961
  });
25844
25962
  return;
25845
25963
  }
@@ -25873,7 +25991,7 @@ var init_oauth_token_flow = __esm({
25873
25991
  access_token: accessToken,
25874
25992
  token_type: "Bearer",
25875
25993
  expires_in: 86400,
25876
- refresh_token: (0, import_utils42.randomUUID)()
25994
+ refresh_token: (0, import_utils44.randomUUID)()
25877
25995
  });
25878
25996
  }
25879
25997
  async buildTokenResponse() {
@@ -25940,13 +26058,13 @@ var init_oauth_token_flow = __esm({
25940
26058
  });
25941
26059
 
25942
26060
  // libs/sdk/src/auth/flows/oauth.callback.flow.ts
25943
- var import_zod58, import_utils43, import_auth22, inputSchema18, stateSchema16, outputSchema16, plan16, name17, Stage17, OauthCallbackFlow;
26061
+ var import_zod58, import_utils45, import_auth22, inputSchema18, stateSchema16, outputSchema16, plan16, name17, Stage17, OauthCallbackFlow;
25944
26062
  var init_oauth_callback_flow = __esm({
25945
26063
  "libs/sdk/src/auth/flows/oauth.callback.flow.ts"() {
25946
26064
  "use strict";
25947
26065
  init_common();
25948
26066
  import_zod58 = require("zod");
25949
- import_utils43 = require("@frontmcp/utils");
26067
+ import_utils45 = require("@frontmcp/utils");
25950
26068
  import_auth22 = require("@frontmcp/auth");
25951
26069
  inputSchema18 = httpInputSchema;
25952
26070
  stateSchema16 = import_zod58.z.object({
@@ -26158,7 +26276,7 @@ var init_oauth_callback_flow = __esm({
26158
26276
  return;
26159
26277
  }
26160
26278
  const federatedSession = (0, import_auth22.createFederatedAuthSession)({
26161
- pendingAuthId: this.state.required.pendingAuthId || (0, import_utils43.randomUUID)(),
26279
+ pendingAuthId: this.state.required.pendingAuthId || (0, import_utils45.randomUUID)(),
26162
26280
  clientId,
26163
26281
  redirectUri,
26164
26282
  scopes: scopes ?? [],
@@ -26178,14 +26296,14 @@ var init_oauth_callback_flow = __esm({
26178
26296
  await sessionStore.store(federatedSession);
26179
26297
  this.logger.info(`Created federated session: ${federatedSession.id}`);
26180
26298
  const firstProviderId = selectedProviders[0];
26181
- const verifier = (0, import_utils43.generateCodeVerifier)();
26182
- const challenge = (0, import_utils43.sha256Base64url)(verifier);
26299
+ const verifier = (0, import_utils45.generateCodeVerifier)();
26300
+ const challenge = (0, import_utils45.sha256Base64url)(verifier);
26183
26301
  const pkce = {
26184
26302
  verifier,
26185
26303
  challenge,
26186
26304
  method: "S256"
26187
26305
  };
26188
- const providerState = `federated:${federatedSession.id}:${(0, import_utils43.randomUUID)()}`;
26306
+ const providerState = `federated:${federatedSession.id}:${(0, import_utils45.randomUUID)()}`;
26189
26307
  (0, import_auth22.startNextProvider)(federatedSession, pkce, providerState);
26190
26308
  await sessionStore.update(federatedSession);
26191
26309
  const providerConfig = localAuth.getProviderConfig(firstProviderId);
@@ -26306,7 +26424,7 @@ var init_oauth_callback_flow = __esm({
26306
26424
  * In production, this would be the user's ID from the database
26307
26425
  */
26308
26426
  generateUserSub(email) {
26309
- const hash = (0, import_utils43.sha256Hex)(email.toLowerCase());
26427
+ const hash = (0, import_utils45.sha256Hex)(email.toLowerCase());
26310
26428
  return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
26311
26429
  }
26312
26430
  /**
@@ -26399,7 +26517,7 @@ var init_oauth_callback_flow = __esm({
26399
26517
  });
26400
26518
 
26401
26519
  // libs/sdk/src/auth/flows/oauth.provider-callback.flow.ts
26402
- var import_zod59, import_auth23, import_utils44, inputSchema19, stateSchema17, outputSchema17, plan17, name18, Stage18, OauthProviderCallbackFlow;
26520
+ var import_zod59, import_auth23, import_utils46, inputSchema19, stateSchema17, outputSchema17, plan17, name18, Stage18, OauthProviderCallbackFlow;
26403
26521
  var init_oauth_provider_callback_flow = __esm({
26404
26522
  "libs/sdk/src/auth/flows/oauth.provider-callback.flow.ts"() {
26405
26523
  "use strict";
@@ -26407,7 +26525,7 @@ var init_oauth_provider_callback_flow = __esm({
26407
26525
  import_zod59 = require("zod");
26408
26526
  init_instance_local_primary_auth();
26409
26527
  import_auth23 = require("@frontmcp/auth");
26410
- import_utils44 = require("@frontmcp/utils");
26528
+ import_utils46 = require("@frontmcp/utils");
26411
26529
  init_errors();
26412
26530
  inputSchema19 = httpInputSchema;
26413
26531
  stateSchema17 = import_zod59.z.object({
@@ -26663,14 +26781,14 @@ var init_oauth_provider_callback_flow = __esm({
26663
26781
  if (!nextProviderId) {
26664
26782
  return this.completeFederatedAuth(session);
26665
26783
  }
26666
- const verifier = (0, import_utils44.generateCodeVerifier)();
26667
- const challenge = (0, import_utils44.sha256Base64url)(verifier);
26784
+ const verifier = (0, import_utils46.generateCodeVerifier)();
26785
+ const challenge = (0, import_utils46.sha256Base64url)(verifier);
26668
26786
  const pkce = {
26669
26787
  verifier,
26670
26788
  challenge,
26671
26789
  method: "S256"
26672
26790
  };
26673
- const providerState = `federated:${session.id}:${(0, import_utils44.randomUUID)()}`;
26791
+ const providerState = `federated:${session.id}:${(0, import_utils46.randomUUID)()}`;
26674
26792
  (0, import_auth23.startNextProvider)(session, pkce, providerState);
26675
26793
  const sessionStore = localAuth.federatedSessionStore;
26676
26794
  if (sessionStore) {
@@ -26737,9 +26855,9 @@ var init_oauth_provider_callback_flow = __esm({
26737
26855
  */
26738
26856
  generateUserSub(email) {
26739
26857
  if (!email) {
26740
- return `anon:${(0, import_utils44.randomUUID)()}`;
26858
+ return `anon:${(0, import_utils46.randomUUID)()}`;
26741
26859
  }
26742
- const hash = (0, import_utils44.sha256Base64url)(email.toLowerCase());
26860
+ const hash = (0, import_utils46.sha256Base64url)(email.toLowerCase());
26743
26861
  return `user:${hash.substring(0, 16)}`;
26744
26862
  }
26745
26863
  /**
@@ -26839,12 +26957,12 @@ var init_oauth_provider_callback_flow = __esm({
26839
26957
  });
26840
26958
 
26841
26959
  // libs/sdk/src/auth/instances/instance.local-primary-auth.ts
26842
- var import_jose, import_utils45, import_auth25, import_auth26, DEFAULT_NO_AUTH_SECRET, LocalPrimaryAuth;
26960
+ var import_jose, import_utils47, import_auth25, import_auth26, DEFAULT_NO_AUTH_SECRET, LocalPrimaryAuth;
26843
26961
  var init_instance_local_primary_auth = __esm({
26844
26962
  "libs/sdk/src/auth/instances/instance.local-primary-auth.ts"() {
26845
26963
  "use strict";
26846
26964
  import_jose = require("jose");
26847
- import_utils45 = require("@frontmcp/utils");
26965
+ import_utils47 = require("@frontmcp/utils");
26848
26966
  init_common();
26849
26967
  init_auth2();
26850
26968
  init_well_known_prm_flow();
@@ -26860,7 +26978,7 @@ var init_instance_local_primary_auth = __esm({
26860
26978
  import_auth26 = require("@frontmcp/auth");
26861
26979
  init_oauth_provider_callback_flow();
26862
26980
  init_auth_internal_errors();
26863
- DEFAULT_NO_AUTH_SECRET = (0, import_utils45.randomBytes)(32);
26981
+ DEFAULT_NO_AUTH_SECRET = (0, import_utils47.randomBytes)(32);
26864
26982
  LocalPrimaryAuth = class extends FrontMcpAuth {
26865
26983
  constructor(scope, providers, options) {
26866
26984
  super(options);
@@ -26870,7 +26988,7 @@ var init_instance_local_primary_auth = __esm({
26870
26988
  this.port = this.providers.getActiveScope().metadata.http?.port ?? 3001;
26871
26989
  this.host = "localhost";
26872
26990
  this.issuer = this.deriveIssuer(options);
26873
- const jwtSecret = (0, import_utils45.getEnv)("JWT_SECRET");
26991
+ const jwtSecret = (0, import_utils47.getEnv)("JWT_SECRET");
26874
26992
  if (jwtSecret) {
26875
26993
  this.secret = new TextEncoder().encode(jwtSecret);
26876
26994
  } else {
@@ -26936,7 +27054,7 @@ var init_instance_local_primary_auth = __esm({
26936
27054
  return basePath;
26937
27055
  }
26938
27056
  async signAnonymousJwt() {
26939
- const sub = (0, import_utils45.randomUUID)();
27057
+ const sub = (0, import_utils47.randomUUID)();
26940
27058
  return new import_jose.SignJWT({ sub, role: "user", anonymous: true }).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setIssuer(this.issuer).setExpirationTime("1d").sign(this.secret);
26941
27059
  }
26942
27060
  /**
@@ -26966,7 +27084,7 @@ var init_instance_local_primary_auth = __esm({
26966
27084
  };
26967
27085
  }
26968
27086
  }
26969
- const jwt = new import_jose.SignJWT(claims).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setIssuer(this.issuer).setExpirationTime(`${this.accessTokenTtlSeconds}s`).setJti((0, import_utils45.randomUUID)());
27087
+ const jwt = new import_jose.SignJWT(claims).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setIssuer(this.issuer).setExpirationTime(`${this.accessTokenTtlSeconds}s`).setJti((0, import_utils47.randomUUID)());
26970
27088
  if (audience) {
26971
27089
  jwt.setAudience(audience);
26972
27090
  }
@@ -27032,7 +27150,7 @@ var init_instance_local_primary_auth = __esm({
27032
27150
  const pendingAuthId = `pending:${codeRecord.pendingAuthId}`;
27033
27151
  const parts = accessToken.split(".");
27034
27152
  const signature = parts[2] || accessToken;
27035
- const newAuthId = (0, import_utils45.sha256Hex)(signature).substring(0, 16);
27153
+ const newAuthId = (0, import_utils47.sha256Hex)(signature).substring(0, 16);
27036
27154
  await this.orchestratedTokenStore.migrateTokens(pendingAuthId, newAuthId);
27037
27155
  this.logger.info(`Migrated tokens from ${pendingAuthId} to ${newAuthId}`);
27038
27156
  } catch (err) {
@@ -27261,7 +27379,7 @@ var init_instance_local_primary_auth = __esm({
27261
27379
  if (idToken) {
27262
27380
  try {
27263
27381
  const [, payloadB64] = idToken.split(".");
27264
- const payload = JSON.parse(new TextDecoder().decode((0, import_utils45.base64urlDecode)(payloadB64)));
27382
+ const payload = JSON.parse(new TextDecoder().decode((0, import_utils47.base64urlDecode)(payloadB64)));
27265
27383
  return {
27266
27384
  sub: payload["sub"],
27267
27385
  email: payload["email"],
@@ -27566,14 +27684,14 @@ var init_auth_registry = __esm({
27566
27684
  });
27567
27685
 
27568
27686
  // libs/sdk/src/scope/flows/http.request.flow.ts
27569
- var import_zod60, import_utils46, plan18, httpRequestStateSchema, name19, Stage19, HttpRequestFlow;
27687
+ var import_zod60, import_utils48, plan18, httpRequestStateSchema, name19, Stage19, HttpRequestFlow;
27570
27688
  var init_http_request_flow = __esm({
27571
27689
  "libs/sdk/src/scope/flows/http.request.flow.ts"() {
27572
27690
  "use strict";
27573
27691
  init_common();
27574
27692
  import_zod60 = require("zod");
27575
27693
  init_session_verify_flow();
27576
- import_utils46 = require("@frontmcp/utils");
27694
+ import_utils48 = require("@frontmcp/utils");
27577
27695
  init_errors();
27578
27696
  plan18 = {
27579
27697
  pre: [
@@ -27629,7 +27747,7 @@ var init_http_request_flow = __esm({
27629
27747
  const { request } = this.rawInput;
27630
27748
  this.requestStartTime = Date.now();
27631
27749
  const ctx = this.tryGetContext();
27632
- this.requestId = ctx?.requestId ?? `req-${(0, import_utils46.randomUUID)()}`;
27750
+ this.requestId = ctx?.requestId ?? `req-${(0, import_utils48.randomUUID)()}`;
27633
27751
  const headers = request.headers ?? {};
27634
27752
  const body = request.body;
27635
27753
  const userAgent = headers["user-agent"];
@@ -28113,11 +28231,11 @@ var init_transport_remote = __esm({
28113
28231
  });
28114
28232
 
28115
28233
  // libs/sdk/src/transport/adapters/base-sse-transport.ts
28116
- var import_utils47, import_raw_body, import_content_type, import_protocol19, MAXIMUM_MESSAGE_SIZE, SSEServerTransport;
28234
+ var import_utils49, import_raw_body, import_content_type, import_protocol19, MAXIMUM_MESSAGE_SIZE, SSEServerTransport;
28117
28235
  var init_base_sse_transport = __esm({
28118
28236
  "libs/sdk/src/transport/adapters/base-sse-transport.ts"() {
28119
28237
  "use strict";
28120
- import_utils47 = require("@frontmcp/utils");
28238
+ import_utils49 = require("@frontmcp/utils");
28121
28239
  import_raw_body = __toESM(require("raw-body"));
28122
28240
  import_content_type = __toESM(require("content-type"));
28123
28241
  import_protocol19 = require("@frontmcp/protocol");
@@ -28130,7 +28248,7 @@ var init_base_sse_transport = __esm({
28130
28248
  constructor(_endpoint, res, options) {
28131
28249
  this._endpoint = _endpoint;
28132
28250
  this.res = res;
28133
- this._sessionId = options?.sessionId ?? (0, import_utils47.randomUUID)();
28251
+ this._sessionId = options?.sessionId ?? (0, import_utils49.randomUUID)();
28134
28252
  this._options = options || { enableDnsRebindingProtection: false };
28135
28253
  }
28136
28254
  _sseResponse;
@@ -29741,21 +29859,21 @@ var init_transport_local_adapter = __esm({
29741
29859
  });
29742
29860
 
29743
29861
  // libs/sdk/src/transport/transport.error.ts
29744
- var import_utils48, JSON_RPC2, rpcError, rpcRequest;
29862
+ var import_utils50, JSON_RPC2, rpcError, rpcRequest;
29745
29863
  var init_transport_error = __esm({
29746
29864
  "libs/sdk/src/transport/transport.error.ts"() {
29747
29865
  "use strict";
29748
- import_utils48 = require("@frontmcp/utils");
29866
+ import_utils50 = require("@frontmcp/utils");
29749
29867
  JSON_RPC2 = "2.0";
29750
29868
  rpcError = (message, requestId) => ({
29751
29869
  jsonrpc: JSON_RPC2,
29752
29870
  error: { code: -32e3, message },
29753
- id: requestId ?? (0, import_utils48.randomUUID)()
29871
+ id: requestId ?? (0, import_utils50.randomUUID)()
29754
29872
  // change it to request id + random
29755
29873
  });
29756
29874
  rpcRequest = (requestId, method, params) => ({
29757
29875
  jsonrpc: JSON_RPC2,
29758
- id: requestId ?? (0, import_utils48.randomUUID)(),
29876
+ id: requestId ?? (0, import_utils50.randomUUID)(),
29759
29877
  method,
29760
29878
  ...params !== void 0 && { params }
29761
29879
  });
@@ -29763,12 +29881,12 @@ var init_transport_error = __esm({
29763
29881
  });
29764
29882
 
29765
29883
  // libs/sdk/src/elicitation/store/storage-elicitation.store.ts
29766
- var import_utils49, import_utils50, RESOLVED_RESULT_TTL_SECONDS, RESULT_CHANNEL_PREFIX, FALLBACK_RESULT_CHANNEL_PREFIX, StorageElicitationStore;
29884
+ var import_utils51, import_utils52, RESOLVED_RESULT_TTL_SECONDS, RESULT_CHANNEL_PREFIX, FALLBACK_RESULT_CHANNEL_PREFIX, StorageElicitationStore;
29767
29885
  var init_storage_elicitation_store = __esm({
29768
29886
  "libs/sdk/src/elicitation/store/storage-elicitation.store.ts"() {
29769
29887
  "use strict";
29770
- import_utils49 = require("@frontmcp/utils");
29771
- import_utils50 = require("@frontmcp/utils");
29888
+ import_utils51 = require("@frontmcp/utils");
29889
+ import_utils52 = require("@frontmcp/utils");
29772
29890
  RESOLVED_RESULT_TTL_SECONDS = 300;
29773
29891
  RESULT_CHANNEL_PREFIX = "result:";
29774
29892
  FALLBACK_RESULT_CHANNEL_PREFIX = "fallback-result:";
@@ -29793,9 +29911,9 @@ var init_storage_elicitation_store = __esm({
29793
29911
  constructor(storage, logger) {
29794
29912
  this.storage = storage;
29795
29913
  this.logger = logger;
29796
- this.pending = new import_utils49.TypedStorage(storage.namespace("pending"));
29797
- this.fallback = new import_utils49.TypedStorage(storage.namespace("fallback"));
29798
- this.resolved = new import_utils49.TypedStorage(storage.namespace("resolved"));
29914
+ this.pending = new import_utils51.TypedStorage(storage.namespace("pending"));
29915
+ this.fallback = new import_utils51.TypedStorage(storage.namespace("fallback"));
29916
+ this.resolved = new import_utils51.TypedStorage(storage.namespace("resolved"));
29799
29917
  }
29800
29918
  // ============================================
29801
29919
  // Pending Elicitation Methods
@@ -29805,7 +29923,7 @@ var init_storage_elicitation_store = __esm({
29805
29923
  */
29806
29924
  async setPending(record) {
29807
29925
  const { sessionId, expiresAt } = record;
29808
- const ttlSeconds = (0, import_utils50.expiresAtToTTL)(expiresAt);
29926
+ const ttlSeconds = (0, import_utils52.expiresAtToTTL)(expiresAt);
29809
29927
  if (ttlSeconds <= 0) {
29810
29928
  this.logger?.warn("[StorageElicitationStore] Record already expired, not storing", {
29811
29929
  sessionId,
@@ -29983,7 +30101,7 @@ var init_storage_elicitation_store = __esm({
29983
30101
  */
29984
30102
  async setPendingFallback(record) {
29985
30103
  const { elicitId, expiresAt } = record;
29986
- const ttlSeconds = (0, import_utils50.expiresAtToTTL)(expiresAt);
30104
+ const ttlSeconds = (0, import_utils52.expiresAtToTTL)(expiresAt);
29987
30105
  if (ttlSeconds <= 0) {
29988
30106
  this.logger?.warn("[StorageElicitationStore] Fallback record already expired, not storing", { elicitId });
29989
30107
  return;
@@ -30238,7 +30356,7 @@ var init_storage_elicitation_store = __esm({
30238
30356
 
30239
30357
  // libs/sdk/src/elicitation/store/elicitation-encryption.ts
30240
30358
  function getElicitationSecret() {
30241
- return (0, import_utils51.getEnv)("MCP_ELICITATION_SECRET") || (0, import_utils51.getEnv)("MCP_SESSION_SECRET") || (0, import_utils51.getEnv)("MCP_SERVER_SECRET") || null;
30359
+ return (0, import_utils53.getEnv)("MCP_ELICITATION_SECRET") || (0, import_utils53.getEnv)("MCP_SESSION_SECRET") || (0, import_utils53.getEnv)("MCP_SERVER_SECRET") || null;
30242
30360
  }
30243
30361
  function isElicitationEncryptionAvailable() {
30244
30362
  return getElicitationSecret() !== null;
@@ -30251,27 +30369,27 @@ async function deriveElicitationKey(sessionId, secret) {
30251
30369
  const ikm = textEncoder.encode(serverSecret + sessionId);
30252
30370
  const salt = textEncoder.encode(ELICITATION_SALT);
30253
30371
  const info = textEncoder.encode(`elicit:${sessionId}`);
30254
- return (0, import_utils51.hkdfSha256)(ikm, salt, info, 32);
30372
+ return (0, import_utils53.hkdfSha256)(ikm, salt, info, 32);
30255
30373
  }
30256
30374
  async function encryptElicitationData(data, sessionId, secret) {
30257
30375
  const key = await deriveElicitationKey(sessionId, secret);
30258
30376
  const plaintext = textEncoder.encode(JSON.stringify(data));
30259
- const iv = (0, import_utils51.randomBytes)(12);
30260
- const { ciphertext, tag } = (0, import_utils51.encryptAesGcm)(key, plaintext, iv);
30377
+ const iv = (0, import_utils53.randomBytes)(12);
30378
+ const { ciphertext, tag } = (0, import_utils53.encryptAesGcm)(key, plaintext, iv);
30261
30379
  return {
30262
30380
  alg: "A256GCM",
30263
- iv: (0, import_utils51.base64urlEncode)(iv),
30264
- tag: (0, import_utils51.base64urlEncode)(tag),
30265
- data: (0, import_utils51.base64urlEncode)(ciphertext)
30381
+ iv: (0, import_utils53.base64urlEncode)(iv),
30382
+ tag: (0, import_utils53.base64urlEncode)(tag),
30383
+ data: (0, import_utils53.base64urlEncode)(ciphertext)
30266
30384
  };
30267
30385
  }
30268
30386
  async function decryptElicitationData(blob, sessionId, secret) {
30269
30387
  try {
30270
30388
  const key = await deriveElicitationKey(sessionId, secret);
30271
- const iv = (0, import_utils51.base64urlDecode)(blob.iv);
30272
- const tag = (0, import_utils51.base64urlDecode)(blob.tag);
30273
- const ciphertext = (0, import_utils51.base64urlDecode)(blob.data);
30274
- const decrypted = (0, import_utils51.decryptAesGcm)(key, ciphertext, iv, tag);
30389
+ const iv = (0, import_utils53.base64urlDecode)(blob.iv);
30390
+ const tag = (0, import_utils53.base64urlDecode)(blob.tag);
30391
+ const ciphertext = (0, import_utils53.base64urlDecode)(blob.data);
30392
+ const decrypted = (0, import_utils53.decryptAesGcm)(key, ciphertext, iv, tag);
30275
30393
  return JSON.parse(textDecoder.decode(decrypted));
30276
30394
  } catch {
30277
30395
  return null;
@@ -30311,11 +30429,11 @@ async function tryDecryptStoredValue(value, sessionId, secret) {
30311
30429
  }
30312
30430
  return decryptElicitationData(value, sessionId, secret);
30313
30431
  }
30314
- var import_utils51, ELICITATION_SALT, textEncoder, textDecoder;
30432
+ var import_utils53, ELICITATION_SALT, textEncoder, textDecoder;
30315
30433
  var init_elicitation_encryption = __esm({
30316
30434
  "libs/sdk/src/elicitation/store/elicitation-encryption.ts"() {
30317
30435
  "use strict";
30318
- import_utils51 = require("@frontmcp/utils");
30436
+ import_utils53 = require("@frontmcp/utils");
30319
30437
  init_auth_internal_errors();
30320
30438
  ELICITATION_SALT = "elicitation-store-v1";
30321
30439
  textEncoder = new TextEncoder();
@@ -30717,10 +30835,10 @@ var init_encrypted_elicitation_store = __esm({
30717
30835
 
30718
30836
  // libs/sdk/src/elicitation/store/elicitation-store.factory.ts
30719
30837
  function detectStorageType(storage) {
30720
- if ((0, import_utils52.getEnv)("UPSTASH_REDIS_REST_URL")) {
30838
+ if ((0, import_utils54.getEnv)("UPSTASH_REDIS_REST_URL")) {
30721
30839
  return "upstash";
30722
30840
  }
30723
- if ((0, import_utils52.getEnv)("REDIS_URL") || (0, import_utils52.getEnv)("REDIS_HOST")) {
30841
+ if ((0, import_utils54.getEnv)("REDIS_URL") || (0, import_utils54.getEnv)("REDIS_HOST")) {
30724
30842
  return "redis";
30725
30843
  }
30726
30844
  return "memory";
@@ -30774,7 +30892,7 @@ async function createElicitationStore(options = {}) {
30774
30892
  });
30775
30893
  }
30776
30894
  }
30777
- if (finalStorageConfig?.type === "vercel-kv" || (0, import_utils52.getEnv)("KV_REST_API_URL")) {
30895
+ if (finalStorageConfig?.type === "vercel-kv" || (0, import_utils54.getEnv)("KV_REST_API_URL")) {
30778
30896
  throw new ElicitationNotSupportedError(
30779
30897
  "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."
30780
30898
  );
@@ -30784,7 +30902,7 @@ async function createElicitationStore(options = {}) {
30784
30902
  "Elicitation requires distributed storage when running on Edge runtime. Edge functions are stateless and cannot use in-memory elicitation. Configure Redis or Upstash storage."
30785
30903
  );
30786
30904
  }
30787
- const storage = await (0, import_utils52.createStorage)({
30905
+ const storage = await (0, import_utils54.createStorage)({
30788
30906
  ...finalStorageConfig,
30789
30907
  prefix: keyPrefix,
30790
30908
  fallback: isEdgeRuntime2 ? "error" : "memory"
@@ -30822,7 +30940,7 @@ async function createElicitationStore(options = {}) {
30822
30940
  }
30823
30941
  function createMemoryElicitationStore(options = {}) {
30824
30942
  const { keyPrefix = "mcp:elicit:", logger, encryption } = options;
30825
- const storage = (0, import_utils52.createMemoryStorage)({ prefix: keyPrefix });
30943
+ const storage = (0, import_utils54.createMemoryStorage)({ prefix: keyPrefix });
30826
30944
  let store = new StorageElicitationStore(storage, logger);
30827
30945
  const encryptionEnabled = encryption?.enabled ?? "auto";
30828
30946
  const encryptionSecret = encryption?.secret;
@@ -30866,11 +30984,11 @@ function createElicitationStoreFromStorage(storage, options = {}) {
30866
30984
  });
30867
30985
  return { store, type, storage, encrypted };
30868
30986
  }
30869
- var import_utils52;
30987
+ var import_utils54;
30870
30988
  var init_elicitation_store_factory = __esm({
30871
30989
  "libs/sdk/src/elicitation/store/elicitation-store.factory.ts"() {
30872
30990
  "use strict";
30873
- import_utils52 = require("@frontmcp/utils");
30991
+ import_utils54 = require("@frontmcp/utils");
30874
30992
  init_storage_elicitation_store();
30875
30993
  init_encrypted_elicitation_store();
30876
30994
  init_elicitation_encryption();
@@ -31570,11 +31688,11 @@ var init_ext_apps_types = __esm({
31570
31688
  function createExtAppsMessageHandler(options) {
31571
31689
  return new ExtAppsMessageHandler(options);
31572
31690
  }
31573
- var import_utils53, ExtAppsMessageHandler, ExtAppsError, ExtAppsMethodNotFoundError, ExtAppsInvalidParamsError, ExtAppsNotSupportedError, ExtAppsToolNotFoundError;
31691
+ var import_utils55, ExtAppsMessageHandler, ExtAppsError, ExtAppsMethodNotFoundError, ExtAppsInvalidParamsError, ExtAppsNotSupportedError, ExtAppsToolNotFoundError;
31574
31692
  var init_ext_apps_handler = __esm({
31575
31693
  "libs/sdk/src/ext-apps/ext-apps.handler.ts"() {
31576
31694
  "use strict";
31577
- import_utils53 = require("@frontmcp/utils");
31695
+ import_utils55 = require("@frontmcp/utils");
31578
31696
  init_ext_apps_types();
31579
31697
  ExtAppsMessageHandler = class {
31580
31698
  context;
@@ -31618,7 +31736,7 @@ var init_ext_apps_handler = __esm({
31618
31736
  code: errorCode,
31619
31737
  message: errorMessage,
31620
31738
  // Only include stack traces in development to avoid leaking internals in production
31621
- data: (0, import_utils53.isDevelopment)() && error instanceof Error ? { stack: error.stack } : void 0
31739
+ data: (0, import_utils55.isDevelopment)() && error instanceof Error ? { stack: error.stack } : void 0
31622
31740
  }
31623
31741
  };
31624
31742
  }
@@ -32716,21 +32834,21 @@ async function createVercelKvSessionStore(options, logger) {
32716
32834
  await store.connect();
32717
32835
  return store;
32718
32836
  }
32719
- var import_utils54;
32837
+ var import_utils56;
32720
32838
  var init_session_store_factory = __esm({
32721
32839
  "libs/sdk/src/auth/session/session-store.factory.ts"() {
32722
32840
  "use strict";
32723
- import_utils54 = require("@frontmcp/utils");
32841
+ import_utils56 = require("@frontmcp/utils");
32724
32842
  init_common();
32725
32843
  }
32726
32844
  });
32727
32845
 
32728
32846
  // libs/sdk/src/transport/transport.registry.ts
32729
- var import_utils55, import_auth30, TransportService;
32847
+ var import_utils57, import_auth30, TransportService;
32730
32848
  var init_transport_registry = __esm({
32731
32849
  "libs/sdk/src/transport/transport.registry.ts"() {
32732
32850
  "use strict";
32733
- import_utils55 = require("@frontmcp/utils");
32851
+ import_utils57 = require("@frontmcp/utils");
32734
32852
  init_transport_remote();
32735
32853
  init_transport_local();
32736
32854
  init_transport_errors();
@@ -33178,7 +33296,7 @@ var init_transport_registry = __esm({
33178
33296
  }
33179
33297
  /* --------------------------------- internals -------------------------------- */
33180
33298
  sha256(value) {
33181
- return (0, import_utils55.sha256Hex)(value);
33299
+ return (0, import_utils57.sha256Hex)(value);
33182
33300
  }
33183
33301
  /**
33184
33302
  * Create a history key from components.
@@ -33743,11 +33861,11 @@ function createSkillHttpAuthValidator(skillsConfig, logger) {
33743
33861
  }
33744
33862
  return new SkillHttpAuthValidator({ skillsConfig, logger });
33745
33863
  }
33746
- var import_utils56, SkillHttpAuthValidator;
33864
+ var import_utils58, SkillHttpAuthValidator;
33747
33865
  var init_skill_http_auth = __esm({
33748
33866
  "libs/sdk/src/skill/auth/skill-http-auth.ts"() {
33749
33867
  "use strict";
33750
- import_utils56 = require("@frontmcp/utils");
33868
+ import_utils58 = require("@frontmcp/utils");
33751
33869
  SkillHttpAuthValidator = class {
33752
33870
  skillsConfig;
33753
33871
  logger;
@@ -33824,7 +33942,7 @@ var init_skill_http_auth = __esm({
33824
33942
  const keyBytes = encoder.encode(key);
33825
33943
  if (keyBytes.length === candidateBytes.length) {
33826
33944
  try {
33827
- if ((0, import_utils56.timingSafeEqual)(keyBytes, candidateBytes)) {
33945
+ if ((0, import_utils58.timingSafeEqual)(keyBytes, candidateBytes)) {
33828
33946
  found = true;
33829
33947
  }
33830
33948
  } catch {
@@ -35139,15 +35257,15 @@ var init_skill_session_types = __esm({
35139
35257
  });
35140
35258
 
35141
35259
  // libs/sdk/src/skill/session/skill-session.manager.ts
35142
- var import_utils57, SkillSessionManager;
35260
+ var import_utils59, SkillSessionManager;
35143
35261
  var init_skill_session_manager = __esm({
35144
35262
  "libs/sdk/src/skill/session/skill-session.manager.ts"() {
35145
35263
  "use strict";
35146
- import_utils57 = require("@frontmcp/utils");
35264
+ import_utils59 = require("@frontmcp/utils");
35147
35265
  init_skill_session_types();
35148
35266
  init_errors();
35149
- SkillSessionManager = class extends import_utils57.EventEmitter {
35150
- storage = new import_utils57.AsyncLocalStorage();
35267
+ SkillSessionManager = class extends import_utils59.EventEmitter {
35268
+ storage = new import_utils59.AsyncLocalStorage();
35151
35269
  options;
35152
35270
  logger;
35153
35271
  store;
@@ -36189,18 +36307,15 @@ var init_complete_flow = __esm({
36189
36307
  } else {
36190
36308
  const resourceMatch = this.scope.resources.findResourceForUri(uri);
36191
36309
  if (resourceMatch) {
36192
- const instance = resourceMatch.instance;
36193
- if (typeof instance.getArgumentCompleter === "function") {
36194
- const completer = instance.getArgumentCompleter(argName);
36195
- if (completer) {
36196
- try {
36197
- const result = await completer(argValue);
36198
- values = result.values || [];
36199
- total = result.total;
36200
- hasMore = result.hasMore;
36201
- } catch (e) {
36202
- this.logger.warn(`complete: completer failed for resource "${uri}" argument "${argName}": ${e}`);
36203
- }
36310
+ const completer = resourceMatch.instance.getArgumentCompleter(argName);
36311
+ if (completer) {
36312
+ try {
36313
+ const result = await completer(argValue);
36314
+ values = result.values || [];
36315
+ total = result.total;
36316
+ hasMore = result.hasMore;
36317
+ } catch (e) {
36318
+ this.logger.warn(`complete: completer failed for resource "${uri}" argument "${argName}": ${e}`);
36204
36319
  }
36205
36320
  }
36206
36321
  } else {
@@ -36663,13 +36778,13 @@ var init_call_agent_flow = __esm({
36663
36778
  });
36664
36779
 
36665
36780
  // libs/sdk/src/elicitation/flows/elicitation-request.flow.ts
36666
- var import_zod75, import_utils58, inputSchema30, outputSchema28, stateSchema29, plan30, name31, Stage31, ElicitationRequestFlow;
36781
+ var import_zod75, import_utils60, inputSchema30, outputSchema28, stateSchema29, plan30, name31, Stage31, ElicitationRequestFlow;
36667
36782
  var init_elicitation_request_flow = __esm({
36668
36783
  "libs/sdk/src/elicitation/flows/elicitation-request.flow.ts"() {
36669
36784
  "use strict";
36670
36785
  init_common();
36671
36786
  import_zod75 = require("zod");
36672
- import_utils58 = require("@frontmcp/utils");
36787
+ import_utils60 = require("@frontmcp/utils");
36673
36788
  init_errors();
36674
36789
  init_elicitation_types();
36675
36790
  inputSchema30 = import_zod75.z.object({
@@ -36751,7 +36866,7 @@ var init_elicitation_request_flow = __esm({
36751
36866
  async generateElicitId() {
36752
36867
  this.logger.verbose("generateElicitId:start");
36753
36868
  const { elicitationId, ttl } = this.state;
36754
- const elicitId = elicitationId ?? `elicit-${(0, import_utils58.randomUUID)()}`;
36869
+ const elicitId = elicitationId ?? `elicit-${(0, import_utils60.randomUUID)()}`;
36755
36870
  const expiresAt = Date.now() + (ttl ?? DEFAULT_ELICIT_TTL);
36756
36871
  this.state.set({ elicitId, expiresAt });
36757
36872
  this.logger.verbose("generateElicitId:done", { elicitId });
@@ -37059,30 +37174,30 @@ var require_dist = __commonJS({
37059
37174
  sqliteStorageOptionsSchema: () => sqliteStorageOptionsSchema
37060
37175
  });
37061
37176
  module2.exports = __toCommonJS2(index_exports2);
37062
- var import_utils75 = require("@frontmcp/utils");
37177
+ var import_utils77 = require("@frontmcp/utils");
37063
37178
  var HKDF_SALT = new TextEncoder().encode("frontmcp-sqlite-storage-v1");
37064
37179
  var HKDF_INFO = new TextEncoder().encode("aes-256-gcm-value-encryption");
37065
37180
  var KEY_LENGTH = 32;
37066
37181
  function deriveEncryptionKey(secret) {
37067
37182
  const ikm = new TextEncoder().encode(secret);
37068
- return (0, import_utils75.hkdfSha256)(ikm, HKDF_SALT, HKDF_INFO, KEY_LENGTH);
37183
+ return (0, import_utils77.hkdfSha256)(ikm, HKDF_SALT, HKDF_INFO, KEY_LENGTH);
37069
37184
  }
37070
37185
  var SEPARATOR = ":";
37071
37186
  function encryptValue(key, plaintext) {
37072
- const iv = (0, import_utils75.randomBytes)(12);
37187
+ const iv = (0, import_utils77.randomBytes)(12);
37073
37188
  const plaintextBytes = new TextEncoder().encode(plaintext);
37074
- const { ciphertext, tag } = (0, import_utils75.encryptAesGcm)(key, plaintextBytes, iv);
37075
- return [(0, import_utils75.base64urlEncode)(iv), (0, import_utils75.base64urlEncode)(tag), (0, import_utils75.base64urlEncode)(ciphertext)].join(SEPARATOR);
37189
+ const { ciphertext, tag } = (0, import_utils77.encryptAesGcm)(key, plaintextBytes, iv);
37190
+ return [(0, import_utils77.base64urlEncode)(iv), (0, import_utils77.base64urlEncode)(tag), (0, import_utils77.base64urlEncode)(ciphertext)].join(SEPARATOR);
37076
37191
  }
37077
37192
  function decryptValue(key, encrypted) {
37078
37193
  const parts = encrypted.split(SEPARATOR);
37079
37194
  if (parts.length !== 3) {
37080
37195
  throw new Error("Invalid encrypted value format");
37081
37196
  }
37082
- const iv = (0, import_utils75.base64urlDecode)(parts[0]);
37083
- const tag = (0, import_utils75.base64urlDecode)(parts[1]);
37084
- const ciphertext = (0, import_utils75.base64urlDecode)(parts[2]);
37085
- const plaintext = (0, import_utils75.decryptAesGcm)(key, ciphertext, iv, tag);
37197
+ const iv = (0, import_utils77.base64urlDecode)(parts[0]);
37198
+ const tag = (0, import_utils77.base64urlDecode)(parts[1]);
37199
+ const ciphertext = (0, import_utils77.base64urlDecode)(parts[2]);
37200
+ const plaintext = (0, import_utils77.decryptAesGcm)(key, ciphertext, iv, tag);
37086
37201
  return new TextDecoder().decode(plaintext);
37087
37202
  }
37088
37203
  var SqliteKvStore = class {
@@ -39179,11 +39294,11 @@ var init_workflow_engine = __esm({
39179
39294
  });
39180
39295
 
39181
39296
  // libs/sdk/src/job/execution/job-execution.manager.ts
39182
- var import_utils59, JobExecutionManager;
39297
+ var import_utils61, JobExecutionManager;
39183
39298
  var init_job_execution_manager = __esm({
39184
39299
  "libs/sdk/src/job/execution/job-execution.manager.ts"() {
39185
39300
  "use strict";
39186
- import_utils59 = require("@frontmcp/utils");
39301
+ import_utils61 = require("@frontmcp/utils");
39187
39302
  init_workflow_engine();
39188
39303
  JobExecutionManager = class {
39189
39304
  stateStore;
@@ -39198,7 +39313,7 @@ var init_job_execution_manager = __esm({
39198
39313
  * Execute a job inline (synchronous) or in background.
39199
39314
  */
39200
39315
  async executeJob(job, input, opts = {}) {
39201
- const runId = (0, import_utils59.randomUUID)();
39316
+ const runId = (0, import_utils61.randomUUID)();
39202
39317
  const retryConfig = job.metadata.retry ?? {};
39203
39318
  const maxAttempts = retryConfig.maxAttempts ?? 1;
39204
39319
  const runRecord = {
@@ -39236,7 +39351,7 @@ var init_job_execution_manager = __esm({
39236
39351
  * Execute a workflow inline or in background.
39237
39352
  */
39238
39353
  async executeWorkflow(workflow, jobRegistry, opts = {}) {
39239
- const runId = (0, import_utils59.randomUUID)();
39354
+ const runId = (0, import_utils61.randomUUID)();
39240
39355
  const runRecord = {
39241
39356
  runId,
39242
39357
  jobId: workflow.metadata.id ?? workflow.name,
@@ -40366,7 +40481,7 @@ var init_job_scope_helper = __esm({
40366
40481
  });
40367
40482
 
40368
40483
  // libs/sdk/src/scope/scope.instance.ts
40369
- var import_reflect_metadata20, import_utils60, import_guard6, Scope;
40484
+ var import_reflect_metadata20, import_utils62, import_guard6, Scope;
40370
40485
  var init_scope_instance = __esm({
40371
40486
  "libs/sdk/src/scope/scope.instance.ts"() {
40372
40487
  "use strict";
@@ -40386,7 +40501,7 @@ var init_scope_instance = __esm({
40386
40501
  init_agent_registry();
40387
40502
  init_skill_registry();
40388
40503
  init_skill_validation_error();
40389
- import_utils60 = require("@frontmcp/utils");
40504
+ import_utils62 = require("@frontmcp/utils");
40390
40505
  init_errors();
40391
40506
  init_skill_scope_helper();
40392
40507
  init_session2();
@@ -40470,7 +40585,7 @@ var init_scope_instance = __esm({
40470
40585
  await this.scopeProviders.ready;
40471
40586
  const scopeRef = { kind: "scope", id: this.id, ref: _Scope };
40472
40587
  const scopeProviders = this.scopeProviders;
40473
- const perf = (0, import_utils60.getEnvFlag)("FRONTMCP_PERF");
40588
+ const perf = (0, import_utils62.getEnvFlag)("FRONTMCP_PERF");
40474
40589
  const t0 = perf ? performance.now() : 0;
40475
40590
  const mark = perf ? (label) => this.logger.info(`[PERF] ${label}: ${(performance.now() - t0).toFixed(1)}ms`) : () => {
40476
40591
  };
@@ -40496,7 +40611,7 @@ var init_scope_instance = __esm({
40496
40611
  redis: elicitationRedis,
40497
40612
  keyPrefix: elicitationRedis?.keyPrefix ?? "mcp:elicit:",
40498
40613
  logger: this.logger,
40499
- isEdgeRuntime: (0, import_utils60.isEdgeRuntime)()
40614
+ isEdgeRuntime: (0, import_utils62.isEdgeRuntime)()
40500
40615
  });
40501
40616
  this._elicitationStore = elicitStore;
40502
40617
  })() : void 0;
@@ -41155,7 +41270,7 @@ var init_base_host_adapter = __esm({
41155
41270
  });
41156
41271
 
41157
41272
  // libs/sdk/src/server/adapters/express.host.adapter.ts
41158
- var http, import_express, import_cors, import_utils61, ExpressHostAdapter;
41273
+ var http, import_express, import_cors, import_utils63, ExpressHostAdapter;
41159
41274
  var init_express_host_adapter = __esm({
41160
41275
  "libs/sdk/src/server/adapters/express.host.adapter.ts"() {
41161
41276
  "use strict";
@@ -41163,7 +41278,7 @@ var init_express_host_adapter = __esm({
41163
41278
  import_express = __toESM(require("express"));
41164
41279
  import_cors = __toESM(require("cors"));
41165
41280
  init_base_host_adapter();
41166
- import_utils61 = require("@frontmcp/utils");
41281
+ import_utils63 = require("@frontmcp/utils");
41167
41282
  ExpressHostAdapter = class extends HostServerAdapter {
41168
41283
  app = (0, import_express.default)();
41169
41284
  router = import_express.default.Router();
@@ -41255,8 +41370,8 @@ var init_express_host_adapter = __esm({
41255
41370
  }
41256
41371
  async cleanupStaleSocket(socketPath) {
41257
41372
  try {
41258
- if (await (0, import_utils61.fileExists)(socketPath)) {
41259
- await (0, import_utils61.unlink)(socketPath);
41373
+ if (await (0, import_utils63.fileExists)(socketPath)) {
41374
+ await (0, import_utils63.unlink)(socketPath);
41260
41375
  }
41261
41376
  } catch {
41262
41377
  }
@@ -41433,12 +41548,12 @@ var init_logger_utils = __esm({
41433
41548
  });
41434
41549
 
41435
41550
  // libs/sdk/src/logger/instances/instance.console-logger.ts
41436
- var import_utils62, ConsoleLogTransportInstance;
41551
+ var import_utils64, ConsoleLogTransportInstance;
41437
41552
  var init_instance_console_logger = __esm({
41438
41553
  "libs/sdk/src/logger/instances/instance.console-logger.ts"() {
41439
41554
  "use strict";
41440
41555
  init_common();
41441
- import_utils62 = require("@frontmcp/utils");
41556
+ import_utils64 = require("@frontmcp/utils");
41442
41557
  ConsoleLogTransportInstance = class extends LogTransportInterface {
41443
41558
  log(rec) {
41444
41559
  const fn = this.bind(rec.level, rec.prefix);
@@ -41466,7 +41581,7 @@ var init_instance_console_logger = __esm({
41466
41581
  const BOLD = "\x1B[1m";
41467
41582
  const DIM = "\x1B[2m";
41468
41583
  const GRAY = "\x1B[90m";
41469
- const useAnsi = (0, import_utils62.supportsAnsi)();
41584
+ const useAnsi = (0, import_utils64.supportsAnsi)();
41470
41585
  const timePart = useAnsi ? `${DIM}[${ts}]${RESET}` : `[${ts}]`;
41471
41586
  const scopePart = loggerPrefix ? useAnsi ? `${BOLD}[${loggerPrefix}]${RESET}` : `[${loggerPrefix}]` : void 0;
41472
41587
  const levelPart = useAnsi ? `${BOLD}${meta.ansi}${meta.label}${RESET}` : meta.label;
@@ -41504,12 +41619,12 @@ var init_instance_console_logger = __esm({
41504
41619
  });
41505
41620
 
41506
41621
  // libs/sdk/src/logger/instances/instance.logger.ts
41507
- var import_utils63, LoggerInstance;
41622
+ var import_utils65, LoggerInstance;
41508
41623
  var init_instance_logger = __esm({
41509
41624
  "libs/sdk/src/logger/instances/instance.logger.ts"() {
41510
41625
  "use strict";
41511
41626
  init_common();
41512
- import_utils63 = require("@frontmcp/utils");
41627
+ import_utils65 = require("@frontmcp/utils");
41513
41628
  LoggerInstance = class _LoggerInstance extends FrontMcpLogger {
41514
41629
  constructor(config, getTransports) {
41515
41630
  super();
@@ -41564,7 +41679,7 @@ var init_instance_logger = __esm({
41564
41679
  }
41565
41680
  _getter(level) {
41566
41681
  if (level < this.level || this.level === 100 /* Off */) return () => void 0;
41567
- if ((0, import_utils63.isDevelopment)() && this.config.enableConsole && this.consoleTransport) {
41682
+ if ((0, import_utils65.isDevelopment)() && this.config.enableConsole && this.consoleTransport) {
41568
41683
  return this.consoleTransport.bind(level, this.prefix);
41569
41684
  }
41570
41685
  const emit = this.emit.bind(this);
@@ -41894,7 +42009,7 @@ __export(in_memory_server_exports, {
41894
42009
  async function createInMemoryServer(scope, options) {
41895
42010
  const { InMemoryTransport, McpServer: McpServer2 } = await import("@frontmcp/protocol");
41896
42011
  const { createMcpHandlers: createMcpHandlers2 } = await Promise.resolve().then(() => (init_mcp_handlers(), mcp_handlers_exports));
41897
- const sessionId = options?.sessionId ?? `in-memory:${(0, import_utils64.randomUUID)()}`;
42012
+ const sessionId = options?.sessionId ?? `in-memory:${(0, import_utils66.randomUUID)()}`;
41898
42013
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
41899
42014
  let currentAuthInfo = options?.authInfo ?? {};
41900
42015
  const hasRemoteApps = scope.apps?.getApps().some((app) => app.isRemote) ?? false;
@@ -41948,11 +42063,11 @@ async function createInMemoryServer(scope, options) {
41948
42063
  }
41949
42064
  };
41950
42065
  }
41951
- var import_utils64;
42066
+ var import_utils66;
41952
42067
  var init_in_memory_server = __esm({
41953
42068
  "libs/sdk/src/transport/in-memory-server.ts"() {
41954
42069
  "use strict";
41955
- import_utils64 = require("@frontmcp/utils");
42070
+ import_utils66 = require("@frontmcp/utils");
41956
42071
  }
41957
42072
  });
41958
42073
 
@@ -41961,13 +42076,13 @@ var direct_client_exports = {};
41961
42076
  __export(direct_client_exports, {
41962
42077
  DirectClientImpl: () => DirectClientImpl
41963
42078
  });
41964
- var import_utils65, import_protocol43, DirectClientImpl;
42079
+ var import_utils67, import_protocol43, DirectClientImpl;
41965
42080
  var init_direct_client = __esm({
41966
42081
  "libs/sdk/src/direct/direct-client.ts"() {
41967
42082
  "use strict";
41968
42083
  init_llm_platform();
41969
42084
  init_errors();
41970
- import_utils65 = require("@frontmcp/utils");
42085
+ import_utils67 = require("@frontmcp/utils");
41971
42086
  import_protocol43 = require("@frontmcp/protocol");
41972
42087
  init_skills_mcp_types();
41973
42088
  DirectClientImpl = class _DirectClientImpl {
@@ -42005,7 +42120,7 @@ var init_direct_client = __esm({
42005
42120
  */
42006
42121
  static async create(scope, options) {
42007
42122
  const { createInMemoryServer: createInMemoryServer2 } = await Promise.resolve().then(() => (init_in_memory_server(), in_memory_server_exports));
42008
- const sessionId = options?.session?.id ?? `direct:${(0, import_utils65.randomUUID)()}`;
42123
+ const sessionId = options?.session?.id ?? `direct:${(0, import_utils67.randomUUID)()}`;
42009
42124
  const clientInfo = options?.clientInfo ?? { name: "mcp-client", version: "1.0.0" };
42010
42125
  const authInfo = {};
42011
42126
  if (options?.authToken) {
@@ -42420,7 +42535,7 @@ function buildAuthInfo(authContext, defaultSessionId) {
42420
42535
  if (!authContext && !defaultSessionId) {
42421
42536
  return void 0;
42422
42537
  }
42423
- const sessionId = authContext?.sessionId ?? defaultSessionId ?? `direct:${(0, import_utils66.randomUUID)()}`;
42538
+ const sessionId = authContext?.sessionId ?? defaultSessionId ?? `direct:${(0, import_utils68.randomUUID)()}`;
42424
42539
  const user = authContext?.user ? { iss: "direct", sub: authContext.user.sub ?? "direct", ...authContext.user } : { iss: "direct", sub: "direct" };
42425
42540
  const clientId = user.sub ?? "direct";
42426
42541
  const authInfo = {
@@ -42435,11 +42550,11 @@ function buildAuthInfo(authContext, defaultSessionId) {
42435
42550
  }
42436
42551
  return authInfo;
42437
42552
  }
42438
- var import_utils66, DirectMcpServerImpl;
42553
+ var import_utils68, DirectMcpServerImpl;
42439
42554
  var init_direct_server = __esm({
42440
42555
  "libs/sdk/src/direct/direct-server.ts"() {
42441
42556
  "use strict";
42442
- import_utils66 = require("@frontmcp/utils");
42557
+ import_utils68 = require("@frontmcp/utils");
42443
42558
  init_common();
42444
42559
  init_errors();
42445
42560
  DirectMcpServerImpl = class {
@@ -42449,7 +42564,7 @@ var init_direct_server = __esm({
42449
42564
  defaultSessionId;
42450
42565
  constructor(scope) {
42451
42566
  this.scope = scope;
42452
- this.defaultSessionId = `direct:${(0, import_utils66.randomUUID)()}`;
42567
+ this.defaultSessionId = `direct:${(0, import_utils68.randomUUID)()}`;
42453
42568
  this.ready = Promise.resolve();
42454
42569
  }
42455
42570
  /**
@@ -42715,7 +42830,7 @@ var front_mcp_exports = {};
42715
42830
  __export(front_mcp_exports, {
42716
42831
  FrontMcpInstance: () => FrontMcpInstance
42717
42832
  });
42718
- var import_utils67, FrontMcpInstance;
42833
+ var import_utils69, FrontMcpInstance;
42719
42834
  var init_front_mcp = __esm({
42720
42835
  "libs/sdk/src/front-mcp/front-mcp.ts"() {
42721
42836
  "use strict";
@@ -42726,7 +42841,7 @@ var init_front_mcp = __esm({
42726
42841
  init_logger_registry();
42727
42842
  init_direct();
42728
42843
  init_errors();
42729
- import_utils67 = require("@frontmcp/utils");
42844
+ import_utils69 = require("@frontmcp/utils");
42730
42845
  FrontMcpInstance = class _FrontMcpInstance2 {
42731
42846
  config;
42732
42847
  ready;
@@ -42758,6 +42873,9 @@ var init_front_mcp = __esm({
42758
42873
  throw new ServerNotFoundError();
42759
42874
  }
42760
42875
  await server.start();
42876
+ for (const scope of this.getScopes()) {
42877
+ await scope.emitServerStarted();
42878
+ }
42761
42879
  }
42762
42880
  /**
42763
42881
  * Get the configuration used to create this FrontMCP instance.
@@ -42950,8 +43068,8 @@ var init_front_mcp = __esm({
42950
43068
  frontMcp.log?.info(`MCP server listening on unix://${socketPath}`);
42951
43069
  const cleanup = async () => {
42952
43070
  try {
42953
- if (await (0, import_utils67.fileExists)(socketPath)) {
42954
- await (0, import_utils67.unlink)(socketPath);
43071
+ if (await (0, import_utils69.fileExists)(socketPath)) {
43072
+ await (0, import_utils69.unlink)(socketPath);
42955
43073
  }
42956
43074
  } catch {
42957
43075
  }
@@ -43010,7 +43128,7 @@ var init_front_mcp = __esm({
43010
43128
  serverInfo: scope.metadata.info
43011
43129
  };
43012
43130
  const mcpServer = new McpServer2(scope.metadata.info, serverOptions);
43013
- const sessionId = `stdio:${(0, import_utils67.randomUUID)()}`;
43131
+ const sessionId = `stdio:${(0, import_utils69.randomUUID)()}`;
43014
43132
  const handlers = createMcpHandlers2({ scope, serverOptions });
43015
43133
  for (const handler of handlers) {
43016
43134
  const originalHandler = handler.handler;
@@ -43153,8 +43271,8 @@ function FrontMcp(providedMetadata) {
43153
43271
  Reflect.defineMetadata(FrontMcpTokens[property] ?? property, metadata[property], target);
43154
43272
  }
43155
43273
  Reflect.defineMetadata("__frontmcp:config", metadata, target);
43156
- const isServerless2 = (0, import_utils68.getEnvFlag)("FRONTMCP_SERVERLESS");
43157
- const isSchemaExtract = (0, import_utils68.getEnvFlag)("FRONTMCP_SCHEMA_EXTRACT");
43274
+ const isServerless2 = (0, import_utils70.getEnvFlag)("FRONTMCP_SERVERLESS");
43275
+ const isSchemaExtract = (0, import_utils70.getEnvFlag)("FRONTMCP_SCHEMA_EXTRACT");
43158
43276
  if (isSchemaExtract) {
43159
43277
  } else if (isServerless2) {
43160
43278
  const ServerlessInstance = getFrontMcpInstance();
@@ -43171,14 +43289,14 @@ function FrontMcp(providedMetadata) {
43171
43289
  }
43172
43290
  };
43173
43291
  }
43174
- var import_reflect_metadata25, import_utils68, _FrontMcpInstance, _serverlessHandlerFns;
43292
+ var import_reflect_metadata25, import_utils70, _FrontMcpInstance, _serverlessHandlerFns;
43175
43293
  var init_front_mcp_decorator = __esm({
43176
43294
  "libs/sdk/src/common/decorators/front-mcp.decorator.ts"() {
43177
43295
  "use strict";
43178
43296
  import_reflect_metadata25 = require("reflect-metadata");
43179
43297
  init_tokens();
43180
43298
  init_metadata();
43181
- import_utils68 = require("@frontmcp/utils");
43299
+ import_utils70 = require("@frontmcp/utils");
43182
43300
  init_mcp_error();
43183
43301
  init_decorator_errors();
43184
43302
  _FrontMcpInstance = null;
@@ -43640,7 +43758,7 @@ function resolveCallerDir() {
43640
43758
  if (file.includes("node_modules") || file.includes("skill.decorator")) {
43641
43759
  continue;
43642
43760
  }
43643
- return (0, import_utils69.dirname)(file);
43761
+ return (0, import_utils71.dirname)(file);
43644
43762
  }
43645
43763
  }
43646
43764
  return void 0;
@@ -43699,14 +43817,14 @@ function getSkillMetadata(target) {
43699
43817
  }
43700
43818
  return metadata;
43701
43819
  }
43702
- var import_reflect_metadata34, import_utils69, Skill;
43820
+ var import_reflect_metadata34, import_utils71, Skill;
43703
43821
  var init_skill_decorator = __esm({
43704
43822
  "libs/sdk/src/common/decorators/skill.decorator.ts"() {
43705
43823
  "use strict";
43706
43824
  import_reflect_metadata34 = require("reflect-metadata");
43707
43825
  init_tokens();
43708
43826
  init_metadata();
43709
- import_utils69 = require("@frontmcp/utils");
43827
+ import_utils71 = require("@frontmcp/utils");
43710
43828
  init_package_specifier();
43711
43829
  init_validate_remote_url();
43712
43830
  Object.assign(FrontMcpSkill, {
@@ -44217,6 +44335,29 @@ var init_resource_interface = __esm({
44217
44335
  this.uri = uri;
44218
44336
  this.params = params;
44219
44337
  }
44338
+ /**
44339
+ * Override to provide autocompletion for resource template arguments.
44340
+ * Called by the MCP `completion/complete` handler when a client requests
44341
+ * suggestions for a template parameter.
44342
+ *
44343
+ * @param argName - The template parameter name (e.g., 'userId')
44344
+ * @returns A completer function, or null if no completion is available for this argument
44345
+ *
44346
+ * @example
44347
+ * ```typescript
44348
+ * getArgumentCompleter(argName: string): ResourceArgumentCompleter | null {
44349
+ * if (argName === 'userId') {
44350
+ * return async (partial) => ({
44351
+ * values: await this.searchUsers(partial),
44352
+ * });
44353
+ * }
44354
+ * return null;
44355
+ * }
44356
+ * ```
44357
+ */
44358
+ getArgumentCompleter(_argName) {
44359
+ return null;
44360
+ }
44220
44361
  get output() {
44221
44362
  return this._output;
44222
44363
  }
@@ -45486,11 +45627,11 @@ var init_decide_request_intent_utils = __esm({
45486
45627
 
45487
45628
  // libs/sdk/src/common/utils/path.utils.ts
45488
45629
  function normalizeEntryPrefix(entryPath) {
45489
- const t = (0, import_utils70.trimSlashes)(entryPath ?? "");
45630
+ const t = (0, import_utils72.trimSlashes)(entryPath ?? "");
45490
45631
  return t ? `/${t}` : "";
45491
45632
  }
45492
45633
  function normalizeScopeBase(scopeBase) {
45493
- const t = (0, import_utils70.trimSlashes)(scopeBase ?? "");
45634
+ const t = (0, import_utils72.trimSlashes)(scopeBase ?? "");
45494
45635
  return t ? `/${t}` : "";
45495
45636
  }
45496
45637
  function getRequestBaseUrl(req, entryPath) {
@@ -45511,22 +45652,22 @@ function computeResource(req, entryPath, scopeBase) {
45511
45652
  function urlToSafeId(url) {
45512
45653
  const u = new URL(url);
45513
45654
  const raw = (u.host + (u.pathname && u.pathname !== "/" ? u.pathname : "")).replace(/\/+$/, "");
45514
- return (0, import_utils70.trimSlashes)(raw).replace(/[^a-zA-Z0-9_-]/g, "-");
45655
+ return (0, import_utils72.trimSlashes)(raw).replace(/[^a-zA-Z0-9_-]/g, "-");
45515
45656
  }
45516
45657
  function makeWellKnownPaths(name33, entryPrefix, scopeBase = "") {
45517
45658
  const prefix = normalizeEntryPrefix(entryPrefix);
45518
45659
  const scope = normalizeScopeBase(scopeBase);
45519
- const reversed = (0, import_utils70.joinPath)(".well-known", name33) + `${prefix}${scope}`;
45520
- const inPrefixRoot = `${prefix}${(0, import_utils70.joinPath)(".well-known", name33)}${scope}`;
45521
- const inPrefixScope = `${prefix}${scope}${(0, import_utils70.joinPath)(".well-known", name33)}`;
45660
+ const reversed = (0, import_utils72.joinPath)(".well-known", name33) + `${prefix}${scope}`;
45661
+ const inPrefixRoot = `${prefix}${(0, import_utils72.joinPath)(".well-known", name33)}${scope}`;
45662
+ const inPrefixScope = `${prefix}${scope}${(0, import_utils72.joinPath)(".well-known", name33)}`;
45522
45663
  return /* @__PURE__ */ new Set([reversed, inPrefixRoot, inPrefixScope]);
45523
45664
  }
45524
- var import_utils70, import_utils71;
45665
+ var import_utils72, import_utils73;
45525
45666
  var init_path_utils = __esm({
45526
45667
  "libs/sdk/src/common/utils/path.utils.ts"() {
45527
45668
  "use strict";
45528
- import_utils70 = require("@frontmcp/utils");
45529
- import_utils71 = require("@frontmcp/utils");
45669
+ import_utils72 = require("@frontmcp/utils");
45670
+ import_utils73 = require("@frontmcp/utils");
45530
45671
  }
45531
45672
  });
45532
45673
 
@@ -45843,6 +45984,28 @@ var init_scope_entry = __esm({
45843
45984
  const scope = normalizeScopeBase(this.routeBase ?? "");
45844
45985
  return `${prefix}${scope}`;
45845
45986
  }
45987
+ /**
45988
+ * Lifecycle callbacks registered by plugins via onServerStarted().
45989
+ * Called after the HTTP server starts listening.
45990
+ */
45991
+ lifecycleCallbacks = [];
45992
+ /**
45993
+ * Register a callback to run after the server has started.
45994
+ * Plugins can use this for post-startup initialization (e.g., warming caches,
45995
+ * starting background jobs, logging readiness).
45996
+ */
45997
+ onServerStarted(callback) {
45998
+ this.lifecycleCallbacks.push(callback);
45999
+ }
46000
+ /**
46001
+ * Emit the server-started lifecycle event. Called by FrontMcpInstance after server.start().
46002
+ * @internal
46003
+ */
46004
+ async emitServerStarted() {
46005
+ for (const cb of this.lifecycleCallbacks) {
46006
+ await cb();
46007
+ }
46008
+ }
45846
46009
  };
45847
46010
  }
45848
46011
  });
@@ -45961,12 +46124,12 @@ var init_adapter_entry = __esm({
45961
46124
  });
45962
46125
 
45963
46126
  // libs/sdk/src/common/entries/tool.entry.ts
45964
- var import_utils74, ToolEntry2;
46127
+ var import_utils76, ToolEntry2;
45965
46128
  var init_tool_entry = __esm({
45966
46129
  "libs/sdk/src/common/entries/tool.entry.ts"() {
45967
46130
  "use strict";
45968
46131
  init_base_entry();
45969
- import_utils74 = require("@frontmcp/utils");
46132
+ import_utils76 = require("@frontmcp/utils");
45970
46133
  ToolEntry2 = class extends BaseEntry {
45971
46134
  owner;
45972
46135
  /**
@@ -46033,7 +46196,7 @@ var init_tool_entry = __esm({
46033
46196
  const { z: z91, toJSONSchema: toJSONSchema8 } = require("zod");
46034
46197
  return toJSONSchema8(z91.object(this.inputSchema));
46035
46198
  } catch (error) {
46036
- if ((0, import_utils74.isDebug)() || (0, import_utils74.isDevelopment)()) {
46199
+ if ((0, import_utils76.isDebug)() || (0, import_utils76.isDevelopment)()) {
46037
46200
  console.warn("[ToolEntry] Failed to convert Zod schema to JSON Schema:", error);
46038
46201
  }
46039
46202
  return { type: "object", properties: {} };
@@ -46073,6 +46236,14 @@ var init_resource_entry = __esm({
46073
46236
  * Whether this resource is a template (has uriTemplate instead of uri)
46074
46237
  */
46075
46238
  isTemplate;
46239
+ /**
46240
+ * Get an argument completer for resource template autocompletion.
46241
+ * Override in subclasses to provide suggestions for template parameters.
46242
+ * Returns null by default (no completion available).
46243
+ */
46244
+ getArgumentCompleter(_argName) {
46245
+ return null;
46246
+ }
46076
46247
  };
46077
46248
  }
46078
46249
  });
@@ -47123,7 +47294,7 @@ __export(index_exports, {
47123
47294
  isValidVersion: () => isValidVersion,
47124
47295
  isVercelKvProvider: () => isVercelKvProvider,
47125
47296
  job: () => frontMcpJob,
47126
- joinPath: () => import_utils71.joinPath,
47297
+ joinPath: () => import_utils73.joinPath,
47127
47298
  jsonWebKeySetSchema: () => import_auth.jsonWebKeySetSchema,
47128
47299
  jwkParametersSchema: () => import_auth.jwkParametersSchema,
47129
47300
  jwkSchema: () => import_auth.jwkSchema,
@@ -47209,7 +47380,7 @@ __export(index_exports, {
47209
47380
  toolPaginationOptionsSchema: () => toolPaginationOptionsSchema,
47210
47381
  transparentAuthOptionsSchema: () => import_auth6.transparentAuthOptionsSchema,
47211
47382
  transportOptionsSchema: () => transportOptionsSchema,
47212
- trimSlashes: () => import_utils71.trimSlashes,
47383
+ trimSlashes: () => import_utils73.trimSlashes,
47213
47384
  tryDecryptStoredValue: () => tryDecryptStoredValue,
47214
47385
  tryGetConfig: () => tryGetConfig,
47215
47386
  urlToSafeId: () => urlToSafeId,