AgentStack is a production-grade multi-agent framework built on Mastra, delivering 60+ enterprise tools, 30+ specialized agents, 14 workflows, 4 agent networks, 65 UI components (30+ AI Elements + 35+ base), and A2A/MCP orchestration for scalable AI systems. Focuses on financial intelligence, RAG pipelines, observability, secure governance, and AI chat interfaces.
| Feature | AgentStack | LangChain | CrewAI | AutoGen |
|---|---|---|---|---|
| Production Observability | ✅ Full Langfuse tracing + custom scorers | ❌ Basic | ❌ Limited | |
| Financial Tools | ✅ Polygon/Finnhub/AlphaVantage (30+ endpoints) | ❌ None | ❌ None | ❌ None |
| RAG Pipeline | ✅ PgVector HNSW + rerank + graphRAG | ❌ Basic | ❌ None | |
| Multi-Agent | ✅ A2A MCP + parallel orchestration (30+ agents) | ✅ Sequential | ✅ Custom | |
| Governance | ✅ JWT/RBAC + path traversal + HTML sanitization | ❌ Custom | ❌ None | ❌ None |
| TypeScript | ✅ Zod schemas everywhere (94+ tools) | ❌ Python | ||
| UI Components | ✅ 65 components (AI Elements + shadcn/ui) | ❌ None | ❌ None | ❌ None |
| Tests | ✅ Vitest + comprehensive test suite | ❌ Sparse |
Built for production: Secure, observable, testable agents with zero-config PgVector RAG + enterprise financial APIs.
- 💰 Financial Intelligence: 30+ tools (Polygon quotes/aggs/fundamentals, Finnhub analysis, AlphaVantage indicators)
- 🔍 Semantic RAG: PgVector (3072D embeddings) + MDocument chunking + rerank + graph traversal
- 🤖 30+ Agents: Research → Learn → Report → Edit → Analyze (stock/crypto/copywriter/evaluator/data pipeline/business-legal/charting/image/coding/dane)
- 📋 14 Workflows: Weather, content, financial reports, document processing, research synthesis, learning extraction, governed RAG (index + answer), spec generation, repo ingestion, stock analysis
- 🌐 4 Agent Networks: Coding team, data pipeline, report generation, research pipeline
- 🔌 A2A/MCP: MCP server coordinates parallel agents (research+stock→report), A2A coordinator for cross-agent communication
- 🎨 65 UI Components: AI Elements (30 chat/reasoning/canvas components) + shadcn/ui (35 base primitives)
- 📊 Full Observability: Langfuse traces + 10+ custom scorers (diversity/quality/completeness) + TanStack Query for state management
- 🛡️ Enterprise Security: JWT auth, RBAC, path validation, HTML sanitization, secrets masking
- ⚡ Extensible: Model registry (Gemini/OpenAI/Anthropic/OpenRouter), Zod schemas everywhere, MastraClient SDK integration
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
graph TB
subgraph "� Frontend (Next.js 16)"
UI[AI Elements + shadcn/ui<br/>• 30+ AI Components<br/>• 35+ Base Primitives]
App[App Router<br/>• React 19<br/>• Tailwind CSS 4]
end
subgraph "🌐 MCP/A2A Client"
Client[Cursor/Claude/External Agents] --> Coord[A2A Coordinator MCP]
end
subgraph "🎯 AgentStack Runtime"
Coord --> Agents[30+ Agents<br/>• Research/Financial/Coding<br/>• Content/Data/Business]
Agents --> Tools[60+ Tools<br/>• Polygon/Finnhub/SerpAPI<br/>• RAG/Code/Data Processing]
Agents --> Workflows[14+ Workflows<br/>• Weather/Content/Financial<br/>• Document/RAG/Analysis]
Agents --> Networks[4+ Networks<br/>• Coding/Data/Report/Research]
end
subgraph "🗄️ PgVector Storage"
Tools --> Embeddings[3072D Gemini<br/>HNSW/Flat Indexes]
Tools --> Postgres[Traces/Evals<br/>Memory/Threads]
end
subgraph "📊 Observability"
Agents --> Otel[Otel Traces<br/>• 97% Traced<br/>• 10+ Scorers]
UI --> Otel
Postgres --> Otel
Agents --> Otel
Coord --> Otel
Workflows --> Otel
Networks --> Otel
end
UI --> App
App --> Agents
style Client stroke:#58a6ff
style App stroke:#58a6ff
style Coord stroke:#58a6ff
style Agents stroke:#58a6ff
style Tools stroke:#58a6ff
style Embeddings stroke:#58a6ff
style Workflows stroke:#58a6ff
style Networks stroke:#58a6ff
style Postgres stroke:#58a6ff
style Otel stroke:#58a6ff
style UI stroke:#58a6ff
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
sequenceDiagram
participant User
participant Workflow
participant Writer
participant Agent/Tool
participant Logger
User->>Workflow: Execute workflow step
Workflow->>Logger: logStepStart()
Workflow->>Writer: custom({ type: "data-tool-progress" })
Note over Writer: status: "in-progress"<br/>message: "Starting..."<br/>stage: "step-id"
Writer-->>User: Stream progress update
Workflow->>Agent/Tool: Execute operation
Agent/Tool->>Writer: custom({ type: "data-tool-progress" })
Note over Writer: Tool emits progress<br/>with same format
Writer-->>User: Stream tool progress
Agent/Tool-->>Workflow: Return result
Workflow->>Writer: custom({ type: "data-tool-progress" })
Note over Writer: status: "done"<br/>message: "Completed..."<br/>stage: "step-id"
Writer-->>User: Stream completion
Workflow->>Logger: logStepEnd()
Workflow-->>User: Return final output
alt Error occurs
Agent/Tool->>Writer: custom({ type: "data-tool-progress" })
Note over Writer: status: "error"<br/>message: error details
Writer-->>User: Stream error
Workflow->>Logger: logError()
end
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
flowchart TD
A[app/chat] -->|components| B[chat-header.tsx]
A -->|components| C[chat-messages.tsx]
A -->|components| D[chat-input.tsx]
A -->|config| E[agents.ts]
A -->|providers| F[chat-context.tsx]
G[app/networks] -->|components| H[network-header.tsx]
G -->|components| I[network-messages.tsx]
G -->|config| J[networks.ts]
G -->|providers| K[network-context.tsx]
L[app/workflows] -->|components| M[workflow-canvas.tsx]
L -->|components| N[workflow-header.tsx]
L -->|config| O[workflows.ts]
L -->|providers| P[workflow-context.tsx]
Q[app/dashboard] -->|components| R[dashboard.tsx]
Q -->|components| S[agent-list.tsx]
Q -->|providers| T[dashboard-context.tsx]
U[lib] -->|hooks| V[use-mastra.ts]
U -->|hooks| W[use-dashboard-queries.ts]
U -->|utils| X[utils.ts]
U -->|client| Y[mastra-client.ts]
Z[src/types] -->|api| AA[mastra-api.ts]
AB[src/mastra/index.ts] -->|imports| AC[agents/*]
AB -->|imports| AD[tools/*]
AB -->|imports| AE[workflows/*]
AB -->|imports| AF[networks/*]
AB -->|imports| AG[config/*]
style A stroke:#64b5f6
style B stroke:#64b5f6
style C stroke:#64b5f6
style D stroke:#64b5f6
style E stroke:#64b5f6
style F stroke:#64b5f6
style G stroke:#64b5f6
style H stroke:#64b5f6
style I stroke:#64b5f6
style J stroke:#64b5f6
style K stroke:#64b5f6
style L stroke:#64b5f6
style M stroke:#64b5f6
style N stroke:#64b5f6
style O stroke:#64b5f6
style P stroke:#64b5f6
style L stroke:#64b5f6
style Q stroke:#64b5f6
style U stroke:#64b5f6
style Z stroke:#64b5f6
style AB stroke:#64b5f6
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
flowchart TD
A[Docs/PDF/Web] --> B[MDocument Chunker<br/>• 10 Strategies<br/>• Metadata Extract]
B --> C[Gemini Embeddings<br/>• 3072D Vectors]
C --> D[PgVector Upsert<br/>• HNSW/Flat<br/>• Metadata Filter]
E[Query] --> F[Query Embed]
F --> G[Vector Search<br/>• Top-K + Rerank]
G --> H[Graph Traversal<br/>• Relations/Context]
H --> I[Answer Agent<br/>• Cite/Verify]
I --> J[Response + Sources]
J --> K[Otel Traces<br/>• 97% Coverage]
J --> L[Embedding Store<br/>• Memory Threads]
style A stroke:#58a6ff
style B stroke:#58a6ff
style C stroke:#58a6ff
style D stroke:#58a6ff
style E stroke:#58a6ff
style F stroke:#58a6ff
style G stroke:#58a6ff
style H stroke:#58a6ff
style I stroke:#58a6ff
style J stroke:#58a6ff
style K stroke:#58a6ff
style L stroke:#58a6ff
style K stroke:#58a6ff
style L stroke:#58a6ff
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
sequenceDiagram
actor User as User
participant Assistant as Assistant_Message
participant NetworkProvider as NetworkProvider
participant WorkflowProvider as WorkflowProvider
participant ProgressPanel as ProgressPanel
User->>Assistant: Run network or workflow
Assistant->>NetworkProvider: Stream messages with parts
Assistant->>WorkflowProvider: Stream messages with parts
loop For_each_assistant_message_in_network
NetworkProvider->>NetworkProvider: Iterate parts with index partIndex
NetworkProvider->>NetworkProvider: Build id using messageId_partType_partIndex
NetworkProvider->>NetworkProvider: Append ProgressEvent to allProgressEvents
end
loop For_each_assistant_message_in_workflow
WorkflowProvider->>WorkflowProvider: Iterate parts with index partIndex
WorkflowProvider->>WorkflowProvider: Build id using messageId_partType_partIndex
WorkflowProvider->>WorkflowProvider: Append ProgressEvent to allProgressEvents
end
NetworkProvider->>ProgressPanel: Provide progressEvents for network view
WorkflowProvider->>ProgressPanel: Provide progressEvents for workflow view
ProgressPanel->>User: Render grouped progress items with stable IDs
- Node.js ≥20.9.0
- PostgreSQL + pgvector (for RAG/Memory)
- API Keys:
.env(Gemini/SerpAPI/Polygon/etc.)
git clone https://github.com/ssdeanx/AgentStack.git
cd AgentStack
npm icp .env.example .env
# Add your keys (Gemini, SerpAPI, Polygon, etc.)# Terminal 1: Start Mastra backend (agents/tools/workflows at :4111)
npm run devThe frontend uses @mastra/client-js with TanStack Query for robust state management:
// lib/mastra-client.ts - Base client configuration
import { MastraClient } from "@mastra/client-js";
export const mastraClient = new MastraClient({
baseUrl: process.env.NEXT_PUBLIC_MASTRA_API_URL || "http://localhost:4111",
});
// lib/hooks/use-dashboard-queries.ts - TanStack Query hooks
import { useQuery } from "@tanstack/react-query";
import { mastraClient } from "@/lib/mastra-client";
// Query keys for cache management
export const queryKeys = {
agents: ["agents"] as const,
agent: (id: string) => ["agents", id] as const,
workflows: ["workflows"] as const,
tools: ["tools"] as const,
traces: (filters?: Record<string, unknown>) => ["traces", filters] as const,
threads: (resourceId: string, agentId: string) => ["threads", resourceId, agentId] as const,
vectors: (vectorName: string) => ["vectors", vectorName] as const,
};
// Type-safe query hooks
export function useAgentsQuery() {
return useQuery({
queryKey: queryKeys.agents,
queryFn: async (): Promise<Agent[]> => {
const agents = await mastraClient.listAgents();
return Object.entries(agents).map(([id, agent]) => ({
id,
name: agent.name,
description: agent.description,
model: agent.model,
}));
},
});
}
// lib/types/mastra-api.ts - Zod schemas for type safety
import { z } from "zod";
export const AgentSchema = z.object({
id: z.string(),
name: z.string().optional(),
description: z.string().optional(),
model: z.union([z.string(), z.object({ provider: z.string(), name: z.string() })]).optional(),
tools: z.union([z.array(z.string()), z.record(z.string(), z.unknown())]).optional(),
});
export type Agent = z.infer<typeof AgentSchema>;
// Available hooks:
// - useAgentsQuery(), useAgentQuery(id)
// - useWorkflowsQuery(), useWorkflowQuery(id)
// - useToolsQuery(), useToolQuery(id)
// - useTracesQuery(params), useTraceQuery(id)
// - useMemoryThreadsQuery(resourceId, agentId)
// - useMemoryMessagesQuery(threadId, agentId)
// - useVectorIndexesQuery(vectorName)
// - useExecuteToolMutation()
// - useCreateThreadMutation()
// - useVectorQueryMutation()Key Features:
- Type Safety: All API responses validated with Zod schemas
- Caching: Centralized query keys for efficient cache management
- Mutations: useExecuteToolMutation, useCreateThreadMutation, useVectorQueryMutation
- Real-time: Automatic cache invalidation and refetch on mutations
- Error Handling: Built-in loading/error states
Usage in client components:
"use client";
import { useAgentsQuery } from "@/lib/hooks/use-dashboard-queries";
export function AgentsList() {
const { data: agents, isLoading, error } = useAgentsQuery();
if (isLoading) return <div>Loading agents...</div>;
if (error) return <div>Error: {error.message}</div>;
return agents.map(agent => <AgentCard key={agent.id} agent={agent} />);
}Pages:
/- Landing page with agent overview/test- Server action demo (SSR)/chat- AI chat with 48+ agents using AI Elements and @ai-sdk/react/networks- Advanced agent network orchestration with routing/workflows- Interactive workflow canvas with 11+ workflows/dashboard- Admin dashboard with TanStack Query hooks for agents/tools/workflows/traces/memory/vectors/tools- Tool documentation and execution interface/docs- Comprehensive documentation (AI SDK, components, RAG, security, runtime context)/api-reference- OpenAPI schema and API documentation
Shared Libraries:
lib/mastra-client.ts- MastraClient configuration for frontendlib/hooks/- TanStack Query hooks for data fetching (15+ hooks)use-dashboard-queries.ts- Agents, workflows, tools, traces, threads, messages, vectorsuse-mastra.ts- Generic fetch hook with loading/error states
lib/types/- Zod schemas and TypeScript typesmastra-api.ts- Agent, Workflow, Tool, Trace, Message, Vector types
lib/utils.ts- Shared utilities (cn, formatDate, etc.)lib/a2a.ts- Agent-to-agent coordination utilitieslib/auth.ts- Authentication utilities
npm run mcp-server # http://localhost:6969/mcpnpm run build
npm run start╭─────────────────────────────── AgentStack ───────────────────────────────╮
│ Files: 574 | Size: 6.3MB │
│ Top Extensions: .tsx (197), .ts (190), .md (138), .mdx (15), .json (8) │
╰──────────────────────────────────────────────────────────────────────────╯
AgentStack
├── app/ (173 files, 878.7KB)
│ ├── about/ (410.0B)
│ │ └── page.tsx
│ ├── api/ (6 files, 6.6KB)
│ │ ├── chat/
│ │ │ └── route.ts
│ │ ├── chat-extra/ (581.0B)
│ │ │ └── route.ts
│ │ ├── completion/ (449.0B)
│ │ │ └── route.ts
│ │ ├── contact/ (2.2KB)
│ │ │ └── route.ts
│ │ └── v0/ (445.0B)
│ │ └── route.ts
│ ├── api-reference/ (5 files, 38.0KB)
│ │ ├── agents/ (8.2KB)
│ │ │ └── page.mdx
│ │ ├── openapi-schema/ (13.6KB)
│ │ │ └── page.mdx
│ │ ├── tools/ (7.1KB)
│ │ │ └── page.mdx
│ │ ├── workflows/ (8.8KB)
│ │ │ └── page.mdx
│ │ └── page.tsx
│ ├── blog/ (4 files, 13.4KB, all .tsx)
│ │ ├── hello-world-agentstack/ (9.1KB)
│ │ │ └── page.mdx
│ │ ├── session-summary/ (2.1KB)
│ │ │ └── page.tsx
│ │ └── layout page
│ ├── careers/ (418.0B)
│ │ └── page.tsx
│ ├── changelog/ (417.0B)
│ │ └── page.tsx
│ ├── chat/ (27 files, 175.7KB)
│ │ ├── components/ (16 files, 93.5KB, all .tsx)
│ │ │ └── agent-artifact agent-inline-citation agent-sources agent-web-preview
│ │ │ agent-chain-of-thought agent-plan agent-suggestions chat-header
│ │ │ agent-checkpoint agent-queue agent-task chat-input
│ │ │ agent-confirmation agent-reasoning agent-tools chat-messages
│ │ ├── config/ (7 files, 50.4KB, all .ts)
│ │ │ └── agents google-models ollama-models openrouter-models
│ │ │ anthropic-models models openai-models
│ │ ├── helpers/ (6.6KB)
│ │ │ └── tool-part-transform.ts
│ │ ├── providers/ (16.8KB)
│ │ │ └── chat-context.tsx
│ │ └── AGENTS.md page.tsx
│ ├── components/ (30 files, 218.5KB, all .tsx)
│ │ └── about-content contact-form landing-hero privacy-content
│ │ api-components docs-layout landing-stats sidebar
│ │ api-reference-content docs-nav landing-testimonials strip-frontmatter
│ │ blog-data examples-list landing-trust terms-content
│ │ blog-layout footer navbar tools-list
│ │ blog-list landing-agents networks-list workflows-list
│ │ careers-content landing-cta page-header
│ │ changelog-list landing-features pricing-tiers
│ ├── contact/ (409.0B)
│ │ └── page.tsx
│ ├── dashboard/ (44 files, 162.4KB)
│ │ ├── _components/ (8 files, 26.9KB)
│ │ │ └── data-table.tsx empty-state.tsx index.ts sidebar.tsx
│ │ │ detail-panel.tsx error-fallback.tsx loading-skeleton.tsx stat-card.tsx
│ │ ├── agents/ (9 files, 15.2KB, all .tsx)
│ │ │ ├── _components/ (6 files, 11.9KB)
│ │ │ │ └── agent-details.tsx agent-list-item.tsx agent-tools-tab.tsx
│ │ │ │ agent-evals-tab.tsx agent-list.tsx index.ts
│ │ │ └── error loading page
│ │ ├── logs/ (3 files, 11.2KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── memory/ (3 files, 17.2KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── observability/ (3 files, 18.1KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── telemetry/ (3 files, 11.1KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── tools/ (3 files, 11.1KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── vectors/ (3 files, 15.0KB, all .tsx)
│ │ │ └── error loading page
│ │ ├── workflows/ (3 files, 14.1KB, all .tsx)
│ │ │ └── error loading page
│ │ └── AGENTS.md error.tsx layout.tsx loading.tsx page.tsx providers.tsx
│ ├── docs/ (13 files, 90.5KB, all .tsx)
│ │ ├── ai-sdk/ (13.5KB)
│ │ │ └── page.mdx
│ │ ├── components/ (8.1KB)
│ │ │ └── page.mdx
│ │ ├── configuration/ (8.6KB)
│ │ │ └── page.mdx
│ │ ├── core-concepts/ (7.6KB)
│ │ │ └── page.mdx
│ │ ├── getting-started/ (2 files, 7.5KB)
│ │ │ └── 1.tsx page.mdx
│ │ ├── prompts/kiro-lite/ (9.8KB)
│ │ │ └── page.mdx
│ │ ├── rag/ (8.3KB)
│ │ │ └── page.mdx
│ │ ├── runtime-context/ (9.9KB)
│ │ │ └── page.mdx
│ │ ├── security/ (9.1KB)
│ │ │ └── page.mdx
│ │ ├── ui/ (6.8KB)
│ │ │ └── page.mdx
│ │ └── layout page
│ ├── examples/ (413.0B)
│ │ └── page.tsx
│ ├── login/ (6.4KB)
│ │ └── page.tsx
│ ├── networks/ (11 files, 82.1KB)
│ │ ├── components/ (7 files, 63.8KB, all .tsx)
│ │ │ └── network-agents network-header network-input network-routing-panel
│ │ │ network-chat network-info-panel network-messages
│ │ ├── config/ (4.4KB)
│ │ │ └── networks.ts
│ │ ├── providers/ (9.2KB)
│ │ │ └── network-context.tsx
│ │ └── AGENTS.md page.tsx
│ ├── pricing/ (412.0B)
│ │ └── page.tsx
│ ├── privacy/ (418.0B)
│ │ └── page.tsx
│ ├── terms/ (410.0B)
│ │ └── page.tsx
│ ├── test/ (7 files, 4.1KB)
│ │ └── AGENTS.md chat-extra.tsx completion.tsx page.tsx
│ │ action.ts chat.tsx form.tsx
│ ├── tools/ (401.0B)
│ │ └── page.tsx
│ ├── workflows/ (12 files, 60.7KB)
│ │ ├── components/ (8 files, 28.8KB, all .tsx)
│ │ │ └── workflow-actions workflow-header workflow-input-panel workflow-node
│ │ │ workflow-canvas workflow-info-panel workflow-legend workflow-output
│ │ ├── config/ (13.0KB)
│ │ │ └── workflows.ts
│ │ ├── providers/ (10.8KB)
│ │ │ └── workflow-context.tsx
│ │ └── AGENTS.md page.tsx
│ └── AGENTS.md globals.css layout.tsx page.tsx
├── docs/ (12 files, 339.7KB)
│ ├── adr/ (1.6KB)
│ │ └── 0001-why-pgvector-and-gemini-embeddings.md
│ ├── components/ (5 files, 36.5KB, all .md)
│ │ └── app-chat-documentation app-networks-documentation lib-documentation
│ │ app-dashboard-documentation app-workflows-documentation
│ └── ai-elements_aisk-urls.md kiro-lite.prompt.md
│ api-small.md runtimeContext.md
│ ⭐️ api.md
├── hooks/ (6 files, 5.6KB, all .ts)
│ └── index use-debounce use-local-storage use-media-query use-mounted use-utils
├── lib/ (7 files, 34.6KB, all .ts)
│ ├── hooks/ (2 files, 24.2KB, all .ts)
│ │ └── use-dashboard-queries use-mastra
│ ├── types/ (5.4KB)
│ │ └── mastra-api.ts
│ └── auth client-stream-to-ai-sdk mastra-client utils
├── src/ (206 files, 2.7MB)
│ ├── components/ai-elements/ (30 files, 153.5KB, all .tsx)
│ │ └── artifact confirmation edge model-selector prompt-input suggestion
│ │ canvas connection image node queue task
│ │ chain-of-thought context inline-citation open-in-chat reasoning tool
│ │ checkpoint controls loader panel shimmer toolbar
│ │ code-block conversation message plan sources web-preview
│ └── mastra/ (176 files, 2.5MB)
│ ├── a2a/ (3 files, 13.4KB)
│ │ └── AGENTS.md a2aCoordinatorAgent.ts codingA2ACoordinator.ts
│ ├── agents/ (30 files, 192.5KB)
│ │ └── AGENTS.md excalidraw_validator.ts
│ │ acpAgent.ts for await (const part of result.md
│ │ businessLegalAgents.ts image.ts
│ │ calendarAgent.ts image_to_csv.ts
│ │ codingAgents.ts knowledgeIndexingAgent.ts
│ │ contentStrategistAgent.ts learningExtractionAgent.ts
│ │ copywriterAgent.ts package-publisher.ts
│ │ csv_to_excalidraw.ts recharts.ts
│ │ dane.ts reportAgent.ts
│ │ dataExportAgent.ts researchAgent.ts
│ │ dataIngestionAgent.ts researchPaperAgent.ts
│ │ dataTransformationAgent.ts scriptWriterAgent.ts
│ │ documentProcessingAgent.ts sql.ts
│ │ editorAgent.ts stockAnalysisAgent.ts
│ │ evaluationAgent.ts weather-agent.ts
│ ├── config/ (29 files, 252.4KB)
│ │ ├── vector/ (11 files, 108.0KB)
│ │ │ └── AGENTS.md chroma.ts couchbase.ts opensearch.ts qdrant.ts s3vectors.ts
│ │ │ astra.ts cloudflare.ts lance.ts pinecone.ts registry.ts
│ │ └── AGENTS.md gemini-cli.ts mongodb.ts processors.ts upstashMemory.ts
│ │ README.md google.ts openai.ts role-hierarchy.ts vertex.ts
│ │ anthropic.ts index.ts openrouter.ts tracing.ts
│ │ copilot.ts logger.ts pg-storage.ts upstash.ts
│ ├── data/ (10 files, 1020.7KB)
│ │ └── AGENTS.md diamond.excalidraw sample_dataset.csv
│ │ circle.excalidraw example-text-arrows.excalidraw ⭐️ test.excalidraw
│ │ diagram (5).json pencil.excalidraw
│ │ diagram.excalidraw relationship.excalidraw
│ ├── experiments/ (8.6KB)
│ │ └── agent-experiments.ts
│ ├── mcp/ (6 files, 34.6KB)
│ │ └── AGENTS.md index.ts mcp-client.ts prompts.ts resources.ts server.ts
│ ├── networks/ (6 files, 27.6KB)
│ │ └── AGENTS.md dataPipelineNetwork.ts reportGenerationNetwork.ts
│ │ codingTeamNetwork.ts index.ts researchPipelineNetwork.ts
│ ├── policy/ (2 files, 7.0KB)
│ │ └── AGENTS.md acl.yaml
│ ├── scorers/ (11 files, 52.3KB)
│ │ └── AGENTS.md financial-scorers.ts structure.scorer.ts
│ │ csv-validity.scorer.ts index.ts tone-consistency.scorer.ts
│ │ custom-scorers.ts script-scorers.ts weather-scorer.ts
│ │ factuality.scorer.ts sql-validity.scorer.ts
│ ├── tools/ (60 files, 753.7KB)
│ │ ├── tests/ (15 files, 145.8KB, all .ts)
│ │ │ └── copywriter-agent-tool.test json-to-csv.tool.test
│ │ │ csv-to-json.tool.test serpapi-academic-local.tool.test
│ │ │ data-file-manager.test serpapi-news-trends.tool.test
│ │ │ data-validator.tool.test serpapi-search.tool.test
│ │ │ document-chunking.tool.test serpapi-shopping.tool.test
│ │ │ editor-agent-tool.test weather-tool.test
│ │ │ evaluateResultTool.test web-scraper-tool.test
│ │ │ extractLearningsTool.test
│ │ └── AGENTS.md document-chunking.tool.ts pdf-data-conversion.tool.ts
│ │ AGENTS.md.bak editor-agent-tool.ts pdf.ts
│ │ alpha-vantage.tool.ts evaluateResultTool.ts pg-sql-tool.ts
│ │ arxiv.tool.ts execa-tool.ts pnpm-tool.ts
│ │ browser-tool.ts extractLearningsTool.ts polygon-tools.ts
│ │ calendar-tool.ts financial-chart-tools.ts semantic-utils.ts
│ │ code-analysis.tool.ts find-references.tool.ts serpapi-academic-local.tool.ts
│ │ code-chunking.ts find-symbol.tool.ts serpapi-config.ts
│ │ code-search.tool.ts finnhub-tools.ts serpapi-news-trends.tool.ts
│ │ copywriter-agent-tool.ts fs.ts serpapi-search.tool.ts
│ │ csv-to-json.tool.ts github.ts serpapi-shopping.tool.ts
│ │ data-file-manager.ts index.ts test-generator.tool.ts
│ │ data-processing-tools.ts json-to-csv.tool.ts weather-tool.ts
│ │ data-validator.tool.ts jwt-auth.tool.ts ⭐️ web-scraper-tool.ts
│ │ diff-review.tool.ts multi-string-edit.tool.ts write-note.ts
│ ├── types/ (2 files, 1.2KB, all .ts)
│ │ └── excalidraw-to-svg.d svgjson.d
│ ├── workflows/ (14 files, 180.8KB)
│ │ └── AGENTS.md financial-report-workflow.ts spec-generation-workflow.ts
│ │ changelog.ts learning-extraction-workflow.ts stock-analysis-workflow.ts
│ │ content-review-workflow.ts new-contributor.ts telephone-game.ts
│ │ content-studio-workflow.ts repo-ingestion-workflow.ts weather-workflow.ts
│ │ document-processing-workflow.ts research-synthesis-workflow.ts
│ └── AGENTS.md index.ts
├── tests/ (3 files, 2.5KB, all .ts)
│ ├── test-results/ (1.0KB)
│ │ └── test-results.json
│ └── api-chat-r.test docs-hello-world.test
├── ui/ (34 files, 91.4KB, all .tsx)
│ └── accordion button command input-group popover separator textarea
│ alert card dialog input progress sheet theme-toggle
│ avatar carousel dropdown-menu label radio-group skeleton tooltip
│ badge checkbox helpers layout scroll-area switch typography
│ button-group collapsible hover-card link select tabs
└── .blackboxrules components.json networksCustomToolv1.png prettier.config.js
.env.example eslint.config.cjs networksv1.png read_pdf_parse.js
.gitignore globalSetup.ts next.config.ts testSetup.ts
.markdownlint.json instrumentation.ts ⭐️ package-lock.json tsconfig.json
AGENTS.md llms.txt package.json vitest.config.ts
README.md mdx-components.tsx postcss.config.mjs- New Tool:
src/mastra/tools/my-tool.ts→createTool({zodSchema, execute}) - New Agent:
src/mastra/agents/my-agent.ts→ Compose tools + Zod instructions - Test:
npm test(97% coverage) ornpx vitest src/mastra/tools/tests/my-tool.test.ts - Lint:
npm run lint
| Env Var | Purpose | Required |
|---|---|---|
SUPABASE |
Postgres + PgVector RAG | ✅ |
GOOGLE_GENERATIVE_AI_API_KEY |
Gemini LLM/Embeddings | ✅ |
SERPAPI_API_KEY |
Search/News/Shopping (10+ tools) | ✅ |
POLYGON_API_KEY |
Stock/Crypto quotes/aggs/fundamentals | ✅ |
LANGFUSE_BASE_URL |
Langfuse tracing | Observability |
Full: .env.example + src/mastra/config/AGENTS.md
npm test # All tests
npm run coverage # LCOV report
npx vitest -t "polygon" # Filter (e.g., financial tools)- Vitest + Zod: Schema validation + mocks
- API Mocks: Financial/search tools fully mocked
- JWT Auth:
jwt-auth.tool.ts+ RBAC - Path Traversal:
validateDataPath()everywhere - HTML Sanitization: JSDOM + Cheerio (script/strip events)
- Secrets Masking:
maskSensitiveMessageData() - Rate Limiting: Built into financial APIs
Langfuse Exporters:
├── Traces: 100% (spans/tools/agents)
├── Scorers: 10+ (diversity/quality/task-completion)
├── Metrics: Latency/errors/tool-calls
└── Sampling: Always-on + ratio (30-80%)Custom Scorers: Source diversity, completeness, creativity, response quality.
The admin dashboard provides comprehensive observability and management:
Routes:
/dashboard- Overview with stat cards (agents, workflows, tools, recent activity)/dashboard/agents- Agent management (list, details, tools, evals)/dashboard/workflows- Workflow monitoring and execution history/dashboard/tools- Tool catalog and usage analytics/dashboard/observability- Traces, spans, and performance metrics/dashboard/memory- Memory threads, messages, and working memory/dashboard/vectors- Vector indexes and similarity search/dashboard/logs- System logs with transport filtering/dashboard/telemetry- Performance telemetry and metrics
Components:
// Shared components (_components/)
- data-table.tsx // Reusable TanStack Table with sorting/filtering
- detail-panel.tsx // Slide-over panel for item details
- empty-state.tsx // Consistent empty states
- error-fallback.tsx // Error boundary with retry
- loading-skeleton.tsx // Skeleton loaders
- sidebar.tsx // Navigation sidebar
- stat-card.tsx // Metric display cards
// Agent-specific (agents/_components/)
- agent-list.tsx // Filterable agent list
- agent-list-item.tsx // Individual agent card
- agent-details.tsx // Agent configuration details
- agent-tab.tsx // Agent overview tab
- agent-tools-tab.tsx // Agent tools tab
- agent-evals-tab.tsx // Agent evaluations tabData Fetching:
All dashboard pages use TanStack Query hooks from lib/hooks/use-dashboard-queries.ts:
import { useAgentsQuery, useToolsQuery, useTracesQuery } from "@/lib/hooks/use-dashboard-queries";
function AgentsPage() {
const { data: agents, isLoading } = useAgentsQuery();
const { data: tools } = useToolsQuery();
// Automatic caching, refetching, and error handling
}| Category | Tools | Agents | Frontend |
|---|---|---|---|
| 🔍 Search | SerpAPI (News/Trends/Shopping/Scholar/Local/Yelp) | ResearchAgent | Chat interface with citations |
| 💰 Financial | Polygon (10+), Finnhub (6+), AlphaVantage (indicators) | StockAnalysis, CryptoAnalysis | Dashboard with charts and metrics |
| 📄 RAG | PgVector chunk/rerank/query/graph | Retrieve/Rerank/Answerer | Vector search interface |
| 📝 Content | PDF→MD, Web Scraper, Copywriter/Editor | CopywriterAgent, EditorAgent, ReportAgent | Chat with artifact preview |
| 🎨 Visual | CSV↔Excalidraw, SVG/XML process | csvToExcalidrawAgent, imageToCsvAgent | Workflow canvas visualization |
| 🌐 Orchestration | A2A MCP Server | a2aCoordinatorAgent, codingA2ACoordinator | Network routing panel |
| 💻 UI | AI Elements (30), shadcn/ui (35), Radix primitives | Chat/Reasoning/Canvas interfaces | 65 components across 10+ app routes |
| 📊 Observability | Langfuse traces, Custom scorers | All agents instrumented | Dashboard with traces/logs/telemetry |
| 🔄 State Mgmt | TanStack Query | Memory threads, working memory | 15+ hooks with caching and invalidation |
The chat interface (/chat) provides a production-ready AI chat experience with 48+ specialized agents:
AI Elements Components (16 integrated):
AgentArtifact- Code/document artifacts with previewAgentChainOfThought- Step-by-step reasoning displayAgentCheckpoint- Progress checkpointsAgentConfirmation- User confirmationsAgentInlineCitation- Source citationsAgentPlan- Multi-step plansAgentQueue- Task queuesAgentReasoning- Reasoning tracesAgentSources- Source documentsAgentSuggestions- Follow-up suggestionsAgentTask- Individual tasksAgentTools- Tool usage displayAgentWebPreview- Web preview iframe
Agent Categories (48+ total):
- Research (5): researchAgent, researchPaperAgent, knowledgeIndexingAgent, learningExtractionAgent, dane
- Content (5): copywriterAgent, editorAgent, contentStrategistAgent, scriptWriterAgent, reportAgent
- Financial (6): stockAnalysisAgent, chartSupervisorAgent, chartTypeAdvisorAgent, chartDataProcessorAgent, chartGeneratorAgent
- Data (8): dataIngestionAgent, dataTransformationAgent, dataExportAgent, documentProcessingAgent, csvToExcalidrawAgent, imageToCsvAgent, excalidrawValidatorAgent, imageAgent
- Coding (9): codeArchitectAgent, codeReviewerAgent, testEngineerAgent, refactoringAgent, daneCommitMessage, daneIssueLabeler, daneLinkChecker, daneChangeLog, danePackagePublisher
- Business (4): legalResearchAgent, contractAnalysisAgent, complianceMonitoringAgent, businessStrategyAgent
Model Providers (40+ models):
- Google: 8 models (Gemini 2.5 Flash, Pro, Exp variants)
- OpenAI: 12 models (GPT-5, GPT-4o, o1, o3-mini)
- Anthropic: 8 models (Claude 4.5, 4 Sonnet/Opus/Haiku)
- OpenRouter: 12+ models (Llama, Mistral, Qwen)
Advanced agent network orchestration (/networks) with routing and coordination:
4 Pre-configured Networks:
- Coding Team Network (4 agents): Architecture → Review → Testing → Refactoring
- Data Pipeline Network (3 agents): Ingestion → Transformation → Export
- Report Generation Network (3 agents): Research → Analysis → Report
- Research Pipeline Network (4 agents): Research → Learning → Knowledge Indexing → Synthesis
Features:
- Network Routing Panel: Visualizes agent routing decisions in real-time
- Parallel Execution: Multiple agents work simultaneously
- A2A Coordination: Inter-agent communication management
Interactive workflow visualization (/workflows) with AI Elements Canvas:
11 Pre-built Workflows:
- Weather Workflow: Fetch weather → Analyze → Suggest activities
- Content Studio: Research → Write → Edit → Review
- Content Review: Fetch → Analyze → Score → Report
- Financial Report: Market data → Analysis → Report generation
- Document Processing: Upload → Parse → Chunk → Embed → Index
- Research Synthesis: Query → Search → Analyze → Synthesize
- Learning Extraction: Read → Extract → Summarize → Store
- Governed RAG Index: Validate → Chunk → Embed → Upsert
- Governed RAG Answer: Query → Retrieve → Rerank → Answer
- Spec Generation: Requirements → Design → Spec → Validation
- Stock Analysis: Fetch data → Technical analysis → Report
AI Elements Components (8 for workflows):
WorkflowCanvas- Main canvas with pan/zoomWorkflowNode- Individual workflow stepsWorkflowEdge- Connections between stepsWorkflowPanel- Side panel with detailsWorkflowControls- Canvas controlsWorkflowLegend- Node type legendWorkflowOutput- Execution output display
// src/mastra/agents/my-agent.ts
import { Agent } from '@mastra/core/agent'
export const myAgent = new Agent({
id: 'my-agent',
tools: { polygonStockQuotesTool, pgQueryTool },
instructions: 'Analyze stocks with Polygon + RAG...',
model: googleAI, // From model registry
memory: pgMemory,
})
// Auto-registers in index.ts# Start server
npm run mcp-server
# Use in Cursor/Claude
# coordinate_a2a_task({task: "AAPL analysis", agents: ["research", "stock"]})- Fork:
https://github.com/ssdeanx/AgentStack - Setup:
npm ci && npm test - Add: Tool/Agent + Zod schema + Vitest
- PR:
npm test+ coverage >95%
Guidelines:
- Zod Everywhere: Input/output schemas
- Stateless Tools: Agents orchestrate
- Mock APIs: 100% test coverage
- Trace Everything: Arize spans
Frontend Routes:
- Chat Interface: AI chat with 48+ agents using AI Elements and @ai-sdk/react
- Networks: Advanced agent network orchestration with routing panel
- Workflows: Interactive workflow visualization with AI Elements Canvas
- Dashboard: Admin dashboard with agents/tools/workflows/traces/memory/vectors
- Documentation: Comprehensive docs (AI SDK, components, RAG, security)
- API Reference: OpenAPI schema and API documentation
Shared Libraries:
- lib/hooks: TanStack Query hooks for data fetching (15+ hooks)
use-dashboard-queries.ts- Agents, workflows, tools, traces, threads, messages, vectorsuse-mastra.ts- Generic fetch hook with loading/error states
- lib/types: Zod schemas and TypeScript types
mastra-api.ts- Agent, Workflow, Tool, Trace, Message, Vector types
- lib/: Client SDK, utilities, auth, A2A coordination
Core Components:
- UI Components: 35 shadcn/ui base components
- AI Elements: 30 AI chat/reasoning/canvas components
- Agents Catalog: 48 agents
- Tools Matrix: 94+ tools
- Workflows: 11 multi-step workflows
- Networks: 4 agent networks
- Config Guide: Setup + env vars
- MCP/A2A: Multi-agent federation
- Scorers: 10+ eval metrics
- Financial Suite: Polygon/Finnhub/AlphaVantage (✅ Live - 30+ endpoints)
- RAG Pipeline: PgVector + rerank/graph (✅ Live)
- A2A MCP: Parallel orchestration (✅ Live)
- 11 Workflows: Sequential, parallel, branch, loop, foreach, suspend/resume (✅ Live)
- 4 Agent Networks: Routing and coordination (✅ Live)
- 65 UI Components: AI Elements + shadcn/ui (✅ Live)
- Chat Interface: Full agent chat UI with AI Elements (✅ Live - 48+ agents)
- Dashboard: Admin dashboard with TanStack Query (✅ Live - 8 routes)
- MastraClient SDK: Type-safe client with Zod schemas (✅ Live)
- LangSmith/Phoenix: Enhanced eval dashboards
- Docker/Helm: K8s deployment templates
- Multi-tenancy: Tenant isolation and resource management
⭐ Star ssdeanx/AgentStack 🐦 Follow @ssdeanx 📘 Docs (Coming Q1 2026)
Last updated: 2025-12-05 | v1.1.0
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#58a6ff', 'primaryTextColor': '#c9d1d9', 'primaryBorderColor': '#30363d', 'lineColor': '#58a6ff', 'sectionBkgColor': '#161b22', 'altSectionBkgColor': '#0d1117', 'sectionTextColor': '#c9d1d9', 'gridColor': '#30363d', 'tertiaryColor': '#161b22' }}}%%
classDiagram
direction LR
class AgentPlanData {
+string title
+string description
+PlanStep[] steps
+bool isStreaming
+number currentStep
}
class PlanStep {
+string text
+bool completed
}
class AgentTaskData {
+string title
+TaskStep[] steps
}
class TaskStep {
+string id
+string text
+TaskStepStatus status
+string file_name
+string file_icon
}
class TaskStepStatus {
<<enumeration>>
pending
running
completed
error
}
class ArtifactData {
+string id
+string title
+string description
+string type
+string language
+string content
}
class Citation {
+string id
+string number
+string title
+string url
+string description
+string quote
}
class QueuedTask {
+string id
+string title
+string description
+string status
+Date createdAt
+Date completedAt
+string error
}
class WebPreviewData {
+string id
+string url
+string title
+string code
+string language
+string html
+bool editable
+bool showConsole
+number height
}
class ReasoningStep {
+string id
+string label
+string description
+string status
+string[] searchResults
+number duration
}
class AgentSuggestionsProps {
+string[] suggestions
+onSelect(suggestion)
+bool disabled
+string className
}
class AgentSourcesProps {
+SourceItem[] sources
+string className
+number maxVisible
}
class SourceItem {
+string url
+string title
}
class AgentReasoningProps {
+string reasoning
+bool isStreaming
+number duration
+string className
}
class AgentToolsProps {
+ToolInvocation[] tools
+string className
}
class ConfirmationSeverity {
<<enumeration>>
info
warning
danger
}
class InlineCitationToken {
<<union>>
text
citation
}
class ChatUtils {
+extractPlanFromText(text) AgentPlanData
+parseReasoningToSteps(reasoning) ReasoningStep[]
+tokenizeInlineCitations(content, sources) InlineCitationToken[]
+getSuggestionsForAgent(agentId) string[]
}
class AgentPlan {
+AgentPlanData plan
+onExecuteCurrentStep()
+onCancel()
+onApprove()
}
class AgentTask {
+AgentTaskData task
}
class AgentArtifact {
+ArtifactData artifact
+onCodeUpdate(artifactId, newCode)
}
class AgentInlineCitation {
+Citation[] citations
+string text
}
class AgentSuggestions {
+AgentSuggestionsProps props
}
class AgentSources {
+AgentSourcesProps props
}
class AgentReasoning {
+AgentReasoningProps props
}
class AgentTools {
+AgentToolsProps props
}
class AgentQueue {
+QueuedTask[] tasks
}
class AgentWebPreview {
+WebPreviewData preview
+onCodeChange(code)
}
class AgentCodeSandbox {
+onCodeChange(code)
}
%% Relationships between data types
AgentPlanData --> "*" PlanStep
AgentTaskData --> "*" TaskStep
TaskStep --> TaskStepStatus
AgentSourcesProps --> "*" SourceItem
AgentToolsProps --> "*" ToolInvocation
%% Components depending on shared chat types
AgentPlan --> AgentPlanData
AgentTask --> AgentTaskData
AgentArtifact --> ArtifactData
AgentInlineCitation --> Citation
AgentSuggestions --> AgentSuggestionsProps
AgentSources --> AgentSourcesProps
AgentReasoning --> AgentReasoningProps
AgentTools --> AgentToolsProps
AgentQueue --> QueuedTask
AgentWebPreview --> WebPreviewData
AgentCodeSandbox --> WebPreviewData
%% Utilities using shared types
ChatUtils --> AgentPlanData
ChatUtils --> ReasoningStep
ChatUtils --> InlineCitationToken
ChatUtils --> AgentSuggestionsProps

