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
36 changes: 36 additions & 0 deletions frameworks/mastra/supervisor-agent/.cursorrules/agent.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
description: Guidelines for writing Agentuity AI Agents in TypeScript
globs: "**/src/agents/**/index.ts"
alwaysApply: true
---

# AI Agent File

- Prefer using the `agentuity agent create` command to create a new Agent
- Prefer loading types from the node modules package `@agentuity/sdk` in the node_modules folder
- The file should export a default function
- Prefer naming the default function Agent or the name of the Agent based on the context of the Agent description
- All code should be in Typescript format
- Use the provided logger from the `AgentContext` interface such as `ctx.logger.info("my message: %s", "hello")`

## Example Agent File

```typescript
import type { AgentRequest, AgentResponse, AgentContext } from "@agentuity/sdk";

export default async function Agent(req: AgentRequest, resp: AgentResponse, ctx: AgentContext) {
return resp.json({"hello":"world"});
}
```

### AgentRequest

The AgentRequest interface provides a set of helper methods and public variables which can be used for working with data has been passed to the Agent.

### AgentResponse

The AgentResponse interface provides a set of helper methods for responding with different data formats from the Agent.

### AgentContext

The AgentContext has information specific to the incoming Agent request and a set of helper methods for accessing AI services like KeyValue storage and Vector storage.
9 changes: 9 additions & 0 deletions frameworks/mastra/supervisor-agent/.cursorrules/agentuity.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
description: Guidelines for the Agentuity AI Configuration file
globs: "agentuity.yaml"
alwaysApply: true
---

# Agentuity Configuration File

This file is used by agentuity to configure the AI Agent project. You should NOT suggest edits to this file.
9 changes: 9 additions & 0 deletions frameworks/mastra/supervisor-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
dist/
.env
.env.local
.env.production.local
.env.development.local
*.log
.DS_Store
.agentuity/
58 changes: 58 additions & 0 deletions frameworks/mastra/supervisor-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Mastra Supervisor Agent

A supervisor agent that coordinates copywriting, editing, and publishing workflows using the Mastra framework. This example demonstrates how to wrap the original Mastra supervisor agent pattern within Agentuity's structure while preserving all framework-specific functionality.

## Overview

