-
Notifications
You must be signed in to change notification settings - Fork 5
Add Mastra supervisor agent wrapper #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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. |
| 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/ |
| 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 | ||
|
|
||
| ## 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 | ||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainDev command/entrypoint: validate .agentuity/index.js generation and Bun availability. 🏁 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
🤖 Prompt for AI Agents |
||
| 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 | ||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| "formatter": { | ||||||||||||||||||||||||||||||||||||||
| "enabled": true, | ||||||||||||||||||||||||||||||||||||||
| "indentStyle": "tab" | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| "organizeImports": { | ||||||||||||||||||||||||||||||||||||||
| "enabled": true | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| "linter": { | ||||||||||||||||||||||||||||||||||||||
| "enabled": true, | ||||||||||||||||||||||||||||||||||||||
| "rules": { | ||||||||||||||||||||||||||||||||||||||
| "recommended": false, | ||||||||||||||||||||||||||||||||||||||
| "correctness": { | ||||||||||||||||||||||||||||||||||||||
| "noUnusedVariables": "error" | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| "style": { | ||||||||||||||||||||||||||||||||||||||
| "useImportType": "error" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||
| "javascript": { | ||||||||||||||||||||||||||||||||||||||
| "formatter": { | ||||||||||||||||||||||||||||||||||||||
| "quoteStyle": "double" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
copywriterToolto the publisher. Either add aneditorTooland wire it, or adjust the README.Would you like a patch to add
editorTooland update the publisher to use it?🏁 Script executed:
Length of output: 2006
Align README with editor agent usage
README describes an editor tool, but the implementation instantiates an
editorAgentdirectly (index.ts 31–33) and only wirescopywriterTool. Update the README to reference the editorAgent step or introduce aneditorToolin 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