@frontmcp/sdk 1.11.0 → 1.11.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/app/instances/app.esm.instance.d.ts.map +1 -1
  2. package/app/instances/empty-app-registries.d.ts +1 -0
  3. package/app/instances/empty-app-registries.d.ts.map +1 -1
  4. package/auth/flows/oauth.callback.flow.d.ts +5 -0
  5. package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
  6. package/auth/flows/oauth.connect.flow.d.ts +4 -2
  7. package/auth/flows/oauth.connect.flow.d.ts.map +1 -1
  8. package/auth/vault/auth-providers.providers.d.ts +7 -16
  9. package/auth/vault/auth-providers.providers.d.ts.map +1 -1
  10. package/auth/vault/index.d.ts +1 -2
  11. package/auth/vault/index.d.ts.map +1 -1
  12. package/auth/vault/unconfigured-auth-providers.d.ts +4 -0
  13. package/auth/vault/unconfigured-auth-providers.d.ts.map +1 -0
  14. package/browser/app/instances/app.esm.instance.mjs +2 -0
  15. package/browser/app/instances/empty-app-registries.mjs +2 -0
  16. package/browser/auth/flows/oauth.callback.flow.mjs +26 -1
  17. package/browser/auth/flows/oauth.connect.flow.mjs +31 -24
  18. package/browser/auth/vault/auth-providers.providers.mjs +96 -0
  19. package/browser/auth/vault/credential-cache.mjs +5 -0
  20. package/browser/auth/vault/unconfigured-auth-providers.mjs +21 -0
  21. package/browser/common/entries/scope.entry.mjs +35 -0
  22. package/browser/common/interfaces/execution-context.interface.mjs +5 -0
  23. package/browser/common/interfaces/server.interface.mjs +2 -0
  24. package/browser/common/metadata/front-mcp.metadata.mjs +3 -0
  25. package/browser/common/metadata/plugin.metadata.mjs +2 -1
  26. package/browser/common/schemas/http-output.schema.mjs +12 -1
  27. package/browser/common/tokens/front-mcp.tokens.mjs +1 -0
  28. package/browser/common/tokens/plugin.tokens.mjs +2 -1
  29. package/browser/common/types/options/skills-http/schema.mjs +13 -0
  30. package/browser/direct/direct-client.mjs +10 -1
  31. package/browser/direct/token-auth-info.mjs +33 -0
  32. package/browser/elicitation/helpers/elicit.helper.mjs +10 -7
  33. package/browser/errors/http-route.errors.mjs +9 -0
  34. package/browser/errors/index.mjs +3 -1
  35. package/browser/errors/misconfiguration.mjs +4 -1
  36. package/browser/errors/plugin.errors.mjs +30 -0
  37. package/browser/errors/tool-credentials-required.error.mjs +18 -5
  38. package/browser/front-mcp/front-mcp.mjs +7 -5
  39. package/browser/health/health.service.mjs +14 -6
  40. package/browser/http-route/flows/http.route.flow.mjs +47 -19
  41. package/browser/index.cjs +3581 -2501
  42. package/browser/index.mjs +20 -4
  43. package/browser/job/enclave/browser-enclave-core.mjs +9 -0
  44. package/browser/job/enclave/job-enclave.bridge.mjs +3 -20
  45. package/browser/notification/notification.service.mjs +5 -5
  46. package/browser/plugin/plugin.registry.mjs +56 -3
  47. package/browser/provider/provider.registry.mjs +2 -0
  48. package/browser/resource/flows/resources-list.flow.mjs +31 -1
  49. package/browser/scope/dev-events-observability.mjs +9 -5
  50. package/browser/scope/scope.instance.mjs +15 -6
  51. package/browser/server/server.validation.mjs +3 -6
  52. package/browser/skill/decision/decisions-api.decider.mjs +62 -0
  53. package/browser/skill/decision/skill-decision.ranker.mjs +96 -0
  54. package/browser/skill/errors/skill-bundle-not-loaded.error.mjs +21 -0
  55. package/browser/skill/flows/load-skill.flow.mjs +21 -12
  56. package/browser/skill/flows/search-skills.flow.mjs +10 -2
  57. package/browser/skill/index.mjs +6 -0
  58. package/browser/skill/providers/memory-skill.provider.mjs +41 -135
  59. package/browser/skill/sep-2640/resources/skill-index.resource.mjs +2 -0
  60. package/browser/skill/sep-2640/resources/skill-md.resource.mjs +3 -3
  61. package/browser/skill/sep-2640/sep-2640.builders.mjs +24 -2
  62. package/browser/skill/sep-2640/sep-2640.per-skill.mjs +3 -4
  63. package/browser/skill/sep-2640/sep-2640.resource-helpers.mjs +14 -2
  64. package/browser/skill/skill-catalog-source.mjs +55 -0
  65. package/browser/skill/skill-instructions.helper.mjs +25 -7
  66. package/browser/skill/skill-search-text.mjs +166 -0
  67. package/browser/skill/skill.registry.mjs +64 -3
  68. package/browser/subsystems.mjs +14 -1
  69. package/browser/surface/index.mjs +6 -0
  70. package/browser/surface/list-change-batch.mjs +51 -0
  71. package/browser/surface/live-surface.mjs +2 -2
  72. package/browser/tool/flows/call-tool.flow.mjs +18 -4
  73. package/browser/tool/flows/tool-credentials.gate.mjs +60 -10
  74. package/browser/tool/tool.registry.mjs +9 -2
  75. package/browser/transport/mcp-20260728/mrtr.mjs +13 -6
  76. package/browser/transport/mcp-20260728/subscriptions.mjs +6 -6
  77. package/browser/transport/mcp-handlers/skills-list-request.handler.mjs +19 -7
  78. package/browser/transport/mcp-handlers/skills-mcp.types.mjs +8 -4
  79. package/browser/transport/relay/relay-http.mjs +2 -1
  80. package/browser/transport/web-fetch-handler.mjs +6 -8
  81. package/browser/transport/web-response.renderer.mjs +6 -2
  82. package/browser/utils/http-location.utils.mjs +8 -0
  83. package/common/decorators/tool.decorator.d.ts +2 -1
  84. package/common/decorators/tool.decorator.d.ts.map +1 -1
  85. package/common/entries/scope.entry.d.ts +20 -0
  86. package/common/entries/scope.entry.d.ts.map +1 -1
  87. package/common/interfaces/execution-context.interface.d.ts +3 -1
  88. package/common/interfaces/execution-context.interface.d.ts.map +1 -1
  89. package/common/interfaces/server.interface.d.ts +2 -0
  90. package/common/interfaces/server.interface.d.ts.map +1 -1
  91. package/common/interfaces/skill.interface.d.ts +5 -0
  92. package/common/interfaces/skill.interface.d.ts.map +1 -1
  93. package/common/metadata/app.metadata.d.ts +1 -1
  94. package/common/metadata/front-mcp.metadata.d.ts +394 -92
  95. package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
  96. package/common/metadata/plugin.metadata.d.ts +8 -0
  97. package/common/metadata/plugin.metadata.d.ts.map +1 -1
  98. package/common/schemas/http-output.schema.d.ts.map +1 -1
  99. package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
  100. package/common/tokens/plugin.tokens.d.ts +1 -0
  101. package/common/tokens/plugin.tokens.d.ts.map +1 -1
  102. package/common/types/options/elicitation/schema.d.ts +1 -1
  103. package/common/types/options/redis/schema.d.ts +3 -3
  104. package/common/types/options/redis/schema.d.ts.map +1 -1
  105. package/common/types/options/skills-http/interfaces.d.ts +16 -0
  106. package/common/types/options/skills-http/interfaces.d.ts.map +1 -1
  107. package/common/types/options/skills-http/schema.d.ts +13 -2
  108. package/common/types/options/skills-http/schema.d.ts.map +1 -1
  109. package/common/types/options/transport/schema.d.ts +4 -4
  110. package/context/frontmcp-context.d.ts +1 -1
  111. package/context/frontmcp-context.d.ts.map +1 -1
  112. package/direct/client.types.d.ts +60 -21
  113. package/direct/client.types.d.ts.map +1 -1
  114. package/direct/create.types.d.ts +6 -1
  115. package/direct/create.types.d.ts.map +1 -1
  116. package/direct/index.d.ts +1 -1
  117. package/direct/index.d.ts.map +1 -1
  118. package/direct/token-auth-info.d.ts +9 -0
  119. package/direct/token-auth-info.d.ts.map +1 -0
  120. package/elicitation/helpers/elicit.helper.d.ts +5 -0
  121. package/elicitation/helpers/elicit.helper.d.ts.map +1 -1
  122. package/errors/error-handler.d.ts +1 -0
  123. package/errors/error-handler.d.ts.map +1 -1
  124. package/errors/http-route.errors.d.ts +4 -0
  125. package/errors/http-route.errors.d.ts.map +1 -1
  126. package/errors/index.d.ts +1 -1
  127. package/errors/index.d.ts.map +1 -1
  128. package/errors/mcp.error.d.ts +2 -0
  129. package/errors/mcp.error.d.ts.map +1 -1
  130. package/errors/misconfiguration.d.ts.map +1 -1
  131. package/errors/plugin.errors.d.ts +12 -0
  132. package/errors/plugin.errors.d.ts.map +1 -1
  133. package/errors/tool-credentials-required.error.d.ts +10 -2
  134. package/errors/tool-credentials-required.error.d.ts.map +1 -1
  135. package/esm/index.mjs +39 -31
  136. package/front-mcp/front-mcp.d.ts +3 -0
  137. package/front-mcp/front-mcp.d.ts.map +1 -1
  138. package/health/health.service.d.ts +10 -3
  139. package/health/health.service.d.ts.map +1 -1
  140. package/http-route/flows/http.route.flow.d.ts +6 -0
  141. package/http-route/flows/http.route.flow.d.ts.map +1 -1
  142. package/index.d.ts +10 -10
  143. package/index.d.ts.map +1 -1
  144. package/index.js +46 -38
  145. package/job/enclave/browser-enclave-core.d.ts +3 -0
  146. package/job/enclave/browser-enclave-core.d.ts.map +1 -0
  147. package/job/enclave/enclave-core.d.ts +3 -0
  148. package/job/enclave/enclave-core.d.ts.map +1 -0
  149. package/job/enclave/job-enclave.bridge.d.ts +1 -9
  150. package/job/enclave/job-enclave.bridge.d.ts.map +1 -1
  151. package/package.json +16 -11
  152. package/plugin/plugin.registry.d.ts +5 -1
  153. package/plugin/plugin.registry.d.ts.map +1 -1
  154. package/provider/provider.registry.d.ts.map +1 -1
  155. package/resource/flows/resources-list.flow.d.ts +3 -1
  156. package/resource/flows/resources-list.flow.d.ts.map +1 -1
  157. package/scope/dev-events-observability.d.ts +2 -0
  158. package/scope/dev-events-observability.d.ts.map +1 -1
  159. package/scope/scope.instance.d.ts.map +1 -1
  160. package/server/adapters/utf8-json.parser.d.ts +2 -0
  161. package/server/adapters/utf8-json.parser.d.ts.map +1 -1
  162. package/server/server.validation.d.ts.map +1 -1
  163. package/skill/decision/decisions-api.decider.d.ts +26 -0
  164. package/skill/decision/decisions-api.decider.d.ts.map +1 -0
  165. package/skill/decision/index.d.ts +4 -0
  166. package/skill/decision/index.d.ts.map +1 -0
  167. package/skill/decision/skill-decision.ranker.d.ts +28 -0
  168. package/skill/decision/skill-decision.ranker.d.ts.map +1 -0
  169. package/skill/decision/skill-decision.types.d.ts +63 -0
  170. package/skill/decision/skill-decision.types.d.ts.map +1 -0
  171. package/skill/errors/index.d.ts +1 -0
  172. package/skill/errors/index.d.ts.map +1 -1
  173. package/skill/errors/skill-bundle-not-loaded.error.d.ts +16 -0
  174. package/skill/errors/skill-bundle-not-loaded.error.d.ts.map +1 -0
  175. package/skill/flows/load-skill.flow.d.ts +4 -2
  176. package/skill/flows/load-skill.flow.d.ts.map +1 -1
  177. package/skill/flows/search-skills.flow.d.ts +5 -1
  178. package/skill/flows/search-skills.flow.d.ts.map +1 -1
  179. package/skill/index.d.ts +6 -0
  180. package/skill/index.d.ts.map +1 -1
  181. package/skill/providers/memory-skill.provider.d.ts +10 -12
  182. package/skill/providers/memory-skill.provider.d.ts.map +1 -1
  183. package/skill/sep-2640/resources/skill-index.resource.d.ts.map +1 -1
  184. package/skill/sep-2640/sep-2640.builders.d.ts +7 -2
  185. package/skill/sep-2640/sep-2640.builders.d.ts.map +1 -1
  186. package/skill/sep-2640/sep-2640.per-skill.d.ts.map +1 -1
  187. package/skill/sep-2640/sep-2640.resource-helpers.d.ts +7 -1
  188. package/skill/sep-2640/sep-2640.resource-helpers.d.ts.map +1 -1
  189. package/skill/skill-catalog-source.d.ts +69 -0
  190. package/skill/skill-catalog-source.d.ts.map +1 -0
  191. package/skill/skill-instructions.helper.d.ts +15 -0
  192. package/skill/skill-instructions.helper.d.ts.map +1 -1
  193. package/skill/skill-search-text.d.ts +60 -0
  194. package/skill/skill-search-text.d.ts.map +1 -0
  195. package/skill/skill-storage.interface.d.ts +5 -0
  196. package/skill/skill-storage.interface.d.ts.map +1 -1
  197. package/skill/skill.registry.d.ts +29 -0
  198. package/skill/skill.registry.d.ts.map +1 -1
  199. package/subsystems.d.ts +1 -1
  200. package/subsystems.d.ts.map +1 -1
  201. package/surface/index.d.ts +1 -0
  202. package/surface/index.d.ts.map +1 -1
  203. package/surface/list-change-batch.d.ts +28 -0
  204. package/surface/list-change-batch.d.ts.map +1 -0
  205. package/tool/flows/call-tool.flow.d.ts +5 -2
  206. package/tool/flows/call-tool.flow.d.ts.map +1 -1
  207. package/tool/flows/tool-credentials.gate.d.ts +26 -0
  208. package/tool/flows/tool-credentials.gate.d.ts.map +1 -1
  209. package/tool/tool.registry.d.ts +2 -0
  210. package/tool/tool.registry.d.ts.map +1 -1
  211. package/transport/mcp-20260728/mrtr.d.ts +6 -2
  212. package/transport/mcp-20260728/mrtr.d.ts.map +1 -1
  213. package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
  214. package/transport/mcp-handlers/index.d.ts +1 -1
  215. package/transport/mcp-handlers/skills-list-request.handler.d.ts.map +1 -1
  216. package/transport/mcp-handlers/skills-mcp.types.d.ts +4 -1
  217. package/transport/mcp-handlers/skills-mcp.types.d.ts.map +1 -1
  218. package/transport/relay/relay-http.d.ts.map +1 -1
  219. package/transport/web-response.renderer.d.ts.map +1 -1
  220. package/utils/http-location.utils.d.ts +8 -0
  221. package/utils/http-location.utils.d.ts.map +1 -0
  222. package/auth/vault/auth-providers.context-extension.d.ts +0 -68
  223. package/auth/vault/auth-providers.context-extension.d.ts.map +0 -1
