@mastra/mcp-docs-server 1.2.3-alpha.7 → 1.2.3
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/agent-builder/memory.md +4 -2
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agents/agent-approval.md +38 -0
- package/.docs/docs/agents/file-based-agents.md +286 -0
- package/.docs/docs/agents/heartbeats.md +211 -0
- package/.docs/docs/getting-started/project-structure.md +18 -14
- package/.docs/docs/memory/observational-memory.md +114 -0
- package/.docs/docs/memory/working-memory.md +2 -0
- package/.docs/docs/observability/integrations/exporters/otel.md +23 -2
- package/.docs/models/gateways/netlify.md +3 -1
- package/.docs/models/gateways/openrouter.md +1 -3
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +3 -2
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/llmgateway.md +5 -7
- package/.docs/models/providers/novita-ai.md +1 -1
- package/.docs/models/providers/opencode-go.md +1 -1
- package/.docs/models/providers/sakana.md +73 -0
- package/.docs/models/providers/stepfun.md +1 -1
- package/.docs/models/providers/subconscious.md +71 -0
- package/.docs/models/providers/synthetic.md +8 -6
- package/.docs/models/providers/xiaomi.md +2 -2
- package/.docs/models/providers/zeldoc.md +1 -1
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/agent-controller/agent-controller-class.md +9 -9
- package/.docs/reference/agents/listSuspendedRuns.md +91 -0
- package/.docs/reference/client-js/agents.md +21 -0
- package/.docs/reference/coding-agent/build-base-prompt.md +75 -0
- package/.docs/reference/coding-agent/create-coding-agent.md +97 -0
- package/.docs/reference/index.md +3 -0
- package/.docs/reference/memory/observational-memory.md +90 -0
- package/CHANGELOG.md +58 -0
- package/package.json +6 -6
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Agent.listSuspendedRuns()
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.43.0`
|
|
4
|
+
|
|
5
|
+
The `.listSuspendedRuns()` method lists suspended agent runs from workflow snapshot storage: runs waiting on a tool call requiring [approval](https://mastra.ai/docs/agents/agent-approval), or on a tool that called `suspend()`. Because discovery is backed by storage rather than in-memory state, it works after a server restart and across multiple server instances.
|
|
6
|
+
|
|
7
|
+
Pass the returned `runId` to [`resumeStream()`](https://mastra.ai/docs/agents/agent-approval), `approveToolCall()`, or `declineToolCall()` to continue the run.
|
|
8
|
+
|
|
9
|
+
The filter contract mirrors the workflow run listing APIs (`listWorkflowRuns`), plus the agent-level `threadId` filter.
|
|
10
|
+
|
|
11
|
+
## Usage example
|
|
12
|
+
|
|
13
|
+
Discover the pending run for a conversation and continue it. Check `requiresApproval` to pick the right continuation — `approveToolCall()` / `declineToolCall()` for approval suspensions, `resumeStream()` with resume data for `suspend()`-based suspensions:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const { runs } = await agent.listSuspendedRuns({
|
|
17
|
+
threadId: 'thread-123',
|
|
18
|
+
resourceId: 'user-456',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const run = runs[0]
|
|
22
|
+
const toolCall = run?.toolCalls[0]
|
|
23
|
+
|
|
24
|
+
if (run && toolCall) {
|
|
25
|
+
const stream = toolCall.requiresApproval
|
|
26
|
+
? await agent.approveToolCall({ runId: run.runId, toolCallId: toolCall.toolCallId })
|
|
27
|
+
: await agent.resumeStream({ name: 'San Francisco' }, { runId: run.runId })
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Parameters
|
|
32
|
+
|
|
33
|
+
**options** (`AgentListSuspendedRunsOptions`): Filters and pagination for scoping the results. (Default: `{}`)
|
|
34
|
+
|
|
35
|
+
**options.threadId** (`string`): Only return runs that belong to this memory thread.
|
|
36
|
+
|
|
37
|
+
**options.resourceId** (`string`): Only return runs that belong to this memory resource.
|
|
38
|
+
|
|
39
|
+
**options.fromDate** (`Date`): Only return runs created at or after this date.
|
|
40
|
+
|
|
41
|
+
**options.toDate** (`Date`): Only return runs created at or before this date.
|
|
42
|
+
|
|
43
|
+
**options.perPage** (`number`): Number of items per page. Pagination is applied when both perPage and page are provided; otherwise all matching runs are returned.
|
|
44
|
+
|
|
45
|
+
**options.page** (`number`): Zero-indexed page number.
|
|
46
|
+
|
|
47
|
+
## Returns
|
|
48
|
+
|
|
49
|
+
**result** (`Promise<AgentListSuspendedRunsResult>`): A promise that resolves to the matching runs and the total count before pagination.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface AgentListSuspendedRunsResult {
|
|
53
|
+
runs: AgentRun[]
|
|
54
|
+
/** Total number of matching runs, before pagination */
|
|
55
|
+
total: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface AgentRun {
|
|
59
|
+
/** Run ID accepted by resumeStream(), approveToolCall(), and declineToolCall() */
|
|
60
|
+
runId: string
|
|
61
|
+
status: 'suspended'
|
|
62
|
+
threadId?: string
|
|
63
|
+
resourceId?: string
|
|
64
|
+
/** When the run suspended */
|
|
65
|
+
suspendedAt: Date
|
|
66
|
+
/** Suspended tool calls awaiting approval or resume data */
|
|
67
|
+
toolCalls: AgentRunToolCall[]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface AgentRunToolCall {
|
|
71
|
+
toolCallId?: string
|
|
72
|
+
toolName?: string
|
|
73
|
+
/** Arguments the model supplied (approval suspensions only) */
|
|
74
|
+
args?: unknown
|
|
75
|
+
/** True when the run is waiting on a tool-call approval */
|
|
76
|
+
requiresApproval: boolean
|
|
77
|
+
/** The tool-defined suspend payload when the tool called suspend() */
|
|
78
|
+
suspendPayload?: unknown
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Discovery scope
|
|
83
|
+
|
|
84
|
+
Results are scoped to runs started by the agent you call `listSuspendedRuns()` on: snapshots persist the owning agent's id, so runs started by other agents on the same Mastra instance are not returned. In [supervisor setups](https://mastra.ai/docs/agents/agent-approval) the supervisor sees its outer run — the one to resume — while a subagent's inner run is only visible from the subagent itself. Filter by `threadId` and `resourceId` to scope results to one conversation.
|
|
85
|
+
|
|
86
|
+
Run snapshots are only persisted while a run is waiting on input and are deleted when it finishes, so suspended runs are the only runs discoverable from storage. Suspended runs only survive restarts when the Mastra instance has a persistent [storage provider](https://mastra.ai/docs/memory/storage) configured. With the default in-memory store, snapshots are lost on restart.
|
|
87
|
+
|
|
88
|
+
## Related
|
|
89
|
+
|
|
90
|
+
- [Agent approval](https://mastra.ai/docs/agents/agent-approval)
|
|
91
|
+
- [Storage](https://mastra.ai/docs/memory/storage)
|
|
@@ -362,6 +362,27 @@ response.processDataStream({
|
|
|
362
362
|
})
|
|
363
363
|
```
|
|
364
364
|
|
|
365
|
+
### `listSuspendedRuns()`
|
|
366
|
+
|
|
367
|
+
List suspended runs for the agent from storage — runs waiting on a tool-call approval or on a tool that suspended. Discovery is backed by storage, so it works after a server restart and across server instances. Pass the returned `runId` to `approveToolCall()`, `declineToolCall()`, or `resumeStream()`.
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
const { runs, total } = await agent.listSuspendedRuns({
|
|
371
|
+
threadId: 'thread-456',
|
|
372
|
+
resourceId: 'user-123',
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
if (runs[0]) {
|
|
376
|
+
console.log(runs[0].toolCalls) // [{ toolCallId, toolName, args, requiresApproval }]
|
|
377
|
+
await agent.approveToolCall({
|
|
378
|
+
runId: runs[0].runId,
|
|
379
|
+
toolCallId: runs[0].toolCalls[0].toolCallId,
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Accepts optional filters (`threadId`, `resourceId`, `fromDate`, `toDate`) and pagination (`perPage`, `page`). Returns `{ runs, total }`, where `total` is the number of matching runs before pagination. See [`Agent.listSuspendedRuns()`](https://mastra.ai/reference/agents/listSuspendedRuns) for details on the returned run shape.
|
|
385
|
+
|
|
365
386
|
### `approveToolCall()`
|
|
366
387
|
|
|
367
388
|
Approve a pending tool call and return a continuation stream. Use this when you are rendering the resumed chunks from the approval response.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# buildBasePrompt()
|
|
2
|
+
|
|
3
|
+
`buildBasePrompt()` builds the shared base system prompt for a coding agent — the behavioral instructions that make the agent a good coding assistant. It takes a `PromptContext` describing the current environment (project, platform, git branch, mode, model) and returns the prompt as a string.
|
|
4
|
+
|
|
5
|
+
Product-specific strings are parameterized through `productName`, `coAuthorName`, and `coAuthorEmail`, so you can rebrand the prompt and commit trailer without forking it. They default to `"Mastra Code"` / `"noreply@mastra.ai"`, so existing callers keep identical output.
|
|
6
|
+
|
|
7
|
+
Use this with [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent) when you build dynamic instructions for the agent.
|
|
8
|
+
|
|
9
|
+
## Usage example
|
|
10
|
+
|
|
11
|
+
Build the base prompt from a `PromptContext`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { buildBasePrompt } from '@mastra/core/coding-agent'
|
|
15
|
+
|
|
16
|
+
const prompt = buildBasePrompt({
|
|
17
|
+
projectPath: process.cwd(),
|
|
18
|
+
projectName: 'my-app',
|
|
19
|
+
gitBranch: 'main',
|
|
20
|
+
platform: process.platform,
|
|
21
|
+
date: new Date().toDateString(),
|
|
22
|
+
mode: 'build',
|
|
23
|
+
modelId: 'openai/gpt-5',
|
|
24
|
+
toolGuidance: '',
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To rebrand the prompt, pass the product and co-author fields:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const prompt = buildBasePrompt({
|
|
32
|
+
// ...environment fields
|
|
33
|
+
productName: 'Acme Coder',
|
|
34
|
+
coAuthorName: 'Acme Bot',
|
|
35
|
+
coAuthorEmail: 'bot@acme.dev',
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Parameters
|
|
40
|
+
|
|
41
|
+
`buildBasePrompt()` takes a single `PromptContext` object.
|
|
42
|
+
|
|
43
|
+
**projectPath** (`string`): Absolute path to the project root.
|
|
44
|
+
|
|
45
|
+
**projectName** (`string`): Display name of the project.
|
|
46
|
+
|
|
47
|
+
**gitBranch** (`string`): Current git branch, if the project is a git repository.
|
|
48
|
+
|
|
49
|
+
**platform** (`string`): Operating system platform (for example, the value of process.platform).
|
|
50
|
+
|
|
51
|
+
**commonBinaries** (`{ name: string; path: string | null }[]`): Common binaries detected on the system, each with a name and resolved path (or null when not found).
|
|
52
|
+
|
|
53
|
+
**date** (`string`): Current date string injected into the prompt.
|
|
54
|
+
|
|
55
|
+
**mode** (`string`): Active agent mode (for example, "build" or "plan").
|
|
56
|
+
|
|
57
|
+
**modelId** (`string`): Identifier of the active model, included in the commit Co-Authored-By line when provided.
|
|
58
|
+
|
|
59
|
+
**activePlan** (`{ title: string; plan: string; approvedAt: string } | null`): The currently approved plan, if any.
|
|
60
|
+
|
|
61
|
+
**toolGuidance** (`string`): Tool-usage guidance section appended to the prompt.
|
|
62
|
+
|
|
63
|
+
**productName** (`string`): Display name used in the prompt header. (Default: `Mastra Code`)
|
|
64
|
+
|
|
65
|
+
**coAuthorName** (`string`): Name used in the commit Co-Authored-By line. (Default: `Mastra Code`)
|
|
66
|
+
|
|
67
|
+
**coAuthorEmail** (`string`): Email used in the commit Co-Authored-By line. (Default: `noreply@mastra.ai`)
|
|
68
|
+
|
|
69
|
+
## Returns
|
|
70
|
+
|
|
71
|
+
**prompt** (`string`): The base system prompt for the coding agent.
|
|
72
|
+
|
|
73
|
+
## Related
|
|
74
|
+
|
|
75
|
+
- [`createCodingAgent()`](https://mastra.ai/reference/coding-agent/create-coding-agent)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# createCodingAgent()
|
|
2
|
+
|
|
3
|
+
`createCodingAgent()` builds a coding [`Agent`](https://mastra.ai/reference/agents/agent) with portable defaults for the pieces a coding agent always needs: a local workspace, the task-list signal provider, network-retry error processors, and the goal judge prompt. Supply only `model`, `instructions`, and `tools` to get a working agent, or override any default.
|
|
4
|
+
|
|
5
|
+
The returned value is a standard `Agent`, so it works anywhere an `Agent` does — including as the agent passed to an [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class).
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
Pass a model, instructions, and tools. The factory fills in the workspace, task signal, error processors, and goal prompt:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { createCodingAgent } from '@mastra/core/coding-agent'
|
|
13
|
+
|
|
14
|
+
const agent = createCodingAgent({
|
|
15
|
+
id: 'my-coding-agent',
|
|
16
|
+
name: 'My Coding Agent',
|
|
17
|
+
model: 'openai/gpt-5',
|
|
18
|
+
instructions: 'You are a helpful coding assistant.',
|
|
19
|
+
tools: {},
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Parameters
|
|
24
|
+
|
|
25
|
+
`createCodingAgent()` accepts every field of [`AgentConfig`](https://mastra.ai/reference/agents/agent) plus the fields below. Fields you provide always take precedence over the factory defaults.
|
|
26
|
+
|
|
27
|
+
**model** (`MastraLanguageModel | DynamicArgument<MastraLanguageModel>`): The language model the agent uses. Passed straight through to Agent.
|
|
28
|
+
|
|
29
|
+
**instructions** (`string | DynamicArgument<string>`): System instructions for the agent. Passed straight through to Agent.
|
|
30
|
+
|
|
31
|
+
**tools** (`ToolsInput | DynamicArgument<ToolsInput>`): Tools available to the agent. Passed straight through to Agent.
|
|
32
|
+
|
|
33
|
+
**workspace** (`AnyWorkspace | undefined`): The workspace backing the agent. When the key is omitted, a default local workspace is built. When set explicitly to undefined, the factory builds no default — opt out when the workspace is wired elsewhere (for example at the AgentController level).
|
|
34
|
+
|
|
35
|
+
**basePath** (`string`): Base path for the default workspace built when workspace is omitted. (Default: `process.cwd()`)
|
|
36
|
+
|
|
37
|
+
**signals** (`SignalProvider[]`): Signal providers for the agent. When omitted, defaults to a single TaskSignalProvider.
|
|
38
|
+
|
|
39
|
+
**errorProcessors** (`Processor[]`): Error processors for the agent. When omitted, defaults to the ECONNRESET/bad-request retry stack plus PrefillErrorHandler and ProviderHistoryCompat.
|
|
40
|
+
|
|
41
|
+
**goal** (`AgentGoalConfig`): Goal configuration. When provided without a prompt, the prompt defaults to DEFAULT\_GOAL\_JUDGE\_PROMPT.
|
|
42
|
+
|
|
43
|
+
## Returns
|
|
44
|
+
|
|
45
|
+
**agent** (`Agent`): A coding agent with the resolved workspace, signals, error processors, and goal applied.
|
|
46
|
+
|
|
47
|
+
## Defaults
|
|
48
|
+
|
|
49
|
+
The factory only fills a default when you do not provide the corresponding field. Caller-provided values always win.
|
|
50
|
+
|
|
51
|
+
| Field | Default when omitted |
|
|
52
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `workspace` | A [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) backed by `LocalFilesystem` and `LocalSandbox` rooted at the base path. |
|
|
54
|
+
| `signals` | A single [`TaskSignalProvider`](https://mastra.ai/reference/signals/task-signal-provider). |
|
|
55
|
+
| `errorProcessors` | ECONNRESET and bad-request retry processors plus `PrefillErrorHandler` and `ProviderHistoryCompat`. |
|
|
56
|
+
| `goal.prompt` | `DEFAULT_GOAL_JUDGE_PROMPT` (only when a `goal` is configured). |
|
|
57
|
+
|
|
58
|
+
### Workspace
|
|
59
|
+
|
|
60
|
+
When the `workspace` key is omitted, the factory builds a local workspace rooted at `basePath` (default `process.cwd()`):
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
|
|
64
|
+
|
|
65
|
+
new Workspace({
|
|
66
|
+
filesystem: new LocalFilesystem({ basePath }),
|
|
67
|
+
sandbox: new LocalSandbox({ workingDirectory: basePath }),
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To opt out — for example when the workspace is injected at the [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class) level — pass `workspace: undefined` explicitly:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const agent = createCodingAgent({
|
|
75
|
+
id: 'my-coding-agent',
|
|
76
|
+
name: 'My Coding Agent',
|
|
77
|
+
model: 'openai/gpt-5',
|
|
78
|
+
instructions: 'You are a helpful coding assistant.',
|
|
79
|
+
tools: {},
|
|
80
|
+
workspace: undefined, // opt out of the default workspace
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Error processors
|
|
85
|
+
|
|
86
|
+
The default error processors apply a retry policy for transient failures:
|
|
87
|
+
|
|
88
|
+
- Network resets (`ECONNRESET` / `socket hang up`) retry up to twice with exponential backoff (`1000ms * 2^retryCount`, capped at `30000ms`).
|
|
89
|
+
- Bad-request errors retry once after `2000ms`.
|
|
90
|
+
|
|
91
|
+
`PrefillErrorHandler` and `ProviderHistoryCompat` are also included for provider compatibility.
|
|
92
|
+
|
|
93
|
+
## Related
|
|
94
|
+
|
|
95
|
+
- [`buildBasePrompt()`](https://mastra.ai/reference/coding-agent/build-base-prompt)
|
|
96
|
+
- [`Agent`](https://mastra.ai/reference/agents/agent)
|
|
97
|
+
- [`AgentController`](https://mastra.ai/reference/agent-controller/agent-controller-class)
|
package/.docs/reference/index.md
CHANGED
|
@@ -28,6 +28,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
28
28
|
- [.listAgents()](https://mastra.ai/reference/agents/listAgents)
|
|
29
29
|
- [.listScorers()](https://mastra.ai/reference/agents/listScorers)
|
|
30
30
|
- [.listSkills()](https://mastra.ai/reference/agents/listSkills)
|
|
31
|
+
- [.listSuspendedRuns()](https://mastra.ai/reference/agents/listSuspendedRuns)
|
|
31
32
|
- [.listTools()](https://mastra.ai/reference/agents/listTools)
|
|
32
33
|
- [.listWorkflows()](https://mastra.ai/reference/agents/listWorkflows)
|
|
33
34
|
- [.network()](https://mastra.ai/reference/agents/network)
|
|
@@ -73,6 +74,8 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
73
74
|
- [Tools API](https://mastra.ai/reference/client-js/tools)
|
|
74
75
|
- [Vectors API](https://mastra.ai/reference/client-js/vectors)
|
|
75
76
|
- [Workflows API](https://mastra.ai/reference/client-js/workflows)
|
|
77
|
+
- [buildBasePrompt()](https://mastra.ai/reference/coding-agent/build-base-prompt)
|
|
78
|
+
- [createCodingAgent()](https://mastra.ai/reference/coding-agent/create-coding-agent)
|
|
76
79
|
- [Mastra Class](https://mastra.ai/reference/core/mastra-class)
|
|
77
80
|
- [MastraModelGateway](https://mastra.ai/reference/core/mastra-model-gateway)
|
|
78
81
|
- [.addGateway()](https://mastra.ai/reference/core/addGateway)
|
|
@@ -54,6 +54,8 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
54
54
|
|
|
55
55
|
**observation.threadTitle** (`boolean`): When \`true\`, the Observer suggests short thread titles and updates the thread title when the conversation topic meaningfully changes. This is opt-in and defaults to disabled.
|
|
56
56
|
|
|
57
|
+
**observation.extract** (`Extractor[]`): Custom values to extract after observation. Schema-less extractors are requested inline in the Observer output. Schema-backed extractors run as a follow-up structured output call and are stored in thread OM metadata.
|
|
58
|
+
|
|
57
59
|
**observation.observeAttachments** (`boolean | string[]`): Controls which image/file attachments are forwarded to the Observer model alongside their placeholder text lines. \`true\` (default) forwards all attachments. \`false\` drops all attachments while keeping placeholders visible. An array is a case-insensitive mimeType allowlist supporting exact matches (\`'application/pdf'\`), wildcard subtypes (\`'image/\*'\`), and bare \`'\*'\` for everything. Useful when the Observer model is text-only (e.g. some DeepSeek endpoints) while the main agent uses a multimodal model. Tool-result attachments are filtered using the same rule.
|
|
58
60
|
|
|
59
61
|
**observation.messageTokens** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. Text is estimated locally with \`tokenx\`. Image parts are included with model-aware heuristics when possible, with deterministic fallbacks when image metadata is incomplete. Image-like \`file\` parts are counted the same way when uploads are normalized as files.
|
|
@@ -86,6 +88,8 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
86
88
|
|
|
87
89
|
**reflection.instruction** (`string`): Custom instruction appended to the Reflector's system prompt. Use this to customize how the Reflector consolidates observations, such as prioritizing certain types of information.
|
|
88
90
|
|
|
91
|
+
**reflection.extract** (`Extractor[]`): Custom values to extract after reflection. Schema-less extractors are requested inline in the Reflector output. Schema-backed extractors run as a follow-up structured output call and are stored in thread OM metadata.
|
|
92
|
+
|
|
89
93
|
**reflection.observationTokens** (`number`): Token count of observations that triggers reflection. When observation tokens exceed this threshold, the Reflector agent is called to condense them.
|
|
90
94
|
|
|
91
95
|
**reflection.modelSettings** (`ObservationalMemoryModelSettings`): Model settings for the Reflector agent.
|
|
@@ -112,8 +116,86 @@ OM persists token payload estimates so repeated counting can reuse prior token e
|
|
|
112
116
|
- Per-message and per-conversation overhead are always recomputed at runtime and aren't cached.
|
|
113
117
|
- `data-*` and `reasoning` parts are skipped and don't receive cache entries.
|
|
114
118
|
|
|
119
|
+
## Extractor API
|
|
120
|
+
|
|
121
|
+
`Extractor` defines a value that OM should extract during observation or reflection. Built-in OM values such as `current-task`, `suggested-response`, and `thread-title` use the same extractor pipeline as custom values.
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { Memory, Extractor } from '@mastra/memory'
|
|
125
|
+
import { z } from 'zod'
|
|
126
|
+
|
|
127
|
+
const memory = new Memory({
|
|
128
|
+
options: {
|
|
129
|
+
observationalMemory: {
|
|
130
|
+
model: 'openai/gpt-5-mini',
|
|
131
|
+
observation: {
|
|
132
|
+
extract: [
|
|
133
|
+
new Extractor({
|
|
134
|
+
name: 'User profile',
|
|
135
|
+
instructions: 'Extract stable user profile facts that should be remembered.',
|
|
136
|
+
schema: z.object({
|
|
137
|
+
name: z.string().optional(),
|
|
138
|
+
timezone: z.string().optional(),
|
|
139
|
+
}),
|
|
140
|
+
}),
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**name** (`string`): Human-readable extractor name. OM slugifies this value into the extractor slug. Names must be unique after slug generation.
|
|
149
|
+
|
|
150
|
+
**slug** (`string`): Generated stable identifier for persisted values and XML tags. Slugs use lowercase letters, numbers, and hyphens. Built-in slugs and reserved XML tags cannot be used by custom extractors.
|
|
151
|
+
|
|
152
|
+
**instructions** (`string | (context) => string`): Instructions for what to extract and when to update the value. Use a function to derive instructions from runtime context.
|
|
153
|
+
|
|
154
|
+
**schema** (`ZodType<T> | (context) => ZodType<T> | undefined`): Optional Zod schema for structured extraction. When provided, OM runs a follow-up structured output call after the main OM operation. When omitted, the extractor is an inline string extractor emitted in the Observer or Reflector response. Use a function to derive the schema from runtime context.
|
|
155
|
+
|
|
156
|
+
**includePreviousExtraction** (`boolean`): Controls whether the previous extraction is shown to the extractor on future OM runs. Set to \`false\` for values that should only come from the current OM run. (Default: `true`)
|
|
157
|
+
|
|
158
|
+
**onExtracted** (`(context) => T | void | Promise<T | void>`): Optional hook called after a custom extractor returns a value and before metadata is persisted. Returning a value replaces the extracted value. Throwing records an extraction failure.
|
|
159
|
+
|
|
160
|
+
### Extraction behavior
|
|
161
|
+
|
|
162
|
+
- Extracted values are stored in thread OM metadata under `om.extracted`.
|
|
163
|
+
- Built-in extractor values are also mirrored to the compatibility metadata fields `currentTask`, `suggestedResponse`, and `threadTitle`.
|
|
164
|
+
- `thread-title` updates the thread title only when `observation.threadTitle` is enabled.
|
|
165
|
+
- `observation.extract` runs during observation. `reflection.extract` runs during reflection.
|
|
166
|
+
- Schema-backed extractors add a follow-up structured output request.
|
|
167
|
+
- Schema-less extractors are inline string extractors emitted directly in the Observer or Reflector output.
|
|
168
|
+
- Dynamic extractor functions receive runtime context, including `source`, `threadId`, `resourceId`, `mainAgent`, `memory`, and `requestContext` when available.
|
|
169
|
+
- `WorkingMemoryExtractor` uses the normal extractor pipeline to update working memory through the active `Memory` instance. It uses structured extraction when working memory has a JSON schema and skips OM metadata persistence, so the working memory payload isn't duplicated under OM extracted metadata.
|
|
170
|
+
- `observationalMemory.observation.manageWorkingMemory` adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true` when working memory is enabled.
|
|
171
|
+
- Extraction failures are reported in OM marker data and do not discard other successful extracted values.
|
|
172
|
+
|
|
115
173
|
## Examples
|
|
116
174
|
|
|
175
|
+
### Working memory updates
|
|
176
|
+
|
|
177
|
+
Use `observationalMemory.observation.manageWorkingMemory` when OM should update working memory.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import { Memory } from '@mastra/memory'
|
|
181
|
+
|
|
182
|
+
const memory = new Memory({
|
|
183
|
+
options: {
|
|
184
|
+
workingMemory: {
|
|
185
|
+
enabled: true,
|
|
186
|
+
},
|
|
187
|
+
observationalMemory: {
|
|
188
|
+
enabled: true,
|
|
189
|
+
observation: {
|
|
190
|
+
manageWorkingMemory: true,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
|
|
198
|
+
|
|
117
199
|
### Resource scope with custom thresholds (experimental)
|
|
118
200
|
|
|
119
201
|
```typescript
|
|
@@ -431,6 +513,10 @@ Emitted when observation or reflection completes successfully.
|
|
|
431
513
|
|
|
432
514
|
**suggestedResponse** (`string`): Suggested response extracted by the Observer.
|
|
433
515
|
|
|
516
|
+
**extractedValues** (`Record<string, unknown>`): Values extracted during this OM operation, keyed by extractor slug.
|
|
517
|
+
|
|
518
|
+
**extractionFailures** (`Array<{ slug: string; error: string }>`): Extractor failures from this OM operation. Successful extractor values are still included.
|
|
519
|
+
|
|
434
520
|
**recordId** (`string`): The OM record ID.
|
|
435
521
|
|
|
436
522
|
**threadId** (`string`): This thread's ID.
|
|
@@ -495,6 +581,10 @@ Emitted when async buffering completes. The content is stored but not yet activa
|
|
|
495
581
|
|
|
496
582
|
**observations** (`string`): The buffered content.
|
|
497
583
|
|
|
584
|
+
**extractedValues** (`Record<string, unknown>`): Values extracted during this buffered OM operation, keyed by extractor slug.
|
|
585
|
+
|
|
586
|
+
**extractionFailures** (`Array<{ slug: string; error: string }>`): Extractor failures from this buffered OM operation. Successful extractor values are still included.
|
|
587
|
+
|
|
498
588
|
**recordId** (`string`): The OM record ID.
|
|
499
589
|
|
|
500
590
|
**threadId** (`string`): This thread's ID.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`65a66db`](https://github.com/mastra-ai/mastra/commit/65a66dbe249a0d92d828c605b955e73a983cf3b0), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
|
|
8
|
+
- @mastra/core@1.48.0
|
|
9
|
+
- @mastra/mcp@1.12.1
|
|
10
|
+
|
|
11
|
+
## 1.2.3-alpha.17
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
|
|
16
|
+
- @mastra/core@1.48.0-alpha.10
|
|
17
|
+
|
|
18
|
+
## 1.2.3-alpha.16
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1)]:
|
|
23
|
+
- @mastra/core@1.48.0-alpha.9
|
|
24
|
+
|
|
25
|
+
## 1.2.3-alpha.14
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257)]:
|
|
30
|
+
- @mastra/core@1.48.0-alpha.8
|
|
31
|
+
|
|
32
|
+
## 1.2.3-alpha.13
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c)]:
|
|
37
|
+
- @mastra/core@1.48.0-alpha.7
|
|
38
|
+
|
|
39
|
+
## 1.2.3-alpha.12
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [[`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`65a66db`](https://github.com/mastra-ai/mastra/commit/65a66dbe249a0d92d828c605b955e73a983cf3b0), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb)]:
|
|
44
|
+
- @mastra/core@1.48.0-alpha.6
|
|
45
|
+
- @mastra/mcp@1.12.1-alpha.0
|
|
46
|
+
|
|
47
|
+
## 1.2.3-alpha.10
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [[`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b)]:
|
|
52
|
+
- @mastra/core@1.48.0-alpha.5
|
|
53
|
+
|
|
54
|
+
## 1.2.3-alpha.8
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [[`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4)]:
|
|
59
|
+
- @mastra/core@1.48.0-alpha.4
|
|
60
|
+
|
|
3
61
|
## 1.2.3-alpha.7
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.2.3
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/mcp": "^1.12.
|
|
32
|
-
"@mastra/core": "1.48.0
|
|
31
|
+
"@mastra/mcp": "^1.12.1",
|
|
32
|
+
"@mastra/core": "1.48.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^1.19.11",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsx": "^4.22.4",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "4.1.8",
|
|
48
|
-
"@internal/types-builder": "0.0.
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
48
|
+
"@internal/types-builder": "0.0.85",
|
|
49
|
+
"@internal/lint": "0.0.110",
|
|
50
|
+
"@mastra/core": "1.48.0"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|