@mastra/core 1.16.0-alpha.2 → 1.16.0-alpha.3

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 (162) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/index.cjs +8 -8
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{chunk-4R7XCDYZ.js → chunk-26OOSNWN.js} +3 -3
  6. package/dist/{chunk-4R7XCDYZ.js.map → chunk-26OOSNWN.js.map} +1 -1
  7. package/dist/{chunk-373WBBIV.js → chunk-2CEWKM43.js} +3 -3
  8. package/dist/{chunk-373WBBIV.js.map → chunk-2CEWKM43.js.map} +1 -1
  9. package/dist/{chunk-6FFPNMST.cjs → chunk-2NDTZII6.cjs} +15 -15
  10. package/dist/{chunk-6FFPNMST.cjs.map → chunk-2NDTZII6.cjs.map} +1 -1
  11. package/dist/{chunk-4B2CHAMZ.cjs → chunk-4EZX3JLF.cjs} +9 -9
  12. package/dist/{chunk-4B2CHAMZ.cjs.map → chunk-4EZX3JLF.cjs.map} +1 -1
  13. package/dist/{chunk-L4AQYWBK.cjs → chunk-4LDSJHWQ.cjs} +7 -7
  14. package/dist/{chunk-L4AQYWBK.cjs.map → chunk-4LDSJHWQ.cjs.map} +1 -1
  15. package/dist/{chunk-UA5AY2ES.js → chunk-76GUV7TZ.js} +3 -3
  16. package/dist/{chunk-UA5AY2ES.js.map → chunk-76GUV7TZ.js.map} +1 -1
  17. package/dist/{chunk-JY32HS2J.js → chunk-7LMIK23W.js} +3 -3
  18. package/dist/{chunk-JY32HS2J.js.map → chunk-7LMIK23W.js.map} +1 -1
  19. package/dist/{chunk-FQJZIBZ2.js → chunk-A25ZFPG7.js} +6 -6
  20. package/dist/{chunk-FQJZIBZ2.js.map → chunk-A25ZFPG7.js.map} +1 -1
  21. package/dist/{chunk-TQTUU6QD.cjs → chunk-AVOGYFGK.cjs} +83 -83
  22. package/dist/{chunk-TQTUU6QD.cjs.map → chunk-AVOGYFGK.cjs.map} +1 -1
  23. package/dist/{chunk-PLWEBAHH.cjs → chunk-BF2JWKWL.cjs} +5 -5
  24. package/dist/{chunk-PLWEBAHH.cjs.map → chunk-BF2JWKWL.cjs.map} +1 -1
  25. package/dist/{chunk-DJLBGTUV.cjs → chunk-BXDWBXQW.cjs} +5 -5
  26. package/dist/{chunk-DJLBGTUV.cjs.map → chunk-BXDWBXQW.cjs.map} +1 -1
  27. package/dist/{chunk-CJVTGET7.js → chunk-GZWOMZ7C.js} +3 -3
  28. package/dist/{chunk-CJVTGET7.js.map → chunk-GZWOMZ7C.js.map} +1 -1
  29. package/dist/{chunk-HQKKB3UP.js → chunk-IS7VFXXN.js} +8 -8
  30. package/dist/{chunk-HQKKB3UP.js.map → chunk-IS7VFXXN.js.map} +1 -1
  31. package/dist/{chunk-4DW75LWG.js → chunk-JBAMLTYP.js} +4 -4
  32. package/dist/{chunk-4DW75LWG.js.map → chunk-JBAMLTYP.js.map} +1 -1
  33. package/dist/{chunk-3OZVV5J7.js → chunk-JO36CQSY.js} +4 -4
  34. package/dist/{chunk-3OZVV5J7.js.map → chunk-JO36CQSY.js.map} +1 -1
  35. package/dist/{chunk-55W2K42G.js → chunk-MLCFE6MR.js} +15 -3
  36. package/dist/chunk-MLCFE6MR.js.map +1 -0
  37. package/dist/{chunk-GXAKTLZ3.cjs → chunk-MQ2YFSTS.cjs} +185 -185
  38. package/dist/{chunk-GXAKTLZ3.cjs.map → chunk-MQ2YFSTS.cjs.map} +1 -1
  39. package/dist/{chunk-4MG6J5RS.cjs → chunk-Q7B3NPO3.cjs} +3 -3
  40. package/dist/{chunk-4MG6J5RS.cjs.map → chunk-Q7B3NPO3.cjs.map} +1 -1
  41. package/dist/{chunk-4TMCYZ72.cjs → chunk-RKGUSDHX.cjs} +53 -53
  42. package/dist/{chunk-4TMCYZ72.cjs.map → chunk-RKGUSDHX.cjs.map} +1 -1
  43. package/dist/{chunk-563KV7S2.js → chunk-STU7CG7E.js} +5 -5
  44. package/dist/{chunk-563KV7S2.js.map → chunk-STU7CG7E.js.map} +1 -1
  45. package/dist/{chunk-GZ2ZPBMU.js → chunk-TKGXEXRR.js} +21 -12
  46. package/dist/chunk-TKGXEXRR.js.map +1 -0
  47. package/dist/{chunk-O3WTNJXV.js → chunk-TQO7BSJX.js} +3 -3
  48. package/dist/{chunk-O3WTNJXV.js.map → chunk-TQO7BSJX.js.map} +1 -1
  49. package/dist/{chunk-D5DBRZH3.js → chunk-TUSCHVH3.js} +5 -4
  50. package/dist/chunk-TUSCHVH3.js.map +1 -0
  51. package/dist/{chunk-325Q6NH6.cjs → chunk-V7KMU6NL.cjs} +7 -7
  52. package/dist/{chunk-325Q6NH6.cjs.map → chunk-V7KMU6NL.cjs.map} +1 -1
  53. package/dist/{chunk-2DPHD6NF.cjs → chunk-VQMIFPSC.cjs} +70 -61
  54. package/dist/chunk-VQMIFPSC.cjs.map +1 -0
  55. package/dist/{chunk-L53XY7WT.js → chunk-WEKILIGZ.js} +161 -63
  56. package/dist/chunk-WEKILIGZ.js.map +1 -0
  57. package/dist/{chunk-KWQ4YIWP.cjs → chunk-WZ2EJZ7R.cjs} +6 -6
  58. package/dist/{chunk-KWQ4YIWP.cjs.map → chunk-WZ2EJZ7R.cjs.map} +1 -1
  59. package/dist/{chunk-P7KTLFJM.js → chunk-WZQ2AJZV.js} +8 -8
  60. package/dist/{chunk-P7KTLFJM.js.map → chunk-WZQ2AJZV.js.map} +1 -1
  61. package/dist/{chunk-GYLHNAH7.cjs → chunk-XME4PQE7.cjs} +15 -3
  62. package/dist/chunk-XME4PQE7.cjs.map +1 -0
  63. package/dist/{chunk-Q7EDK6IW.cjs → chunk-XYT5D2T7.cjs} +9 -9
  64. package/dist/{chunk-Q7EDK6IW.cjs.map → chunk-XYT5D2T7.cjs.map} +1 -1
  65. package/dist/{chunk-KQ3SJZG5.cjs → chunk-YSPKTAYB.cjs} +182 -84
  66. package/dist/chunk-YSPKTAYB.cjs.map +1 -0
  67. package/dist/{chunk-3XWXW2YI.cjs → chunk-YVFTL5BS.cjs} +17 -16
  68. package/dist/chunk-YVFTL5BS.cjs.map +1 -0
  69. package/dist/datasets/index.cjs +17 -17
  70. package/dist/datasets/index.js +2 -2
  71. package/dist/docs/SKILL.md +1 -1
  72. package/dist/docs/assets/SOURCE_MAP.json +226 -226
  73. package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +132 -2
  74. package/dist/docs/references/docs-workspace-skills.md +23 -0
  75. package/dist/docs/references/reference-tools-create-tool.md +1 -1
  76. package/dist/docs/references/reference-workspace-workspace-class.md +13 -1
  77. package/dist/evals/index.cjs +5 -5
  78. package/dist/evals/index.js +2 -2
  79. package/dist/evals/scoreTraces/index.cjs +3 -3
  80. package/dist/evals/scoreTraces/index.js +1 -1
  81. package/dist/harness/index.cjs +17 -17
  82. package/dist/harness/index.js +7 -7
  83. package/dist/index.cjs +2 -2
  84. package/dist/index.js +1 -1
  85. package/dist/integration/index.cjs +2 -2
  86. package/dist/integration/index.js +1 -1
  87. package/dist/llm/index.cjs +16 -16
  88. package/dist/llm/index.js +5 -5
  89. package/dist/loop/index.cjs +14 -14
  90. package/dist/loop/index.js +1 -1
  91. package/dist/loop/network/index.d.ts.map +1 -1
  92. package/dist/mastra/index.cjs +2 -2
  93. package/dist/mastra/index.js +1 -1
  94. package/dist/memory/index.cjs +14 -14
  95. package/dist/memory/index.js +1 -1
  96. package/dist/models-dev-2FOUJALF.cjs +12 -0
  97. package/dist/{models-dev-OFI5OSM7.cjs.map → models-dev-2FOUJALF.cjs.map} +1 -1
  98. package/dist/models-dev-A55UVGDD.js +3 -0
  99. package/dist/{models-dev-OU3ACSEQ.js.map → models-dev-A55UVGDD.js.map} +1 -1
  100. package/dist/netlify-I3P5QPXG.cjs +12 -0
  101. package/dist/{netlify-YVCTG2Z3.cjs.map → netlify-I3P5QPXG.cjs.map} +1 -1
  102. package/dist/netlify-MF3L2BRE.js +3 -0
  103. package/dist/{netlify-OPNSZBGQ.js.map → netlify-MF3L2BRE.js.map} +1 -1
  104. package/dist/processor-provider/index.cjs +10 -10
  105. package/dist/processor-provider/index.js +1 -1
  106. package/dist/processors/index.cjs +42 -42
  107. package/dist/processors/index.js +1 -1
  108. package/dist/processors/processors/skills.d.ts.map +1 -1
  109. package/dist/provider-registry-J76YNM72.js +3 -0
  110. package/dist/{provider-registry-KYR3I44P.js.map → provider-registry-J76YNM72.js.map} +1 -1
  111. package/dist/provider-registry-QB6DEJ7U.cjs +40 -0
  112. package/dist/{provider-registry-73NPBVKH.cjs.map → provider-registry-QB6DEJ7U.cjs.map} +1 -1
  113. package/dist/relevance/index.cjs +3 -3
  114. package/dist/relevance/index.js +1 -1
  115. package/dist/storage/index.cjs +74 -74
  116. package/dist/storage/index.js +1 -1
  117. package/dist/stream/index.cjs +8 -8
  118. package/dist/stream/index.js +1 -1
  119. package/dist/test-utils/llm-mock.cjs +4 -4
  120. package/dist/test-utils/llm-mock.js +1 -1
  121. package/dist/tool-loop-agent/index.cjs +4 -4
  122. package/dist/tool-loop-agent/index.js +1 -1
  123. package/dist/tools/index.cjs +7 -7
  124. package/dist/tools/index.js +1 -1
  125. package/dist/tools/is-vercel-tool.cjs +2 -2
  126. package/dist/tools/is-vercel-tool.js +1 -1
  127. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  128. package/dist/tools/tool.d.ts.map +1 -1
  129. package/dist/tools/types.d.ts +1 -0
  130. package/dist/tools/types.d.ts.map +1 -1
  131. package/dist/utils.cjs +23 -23
  132. package/dist/utils.d.ts +1 -0
  133. package/dist/utils.d.ts.map +1 -1
  134. package/dist/utils.js +1 -1
  135. package/dist/vector/index.cjs +7 -7
  136. package/dist/vector/index.js +1 -1
  137. package/dist/workflows/evented/index.cjs +10 -10
  138. package/dist/workflows/evented/index.js +1 -1
  139. package/dist/workflows/index.cjs +24 -24
  140. package/dist/workflows/index.js +1 -1
  141. package/dist/workspace/index.cjs +68 -68
  142. package/dist/workspace/index.js +1 -1
  143. package/dist/workspace/skills/tools.d.ts.map +1 -1
  144. package/dist/workspace/skills/types.d.ts +9 -5
  145. package/dist/workspace/skills/types.d.ts.map +1 -1
  146. package/dist/workspace/skills/workspace-skills.d.ts.map +1 -1
  147. package/dist/workspace/workspace.d.ts +1 -1
  148. package/package.json +7 -7
  149. package/dist/chunk-2DPHD6NF.cjs.map +0 -1
  150. package/dist/chunk-3XWXW2YI.cjs.map +0 -1
  151. package/dist/chunk-55W2K42G.js.map +0 -1
  152. package/dist/chunk-D5DBRZH3.js.map +0 -1
  153. package/dist/chunk-GYLHNAH7.cjs.map +0 -1
  154. package/dist/chunk-GZ2ZPBMU.js.map +0 -1
  155. package/dist/chunk-KQ3SJZG5.cjs.map +0 -1
  156. package/dist/chunk-L53XY7WT.js.map +0 -1
  157. package/dist/models-dev-OFI5OSM7.cjs +0 -12
  158. package/dist/models-dev-OU3ACSEQ.js +0 -3
  159. package/dist/netlify-OPNSZBGQ.js +0 -3
  160. package/dist/netlify-YVCTG2Z3.cjs +0 -12
  161. package/dist/provider-registry-73NPBVKH.cjs +0 -40
  162. package/dist/provider-registry-KYR3I44P.js +0 -3
