@mastra/agent-builder 0.0.1-alpha.1 → 0.0.1-alpha.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.
- package/CHANGELOG.md +15 -0
- package/dist/agent/index.d.ts +5885 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/defaults.d.ts +6529 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1810 -36
- package/dist/index.js.map +1 -0
- package/dist/processors/tool-summary.d.ts +29 -0
- package/dist/processors/tool-summary.d.ts.map +1 -0
- package/dist/processors/write-file.d.ts +10 -0
- package/dist/processors/write-file.d.ts.map +1 -0
- package/dist/types.d.ts +1121 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +63 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/workflows/index.d.ts +5 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/shared/schema.d.ts +139 -0
- package/dist/workflows/shared/schema.d.ts.map +1 -0
- package/dist/workflows/task-planning/prompts.d.ts +37 -0
- package/dist/workflows/task-planning/prompts.d.ts.map +1 -0
- package/dist/workflows/task-planning/schema.d.ts +548 -0
- package/dist/workflows/task-planning/schema.d.ts.map +1 -0
- package/dist/workflows/task-planning/task-planning.d.ts +992 -0
- package/dist/workflows/task-planning/task-planning.d.ts.map +1 -0
- package/dist/workflows/template-builder/template-builder.d.ts +1910 -0
- package/dist/workflows/template-builder/template-builder.d.ts.map +1 -0
- package/dist/workflows/workflow-builder/prompts.d.ts +44 -0
- package/dist/workflows/workflow-builder/prompts.d.ts.map +1 -0
- package/dist/workflows/workflow-builder/schema.d.ts +1170 -0
- package/dist/workflows/workflow-builder/schema.d.ts.map +1 -0
- package/dist/workflows/workflow-builder/tools.d.ts +309 -0
- package/dist/workflows/workflow-builder/tools.d.ts.map +1 -0
- package/dist/workflows/workflow-builder/workflow-builder.d.ts +2714 -0
- package/dist/workflows/workflow-builder/workflow-builder.d.ts.map +1 -0
- package/dist/workflows/workflow-map.d.ts +3735 -0
- package/dist/workflows/workflow-map.d.ts.map +1 -0
- package/package.json +20 -9
- package/.turbo/turbo-build.log +0 -12
- package/dist/_tsup-dts-rollup.d.cts +0 -14933
- package/dist/_tsup-dts-rollup.d.ts +0 -14933
- package/dist/index.cjs +0 -4357
- package/dist/index.d.cts +0 -4
- package/eslint.config.js +0 -11
- package/integration-tests/CHANGELOG.md +0 -9
- package/integration-tests/README.md +0 -154
- package/integration-tests/docker-compose.yml +0 -39
- package/integration-tests/package.json +0 -38
- package/integration-tests/src/agent-template-behavior.test.ts +0 -103
- package/integration-tests/src/fixtures/minimal-mastra-project/env.example +0 -6
- package/integration-tests/src/fixtures/minimal-mastra-project/package.json +0 -17
- package/integration-tests/src/fixtures/minimal-mastra-project/src/mastra/agents/weather.ts +0 -34
- package/integration-tests/src/fixtures/minimal-mastra-project/src/mastra/index.ts +0 -15
- package/integration-tests/src/fixtures/minimal-mastra-project/src/mastra/mcp/index.ts +0 -46
- package/integration-tests/src/fixtures/minimal-mastra-project/src/mastra/tools/weather.ts +0 -14
- package/integration-tests/src/fixtures/minimal-mastra-project/tsconfig.json +0 -17
- package/integration-tests/src/template-integration.test.ts +0 -312
- package/integration-tests/tsconfig.json +0 -9
- package/integration-tests/vitest.config.ts +0 -18
- package/src/agent/index.ts +0 -187
- package/src/agent-builder.test.ts +0 -313
- package/src/defaults.ts +0 -2876
- package/src/index.ts +0 -3
- package/src/processors/tool-summary.ts +0 -145
- package/src/processors/write-file.ts +0 -17
- package/src/types.ts +0 -305
- package/src/utils.ts +0 -409
- package/src/workflows/index.ts +0 -1
- package/src/workflows/template-builder.ts +0 -1682
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -11
package/dist/index.d.cts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { AgentBuilder } from './_tsup-dts-rollup.cjs';
|
|
2
|
-
export { mergeTemplateBySlug } from './_tsup-dts-rollup.cjs';
|
|
3
|
-
export { agentBuilderTemplateWorkflow } from './_tsup-dts-rollup.cjs';
|
|
4
|
-
export { AgentBuilderDefaults_alias_1 as AgentBuilderDefaults } from './_tsup-dts-rollup.cjs';
|
package/eslint.config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createConfig } from '@internal/lint/eslint';
|
|
2
|
-
|
|
3
|
-
const config = await createConfig();
|
|
4
|
-
|
|
5
|
-
/** @type {import("eslint").Linter.Config[]} */
|
|
6
|
-
export default [
|
|
7
|
-
...config,
|
|
8
|
-
{
|
|
9
|
-
...(await import('typescript-eslint')).configs.disableTypeChecked,
|
|
10
|
-
},
|
|
11
|
-
];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# @mastra/agent-builder-integration-tests
|
|
2
|
-
|
|
3
|
-
## 0.1.1-alpha.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [[`aedbbfa`](https://github.com/mastra-ai/mastra/commit/aedbbfa064124ddde039111f12629daebfea7e48), [`f643c65`](https://github.com/mastra-ai/mastra/commit/f643c651bdaf57c2343cf9dbfc499010495701fb), [`fef7375`](https://github.com/mastra-ai/mastra/commit/fef737534574f41b432a7361a285f776c3bac42b), [`e3d8fea`](https://github.com/mastra-ai/mastra/commit/e3d8feaacfb8b5c5c03c13604cc06ea2873d45fe), [`48b9e55`](https://github.com/mastra-ai/mastra/commit/48b9e553a39528dcc20fbbeb798c3b1a1961468e), [`3412597`](https://github.com/mastra-ai/mastra/commit/3412597a6644c0b6bf3236d6e319ed1450c5bae8)]:
|
|
8
|
-
- @mastra/core@0.15.3-alpha.3
|
|
9
|
-
- @mastra/agent-builder@0.0.1-alpha.1
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
# Agent Builder Integration Tests
|
|
2
|
-
|
|
3
|
-
This directory contains comprehensive integration tests for the Mastra Agent Builder, specifically testing the template merging workflow functionality.
|
|
4
|
-
|
|
5
|
-
## Test Files
|
|
6
|
-
|
|
7
|
-
### 1. `merge-template.test.ts`
|
|
8
|
-
|
|
9
|
-
Tests the AgentBuilder with natural language prompts to merge templates using the `mergeTemplate` tool.
|
|
10
|
-
|
|
11
|
-
### 2. `template-workflow.test.ts` (Comprehensive Integration Test)
|
|
12
|
-
|
|
13
|
-
Full end-to-end test that:
|
|
14
|
-
|
|
15
|
-
- Sets up a real Mastra project from the minimal fixture
|
|
16
|
-
- Runs the complete template merge workflow
|
|
17
|
-
- Installs dependencies
|
|
18
|
-
- Starts a Mastra server
|
|
19
|
-
- Validates that both original and new agents/workflows function correctly
|
|
20
|
-
- Tests git history and branch management
|
|
21
|
-
|
|
22
|
-
### 3. `template-workflow-mock.test.ts` (Unit Tests)
|
|
23
|
-
|
|
24
|
-
Lightweight tests with mocked dependencies that validate:
|
|
25
|
-
|
|
26
|
-
- Template API fetching
|
|
27
|
-
- Workflow configuration
|
|
28
|
-
- Input validation
|
|
29
|
-
- Project structure validation
|
|
30
|
-
|
|
31
|
-
## Running Tests
|
|
32
|
-
|
|
33
|
-
### Prerequisites
|
|
34
|
-
|
|
35
|
-
- Node.js and pnpm installed
|
|
36
|
-
- For integration tests: `OPENAI_API_KEY` environment variable set
|
|
37
|
-
- Git configured with user.name and user.email
|
|
38
|
-
|
|
39
|
-
### Commands
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Run all tests
|
|
43
|
-
pnpm test
|
|
44
|
-
|
|
45
|
-
# Run only the mocked unit tests (no API key required)
|
|
46
|
-
pnpm test:mock
|
|
47
|
-
|
|
48
|
-
# Run the full integration template test (requires OPENAI_API_KEY)
|
|
49
|
-
pnpm test:template
|
|
50
|
-
|
|
51
|
-
# Run the agent builder prompt tests
|
|
52
|
-
pnpm test:agent
|
|
53
|
-
|
|
54
|
-
# Run a specific test file
|
|
55
|
-
pnpm vitest run ./src/template-workflow.test.ts
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Environment Variables
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Required for integration tests
|
|
62
|
-
export OPENAI_API_KEY="your-openai-api-key"
|
|
63
|
-
|
|
64
|
-
# Optional: Use a different OpenAI model
|
|
65
|
-
export OPENAI_MODEL="gpt-4o-mini"
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Test Scenarios
|
|
69
|
-
|
|
70
|
-
### Template Workflow Integration Test
|
|
71
|
-
|
|
72
|
-
This comprehensive test validates the complete template integration process:
|
|
73
|
-
|
|
74
|
-
1. **Setup Phase**:
|
|
75
|
-
- Creates a temporary directory
|
|
76
|
-
- Copies the minimal Mastra project fixture
|
|
77
|
-
- Initializes git repository
|
|
78
|
-
- Installs dependencies with pnpm
|
|
79
|
-
|
|
80
|
-
2. **Template Merge Phase**:
|
|
81
|
-
- Fetches template metadata from Mastra API
|
|
82
|
-
- Runs the merge workflow to integrate `csv-to-questions` template
|
|
83
|
-
- Validates file creation and git history
|
|
84
|
-
|
|
85
|
-
3. **Server Validation Phase**:
|
|
86
|
-
- Starts a Mastra development server
|
|
87
|
-
- Tests original agents (weather) still work
|
|
88
|
-
- Tests new agents (csvQuestionAgent) are functional
|
|
89
|
-
- Validates workflow registration
|
|
90
|
-
|
|
91
|
-
4. **Conflict Handling**:
|
|
92
|
-
- Tests duplicate template merging
|
|
93
|
-
- Validates graceful conflict resolution
|
|
94
|
-
|
|
95
|
-
### Expected Template Files
|
|
96
|
-
|
|
97
|
-
After merging the `csv-to-questions` template, these files should be created:
|
|
98
|
-
|
|
99
|
-
- `src/mastra/agents/csvQuestionAgent.ts`
|
|
100
|
-
- `src/mastra/tools/csvTool.ts`
|
|
101
|
-
- `src/mastra/workflows/csvToQuestionsWorkflow.ts`
|
|
102
|
-
|
|
103
|
-
### Git History Validation
|
|
104
|
-
|
|
105
|
-
The test validates that proper git commits are created:
|
|
106
|
-
|
|
107
|
-
- `feat(template): add agent csvQuestionAgent (csv-to-questions@<sha>)`
|
|
108
|
-
- `feat(template): add tool csvTool (csv-to-questions@<sha>)`
|
|
109
|
-
- `feat(template): add workflow csvToQuestionsWorkflow (csv-to-questions@<sha>)`
|
|
110
|
-
- `feat(template): update package.json for csv-to-questions`
|
|
111
|
-
|
|
112
|
-
## Debugging
|
|
113
|
-
|
|
114
|
-
### Common Issues
|
|
115
|
-
|
|
116
|
-
1. **OpenAI API Key**: Ensure `OPENAI_API_KEY` is set for integration tests
|
|
117
|
-
2. **Port Conflicts**: Tests use dynamic port allocation to avoid conflicts
|
|
118
|
-
3. **Git Configuration**: Ensure git user.name and user.email are configured
|
|
119
|
-
4. **Dependencies**: Run `pnpm install` in the test project before running tests
|
|
120
|
-
|
|
121
|
-
### Verbose Output
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# Run with verbose output for debugging
|
|
125
|
-
pnpm vitest run ./src/template-workflow.test.ts --reporter=verbose
|
|
126
|
-
|
|
127
|
-
# Run a single test case
|
|
128
|
-
pnpm vitest run ./src/template-workflow.test.ts -t "should merge csv-to-questions template"
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Test Timeouts
|
|
132
|
-
|
|
133
|
-
- Mock tests: 5 seconds (default)
|
|
134
|
-
- Integration tests: 3 minutes for workflow, 2 minutes for server tests
|
|
135
|
-
- Server startup timeout: 30 seconds
|
|
136
|
-
|
|
137
|
-
## CI/CD Considerations
|
|
138
|
-
|
|
139
|
-
For CI/CD environments:
|
|
140
|
-
|
|
141
|
-
1. Use `test:mock` for fast unit tests without external dependencies
|
|
142
|
-
2. Use `test:integration` only when OpenAI API key is available
|
|
143
|
-
3. Consider using test containers for isolated environments
|
|
144
|
-
4. Mock external API calls for reliable CI execution
|
|
145
|
-
|
|
146
|
-
## Contributing
|
|
147
|
-
|
|
148
|
-
When adding new tests:
|
|
149
|
-
|
|
150
|
-
1. Follow the existing pattern of setup/teardown
|
|
151
|
-
2. Use descriptive test names
|
|
152
|
-
3. Include proper cleanup in `afterAll` hooks
|
|
153
|
-
4. Add appropriate timeouts for long-running operations
|
|
154
|
-
5. Validate both success and error scenarios
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
postgres:
|
|
3
|
-
image: ankane/pgvector:v0.5.1
|
|
4
|
-
ports:
|
|
5
|
-
- '5435:5432'
|
|
6
|
-
environment:
|
|
7
|
-
POSTGRES_USER: postgres
|
|
8
|
-
POSTGRES_PASSWORD: password
|
|
9
|
-
POSTGRES_DB: mastra
|
|
10
|
-
volumes:
|
|
11
|
-
- pg_data:/var/lib/postgresql/data
|
|
12
|
-
healthcheck:
|
|
13
|
-
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
|
14
|
-
interval: 5s
|
|
15
|
-
timeout: 5s
|
|
16
|
-
retries: 5
|
|
17
|
-
redis:
|
|
18
|
-
image: redis:7-alpine
|
|
19
|
-
ports:
|
|
20
|
-
- '6371:6379'
|
|
21
|
-
command: redis-server --requirepass redis_password
|
|
22
|
-
healthcheck:
|
|
23
|
-
test: ['CMD', 'redis-cli', 'ping']
|
|
24
|
-
interval: 5s
|
|
25
|
-
timeout: 5s
|
|
26
|
-
retries: 5
|
|
27
|
-
serverless-redis-http:
|
|
28
|
-
image: hiett/serverless-redis-http:latest
|
|
29
|
-
ports:
|
|
30
|
-
- '8080:80'
|
|
31
|
-
environment:
|
|
32
|
-
SRH_MODE: env
|
|
33
|
-
SRH_TOKEN: test_token
|
|
34
|
-
SRH_CONNECTION_STRING: 'redis://:redis_password@redis:6379'
|
|
35
|
-
depends_on:
|
|
36
|
-
redis:
|
|
37
|
-
condition: service_healthy
|
|
38
|
-
volumes:
|
|
39
|
-
pg_data:
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mastra/agent-builder-integration-tests",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.1.1-alpha.0",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "vitest run",
|
|
7
|
-
"test:agent": "vitest run ./src/agent-template-behavior.test.ts",
|
|
8
|
-
"test:template": "vitest run ./src/template-integration.test.ts",
|
|
9
|
-
"dev": "mastra dev"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@ai-sdk/google": "^1.2.19",
|
|
13
|
-
"@ai-sdk/openai": "^1.3.0",
|
|
14
|
-
"@ai-sdk/react": "^1.2.1",
|
|
15
|
-
"@mastra/agent-builder": "workspace:*",
|
|
16
|
-
"dotenv": "^16.4.7",
|
|
17
|
-
"json-schema": "^0.4.0",
|
|
18
|
-
"zod": "^3.24.3"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@faker-js/faker": "^9.6.0",
|
|
22
|
-
"@mastra/core": "workspace:*",
|
|
23
|
-
"@testing-library/react": "^16.2.0",
|
|
24
|
-
"@types/json-schema": "^7.0.15",
|
|
25
|
-
"@types/node": "^20.17.27",
|
|
26
|
-
"ai": "^4.2.2",
|
|
27
|
-
"jsdom": "^26.0.0",
|
|
28
|
-
"mastra": "workspace:*",
|
|
29
|
-
"next": "^15.2.4",
|
|
30
|
-
"react": "^19.1.0",
|
|
31
|
-
"react-dom": "^19.1.0",
|
|
32
|
-
"typescript": "^5.8.2",
|
|
33
|
-
"vitest": "^3.2.4"
|
|
34
|
-
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"@mastra/core": ">=0.15.2-0 <0.16.0-0"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { mkdtempSync, mkdirSync, rmSync, cpSync, existsSync } from 'node:fs';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
5
|
-
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
6
|
-
import { AgentBuilder } from '../../src/index';
|
|
7
|
-
|
|
8
|
-
// Import openai dynamically to handle cases where it might not be available
|
|
9
|
-
const openai = (() => {
|
|
10
|
-
try {
|
|
11
|
-
return require('@ai-sdk/openai').openai;
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
})();
|
|
16
|
-
|
|
17
|
-
function exec(cmd: string, cwd?: string) {
|
|
18
|
-
return execSync(cmd, { stdio: 'pipe', cwd }).toString();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function initGitRepo(repoDir: string) {
|
|
22
|
-
exec('git init -q', repoDir);
|
|
23
|
-
exec('git config user.email "test@example.com"', repoDir);
|
|
24
|
-
exec('git config user.name "Test User"', repoDir);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function commitAll(repoDir: string, message: string) {
|
|
28
|
-
exec('git add .', repoDir);
|
|
29
|
-
exec(`git commit -m "${message}" -q`, repoDir);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
describe('agent-builder merge template via agent prompt (real template)', () => {
|
|
33
|
-
const integrationProjectsDir = resolve(__dirname, '../integration-projects');
|
|
34
|
-
mkdirSync(integrationProjectsDir, { recursive: true });
|
|
35
|
-
const tempRoot = mkdtempSync(join(integrationProjectsDir, 'agent-builder-it-'));
|
|
36
|
-
const fixtureProjectPath = resolve(__dirname, 'fixtures/minimal-mastra-project');
|
|
37
|
-
const targetRepo = join(tempRoot, 'project-under-test');
|
|
38
|
-
const realTemplateGit = 'https://github.com/mastra-ai/template-pdf-questions';
|
|
39
|
-
|
|
40
|
-
const runtimeContext = new RuntimeContext();
|
|
41
|
-
runtimeContext.set('targetPath', targetRepo);
|
|
42
|
-
|
|
43
|
-
beforeAll(() => {
|
|
44
|
-
// Copy the fixture mastra project into temp directory
|
|
45
|
-
mkdirSync(targetRepo, { recursive: true });
|
|
46
|
-
cpSync(fixtureProjectPath, targetRepo, { recursive: true });
|
|
47
|
-
|
|
48
|
-
// Initialize git in target
|
|
49
|
-
initGitRepo(targetRepo);
|
|
50
|
-
commitAll(targetRepo, 'chore: initial mastra project');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
afterAll(() => {
|
|
54
|
-
try {
|
|
55
|
-
rmSync(tempRoot, { recursive: true, force: true });
|
|
56
|
-
} catch {}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('uses AgentBuilder with natural language to merge pdf-questions template', async () => {
|
|
60
|
-
// Skip test if no OPENAI_API_KEY available or openai not available
|
|
61
|
-
if (!process.env.OPENAI_API_KEY || !openai) {
|
|
62
|
-
console.log('Skipping test: OPENAI_API_KEY not set or @ai-sdk/openai not available');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Create AgentBuilder with real OpenAI model
|
|
67
|
-
const agent = new AgentBuilder({
|
|
68
|
-
instructions:
|
|
69
|
-
'You are an expert at merging Mastra templates into projects. Always use the merge-template tool for template operations.',
|
|
70
|
-
model: openai('gpt-4o-mini'),
|
|
71
|
-
projectPath: targetRepo,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const prompt = `I want to merge the PDF Questions template into this Mastra project.
|
|
75
|
-
|
|
76
|
-
Template repository: ${realTemplateGit}`;
|
|
77
|
-
|
|
78
|
-
// Call the agent with natural language
|
|
79
|
-
const response = await agent.generate(prompt, {
|
|
80
|
-
maxSteps: 5,
|
|
81
|
-
runtimeContext,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Verify files were actually created in the target project
|
|
85
|
-
const expectedFiles = ['src/mastra/agents', 'src/mastra/tools', 'src/mastra/workflows'];
|
|
86
|
-
|
|
87
|
-
for (const expectedPath of expectedFiles) {
|
|
88
|
-
const fullPath = join(targetRepo, expectedPath);
|
|
89
|
-
expect(existsSync(fullPath)).toBe(true);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Verify git branch was created
|
|
93
|
-
const branches = exec('git branch', targetRepo);
|
|
94
|
-
expect(branches).toContain('feat/install-template-template-pdf-questions');
|
|
95
|
-
|
|
96
|
-
// Verify package.json was updated with template scripts
|
|
97
|
-
const packageJsonPath = join(targetRepo, 'package.json');
|
|
98
|
-
expect(existsSync(packageJsonPath)).toBe(true);
|
|
99
|
-
|
|
100
|
-
// Verify response contains confirmation
|
|
101
|
-
expect(response.text.toLowerCase()).toMatch(/merge|template|success|applied|complete/);
|
|
102
|
-
}, 600000); // Longer timeout for full merge operation
|
|
103
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "minimal-mastra-fixture",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "mastra dev",
|
|
7
|
-
"build": "mastra build"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@mastra/core": "latest",
|
|
11
|
-
"@mastra/mcp": "latest",
|
|
12
|
-
"zod": "^3.25.0"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"typescript": "^5.0.0"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { openai } from '@ai-sdk/openai';
|
|
2
|
-
import { createTool } from '@mastra/core';
|
|
3
|
-
import { Agent } from '@mastra/core/agent';
|
|
4
|
-
import { MCPClient } from '@mastra/mcp';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { weatherTool } from '../tools/weather';
|
|
7
|
-
|
|
8
|
-
const client = new MCPClient({
|
|
9
|
-
id: 'weather-server',
|
|
10
|
-
servers: {
|
|
11
|
-
weather: {
|
|
12
|
-
url: new URL(`http://localhost:4199/api/mcp/myMcpServer/mcp`),
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const weatherAgent = new Agent({
|
|
18
|
-
name: 'test',
|
|
19
|
-
instructions:
|
|
20
|
-
'You are a weather agent. When asked about weather in any city, use the get_weather tool with the city name as the postal code. When asked for clipboard contents you also get that.',
|
|
21
|
-
model: openai('gpt-4o'),
|
|
22
|
-
tools: async () => {
|
|
23
|
-
const tools = await client.getTools();
|
|
24
|
-
return {
|
|
25
|
-
get_weather: weatherTool,
|
|
26
|
-
clipboard: createTool({
|
|
27
|
-
id: 'clipboard',
|
|
28
|
-
description: 'Returns the contents of the users clipboard',
|
|
29
|
-
inputSchema: z.object({}),
|
|
30
|
-
}),
|
|
31
|
-
...tools,
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Mastra } from '@mastra/core';
|
|
2
|
-
import { weatherAgent } from './agents/weather';
|
|
3
|
-
import { myMcpServer } from './mcp';
|
|
4
|
-
|
|
5
|
-
export const mastra = new Mastra({
|
|
6
|
-
agents: {
|
|
7
|
-
weatherAgent,
|
|
8
|
-
},
|
|
9
|
-
mcpServers: {
|
|
10
|
-
myMcpServer,
|
|
11
|
-
},
|
|
12
|
-
server: {
|
|
13
|
-
port: 4199,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createTool } from '@mastra/core/tools';
|
|
2
|
-
import { MCPServer } from '@mastra/mcp';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
export const myMcpServer = new MCPServer({
|
|
6
|
-
name: 'My Calculation & Data MCP Server',
|
|
7
|
-
version: '1.0.0',
|
|
8
|
-
tools: {
|
|
9
|
-
calculator: createTool({
|
|
10
|
-
id: 'calculator',
|
|
11
|
-
description: 'Performs basic arithmetic operations (add, subtract).',
|
|
12
|
-
inputSchema: z.object({
|
|
13
|
-
num1: z.number().describe('The first number.'),
|
|
14
|
-
num2: z.number().describe('The second number.'),
|
|
15
|
-
operation: z.enum(['add', 'subtract']).describe('The operation to perform.'),
|
|
16
|
-
}),
|
|
17
|
-
execute: async ({ context }) => {
|
|
18
|
-
const { num1, num2, operation } = context;
|
|
19
|
-
if (operation === 'add') {
|
|
20
|
-
return num1 + num2;
|
|
21
|
-
}
|
|
22
|
-
if (operation === 'subtract') {
|
|
23
|
-
return num1 - num2;
|
|
24
|
-
}
|
|
25
|
-
throw new Error('Invalid operation');
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
fetchWeather: createTool({
|
|
29
|
-
id: 'fetchWeather',
|
|
30
|
-
description: 'Fetches a (simulated) weather forecast for a given city.',
|
|
31
|
-
inputSchema: z.object({
|
|
32
|
-
city: z.string().describe('The city to get weather for, e.g., London, Paris.'),
|
|
33
|
-
}),
|
|
34
|
-
execute: async ({ context }) => {
|
|
35
|
-
const { city } = context;
|
|
36
|
-
const temperatures = {
|
|
37
|
-
london: '15°C',
|
|
38
|
-
paris: '18°C',
|
|
39
|
-
tokyo: '22°C',
|
|
40
|
-
};
|
|
41
|
-
const temp = temperatures[city.toLowerCase() as keyof typeof temperatures] || '20°C';
|
|
42
|
-
return `The weather in ${city} is ${temp} and sunny.`;
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createTool } from '@mastra/core/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
export const weatherTool = createTool({
|
|
5
|
-
id: 'get_weather',
|
|
6
|
-
description: 'Get the weather for a given location',
|
|
7
|
-
inputSchema: z.object({
|
|
8
|
-
postalCode: z.string().describe('The location to get the weather for'),
|
|
9
|
-
}),
|
|
10
|
-
execute: async ({ context }) => {
|
|
11
|
-
const { postalCode } = context;
|
|
12
|
-
return `The weather in ${postalCode} is sunny. It is currently 70 degrees and feels like 65 degrees.`;
|
|
13
|
-
},
|
|
14
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
|
-
"paths": {
|
|
12
|
-
"@/*": ["./src/*"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"include": ["src/**/*"],
|
|
16
|
-
"exclude": ["node_modules"]
|
|
17
|
-
}
|