@mastra/mcp-docs-server 1.2.7-alpha.12 → 1.2.7-alpha.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/integrations.md +2 -44
- package/.docs/docs/agent-builder/overview.md +3 -4
- package/.docs/docs/agent-builder/skill-registries.md +3 -1
- package/.docs/docs/agent-controller/overview.md +2 -3
- package/.docs/docs/agent-controller/session.md +3 -1
- package/.docs/docs/agents/a2a.md +1 -2
- package/.docs/docs/agents/channels.md +225 -0
- package/.docs/docs/agents/code-mode.md +1 -1
- package/.docs/docs/agents/file-based-agents.md +297 -0
- package/.docs/docs/agents/guardrails.md +9 -10
- package/.docs/docs/agents/overview.md +4 -4
- package/.docs/docs/agents/skills.md +5 -3
- package/.docs/docs/agents/structured-output.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +4 -3
- package/.docs/docs/agents/using-tools.md +4 -2
- package/.docs/docs/browser/agent-browser.md +3 -1
- package/.docs/docs/browser/browser-viewer.md +3 -1
- package/.docs/docs/browser/overview.md +1 -2
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/deployment/mastra-server.md +4 -2
- package/.docs/docs/editor/overview.md +6 -2
- package/.docs/docs/editor/prompts.md +1 -1
- package/.docs/docs/editor/tools.md +5 -3
- package/.docs/docs/evals/custom-scorers.md +3 -1
- package/.docs/docs/evals/datasets/overview.md +5 -4
- package/.docs/docs/evals/datasets/running-experiments.md +2 -4
- package/.docs/docs/evals/evals-with-memory.md +3 -1
- package/.docs/docs/evals/gates-and-verdicts.md +3 -1
- package/.docs/docs/evals/overview.md +1 -4
- package/.docs/docs/evals/quick-checks.md +3 -1
- package/.docs/docs/long-running-agents/background-tasks.md +1 -1
- package/.docs/docs/long-running-agents/durable-agents.md +5 -3
- package/.docs/docs/long-running-agents/goals.md +3 -1
- package/.docs/docs/long-running-agents/signal-providers.md +3 -1
- package/.docs/docs/long-running-agents/signals.md +22 -11
- package/.docs/docs/mastra-platform/observability.md +1 -5
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +10 -6
- package/.docs/docs/memory/observational-memory.md +1 -2
- package/.docs/docs/memory/overview.md +4 -6
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/working-memory.md +3 -3
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +3 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/server/auth/auth0.md +1 -1
- package/.docs/docs/server/auth/better-auth.md +2 -2
- package/.docs/docs/server/auth/clerk.md +1 -1
- package/.docs/docs/server/auth/firebase.md +1 -1
- package/.docs/docs/server/auth/google.md +2 -2
- package/.docs/docs/server/auth/jwt.md +2 -2
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/pubsub.md +1 -1
- package/.docs/docs/server/request-context.md +4 -4
- package/.docs/docs/server/server-adapters.md +8 -8
- package/.docs/docs/studio/auth.md +3 -1
- package/.docs/docs/studio/overview.md +1 -1
- package/.docs/docs/voice/livekit.md +3 -100
- package/.docs/docs/workflows/agents-and-tools.md +5 -3
- package/.docs/docs/workflows/control-flow.md +3 -1
- package/.docs/docs/workflows/overview.md +7 -6
- package/.docs/docs/workspace/overview.md +1 -2
- package/.docs/docs/workspace/sandbox.md +0 -2
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
- package/.docs/guides/concepts/streaming.md +3 -3
- package/.docs/guides/getting-started/quickstart.md +1 -3
- package/.docs/guides/guide/chef-michel.md +2 -0
- package/.docs/guides/guide/slack-assistant.md +2 -2
- package/.docs/guides/guide/stock-agent.md +2 -0
- package/.docs/models/environment-variables.md +0 -7
- package/.docs/models/gateways/netlify.md +1 -4
- package/.docs/models/gateways/openrouter.md +7 -10
- package/.docs/models/gateways/vercel.md +1 -8
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/abacus.md +14 -44
- package/.docs/models/providers/google.md +1 -2
- package/.docs/models/providers/llmgateway.md +181 -185
- package/.docs/models/providers/nano-gpt.md +2 -2
- package/.docs/models/providers/neon.md +29 -40
- package/.docs/models/providers/nvidia.md +3 -1
- package/.docs/models/providers/openai.md +1 -6
- package/.docs/models/providers/opencode.md +2 -6
- package/.docs/models/providers/poolside.md +5 -6
- package/.docs/models/providers/routing-run.md +34 -23
- package/.docs/models/providers/the-grid-ai.md +3 -3
- package/.docs/models/providers/wandb.md +14 -21
- package/.docs/models/providers/xai.md +1 -2
- package/.docs/models/providers.md +0 -7
- package/.docs/reference/agents/channels.md +2 -2
- package/.docs/reference/channels/channel-provider.md +1 -1
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/mastra.md +10 -117
- package/.docs/reference/evals/create-scorer.md +0 -8
- package/.docs/reference/index.md +0 -17
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +1 -1
- package/.docs/reference/server/express-adapter.md +3 -1
- package/.docs/reference/server/fastify-adapter.md +3 -1
- package/.docs/reference/server/hono-adapter.md +3 -1
- package/.docs/reference/server/koa-adapter.md +3 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -1
- package/.docs/reference/storage/clickhouse.md +0 -32
- package/.docs/reference/storage/composite.md +1 -27
- package/.docs/reference/storage/retention.md +0 -11
- package/.docs/reference/tools/mcp-client.md +0 -22
- package/.docs/reference/tools/mcp-server.md +4 -161
- package/.docs/reference/voice/livekit.md +8 -272
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +3 -1
- package/.docs/reference/workspace/agentfs-filesystem.md +3 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +3 -1
- package/.docs/reference/workspace/archil-filesystem.md +3 -1
- package/.docs/reference/workspace/azure-blob-filesystem.md +3 -1
- package/.docs/reference/workspace/blaxel-sandbox.md +3 -1
- package/.docs/reference/workspace/daytona-sandbox.md +3 -1
- package/.docs/reference/workspace/docker-sandbox.md +3 -1
- package/.docs/reference/workspace/e2b-sandbox.md +3 -1
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -1
- package/.docs/reference/workspace/gcs-filesystem.md +3 -1
- package/.docs/reference/workspace/google-drive-filesystem.md +3 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -1
- package/.docs/reference/workspace/local-sandbox.md +3 -1
- package/.docs/reference/workspace/modal-sandbox.md +3 -1
- package/.docs/reference/workspace/railway-sandbox.md +3 -1
- package/.docs/reference/workspace/s3-filesystem.md +3 -1
- package/.docs/reference/workspace/vercel-sandbox.md +7 -5
- package/.docs/reference/workspace/vercel-serverless.md +3 -1
- package/CHANGELOG.md +0 -29
- package/package.json +5 -5
- package/.docs/docs/capabilities/channels/discord.md +0 -98
- package/.docs/docs/capabilities/channels/other-adapters.md +0 -68
- package/.docs/docs/capabilities/channels/overview.md +0 -255
- package/.docs/docs/capabilities/channels/slack.md +0 -225
- package/.docs/docs/capabilities/channels/teams.md +0 -100
- package/.docs/docs/capabilities/channels/telegram.md +0 -98
- package/.docs/docs/capabilities/channels/whatsapp.md +0 -99
- package/.docs/docs/getting-started/file-based-agents.md +0 -116
- package/.docs/models/providers/crossmodel.md +0 -109
- package/.docs/models/providers/empiriolabs.md +0 -106
- package/.docs/models/providers/meta.md +0 -101
- package/.docs/models/providers/model-oracle-ai.md +0 -87
- package/.docs/models/providers/pioneer.md +0 -148
- package/.docs/models/providers/unorouter.md +0 -95
- package/.docs/models/providers/zenifra.md +0 -73
- package/.docs/reference/file-based-agents/config.md +0 -97
- package/.docs/reference/file-based-agents/instructions.md +0 -54
- package/.docs/reference/file-based-agents/logger.md +0 -26
- package/.docs/reference/file-based-agents/memory.md +0 -58
- package/.docs/reference/file-based-agents/observability.md +0 -32
- package/.docs/reference/file-based-agents/processors.md +0 -56
- package/.docs/reference/file-based-agents/scorers.md +0 -54
- package/.docs/reference/file-based-agents/server.md +0 -37
- package/.docs/reference/file-based-agents/skills.md +0 -56
- package/.docs/reference/file-based-agents/storage.md +0 -30
- package/.docs/reference/file-based-agents/studio.md +0 -56
- package/.docs/reference/file-based-agents/subagents.md +0 -123
- package/.docs/reference/file-based-agents/tools.md +0 -63
- package/.docs/reference/file-based-agents/workflows.md +0 -52
- package/.docs/reference/file-based-agents/workspace.md +0 -74
- package/.docs/reference/memory/summarizeConversation.md +0 -99
- package/.docs/reference/memory/summarizeThread.md +0 -93
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Workspace
|
|
4
|
-
|
|
5
|
-
A [workspace](https://mastra.ai/docs/workspace/overview) gives an agent filesystem access and command execution. File-based agents get a default workspace automatically when discovered through `mastra dev` or `mastra build`, so they can read and write files and run shell commands without extra configuration.
|
|
6
|
-
|
|
7
|
-
Use this page for the file-based convention. For workspace providers, tools, search, lifecycle, and sandbox details, see [Workspaces](https://mastra.ai/docs/workspace/overview).
|
|
8
|
-
|
|
9
|
-
## Default workspace
|
|
10
|
-
|
|
11
|
-
Without `workspace.ts`, a file-based agent gets a default [`Workspace`](https://mastra.ai/reference/workspace/workspace-class) when the build provides a per-agent workspace path. The default workspace uses:
|
|
12
|
-
|
|
13
|
-
- [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) rooted at the agent's bundled workspace directory.
|
|
14
|
-
- [`LocalSandbox`](https://mastra.ai/reference/workspace/local-sandbox) with the same working directory.
|
|
15
|
-
|
|
16
|
-
This gives the agent file tools and shell tools automatically. The default workspace is per agent; subagents get nested workspace directories under their parent agent's workspace path.
|
|
17
|
-
|
|
18
|
-
## Quickstart
|
|
19
|
-
|
|
20
|
-
For the default workspace, don't add a file. Start with an agent directory like this:
|
|
21
|
-
|
|
22
|
-
```text
|
|
23
|
-
src/mastra/agents/weather/
|
|
24
|
-
├── config.ts
|
|
25
|
-
└── instructions.md
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Add `workspace.ts` only when you need to customize the workspace:
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
|
|
32
|
-
|
|
33
|
-
export default new Workspace({
|
|
34
|
-
name: 'weather-workspace',
|
|
35
|
-
filesystem: new LocalFilesystem({ basePath: './data/weather' }),
|
|
36
|
-
sandbox: new LocalSandbox({ workingDirectory: './data/weather' }),
|
|
37
|
-
})
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Visit the [`Workspace` reference](https://mastra.ai/reference/workspace/workspace-class) for the full config.
|
|
41
|
-
|
|
42
|
-
## When to customize the workspace
|
|
43
|
-
|
|
44
|
-
Customize the workspace when the default local directory isn't enough. Common reasons include:
|
|
45
|
-
|
|
46
|
-
- Point file tools at a different filesystem root.
|
|
47
|
-
- Run shell commands in a different sandbox provider.
|
|
48
|
-
- Add workspace search with BM25 or vector search.
|
|
49
|
-
- Share one workspace across multiple agents.
|
|
50
|
-
|
|
51
|
-
For provider patterns and runtime behavior, see the [workspace overview](https://mastra.ai/docs/workspace/overview), [sandbox guide](https://mastra.ai/docs/workspace/sandbox), and [workspace search](https://mastra.ai/docs/workspace/search).
|
|
52
|
-
|
|
53
|
-
## Runtime boundary
|
|
54
|
-
|
|
55
|
-
The workspace filesystem controls what file tools can read and write. The sandbox controls where shell commands run. Application runtime code, including code in [`tools/`](https://mastra.ai/reference/file-based-agents/tools), still runs in your app/server process unless it explicitly calls workspace or sandbox APIs.
|
|
56
|
-
|
|
57
|
-
## Seed files
|
|
58
|
-
|
|
59
|
-
Add a `workspace/` directory to ship starting files with the agent. Mastra mirrors files under `workspace/` into the agent's default runtime workspace at build time, so the agent starts with those files on disk.
|
|
60
|
-
|
|
61
|
-
```text
|
|
62
|
-
src/mastra/agents/weather/
|
|
63
|
-
├── config.ts
|
|
64
|
-
└── workspace/
|
|
65
|
-
├── README.md
|
|
66
|
-
└── data/
|
|
67
|
-
└── cities.json
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
The files are copied into the bundled workspace path, where workspace file tools and sandbox commands can read them. Symlinked seed files are skipped during mirroring.
|
|
71
|
-
|
|
72
|
-
## Precedence with config
|
|
73
|
-
|
|
74
|
-
`config.workspace` wins over `workspace.ts`; otherwise the default file-based workspace is used. See [`config.ts` precedence](https://mastra.ai/reference/file-based-agents/config) for the full merge table.
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# summarizeConversation()
|
|
4
|
-
|
|
5
|
-
The standalone `summarizeConversation()` function summarizes a conversation in one shot. It distills the messages you pass in with the same Observer plumbing that powers [Observational Memory](https://mastra.ai/reference/memory/observational-memory) — without Observational Memory attached to an agent, and without reading from or writing to storage.
|
|
6
|
-
|
|
7
|
-
Nothing is written back to memory. The summary and extracted values are returned to you (and to each extractor's `onExtracted` hook), so you decide where they go — for example your own database.
|
|
8
|
-
|
|
9
|
-
Use this when you already have the messages in hand and want explicit control over what gets summarized. To summarize a stored thread by ID instead, use [`Memory.summarizeThread()`](https://mastra.ai/reference/memory/summarizeThread), which loads the messages for you.
|
|
10
|
-
|
|
11
|
-
## Usage example
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { summarizeConversation } from '@mastra/memory'
|
|
15
|
-
|
|
16
|
-
const result = await summarizeConversation({
|
|
17
|
-
model: 'openai/gpt-5-mini',
|
|
18
|
-
messages,
|
|
19
|
-
instructions: 'Summarize this voicemail call for the business owner.',
|
|
20
|
-
})
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Parameters
|
|
24
|
-
|
|
25
|
-
**model** (`string | LanguageModel | DynamicModel`): Model that runs the summarization, such as a router string like '\_\_GATEWAY\_OPENAI\_MODEL\_MINI\_\_'.
|
|
26
|
-
|
|
27
|
-
**messages** (`MastraDBMessage[]`): The conversation to summarize. When empty, the function returns an empty result without calling the model.
|
|
28
|
-
|
|
29
|
-
**instructions** (`string`): Extra guidance appended to the summarizer's system prompt, such as what to focus on or who the summary is for.
|
|
30
|
-
|
|
31
|
-
**extract** (`Extractor[]`): Extractors to run over the conversation. Extractors with a Zod schema run as a follow-up structured output call; schema-less extractors are extracted inline. Each extractor's onExtracted hook fires with the extracted value.
|
|
32
|
-
|
|
33
|
-
**threadId** (`string`): Thread the conversation belongs to. Defaults to the first threadId found on messages. Passed to extractor contexts.
|
|
34
|
-
|
|
35
|
-
**resourceId** (`string`): Resource (user) the conversation belongs to. Defaults to the first resourceId found on messages. Passed to extractor contexts.
|
|
36
|
-
|
|
37
|
-
**memory** (`Memory`): Memory instance forwarded to extractor contexts. Set automatically when called through Memory.summarizeThread().
|
|
38
|
-
|
|
39
|
-
**mastra** (`Mastra`): Mastra instance used to resolve custom gateway models. Set automatically when called through Memory.summarizeThread().
|
|
40
|
-
|
|
41
|
-
**requestContext** (`RequestContext`): Request context forwarded to the summarizer model and extractor hooks.
|
|
42
|
-
|
|
43
|
-
**abortSignal** (`AbortSignal`): Signal to cancel the summarization call.
|
|
44
|
-
|
|
45
|
-
## Returns
|
|
46
|
-
|
|
47
|
-
**summary** (`string`): The distilled observations produced from the conversation, in dense bullet form.
|
|
48
|
-
|
|
49
|
-
**extracted** (`Record<string, unknown>`): Values produced by extract extractors, keyed by extractor slug.
|
|
50
|
-
|
|
51
|
-
**extractionFailures** (`{ slug: string; error: string }[]`): Extractors that failed to produce a valid value, with the reason. Only present when at least one extractor failed.
|
|
52
|
-
|
|
53
|
-
**usage** (`{ inputTokens?: number; outputTokens?: number; totalTokens?: number }`): Token usage of the summarization call.
|
|
54
|
-
|
|
55
|
-
## Extended usage example
|
|
56
|
-
|
|
57
|
-
The following example summarizes an in-flight voice session from messages the application already holds, and extracts a structured record:
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { summarizeConversation, Extractor } from '@mastra/memory'
|
|
61
|
-
import type { MastraDBMessage } from '@mastra/core/agent'
|
|
62
|
-
import { z } from 'zod'
|
|
63
|
-
import { sessionRecords } from './db'
|
|
64
|
-
|
|
65
|
-
const sessionSummary = new Extractor({
|
|
66
|
-
name: 'session-summary',
|
|
67
|
-
instructions: 'Return a concise summary of the session.',
|
|
68
|
-
schema: z.object({
|
|
69
|
-
summary: z.string(),
|
|
70
|
-
sentiment: z.enum(['positive', 'neutral', 'negative']),
|
|
71
|
-
followUps: z.array(z.string()),
|
|
72
|
-
}),
|
|
73
|
-
metadataKeyPath: false, // don't persist into memory metadata — the hook owns storage
|
|
74
|
-
onExtracted: async ({ current, threadId }) => {
|
|
75
|
-
await sessionRecords.upsert({ sessionId: threadId, record: current })
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
export async function onSessionEnd(messages: MastraDBMessage[]) {
|
|
80
|
-
const { summary, extracted, extractionFailures } = await summarizeConversation({
|
|
81
|
-
model: 'openai/gpt-5-mini',
|
|
82
|
-
messages,
|
|
83
|
-
instructions: 'Summarize this support session for the account manager.',
|
|
84
|
-
extract: [sessionSummary],
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
if (extractionFailures?.length) {
|
|
88
|
-
console.warn('Some extractors failed', extractionFailures)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { summary, extracted }
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Related
|
|
96
|
-
|
|
97
|
-
- [.summarizeThread()](https://mastra.ai/reference/memory/summarizeThread)
|
|
98
|
-
- [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
|
|
99
|
-
- [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
-
|
|
3
|
-
# Memory.summarizeThread()
|
|
4
|
-
|
|
5
|
-
The `.summarizeThread()` method summarizes a thread's conversation in one shot. It loads the thread's messages from storage and distills them with the same Observer plumbing that powers [Observational Memory](https://mastra.ai/reference/memory/observational-memory) — as a standalone call, without Observational Memory attached to an agent.
|
|
6
|
-
|
|
7
|
-
Messages load page-by-page starting from the newest, bounded by `lastMessages` and `maxInputTokens`, so summarizing a long thread doesn't read its entire history from storage.
|
|
8
|
-
|
|
9
|
-
Nothing is written back to memory. The summary and extracted values are returned to you (and to each extractor's `onExtracted` hook), so you decide where they go — for example your own database.
|
|
10
|
-
|
|
11
|
-
Use this when a session ends and you want a summary or structured extraction of the whole conversation, such as a voice call at hang-up. To summarize messages you already have in hand (without loading them from a thread), use the standalone [`summarizeConversation()`](https://mastra.ai/reference/memory/summarizeConversation) function instead — it takes the same options with `messages` in place of `threadId`.
|
|
12
|
-
|
|
13
|
-
## Usage example
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
const result = await memory.summarizeThread({
|
|
17
|
-
model: 'openai/gpt-5-mini',
|
|
18
|
-
threadId: 'thread-123',
|
|
19
|
-
instructions: 'Summarize this voicemail call for the business owner.',
|
|
20
|
-
})
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Parameters
|
|
24
|
-
|
|
25
|
-
**threadId** (`string`): The unique identifier of the thread to summarize.
|
|
26
|
-
|
|
27
|
-
**model** (`string | LanguageModel | DynamicModel`): Model that runs the summarization, such as a router string like '\_\_GATEWAY\_OPENAI\_MODEL\_MINI\_\_'.
|
|
28
|
-
|
|
29
|
-
**resourceId** (`string`): ID of the resource that owns the thread. If provided, validates thread ownership. Also passed to extractor contexts.
|
|
30
|
-
|
|
31
|
-
**lastMessages** (`number`): Only summarize the last N messages of the thread. By default the whole thread is loaded, bounded by maxInputTokens.
|
|
32
|
-
|
|
33
|
-
**maxInputTokens** (`number`): Stop loading older messages once the collected messages exceed this estimated token count. The newest message is always included. (Default: `1000000`)
|
|
34
|
-
|
|
35
|
-
**instructions** (`string`): Extra guidance appended to the summarizer's system prompt, such as what to focus on or who the summary is for.
|
|
36
|
-
|
|
37
|
-
**extract** (`Extractor[]`): Extractors to run over the conversation. Extractors with a Zod schema run as a follow-up structured output call; schema-less extractors are extracted inline. Each extractor's onExtracted hook fires with the extracted value.
|
|
38
|
-
|
|
39
|
-
**requestContext** (`RequestContext`): Request context forwarded to the summarizer model and extractor hooks.
|
|
40
|
-
|
|
41
|
-
**abortSignal** (`AbortSignal`): Signal to cancel the summarization call.
|
|
42
|
-
|
|
43
|
-
## Returns
|
|
44
|
-
|
|
45
|
-
**summary** (`string`): The distilled observations produced from the conversation, in dense bullet form.
|
|
46
|
-
|
|
47
|
-
**extracted** (`Record<string, unknown>`): Values produced by extract extractors, keyed by extractor slug.
|
|
48
|
-
|
|
49
|
-
**extractionFailures** (`{ slug: string; error: string }[]`): Extractors that failed to produce a valid value, with the reason. Only present when at least one extractor failed.
|
|
50
|
-
|
|
51
|
-
**usage** (`{ inputTokens?: number; outputTokens?: number; totalTokens?: number }`): Token usage of the summarization call.
|
|
52
|
-
|
|
53
|
-
## Extended usage example
|
|
54
|
-
|
|
55
|
-
The following example summarizes a finished voice call and stores a structured record in the application's own database:
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { Extractor } from '@mastra/memory'
|
|
59
|
-
import { z } from 'zod'
|
|
60
|
-
import { memory } from './mastra/memory'
|
|
61
|
-
import { callRecords } from './db'
|
|
62
|
-
|
|
63
|
-
const callSummary = new Extractor({
|
|
64
|
-
name: 'call-summary',
|
|
65
|
-
instructions: 'Return a concise summary of the call.',
|
|
66
|
-
schema: z.object({
|
|
67
|
-
summary: z.string(),
|
|
68
|
-
sentiment: z.enum(['positive', 'neutral', 'negative']),
|
|
69
|
-
requestedServices: z.array(z.string()),
|
|
70
|
-
}),
|
|
71
|
-
metadataKeyPath: false, // don't persist into memory metadata — the hook owns storage
|
|
72
|
-
onExtracted: async ({ current, threadId, resourceId }) => {
|
|
73
|
-
await callRecords.upsert({ callId: threadId, callerId: resourceId, record: current })
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
export async function onCallEnd(threadId: string, resourceId: string) {
|
|
78
|
-
await memory.summarizeThread({
|
|
79
|
-
model: 'openai/gpt-5-mini',
|
|
80
|
-
threadId,
|
|
81
|
-
resourceId,
|
|
82
|
-
instructions: 'Summarize this voicemail call for the business owner.',
|
|
83
|
-
extract: [callSummary],
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Related
|
|
89
|
-
|
|
90
|
-
- [summarizeConversation()](https://mastra.ai/reference/memory/summarizeConversation)
|
|
91
|
-
- [Memory Class Reference](https://mastra.ai/reference/memory/memory-class)
|
|
92
|
-
- [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
|
|
93
|
-
- [.recall()](https://mastra.ai/reference/memory/recall)
|