@@ -1,4 +1,4 @@
1
- import { createTool } from './chunk-55W2K42G.js';
1
+ import { createTool } from './chunk-MLCFE6MR.js';
2
2
  import { MastraBase } from './chunk-WCAFTXGK.js';
3
3
  import { RegisteredLogger } from './chunk-X2WMFSPB.js';
4
4
  import * as nodePath from 'path';
@@ -4994,7 +4994,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
4994
4994
  #skillsResolver;
4995
4995
  #searchEngine;
4996
4996
  #validateOnLoad;
4997
- /** Map of skill name -> full skill data */
4997
+ /** Map of skill name -> array of candidates (supports same-named skills from different sources) */
4998
4998
  #skills = /* @__PURE__ */ new Map();
4999
4999
  /** Whether skills have been discovered */
5000
5000
  #initialized = false;
@@ -5022,28 +5022,91 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5022
5022
  // ===========================================================================
5023
5023
  async list() {
5024
5024
  await this.#ensureInitialized();
5025
- return Array.from(this.#skills.values()).map((skill) => ({
5026
- name: skill.name,
5027
- description: skill.description,
5028
- license: skill.license,
5029
- compatibility: skill.compatibility,
5030
- metadata: skill.metadata
5031
- }));
5025
+ const results = [];
5026
+ for (const candidates of this.#skills.values()) {
5027
+ for (const skill of candidates) {
5028
+ results.push({
5029
+ name: skill.name,
5030
+ path: skill.path,
5031
+ description: skill.description,
5032
+ license: skill.license,
5033
+ compatibility: skill.compatibility,
5034
+ metadata: skill.metadata
5035
+ });
5036
+ }
5037
+ }
5038
+ return results;
5032
5039
  }
