-
Notifications
You must be signed in to change notification settings - Fork 931
feat!(mastra): Support 1.0.0-beta #685
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
Open
LekoArts
wants to merge
18
commits into
ag-ui-protocol:main
Choose a base branch
from
LekoArts:mastra-v1-beta-compat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0bea326
update deps
LekoArts 5da63e8
update code
LekoArts a62f159
remove unused lock file
LekoArts 4e06521
update deps in examples
LekoArts d2aeeb8
update code
LekoArts b8190c1
qol
LekoArts 9ba3771
example working
LekoArts 78467f4
fix cli example
LekoArts 69bfb25
update dojo
LekoArts 0050d12
add unit tests
LekoArts 9d01d7a
revert
LekoArts 8ee7643
Merge branch 'main' into mastra-v1-beta-compat
LekoArts e48d161
update mastra versions
LekoArts 8a090af
updates
LekoArts 1fe47f8
fixes
LekoArts a84393b
resource scoped
LekoArts 68dd826
Merge branch 'main' into mastra-v1-beta-compat
LekoArts 87b99bc
re-apply changes
LekoArts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,51 @@ | ||
| # AG-UI CLI | ||
| # AG-UI CLI Example | ||
|
|
||
| A command-line chat interface demonstrating the AG-UI client with a Mastra agent. This example shows how to build an interactive CLI application that streams agent responses and tool calls in real-time. | ||
|
|
||
| ## Features | ||
|
|
||
| - Interactive chat loop with streaming responses | ||
| - Real-time tool call visualization (weather and browser tools) | ||
| - Message history persistence using LibSQL | ||
| - Built with `@ag-ui/client` and `@ag-ui/mastra` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js 22.13.0 or later | ||
| - OpenAI API key | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Install dependencies from the repository root: | ||
|
|
||
| ```bash | ||
| pnpm install | ||
| ``` | ||
|
|
||
| 2. Set your OpenAI API key: | ||
| ```bash | ||
| export OPENAI_API_KEY=your_api_key_here | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Run the CLI: | ||
|
|
||
| ```bash | ||
| pnpm start | ||
| ``` | ||
|
|
||
| Try these example prompts: | ||
|
|
||
| - "What's the weather in San Francisco?" | ||
| - "Browse https://example.com" | ||
|
|
||
| Press `Ctrl+D` to quit. | ||
|
|
||
| ## How It Works | ||
|
|
||
| This example uses: | ||
|
|
||
| - **MastraAgent**: Wraps a Mastra agent with AG-UI protocol support | ||
| - **Event Handlers**: Streams text deltas, tool calls, and results to the console | ||
| - **Memory**: Persists conversation history in a local SQLite database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import { openai } from "@ai-sdk/openai"; | ||
| import { Agent } from "@mastra/core/agent"; | ||
| import { MastraAgent } from "@ag-ui/mastra"; | ||
| import { Memory } from "@mastra/memory"; | ||
|
|
@@ -7,8 +6,9 @@ import { weatherTool } from "./tools/weather.tool"; | |
| import { browserTool } from "./tools/browser.tool"; | ||
|
|
||
| export const agent = new MastraAgent({ | ||
| // @ts-ignore | ||
| resourceId: "cliExample", | ||
| agent: new Agent({ | ||
| id: "ag-ui-agent", | ||
| name: "AG-UI Agent", | ||
| instructions: ` | ||
| You are a helpful assistant that runs a CLI application. | ||
|
|
@@ -26,13 +26,13 @@ export const agent = new MastraAgent({ | |
| Use the browserTool to browse the web. | ||
|
|
||
| `, | ||
| model: openai("gpt-4o-mini"), | ||
| model: "openai/gpt-4o-mini", | ||
| tools: { weatherTool, browserTool }, | ||
| memory: new Memory({ | ||
| storage: new LibSQLStore({ | ||
| id: "mastra-cli-example-db", | ||
|
Author
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. |
||
| url: "file:./mastra.db", | ||
| }), | ||
| }), | ||
| }), | ||
| threadId: "1", | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,8 @@ export const browserTool = createTool({ | |
| url: z.string().describe("URL to browse"), | ||
| }), | ||
| outputSchema: z.string(), | ||
| execute: async ({ context }) => { | ||
| open(context.url); | ||
| return `Browsed ${context.url}`; | ||
| execute: async (inputData) => { | ||
|
Author
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. |
||
| open(inputData.url); | ||
| return `Browsed ${inputData.url}`; | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,3 +141,6 @@ dist | |
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* | ||
| .vite/ | ||
|
|
||
| # Mastra files | ||
| .mastra | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Mastra now has its own model router so we can remove AI SDK usage