mastra-minds 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -0
- package/dist/agent.d.ts +56 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +97906 -0
- package/dist/parser.d.ts +9 -0
- package/dist/registry.d.ts +39 -0
- package/dist/tools.d.ts +259 -0
- package/dist/types.d.ts +20 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# mastra-minds
|
|
2
|
+
|
|
3
|
+
Agent Minds system for [Mastra](https://mastra.ai) - Claude-style skills with progressive disclosure.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📦 **MIND.md Format** - Simple markdown-based mind definition
|
|
8
|
+
- 🔄 **Progressive Disclosure** - Load metadata first, full content on-demand
|
|
9
|
+
- 🛠️ **Script Execution** - Run TypeScript/JavaScript/Python/Bash scripts
|
|
10
|
+
- 🔌 **Mastra Integration** - Drop-in tools for any Mastra agent
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun add mastra-minds
|
|
16
|
+
# or
|
|
17
|
+
npm install mastra-minds
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Create a mind
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
minds/
|
|
26
|
+
└── my-mind/
|
|
27
|
+
├── MIND.md
|
|
28
|
+
├── scripts/
|
|
29
|
+
│ └── helper.ts
|
|
30
|
+
└── references/
|
|
31
|
+
└── guide.md
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
# minds/my-mind/MIND.md
|
|
36
|
+
---
|
|
37
|
+
name: my-mind
|
|
38
|
+
description: Does X when user asks for Y
|
|
39
|
+
allowed-tools: Read Write Bash
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
# My Mind
|
|
43
|
+
|
|
44
|
+
Instructions for the agent to follow...
|
|
45
|
+
|
|
46
|
+
## Scripts
|
|
47
|
+
|
|
48
|
+
Run `execute-mind-script: my-mind, helper.ts` for automation.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Initialize and create agent
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { createMindsAgent, initMindRegistry } from 'mastra-minds';
|
|
55
|
+
|
|
56
|
+
// Initialize mind registry
|
|
57
|
+
await initMindRegistry('./minds');
|
|
58
|
+
|
|
59
|
+
// Create agent with minds
|
|
60
|
+
const agent = createMindsAgent({
|
|
61
|
+
name: 'My Agent',
|
|
62
|
+
model: 'your-model',
|
|
63
|
+
instructions: 'You are a helpful assistant.',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Use the agent
|
|
67
|
+
const response = await agent.generate('Help me with X');
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Or integrate manually
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { Mastra } from '@mastra/core';
|
|
74
|
+
import { initMindRegistry, mindTools, generateMindsInstructions, getMindRegistry } from 'mastra-minds';
|
|
75
|
+
|
|
76
|
+
await initMindRegistry('./minds');
|
|
77
|
+
|
|
78
|
+
const registry = getMindRegistry();
|
|
79
|
+
const mindsXml = registry.generateAvailableMindsXml();
|
|
80
|
+
|
|
81
|
+
const agent = new Agent({
|
|
82
|
+
name: 'My Agent',
|
|
83
|
+
model: myModel,
|
|
84
|
+
instructions: `Base instructions...\n\n${generateMindsInstructions(mindsXml)}`,
|
|
85
|
+
tools: {
|
|
86
|
+
...mindTools,
|
|
87
|
+
...myOtherTools,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## MIND.md Format
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
---
|
|
96
|
+
name: mind-name # Required: lowercase, hyphens only
|
|
97
|
+
description: What it does # Required: when to use this mind
|
|
98
|
+
allowed-tools: Read Write # Optional: pre-approved tools
|
|
99
|
+
model: your-model # Optional: model override
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
# Mind Title
|
|
103
|
+
|
|
104
|
+
Markdown content with instructions...
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Available Tools
|
|
108
|
+
|
|
109
|
+
| Tool | Description |
|
|
110
|
+
|------|-------------|
|
|
111
|
+
| `load-mind` | Load a mind's full instructions |
|
|
112
|
+
| `read-mind-resource` | Read files from mind's directory |
|
|
113
|
+
| `execute-mind-script` | Run scripts (.ts, .js, .sh, .py) |
|
|
114
|
+
| `list-minds` | List all available minds |
|
|
115
|
+
|
|
116
|
+
## Directory Structure
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
minds/
|
|
120
|
+
├── mind-a/
|
|
121
|
+
│ ├── MIND.md # Required: mind definition
|
|
122
|
+
│ ├── scripts/ # Optional: executable scripts
|
|
123
|
+
│ │ └── helper.ts
|
|
124
|
+
│ ├── references/ # Optional: reference docs
|
|
125
|
+
│ │ └── guide.md
|
|
126
|
+
│ └── assets/ # Optional: templates, configs
|
|
127
|
+
│ └── template.json
|
|
128
|
+
└── mind-b/
|
|
129
|
+
└── MIND.md
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## API Reference
|
|
133
|
+
|
|
134
|
+
### `initMindRegistry(mindsDir: string)`
|
|
135
|
+
|
|
136
|
+
Initialize the mind registry by scanning a directory.
|
|
137
|
+
|
|
138
|
+
### `createMindsAgent(options: MindsAgentOptions)`
|
|
139
|
+
|
|
140
|
+
Create a Mastra agent with minds support.
|
|
141
|
+
|
|
142
|
+
### `mindTools`
|
|
143
|
+
|
|
144
|
+
Object containing all mind-related tools for manual integration.
|
|
145
|
+
|
|
146
|
+
### `getMindRegistry()`
|
|
147
|
+
|
|
148
|
+
Get the initialized registry instance.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Agent } from "@mastra/core/agent";
|
|
2
|
+
import type { CoreSystemMessage } from "ai";
|
|
3
|
+
/**
|
|
4
|
+
* SystemMessage type - matches Mastra's supported formats
|
|
5
|
+
*/
|
|
6
|
+
export type SystemMessage = string | string[] | CoreSystemMessage | CoreSystemMessage[];
|
|
7
|
+
export interface MindsAgentOptions {
|
|
8
|
+
/** Agent name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** LLM model configuration */
|
|
11
|
+
model: string;
|
|
12
|
+
/** Your instructions - minds instructions will be auto-injected */
|
|
13
|
+
instructions?: SystemMessage;
|
|
14
|
+
/** Additional tools to include alongside mind tools */
|
|
15
|
+
additionalTools?: Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Where to inject minds instructions: 'before' or 'after' your instructions
|
|
18
|
+
* @default 'after'
|
|
19
|
+
*/
|
|
20
|
+
mindsPosition?: "before" | "after";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wrap instructions with minds support
|
|
24
|
+
*
|
|
25
|
+
* Use this when you're creating an Agent manually but want minds auto-injected.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const agent = new Agent({
|
|
30
|
+
* name: 'My Agent',
|
|
31
|
+
* model: 'claude-sonnet-4-20250514',
|
|
32
|
+
* instructions: withMinds('You are a helpful assistant.'),
|
|
33
|
+
* tools: { ...mindTools, ...myTools },
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function withMinds(instructions?: SystemMessage, position?: "before" | "after"): CoreSystemMessage[];
|
|
38
|
+
/**
|
|
39
|
+
* Create a Mastra Agent with minds support
|
|
40
|
+
*
|
|
41
|
+
* Minds instructions are automatically injected - you just provide your own instructions.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { createMindsAgent, initMindRegistry } from 'mastra-minds';
|
|
46
|
+
*
|
|
47
|
+
* await initMindRegistry('./minds');
|
|
48
|
+
*
|
|
49
|
+
* const agent = createMindsAgent({
|
|
50
|
+
* name: 'My Agent',
|
|
51
|
+
* model: 'claude-sonnet-4-20250514',
|
|
52
|
+
* instructions: 'You are a helpful assistant.',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function createMindsAgent(options: MindsAgentOptions): Agent;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mastra-minds
|
|
3
|
+
*
|
|
4
|
+
* Agent Minds system for Mastra - Claude-style skills with progressive disclosure
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createMindsAgent, initMindRegistry } from 'mastra-minds';
|
|
9
|
+
*
|
|
10
|
+
* // Initialize minds from a directory
|
|
11
|
+
* await initMindRegistry('./minds');
|
|
12
|
+
*
|
|
13
|
+
* // Create an agent with minds support
|
|
14
|
+
* const agent = createMindsAgent({
|
|
15
|
+
* name: 'My Agent',
|
|
16
|
+
* model: 'your-model',
|
|
17
|
+
* additionalTools: { myTool },
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export { parseMindMd, loadMind } from "./parser";
|
|
22
|
+
export { MindRegistry, getMindRegistry, initMindRegistry, } from "./registry";
|
|
23
|
+
export { loadMindTool, readMindResourceTool, executeMindScriptTool, listMindsTool, mindTools, } from "./tools";
|
|
24
|
+
export type { Mind, MindFrontmatter, MindMetadata } from "./types";
|
|
25
|
+
export { MindFrontmatterSchema } from "./types";
|
|
26
|
+
export { createMindsAgent, withMinds } from "./agent";
|
|
27
|
+
export type { MindsAgentOptions, SystemMessage } from "./agent";
|