5033
5040
  async get(name) {
5034
5041
  await this.#ensureInitialized();
5035
- const skill = this.#skills.get(name);
5042
+ const skill = this.#resolveByName(name) ?? this.#resolveByPath(name);
5036
5043
  if (!skill) return null;
5037
5044
  const { indexableContent: _, ...skillData } = skill;
5038
5045
  return skillData;
5039
5046
  }
5040
5047
  async has(name) {
5041
5048
  await this.#ensureInitialized();
5042
- return this.#skills.has(name);
5049
+ return (this.#resolveByName(name) ?? this.#resolveByPath(name)) !== null;
5050
+ }
5051
+ // ===========================================================================
5052
+ // Skill Resolution (Private)
5053
+ // ===========================================================================
5054
+ /**
5055
+ * Resolve a skill by name with tie-breaking when multiple candidates exist.
5056
+ * Priority: local > managed > external, then alphabetical path.
5057
+ */
5058
+ #resolveByName(name) {
5059
+ const candidates = this.#skills.get(name);
5060
+ if (!candidates || candidates.length === 0) return null;
5061
+ return this.#tieBreak(candidates);
5062
+ }
5063
+ /**
5064
+ * Resolve a skill by exact path (escape hatch for disambiguation).
5065
+ * Searches across all candidate arrays.
5066
+ */
5067
+ #resolveByPath(skillPath) {
5068
+ for (const candidates of this.#skills.values()) {
5069
+ const match = candidates.find((s) => s.path === skillPath);
5070
+ if (match) return match;
5071
+ }
5072
+ return null;
5073
+ }
5074
+ /**
5075
+ * Pick the winning skill from an array of same-named candidates.
5076
+ * When there's only one candidate, returns it directly (no warning).
5077
+ * When there are multiple, applies source-type priority and warns.
5078
+ *
5079
+ * Priority: local (0) > managed (1) > external (2).
5080
+ * Throws if source-type priority can't resolve the tie (e.g., two local skills with same name).
5081
+ */
5082
+ #tieBreak(candidates) {
5083
+ if (candidates.length === 0) return null;
5084
+ if (candidates.length === 1) return candidates[0];
5085
+ const SOURCE_PRIORITY = { local: 0, managed: 1, external: 2 };
5086
+ const sorted = [...candidates].sort((a, b) => {
5087
+ const aPri = SOURCE_PRIORITY[a.source.type] ?? 99;
5088
+ const bPri = SOURCE_PRIORITY[b.source.type] ?? 99;
5089
+ if (aPri !== bPri) return aPri - bPri;
5090
+ return a.path.localeCompare(b.path);
5091
+ });
5092
+ const winner = sorted[0];
5093
+ const runnerUp = sorted[1];
5094
+ if (winner.source.type === runnerUp.source.type) {
5095
+ const paths = sorted.filter((s) => s.source.type === winner.source.type).map((s) => `"${s.path}"`).join(", ");
5096
+ throw new Error(
5097
+ `[WorkspaceSkills] Cannot resolve skill "${winner.name}": multiple ${winner.source.type} skills found at ${paths}. Rename one or move it to a different source type.`
5098
+ );
5099
+ }
5100
+ console.warn(
5101
+ `[WorkspaceSkills] Multiple skills named "${winner.name}" found. Using "${winner.path}" (source: ${winner.source.type}). Other candidates: ${sorted.slice(1).map((s) => `"${s.path}" (${s.source.type})`).join(", ")}`
5102
+ );
5103
+ return winner;
5043
5104
  }
