@mastra/mcp-docs-server 1.2.4 → 1.2.5-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/deploying.md +1 -1
- package/.docs/docs/agent-controller/overview.md +1 -1
- package/.docs/docs/agent-controller/session.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +1 -1
- package/.docs/docs/agents/supervisor-agents.md +3 -3
- package/.docs/docs/agents/using-tools.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/background-tasks.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/durable-agents.md +2 -2
- package/.docs/docs/{agents → long-running-agents}/goals.md +1 -1
- package/.docs/docs/{agents → long-running-agents}/heartbeats.md +5 -5
- package/.docs/docs/{agents → long-running-agents}/signal-providers.md +4 -4
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/config.md +1 -2
- package/.docs/docs/server/pubsub.md +2 -2
- package/.docs/docs/voice/overview.md +3 -3
- package/.docs/docs/voice/speech-to-speech.md +81 -1
- package/.docs/docs/voice/speech-to-text.md +19 -1
- package/.docs/docs/voice/text-to-speech.md +21 -1
- package/.docs/docs/workflows/control-flow.md +1 -1
- package/.docs/docs/workflows/error-handling.md +1 -1
- package/.docs/docs/workflows/human-in-the-loop.md +1 -1
- package/.docs/docs/workflows/overview.md +1 -1
- package/.docs/docs/workflows/snapshots.md +1 -1
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/docs/workflows/time-travel.md +1 -1
- package/.docs/docs/workflows/workflow-state.md +1 -1
- package/.docs/guides/build-your-ui/copilotkit/channels.md +76 -0
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +174 -0
- package/.docs/guides/build-your-ui/copilotkit/overview.md +411 -0
- package/.docs/guides/concepts/streaming.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -2
- package/.docs/guides/guide/signal-provider.md +5 -5
- package/.docs/models/environment-variables.md +2 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/alibaba-cn.md +2 -1
- package/.docs/models/providers/friendli.md +1 -2
- package/.docs/models/providers/kenari.md +95 -0
- package/.docs/models/providers/nvidia.md +2 -3
- package/.docs/models/providers/tencent-token-plan.md +7 -7
- package/.docs/models/providers/tencent-tokenhub.md +5 -4
- package/.docs/models/providers.md +2 -0
- package/.docs/reference/acp/acp-agent.md +5 -5
- package/.docs/reference/acp/create-acp-tool.md +5 -5
- package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
- package/.docs/reference/agents/agent.md +34 -34
- package/.docs/reference/agents/channels.md +19 -19
- package/.docs/reference/agents/createSkill.md +2 -2
- package/.docs/reference/agents/durable-agent.md +22 -22
- package/.docs/reference/agents/generate.md +10 -10
- package/.docs/reference/agents/generateLegacy.md +12 -12
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getVoice.md +1 -1
- package/.docs/reference/agents/inngest-agent.md +9 -9
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +4 -4
- package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
- package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +4 -4
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/ai-sdk/with-mastra.md +2 -2
- package/.docs/reference/ai-sdk/workflow-route.md +2 -2
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
- package/.docs/reference/auth/google.md +10 -10
- package/.docs/reference/auth/okta.md +11 -11
- package/.docs/reference/auth/workos.md +3 -3
- package/.docs/reference/channels/slack-provider.md +15 -15
- package/.docs/reference/cli/mastra.md +145 -0
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/mastra-client.md +5 -5
- package/.docs/reference/client-js/responses.md +3 -3
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/getAgentById.md +3 -3
- package/.docs/reference/core/getWorkflow.md +1 -1
- package/.docs/reference/core/listWorkflows.md +1 -1
- package/.docs/reference/core/mastra-class.md +3 -3
- package/.docs/reference/core/removeWorkspace.md +2 -2
- package/.docs/reference/datasets/compareExperiments.md +1 -1
- package/.docs/reference/datasets/getItemHistory.md +1 -1
- package/.docs/reference/datasets/list.md +5 -5
- package/.docs/reference/datasets/listExperimentResults.md +4 -4
- package/.docs/reference/datasets/listExperiments.md +4 -4
- package/.docs/reference/datasets/listItems.md +5 -5
- package/.docs/reference/datasets/listVersions.md +3 -3
- package/.docs/reference/datasets/startExperiment.md +8 -8
- package/.docs/reference/datasets/startExperimentAsync.md +1 -1
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
- package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
- package/.docs/reference/editor/blob-store-provider.md +2 -2
- package/.docs/reference/editor/browser-provider.md +2 -2
- package/.docs/reference/editor/filesystem-provider.md +2 -2
- package/.docs/reference/editor/mastra-editor.md +2 -2
- package/.docs/reference/editor/processor-provider.md +4 -4
- package/.docs/reference/editor/sandbox-provider.md +2 -2
- package/.docs/reference/editor/storage-browser-ref.md +2 -2
- package/.docs/reference/editor/storage-workspace-ref.md +7 -7
- package/.docs/reference/evals/create-scorer.md +8 -8
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +7 -7
- package/.docs/reference/evals/trajectory-accuracy.md +1 -1
- package/.docs/reference/index.md +2 -2
- package/.docs/reference/logging/pino-logger.md +4 -4
- package/.docs/reference/memory/cloneThread.md +35 -4
- package/.docs/reference/memory/memory-class.md +5 -5
- package/.docs/reference/memory/observational-memory.md +43 -43
- package/.docs/reference/memory/recall.md +4 -4
- package/.docs/reference/memory/serialized-memory-config.md +6 -6
- package/.docs/reference/observability/tracing/configuration.md +4 -4
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +20 -20
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/response-cache.md +6 -6
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/pubsub/base.md +7 -7
- package/.docs/reference/pubsub/caching-pubsub.md +1 -1
- package/.docs/reference/pubsub/event-emitter.md +2 -2
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/lease-provider.md +3 -3
- package/.docs/reference/pubsub/redis-streams.md +6 -6
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +2 -2
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +3 -3
- package/.docs/reference/server/register-api-route.md +3 -3
- package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
- package/.docs/reference/signals/signal-provider.md +7 -7
- package/.docs/reference/signals/webhook-signal-provider.md +2 -2
- package/.docs/reference/storage/clickhouse.md +7 -7
- package/.docs/reference/storage/composite.md +2 -2
- package/.docs/reference/storage/duckdb.md +1 -1
- package/.docs/reference/storage/dynamodb.md +1 -1
- package/.docs/reference/storage/libsql.md +1 -1
- package/.docs/reference/storage/postgresql.md +2 -2
- package/.docs/reference/storage/redis.md +2 -2
- package/.docs/reference/storage/retention.md +5 -5
- package/.docs/reference/storage/spanner.md +6 -6
- package/.docs/reference/streaming/ChunkType.md +3 -3
- package/.docs/reference/streaming/agents/stream.md +14 -14
- package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -140
- package/.docs/reference/tools/brightdata.md +4 -4
- package/.docs/reference/tools/create-code-mode.md +5 -5
- package/.docs/reference/tools/create-tool.md +15 -15
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +12 -12
- package/.docs/reference/tools/perplexity.md +3 -3
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/chroma.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/voice/google-gemini-live.md +3 -3
- package/.docs/reference/voice/inworld-realtime.md +12 -12
- package/.docs/reference/voice/inworld.md +2 -2
- package/.docs/reference/voice/voice.on.md +1 -1
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
- package/.docs/reference/workspace/archil-filesystem.md +5 -5
- package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
- package/.docs/reference/workspace/daytona-sandbox.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +3 -3
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/mesa-filesystem.md +3 -3
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +4 -4
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
- package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
- package/.docs/reference/workspace/workspace-class.md +15 -15
- package/CHANGELOG.md +15 -0
- package/package.json +5 -5
- package/.docs/docs/agents/adding-voice.md +0 -383
- package/.docs/docs/community/contributing-templates.md +0 -5
- package/.docs/docs/community/discord.md +0 -11
- package/.docs/guides/build-your-ui/copilotkit.md +0 -291
- package/LICENSE.md +0 -30
- /package/.docs/docs/{community/licensing.md → license.md} +0 -0
- /package/.docs/docs/{agents → long-running-agents}/signals.md +0 -0
|
@@ -103,7 +103,7 @@ new Mastra({
|
|
|
103
103
|
|
|
104
104
|
`S3Filesystem` uses the default AWS credential chain (environment variables, `~/.aws` config, IAM roles, EC2 instance profile). For long-running deployments, use a credential provider function so credentials refresh automatically.
|
|
105
105
|
|
|
106
|
-
`DockerSandbox` and `
|
|
106
|
+
`DockerSandbox`, `VercelSandbox`, and `VercelServerlessSandbox` are alternative cloud sandbox providers. Pick whichever matches your runtime.
|
|
107
107
|
|
|
108
108
|
> **Warning:** A local sandbox can't run commands safely in a shared environment. Always register a cloud sandbox provider and reference it in the workspace config before deploying.
|
|
109
109
|
|
|
@@ -42,7 +42,7 @@ You could assemble all of this yourself on top of the [Agent class](https://mast
|
|
|
42
42
|
- **Subagents**: Spawn focused child agents with constrained tools for subtasks, optionally forking the parent conversation. See [Subagents](https://mastra.ai/docs/agent-controller/subagents).
|
|
43
43
|
- **Tool approvals and permissions**: Configure which tools require user confirmation, grant session-wide exceptions, and handle interactive tool suspension. See [Tool approvals](https://mastra.ai/docs/agent-controller/tool-approvals).
|
|
44
44
|
- **Model management**: Switch models per-mode at runtime, track usage, and resolve gateway-backed models through Mastra's [model router](https://mastra.ai/models).
|
|
45
|
-
- **Follow-ups and steering**: Queue messages while the agent is running, or inject mid-stream instructions to redirect the agent. Built on [signals](https://mastra.ai/docs/agents/signals).
|
|
45
|
+
- **Follow-ups and steering**: Queue messages while the agent is running, or inject mid-stream instructions to redirect the agent. Built on [signals](https://mastra.ai/docs/long-running-agents/signals).
|
|
46
46
|
- **Event system**: Subscribe to typed events (message updates, mode changes, tool approvals) or coalesced `AgentControllerDisplayState` snapshots to drive your UI. See [Events](https://mastra.ai/reference/agent-controller/agent-controller-class).
|
|
47
47
|
- **Observational memory**: Automatic summarization and reflection across threads for long-running agent sessions. See [Observational memory](https://mastra.ai/docs/memory/observational-memory).
|
|
48
48
|
|
|
@@ -101,7 +101,7 @@ A user may want to add to the conversation while the agent is still working. Ins
|
|
|
101
101
|
const queued = agentController.session.followUps.count()
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
Queue a follow-up with `agentController.followUp({ content })`. To redirect the agent mid-run instead of waiting, use `agentController.steer({ content })`. Both build on [signals](https://mastra.ai/docs/agents/signals).
|
|
104
|
+
Queue a follow-up with `agentController.followUp({ content })`. To redirect the agent mid-run instead of waiting, use `agentController.steer({ content })`. Both build on [signals](https://mastra.ai/docs/long-running-agents/signals).
|
|
105
105
|
|
|
106
106
|
## State
|
|
107
107
|
|
|
@@ -203,7 +203,7 @@ Once your agent is running, use this table to find the right page for what you w
|
|
|
203
203
|
| Keep your agent safe | [Guardrails](https://mastra.ai/docs/agents/guardrails) |
|
|
204
204
|
| Build agents that correct their work | [Rubric scorer](https://mastra.ai/docs/agents/supervisor-agents) |
|
|
205
205
|
| Swap instructions or models based on request context | [Dynamic configuration](https://mastra.ai/docs/server/request-context) |
|
|
206
|
-
| Add speech-to-text or text-to-speech | [Voice](https://mastra.ai/docs/
|
|
206
|
+
| Add speech-to-text or text-to-speech | [Voice](https://mastra.ai/docs/voice/overview) |
|
|
207
207
|
| Connect to Slack, Discord, or Telegram | [Channels](https://mastra.ai/docs/agents/channels) |
|
|
208
208
|
|
|
209
209
|
## Multi-agent systems
|
|
@@ -638,7 +638,7 @@ Do not mention the reminder to the user or quote the tags back to them.`,
|
|
|
638
638
|
await agent.generate('Your prompt', { maxSteps: MAX_STEPS })
|
|
639
639
|
```
|
|
640
640
|
|
|
641
|
-
> **Note:** Reactive signals default to `tagName: 'system-reminder'`. Visit [Signals](https://mastra.ai/docs/agents/signals) for more on processor-emitted signals.
|
|
641
|
+
> **Note:** Reactive signals default to `tagName: 'system-reminder'`. Visit [Signals](https://mastra.ai/docs/long-running-agents/signals) for more on processor-emitted signals.
|
|
642
642
|
|
|
643
643
|
### Emit custom stream events
|
|
644
644
|
|
|
@@ -374,7 +374,7 @@ Success criteria:
|
|
|
374
374
|
|
|
375
375
|
## Running subagents in the background
|
|
376
376
|
|
|
377
|
-
Subagent invocations are dispatched as tool calls, so they can run as [background tasks](https://mastra.ai/docs/agents/background-tasks). This is useful when one or more delegations are long-running and you don't want them to block the supervisor's response.
|
|
377
|
+
Subagent invocations are dispatched as tool calls, so they can run as [background tasks](https://mastra.ai/docs/long-running-agents/background-tasks). This is useful when one or more delegations are long-running and you don't want them to block the supervisor's response.
|
|
378
378
|
|
|
379
379
|
Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration) on the Mastra instance, then opt subagents in on the supervisor:
|
|
380
380
|
|
|
@@ -399,7 +399,7 @@ const stream = await supervisor.streamUntilIdle('Research AI in education and wr
|
|
|
399
399
|
|
|
400
400
|
Use [`streamUntilIdle()`](https://mastra.ai/reference/streaming/agents/streamUntilIdle) instead of `stream()` so the stream stays open until the subagents complete and the supervisor has had a chance to respond to their results.
|
|
401
401
|
|
|
402
|
-
If a subagent isn't listed on the supervisor but has its own background-eligible tools, the supervisor still dispatches the subagent as a background task and inherits its config. See [Inheriting from the subagent](https://mastra.ai/docs/agents/background-tasks) for details.
|
|
402
|
+
If a subagent isn't listed on the supervisor but has its own background-eligible tools, the supervisor still dispatches the subagent as a background task and inherits its config. See [Inheriting from the subagent](https://mastra.ai/docs/long-running-agents/background-tasks) for details.
|
|
403
403
|
|
|
404
404
|
## Subagent versioning
|
|
405
405
|
|
|
@@ -420,7 +420,7 @@ Version overrides propagate automatically through delegation. See [Subagent vers
|
|
|
420
420
|
|
|
421
421
|
## Related
|
|
422
422
|
|
|
423
|
-
- [Background tasks](https://mastra.ai/docs/agents/background-tasks)
|
|
423
|
+
- [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks)
|
|
424
424
|
- [Subagent versioning](https://mastra.ai/docs/editor/overview)
|
|
425
425
|
- [Guide: Research coordinator](https://mastra.ai/guides/guide/research-coordinator)
|
|
426
426
|
- [Agent.stream() reference](https://mastra.ai/reference/streaming/agents/stream)
|
|
@@ -415,7 +415,7 @@ Note that for subagents, you'll see two different identifiers in stream response
|
|
|
415
415
|
|
|
416
416
|
- [`createTool` reference](https://mastra.ai/reference/tools/create-tool)
|
|
417
417
|
- [`Agent.generate()` reference](https://mastra.ai/reference/agents/generate): Runtime options for tool selection, steps, and callbacks
|
|
418
|
-
- [Background tasks](https://mastra.ai/docs/agents/background-tasks): Run long-running tools without blocking the agent loop
|
|
418
|
+
- [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks): Run long-running tools without blocking the agent loop
|
|
419
419
|
- [MCP overview](https://mastra.ai/docs/mcp/overview)
|
|
420
420
|
- [Dynamic tool search](https://mastra.ai/reference/processors/tool-search-processor): Load tools on demand for agents with large tool libraries
|
|
421
421
|
- [Tools with structured output](https://mastra.ai/docs/agents/structured-output): Model compatibility when combining tools and structured output
|
|
@@ -121,7 +121,7 @@ If the agent has `backgroundTasks.disabled: true`, every tool call runs synchron
|
|
|
121
121
|
|
|
122
122
|
## Background tasks related stream chunks
|
|
123
123
|
|
|
124
|
-
When a tool call dispatches as a background task, two streams may surface lifecycle events for it: the agent's own stream and the [`backgroundTaskManager.stream()`](https://mastra.ai/docs/agents/background-tasks) SSE stream. Each stream covers a different set of chunk types:
|
|
124
|
+
When a tool call dispatches as a background task, two streams may surface lifecycle events for it: the agent's own stream and the [`backgroundTaskManager.stream()`](https://mastra.ai/docs/long-running-agents/background-tasks) SSE stream. Each stream covers a different set of chunk types:
|
|
125
125
|
|
|
126
126
|
| Chunk type | When it fires | Emitted by |
|
|
127
127
|
| --------------------------- | -------------------------------------------------------------------------------------- | -------------- |
|
|
@@ -376,7 +376,7 @@ These read from storage rather than the pubsub stream, so they're suitable for p
|
|
|
376
376
|
|
|
377
377
|
- [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
|
|
378
378
|
- [backgroundTasks configuration reference](https://mastra.ai/reference/configuration)
|
|
379
|
-
- [Durable agents](https://mastra.ai/docs/agents/durable-agents)
|
|
379
|
+
- [Durable agents](https://mastra.ai/docs/long-running-agents/durable-agents)
|
|
380
380
|
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
381
381
|
- [Stream chunk types](https://mastra.ai/reference/streaming/ChunkType)
|
|
382
382
|
- [Storage](https://mastra.ai/docs/memory/storage)
|
|
@@ -199,7 +199,7 @@ await durableAgent.stream('Research topic', {
|
|
|
199
199
|
})
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
> **Note:** Visit [Background tasks](https://mastra.ai/docs/agents/background-tasks) for the full background task guide, including configuration, subagents, and suspend/resume.
|
|
202
|
+
> **Note:** Visit [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks) for the full background task guide, including configuration, subagents, and suspend/resume.
|
|
203
203
|
|
|
204
204
|
## Cleanup
|
|
205
205
|
|
|
@@ -228,6 +228,6 @@ await durableAgent.resume(runId, { approved: true })
|
|
|
228
228
|
|
|
229
229
|
- [DurableAgent reference](https://mastra.ai/reference/agents/durable-agent)
|
|
230
230
|
- [`createInngestAgent()` reference](https://mastra.ai/reference/agents/inngest-agent)
|
|
231
|
-
- [Background tasks](https://mastra.ai/docs/agents/background-tasks)
|
|
231
|
+
- [Background tasks](https://mastra.ai/docs/long-running-agents/background-tasks)
|
|
232
232
|
- [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest)
|
|
233
233
|
- [Agent overview](https://mastra.ai/docs/agents/overview)
|
|
@@ -110,5 +110,5 @@ Per-objective values written by `setObjective` / `updateObjectiveOptions` take p
|
|
|
110
110
|
## Related
|
|
111
111
|
|
|
112
112
|
- [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) — `isTaskComplete` and the rubric scorer
|
|
113
|
-
- [Signal providers](https://mastra.ai/docs/agents/signal-providers) — how the objective is projected into context
|
|
113
|
+
- [Signal providers](https://mastra.ai/docs/long-running-agents/signal-providers) — how the objective is projected into context
|
|
114
114
|
- [Memory storage](https://mastra.ai/docs/memory/storage) — the storage backend goals require
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
> **Beta:** This feature is in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
|
-
A heartbeat runs an agent on a cron schedule. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/agents/signals) into a thread or as a threadless `agent.generate()` run. Use heartbeats for recurring agent work such as daily summaries, periodic checks, or scheduled nudges into a conversation.
|
|
9
|
+
A heartbeat runs an agent on a cron schedule. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/long-running-agents/signals) into a thread or as a threadless `agent.generate()` run. Use heartbeats for recurring agent work such as daily summaries, periodic checks, or scheduled nudges into a conversation.
|
|
10
10
|
|
|
11
11
|
Heartbeats are persisted, so they survive restarts and redeploys. Manage them at runtime through `mastra.heartbeats`, the canonical create, read, update, and delete (CRUD) surface.
|
|
12
12
|
|
|
@@ -73,7 +73,7 @@ Without a `threadId`, each fire is an isolated `agent.generate()` run. Nothing i
|
|
|
73
73
|
|
|
74
74
|
### Threaded
|
|
75
75
|
|
|
76
|
-
With a `threadId`, the heartbeat sends a [signal](https://mastra.ai/docs/agents/signals) into that thread, so the prompt joins the agent's conversation. Threaded heartbeats require a `resourceId` alongside the `threadId`.
|
|
76
|
+
With a `threadId`, the heartbeat sends a [signal](https://mastra.ai/docs/long-running-agents/signals) into that thread, so the prompt joins the agent's conversation. Threaded heartbeats require a `resourceId` alongside the `threadId`.
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
79
|
await mastra.heartbeats.create({
|
|
@@ -85,9 +85,9 @@ await mastra.heartbeats.create({
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
Threaded heartbeats accept extra fields that control how the signal behaves. They mirror the options [`agent.sendSignal`](https://mastra.ai/docs/agents/signals) accepts and stay JSON-serializable so they persist with the schedule.
|
|
88
|
+
Threaded heartbeats accept extra fields that control how the signal behaves. They mirror the options [`agent.sendSignal`](https://mastra.ai/docs/long-running-agents/signals) accepts and stay JSON-serializable so they persist with the schedule.
|
|
89
89
|
|
|
90
|
-
- `signalType`: the [signal type](https://mastra.ai/docs/agents/signals) to send, for example `notification` or `system-reminder`. Defaults to `notification`.
|
|
90
|
+
- `signalType`: the [signal type](https://mastra.ai/docs/long-running-agents/signals) to send, for example `notification` or `system-reminder`. Defaults to `notification`.
|
|
91
91
|
- `tagName`: the XML tag the signal renders as. Defaults to `heartbeat`, so a fire surfaces to the agent as `<heartbeat>…</heartbeat>`.
|
|
92
92
|
- `attributes`: values rendered onto the signal's XML tag.
|
|
93
93
|
- `ifActive`: behavior when the thread is already streaming, as `{ behavior, attributes }`. `behavior` is one of `deliver`, `persist`, or `discard`.
|
|
@@ -209,5 +209,5 @@ Hook exceptions are caught and logged. They never re-route the worker or trigger
|
|
|
209
209
|
|
|
210
210
|
## Related
|
|
211
211
|
|
|
212
|
-
- [Signals](https://mastra.ai/docs/agents/signals): the delivery mechanism behind threaded heartbeats.
|
|
212
|
+
- [Signals](https://mastra.ai/docs/long-running-agents/signals): the delivery mechanism behind threaded heartbeats.
|
|
213
213
|
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows): run a workflow, rather than an agent, on a cron schedule.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
> **Beta:** This feature is in beta. Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
|
-
A signal provider monitors an external source, such as GitHub, Slack, continuous integration (CI), or your own API, and pushes [notification signals](https://mastra.ai/docs/agents/signals) into subscribed agent threads.
|
|
9
|
+
A signal provider monitors an external source, such as GitHub, Slack, continuous integration (CI), or your own API, and pushes [notification signals](https://mastra.ai/docs/long-running-agents/signals) into subscribed agent threads.
|
|
10
10
|
|
|
11
11
|
## When to use a signal provider
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ If you only need to push a one-off event into a thread, call [`agent.sendNotific
|
|
|
20
20
|
|
|
21
21
|
## How signal providers work
|
|
22
22
|
|
|
23
|
-
A signal provider is the producing side of the [signals](https://mastra.ai/docs/agents/signals) system. It brings external events into a thread, while the signal APIs control how the thread consumes them.
|
|
23
|
+
A signal provider is the producing side of the [signals](https://mastra.ai/docs/long-running-agents/signals) system. It brings external events into a thread, while the signal APIs control how the thread consumes them.
|
|
24
24
|
|
|
25
25
|
A signal provider combines three capabilities:
|
|
26
26
|
|
|
@@ -218,7 +218,7 @@ export const devAgent = new Agent({
|
|
|
218
218
|
## Related
|
|
219
219
|
|
|
220
220
|
- [Guide: Building a signal provider](https://mastra.ai/guides/guide/signal-provider)
|
|
221
|
-
- [Signals](https://mastra.ai/docs/agents/signals)
|
|
222
|
-
- [Notification signals](https://mastra.ai/docs/agents/signals)
|
|
221
|
+
- [Signals](https://mastra.ai/docs/long-running-agents/signals)
|
|
222
|
+
- [Notification signals](https://mastra.ai/docs/long-running-agents/signals)
|
|
223
223
|
- [`SignalProvider` reference](https://mastra.ai/reference/signals/signal-provider)
|
|
224
224
|
- [`WebhookSignalProvider` reference](https://mastra.ai/reference/signals/webhook-signal-provider)
|
|
@@ -399,7 +399,7 @@ const response = await agent.generate('What do you know about me?', {
|
|
|
399
399
|
|
|
400
400
|
## Opt in to state signals (experimental)
|
|
401
401
|
|
|
402
|
-
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/agents/signals) instead by setting `useStateSignals: true`:
|
|
402
|
+
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/long-running-agents/signals) instead by setting `useStateSignals: true`:
|
|
403
403
|
|
|
404
404
|
```typescript
|
|
405
405
|
const memory = new Memory({
|
|
@@ -96,8 +96,7 @@ export const observability = new Observability({
|
|
|
96
96
|
In serverless environments, flush observability exporters before the runtime pauses or exits:
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
|
-
|
|
100
|
-
await observability.flush()
|
|
99
|
+
await mastra.observability.flush()
|
|
101
100
|
```
|
|
102
101
|
|
|
103
102
|
Use external storage in serverless environments instead of local file storage. For storage selection and routing, see [Storage](https://mastra.ai/docs/observability/storage).
|
|
@@ -12,7 +12,7 @@ Several built-in systems publish and subscribe to events through the same pub/su
|
|
|
12
12
|
|
|
13
13
|
- **Workflow execution**: The scheduler publishes a `workflow.start` event, and a long-lived worker consumes it to run the workflow. Step and lifecycle events flow over pub/sub during execution.
|
|
14
14
|
- **Scheduled workflows**: The scheduler dispatches due runs by publishing to the workflow topic. See [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows).
|
|
15
|
-
- **Background tasks**: A task manager dispatches work to a worker group and fans task lifecycle updates out to subscribers, which is how background task streams stay live. See [Background task streaming](https://mastra.ai/docs/agents/background-tasks).
|
|
15
|
+
- **Background tasks**: A task manager dispatches work to a worker group and fans task lifecycle updates out to subscribers, which is how background task streams stay live. See [Background task streaming](https://mastra.ai/docs/long-running-agents/background-tasks).
|
|
16
16
|
- **Agent signals**: Sending a signal to an active agent run publishes an event on a thread topic, so a run executing in another process receives the signal.
|
|
17
17
|
- **Resumable streams**: Stream chunks are published per run, so a client that reconnects can replay what it missed.
|
|
18
18
|
|
|
@@ -122,5 +122,5 @@ export const mastra = new Mastra({
|
|
|
122
122
|
|
|
123
123
|
- [PubSub reference](https://mastra.ai/reference/pubsub/base)
|
|
124
124
|
- [Mastra class](https://mastra.ai/reference/core/mastra-class)
|
|
125
|
-
- [Background task streaming](https://mastra.ai/docs/agents/background-tasks)
|
|
125
|
+
- [Background task streaming](https://mastra.ai/docs/long-running-agents/background-tasks)
|
|
126
126
|
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows)
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Mastra's Voice system provides a unified interface for voice interactions, enabling text-to-speech (TTS), speech-to-text (STT), and real-time speech-to-speech (STS) capabilities in your applications.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Add voice to agents
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Pass a voice provider to an agent with the `voice` property. The same property supports text-to-speech (TTS), speech-to-text (STT), and real-time speech-to-speech (STS), depending on the provider you configure.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -1139,7 +1139,7 @@ const voiceAgent = new Agent({
|
|
|
1139
1139
|
})
|
|
1140
1140
|
```
|
|
1141
1141
|
|
|
1142
|
-
### Using
|
|
1142
|
+
### Using multiple voice providers
|
|
1143
1143
|
|
|
1144
1144
|
This example demonstrates how to create and use two different voice providers in Mastra: OpenAI for speech-to-text (STT) and PlayAI for text-to-speech (TTS).
|
|
1145
1145
|
|
|
@@ -54,7 +54,87 @@ const micStream = getMicrophoneStream()
|
|
|
54
54
|
await agent.voice.send(micStream)
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
For
|
|
57
|
+
For a broader overview of voice providers on agents, see [Voice in Mastra](https://mastra.ai/docs/voice/overview).
|
|
58
|
+
|
|
59
|
+
## Use tools in realtime sessions
|
|
60
|
+
|
|
61
|
+
Realtime voice providers can use tools configured on the agent. Add the tools to the `Agent` definition, then connect and send audio through the voice provider:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { Agent } from '@mastra/core/agent'
|
|
65
|
+
import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
|
|
66
|
+
import { calculate, search } from '../tools'
|
|
67
|
+
|
|
68
|
+
export const agent = new Agent({
|
|
69
|
+
id: 'speech-to-speech-agent',
|
|
70
|
+
name: 'Speech-to-Speech Agent',
|
|
71
|
+
instructions: 'You are a helpful assistant with speech-to-speech capabilities.',
|
|
72
|
+
model: 'openai/gpt-5.5',
|
|
73
|
+
tools: {
|
|
74
|
+
search,
|
|
75
|
+
calculate,
|
|
76
|
+
},
|
|
77
|
+
voice: new OpenAIRealtimeVoice(),
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Listen for realtime events
|
|
82
|
+
|
|
83
|
+
Realtime voice providers emit events you can use to update your UI, play assistant audio, log transcriptions, and handle errors:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
agent.voice.on('speaking', ({ audio }) => {
|
|
87
|
+
playAudio(audio)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
agent.voice.on('writing', ({ text, role }) => {
|
|
91
|
+
console.log(`${role}: ${text}`)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
agent.voice.on('error', error => {
|
|
95
|
+
console.error('Voice error:', error)
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Event names and payloads vary by provider. Check the provider section below or the provider reference for the full event list.
|
|
100
|
+
|
|
101
|
+
## Per-session voice instances
|
|
102
|
+
|
|
103
|
+
A static `voice` instance is shared across every request. This works for one-shot text-to-speech, but real-time and speech-to-speech providers store session state such as the WebSocket connection, tools, instructions, and request context. If one agent handles several live sessions at once, a shared instance can let one session overwrite another session's state.
|
|
104
|
+
|
|
105
|
+
Provide `voice` as a resolver when each live session needs its own voice instance. Mastra runs the resolver on each `getVoice()` call and returns a fresh instance for that request context:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { Agent } from '@mastra/core/agent'
|
|
109
|
+
import { RequestContext } from '@mastra/core/request-context'
|
|
110
|
+
import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
|
|
111
|
+
|
|
112
|
+
export const agent = new Agent({
|
|
113
|
+
id: 'support-line',
|
|
114
|
+
name: 'Support Line',
|
|
115
|
+
instructions: ({ requestContext }) => `Help user ${requestContext.get('user')}.`,
|
|
116
|
+
model: 'openai/gpt-5.5',
|
|
117
|
+
voice: ({ requestContext }) =>
|
|
118
|
+
new OpenAIRealtimeVoice({
|
|
119
|
+
apiKey: requestContext.get('apiKey'),
|
|
120
|
+
}),
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const requestContext = new RequestContext()
|
|
124
|
+
requestContext.set('user', 'user-123')
|
|
125
|
+
requestContext.set('apiKey', process.env.OPENAI_API_KEY)
|
|
126
|
+
|
|
127
|
+
const voice = await agent.getVoice({ requestContext })
|
|
128
|
+
await voice.connect()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
When you use a resolver:
|
|
132
|
+
|
|
133
|
+
- Each call to `getVoice()` returns a new instance, so concurrent sessions don't share state.
|
|
134
|
+
- Mastra doesn't add tools or instructions to a resolver instance. Configure them inside the resolver or on the provider.
|
|
135
|
+
- You own the returned instance lifecycle, so call `disconnect()` or `close()` when the session ends.
|
|
136
|
+
|
|
137
|
+
The `agent.voice` getter has no request context, so it throws when `voice` is a resolver. Use `agent.getVoice({ requestContext })` instead.
|
|
58
138
|
|
|
59
139
|
## Google Gemini Live (Realtime)
|
|
60
140
|
|
|
@@ -78,4 +78,22 @@ const { text } = await agent.generate(
|
|
|
78
78
|
console.log(`Recommendation: ${text}`)
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
## Transcribe an audio file
|
|
82
|
+
|
|
83
|
+
The `listen()` method accepts a stream of audio data from a microphone or file. Use `createReadStream()` when you want to transcribe an audio file:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { createReadStream } from 'fs'
|
|
87
|
+
import path from 'path'
|
|
88
|
+
|
|
89
|
+
const audioFilePath = path.join(process.cwd(), 'agent.m4a')
|
|
90
|
+
const audioStream = createReadStream(audioFilePath)
|
|
91
|
+
|
|
92
|
+
const transcription = await agent.voice.listen(audioStream, {
|
|
93
|
+
filetype: 'm4a',
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
console.log(`Transcription: ${transcription}`)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For a broader overview of voice providers on agents, see [Voice in Mastra](https://mastra.ai/docs/voice/overview).
|
|
@@ -82,4 +82,24 @@ const readableStream = await voice.speak(text, {
|
|
|
82
82
|
})
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
## Save speech output
|
|
86
|
+
|
|
87
|
+
The `speak()` method returns an audio stream. Pipe the stream to a file when you need to save generated speech for later playback or processing:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { createWriteStream } from 'fs'
|
|
91
|
+
import path from 'path'
|
|
92
|
+
|
|
93
|
+
const audio = await agent.voice.speak('Hello, world!')
|
|
94
|
+
const filePath = path.join(process.cwd(), 'agent.mp3')
|
|
95
|
+
const writer = createWriteStream(filePath)
|
|
96
|
+
|
|
97
|
+
audio.pipe(writer)
|
|
98
|
+
|
|
99
|
+
await new Promise<void>((resolve, reject) => {
|
|
100
|
+
writer.on('finish', () => resolve())
|
|
101
|
+
writer.on('error', reject)
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For a broader overview of voice providers on agents, see [Voice in Mastra](https://mastra.ai/docs/voice/overview).
|
|
@@ -862,5 +862,5 @@ export const testWorkflow = createWorkflow({...})
|
|
|
862
862
|
|
|
863
863
|
## Related
|
|
864
864
|
|
|
865
|
-
- [Suspend
|
|
865
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
866
866
|
- [Human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop)
|
|
@@ -357,6 +357,6 @@ for await (const chunk of stream.stream) {
|
|
|
357
357
|
## Related
|
|
358
358
|
|
|
359
359
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
360
|
-
- [Suspend
|
|
360
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
361
361
|
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
362
362
|
- [Human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop)
|
|
@@ -214,4 +214,4 @@ const handleDelete = async () => {
|
|
|
214
214
|
## Related
|
|
215
215
|
|
|
216
216
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
217
|
-
- [Suspend
|
|
217
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
@@ -545,5 +545,5 @@ For a closer look at workflows, see our [Workflow Guide](https://mastra.ai/guide
|
|
|
545
545
|
|
|
546
546
|
- [Workflow State](https://mastra.ai/docs/workflows/workflow-state)
|
|
547
547
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
548
|
-
- [Suspend
|
|
548
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
549
549
|
- [Error Handling](https://mastra.ai/docs/workflows/error-handling)
|
|
@@ -235,6 +235,6 @@ if (result.status === 'suspended') {
|
|
|
235
235
|
## Related
|
|
236
236
|
|
|
237
237
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
238
|
-
- [Suspend
|
|
238
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
239
239
|
- [Time Travel](https://mastra.ai/docs/workflows/time-travel)
|
|
240
240
|
- [Human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
2
|
|
|
3
|
-
# Suspend
|
|
3
|
+
# Suspend and resume
|
|
4
4
|
|
|
5
5
|
Workflows can be paused at any step to collect additional data, wait for API callbacks, throttle costly operations, or request [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) input. When a workflow is suspended, its current execution state is saved as a snapshot. You can later resume the workflow from a [specific step ID](https://mastra.ai/docs/workflows/snapshots), restoring the exact state captured in that snapshot. [Snapshots](https://mastra.ai/docs/workflows/snapshots) are stored in your configured storage provider and persist across deployments and application restarts.
|
|
6
6
|
|
|
@@ -306,6 +306,6 @@ const result = await run.timeTravel({
|
|
|
306
306
|
## Related
|
|
307
307
|
|
|
308
308
|
- [Snapshots](https://mastra.ai/docs/workflows/snapshots)
|
|
309
|
-
- [Suspend
|
|
309
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
310
310
|
- [Error Handling](https://mastra.ai/docs/workflows/error-handling)
|
|
311
311
|
- [Control Flow](https://mastra.ai/docs/workflows/control-flow)
|
|
@@ -178,6 +178,6 @@ const parentWorkflow = createWorkflow({
|
|
|
178
178
|
## Related
|
|
179
179
|
|
|
180
180
|
- [Workflows overview](https://mastra.ai/docs/workflows/overview)
|
|
181
|
-
- [Suspend
|
|
181
|
+
- [Suspend and Resume](https://mastra.ai/docs/workflows/suspend-and-resume)
|
|
182
182
|
- [Step Class](https://mastra.ai/reference/workflows/step)
|
|
183
183
|
- [Workflow Class](https://mastra.ai/reference/workflows/workflow)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# CopilotKit channels
|
|
4
|
+
|
|
5
|
+
The same Mastra agent that powers your in-app copilot can also run as a bot in messaging platforms. CopilotKit's bot layer connects your agent to Slack, Discord, Telegram, WhatsApp, and Microsoft Teams, with threads, tool calls, and human-in-the-loop approvals handled in the channel.
|
|
6
|
+
|
|
7
|
+
> **Info:** The full setup lives in the [CopilotKit bot documentation](https://docs.copilotkit.ai/slack). This page shows how it fits together with a Mastra agent.
|
|
8
|
+
|
|
9
|
+
## How it fits together
|
|
10
|
+
|
|
11
|
+
Your Mastra agent stays where it is, exposed through `registerCopilotKit()` as described in [CopilotKit overview](https://mastra.ai/guides/build-your-ui/copilotkit/overview). The bot is a separate process built with `@copilotkit/bot`: you attach one or more platform adapters and point the bot at your agent. `createBot` takes an array of adapters, so a single bot can serve several platforms at once.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createBot } from '@copilotkit/bot'
|
|
15
|
+
import { slack } from '@copilotkit/bot-slack'
|
|
16
|
+
|
|
17
|
+
const bot = createBot({
|
|
18
|
+
adapters: [
|
|
19
|
+
slack({
|
|
20
|
+
botToken: process.env.SLACK_BOT_TOKEN!,
|
|
21
|
+
appToken: process.env.SLACK_APP_TOKEN!,
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
// Point the bot at your agent.
|
|
25
|
+
agent: threadId => {
|
|
26
|
+
// ...connect to your CopilotKit runtime / Mastra agent
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
bot.onMention(async ({ thread }) => {
|
|
31
|
+
await thread.runAgent()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
await bot.start()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Rich messages are written as JSX and rendered to each platform's native message format (Block Kit on Slack, for example), so an interactive card degrades gracefully where a platform has no equivalent.
|
|
38
|
+
|
|
39
|
+
## Slack
|
|
40
|
+
|
|
41
|
+
The [Slack quickstart](https://docs.copilotkit.ai/slack) takes you from zero to a bot you can `@`-mention in a channel, then adds an interactive button card. Slack runs over Socket Mode, which opens an outbound WebSocket to Slack, so no public URL or tunnel is required during development.
|
|
42
|
+
|
|
43
|
+
Install the packages:
|
|
44
|
+
|
|
45
|
+
**npm**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @copilotkit/bot @copilotkit/bot-ui @copilotkit/bot-slack
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**pnpm**:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pnpm add @copilotkit/bot @copilotkit/bot-ui @copilotkit/bot-slack
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Yarn**:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
yarn add @copilotkit/bot @copilotkit/bot-ui @copilotkit/bot-slack
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Bun**:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bun add @copilotkit/bot @copilotkit/bot-ui @copilotkit/bot-slack
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Set the Slack credentials in your environment:
|
|
70
|
+
|
|
71
|
+
- `SLACK_BOT_TOKEN`: Bot User OAuth token (`xoxb-...`)
|
|
72
|
+
- `SLACK_APP_TOKEN`: App-level token with the `connections:write` scope (`xapp-...`)
|
|
73
|
+
|
|
74
|
+
## Other platforms
|
|
75
|
+
|
|
76
|
+
The bot adapters share one `@copilotkit/bot` API and differ only in what each platform natively supports. For Discord, Telegram, WhatsApp, and Microsoft Teams, set the relevant platform credentials and add the matching adapter to the `adapters` array. See the [CopilotKit bot documentation](https://docs.copilotkit.ai/slack) for platform-specific setup.
|