@@ -4,10 +4,14 @@ import { callSurfaceOf } from "../common/availability/index.mjs";
4
4
  import { mcpRequestSurface } from "../transport/mcp-handlers/mcp-surface.mjs";
5
5
  import { SKILL_INDEX_URI } from "./sep-2640/sep-2640.constants.mjs";
6
6
  import { filterSkillsByAuthorities } from "./skill-authorities.helper.mjs";
7
+ import { readySkillCatalog } from "./skill-catalog-source.mjs";
7
8
  import { filterServableSkills } from "./skill-filter.helper.mjs";
8
9
  var DEFAULT_POLICY = "compact";
9
10
  var MAX_SKILL_CATALOG_CHARS = 16e3;
10
11
  var TRUNCATION_FOOTER_RESERVE = 160;
12
+ function pointersFor(options) {
13
+ return options.pointers ?? (options.mcpResources === false ? METHOD_POINTERS : RESOURCE_POINTERS);
14
+ }
11
15
  var RESOURCE_POINTERS = {
12
16
  header: `Available skills (read the \`${SKILL_INDEX_URI}\` resource for each skill's \`SKILL.md\` URI):`,
13
17
  truncationHint: `read \`${SKILL_INDEX_URI}\` to browse`,
@@ -35,7 +39,7 @@ function sanitizeName(raw) {
35
39
  function buildSkillsCatalogSummary(skillRegistry, options = {}) {
36
40
  const skills = listedSkills(skillRegistry, options);
37
41
  if (skills.length === 0) return "";
38
- const pointers = options.mcpResources === false ? METHOD_POINTERS : RESOURCE_POINTERS;
42
+ const pointers = pointersFor(options);
39
43
  const lines = [pointers.header, ""];
40
44
  let truncated = false;
41
45
  let shownCount = 0;
@@ -67,8 +71,11 @@ function buildCompactSkillsLine(skillRegistry, options) {
67
71
  if (count === 0 && !servesExternalSkills) return "";
68
72
  let skills = count === 1 ? "1 skill" : `${count} skills`;
69
73
  if (servesExternalSkills) skills = "skills";
70
- const pointers = options.mcpResources === false ? METHOD_POINTERS : RESOURCE_POINTERS;
71
- return `This server has ${skills}: ${pointers.compact}`;
74
+ return `This server has ${skills}: ${pointersFor(options).compact}`;
75
+ }
76
+ function buildSkillsNotLoadedLine(reason) {
77
+ const singleLineReason = reason.replace(/\s+/g, " ").trim();
78
+ return `This server's skills have not loaded yet (${singleLineReason}). Ask for them again shortly; the server sends notifications/skills/list_changed once they load.`;
72
79
  }
73
80
  function composeInitializeInstructions(options) {
74
81
  const policy = options.policy ?? DEFAULT_POLICY;
@@ -82,7 +89,15 @@ function composeInitializeInstructions(options) {
82
89
  if (policy === "off") {
83
90
  return joinSections([user, channel]);
84
91
  }
85
- const summaryOptions = { mcpResources: options.mcpResources, skills: options.skills };
92
+ if (options.skillsNotLoaded !== void 0) {
93
+ const notLoaded = buildSkillsNotLoadedLine(options.skillsNotLoaded);
94
+ return joinSections(policy === "prepend" ? [notLoaded, channel, user] : [user, channel, notLoaded]);
95
+ }
96
+ const summaryOptions = {
97
+ mcpResources: options.mcpResources,
98
+ skills: options.skills,
99
+ pointers: options.pointers
100
+ };
86
101
  if (policy === "compact") {
87
102
  return joinSections([user, channel, buildCompactSkillsLine(options.skillRegistry, summaryOptions)]);
88
103
  }
@@ -104,14 +119,17 @@ function instructionsPolicyFor(scope, clientName) {
104
119
  }
105
120
  async function composeCallerInstructions(scope, options = {}) {
106
121
  const skillsConfig = scope.metadata.skillsConfig;
122
+ const { source, notLoadedReason } = await readySkillCatalog(scope);
107
123
  const composeOptions = {
108
124
  userInstructions: scope.metadata.instructions,
109
125
  channelInstructions: buildChannelInstructions(scope.channels),
110
126
  skillRegistry: scope.skills,
111
127
  policy: instructionsPolicyFor(scope, options.clientName),
112
- mcpResources: skillsConfig?.mcpResources
128
+ mcpResources: skillsConfig?.mcpResources,
129
+ pointers: source?.pointers,
130
+ skillsNotLoaded: notLoadedReason
113
131
  };
114
- const withUriHints = options.skillUriHints === true && skillUriHintsEnabled(scope);
132
+ const withUriHints = options.skillUriHints === true && notLoadedReason === void 0 && skillUriHintsEnabled(scope);
115
133
  const listsSkills = withUriHints || includesSkillCatalog(composeOptions);
116
134
  let skills = [];
117
135
  if (listsSkills) {
@@ -146,7 +164,7 @@ function skillUriHintsEnabled(scope) {
146
164
  }
147
165
  function includesSkillCatalog(options) {
148
166
  const policy = options.policy ?? DEFAULT_POLICY;
149
- if (policy === "off") return false;
167
+ if (policy === "off" || options.skillsNotLoaded !== void 0) return false;
150
168
  return !(policy === "replace" && (options.userInstructions ?? "").trim().length > 0);
151
169
  }
152
170
  async function skillsVisibleTo(scope, ctx) {
@@ -0,0 +1,166 @@
1
+ // libs/sdk/src/skill/skill-search-text.ts
2
+ var SKILL_STOP_WORDS = /* @__PURE__ */ new Set([
3
+ // Articles & Determiners
4
+ "the",
5
+ "a",
6
+ "an",
7
+ "this",
8
+ "that",
9
+ "these",
10
+ "those",
11
+ // Prepositions
12
+ "in",
13
+ "on",
14
+ "at",
15
+ "to",
16
+ "for",
17
+ "of",
18
+ "with",
19
+ "by",
20
+ "from",
21
+ "into",
22
+ // Conjunctions
23
+ "and",
24
+ "or",
25
+ "but",
26
+ "so",
27
+ "as",
28
+ "if",
29
+ "when",
30
+ "where",
31
+ // Pronouns
32
+ "i",
33
+ "me",
34
+ "my",
35
+ "you",
36
+ "your",
37
+ "it",
38
+ "its",
39
+ "we",
40
+ "our",
41
+ "they",
42
+ "their",
43
+ // Auxiliary verbs
44
+ "is",
45
+ "was",
46
+ "are",
47
+ "were",
48
+ "be",
49
+ "been",
50
+ "being",
51
+ "have",
52
+ "has",
53
+ "had",
54
+ "do",
55
+ "does",
56
+ "did",
57
+ "will",
58
+ "would",
59
+ "can",
60
+ "could",
61
+ "should",
62
+ "may",
63
+ "might",
64
+ // Common fillers
65
+ "please",
66
+ "help",
67
+ "want",
68
+ "need",
69
+ "like",
70
+ "just",
71
+ "how",
72
+ "what"
73
+ ]);
74
+ var MAX_INSTRUCTION_TERMS = 48;
75
+ function identifierWords(identifier) {
76
+ return identifier.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, "$1 $2").replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu, "$1 $2").replace(/(\p{L})(\p{N})/gu, "$1 $2").replace(/[_\-.:/]+/g, " ").trim();
77
+ }
78
+ function instructionTerms(instructions) {
79
+ const terms = /* @__PURE__ */ new Set();
80
+ for (const raw of instructions.split(/[^\p{L}\p{M}\p{N}_]+/u)) {
81
+ if (raw.length === 0) continue;
82
+ for (const word of [raw, ...identifierWords(raw).split(" ")]) {
83
+ const term = word.toLowerCase();
84
+ if (term.length < 4 || SKILL_STOP_WORDS.has(term)) continue;
85
+ terms.add(term);
86
+ if (terms.size >= MAX_INSTRUCTION_TERMS) return [...terms];
87
+ }
88
+ }
89
+ return [...terms];
90
+ }
91
+ function skillSearchText(skill) {
92
+ const parts = [];
93
+ if (skill.name) {
94
+ const nameParts = skill.name.split(/[:\-_.\s]/).filter(Boolean);
95
+ parts.push(...nameParts);
96
+ }
97
+ if (skill.description) {
98
+ parts.push(skill.description, skill.description, skill.description);
99
+ const keyTerms = skill.description.toLowerCase().split(/\s+/).filter((word) => word.length >= 4 && !SKILL_STOP_WORDS.has(word));
100
+ parts.push(...keyTerms);
101
+ }
102
+ for (const tag of skill.tags ?? []) {
103
+ parts.push(tag, tag);
104
+ }
105
+ for (const tool of skill.tools) {
106
+ parts.push(tool.name);
107
+ if (tool.purpose) {
108
+ parts.push(tool.purpose);
109
+ }
110
+ }
111
+ for (const action of skill.actions ?? []) {
112
+ parts.push(action.actionId, identifierWords(action.actionId));
113
+ if (action.summary) parts.push(action.summary);
114
+ if (action.description) parts.push(action.description);
115
+ }
116
+ if (skill.parameters) {
117
+ for (const param of skill.parameters) {
118
+ parts.push(param.name);
119
+ if (param.description) {
120
+ parts.push(param.description);
121
+ }
122
+ }
123
+ }
124
+ if (skill.examples) {
125
+ for (const example of skill.examples) {
126
+ parts.push(example.scenario);
127
+ if (example.expectedOutcome) {
128
+ parts.push(example.expectedOutcome);
129
+ }
130
+ }
131
+ }
132
+ if (skill.instructions) {
133
+ parts.push(...instructionTerms(skill.instructions));
134
+ }
135
+ return parts.join(" ");
136
+ }
137
+ var SKILL_TOKENIZER_ID = "frontmcp-skills-1";
138
+ function skillTokenizer(tokenize) {
139
+ return (text) => tokenize(text).filter((term) => !SKILL_STOP_WORDS.has(term));
140
+ }
141
+ function queryTerms(query, tokenize) {
142
+ if (tokenize) return [...new Set(tokenize(query))];
143
+ return query.toLowerCase().split(/\s+/).filter((term) => term.length > 0 && !SKILL_STOP_WORDS.has(term));
144
+ }
145
+ function queryTermShare(terms, text, tokenize) {
146
+ if (terms.length === 0) return 0;
147
+ const haystack = tokenize ? ` ${tokenize(text).join(" ")} ` : text.toLowerCase();
148
+ return terms.filter((term) => haystack.includes(term)).length / terms.length;
149
+ }
150
+ function negativeQueryShare(negativeQuery, text, tokenize) {
151
+ if (negativeQuery === void 0) return 0;
152
+ const queries = typeof negativeQuery === "string" ? [negativeQuery] : negativeQuery;
153
+ return queries.reduce((max, query) => Math.max(max, queryTermShare(queryTerms(query, tokenize), text, tokenize)), 0);
154
+ }
155
+ export {
156
+ MAX_INSTRUCTION_TERMS,
157
+ SKILL_STOP_WORDS,
158
+ SKILL_TOKENIZER_ID,
159
+ identifierWords,
160
+ instructionTerms,
161
+ negativeQueryShare,
162
+ queryTermShare,
163
+ queryTerms,
164
+ skillSearchText,
165
+ skillTokenizer
166
+ };
@@ -10,6 +10,7 @@ import {
10
10
  SkillValidationError
11
11
  } from "./errors/skill-validation.error.mjs";
12
12
  import { SEP_2640_EXTENSION_ID } from "./sep-2640/sep-2640.constants.mjs";
13
+ import { negativeQueryShare, queryTerms, queryTermShare, skillSearchText } from "./skill-search-text.mjs";
13
14
  import { SkillToolValidator } from "./skill-validator.mjs";
14
15
  import { SkillEmitter } from "./skill.events.mjs";
15
16
  import { createSkillInstance } from "./skill.instance.mjs";
@@ -64,6 +65,11 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
64
65
  withdrawals = 0;
65
66
  /** The last storage-provider write queued per skill id ({@link syncProvider}). */
66
67
  providerWrites = /* @__PURE__ */ new Map();
68
+ /**
69
+ * Dynamic skills the storage provider holds as registered: their last write to it completed. The index has
70
+ * scored them, so the dynamic overlay of {@link search} leaves them to it (#1059).
71
+ */
72
+ providerIndexed = /* @__PURE__ */ new Set();
67
73
  /** Whether a plugin registers skills at runtime ({@link expectDynamicSkills}). */
68
74
  dynamicSkillsExpected = false;
69
75
  /** Adopted skills from child registries */
@@ -94,6 +100,11 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
94
100
  scope;
95
101
  /** Registry-level options for validation behavior */
96
102
  options;
103
+ /**
104
+ * Ranks search results with `options.decision`'s model. Loaded with the first search that uses it, so a server
105
+ * without a decision model doesn't carry the module.
106
+ */
107
+ decisionRankerLoading;
97
108
  /** SEP-2640 \u00a7Discovery \u2014 additional `mcp-resource-template` index entries. */
98
109
  sep2640IndexTemplates = [];
99
110
  /** SEP-2640 ADR \u2014 additional `archive` index entries. */
@@ -383,6 +394,32 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
383
394
  }
384
395
  }
385
396
  async search(query, options) {
397
+ const ranker = query.trim().length > 0 ? await this.decisionRanker() : void 0;
398
+ if (!ranker) return this.searchIndex(query, options);
399
+ const pool = await this.searchIndex(query, { ...options, topK: ranker.maxCandidates, minScore: 0 });
400
+ const ranked = await ranker.rank(query, options?.negativeQuery, pool, options?.topK);
401
+ return ranked ?? this.searchIndex(query, options);
402
+ }
403
+ /** The ranker for `options.decision`, built once; `undefined` without one, or when its module fails to load. */
404
+ decisionRanker() {
405
+ const decision = this.options.decision;
406
+ if (!decision) return Promise.resolve(void 0);
407
+ this.decisionRankerLoading ??= import("./decision/skill-decision.ranker.mjs").then(
408
+ ({ SkillDecisionRanker }) => new SkillDecisionRanker(decision, { warn: (message, meta) => this.scope.logger.warn(message, meta) }),
409
+ (error) => {
410
+ this.scope.logger.warn(
411
+ "skill search: the decision model could not be loaded; results are ranked by the index",
412
+ {
413
+ error: error instanceof Error ? error.message : String(error)
414
+ }
415
+ );
416
+ return void 0;
417
+ }
418
+ );
419
+ return this.decisionRankerLoading;
420
+ }
421
+ /** {@link search} by the index alone: the storage provider, then the dynamic skills it doesn't hold. */
422
+ async searchIndex(query, options) {
386
423
  const topK = options?.topK;
387
424
  const hidden = this.hiddenFromProviderRead();
388
425
  const providerOptions = hidden.size > 0 && typeof topK === "number" && topK >= 0 ? { ...options, topK: topK + hidden.size } : options;
@@ -409,7 +446,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
409
446
  availableTools = v.available;
410
447
  missingTools = v.missing;
411
448
  }
412
- return { ...r, metadata: meta, availableTools, missingTools };
449
+ return { ...r, metadata: meta, availableTools, missingTools, bundleVersion: dyn.bundleVersion };
413
450
  });
414
451
  const overlayOnly = this.searchDynamicOverlay(query, options, baseSeen);
415
452
  if (overlayOnly.length === 0 && rewrites === 0) return baseResults;
@@ -573,6 +610,9 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
573
610
  servesSkills() {
574
611
  return this.dynamicSkillsExpected || this.hasAny() || this.externalProvider?.isReadOnly() === true;
575
612
  }
613
+ bundleVersionOf(skillId) {
614
+ return this.dynamicContents.get(skillId)?.bundleVersion;
615
+ }
576
616
  /**
577
617
  * Get total skill count.
578
618
  *
@@ -608,6 +648,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
608
648
  ...t.purpose !== void 0 && { purpose: t.purpose },
609
649
  ...t.required !== void 0 && { required: t.required }
610
650
  })),
651
+ ...content.tags !== void 0 && { tags: [...content.tags] },
611
652
  ...content.parameters !== void 0 && { parameters: content.parameters },
612
653
  ...content.examples !== void 0 && { examples: content.examples },
613
654
  ...content.license !== void 0 && { license: content.license },
@@ -647,6 +688,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
647
688
  const id = content.id;
648
689
  if (excludeIds.has(id)) continue;
649
690
  if (options?.excludeIds?.includes(id)) continue;
691
+ if (q.length > 0 && this.providerIndexed.has(id)) continue;
650
692
  const meta = this.dynamicSkillMetadata(content);
651
693
  if (options?.tags?.length) {
652
694
  const tags = meta.tags ?? [];
@@ -675,10 +717,22 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
675
717
  } else if (desc.includes(q)) {
676
718
  score = 0.5;
677
719
  } else {
678
- continue;
720
+ const share = queryTermShare(queryTerms(q), skillSearchText(content));
721
+ if (share === 0) continue;
722
+ score = 0.5 * share;
723
+ }
724
+ if (options?.negativeQuery !== void 0) {
725
+ score -= (options.negativeWeight ?? 1) * negativeQueryShare(options.negativeQuery, skillSearchText(content));
679
726
  }
680
727
  if (score < minScore) continue;
681
- out.push({ metadata: meta, score, availableTools, missingTools, source: "local" });
728
+ out.push({
729
+ metadata: meta,
730
+ score,
731
+ availableTools,
732
+ missingTools,
733
+ source: "local",
734
+ ...content.bundleVersion !== void 0 && { bundleVersion: content.bundleVersion }
735
+ });
682
736
  }
683
737
  return out;
684
738
  }
@@ -698,6 +752,9 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
698
752
  }
699
753
  return this.emitter.on((e) => cb({ ...e, snapshot: this.listAllInstances().filter(filter) }));
700
754
  }
755
+ notifyListChanged() {
756
+ this.bump("reset");
757
+ }
701
758
  /* -------------------- Capabilities -------------------- */
702
759
  /**
703
760
  * Get MCP capabilities for skills.
@@ -894,6 +951,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
894
951
  ...t.purpose !== void 0 && { purpose: t.purpose },
895
952
  ...t.required !== void 0 && { required: t.required }
896
953
  })),
954
+ ...content.tags && { tags: [...content.tags] },
897
955
  ...content.parameters && { parameters: content.parameters },
898
956
  ...content.examples && { examples: content.examples },
899
957
  ...content.license && { license: content.license },
@@ -946,6 +1004,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
946
1004
  const generation = (this.dynamicGenerations.get(id) ?? 0) + 1;
947
1005
  this.dynamicGenerations.set(id, generation);
948
1006
  this.reindex();
1007
+ this.providerIndexed.delete(id);
949
1008
  const providerWrites = mutable ? [
950
1009
  ...removed.map((removedId) => this.removeFromProvider(removedId)),
951
1010
  this.syncProvider(id, async () => {
@@ -954,6 +1013,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
954
1013
  } else {
955
1014
  await mutable.add(content);
956
1015
  }
1016
+ if (this.dynamicGenerations.get(id) === generation) this.providerIndexed.add(id);
957
1017
  }).catch((error) => {
958
1018
  this.scope.logger.warn(
959
1019
  `[SkillRegistry] Failed to index dynamic skill ${id} in storage provider: ${error.message}`
@@ -1001,6 +1061,7 @@ var SkillRegistry = class _SkillRegistry extends RegistryAbstract {
1001
1061
  1
1002
1062
  );
1003
1063
  this.dynamicContents.delete(id);
1064
+ this.providerIndexed.delete(id);
1004
1065
  this.dynamicGenerations.set(id, (this.dynamicGenerations.get(id) ?? 0) + 1);
1005
1066
  if (mutable) this.withdrawn.set(id, ++this.withdrawals);
1006
1067
  }
@@ -2,7 +2,17 @@
2
2
  export { CapabilityCache, CircuitBreaker, CircuitBreakerManager, CircuitOpenError, HealthCheckManager, HealthChecker, McpClientService, buildRemotePromptRecord, buildRemoteResourceRecord, buildRemoteResourceTemplateRecord, buildRemoteToolRecord, createRemotePromptContextClass, createRemotePromptInstance, createRemoteResourceContextClass, createRemoteResourceInstance, createRemoteResourceTemplateInstance, createRemoteToolContextClass, createRemoteToolInstance, isAuthError, isConnectionError, isTransientError, withRetry } from "./remote-mcp/index.mjs";
3
3
  export { DEFAULT_NPM_REGISTRY, ESM_SH_BASE_URL, EsmCacheManager, EsmModuleLoader, MANIFEST_PRIMITIVE_KEYS, VersionPoller, VersionResolver, buildEsmPromptRecord, buildEsmResourceRecord, buildEsmShUrl, buildEsmToolRecord, compareVersions, createEsmPromptContextClass, createEsmPromptInstance, createEsmResourceContextClass, createEsmResourceInstance, createEsmToolContextClass, createEsmToolInstance, esmRegistryAuthSchema, frontMcpPackageManifestSchema, getRegistryUrl, isNewerVersion, isPackageSpecifier, isValidRange, isValidVersion, maxSatisfying, normalizeEsmExport, parsePackageSpecifier, resolveRegistryToken, satisfiesRange } from "./esm-loader/index.mjs";
4
4
  import { McpStatelessClientAdapter, negotiateRemoteProtocol } from "./remote-mcp/mcp-stateless-client.adapter.mjs";
5
- import { JobRegistry, JobInstance, JobPermissionGuard, JobExecutionManager, JobEmitter, JobRunResource } from "./job/index.mjs";
5
+ import {
6
+ JobRegistry,
7
+ JobInstance,
8
+ JobPermissionGuard,
9
+ JobExecutionManager,
10
+ JobAdmission,
11
+ JobEmitter,
12
+ JobRunResource,
13
+ jobRunUri,
14
+ mayAccessRun
15
+ } from "./job/index.mjs";
6
16
  import {
7
17
  ExecuteJobTool,
8
18
  GetJobStatusTool,
@@ -43,6 +53,7 @@ export {
43
53
  ExecuteWorkflowTool,
44
54
  GetJobStatusTool,
45
55
  GetWorkflowStatusTool,
56
+ JobAdmission,
46
57
  JobEmitter,
47
58
  JobExecutionManager,
48
59
  JobInstance,
@@ -67,5 +78,7 @@ export {
67
78
  WorkflowRegistry,
68
79
  WorkflowStepExecutor,
69
80
  createEventStore,
81
+ jobRunUri,
82
+ mayAccessRun,
70
83
  negotiateRemoteProtocol
71
84
  };
@@ -7,14 +7,20 @@ import {
7
7
  surfaceHash
8
8
  } from "./live-surface.mjs";
9
9
  import { keepingListsUnchanged, listsUnchanged } from "./unchanged-lists.mjs";
10
+ import {
11
+ announcesListChangeNow,
12
+ runListChangeBatch
13
+ } from "./list-change-batch.mjs";
10
14
  export {
11
15
  LiveSurface,
12
16
  SURFACE_META_KEY,
17
+ announcesListChangeNow,
13
18
  assertEntryEnabled,
14
19
  enabledItems,
15
20
  fileSignal,
16
21
  isEntryEnabled,
17
22
  keepingListsUnchanged,
18
23
  listsUnchanged,
24
+ runListChangeBatch,
19
25
  surfaceHash
20
26
  };
@@ -0,0 +1,51 @@
1
+ // libs/sdk/src/surface/list-change-batch.ts
2
+ import { AsyncLocalStorage } from "@frontmcp/utils";
3
+ import { listsUnchanged } from "./unchanged-lists.mjs";
4
+ var runningBatches = new AsyncLocalStorage();
5
+ function openBatchOf(lists) {
6
+ for (let run = runningBatches.getStore(); run; run = run.outer) {
7
+ if (run.open && run.lists === lists) return run;
8
+ }
9
+ return void 0;
10
+ }
11
+ async function runListChangeBatch(lists, change) {
12
+ const run = { lists, changed: /* @__PURE__ */ new Set(), outer: runningBatches.getStore(), open: true };
13
+ const batch = { listsRestored: () => run.changed.clear() };
14
+ let outcome;
15
+ try {
16
+ outcome = { completed: true, result: await runningBatches.run(run, () => change(batch)) };
17
+ } catch (error) {
18
+ outcome = { completed: false, error };
19
+ }
20
+ run.open = false;
21
+ const announcementFailure = announceChangedLists(run, lists);
22
+ if (!outcome.completed) throw outcome.error;
23
+ if (announcementFailure) throw announcementFailure.error;
24
+ return outcome.result;
25
+ }
26
+ function announceChangedLists(run, lists) {
27
+ const enclosing = openBatchOf(lists);
28
+ let firstFailure;
29
+ for (const kind of run.changed) {
30
+ if (enclosing) {
31
+ enclosing.changed.add(kind);
32
+ continue;
33
+ }
34
+ try {
35
+ lists[kind].notifyListChanged();
36
+ } catch (error) {
37
+ firstFailure ??= { error };
38
+ }
39
+ }
40
+ return firstFailure;
41
+ }
42
+ function announcesListChangeNow(lists, kind) {
43
+ if (listsUnchanged()) return false;
44
+ const batch = openBatchOf(lists);
45
+ batch?.changed.add(kind);
46
+ return batch === void 0;
47
+ }
48
+ export {
49
+ announcesListChangeNow,
50
+ runListChangeBatch
51
+ };
@@ -2,7 +2,7 @@
2
2
  import { sha256Hex } from "@frontmcp/utils";