This agent implements the supervisor pattern from the [Mastra documentation](https://mastra.ai/en/examples/agents/supervisor-agent), featuring:

- **Copywriter Agent**: Generates initial blog post content
- **Editor Agent**: Refines and improves the content
- **Publisher Agent**: Acts as supervisor, coordinating the workflow between agents

The implementation preserves all original Mastra framework code while wrapping it in Agentuity's agent structure.

## Features

- Multi-agent coordination using Mastra's Agent class
- Tool integration with the copywriter tool
- Error handling with structured logging
- Welcome function with example prompts
- Follows Agentuity conventions for framework wrappers

## Usage

The agent accepts a topic and coordinates the creation of a blog post through the three-agent workflow:

1. Publisher agent receives the topic
2. Uses the copywriter tool to generate initial content
3. Coordinates with editor agent for refinement
4. Returns the final polished content

Comment on lines +25 to +31
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Docs claim editor step, but code doesn’t wire an editor tool.

The README describes “Copywriter → Editor → Publisher,” yet the implementation only exposes copywriterTool to the publisher. Either add an editorTool and wire it, or adjust the README.

Would you like a patch to add editorTool and update the publisher to use it?


🏁 Script executed:

#!/bin/bash
# Search for code files in the supervisor agent
echo "Listing TypeScript/JavaScript files under frameworks/mastra/supervisor-agent:"
find frameworks/mastra/supervisor-agent -type f \( -name '*.ts' -o -name '*.js' \)

# Search for wiring of copywriterTool
echo "Occurrences of copywriterTool:"
rg -n 'copywriterTool' frameworks/mastra/supervisor-agent

# Search for wiring of editorTool
echo "Occurrences of editorTool:"
rg -n 'editorTool' frameworks/mastra/supervisor-agent

# Search for generic 'editor' references in code
echo "Occurrences of 'editor' in code:"
rg -n 'editor' frameworks/mastra/supervisor-agent

Length of output: 2006


Align README with editor agent usage
README describes an editor tool, but the implementation instantiates an editorAgent directly (index.ts 31–33) and only wires copywriterTool. Update the README to reference the editorAgent step or introduce an editorTool in code.

🧰 Tools
🪛 LanguageTool

[grammar] ~29-~29: There might be a mistake here.
Context: ...generate initial content 3. Coordinates with editor agent for refinement 4. Returns ...

(QB_NEW_EN)

🤖 Prompt for AI Agents
frameworks/mastra/supervisor-agent/README.md lines 25-31: the README calls the
editor an "editor tool" but the implementation actually instantiates an
editorAgent (index.ts lines 31–33) and only wires the copywriterTool; update the
README to accurately describe the workflow by replacing "editor tool" references
with "editor agent" (or explicitly note that the publisher coordinates with an
editorAgent for refinement), or alternatively modify the code to expose an
editorTool and wire it alongside copywriterTool so README and implementation
match.

## Example Prompts

- "Write a blog post about artificial intelligence"
- "Create content about sustainable technology trends"
- "Generate a post about the future of remote work"

## Development

```bash
# Install dependencies
bun install

# Start development server
agentuity dev

# Build the project
agentuity build
```

## Framework Integration

This example demonstrates the proper way to wrap Mastra framework agents within Agentuity:

- Preserves all original Mastra imports and Agent classes
- Maintains framework-specific tool patterns
- Wraps the workflow in Agentuity's request/response structure
- Includes proper error handling and logging
73 changes: 73 additions & 0 deletions frameworks/mastra/supervisor-agent/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_3acd4734b82ba8aced38c677a97d57bf
# The name of the project which is editable
name: mastra-supervisor-agent
# The description of the project which is editable
description: A supervisor agent that coordinates copywriting, editing, and publishing workflows using the Mastra framework.
# 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: 3500
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:
Comment on lines +17 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Dev command/entrypoint: validate .agentuity/index.js generation and Bun availability.
Dev server points to .agentuity/index.js via bun run; confirm bun is available and the bundler emits this entry before starting dev.


🏁 Script executed:

#!/bin/bash
# Check Bun availability and version
command -v bun >/dev/null 2>&1 && bun --version || echo "Bun not found"

# Ensure the generated entry exists after build (or dev prepare step)
fd -a '.agentuity/index.js' -u || echo "Missing .agentuity/index.js (run agentuity build/dev first?)"

Length of output: 84


Require Bun and generated entry for dev
frameworks/mastra/supervisor-agent/agentuity.yaml:17-33 uses bun run .agentuity/index.js; ensure:

  • bun is installed (or surface a clear error/fallback if missing)
  • .agentuity/index.js is generated before dev (add a prestart/build step or document this prerequisite)
🤖 Prompt for AI Agents
frameworks/mastra/supervisor-agent/agentuity.yaml lines 17-33: the dev command
uses `bun run .agentuity/index.js` but does not ensure bun is available nor that
the generated entry `.agentuity/index.js` exists; update the dev workflow to
first verify `bun` is installed (or print a clear error and exit/fallback to
node/npm/yarn), and ensure the entry is generated before starting by adding a
prestart/build step that runs the generator/compile task (or document this
prerequisite clearly in README and add a prestart command in the YAML that runs
the build step and fails with a helpful message if the generated file is
missing).

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_7af1cdcfadfbaf74fe9de815df4bdff1
# The name of the Agent which is editable
name: mastra-supervisor-agent
36 changes: 36 additions & 0 deletions frameworks/mastra/supervisor-agent/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$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 is not honoring .gitignore; may format build artifacts.

With useIgnoreFile=false and empty ignore list, .agentuity/, dist/, node_modules/ could be linted/formatted.

Apply this diff:

   "vcs": {
-    "enabled": false,
-    "clientKind": "git",
-    "useIgnoreFile": false
+    "enabled": true,
+    "clientKind": "git",
+    "useIgnoreFile": true
   },
   "files": {
-    "ignoreUnknown": false,
-    "ignore": []
+    "ignoreUnknown": false,
+    "ignore": [".agentuity/**", "dist/**", "node_modules/**"]
   },
📝 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/**", "node_modules/**"]
},
🤖 Prompt for AI Agents
In frameworks/mastra/supervisor-agent/biome.json around lines 3 to 11, Biome is
configured with useIgnoreFile=false and an empty ignore list so build artifacts
and deps may be linted/formatted; change useIgnoreFile to true (so .gitignore is
honored) and/or populate the files.ignore array to include common artifacts such
as ".agentuity/", "dist/", and "node_modules/" so those paths are excluded from
formatting/linting.

"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"correctness": {
"noUnusedVariables": "error"
},
"style": {
"useImportType": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
Loading