5044
5105
  async refresh() {
5045
- for (const skill of this.#skills.values()) {
5046
- await this.#removeSkillFromIndex(skill);
5106
+ for (const candidates of this.#skills.values()) {
5107
+ for (const skill of candidates) {
5108
+ await this.#removeSkillFromIndex(skill);
5109
+ }
5047
5110
  }
5048
5111
  this.#skills.clear();
5049
5112
  this.#initialized = false;
@@ -5078,20 +5141,31 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5078
5141
  }
5079
5142
  const source = this.#inferSource(skillPath);
5080
5143
  const skill = await this.#parseSkillFile(skillFilePath, dirName, source);
5081
- const existing = this.#skills.get(skill.name);
5082
- if (existing) {
5083
- await this.#removeSkillFromIndex(existing);
5144
+ const candidates = this.#skills.get(skill.name) ?? [];
5145
+ const existingIdx = candidates.findIndex((s) => s.path === skill.path);
5146
+ if (existingIdx >= 0) {
5147
+ await this.#removeSkillFromIndex(candidates[existingIdx]);
5148
+ candidates[existingIdx] = skill;
5149
+ } else {
5150
+ candidates.push(skill);
5084
5151
  }
5085
- this.#skills.set(skill.name, skill);
5152
+ this.#skills.set(skill.name, candidates);
5086
5153
  await this.#indexSkill(skill);
5087
5154
  this.#lastDiscoveryTime = Date.now();
5088
5155
  }
5089
5156
  async removeSkill(skillName) {
5090
5157
  await this.#ensureInitialized();
5091
- const skill = this.#skills.get(skillName);
5158
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5092
5159
  if (!skill) return;
5093
5160
  await this.#removeSkillFromIndex(skill);
5094
- this.#skills.delete(skillName);
5161
+ const candidates = this.#skills.get(skill.name);
5162
+ if (candidates) {
5163
+ const idx = candidates.findIndex((s) => s.path === skill.path);
5164
+ if (idx >= 0) candidates.splice(idx, 1);
5165
+ if (candidates.length === 0) {
5166
+ this.#skills.delete(skill.name);
5167
+ }
5168
+ }
5095
5169
  this.#lastDiscoveryTime = Date.now();
5096
5170
  }
5097
5171
  /**
@@ -5129,17 +5203,20 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5129
5203
  });
5130
5204
  const results = [];
5131
5205
  for (const result of searchResults) {
5132
- const skillName = result.metadata?.skillName;
5206
+ const skillPath = result.metadata?.skillPath;
5133
5207
  const source = result.metadata?.source;
5134
- if (!skillName || !source) continue;
5135
- if (skillNames && !skillNames.includes(skillName)) {
5208
+ if (!skillPath || !source) continue;
5209
+ const skill = this.#resolveByPath(skillPath);
5210
+ if (!skill) continue;
5211
+ if (skillNames && !skillNames.includes(skill.name)) {
5136
5212
  continue;
5137
5213
  }
5138
5214
  if (!includeReferences && source !== "SKILL.md") {
5139
5215
  continue;
5140
5216
  }
5141
5217
  results.push({
5142
- skillName,
5218
+ skillName: skill.name,
5219
+ skillPath: skill.path,
5143
5220
  source,
5144
5221
  content: result.content,
5145
5222
  score: result.score,
@@ -5155,7 +5232,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5155
5232
  // ===========================================================================
5156
5233
  async getReference(skillName, referencePath) {
5157
5234
  await this.#ensureInitialized();
5158
- const skill = this.#skills.get(skillName);
5235
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5159
5236
  if (!skill) return null;
5160
5237
  const safeRefPath = this.#assertRelativePath(referencePath, "reference");
5161
5238
  const refFilePath = this.#joinPath(skill.path, safeRefPath);
@@ -5171,7 +5248,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5171
5248
  }
5172
5249
  async getScript(skillName, scriptPath) {
5173
5250
  await this.#ensureInitialized();
5174
- const skill = this.#skills.get(skillName);
5251
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5175
5252
  if (!skill) return null;
5176
5253
  const safeScriptPath = this.#assertRelativePath(scriptPath, "script");
5177
5254
  const scriptFilePath = this.#joinPath(skill.path, safeScriptPath);
@@ -5187,7 +5264,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5187
5264
  }
5188
5265
  async getAsset(skillName, assetPath) {
5189
5266
  await this.#ensureInitialized();
5190
- const skill = this.#skills.get(skillName);
5267
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5191
5268
  if (!skill) return null;
5192
5269
  const safeAssetPath = this.#assertRelativePath(assetPath, "asset");
5193
5270
  const assetFilePath = this.#joinPath(skill.path, safeAssetPath);
@@ -5206,17 +5283,17 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5206
5283
  // ===========================================================================
5207
5284
  async listReferences(skillName) {
5208
5285
  await this.#ensureInitialized();
5209
- const skill = this.#skills.get(skillName);
5286
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5210
5287
  return skill?.references ?? [];
5211
5288
  }
5212
5289
  async listScripts(skillName) {
5213
5290
  await this.#ensureInitialized();
5214
- const skill = this.#skills.get(skillName);
5291
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5215
5292
  return skill?.scripts ?? [];
5216
5293
  }
5217
5294
  async listAssets(skillName) {
5218
5295
  await this.#ensureInitialized();
5219
- const skill = this.#skills.get(skillName);
5296
+ const skill = this.#resolveByName(skillName) ?? this.#resolveByPath(skillName);
5220
5297
  return skill?.assets ?? [];
5221
5298
  }
5222
5299
  // ===========================================================================
@@ -5247,6 +5324,20 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5247
5324
  })();
5248
5325
  await this.#initPromise;
5249
5326
  }
5327
+ /**
5328
+ * Add a skill to the candidates map, keyed by name.
5329
+ * Replaces an existing entry at the same path (update case), otherwise appends.
5330
+ */
5331
+ #addToSkillsMap(skill) {
5332
+ const candidates = this.#skills.get(skill.name) ?? [];
5333
+ const idx = candidates.findIndex((s) => s.path === skill.path);
5334
+ if (idx >= 0) {
5335
+ candidates[idx] = skill;
5336
+ } else {
5337
+ candidates.push(skill);
5338
+ }
5339
+ this.#skills.set(skill.name, candidates);
5340
+ }
5250
5341
  /**
5251
5342
  * Discover skills from all skills paths.
5252
5343
  * Uses currently resolved paths (must be set before calling).
@@ -5331,7 +5422,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5331
5422
  if (await this.#source.exists(skillFilePath)) {
5332
5423
  try {
5333
5424
  const skill = await this.#parseSkillFile(skillFilePath, entry.name, source);
5334
- this.#skills.set(skill.name, skill);
5425
+ this.#addToSkillsMap(skill);
5335
5426
  await this.#indexSkill(skill);
5336
5427
  } catch (error) {
5337
5428
  if (error instanceof Error) {
@@ -5366,7 +5457,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5366
5457
  const dirName = skillDir.split("/").pop() || skillDir;
5367
5458
  try {
5368
5459
  const skill = await this.#parseSkillFile(skillsPath, dirName, source);
5369
- this.#skills.set(skill.name, skill);
5460
+ this.#addToSkillsMap(skill);
5370
5461
  await this.#indexSkill(skill);
5371
5462
  } catch (error) {
5372
5463
  if (error instanceof Error) {
@@ -5381,7 +5472,7 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5381
5472
  const dirName = skillsPath.split("/").pop() || skillsPath;
5382
5473
  try {
5383
5474
  const skill = await this.#parseSkillFile(skillFilePath, dirName, source);
5384
- this.#skills.set(skill.name, skill);
5475
+ this.#addToSkillsMap(skill);
5385
5476
  await this.#indexSkill(skill);
5386
5477
  } catch (error) {
5387
5478
  if (error instanceof Error) {
@@ -5473,8 +5564,10 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5473
5564
  const parsed = matter(content);
5474
5565
  const frontmatter = parsed.data;
5475
5566
  const body = parsed.content.trim();
5567
+ const skillPath = this.#getParentPath(filePath);
5476
5568
  const metadata = {
5477
5569
  name: frontmatter.name,
5570
+ path: skillPath,
5478
5571
  description: frontmatter.description,
5479
5572
  license: frontmatter.license,
5480
5573
  compatibility: frontmatter.compatibility,
@@ -5487,14 +5580,12 @@ var WorkspaceSkillsImpl = class _WorkspaceSkillsImpl {
5487
5580
  ${validation.errors.join("\n")}`);
5488
5581
  }
5489
5582
  }
5490
- const skillPath = this.#getParentPath(filePath);
5491
5583
  const references = await this.#discoverFilesInSubdir(skillPath, "references");
5492
5584
  const scripts = await this.#discoverFilesInSubdir(skillPath, "scripts");
5493
5585
  const assets = await this.#discoverFilesInSubdir(skillPath, "assets");
5494
5586
  const indexableContent = await this.#buildIndexableContent(body, skillPath, references);
5495
5587
  return {
5496
5588
  ...metadata,
5497
- path: skillPath,
5498
5589
  instructions: body,
5499
5590
  source,
5500
5591
  references,
@@ -5572,7 +5663,7 @@ ${validation.errors.join("\n")}`);
5572
5663
  */