3
3
  import { isEnabledSource } from "../common/metadata/enabled.metadata.mjs";
4
4
  import { STATELESS_SESSION_ID } from "../transport/transport.types.mjs";
5
- import { listsUnchanged } from "./unchanged-lists.mjs";
5
+ import { announcesListChangeNow } from "./list-change-batch.mjs";
6
6
  var SURFACE_META_KEY = "frontmcp/surface";
7
7
  var LIST_KINDS = ["tools", "resources", "prompts"];
8
8
  function messageOf(error) {
@@ -37,7 +37,7 @@ var LiveSurface = class {
37
37
  }
38
38
  this.stops.push(
39
39
  this.scope.tools.subscribe({ immediate: false }, () => {
40
- if (!listsUnchanged()) this.toolsVersion++;
40
+ if (announcesListChangeNow(this.scope, "tools")) this.toolsVersion++;
41
41
  })
42
42
  );
43
43
  }
@@ -85,7 +85,6 @@ import {
85
85
  TaskAugmentationRequiredError,
86
86
  TaskConcurrencyLimitError,
87
87
  TaskStoreNotInitializedError,
88
- ToolCredentialsRequiredError,
89
88
  ToolExecutionError,
90
89
  ToolNotConsentedError,
91
90
  ToolNotFoundError
@@ -104,7 +103,7 @@ import { hookOwnerIdOf, isServerEntryOwner } from "../../utils/lineage.utils.mjs
104
103
  import { toolOutputPolicies } from "../tool-output-policy.mjs";
105
104
  import { toolServingMode } from "../ui/serving-mode-default.mjs";
106
105
  import { hasUIConfig, WIDGET_CALL_META_KEY } from "../ui/ui-shared.mjs";
107
- import { evaluateToolCredentialGate } from "./tool-credentials.gate.mjs";
106
+ import { askToOpenConnectPages, credentialsRequiredErrorOf, evaluateToolCredentialGate } from "./tool-credentials.gate.mjs";
108
107
  function isWidgetCall(requestMeta) {
109
108
  return typeof requestMeta === "object" && requestMeta !== null && Reflect.get(requestMeta, WIDGET_CALL_META_KEY) === true;
110
109
  }
@@ -694,11 +693,26 @@ var CallToolFlow = class extends FlowBase {
694
693
  }
695
694
  const toolId = tool.fullName || tool.metadata.name;
696
695
  const missingNames = result.missing.map((m) => m.name);
697
- const authUrl = result.missing.find((m) => m.authUrl)?.authUrl;
698
696
  this.logger.info(
699
697
  `checkToolCredentials: tool "${toolId}" missing required credential(s): ${missingNames.join(", ")}`
700
698
  );
701
- throw new ToolCredentialsRequiredError({ toolId, providers: missingNames, authUrl });
699
+ const connectPageAsk = {
700
+ context: this.tryGetContext(),
701
+ getClientCapabilities: (sessionId) => this.scope.notifications.getClientCapabilities(sessionId),
702
+ elicitationEnabled: this.scope.metadata.elicitation?.enabled === true,
703
+ toolId,
704
+ toolInput: this.state.input?.arguments,
705
+ signal: this.state.executionAbort?.signal
706
+ };
707
+ let missing = result.missing;
708
+ if (await askToOpenConnectPages(connectPageAsk, missing)) {
709
+ missing = (await evaluateToolCredentialGate(providers, (token) => toolContext.tryGet(token))).missing;
710
+ if (missing.length === 0) {
711
+ this.logger.verbose("checkToolCredentials:done (connected through the connect page)");
712
+ return;
713
+ }
714
+ }
715
+ throw credentialsRequiredErrorOf(toolId, missing);
702
716
  }
703
717
  async acquireQuota() {
704
718
  this.logger.verbose("acquireQuota:start");