mastra-minds 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,10 +5,12 @@
5
5
  *
6
6
  * @example
7
7
  * ```typescript
8
- * import { createMindsAgent, initMindRegistry } from 'mastra-minds';
8
+ * import { createMindsAgent, initMindRegistry, FileSystemProvider } from 'mastra-minds';
9
9
  *
10
- * // Initialize minds from a directory
11
- * await initMindRegistry('./minds');
10
+ * // Initialize with provider(s)
11
+ * await initMindRegistry({
12
+ * providers: [new FileSystemProvider('./minds')],
13
+ * });
12
14
  *
13
15
  * // Create an agent with minds support
14
16
  * const agent = createMindsAgent({
@@ -18,10 +20,12 @@
18
20
  * });
19
21
  * ```
20
22
  */
21
- export { parseMindMd, loadMind } from "./parser";
22
- export { MindRegistry, getMindRegistry, initMindRegistry, } from "./registry";
23
+ export { parseMindMd } from "./parser";
24
+ export { MindRegistry, getMindRegistry, initMindRegistry } from "./registry";
25
+ export type { MindRegistryOptions, ConflictStrategy } from "./registry";
23
26
  export { loadMindTool, readMindResourceTool, executeMindScriptTool, listMindsTool, mindTools, } from "./tools";
24
- export type { Mind, MindFrontmatter, MindMetadata } from "./types";
27
+ export { FileSystemProvider } from "./providers";
28
+ export type { Mind, MindFrontmatter, MindMetadata, MindsProvider, ScriptResult, } from "./types";
25
29
  export { MindFrontmatterSchema } from "./types";
26
30
  export { createMindsAgent, withMinds } from "./agent";
27
31
  export type { MindsAgentOptions, SystemMessage } from "./agent";
package/dist/index.js CHANGED
@@ -39730,52 +39730,54 @@ function parseFrontmatter(content) {
39730
39730
  }
39731
39731
  return { frontmatter, body: body.trim() };
39732
39732
  }