5573
5664
  async #removeSkillFromIndex(skill) {
5574
5665
  if (!this.#searchEngine?.remove) return;
5575
- const ids = [`skill:${skill.name}:SKILL.md`, ...skill.references.map((r) => `skill:${skill.name}:${r}`)];
5666
+ const ids = [`skill:${skill.path}:SKILL.md`, ...skill.references.map((r) => `skill:${skill.path}:${r}`)];
5576
5667
  for (const id of ids) {
5577
5668
  try {
5578
5669
  await this.#searchEngine.remove(id);
@@ -5597,10 +5688,10 @@ ${validation.errors.join("\n")}`);
5597
5688
  async #indexSkill(skill) {
5598
5689
  if (!this.#searchEngine) return;
5599
5690
  await this.#searchEngine.index({
5600
- id: `skill:${skill.name}:SKILL.md`,
5691
+ id: `skill:${skill.path}:SKILL.md`,
5601
5692
  content: skill.instructions,
5602
5693
  metadata: {
5603
- skillName: skill.name,
5694
+ skillPath: skill.path,
5604
5695
  source: "SKILL.md"
5605
5696
  }
5606
5697
  });
@@ -5610,10 +5701,10 @@ ${validation.errors.join("\n")}`);
5610
5701
  const rawContent = await this.#source.readFile(fullPath);
5611
5702
  const content = typeof rawContent === "string" ? rawContent : rawContent.toString("utf-8");
5612
5703
  await this.#searchEngine.index({
5613
- id: `skill:${skill.name}:${refPath}`,
5704
+ id: `skill:${skill.path}:${refPath}`,
5614
5705
  content,
5615
5706
  metadata: {
5616
- skillName: skill.name,
5707
+ skillPath: skill.path,
5617
5708
  source: `references/${refPath}`
5618
5709
  }
5619
5710
  });
