Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions frameworks/mastra/system-prompt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Agentuity
.agentuity/
65 changes: 65 additions & 0 deletions frameworks/mastra/system-prompt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Mastra System Prompt Example - Agentuity Wrapper

This example demonstrates how to wrap a Mastra agent that uses system prompts within Agentuity's structure. The agent implements a Harry Potter character agent that can respond as different characters from the wizarding world.

## Overview

This is a direct conversion of the [Mastra system-prompt example](https://mastra.ai/en/examples/agents/system-prompt) into an Agentuity agent wrapper. The implementation preserves ALL original Mastra framework code while adding Agentuity's wrapper structure.

## Features

- **Character-based responses**: The agent can respond as Harry Potter, Hermione Granger, or Ron Weasley
- **System prompt demonstration**: Shows how Mastra's system prompts can change agent behavior
- **Preserved framework code**: All original Mastra Agent creation and configuration is maintained
- **Agentuity integration**: Proper error handling, logging, and response formatting

## How it Works

The agent uses Mastra's `Agent` class with system prompts to define character personalities and response styles. When a user makes a request, the agent:

1. Receives input through Agentuity's `AgentRequest`
2. Creates a Mastra `Agent` with character-specific instructions
3. Generates a response using the original Mastra framework
4. Returns the result through Agentuity's `AgentResponse`

## Usage Examples

- "Speak as Harry Potter and tell me about your first day at Hogwarts"
- "Respond as Hermione and explain the importance of studying"
- "Answer as Ron and describe your favorite Quidditch match"

## Framework Preservation

This wrapper maintains the original Mastra framework patterns:

- Uses `@mastra/core/agent` for agent creation
- Preserves the original `Agent` constructor with `name`, `model`, and `instructions`
- Keeps the original `agent.generate()` method call
- Maintains all Mastra-specific configuration and behavior

## Development

```bash
# Install dependencies
bun install

# Run locally
agentuity dev

# Build
agentuity build

# Lint
bun run lint

# Format
bun run format
```

## Dependencies

- `@mastra/core`: Core Mastra framework
- `@ai-sdk/anthropic`: Anthropic AI SDK for Claude models
- `@agentuity/sdk`: Agentuity SDK for wrapper functionality

This example demonstrates the proper way to wrap existing framework agents in Agentuity structure without modifying the original framework code.
73 changes: 73 additions & 0 deletions frameworks/mastra/system-prompt/agentuity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/agentuity/cli/refs/heads/main/agentuity.schema.json

# ------------------------------------------------
# This file is generated by Agentuity
# You should check this file into version control
# ------------------------------------------------

# The version semver range required to run this project
version: '>=0.0.130'
# The ID of the project which is automatically generated
project_id: proj_mastra_system_prompt_example
# The name of the project which is editable
name: mastra-system-prompt
# The description of the project which is editable
description: "A Harry Potter character agent demonstrating Mastra's system prompt capabilities wrapped in Agentuity structure."
# The development configuration for the project
development:
# The port to run the development server on which can be overridden by setting the PORT environment variable
port: 3501
watch:
# Whether to watch for changes and automatically restart the server
enabled: true
# Rules for files to watch for changes
files:
- src/**
# The command to run the development server
command: bun
# The arguments to pass to the development server
args:
- run
- --silent
- .agentuity/index.js
deployment:
command: bun
args:
- run
- --no-install
- --prefer-offline
- --silent
- --no-macros
- --no-global-search-paths
- --report-uncaught-exception
- --disable-sigusr1
- --disallow-code-generation-from-strings
- --no-addons
- --no-deprecation
- .agentuity/index.js
# You should tune the resources for the deployment
resources:
# The memory requirements
memory: 250Mi
# The CPU requirements
cpu: 500M
# The disk size requirements
disk: 100Mi
# You should not need to change these value
bundler:
enabled: true
identifier: bunjs
language: javascript
runtime: bunjs
agents:
dir: src/agents
ignore:
- node_modules/**
- dist/**
- src/**
# The agents that are part of this project
agents:
- # The ID of the Agent which is automatically generated
id: agent_harry_potter_system_prompt
# The name of the Agent which is editable
name: HarryPotterAgent
39 changes: 39 additions & 0 deletions frameworks/mastra/system-prompt/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
Comment on lines +3 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Biome isn’t honoring .gitignore; add VCS ignores or explicit ignores to avoid linting .agentuity output.

With vcs.enabled: false and useIgnoreFile: false, Biome will not respect .gitignore. Once agentuity bundle creates .agentuity/, biome lint . may scan it and produce noise. Recommend enabling VCS ignores or explicitly ignoring build artifacts (at least .agentuity, dist, coverage).

Apply:

   "vcs": {
-    "enabled": false,
+    "enabled": true,
     "clientKind": "git",
-    "useIgnoreFile": false
+    "useIgnoreFile": true
   },
   "files": {
     "ignoreUnknown": false,
-    "ignore": []
+    "ignore": [".agentuity", "dist", "coverage"]
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [".agentuity", "dist", "coverage"]
},
🤖 Prompt for AI Agents
frameworks/mastra/system-prompt/biome.json lines 3-11: Biome is configured with
vcs.enabled: false and useIgnoreFile: false so it will not respect .gitignore
and may lint generated artifacts like .agentuity; update the configuration to
either enable VCS ignore handling (set "vcs.enabled": true or "useIgnoreFile":
true) or add explicit ignores (add ".agentuity", "dist", "coverage" to the
"files.ignore" array) so those build/test artifacts are excluded from linting.

"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"correctness": {
"noUnusedVariables": "error"
},
"style": {
"useImportType": "error"
},
"suspicious": {
"noExplicitAny": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
Loading