@mastra/mcp-docs-server 1.2.23-alpha.10 → 1.2.23-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.
@@ -414,7 +414,7 @@ See [Realtime voice](#quickstart) for setup and concepts.
414
414
  The package has three entry points:
415
415
 
416
416
  - `@mastra/livekit`: server-side APIs, [`liveKitConnectionRoute()`](#livekitconnectionroute), [`dispatchVoiceSession()`](#dispatchvoicesession), [`pipeAgentReplyToWriter()`](#pipeagentreplytowriter), [`serializeSessionMetadata()`](#livekitsessionmetadata), and [`createEndCallTool()`](#createendcalltool). Import these from Mastra server code. This entry never loads the LiveKit agents runtime.
417
- - `@mastra/livekit/worker`: the worker runtime, [`createLiveKitWorker()`](#createlivekitworker), [`runLiveKitWorker()`](#runlivekitworker), [`chatContextToMessages()`](#chatcontexttomessages), and the session helpers [`speakGreeting()`](#speakgreeting), [`waitForAgentDoneSpeaking()`](#waitforagentdonespeaking), and [`runEndCall()`](#runendcall). Import it only from the worker entry file.
417
+ - `@mastra/livekit/worker`: the worker runtime, [`createLiveKitWorker()`](#createlivekitworker), [`runLiveKitWorker()`](#runlivekitworker), [`chatContextToMessages()`](#chatcontexttomessages), the per-session agent class [`MastraVoiceAgent`](#mastravoiceagent), and the session helpers [`speakGreeting()`](#speakgreeting), [`waitForAgentDoneSpeaking()`](#waitforagentdonespeaking), and [`runEndCall()`](#runendcall). Import it only from the worker entry file.
418
418
  - `@mastra/livekit/plugin`: the LLM-component plugin, [`MastraLLM`](#mastrallm) and [`createRemoteAgentReplyGenerator()`](#createremoteagentreplygenerator). Import it in workers that build their own `voice.AgentSession`. `createRemoteAgentReplyGenerator()` is also exported from `@mastra/livekit/worker` because it plugs into `createLiveKitWorker()`'s `generate` option. `MastraLLM` is plugin-only.
419
419
 
420
420
  ### `createLiveKitWorker()`
@@ -551,6 +551,56 @@ export default createLiveKitWorker({
551
551
 
552
552
  Returns: `VoiceTurnMessage[]`, where each entry is `{ role: 'system' | 'user' | 'assistant'; content: string; id?: string }`.
553
553
 
554
+ ### `MastraVoiceAgent`
555
+
556
+ The LiveKit `voice.Agent` subclass that [`createLiveKitWorker()`](#createlivekitworker) builds for every session. Replies come from a Mastra agent (or a custom `generate` source) through the agent's `llmNode`; LiveKit keeps the audio loop, turn detection, and barge-in. Construct it yourself when you own the `voice.AgentSession`, for example to test a Mastra-backed agent with `@livekit/agents`' `voice.testing` harness without speech-to-text, text-to-speech, or a live worker. `createMastraVoiceAgent(options)` is an equivalent factory.
557
+
558
+ ```typescript
559
+ import { initializeLogger, voice } from '@livekit/agents'
560
+ import { MastraVoiceAgent } from '@mastra/livekit/worker'
561
+ import { supportAgent } from './agents/support'
562
+
563
+ // Required outside a LiveKit worker: AgentSession needs the LiveKit logger initialized.
564
+ initializeLogger({ level: 'silent', pretty: false })
565
+
566
+ const session = new voice.AgentSession()
567
+ await session.start({ agent: new MastraVoiceAgent({ agent: supportAgent, memory: false }) })
568
+
569
+ // run() returns a RunResult, not a promise; wait() resolves when the turn completes.
570
+ const result = session.run({ userInput: 'What are your opening hours?' })
571
+ await result.wait()
572
+ result.expect.nextEvent().isMessage({ role: 'assistant' })
573
+ result.expect.noMoreEvents()
574
+ ```
575
+
576
+ The agent carries its own placeholder `llm.LLM` so LiveKit runs the reply pipeline; generation always goes through `llmNode`, so a `FakeLLM` in the session's `llm` slot is ignored and calling the placeholder's `chat()` throws. To stub the model in tests, give the Mastra agent a mock model or pass a custom `generate` function.
577
+
578
+ #### Options
579
+
580
+ Provide exactly one reply source: `agent` or `generate`.
581
+
582
+ **agent** (`Agent`): In-process Mastra agent. Tools and memory run inside it.
583
+
584
+ **generate** (`VoiceReplyGenerator`): Custom reply source, for example from createRemoteAgentReplyGenerator(). A generate source owns its own hooks; toolFeedback, onToolCall, onTurnComplete, and streamOptions only apply to the agent source.
585
+
586
+ **memory** (`MastraVoiceAgentMemory | false`): Conversation persistence as { thread, resource? }. When set, only messages new since the agent last spoke are sent each turn and Mastra Memory supplies history. When false, the full in-session LiveKit context is sent every turn. (Default: `false`)
587
+
588
+ **requestContext** (`RequestContext | Record<string, unknown>`): Request context entries forwarded to every generation.
589
+
590
+ **toolFeedback** (`(toolCall: VoiceToolCall) => string | undefined | void`): Return a short phrase to speak while a tool runs. Agent source only.
591
+
592
+ **onToolCall** (`(toolCall: VoiceToolCall) => void`): Called as each tool call starts, before its result is known. Keep it cheap and non-throwing. Agent source only.
593
+
594
+ **onTurnComplete** (`VoiceTurnCompleteHook`): Called once per turn after the reply finished streaming to text-to-speech. Fire-and-forget; errors are logged. Agent source only.
595
+
596
+ **greetingReminder** (`{ everyMs: number; text?: string }`): Periodic AI re-disclosure: once everyMs has elapsed, the next reply is prefixed with text (spoken at the turn boundary). The worker derives this from configuration.greeting.repeatEvery / repeatText.
597
+
598
+ **streamOptions** (`MastraStreamOptions`): Extra options merged into every agent.stream() call. Agent source only.
599
+
600
+ **instructions** (`string`): LiveKit agent instructions. Not used for reply generation; the Mastra agent applies its own.
601
+
602
+ **id / stt / vad / tts / turnHandling** (`voice.AgentOptions['id' | 'stt' | 'vad' | 'tts' | 'turnHandling']`): Passed through to the LiveKit voice.Agent constructor. Use them to set per-agent speech components or turn handling.
603
+
554
604
  ### `MastraLLM`
555
605
 
556
606
  A standard LiveKit LLM plugin (`llm.LLM`) backed by a Mastra agent. Use it when you build the `voice.AgentSession` yourself and want Mastra in the `llm` slot. [`createLiveKitWorker()`](#createlivekitworker) is the managed alternative. See [Use Mastra as the LLM component](#use-mastra-as-the-llm-component) for how to choose.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.23-alpha.10",
3
+ "version": "1.2.23-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",
@@ -27,8 +27,8 @@
27
27
  "jsdom": "^26.1.0",
28
28
  "local-pkg": "^1.1.2",
29
29
  "zod": "^4.4.3",
30
- "@mastra/core": "1.64.0-alpha.4",
31
- "@mastra/mcp": "^1.17.3-alpha.0"
30
+ "@mastra/core": "1.64.0-alpha.5",
31
+ "@mastra/mcp": "^1.17.3-alpha.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@hono/node-server": "^2.0.0",
@@ -45,7 +45,7 @@
45
45
  "typescript": "^7.0.2",
46
46
  "vitest": "4.1.10",
47
47
  "@internal/lint": "0.0.129",
48
- "@mastra/core": "1.64.0-alpha.4",
48
+ "@mastra/core": "1.64.0-alpha.5",
49
49
  "@internal/types-builder": "0.0.104"
50
50
  },
51
51
  "homepage": "https://mastra.ai",