@@ -5628,13 +5719,16 @@ ${validation.errors.join("\n")}`);
5628
5719
  const { topK = 5, skillNames, includeReferences = true } = options;
5629
5720
  const queryLower = query.toLowerCase();
5630
5721
  const results = [];
5631
- for (const skill of this.#skills.values()) {
5722
+ for (const candidates of this.#skills.values()) {
5723
+ const skill = this.#tieBreak(candidates);
5724
+ if (!skill) continue;
5632
5725
  if (skillNames && !skillNames.includes(skill.name)) {
5633
5726
  continue;
5634
5727
  }
5635
5728
  if (skill.instructions.toLowerCase().includes(queryLower)) {
5636
5729
  results.push({
5637
5730
  skillName: skill.name,
5731
+ skillPath: skill.path,
5638
5732
  source: "SKILL.md",
5639
5733
  content: skill.instructions.substring(0, 200),
5640
5734
  score: 1
@@ -5647,6 +5741,7 @@ ${validation.errors.join("\n")}`);
5647
5741
  if (content && content.toLowerCase().includes(queryLower)) {
5648
5742
  results.push({
5649
5743
  skillName: skill.name,
5744
+ skillPath: skill.path,
5650
5745
  source: `references/${refPath}`,
5651
5746
  content: content.substring(0, 200),
5652
5747
  score: 0.8
@@ -5852,20 +5947,24 @@ function createSkillTools(skills) {
5852
5947
  skill_read: createSkillReadTool(skills)
5853
5948
  };
5854
5949
  }
5950
+ async function resolveSkill(skills, identifier) {
5951
+ const skill = await skills.get(identifier);
5952
+ if (skill) return { skill };
5953
+ const allSkills = await skills.list();
5954
+ const skillEntries = allSkills.map((s) => `${s.name} (${s.path})`);
5955
+ return { notFound: `Skill "${identifier}" not found. Available skills: ${skillEntries.join(", ")}` };
5956
+ }
5855
5957
  function createSkillTool(skills) {
5856
5958
  const tool = createTool({
5857
5959
  id: "skill",
5858
5960
  description: "Activate a skill to load its full instructions. You should activate skills proactively when they are relevant to the user's request without asking for permission first.",
5859
5961
  inputSchema: z.object({
5860
- name: z.string().describe("The name of the skill to activate")
5962
+ name: z.string().describe("The name or path of the skill to activate. Use the path when multiple skills share the same name.")
5861
5963
  }),
5862
5964
  execute: async ({ name }) => {
5863
- const skill = await skills.get(name);
5864
- if (!skill) {
5865
- const skillsList = await skills.list();
5866
- const skillNames = skillsList.map((s) => s.name);
5867
- return `Skill "${name}" not found. Available skills: ${skillNames.join(", ")}`;
5868
- }
5965
+ const result = await resolveSkill(skills, name);
5966
+ if ("notFound" in result) return result.notFound;
5967
+ const { skill } = result;
5869
5968
  const parts = [skill.instructions];
5870
5969
  if (skill.references?.length) {
5871
5970
  parts.push(`
@@ -5919,32 +6018,31 @@ function createSkillReadTool(skills) {
5919
6018
  id: "skill_read",
5920
6019
  description: "Read a file from a skill directory (references, scripts, or assets). The path is relative to the skill root.",
5921
6020
  inputSchema: z.object({
5922
- skillName: z.string().describe("The name of the skill"),
6021
+ skillName: z.string().describe("The name or path of the skill. Use the path when multiple skills share the same name."),
5923
6022
  path: z.string().describe('Path to the file relative to the skill root (e.g. "references/colors.md", "scripts/run.sh")'),
5924
6023
  startLine: z.number().optional().describe("Starting line number (1-indexed). If omitted, starts from the beginning."),
5925
6024
  endLine: z.number().optional().describe("Ending line number (1-indexed, inclusive). If omitted, reads to the end.")
5926
6025
  }),
5927
6026
  execute: async ({ skillName, path: path7, startLine, endLine }) => {
5928
- if (!await skills.has(skillName)) {
5929
- return `Skill "${skillName}" not found.`;
5930
- }
6027
+ const resolved = await resolveSkill(skills, skillName);
6028
+ if ("notFound" in resolved) return resolved.notFound;
6029
+ const resolvedPath = resolved.skill.path;
5931
6030
  let content = null;
5932
- content = await skills.getReference(skillName, path7);
5933
- if (content === null) content = await skills.getScript(skillName, path7);
5934
- if (content === null) content = await skills.getAsset(skillName, path7);
6031
+ content = await skills.getReference(resolvedPath, path7);
6032
+ if (content === null) content = await skills.getScript(resolvedPath, path7);
6033
+ if (content === null) content = await skills.getAsset(resolvedPath, path7);
5935
6034
  if (content === null) {
5936
- const refs = (await skills.listReferences(skillName)).map((f) => `references/${f}`);
5937
- const scripts = (await skills.listScripts(skillName)).map((f) => `scripts/${f}`);
5938
- const assets = (await skills.listAssets(skillName)).map((f) => `assets/${f}`);
5939
- const allFiles = [...refs, ...scripts, ...assets];
6035
+ const refs = (await skills.listReferences(resolvedPath)).map((f) => `references/${f}`);
6036
+ const scriptsList = (await skills.listScripts(resolvedPath)).map((f) => `scripts/${f}`);
6037
+ const assets = (await skills.listAssets(resolvedPath)).map((f) => `assets/${f}`);
6038
+ const allFiles = [...refs, ...scriptsList, ...assets];
5940
6039
  const fileList = allFiles.length > 0 ? `
5941
6040
  Available files: ${allFiles.join(", ")}` : "";
5942
6041
  return `File "${path7}" not found in skill "${skillName}".${fileList}`;
5943
6042
  }
5944
6043
  const textContent = typeof content === "string" ? content : content.toString("utf-8");
5945
6044
  if (textContent.slice(0, 1e3).includes("\0")) {
5946
- const skill = await skills.get(skillName);
5947
- const fullPath = skill ? `${skill.path}/${path7}` : path7;
6045
+ const fullPath = `${resolved.skill.path}/${path7}`;
5948
6046
  const size = typeof content === "string" ? Buffer.byteLength(content) : content.length;
5949
6047
  return `Binary file: ${fullPath} (${size} bytes)`;
5950
6048
  }
@@ -6125,7 +6223,7 @@ var Workspace = class {
6125
6223
  * @example
6126
6224
  * ```typescript
6127
6225
  * const skills = await workspace.skills?.list();
6128
- * const skill = await workspace.skills?.get('brand-guidelines');
6226
+ * const skill = await workspace.skills?.get('skills/brand-guidelines');
6129
6227
  * const results = await workspace.skills?.search('brand colors');
6130
6228
  * ```
6131
6229
  */
@@ -8001,5 +8099,5 @@ function createWorkspaceTools(workspace) {
8001
8099
  }
8002
8100
 
8003
8101
  export { BM25Index, CompositeFilesystem, CompositeVersionedSkillSource, DirectoryNotEmptyError, DirectoryNotFoundError, FileExistsError, FileNotFoundError, FileReadRequiredError, FilesystemError, FilesystemNotAvailableError, FilesystemNotMountableError, FilesystemNotReadyError, IsDirectoryError, IsolationUnavailableError, LocalFilesystem, LocalSandbox, LocalSkillSource, MastraFilesystem, MastraSandbox, MountError, MountManager, MountNotSupportedError, NotDirectoryError, PermissionError, ProcessHandle, SandboxError, SandboxExecutionError, SandboxFeatureNotSupportedError, SandboxNotAvailableError, SandboxNotReadyError, SandboxProcessManager, SandboxTimeoutError, SearchNotAvailableError, StaleFileError, VersionedSkillSource, WORKSPACE_TOOLS, WORKSPACE_TOOLS_PREFIX, Workspace, WorkspaceError, WorkspaceNotAvailableError, WorkspaceNotReadyError, WorkspaceReadOnlyError, callLifecycle, collectSkillForPublish, createGlobMatcher, createSkillTools, createWorkspaceTools, deleteFileTool, detectIsolation, editFileTool, executeCommandTool, extractGlobBase, fileStatTool, getRecommendedIsolation, getTiktoken, indexContentTool, isGlobPattern, isIsolationAvailable, listFilesTool, matchGlob, mkdirTool, publishSkillFromSource, readFileTool, requireFilesystem, requireSandbox, requireWorkspace, resolveToolConfig, searchTool, writeFileTool };
8004
- //# sourceMappingURL=chunk-L53XY7WT.js.map
8005
- //# sourceMappingURL=chunk-L53XY7WT.js.map
8102
+ //# sourceMappingURL=chunk-WEKILIGZ.js.map
8103
+ //# sourceMappingURL=chunk-WEKILIGZ.js.map