chore: install openagent opencode
Signed-off-by: Dmytro Stanchiev <git@dmytros.dev>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<!-- Context: development/agents-tools | Priority: critical | Version: 1.0 | Updated: 2026-02-15 -->
|
||||
|
||||
# Concept: Mastra Agents & Tools
|
||||
|
||||
**Purpose**: Reusable units of logic and LLM-powered entities.
|
||||
|
||||
**Last Updated**: 2026-01-09
|
||||
|
||||
---
|
||||
|
||||
## Core Idea
|
||||
Agents are specialized LLM configurations that use Tools to interact with external systems or perform specific logic. Tools are the building blocks that provide functionality to both agents and workflows.
|
||||
|
||||
## Key Points
|
||||
- **Agents**: Defined with a `name`, `instructions`, and `model`. They can be assigned a set of `tools`.
|
||||
- **Tools**: Defined with `id`, `inputSchema`, `outputSchema`, and an `execute` function.
|
||||
- **Type Safety**: Both agents and tools use Zod for schema validation.
|
||||
- **Standalone Use**: Tools can be executed independently of agents, making them highly reusable.
|
||||
|
||||
## Quick Example
|
||||
```typescript
|
||||
// Tool
|
||||
const myTool = createTool({
|
||||
id: 'my-tool',
|
||||
inputSchema: z.object({ query: z.string() }),
|
||||
execute: async ({ inputData }) => ({ result: `Processed ${inputData.query}` }),
|
||||
});
|
||||
|
||||
// Agent
|
||||
const myAgent = new Agent({
|
||||
name: 'My Agent',
|
||||
instructions: 'Use my-tool to process queries.',
|
||||
model: { provider: 'OPEN_AI', name: 'gpt-4o' },
|
||||
tools: { myTool },
|
||||
});
|
||||
```
|
||||
|
||||
**Reference**: `src/mastra/agents/`, `src/mastra/tools/`
|
||||
**Related**:
|
||||
- concepts/core.md
|
||||
- concepts/workflows.md
|
||||
37
.opencode/context/development/ai/mastra-ai/concepts/core.md
Normal file
37
.opencode/context/development/ai/mastra-ai/concepts/core.md
Normal file
@@ -0,0 +1,37 @@
|
||||
<!-- Context: development/core | Priority: critical | Version: 1.0 | Updated: 2026-02-15 -->
|
||||
|
||||
# Concept: Mastra Core
|
||||
|
||||
**Purpose**: Central orchestration layer for AI agents, workflows, and tools in this project.
|
||||
|
||||
**Last Updated**: 2026-01-09
|
||||
|
||||
---
|
||||
|
||||
## Core Idea
|
||||
Mastra is the central hub that wires together agents, tools, workflows, and observability. It provides a unified interface for executing complex AI tasks with built-in persistence and logging.
|
||||
|
||||
## Key Points
|
||||
- **Centralized Config**: All components are registered in `src/mastra/index.ts`.
|
||||
- **Persistence**: Uses `LibSQLStore` (SQLite) for storing traces, spans, and workflow states.
|
||||
- **Observability**: Built-in tracing and logging (Pino) for every execution.
|
||||
- **Modular Design**: Agents, tools, and workflows are defined separately and composed in the main instance.
|
||||
|
||||
## Quick Example
|
||||
```typescript
|
||||
import { Mastra } from '@mastra/core/mastra';
|
||||
import { agents, tools, workflows } from './components';
|
||||
|
||||
export const mastra = new Mastra({
|
||||
agents,
|
||||
tools,
|
||||
workflows,
|
||||
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
||||
});
|
||||
```
|
||||
|
||||
**Reference**: `src/mastra/index.ts`
|
||||
**Related**:
|
||||
- concepts/workflows.md
|
||||
- concepts/agents-tools.md
|
||||
- lookup/mastra-config.md
|
||||
@@ -0,0 +1,41 @@
|
||||
<!-- Context: development/evaluations | Priority: critical | Version: 1.0 | Updated: 2026-02-15 -->
|
||||
|
||||
# Concept: Mastra Evaluations
|
||||
|
||||
**Purpose**: Quality assurance and scoring for LLM outputs.
|
||||
|
||||
**Last Updated**: 2026-01-09
|
||||
|
||||
---
|
||||
|
||||
## Core Idea
|
||||
Evaluations in Mastra use Scorers to assess the quality, accuracy, and safety of LLM-generated content. They provide a quantitative way to measure performance and detect issues like hallucinations or factual errors.
|
||||
|
||||
## Key Points
|
||||
- **Scorers**: Specialized functions that take LLM output (and optionally ground truth) and return a score (0-1).
|
||||
- **Integration**: Registered in the Mastra instance and can be triggered automatically during workflow execution.
|
||||
- **Metrics**: Common metrics include hallucination detection, fact validation, and relevance scoring.
|
||||
- **Audit Trail**: Scorer results are stored in the `mastra_scorers` table for long-term analysis and reporting.
|
||||
|
||||
## Quick Example
|
||||
```typescript
|
||||
// Scorer definition
|
||||
export const hallucinationDetector = new Scorer({
|
||||
id: 'hallucination-detector',
|
||||
description: 'Detects hallucinations in LLM output',
|
||||
execute: async ({ output, context }) => {
|
||||
// Logic to detect hallucinations
|
||||
return { score: 0.95, rationale: 'No hallucinations found' };
|
||||
},
|
||||
});
|
||||
|
||||
// Registration
|
||||
export const mastra = new Mastra({
|
||||
scorers: { hallucinationDetector },
|
||||
});
|
||||
```
|
||||
|
||||
**Reference**: `src/mastra/scorers/`, `src/mastra/evaluation/`
|
||||
**Related**:
|
||||
- concepts/core.md
|
||||
- concepts/workflows.md
|
||||
@@ -0,0 +1,38 @@
|
||||
<!-- Context: development/storage | Priority: critical | Version: 1.0 | Updated: 2026-02-15 -->
|
||||
|
||||
# Concept: Mastra Data Storage
|
||||
|
||||
**Purpose**: Persistence layer for cases, documents, assessments, and observability.
|
||||
|
||||
**Last Updated**: 2026-01-09
|
||||
|
||||
---
|
||||
|
||||
## Core Idea
|
||||
Mastra uses a dual-storage approach: a local SQLite database (via Drizzle ORM) for business entities and a built-in `LibSQLStore` for Mastra-specific execution data (traces, spans).
|
||||
|
||||
## Key Points
|
||||
- **Business Entities**: Managed in `src/db/schema.ts`. Includes `cases`, `documents`, `assessments`, and `outputs`.
|
||||
- **Mastra Store**: `LibSQLStore` handles `mastra_traces`, `mastra_ai_spans`, and `mastra_scorers`.
|
||||
- **V3 Extensions**: Specific tables for `timeline_events`, `evidence_gaps`, `sub_claims`, and `vulnerability_flags`.
|
||||
- **Observability**: `prompt_execution_traces` provides detailed cost and token tracking per AI call.
|
||||
- **File Storage**: Large blobs (PDFs, JSON outputs) are stored in `./tmp/` with paths referenced in the DB.
|
||||
|
||||
## Quick Example
|
||||
```typescript
|
||||
// Business Schema (Drizzle)
|
||||
export const cases = sqliteTable('cases', {
|
||||
id: text('id').primaryKey(),
|
||||
status: text('status').default('new'),
|
||||
});
|
||||
|
||||
// Mastra Store Config
|
||||
storage: new LibSQLStore({
|
||||
url: process.env.MASTRA_DB_PATH || 'file:./mastra.db',
|
||||
}),
|
||||
```
|
||||
|
||||
**Reference**: `src/db/schema.ts`, `src/mastra/index.ts`
|
||||
**Related**:
|
||||
- concepts/core.md
|
||||
- lookup/mastra-config.md
|
||||
@@ -0,0 +1,35 @@
|
||||
<!-- Context: development/workflows | Priority: critical | Version: 1.0 | Updated: 2026-02-15 -->
|
||||
|
||||
# Concept: Mastra Workflows
|
||||
|
||||
**Purpose**: Linear and parallel execution chains for complex AI tasks.
|
||||
|
||||
**Last Updated**: 2026-01-09
|
||||
|
||||
---
|
||||
|
||||
## Core Idea
|
||||
Workflows in Mastra are directed graphs of steps that process data sequentially or in parallel. They provide a structured way to handle multi-stage LLM operations with built-in state management and human-in-the-loop (HITL) support.
|
||||
|
||||
## Key Points
|
||||
- **Step Definition**: Created with `createStep`, requiring `inputSchema`, `outputSchema`, and an `execute` function.
|
||||
- **Chaining**: Steps are linked using `.then()` for sequential and `.parallel()` for concurrent execution.
|
||||
- **HITL Support**: Steps can `suspend` execution to wait for human input and `resume` when data is provided.
|
||||
- **State Access**: Each step has access to the global workflow `state` and the `inputData` from the previous step.
|
||||
|
||||
## Quick Example
|
||||
```typescript
|
||||
const workflow = createWorkflow({ id: 'my-workflow', inputSchema, outputSchema })
|
||||
.then(step1)
|
||||
.parallel([step2a, step2b])
|
||||
.then(mergeStep)
|
||||
.commit();
|
||||
|
||||
const { runId, start } = workflow.createRun();
|
||||
const result = await start({ inputData: { ... } });
|
||||
```
|
||||
|
||||
**Reference**: `src/mastra/workflows/`
|
||||
**Related**:
|
||||
- concepts/core.md
|
||||
- examples/workflow-example.md
|
||||
Reference in New Issue
Block a user