39733
- function parseMindMd(content, baseDir) {
39733
+ function parseMindMd(content) {
39734
39734
  const { frontmatter, body } = parseFrontmatter(content);
39735
39735
  const validatedFrontmatter = MindFrontmatterSchema.parse(frontmatter);
39736
39736
  return {
39737
+ metadata: {
39738
+ name: validatedFrontmatter.name,
39739
+ description: validatedFrontmatter.description
39740
+ },
39737
39741
  frontmatter: validatedFrontmatter,
39738
- content: body,
39739
- baseDir
39742
+ content: body
39740
39743
  };
39741
39744
  }
39742
- async function loadMind(mindDir) {
39743
- const mindMdPath = `${mindDir}/MIND.md`;
39744
- const file2 = Bun.file(mindMdPath);
39745
- if (!await file2.exists()) {
39746
- throw new Error(`MIND.md not found in ${mindDir}`);
39747
- }
39748
- const content = await file2.text();
39749
- return parseMindMd(content, mindDir);
39750
- }
39751
39745
  // src/registry.ts
39752
- var {Glob } = globalThis.Bun;
39753
39746
  class MindRegistry {
39754
- mindsDir;
39747
+ providers;
39748
+ strategy;
39755
39749
  metadataCache = new Map;
39756
39750
  mindCache = new Map;
39757
- constructor(mindsDir) {
39758
- this.mindsDir = mindsDir;
39759
- }
39760
- async discover() {
39761
- const glob = new Glob("*/MIND.md");
39762
- const minds = [];
39763
- for await (const path of glob.scan(this.mindsDir)) {
39764
- const mindDir = `${this.mindsDir}/${path.replace("/MIND.md", "")}`;
39765
- try {
39766
- const mind = await loadMind(mindDir);
39767
- const metadata = {
39768
- name: mind.frontmatter.name,
39769
- description: mind.frontmatter.description
39770
- };
39771
- this.metadataCache.set(mind.frontmatter.name, metadata);
39772
- this.mindCache.set(mind.frontmatter.name, mind);
39773
- minds.push(metadata);
39774
- } catch (error46) {
39775
- console.error(`Failed to load mind from ${mindDir}:`, error46);
39751
+ mindProviderMap = new Map;
39752
+ constructor(options) {
39753
+ this.providers = options.providers;
39754
+ this.strategy = options.conflictStrategy ?? "first";
39755
+ }
39756
+ async init() {
39757
+ this.metadataCache.clear();
39758
+ this.mindCache.clear();
39759
+ this.mindProviderMap.clear();
39760
+ for (const provider of this.providers) {
39761
+ const minds = await provider.discover();
39762
+ for (const mind of minds) {
39763
+ const existing = this.mindProviderMap.get(mind.name);
39764
+ if (existing) {
39765
+ if (this.strategy === "first") {
39766
+ console.warn(`Mind "${mind.name}" from [${provider.name}] skipped, already registered from [${existing.name}]`);
39767
+ continue;
39768
+ }
39769
+ console.warn(`Mind "${mind.name}" overwritten: [${existing.name}] -> [${provider.name}]`);
39770
+ }
39771
+ this.mindProviderMap.set(mind.name, provider);
39772
+ this.metadataCache.set(mind.name, mind);
39776
39773
  }
39777
39774
  }
39778
- return minds;
39775
+ }
39776
+ getProviderForMind(name) {
39777
+ return this.mindProviderMap.get(name);
39778
+ }
39779
+ getProviders() {
39780
+ return this.providers;
39779
39781
  }
39780
39782
  getMetadata(name) {
39781
39783
  return this.metadataCache.get(name);
@@ -39784,14 +39786,33 @@ class MindRegistry {
39784
39786
  if (this.mindCache.has(name)) {
39785
39787
  return this.mindCache.get(name);
39786
39788
  }
39787
- const mindDir = `${this.mindsDir}/${name}`;
39788
- try {
39789
- const mind = await loadMind(mindDir);
39789
+ const provider = this.mindProviderMap.get(name);
39790
+ if (!provider) {
39791
+ return;
39792
+ }
39793
+ const mind = await provider.loadMind(name);
39794
+ if (mind) {
39790
39795
  this.mindCache.set(name, mind);
39791
- return mind;
39792
- } catch {
39796
+ }
39797
+ return mind;
39798
+ }
39799
+ hasMind(name) {
39800
+ return this.mindProviderMap.has(name);
39801
+ }
39802
+ async readResource(mindName, path) {
39803
+ const provider = this.mindProviderMap.get(mindName);
39804
+ return provider?.readResource(mindName, path);
39805
+ }
39806
+ async executeScript(mindName, scriptPath, args) {
39807
+ const provider = this.mindProviderMap.get(mindName);
39808
+ if (!provider?.executeScript) {
39793
39809
  return;
39794
39810
  }
39811
+ return provider.executeScript(mindName, scriptPath, args);
39812
+ }
39813
+ supportsScripts(mindName) {
39814
+ const provider = this.mindProviderMap.get(mindName);
39815
+ return typeof provider?.executeScript === "function";
39795
39816
  }
39796
39817
  generateAvailableMinds() {
39797
39818
  if (this.metadataCache.size === 0) {
@@ -39802,29 +39823,20 @@ class MindRegistry {
39802
39823
  return `Available minds:
39803
39824
  ${lines}`;
39804
39825
  }
39805
- generateAvailableMindsXml() {
39806
- return this.generateAvailableMinds();
39807
- }
39808
39826
  listMinds() {
39809
39827
  return Array.from(this.metadataCache.keys());
39810
39828
  }
39811
- hasMind(name) {
39812
- return this.metadataCache.has(name);
39813
- }
39814
39829
  }
39815
39830
  var registryInstance = null;
39816
- function getMindRegistry(mindsDir) {
39817
- if (!registryInstance && mindsDir) {
39818
- registryInstance = new MindRegistry(mindsDir);
39819
- }
39831
+ function getMindRegistry() {
39820
39832
  if (!registryInstance) {
39821
- throw new Error("MindRegistry not initialized. Call with mindsDir first.");
39833
+ throw new Error("MindRegistry not initialized. Call initMindRegistry first.");
39822
39834
  }
39823
39835
  return registryInstance;
39824
39836
  }
39825
- async function initMindRegistry(mindsDir) {
39826
- registryInstance = new MindRegistry(mindsDir);
39827
- await registryInstance.discover();
39837
+ async function initMindRegistry(options) {
39838
+ registryInstance = new MindRegistry(options);
39839
+ await registryInstance.init();
39828
39840
  return registryInstance;
39829
39841
  }
39830
39842
  // node_modules/@mastra/core/dist/chunk-DD2VNRQM.js
@@ -40184,7 +40196,6 @@ guide your subsequent actions.`,
40184
40196
  success: exports_external.boolean(),
40185
40197
  mindName: exports_external.string().optional(),
40186
40198
  instructions: exports_external.string().optional(),
40187
- baseDir: exports_external.string().optional(),
40188
40199
  allowedTools: exports_external.array(exports_external.string()).optional(),
40189
40200
  message: exports_external.string().optional()
40190
40201
  }),
@@ -40200,9 +40211,8 @@ guide your subsequent actions.`,
40200
40211
  const allowedTools = mind.frontmatter["allowed-tools"]?.split(/\s+/).filter(Boolean);
40201
40212
  return {
40202
40213
  success: true,
40203
- mindName: mind.frontmatter.name,
40214
+ mindName: mind.metadata.name,
40204
40215
  instructions: mind.content,
40205
- baseDir: mind.baseDir,
40206
40216
  allowedTools
40207
40217
  };
40208
40218
  }
@@ -40223,41 +40233,31 @@ when the mind instructions reference them.`,
40223
40233
  }),
40224
40234
  execute: async (inputData) => {
40225
40235
  const registry2 = getMindRegistry();
40226
- const mind = await registry2.loadMind(inputData.mindName);
40227
- if (!mind) {
40236
+ if (!registry2.hasMind(inputData.mindName)) {
40228
40237
  return {
40229
40238
  success: false,
40230
40239
  message: `Mind "${inputData.mindName}" not found`
40231
40240
  };
40232
40241
  }
40233
- const normalizedPath = inputData.resourcePath.replace(/\.\./g, "");
40234
- const fullPath = `${mind.baseDir}/${normalizedPath}`;
40235
- try {
40236
- const file2 = Bun.file(fullPath);
40237
- if (!await file2.exists()) {
40238
- return {
40239
- success: false,
40240
- message: `Resource not found: ${normalizedPath}`
40241
- };
40242
- }
40243
- const content = await file2.text();
40244
- return {
40245
- success: true,
40246
- content
40247
- };
40248
- } catch (err) {
40242
+ const content = await registry2.readResource(inputData.mindName, inputData.resourcePath);
40243
+ if (content === undefined) {
40249
40244
  return {
40250
40245
  success: false,
40251
- message: `Failed to read resource: ${err}`
40246
+ message: `Resource not found: ${inputData.resourcePath}`
40252
40247
  };
40253
40248
  }
40249
+ return {
40250
+ success: true,
40251
+ content
40252
+ };
40254
40253
  }
40255
40254
  });
40256
40255
  var executeMindScriptTool = createTool({
40257
40256
  id: "execute-mind-script",
40258
40257
  description: `Execute a script from a mind's scripts/ directory.
40259
40258
  Use this when mind instructions tell you to run a script for deterministic operations.
40260
- Scripts can be .ts, .js, .sh, or .py files.`,
40259
+ Scripts can be .ts, .js, .sh, or .py files.
40260
+ Note: Not all providers support script execution.`,
40261
40261
  inputSchema: exports_external.object({
40262
40262
  mindName: exports_external.string().describe("The name of the mind"),
40263
40263
  scriptPath: exports_external.string().describe("Relative path to script in scripts/ (e.g., 'helper.ts')"),
@@ -40272,50 +40272,189 @@ Scripts can be .ts, .js, .sh, or .py files.`,
40272
40272
  }),
40273
40273
  execute: async (inputData) => {
40274
40274
  const registry2 = getMindRegistry();
40275
- const mind = await registry2.loadMind(inputData.mindName);
40276
- if (!mind) {
40275
+ if (!registry2.hasMind(inputData.mindName)) {
40277
40276
  return {
40278
40277
  success: false,
40279
40278
  message: `Mind "${inputData.mindName}" not found`
40280
40279
  };
40281
40280
  }
40282
- const scriptPath = inputData.scriptPath.replace(/\.\./g, "");
40283
- const fullPath = `${mind.baseDir}/scripts/${scriptPath}`;
40281
+ if (!registry2.supportsScripts(inputData.mindName)) {
40282
+ return {
40283
+ success: false,
40284
+ message: "Script execution is not supported by this mind's provider"
40285
+ };
40286
+ }
40287
+ const result = await registry2.executeScript(inputData.mindName, inputData.scriptPath, inputData.args);
40288
+ if (!result) {
40289
+ return {
40290
+ success: false,
40291
+ message: "Script execution failed"
40292
+ };
40293
+ }
40294
+ return {
40295
+ success: result.success,
40296
+ stdout: result.stdout,
40297
+ stderr: result.stderr,
40298
+ exitCode: result.exitCode
40299
+ };
40300
+ }
40301
+ });
40302
+ var listMindsTool = createTool({
40303
+ id: "list-minds",
40304
+ description: "List all available minds with their descriptions",
40305
+ inputSchema: exports_external.object({}),
40306
+ outputSchema: exports_external.object({
40307
+ minds: exports_external.array(exports_external.object({
40308
+ name: exports_external.string(),
40309
+ description: exports_external.string()
40310
+ }))
40311
+ }),
40312
+ execute: async () => {
40313
+ const registry2 = getMindRegistry();
40314
+ const minds = registry2.listMinds().map((name) => {
40315
+ const metadata = registry2.getMetadata(name);
40316
+ return {
40317
+ name,
40318
+ description: metadata?.description || ""
40319
+ };
40320
+ });
40321
+ return { minds };
40322
+ }
40323
+ });
40324
+ var mindTools = {
40325
+ loadMindTool,
40326
+ readMindResourceTool,
40327
+ executeMindScriptTool,
40328
+ listMindsTool
40329
+ };
40330
+ // src/providers/filesystem.ts
40331
+ var {Glob } = globalThis.Bun;
40332
+ class FileSystemProvider {
40333
+ name = "filesystem";
40334
+ baseDir;
40335
+ mindDirs = new Map;
40336
+ constructor(baseDir) {
40337
+ this.baseDir = baseDir;
40338
+ }
40339
+ async discover() {
40340
+ const glob = new Glob("*/MIND.md");
40341
+ const minds = [];
40342
+ for await (const path of glob.scan(this.baseDir)) {
40343
+ const mindDirName = path.replace("/MIND.md", "");
40344
+ const mindDir = `${this.baseDir}/${mindDirName}`;
40345
+ try {
40346
+ const file2 = Bun.file(`${mindDir}/MIND.md`);
40347
+ const content = await file2.text();
40348
+ const mind = parseMindMd(content);
40349
+ this.mindDirs.set(mind.metadata.name, mindDir);
40350
+ minds.push(mind.metadata);
40351
+ } catch (error46) {
40352
+ console.error(`Failed to load mind from ${mindDir}:`, error46);
40353
+ }
40354
+ }
40355
+ return minds;
40356
+ }
40357
+ async loadMind(name) {
40358
+ const mindDir = this.mindDirs.get(name);
40359
+ if (!mindDir) {
40360
+ const fallbackDir = `${this.baseDir}/${name}`;
40361
+ const file2 = Bun.file(`${fallbackDir}/MIND.md`);
40362
+ if (!await file2.exists()) {
40363
+ return;
40364
+ }
40365
+ try {
40366
+ const content = await file2.text();
40367
+ const mind = parseMindMd(content);
40368
+ this.mindDirs.set(name, fallbackDir);
40369
+ return mind;
40370
+ } catch {
40371
+ return;
40372
+ }
40373
+ }
40374
+ try {
40375
+ const file2 = Bun.file(`${mindDir}/MIND.md`);
40376
+ const content = await file2.text();
40377
+ return parseMindMd(content);
40378
+ } catch {
40379
+ return;
40380
+ }
40381
+ }
40382
+ async hasMind(name) {
40383
+ if (this.mindDirs.has(name)) {
40384
+ return true;
40385
+ }
40386
+ const fallbackDir = `${this.baseDir}/${name}`;
40387
+ const file2 = Bun.file(`${fallbackDir}/MIND.md`);
40388
+ return file2.exists();
40389
+ }
40390
+ async readResource(mindName, path) {
40391
+ const mindDir = this.mindDirs.get(mindName);
40392
+ if (!mindDir) {
40393
+ return;
40394
+ }
40395
+ const normalizedPath = path.replace(/\.\./g, "");
40396
+ const fullPath = `${mindDir}/${normalizedPath}`;
40397
+ try {
40398
+ const file2 = Bun.file(fullPath);
40399
+ if (!await file2.exists()) {
40400
+ return;
40401
+ }
40402
+ return file2.text();
40403
+ } catch {
40404
+ return;
40405
+ }
40406
+ }
40407
+ async executeScript(mindName, scriptPath, args) {
40408
+ const mindDir = this.mindDirs.get(mindName);
40409
+ if (!mindDir) {
40410
+ return {
40411
+ success: false,
40412
+ stdout: "",
40413
+ stderr: `Mind "${mindName}" not found`,
40414
+ exitCode: 1
40415
+ };
40416
+ }
40417
+ const normalizedPath = scriptPath.replace(/\.\./g, "");
40418
+ const fullPath = `${mindDir}/scripts/${normalizedPath}`;
40284
40419
  const ext = scriptPath.split(".").pop()?.toLowerCase();
40285
40420
  let command;
40286
40421
  switch (ext) {
40287
40422
  case "ts":
40288
40423
  case "js":
40289
- command = ["bun", fullPath, ...inputData.args || []];
40424
+ command = ["bun", fullPath, ...args || []];
40290
40425
  break;
40291
40426
  case "sh":
40292
- command = ["bash", fullPath, ...inputData.args || []];
40427
+ command = ["bash", fullPath, ...args || []];
40293
40428
  break;
40294
40429
  case "py":
40295
- command = ["python3", fullPath, ...inputData.args || []];
40430
+ command = ["python3", fullPath, ...args || []];
40296
40431
  break;
40297
40432
  default:
40298
40433
  return {
40299
40434
  success: false,
40300
- message: `Unsupported script type: .${ext}. Use .ts, .js, .sh, or .py`
40435
+ stdout: "",
40436
+ stderr: `Unsupported script type: .${ext}. Use .ts, .js, .sh, or .py`,
40437
+ exitCode: 1
40301
40438
  };
40302
40439
  }
40303
40440
  const file2 = Bun.file(fullPath);
40304
40441
  if (!await file2.exists()) {
40305
40442
  return {
40306
40443
  success: false,
40307
- message: `Script not found: scripts/${scriptPath}`
40444
+ stdout: "",
40445
+ stderr: `Script not found: scripts/${scriptPath}`,
40446
+ exitCode: 1
40308
40447
  };
40309
40448
  }
40310
40449
  try {
40311
40450
  const proc = Bun.spawn(command, {
40312
- cwd: mind.baseDir,
40451
+ cwd: mindDir,
40313
40452
  stdout: "pipe",
40314
40453
  stderr: "pipe",
40315
40454
  env: {
40316
40455
  ...process.env,
40317
- MIND_NAME: mind.frontmatter.name,
40318
- MIND_DIR: mind.baseDir
40456
+ MIND_NAME: mindName,
40457
+ MIND_DIR: mindDir
40319
40458
  }
40320
40459
  });
40321
40460
  const stdout = await new Response(proc.stdout).text();
@@ -40327,42 +40466,16 @@ Scripts can be .ts, .js, .sh, or .py files.`,
40327
40466
  stderr: stderr.trim(),
40328
40467
  exitCode
40329
40468
  };
40330
- } catch (err) {
40469
+ } catch (error46) {
40331
40470
  return {
40332
40471
  success: false,
40333
- message: `Execution failed: ${err}`
40472
+ stdout: "",
40473
+ stderr: `Execution failed: ${error46}`,
40474
+ exitCode: 1
40334
40475
  };
40335
40476
  }
40336
40477
  }
40337
- });
40338
- var listMindsTool = createTool({
40339
- id: "list-minds",
40340
- description: "List all available minds with their descriptions",
40341
- inputSchema: exports_external.object({}),
40342
- outputSchema: exports_external.object({
40343
- minds: exports_external.array(exports_external.object({
40344
- name: exports_external.string(),
40345
- description: exports_external.string()
40346
- }))
40347
- }),
40348
- execute: async () => {
40349
- const registry2 = getMindRegistry();
40350
- const minds = registry2.listMinds().map((name) => {
40351
- const metadata = registry2.getMetadata(name);
40352
- return {
40353
- name,
40354
- description: metadata?.description || ""
40355
- };
40356
- });
40357
- return { minds };
40358
- }
40359
- });
40360
- var mindTools = {
40361
- loadMindTool,
40362
- readMindResourceTool,
40363
- executeMindScriptTool,
40364
- listMindsTool
40365
- };
40478
+ }
40366
40479
  // node_modules/@mastra/core/dist/chunk-2SQB3WBT.js
40367
40480
  init_chunk_D22XABFZ();
40368
40481
 
@@ -97895,12 +98008,12 @@ export {
97895
98008
  parseMindMd,
97896
98009
  mindTools,
97897
98010
  loadMindTool,
97898
- loadMind,
97899
98011
  listMindsTool,
97900
98012
  initMindRegistry,
97901
98013
  getMindRegistry,
97902
98014
  executeMindScriptTool,
97903
98015
  createMindsAgent,
97904
98016
  MindRegistry,
97905
- MindFrontmatterSchema
98017
+ MindFrontmatterSchema,
98018
+ FileSystemProvider
97906
98019
  };
package/dist/parser.d.ts CHANGED
@@ -2,8 +2,4 @@ import { type Mind } from "./types";
2
2
  /**
3
3
  * Parse a MIND.md file content into a Mind object
4
4
  */
5
- export declare function parseMindMd(content: string, baseDir: string): Mind;
6
- /**
7
- * Load and parse a mind from a directory
8
- */
9
- export declare function loadMind(mindDir: string): Promise<Mind>;
5
+ export declare function parseMindMd(content: string): Mind;
@@ -0,0 +1,26 @@
1
+ import type { Mind, MindMetadata, MindsProvider, ScriptResult } from "../types";
2
+ /**
3
+ * FileSystemProvider - Loads minds from a local directory
4
+ *
5
+ * Directory structure:
6
+ * ```
7
+ * mindsDir/
8
+ * ├── mind-name/
9
+ * │ ├── MIND.md
10
+ * │ ├── references/
11
+ * │ │ └── guide.md
12
+ * │ └── scripts/
13
+ * │ └── helper.ts
14
+ * ```
15
+ */
16
+ export declare class FileSystemProvider implements MindsProvider {
17
+ readonly name = "filesystem";
18
+ private baseDir;
19
+ private mindDirs;
20
+ constructor(baseDir: string);
21
+ discover(): Promise<MindMetadata[]>;
22
+ loadMind(name: string): Promise<Mind | undefined>;
23
+ hasMind(name: string): Promise<boolean>;
24
+ readResource(mindName: string, path: string): Promise<string | undefined>;
25
+ executeScript(mindName: string, scriptPath: string, args?: string[]): Promise<ScriptResult>;
26
+ }
@@ -0,0 +1 @@
1
+ export { FileSystemProvider } from "./filesystem";
@@ -1,39 +1,77 @@
1
- import type { Mind, MindMetadata } from "./types";
1
+ import type { Mind, MindMetadata, MindsProvider, ScriptResult } from "./types";
2
2
  /**
3
- * MindRegistry manages mind discovery and loading
4
- * Implements progressive disclosure: metadata loaded upfront, full content on-demand
3
+ * Conflict resolution strategy when multiple providers have the same mind name
4
+ */
5
+ export type ConflictStrategy = "first" | "last";
6
+ /**
7
+ * Options for MindRegistry
8
+ */
9
+ export interface MindRegistryOptions {
10
+ providers: MindsProvider[];
11
+ conflictStrategy?: ConflictStrategy;
12
+ }
13
+ /**
14
+ * MindRegistry - Central access point for minds
15
+ *
16
+ * Supports multiple providers with configurable conflict resolution.
5
17
  */
6
18
  export declare class MindRegistry {
7
- private mindsDir;
19
+ private providers;
20
+ private strategy;
8
21
  private metadataCache;
9
22
  private mindCache;
10
- constructor(mindsDir: string);
23
+ private mindProviderMap;
24
+ constructor(options: MindRegistryOptions);
25
+ /**
26
+ * Initialize the registry by discovering minds from all providers
27
+ */
28
+ init(): Promise<void>;
11
29
  /**
12
- * Discover all minds and load their metadata (Level 1: ~100 tokens each)
30
+ * Get the provider for a specific mind
13
31
  */
14
- discover(): Promise<MindMetadata[]>;
32
+ getProviderForMind(name: string): MindsProvider | undefined;
33
+ /**
34
+ * Get all providers
35
+ */
36
+ getProviders(): MindsProvider[];
15
37
  /**
16
38
  * Get mind metadata by name
17
39
  */
18
40
  getMetadata(name: string): MindMetadata | undefined;
19
41
  /**
20
- * Load full mind content (Level 2: <5000 tokens)
42
+ * Load full mind content (with caching)
21
43
  */
22
44
  loadMind(name: string): Promise<Mind | undefined>;
45
+ /**
46
+ * Check if a mind exists
47
+ */
48
+ hasMind(name: string): boolean;
49
+ /**
50
+ * Read a resource from a mind
51
+ */
52
+ readResource(mindName: string, path: string): Promise<string | undefined>;
53
+ /**
54
+ * Execute a script from a mind (if provider supports it)
55
+ */
56
+ executeScript(mindName: string, scriptPath: string, args?: string[]): Promise<ScriptResult | undefined>;
57
+ /**
58
+ * Check if the provider for a mind supports script execution
59
+ */
60
+ supportsScripts(mindName: string): boolean;
23
61
  /**
24
62
  * Generate available minds list for system prompt injection
25
63
  */
26
64
  generateAvailableMinds(): string;
27
- /** @deprecated Use generateAvailableMinds() instead */
28
- generateAvailableMindsXml(): string;
29
65
  /**
30
66
  * List all available mind names
31
67
  */
32
68
  listMinds(): string[];
33
- /**
34
- * Check if a mind exists
35
- */
36
- hasMind(name: string): boolean;
37
69
  }
38
- export declare function getMindRegistry(mindsDir?: string): MindRegistry;
39
- export declare function initMindRegistry(mindsDir: string): Promise<MindRegistry>;
70
+ /**
71
+ * Get the global MindRegistry instance
72
+ */
73
+ export declare function getMindRegistry(): MindRegistry;
74
+ /**
75
+ * Initialize the global MindRegistry
76
+ */
77
+ export declare function initMindRegistry(options: MindRegistryOptions): Promise<MindRegistry>;
package/dist/tools.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * Mind Loader Tool - Core of the prompt injection system
4
- * When invoked, loads the full mind content and returns it for the agent to follow
3
+ * Load Mind Tool - Core of the prompt injection system
5
4
  */
6
5
  export declare const loadMindTool: import("@mastra/core/tools").Tool<z.ZodObject<{
7
6
  name: z.ZodString;
@@ -9,7 +8,6 @@ export declare const loadMindTool: import("@mastra/core/tools").Tool<z.ZodObject
9
8
  success: z.ZodBoolean;
10
9
  mindName: z.ZodOptional<z.ZodString>;
11
10
  instructions: z.ZodOptional<z.ZodString>;
12
- baseDir: z.ZodOptional<z.ZodString>;
13
11
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
12
  message: z.ZodOptional<z.ZodString>;
15
13
  }, z.core.$strip>, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any>, "load-mind"> & {
@@ -20,7 +18,6 @@ export declare const loadMindTool: import("@mastra/core/tools").Tool<z.ZodObject
20
18
  success: z.ZodBoolean;
21
19
  mindName: z.ZodOptional<z.ZodString>;
22
20
  instructions: z.ZodOptional<z.ZodString>;
23
- baseDir: z.ZodOptional<z.ZodString>;
24
21
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
22
  message: z.ZodOptional<z.ZodString>;
26
23
  }, z.core.$strip>;
@@ -30,7 +27,6 @@ export declare const loadMindTool: import("@mastra/core/tools").Tool<z.ZodObject
30
27
  success: boolean;
31
28
  mindName?: string | undefined;
32
29
  instructions?: string | undefined;
33
- baseDir?: string | undefined;
34
30
  allowedTools?: string[] | undefined;
35
31
  message?: string | undefined;
36
32
  } & {
@@ -38,7 +34,7 @@ export declare const loadMindTool: import("@mastra/core/tools").Tool<z.ZodObject
38
34
  }>;
39
35
  };
40
36
  /**
41
- * Read Mind Resource Tool - For loading references/scripts on-demand (Level 3)
37
+ * Read Mind Resource Tool
42
38
  */
43
39
  export declare const readMindResourceTool: import("@mastra/core/tools").Tool<z.ZodObject<{
44
40
  mindName: z.ZodString;
@@ -69,8 +65,7 @@ export declare const readMindResourceTool: import("@mastra/core/tools").Tool<z.Z
69
65
  }>;
70
66
  };
71
67
  /**
72
- * Execute Mind Script Tool - Run scripts from mind's scripts/ directory
73
- * V1: Direct execution without sandbox (development only)
68
+ * Execute Mind Script Tool
74
69
  */
75
70
  export declare const executeMindScriptTool: import("@mastra/core/tools").Tool<z.ZodObject<{
76
71
  mindName: z.ZodString;
@@ -110,7 +105,7 @@ export declare const executeMindScriptTool: import("@mastra/core/tools").Tool<z.
110
105
  }>;
111
106
  };
112
107
  /**
113
- * List Minds Tool - Show available minds
108
+ * List Minds Tool
114
109
  */
115
110
  export declare const listMindsTool: import("@mastra/core/tools").Tool<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
116
111
  minds: z.ZodArray<z.ZodObject<{
@@ -141,7 +136,6 @@ export declare const mindTools: {
141
136
  success: z.ZodBoolean;
142
137
  mindName: z.ZodOptional<z.ZodString>;
143
138
  instructions: z.ZodOptional<z.ZodString>;
144
- baseDir: z.ZodOptional<z.ZodString>;
145
139
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
146
140
  message: z.ZodOptional<z.ZodString>;
147
141
  }, z.core.$strip>, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any>, "load-mind"> & {
@@ -152,7 +146,6 @@ export declare const mindTools: {
152
146
  success: z.ZodBoolean;
153
147
  mindName: z.ZodOptional<z.ZodString>;
154
148
  instructions: z.ZodOptional<z.ZodString>;
155
- baseDir: z.ZodOptional<z.ZodString>;
156
149
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
157
150
  message: z.ZodOptional<z.ZodString>;
158
151
  }, z.core.$strip>;
@@ -162,7 +155,6 @@ export declare const mindTools: {
162
155
  success: boolean;
163
156
  mindName?: string | undefined;
164
157
  instructions?: string | undefined;
165
- baseDir?: string | undefined;
166
158
  allowedTools?: string[] | undefined;
167
159
  message?: string | undefined;
168
160
  } & {
package/dist/types.d.ts CHANGED
@@ -9,12 +9,44 @@ export declare const MindFrontmatterSchema: z.ZodObject<{
9
9
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
10
10
  }, z.core.$strip>;
11
11
  export type MindFrontmatter = z.infer<typeof MindFrontmatterSchema>;
12
+ export interface MindMetadata {
13
+ name: string;
14
+ description: string;
15
+ }
12
16
  export interface Mind {
17
+ metadata: MindMetadata;
13
18
  frontmatter: MindFrontmatter;
14
19
  content: string;
15
- baseDir: string;
16
20
  }
17
- export interface MindMetadata {
18
- name: string;
19
- description: string;
21
+ export interface ScriptResult {
22
+ success: boolean;
23
+ stdout: string;
24
+ stderr: string;
25
+ exitCode: number;
26
+ }
27
+ export interface MindsProvider {
28
+ readonly name: string;
29
+ /**
30
+ * Discover all available minds and return their metadata
31
+ */
32
+ discover(): Promise<MindMetadata[]>;
33
+ /**
34
+ * Load full mind content by name
35
+ */
36
+ loadMind(name: string): Promise<Mind | undefined>;
37
+ /**
38
+ * Check if a mind exists
39
+ */
40
+ hasMind(name: string): Promise<boolean>;
41
+ /**
42
+ * Read a resource file from a mind's directory
43
+ * @param mindName - The mind name
44
+ * @param path - Relative path to resource (e.g., 'references/guide.md')
45
+ */
46
+ readResource(mindName: string, path: string): Promise<string | undefined>;
47
+ /**
48
+ * Execute a script from a mind's scripts directory
49
+ * Optional - not all providers support script execution
50
+ */
51
+ executeScript?(mindName: string, scriptPath: string, args?: string[]): Promise<ScriptResult>;
20
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra-minds",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Agent Minds system for Mastra - Claude-style skills with progressive disclosure",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",