@mastra/mcp-docs-server 1.1.16 → 1.1.17-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/evals/built-in-scorers.md +1 -0
- package/.docs/docs/memory/observational-memory.md +7 -5
- package/.docs/docs/observability/tracing/bridges/otel.md +3 -3
- package/.docs/docs/observability/tracing/exporters/sentry.md +1 -1
- package/.docs/docs/server/auth/okta.md +225 -0
- package/.docs/docs/server/auth.md +1 -0
- package/.docs/docs/workspace/lsp.md +116 -0
- package/.docs/docs/workspace/overview.md +15 -1
- package/.docs/guides/agent-frameworks/ai-sdk.md +3 -3
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/llmgateway.md +269 -0
- package/.docs/models/providers/poe.md +3 -1
- package/.docs/models/providers/siliconflow.md +2 -1
- package/.docs/models/providers/zai.md +14 -13
- package/.docs/models/providers/zhipuai-coding-plan.md +3 -1
- package/.docs/models/providers/zhipuai.md +13 -12
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +2 -0
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/auth/okta.md +162 -0
- package/.docs/reference/client-js/agents.md +2 -2
- package/.docs/reference/client-js/mastra-client.md +1 -1
- package/.docs/reference/client-js/memory.md +1 -1
- package/.docs/reference/deployer/cloudflare.md +31 -1
- package/.docs/reference/evals/noise-sensitivity.md +3 -3
- package/.docs/reference/evals/run-evals.md +78 -3
- package/.docs/reference/evals/scorer-utils.md +184 -0
- package/.docs/reference/evals/trajectory-accuracy.md +613 -0
- package/.docs/reference/harness/harness-class.md +2 -0
- package/.docs/reference/index.md +3 -2
- package/.docs/reference/logging/pino-logger.md +58 -0
- package/.docs/reference/memory/observational-memory.md +2 -2
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/processor-interface.md +3 -3
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/skill-search-processor.md +93 -0
- package/.docs/reference/processors/tool-call-filter.md +2 -2
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/mcp-client.md +1 -1
- package/CHANGELOG.md +42 -0
- package/package.json +4 -4
- package/.docs/reference/core/getStoredAgentById.md +0 -87
- package/.docs/reference/core/listStoredAgents.md +0 -91
|
@@ -30,6 +30,64 @@ export const mastra = new Mastra({
|
|
|
30
30
|
|
|
31
31
|
**formatters** (`pino.LoggerOptions['formatters']`): Custom Pino formatters for log serialization.
|
|
32
32
|
|
|
33
|
+
**redact** (`pino.LoggerOptions['redact']`): Paths or options for redacting sensitive fields from log output (Pino \`redact\`).
|
|
34
|
+
|
|
35
|
+
**prettyPrint** (`boolean`): When false, disables \`pino-pretty\` and writes raw JSON lines (useful for log aggregators). (Default: `true`)
|
|
36
|
+
|
|
37
|
+
**mixin** (`pino.MixinFn`): Pino mixin function merged into every log object (for example request-scoped \`traceId\` or other shared metadata).
|
|
38
|
+
|
|
39
|
+
**customLevels** (`Record<string, number>`): Custom log levels and numeric values, forwarded to Pino. Standard severity is still logged via \`debug\`, \`info\`, \`warn\`, and \`error\`; extra levels follow Pino’s custom-level behavior.
|
|
40
|
+
|
|
41
|
+
## Log enrichment with `mixin`
|
|
42
|
+
|
|
43
|
+
Use `mixin` when you want the same structured fields on every line (for correlation with the rest of your services):
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Mastra } from '@mastra/core'
|
|
47
|
+
import { PinoLogger } from '@mastra/loggers'
|
|
48
|
+
|
|
49
|
+
function getTraceContext() {
|
|
50
|
+
return { traceId: 'abc-123' }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const mastra = new Mastra({
|
|
54
|
+
logger: new PinoLogger({
|
|
55
|
+
name: 'Mastra',
|
|
56
|
+
level: 'info',
|
|
57
|
+
mixin() {
|
|
58
|
+
return getTraceContext()
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Custom levels
|
|
65
|
+
|
|
66
|
+
`customLevels` is passed through to Pino. `PinoLogger` only exposes `debug`, `info`, `warn`, and `error`; for any extra level name (for example `audit`), subclass and forward to the underlying Pino instance:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { Mastra } from '@mastra/core'
|
|
70
|
+
import { PinoLogger } from '@mastra/loggers'
|
|
71
|
+
|
|
72
|
+
type AuditLevel = 'audit'
|
|
73
|
+
|
|
74
|
+
class MastraPinoWithAudit extends PinoLogger<AuditLevel> {
|
|
75
|
+
audit(message: string, meta: Record<string, unknown> = {}) {
|
|
76
|
+
this.logger.audit(meta, message)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const logger = new MastraPinoWithAudit({
|
|
81
|
+
name: 'Mastra',
|
|
82
|
+
level: 'info',
|
|
83
|
+
customLevels: { audit: 35 },
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
export const mastra = new Mastra({ logger })
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Numeric values follow Pino’s ordering (built-in levels use 10–60). A level of `35` sits between `info` (30) and `warn` (40), so with `level: 'info'` both `info` and `audit` lines are emitted.
|
|
90
|
+
|
|
33
91
|
## File transport (structured logs)
|
|
34
92
|
|
|
35
93
|
Writes structured logs to a file using the `FileTransport`. The logger accepts a plain message as the first argument and structured metadata as the second argument. These are internally converted to a `BaseLogMessage` and persisted to the configured file path.
|
|
@@ -632,8 +632,8 @@ import { ModelByInputTokens } from '@mastra/memory'
|
|
|
632
632
|
const selector = new ModelByInputTokens({
|
|
633
633
|
upTo: {
|
|
634
634
|
10_000: 'google/gemini-2.5-flash', // Fast for small inputs
|
|
635
|
-
40_000: 'openai/gpt-
|
|
636
|
-
1_000_000: 'openai/gpt-4
|
|
635
|
+
40_000: 'openai/gpt-5.4-mini', // Stronger for medium inputs
|
|
636
|
+
1_000_000: 'openai/gpt-5.4', // Most capable for large inputs
|
|
637
637
|
},
|
|
638
638
|
})
|
|
639
639
|
```
|
|
@@ -268,7 +268,7 @@ Model Generation attributes.
|
|
|
268
268
|
|
|
269
269
|
```typescript
|
|
270
270
|
interface ModelGenerationAttributes {
|
|
271
|
-
/** Model name (e.g., 'gpt-4', 'claude-
|
|
271
|
+
/** Model name (e.g., 'gpt-5.4', 'claude-opus-4-6') */
|
|
272
272
|
model?: string
|
|
273
273
|
|
|
274
274
|
/** Model provider (e.g., 'openai', 'anthropic') */
|
|
@@ -45,7 +45,7 @@ const storage = new PostgresStorage({
|
|
|
45
45
|
export const agent = new Agent({
|
|
46
46
|
name: 'memory-agent',
|
|
47
47
|
instructions: 'You are a helpful assistant with conversation memory',
|
|
48
|
-
model: 'openai
|
|
48
|
+
model: 'openai/gpt-5.4',
|
|
49
49
|
inputProcessors: [
|
|
50
50
|
new MessageHistory({
|
|
51
51
|
storage,
|
|
@@ -202,9 +202,9 @@ The method can return any combination of these properties:
|
|
|
202
202
|
When multiple processors implement `processInputStep`, they run in order and changes chain through:
|
|
203
203
|
|
|
204
204
|
```text
|
|
205
|
-
Processor 1: receives { model: 'gpt-
|
|
206
|
-
Processor 2: receives { model: 'gpt-
|
|
207
|
-
Final: model = 'gpt-
|
|
205
|
+
Processor 1: receives { model: 'gpt-5.4' } → returns { model: 'gpt-5.4-mini' }
|
|
206
|
+
Processor 2: receives { model: 'gpt-5.4-mini' } → returns { toolChoice: 'none' }
|
|
207
|
+
Final: model = 'gpt-5.4-mini', toolChoice = 'none'
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
#### System message isolation
|
|
@@ -82,7 +82,7 @@ const semanticRecall = new SemanticRecall({
|
|
|
82
82
|
export const agent = new Agent({
|
|
83
83
|
name: 'semantic-memory-agent',
|
|
84
84
|
instructions: 'You are a helpful assistant with semantic memory recall',
|
|
85
|
-
model: 'openai
|
|
85
|
+
model: 'openai/gpt-5.4',
|
|
86
86
|
inputProcessors: [semanticRecall, new MessageHistory({ storage, lastMessages: 50 })],
|
|
87
87
|
outputProcessors: [semanticRecall, new MessageHistory({ storage })],
|
|
88
88
|
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# SkillSearchProcessor
|
|
2
|
+
|
|
3
|
+
The `SkillSearchProcessor` is an **input processor** that enables on-demand skill discovery and loading. Instead of injecting all skill metadata into the system prompt upfront (like `SkillsProcessor`), it gives the agent two meta-tools (`search_skills` and `load_skill`) that let it find and load skills on demand. This reduces context token usage when workspaces have many skills.
|
|
4
|
+
|
|
5
|
+
## Usage example
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { SkillSearchProcessor } from '@mastra/core/processors'
|
|
9
|
+
|
|
10
|
+
const skillSearch = new SkillSearchProcessor({
|
|
11
|
+
workspace,
|
|
12
|
+
search: {
|
|
13
|
+
topK: 5,
|
|
14
|
+
minScore: 0.1,
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Constructor parameters
|
|
20
|
+
|
|
21
|
+
**options** (`SkillSearchProcessorOptions`): Configuration options for the skill search processor
|
|
22
|
+
|
|
23
|
+
**options.workspace** (`Workspace`): Workspace instance containing skills. Skills are accessed via workspace.skills.
|
|
24
|
+
|
|
25
|
+
**options.search** (`{ topK?: number; minScore?: number }`): Configuration for the search behavior.
|
|
26
|
+
|
|
27
|
+
**options.search.topK** (`number`): Maximum number of skills to return in search results.
|
|
28
|
+
|
|
29
|
+
**options.search.minScore** (`number`): Minimum relevance score for including a skill in search results.
|
|
30
|
+
|
|
31
|
+
**options.ttl** (`number`): Time-to-live for thread state in milliseconds. After this duration of inactivity, thread state will be cleaned up. Set to 0 to disable cleanup.
|
|
32
|
+
|
|
33
|
+
## Returns
|
|
34
|
+
|
|
35
|
+
**id** (`string`): Processor identifier set to 'skill-search'
|
|
36
|
+
|
|
37
|
+
**name** (`string`): Processor display name set to 'Skill Search Processor'
|
|
38
|
+
|
|
39
|
+
**processInputStep** (`(args: ProcessInputStepArgs) => Promise<ProcessInputStepResult>`): Processes each step to inject search/load meta-tools and any previously loaded skill instructions as system messages.
|
|
40
|
+
|
|
41
|
+
## Extended usage example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Agent } from '@mastra/core/agent'
|
|
45
|
+
import { SkillSearchProcessor } from '@mastra/core/processors'
|
|
46
|
+
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
|
|
47
|
+
|
|
48
|
+
const workspace = new Workspace({
|
|
49
|
+
filesystem: new LocalFilesystem({ basePath: './project' }),
|
|
50
|
+
skills: ['/skills'],
|
|
51
|
+
bm25: true,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const skillSearch = new SkillSearchProcessor({
|
|
55
|
+
workspace,
|
|
56
|
+
search: {
|
|
57
|
+
topK: 5,
|
|
58
|
+
minScore: 0.1,
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const agent = new Agent({
|
|
63
|
+
name: 'skill-agent',
|
|
64
|
+
instructions:
|
|
65
|
+
'You are a helpful assistant. Use search_skills to find relevant skills, then load_skill to load their instructions.',
|
|
66
|
+
model: 'openai/gpt-4o',
|
|
67
|
+
workspace,
|
|
68
|
+
inputProcessors: [skillSearch],
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The agent workflow is:
|
|
73
|
+
|
|
74
|
+
1. Agent receives a user message
|
|
75
|
+
2. Agent calls `search_skills` with keywords (e.g., "api design")
|
|
76
|
+
3. Agent reviews results and calls `load_skill` with the skill name
|
|
77
|
+
4. The skill's instructions appear as system messages on the next turn
|
|
78
|
+
5. Agent follows the loaded skill's instructions
|
|
79
|
+
|
|
80
|
+
## Compared to SkillsProcessor
|
|
81
|
+
|
|
82
|
+
| | SkillsProcessor | SkillSearchProcessor |
|
|
83
|
+
| -------------- | -------------------------- | ---------------------------------- |
|
|
84
|
+
| Scaling | Injects all skills upfront | On-demand discovery |
|
|
85
|
+
| Context usage | Grows with skill count | Constant (only loaded skills) |
|
|
86
|
+
| Agent workflow | Skills always visible | Agent searches and loads as needed |
|
|
87
|
+
| Best for | Few skills (< 10) | Many skills (10+) |
|
|
88
|
+
|
|
89
|
+
## Related
|
|
90
|
+
|
|
91
|
+
- [ToolSearchProcessor](https://mastra.ai/reference/processors/tool-search-processor)
|
|
92
|
+
- [Processors](https://mastra.ai/docs/agents/processors)
|
|
93
|
+
- [Workspace Skills](https://mastra.ai/docs/workspace/overview)
|
|
@@ -39,7 +39,7 @@ import { ToolCallFilter } from '@mastra/core/processors'
|
|
|
39
39
|
export const agent = new Agent({
|
|
40
40
|
name: 'filtered-agent',
|
|
41
41
|
instructions: 'You are a helpful assistant',
|
|
42
|
-
model: 'openai
|
|
42
|
+
model: 'openai/gpt-5.4',
|
|
43
43
|
tools: {
|
|
44
44
|
searchDatabase,
|
|
45
45
|
sendEmail,
|
|
@@ -64,7 +64,7 @@ import { ToolCallFilter } from '@mastra/core/processors'
|
|
|
64
64
|
export const agent = new Agent({
|
|
65
65
|
name: 'no-tools-context-agent',
|
|
66
66
|
instructions: 'You are a helpful assistant',
|
|
67
|
-
model: 'openai
|
|
67
|
+
model: 'openai/gpt-5.4',
|
|
68
68
|
tools: {
|
|
69
69
|
searchDatabase,
|
|
70
70
|
sendEmail,
|
|
@@ -67,7 +67,7 @@ const storage = new PostgresStorage({
|
|
|
67
67
|
export const agent = new Agent({
|
|
68
68
|
name: 'personalized-agent',
|
|
69
69
|
instructions: 'You are a helpful assistant that remembers user preferences',
|
|
70
|
-
model: 'openai
|
|
70
|
+
model: 'openai/gpt-5.4',
|
|
71
71
|
inputProcessors: [
|
|
72
72
|
new WorkingMemory({
|
|
73
73
|
storage,
|
|
@@ -327,7 +327,7 @@ await agent.stream('message for agent', {
|
|
|
327
327
|
|
|
328
328
|
## OpenAI WebSocket transport
|
|
329
329
|
|
|
330
|
-
Opt into OpenAI Responses WebSocket streaming via `providerOptions.openai.transport`. This only applies to streaming calls and is currently supported for direct OpenAI models (for example, `openai/gpt-
|
|
330
|
+
Opt into OpenAI Responses WebSocket streaming via `providerOptions.openai.transport`. This only applies to streaming calls and is currently supported for direct OpenAI models (for example, `openai/gpt-5.4`). If WebSocket streaming is unavailable, Mastra falls back to HTTP streaming. By default, Mastra closes the WebSocket when the stream finishes.
|
|
331
331
|
|
|
332
332
|
```ts
|
|
333
333
|
const stream = await agent.stream('Hello', {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.17-alpha.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4)]:
|
|
8
|
+
- @mastra/core@1.18.0-alpha.2
|
|
9
|
+
|
|
10
|
+
## 1.1.17-alpha.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`dc9fc19`](https://github.com/mastra-ai/mastra/commit/dc9fc19da4437f6b508cc355f346a8856746a76b), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0)]:
|
|
15
|
+
- @mastra/core@1.18.0-alpha.1
|
|
16
|
+
|
|
17
|
+
## 1.1.17-alpha.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778)]:
|
|
22
|
+
- @mastra/core@1.18.0-alpha.0
|
|
23
|
+
|
|
24
|
+
## 1.1.17-alpha.4
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`86e3263`](https://github.com/mastra-ai/mastra/commit/86e326363edd12be5a5b25ccce4a39f66f7c9f50), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778)]:
|
|
29
|
+
- @mastra/core@1.17.0-alpha.2
|
|
30
|
+
|
|
31
|
+
## 1.1.17-alpha.2
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`7302e5c`](https://github.com/mastra-ai/mastra/commit/7302e5ce0f52d769d3d63fb0faa8a7d4089cda6d)]:
|
|
36
|
+
- @mastra/core@1.16.1-alpha.1
|
|
37
|
+
|
|
38
|
+
## 1.1.17-alpha.0
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067)]:
|
|
43
|
+
- @mastra/core@1.16.1-alpha.0
|
|
44
|
+
|
|
3
45
|
## 1.1.16
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17-alpha.11",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.
|
|
32
|
+
"@mastra/core": "1.18.0-alpha.2",
|
|
33
33
|
"@mastra/mcp": "^1.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.18",
|
|
49
49
|
"@internal/lint": "0.0.74",
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
50
|
+
"@mastra/core": "1.18.0-alpha.2",
|
|
51
|
+
"@internal/types-builder": "0.0.49"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Mastra.getStoredAgentById()
|
|
2
|
-
|
|
3
|
-
The `.getStoredAgentById()` method retrieves an agent configuration from storage by its ID and creates an executable `Agent` instance. Stored agents allow you to persist agent configurations in a database and dynamically load them at runtime.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// Get an Agent instance from storage
|
|
9
|
-
const agent = await mastra.getStoredAgentById('my-stored-agent')
|
|
10
|
-
|
|
11
|
-
if (agent) {
|
|
12
|
-
const response = await agent.generate('Hello')
|
|
13
|
-
console.log(response.text)
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
// Get the raw storage data instead of an Agent instance
|
|
19
|
-
const storedConfig = await mastra.getStoredAgentById('my-stored-agent', { raw: true })
|
|
20
|
-
|
|
21
|
-
if (storedConfig) {
|
|
22
|
-
console.log(storedConfig.instructions)
|
|
23
|
-
console.log(storedConfig.createdAt)
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Parameters
|
|
28
|
-
|
|
29
|
-
**id** (`string`): The unique identifier of the stored agent to retrieve.
|
|
30
|
-
|
|
31
|
-
**options** (`{ raw?: boolean }`): Optional configuration object.
|
|
32
|
-
|
|
33
|
-
**options.raw** (`boolean`): When \`true\`, returns the raw \`StorageAgentType\` object from storage instead of creating an \`Agent\` instance. Useful for inspecting stored configuration or metadata.
|
|
34
|
-
|
|
35
|
-
## Returns
|
|
36
|
-
|
|
37
|
-
**result** (`Agent | StorageAgentType | null`): Returns an \`Agent\` instance by default, or \`StorageAgentType\` when \`raw: true\`. Returns \`null\` if no agent with the given ID exists.
|
|
38
|
-
|
|
39
|
-
## Primitive resolution
|
|
40
|
-
|
|
41
|
-
When creating an `Agent` instance from stored configuration, the method resolves references to registered primitives:
|
|
42
|
-
|
|
43
|
-
- **Tools**: Resolved from `tools` registered in Mastra config
|
|
44
|
-
- **Workflows**: Resolved from `workflows` registered in Mastra config
|
|
45
|
-
- **Subagents**: Resolved from `agents` registered in Mastra config
|
|
46
|
-
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
47
|
-
- **Scorers**: Resolved from `scorers` registered in Mastra config, including sampling configuration
|
|
48
|
-
|
|
49
|
-
If a referenced primitive isn't found in the registry, a warning is logged but the agent is still created.
|
|
50
|
-
|
|
51
|
-
## `StorageAgentType`
|
|
52
|
-
|
|
53
|
-
When using `raw: true`, the returned object has the following structure:
|
|
54
|
-
|
|
55
|
-
**id** (`string`): Unique identifier for the agent.
|
|
56
|
-
|
|
57
|
-
**name** (`string`): Display name of the agent.
|
|
58
|
-
|
|
59
|
-
**description** (`string`): Optional description of the agent.
|
|
60
|
-
|
|
61
|
-
**instructions** (`string`): System instructions for the agent.
|
|
62
|
-
|
|
63
|
-
**model** (`Record<string, unknown>`): Model configuration with provider and name.
|
|
64
|
-
|
|
65
|
-
**tools** (`Record<string, unknown>`): Tool references to resolve from registry.
|
|
66
|
-
|
|
67
|
-
**workflows** (`Record<string, unknown>`): Workflow references to resolve from registry.
|
|
68
|
-
|
|
69
|
-
**agents** (`Record<string, unknown>`): Subagent references to resolve from registry.
|
|
70
|
-
|
|
71
|
-
**memory** (`Record<string, unknown>`): Memory reference to resolve from registry.
|
|
72
|
-
|
|
73
|
-
**scorers** (`Record<string, unknown>`): Scorer references with optional sampling config.
|
|
74
|
-
|
|
75
|
-
**defaultOptions** (`Record<string, unknown>`): Default options passed to agent execution.
|
|
76
|
-
|
|
77
|
-
**metadata** (`Record<string, unknown>`): Custom metadata stored with the agent.
|
|
78
|
-
|
|
79
|
-
**createdAt** (`Date`): Timestamp when the agent was created.
|
|
80
|
-
|
|
81
|
-
**updatedAt** (`Date`): Timestamp when the agent was last updated.
|
|
82
|
-
|
|
83
|
-
## Related
|
|
84
|
-
|
|
85
|
-
- [Mastra.listStoredAgents()](https://mastra.ai/reference/core/listStoredAgents)
|
|
86
|
-
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
87
|
-
- [Agents overview](https://mastra.ai/docs/agents/overview)
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Mastra.listStoredAgents()
|
|
2
|
-
|
|
3
|
-
The `.listStoredAgents()` method retrieves a paginated list of agent configurations from storage. By default, it returns executable `Agent` instances, but can also return raw storage data.
|
|
4
|
-
|
|
5
|
-
## Usage example
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// Get Agent instances from storage
|
|
9
|
-
const { agents, total, hasMore } = await mastra.listStoredAgents()
|
|
10
|
-
|
|
11
|
-
for (const agent of agents) {
|
|
12
|
-
console.log(agent.id, agent.name)
|
|
13
|
-
// Each agent is ready to use
|
|
14
|
-
// const response = await agent.generate("Hello");
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
// Get paginated results with raw storage data
|
|
20
|
-
const result = await mastra.listStoredAgents({
|
|
21
|
-
page: 0,
|
|
22
|
-
perPage: 10,
|
|
23
|
-
raw: true,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
console.log(`Showing ${result.agents.length} of ${result.total} agents`)
|
|
27
|
-
console.log(`Has more: ${result.hasMore}`)
|
|
28
|
-
|
|
29
|
-
for (const config of result.agents) {
|
|
30
|
-
console.log(config.id, config.name, config.createdAt)
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Parameters
|
|
35
|
-
|
|
36
|
-
**args** (`object`): Optional configuration object for pagination and output format.
|
|
37
|
-
|
|
38
|
-
**args.page** (`number`): Zero-indexed page number for pagination.
|
|
39
|
-
|
|
40
|
-
**args.perPage** (`number | false`): Number of items per page. Set to \`false\` to fetch all records without pagination.
|
|
41
|
-
|
|
42
|
-
**args.raw** (`boolean`): When \`true\`, returns raw \`StorageAgentType\` objects instead of \`Agent\` instances.
|
|
43
|
-
|
|
44
|
-
## Returns
|
|
45
|
-
|
|
46
|
-
**agents** (`Agent[] | StorageAgentType[]`): Array of \`Agent\` instances by default, or \`StorageAgentType\` objects when \`raw: true\`.
|
|
47
|
-
|
|
48
|
-
**total** (`number`): Total number of stored agents across all pages.
|
|
49
|
-
|
|
50
|
-
**page** (`number`): Current page number (zero-indexed).
|
|
51
|
-
|
|
52
|
-
**perPage** (`number | false`): Number of items per page, or \`false\` if fetching all.
|
|
53
|
-
|
|
54
|
-
**hasMore** (`boolean`): Whether there are more pages available.
|
|
55
|
-
|
|
56
|
-
## Primitive resolution
|
|
57
|
-
|
|
58
|
-
When creating `Agent` instances (default behavior), each stored agent's configuration is resolved against registered primitives:
|
|
59
|
-
|
|
60
|
-
- **Tools**: Resolved from `tools` registered in Mastra config
|
|
61
|
-
- **Workflows**: Resolved from `workflows` registered in Mastra config
|
|
62
|
-
- **Subagents**: Resolved from `agents` registered in Mastra config
|
|
63
|
-
- **Memory**: Resolved from `memory` registered in Mastra config
|
|
64
|
-
- **Scorers**: Resolved from `scorers` registered in Mastra config
|
|
65
|
-
|
|
66
|
-
If a referenced primitive isn't found, a warning is logged but the agent is still created.
|
|
67
|
-
|
|
68
|
-
## Example: Iterating through all stored agents
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
async function getAllStoredAgents(mastra: Mastra) {
|
|
72
|
-
const allAgents: Agent[] = []
|
|
73
|
-
let page = 0
|
|
74
|
-
let hasMore = true
|
|
75
|
-
|
|
76
|
-
while (hasMore) {
|
|
77
|
-
const result = await mastra.listStoredAgents({ page, perPage: 50 })
|
|
78
|
-
allAgents.push(...result.agents)
|
|
79
|
-
hasMore = result.hasMore
|
|
80
|
-
page++
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return allAgents
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Related
|
|
88
|
-
|
|
89
|
-
- [Mastra.getStoredAgentById()](https://mastra.ai/reference/core/getStoredAgentById)
|
|
90
|
-
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
91
|
-
- [Agents overview](https://mastra.ai/docs/agents/overview)
|