@mastra/mcp-docs-server 1.1.42-alpha.8 → 1.1.43-alpha.0
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 +1 -1
- package/.docs/docs/agents/a2a.md +1 -1
- package/.docs/docs/agents/acp.md +23 -160
- package/.docs/docs/agents/adding-voice.md +7 -7
- package/.docs/docs/agents/agent-approval.md +1 -1
- package/.docs/docs/agents/background-tasks.md +2 -2
- package/.docs/docs/agents/channels.md +1 -1
- package/.docs/docs/agents/code-mode.md +3 -3
- package/.docs/docs/agents/guardrails.md +2 -2
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +146 -3
- package/.docs/docs/agents/sdk-agents.md +261 -0
- package/.docs/docs/agents/signals.md +230 -10
- package/.docs/docs/agents/structured-output.md +5 -5
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +5 -5
- package/.docs/docs/browser/agent-browser.md +1 -1
- package/.docs/docs/browser/browser-viewer.md +1 -1
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/browser/stagehand.md +5 -5
- package/.docs/docs/build-with-ai/skills.md +3 -3
- package/.docs/docs/editor/overview.md +12 -11
- package/.docs/docs/evals/custom-scorers.md +1 -1
- package/.docs/docs/evals/datasets/running-experiments.md +1 -1
- package/.docs/docs/evals/overview.md +2 -2
- package/.docs/docs/getting-started/build-with-ai.md +37 -0
- package/.docs/docs/mastra-platform/observability.md +4 -4
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +1 -1
- package/.docs/docs/memory/memory-processors.md +6 -6
- package/.docs/docs/memory/multi-user-threads.md +2 -2
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/storage.md +2 -1
- package/.docs/docs/memory/working-memory.md +28 -1
- package/.docs/docs/observability/metrics/querying.md +1 -1
- package/.docs/docs/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/docs/observability/tracing/exporters/langsmith.md +2 -2
- package/.docs/docs/rag/graph-rag.md +2 -2
- package/.docs/docs/rag/retrieval.md +12 -12
- package/.docs/docs/server/auth/fga.md +2 -0
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/pubsub.md +124 -0
- package/.docs/docs/server/request-context.md +3 -3
- package/.docs/docs/streaming/overview.md +1 -1
- package/.docs/docs/streaming/tool-streaming.md +1 -1
- package/.docs/docs/studio/auth.md +20 -0
- package/.docs/docs/voice/overview.md +25 -25
- package/.docs/docs/voice/speech-to-speech.md +4 -4
- package/.docs/docs/voice/speech-to-text.md +1 -1
- package/.docs/docs/voice/text-to-speech.md +1 -1
- package/.docs/docs/workspace/filesystem.md +2 -2
- package/.docs/docs/workspace/overview.md +1 -1
- package/.docs/docs/workspace/sandbox.md +1 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -1
- package/.docs/guides/guide/ai-recruiter.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +1 -1
- package/.docs/guides/guide/firecrawl.md +1 -1
- package/.docs/guides/guide/github-actions-pr-description.md +1 -1
- package/.docs/guides/guide/research-assistant.md +1 -1
- package/.docs/guides/guide/research-coordinator.md +2 -2
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +2 -2
- package/.docs/guides/guide/whatsapp-chat-bot.md +2 -2
- package/.docs/guides/migrations/agentnetwork.md +4 -4
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/reference/acp/acp-agent.md +228 -0
- package/.docs/reference/acp/create-acp-tool.md +131 -0
- package/.docs/reference/agents/agent.md +55 -5
- package/.docs/reference/agents/channels.md +47 -5
- package/.docs/reference/agents/durable-agent.md +239 -0
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/agents/getLLM.md +2 -2
- package/.docs/reference/agents/getMetadata.md +2 -2
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +5 -5
- package/.docs/reference/cli/mastra.md +5 -5
- package/.docs/reference/client-js/agents.md +41 -7
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/answer-similarity.md +1 -1
- package/.docs/reference/evals/bias.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +11 -11
- package/.docs/reference/evals/faithfulness.md +1 -1
- package/.docs/reference/evals/hallucination.md +5 -5
- package/.docs/reference/evals/noise-sensitivity.md +11 -11
- package/.docs/reference/evals/prompt-alignment.md +15 -15
- package/.docs/reference/evals/tool-call-accuracy.md +3 -3
- package/.docs/reference/evals/toxicity.md +1 -1
- package/.docs/reference/index.md +9 -0
- package/.docs/reference/memory/memory-class.md +3 -3
- package/.docs/reference/memory/observational-memory.md +4 -4
- package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +2 -2
- package/.docs/reference/processors/pii-detector.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +2 -2
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/response-cache.md +2 -2
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/skill-search-processor.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +3 -3
- package/.docs/reference/processors/tool-call-filter.md +2 -2
- package/.docs/reference/processors/tool-search-processor.md +2 -2
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/pubsub/base.md +168 -0
- package/.docs/reference/pubsub/caching-pubsub.md +102 -0
- package/.docs/reference/pubsub/event-emitter.md +72 -0
- package/.docs/reference/pubsub/google-cloud-pubsub.md +94 -0
- package/.docs/reference/pubsub/redis-streams.md +108 -0
- package/.docs/reference/pubsub/unix-socket-pubsub.md +52 -0
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/storage/dsql.md +1 -1
- package/.docs/reference/storage/libsql.md +6 -0
- package/.docs/reference/storage/mongodb.md +4 -1
- package/.docs/reference/storage/postgresql.md +4 -1
- package/.docs/reference/storage/redis.md +1 -1
- package/.docs/reference/storage/spanner.md +5 -0
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +33 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/upstash.md +1 -1
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +1 -1
- package/.docs/reference/workspace/e2b-sandbox.md +9 -5
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/gcs-filesystem.md +1 -1
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/CHANGELOG.md +38 -0
- package/package.json +6 -6
- package/.docs/docs/agents/response-caching.md +0 -150
|
@@ -117,7 +117,7 @@ export const chatAgent = new Agent({
|
|
|
117
117
|
|
|
118
118
|
Always aim to be helpful while maintaining a friendly, approachable conversation style.
|
|
119
119
|
`,
|
|
120
|
-
model: 'openai/gpt-5.
|
|
120
|
+
model: 'openai/gpt-5.5',
|
|
121
121
|
memory: new Memory({
|
|
122
122
|
storage: new LibSQLStore({
|
|
123
123
|
id: 'agent-storage',
|
|
@@ -155,7 +155,7 @@ export const textMessageAgent = new Agent({
|
|
|
155
155
|
|
|
156
156
|
Always return exactly 5-8 messages in the messages array.
|
|
157
157
|
`,
|
|
158
|
-
model: 'openai/gpt-5.
|
|
158
|
+
model: 'openai/gpt-5.5',
|
|
159
159
|
memory: new Memory({
|
|
160
160
|
storage: new LibSQLStore({
|
|
161
161
|
id: 'agent-storage',
|
|
@@ -27,7 +27,7 @@ const agent = new AgentNetwork({
|
|
|
27
27
|
name: 'agent-network',
|
|
28
28
|
agents: [agent1, agent2],
|
|
29
29
|
tools: { tool1, tool2 },
|
|
30
|
-
model: 'openai/gpt-5.
|
|
30
|
+
model: 'openai/gpt-5.5',
|
|
31
31
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
32
32
|
})
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@ const agent = new Agent({
|
|
|
47
47
|
name: 'agent-network',
|
|
48
48
|
agents: { agent1, agent2 },
|
|
49
49
|
tools: { tool1, tool2 },
|
|
50
|
-
model: 'openai/gpt-5.
|
|
50
|
+
model: 'openai/gpt-5.5',
|
|
51
51
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
52
52
|
memory,
|
|
53
53
|
})
|
|
@@ -68,7 +68,7 @@ const agent = new NewAgentNetwork({
|
|
|
68
68
|
agents: { agent1, agent2 },
|
|
69
69
|
workflows: { workflow1 },
|
|
70
70
|
tools: { tool1, tool2 },
|
|
71
|
-
model: 'openai/gpt-5.
|
|
71
|
+
model: 'openai/gpt-5.5',
|
|
72
72
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
73
73
|
})
|
|
74
74
|
|
|
@@ -88,7 +88,7 @@ const agent = new Agent({
|
|
|
88
88
|
agents: { agent1, agent2 },
|
|
89
89
|
workflows: { workflow1 },
|
|
90
90
|
tools: { tool1, tool2 },
|
|
91
|
-
model: 'openai/gpt-5.
|
|
91
|
+
model: 'openai/gpt-5.5',
|
|
92
92
|
instructions: 'You are a network agent that can help users with a variety of tasks.',
|
|
93
93
|
memory,
|
|
94
94
|
})
|
|
@@ -159,7 +159,7 @@ The following options are available in the standard `.stream()` and `generate()`
|
|
|
159
159
|
name: z.string(),
|
|
160
160
|
age: z.number(),
|
|
161
161
|
}),
|
|
162
|
-
model: 'openai/gpt-5.
|
|
162
|
+
model: 'openai/gpt-5.5', // Optional model override for structuring
|
|
163
163
|
errorStrategy: 'fallback',
|
|
164
164
|
fallbackValue: { name: 'unknown', age: 0 },
|
|
165
165
|
instructions: 'Extract user information', // Override default structuring instructions
|
|
@@ -299,7 +299,7 @@ The following options are available in the standard `.stream()` and `generate()`
|
|
|
299
299
|
schema: z.object({
|
|
300
300
|
summary: z.string(),
|
|
301
301
|
}),
|
|
302
|
-
model: 'openai/gpt-5.
|
|
302
|
+
model: 'openai/gpt-5.5',
|
|
303
303
|
},
|
|
304
304
|
})
|
|
305
305
|
```
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# AcpAgent class
|
|
2
|
+
|
|
3
|
+
The `AcpAgent` class wraps an Agent Client Protocol (ACP)-compatible coding agent as a Mastra subagent. Use it when a parent Mastra agent should delegate repository inspection, code edits, or other ACP-backed tasks to a named subagent.
|
|
4
|
+
|
|
5
|
+
If you want the parent agent to call the ACP agent as a tool instead, use [`createACPTool()`](https://mastra.ai/reference/acp/create-acp-tool).
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
Register an ACP-compatible coding agent in a parent agent's `agents` map:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { AcpAgent } from '@mastra/acp'
|
|
13
|
+
import { Agent } from '@mastra/core/agent'
|
|
14
|
+
|
|
15
|
+
const codeAgent = new AcpAgent({
|
|
16
|
+
id: 'code-agent',
|
|
17
|
+
name: 'Code Agent',
|
|
18
|
+
description: 'An ACP-compatible coding agent that can inspect and edit files',
|
|
19
|
+
command: 'acp-agent',
|
|
20
|
+
args: ['--stdio'],
|
|
21
|
+
cwd: process.cwd(),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const codeSupervisor = new Agent({
|
|
25
|
+
id: 'code-supervisor',
|
|
26
|
+
name: 'Code Supervisor',
|
|
27
|
+
instructions: 'Delegate code editing tasks to the code-agent subagent.',
|
|
28
|
+
model: 'openai/gpt-5.5',
|
|
29
|
+
agents: {
|
|
30
|
+
codeAgent,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For Claude Code, ACP support is provided by the `@agentclientprotocol/claude-agent-acp` bridge package. Configure the ACP agent command to run the bridge, then select a Claude model after session creation:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { AcpAgent } from '@mastra/acp'
|
|
39
|
+
|
|
40
|
+
export const claudeCodeAgent = new AcpAgent({
|
|
41
|
+
id: 'claude-code-agent',
|
|
42
|
+
name: 'Claude Code Agent',
|
|
43
|
+
description: 'Use Claude Code through ACP.',
|
|
44
|
+
command: 'npx',
|
|
45
|
+
args: ['@agentclientprotocol/claude-agent-acp'],
|
|
46
|
+
cwd: process.cwd(),
|
|
47
|
+
model: 'claude-sonnet-4-6',
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Constructor parameters
|
|
52
|
+
|
|
53
|
+
**id** (`string`): Unique identifier for the subagent.
|
|
54
|
+
|
|
55
|
+
**name** (`string`): Display name used during agent delegation. Defaults to \`id\`.
|
|
56
|
+
|
|
57
|
+
**description** (`string`): Description shown to the model when it can delegate to this subagent.
|
|
58
|
+
|
|
59
|
+
**command** (`string`): ACP agent executable to spawn.
|
|
60
|
+
|
|
61
|
+
**args** (`string[]`): Arguments passed to the ACP agent executable. (Default: `[]`)
|
|
62
|
+
|
|
63
|
+
**env** (`Record<string, string>`): Environment variables to merge with the current process environment when spawning the ACP process.
|
|
64
|
+
|
|
65
|
+
**cwd** (`string`): Working directory for the ACP process and ACP session. Also used as the default local filesystem base path. (Default: `process.cwd()`)
|
|
66
|
+
|
|
67
|
+
**session** (`Partial<NewSessionRequest>`): ACP session creation options. Defaults to \`cwd\` or \`process.cwd()\` and an empty MCP server list.
|
|
68
|
+
|
|
69
|
+
**initialize** (`Partial<InitializeRequest>`): ACP initialization options. Defaults to Mastra client information, the current ACP protocol version, and read/write filesystem capabilities.
|
|
70
|
+
|
|
71
|
+
**authMethodId** (`string`): ACP authentication method ID to invoke after initialization and before session creation.
|
|
72
|
+
|
|
73
|
+
**persistSession** (`boolean`): Whether to keep the ACP process and session alive after each prompt. Set to \`false\` to stop the process after each prompt completes. (Default: `true`)
|
|
74
|
+
|
|
75
|
+
**onPermissionRequest** (`(request: RequestPermissionRequest) => Promise<RequestPermissionResponse>`): Callback invoked when the ACP agent requests permission. Defaults to selecting the first permission option, or cancelling when no option is available.
|
|
76
|
+
|
|
77
|
+
**workspace** (`Workspace`): Workspace used for ACP file read and write requests. Defaults to a \`Workspace\` backed by \`LocalFilesystem\` at \`cwd\` or \`process.cwd()\`.
|
|
78
|
+
|
|
79
|
+
**model** (`ModelId`): Model ID to select after ACP session creation using the ACP \`session/set\_model\` method.
|
|
80
|
+
|
|
81
|
+
## Properties
|
|
82
|
+
|
|
83
|
+
**id** (`TId`): Readonly subagent identifier from the constructor options.
|
|
84
|
+
|
|
85
|
+
**name** (`string`): Readonly display name for this subagent.
|
|
86
|
+
|
|
87
|
+
**description** (`string`): Readonly description shown when the parent agent can delegate to this subagent.
|
|
88
|
+
|
|
89
|
+
**connection** (`ACPConnection`): Readonly ACP connection used to start the agent process, create sessions, send prompts, stream updates, and manage models.
|
|
90
|
+
|
|
91
|
+
## Methods
|
|
92
|
+
|
|
93
|
+
### Generation
|
|
94
|
+
|
|
95
|
+
#### `generate(messages, options?)`
|
|
96
|
+
|
|
97
|
+
Sends the prompt to the ACP agent, buffers text chunks from the ACP response, and returns a Mastra subagent generate result.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const result = await codeAgent.generate('Inspect the repository and summarize the test setup')
|
|
101
|
+
|
|
102
|
+
console.log(result.text)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### `stream(messages, options?)`
|
|
106
|
+
|
|
107
|
+
Sends the prompt to the ACP agent and returns a Mastra subagent stream result. ACP `agent_message_chunk` updates are emitted as Mastra `text-delta` chunks.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const result = await codeAgent.stream('Refactor the selected module and explain each change')
|
|
111
|
+
|
|
112
|
+
for await (const chunk of result.fullStream) {
|
|
113
|
+
if (chunk.type === 'text-delta') {
|
|
114
|
+
process.stdout.write(chunk.payload.text)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`resumeGenerate()` and `resumeStream()` are not supported and throw an error when called.
|
|
120
|
+
|
|
121
|
+
### Model management
|
|
122
|
+
|
|
123
|
+
#### `getAvailableModels()`
|
|
124
|
+
|
|
125
|
+
Starts the ACP process if needed and returns the model list advertised by the ACP session.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const models = await codeAgent.getAvailableModels()
|
|
129
|
+
// [{ modelId: 'claude-sonnet-4-6', name: 'Claude Sonnet' }, ...]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### `setModel(modelId)`
|
|
133
|
+
|
|
134
|
+
Selects a model for the active ACP session. If the ACP agent advertises available models, the model ID must match one of them.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
await codeAgent.setModel('claude-sonnet-4-6')
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Session lifecycle
|
|
141
|
+
|
|
142
|
+
`AcpAgent` starts the configured `command` on first use, initializes the ACP client, and creates an ACP session. By default, `persistSession` is `true`, so the process and session stay alive across `generate()`, `stream()`, `getAvailableModels()`, and `setModel()` calls.
|
|
143
|
+
|
|
144
|
+
Set `persistSession: false` when each prompt should run in a fresh ACP process:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { AcpAgent } from '@mastra/acp'
|
|
148
|
+
|
|
149
|
+
export const codeAgent = new AcpAgent({
|
|
150
|
+
id: 'code-agent',
|
|
151
|
+
description: 'Run one isolated ACP coding task',
|
|
152
|
+
command: 'acp-agent',
|
|
153
|
+
args: ['--stdio'],
|
|
154
|
+
cwd: process.cwd(),
|
|
155
|
+
persistSession: false,
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
With `persistSession: false`, `@mastra/acp` stops the ACP process after each prompt completes.
|
|
160
|
+
|
|
161
|
+
## Workspace integration
|
|
162
|
+
|
|
163
|
+
ACP file operations go through Mastra's `Workspace` abstraction. If you do not pass `workspace`, `@mastra/acp` creates a `Workspace` backed by `LocalFilesystem` and uses `cwd` or `process.cwd()` as the filesystem base path.
|
|
164
|
+
|
|
165
|
+
Pass a custom `Workspace` when the ACP agent should read and write through a specific filesystem implementation:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { AcpAgent } from '@mastra/acp'
|
|
169
|
+
import { LocalFilesystem, Workspace } from '@mastra/core/workspace'
|
|
170
|
+
|
|
171
|
+
const workspace = new Workspace({
|
|
172
|
+
filesystem: new LocalFilesystem({
|
|
173
|
+
basePath: process.cwd(),
|
|
174
|
+
}),
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
export const codeAgent = new AcpAgent({
|
|
178
|
+
id: 'code-agent',
|
|
179
|
+
description: 'Run coding tasks in a controlled workspace',
|
|
180
|
+
command: 'acp-agent',
|
|
181
|
+
args: ['--stdio'],
|
|
182
|
+
workspace,
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Use `cwd` and `workspace` together when the ACP process should start in one directory but file operations should use an explicitly configured workspace root.
|
|
187
|
+
|
|
188
|
+
## Permission handling
|
|
189
|
+
|
|
190
|
+
ACP agents may ask the client to choose a permission option before they continue. By default, `AcpAgent` selects the first option returned by the ACP agent, or cancels when no option is available.
|
|
191
|
+
|
|
192
|
+
Pass `onPermissionRequest` to inspect the request and return your own permission response:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { AcpAgent } from '@mastra/acp'
|
|
196
|
+
|
|
197
|
+
export const codeAgent = new AcpAgent({
|
|
198
|
+
id: 'code-agent',
|
|
199
|
+
description: 'Use an ACP-compatible coding agent',
|
|
200
|
+
command: 'acp-agent',
|
|
201
|
+
args: ['--stdio'],
|
|
202
|
+
async onPermissionRequest(request) {
|
|
203
|
+
const allowOption = request.options.find(option => option.name === 'Allow')
|
|
204
|
+
|
|
205
|
+
if (!allowOption) {
|
|
206
|
+
return { outcome: { outcome: 'cancelled' } }
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
outcome: {
|
|
211
|
+
outcome: 'selected',
|
|
212
|
+
optionId: allowOption.optionId,
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Use this callback to enforce local policy, inspect the permission title, or route the decision to your own approval flow.
|
|
220
|
+
|
|
221
|
+
## Related
|
|
222
|
+
|
|
223
|
+
- [Agent Client Protocol docs](https://mastra.ai/docs/agents/acp)
|
|
224
|
+
- [createACPTool() reference](https://mastra.ai/reference/acp/create-acp-tool)
|
|
225
|
+
- [Agent reference](https://mastra.ai/reference/agents/agent)
|
|
226
|
+
- [Subagents](https://mastra.ai/docs/agents/supervisor-agents)
|
|
227
|
+
- [Agent Client Protocol introduction](https://agentclientprotocol.com/overview/introduction)
|
|
228
|
+
- [Agent Client Protocol schema](https://agentclientprotocol.com/protocol/schema)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# createACPTool()
|
|
2
|
+
|
|
3
|
+
The `createACPTool()` function creates a Mastra tool that sends a `task` string to an Agent Client Protocol (ACP)-compatible coding agent and returns the final ACP response as `output`. Use it when a parent agent should decide when to call the ACP agent as a tool.
|
|
4
|
+
|
|
5
|
+
If you want to register the ACP agent as a Mastra subagent instead, use the [`AcpAgent` class](https://mastra.ai/reference/acp/acp-agent).
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
Create a code editing tool and register it on a parent agent:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { createACPTool } from '@mastra/acp'
|
|
13
|
+
import { Agent } from '@mastra/core/agent'
|
|
14
|
+
|
|
15
|
+
const codeAgentTool = createACPTool({
|
|
16
|
+
id: 'code-agent',
|
|
17
|
+
description: 'Use an ACP-compatible coding agent to inspect and edit code',
|
|
18
|
+
command: 'acp-agent',
|
|
19
|
+
args: ['--stdio'],
|
|
20
|
+
cwd: process.cwd(),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export const codeSupervisor = new Agent({
|
|
24
|
+
id: 'code-supervisor',
|
|
25
|
+
name: 'Code Supervisor',
|
|
26
|
+
instructions: 'Use the code-agent tool when a task requires repository inspection or code edits.',
|
|
27
|
+
model: 'openai/gpt-5.5',
|
|
28
|
+
tools: {
|
|
29
|
+
codeAgentTool,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Parameters
|
|
35
|
+
|
|
36
|
+
**id** (`string`): Unique identifier for the Mastra tool.
|
|
37
|
+
|
|
38
|
+
**description** (`string`): Description shown to the model when it can call this tool.
|
|
39
|
+
|
|
40
|
+
**command** (`string`): ACP agent executable to spawn.
|
|
41
|
+
|
|
42
|
+
**args** (`string[]`): Arguments passed to the ACP agent executable. (Default: `[]`)
|
|
43
|
+
|
|
44
|
+
**env** (`Record<string, string>`): Environment variables to merge with the current process environment when spawning the ACP process.
|
|
45
|
+
|
|
46
|
+
**cwd** (`string`): Working directory for the ACP process and ACP session. Also used as the default local filesystem base path. (Default: `process.cwd()`)
|
|
47
|
+
|
|
48
|
+
**session** (`Partial<NewSessionRequest>`): ACP session creation options. Defaults to \`cwd\` or \`process.cwd()\` and an empty MCP server list.
|
|
49
|
+
|
|
50
|
+
**initialize** (`Partial<InitializeRequest>`): ACP initialization options. Defaults to Mastra client information, the current ACP protocol version, and read/write filesystem capabilities.
|
|
51
|
+
|
|
52
|
+
**authMethodId** (`string`): ACP authentication method ID to invoke after initialization and before session creation.
|
|
53
|
+
|
|
54
|
+
**persistSession** (`boolean`): Whether the ACP connection created for a tool execution disconnects after the prompt. Set to \`false\` to stop the process after each prompt completes. (Default: `true`)
|
|
55
|
+
|
|
56
|
+
**onPermissionRequest** (`(request: RequestPermissionRequest) => Promise<RequestPermissionResponse>`): Callback invoked when the ACP agent requests permission. Defaults to selecting the first permission option, or cancelling when no option is available.
|
|
57
|
+
|
|
58
|
+
**workspace** (`Workspace`): Workspace option from the shared ACP connection options. During tool execution, \`createACPTool()\` passes the current Mastra workspace from the execution context when one is available; otherwise the ACP connection falls back to a local filesystem workspace. Use \`AcpAgent\` when you need to provide an explicit workspace instance.
|
|
59
|
+
|
|
60
|
+
**model** (`ModelId`): Model ID to select after ACP session creation using the ACP \`session/set\_model\` method.
|
|
61
|
+
|
|
62
|
+
## Input schema
|
|
63
|
+
|
|
64
|
+
**task** (`string`): The task to send to the ACP agent.
|
|
65
|
+
|
|
66
|
+
## Output schema
|
|
67
|
+
|
|
68
|
+
**output** (`string`): The final text output returned by the ACP agent.
|
|
69
|
+
|
|
70
|
+
## Suspend and resume schema
|
|
71
|
+
|
|
72
|
+
`createACPTool()` defines suspend and resume schemas for permission request payloads. Permission decisions are returned through `onPermissionRequest`; by default, `@mastra/acp` selects the first option returned by the ACP agent, or cancels when no option is available.
|
|
73
|
+
|
|
74
|
+
### Suspend payload
|
|
75
|
+
|
|
76
|
+
**permissionRequest** (`{ title: string; options: { optionId: string; name: string }[] }`): Permission request title and selectable options returned by the ACP agent.
|
|
77
|
+
|
|
78
|
+
### Resume payload
|
|
79
|
+
|
|
80
|
+
**optionId** (`string`): Permission option ID to select when resuming with \`outcome: "selected"\`.
|
|
81
|
+
|
|
82
|
+
**outcome** (`"selected" | "cancelled"`): Permission decision used to continue or cancel the ACP request.
|
|
83
|
+
|
|
84
|
+
## Session lifecycle
|
|
85
|
+
|
|
86
|
+
Each tool execution creates an ACP connection, starts the configured `command`, initializes the ACP client, creates an ACP session, and sends the `task` with ACP `session/prompt`.
|
|
87
|
+
|
|
88
|
+
By default, `persistSession` is `true` for the ACP connection created during tool execution. Set `persistSession: false` when the ACP process should stop as soon as that prompt completes.
|
|
89
|
+
|
|
90
|
+
Use [`AcpAgent`](https://mastra.ai/reference/acp/acp-agent) when you need a reusable ACP subagent instance with explicit session lifecycle control across calls.
|
|
91
|
+
|
|
92
|
+
## Permission handling
|
|
93
|
+
|
|
94
|
+
ACP agents may ask the client to choose a permission option before they continue. By default, `@mastra/acp` selects the first option returned by the ACP agent, or cancels when no option is available.
|
|
95
|
+
|
|
96
|
+
Pass `onPermissionRequest` to inspect the request and return your own permission response:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { createACPTool } from '@mastra/acp'
|
|
100
|
+
|
|
101
|
+
export const codeAgentTool = createACPTool({
|
|
102
|
+
id: 'code-agent',
|
|
103
|
+
description: 'Use an ACP-compatible coding agent',
|
|
104
|
+
command: 'acp-agent',
|
|
105
|
+
args: ['--stdio'],
|
|
106
|
+
async onPermissionRequest(request) {
|
|
107
|
+
const allowOption = request.options.find(option => option.name === 'Allow')
|
|
108
|
+
|
|
109
|
+
if (!allowOption) {
|
|
110
|
+
return { outcome: { outcome: 'cancelled' } }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
outcome: {
|
|
115
|
+
outcome: 'selected',
|
|
116
|
+
optionId: allowOption.optionId,
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Use this callback to enforce local policy, inspect the permission title, or route the decision to your own approval flow.
|
|
124
|
+
|
|
125
|
+
## Related
|
|
126
|
+
|
|
127
|
+
- [Agent Client Protocol docs](https://mastra.ai/docs/agents/acp)
|
|
128
|
+
- [AcpAgent class reference](https://mastra.ai/reference/acp/acp-agent)
|
|
129
|
+
- [Tool reference](https://mastra.ai/reference/tools/create-tool)
|
|
130
|
+
- [Agent Client Protocol introduction](https://agentclientprotocol.com/overview/introduction)
|
|
131
|
+
- [Agent Client Protocol schema](https://agentclientprotocol.com/protocol/schema)
|
|
@@ -16,7 +16,7 @@ export const agent = new Agent({
|
|
|
16
16
|
id: 'test-agent',
|
|
17
17
|
name: 'Test Agent',
|
|
18
18
|
instructions: 'You are a helpful assistant that provides concise answers.',
|
|
19
|
-
model: 'openai/gpt-5.
|
|
19
|
+
model: 'openai/gpt-5.5',
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
// System message object
|
|
@@ -27,7 +27,7 @@ export const agent2 = new Agent({
|
|
|
27
27
|
role: 'system',
|
|
28
28
|
content: 'You are an expert programmer',
|
|
29
29
|
},
|
|
30
|
-
model: 'openai/gpt-5.
|
|
30
|
+
model: 'openai/gpt-5.5',
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
// Array of system messages
|
|
@@ -38,7 +38,7 @@ export const agent3 = new Agent({
|
|
|
38
38
|
{ role: 'system', content: 'You are a helpful assistant' },
|
|
39
39
|
{ role: 'system', content: 'You have expertise in TypeScript' },
|
|
40
40
|
],
|
|
41
|
-
model: 'openai/gpt-5.
|
|
41
|
+
model: 'openai/gpt-5.5',
|
|
42
42
|
})
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -61,7 +61,7 @@ export const agent = new Agent({
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
-
model: 'openai/gpt-5.
|
|
64
|
+
model: 'openai/gpt-5.5',
|
|
65
65
|
})
|
|
66
66
|
```
|
|
67
67
|
|
|
@@ -141,7 +141,7 @@ The model receives this as:
|
|
|
141
141
|
<user name="Devin" from="slack">Can we simplify the API surface?</user>
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
The UI sees
|
|
144
|
+
The UI sees the message contents and can also read `attributes` and `metadata` off the signal message for custom rendering (e.g. showing user names, avatars, or platform badges).
|
|
145
145
|
|
|
146
146
|
### `sendMessage(message, options)`
|
|
147
147
|
|
|
@@ -196,6 +196,54 @@ Sends a signal to an active run or memory thread.
|
|
|
196
196
|
|
|
197
197
|
Returns `{ accepted: true, runId: string, signal: CreatedAgentSignal, persisted?: Promise<void> }`. `persisted` is only present for `persist` behavior and resolves when Mastra finishes writing the signal to memory.
|
|
198
198
|
|
|
199
|
+
### `sendNotificationSignal(notification, options)`
|
|
200
|
+
|
|
201
|
+
Creates or coalesces a notification inbox record, resolves the notification delivery policy, and sends a notification signal when the decision is immediate.
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
const result = await agent.sendNotificationSignal(
|
|
205
|
+
{
|
|
206
|
+
source: 'github',
|
|
207
|
+
kind: 'ci-status',
|
|
208
|
+
priority: 'high',
|
|
209
|
+
summary: 'CI failed on main: 3 tests failed.',
|
|
210
|
+
dedupeKey: 'github:acme/app:main:ci',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
resourceId: 'user-123',
|
|
214
|
+
threadId: 'thread-abc',
|
|
215
|
+
},
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**notification.source** (`string`): External system that produced the notification, such as \`github\`, \`slack\`, or \`email\`.
|
|
220
|
+
|
|
221
|
+
**notification.kind** (`string`): Notification kind within the source, such as \`ci-status\`, \`mention\`, or \`direct-message\`.
|
|
222
|
+
|
|
223
|
+
**notification.summary** (`string`): LLM-facing summary used as the notification signal contents.
|
|
224
|
+
|
|
225
|
+
**notification.priority** (`'low' | 'medium' | 'high' | 'urgent'`): Priority used by the notification delivery policy. Defaults to \`medium\`.
|
|
226
|
+
|
|
227
|
+
**notification.payload** (`unknown`): Structured payload stored on the inbox record for tools or application code.
|
|
228
|
+
|
|
229
|
+
**notification.dedupeKey** (`string`): Key used to coalesce duplicate pending notifications from the same source and thread.
|
|
230
|
+
|
|
231
|
+
**notification.coalesceKey** (`string`): Key used to combine related pending notifications from the same source and thread.
|
|
232
|
+
|
|
233
|
+
**notification.attributes** (`Record<string, JSONValue>`): Extra attributes copied onto the emitted notification signal.
|
|
234
|
+
|
|
235
|
+
**notification.metadata** (`Record<string, unknown>`): Application metadata stored on the inbox record.
|
|
236
|
+
|
|
237
|
+
**options.resourceId** (`string`): Resource ID for the notification inbox and target memory thread.
|
|
238
|
+
|
|
239
|
+
**options.threadId** (`string`): Thread ID for the notification inbox and target memory thread.
|
|
240
|
+
|
|
241
|
+
**options.ifIdle.streamOptions** (`AgentExecutionOptions`): Options for the stream that starts when an immediate notification wakes an idle thread.
|
|
242
|
+
|
|
243
|
+
Returns `{ accepted: true, record: NotificationRecord, decision: NotificationDeliveryDecision, runId?: string, signal?: CreatedAgentSignal, persisted?: Promise<void> }`. `record` is the stored inbox record. `decision` is the delivery-policy result. `signal` and `runId` are present when ingress emits a signal immediately, including the immediate summary emitted for active high-priority notifications. `persisted` is present when the emitted signal is persisted without waking an idle thread.
|
|
244
|
+
|
|
245
|
+
Default delivery is priority-aware. `urgent` notifications deliver immediately. `high` notifications deliver immediately when the thread is idle; when the thread is active, Mastra emits a summary immediately and keeps `deliverAt` for later full delivery when the thread is idle. `medium` notifications deliver immediately when idle and batch into summaries when active. `low` notifications batch into summaries in both active and idle threads; idle low-priority summaries reach subscribers without waking the model loop. For the full flow, visit [Signals](https://mastra.ai/docs/agents/signals).
|
|
246
|
+
|
|
199
247
|
### `subscribeToThread(options)`
|
|
200
248
|
|
|
201
249
|
Subscribes to raw stream chunks for a memory thread. Use this before calling `sendMessage()`, `queueMessage()`, or `sendSignal()` when you need to render stream output, observe signal echoes, or abort the active run.
|
|
@@ -234,6 +282,8 @@ Returns an `AgentThreadSubscription` object with these members:
|
|
|
234
282
|
|
|
235
283
|
**transform** (`ToolPayloadTransformPolicy`): Shared policy for transforming tool payloads before display streams or user-visible transcript messages receive them. Use per-tool \`transform\` on \`createTool()\` for tool-local rules.
|
|
236
284
|
|
|
285
|
+
**notifications** (`{ deliveryPolicy?: NotificationDeliveryPolicyConfig }`): Notification delivery configuration for \`sendNotificationSignal()\`. \`deliveryPolicy\` can define \`decide\`, \`sources\`, \`priorities\`, or \`default\` rules that return \`deliver\`, \`queue\`, \`defer\`, \`summarize\`, \`persist\`, or \`discard\` decisions.
|
|
286
|
+
|
|
237
287
|
**workflows** (`Record<string, Workflow> | ({ requestContext: RequestContext }) => Record<string, Workflow> | Promise<Record<string, Workflow>>`): Workflows that the agent can execute. Can be static or dynamically resolved.
|
|
238
288
|
|
|
239
289
|
**defaultOptions** (`AgentExecutionOptions | ({ requestContext: RequestContext }) => AgentExecutionOptions | Promise<AgentExecutionOptions>`): Default options used when calling \`stream()\` and \`generate()\`.
|
|
@@ -15,7 +15,7 @@ export const supportAgent = new Agent({
|
|
|
15
15
|
id: 'support-agent',
|
|
16
16
|
name: 'Support Agent',
|
|
17
17
|
instructions: 'You are a helpful support assistant.',
|
|
18
|
-
model: 'openai/gpt-5.
|
|
18
|
+
model: 'openai/gpt-5.5',
|
|
19
19
|
channels: {
|
|
20
20
|
adapters: {
|
|
21
21
|
slack: createSlackAdapter(),
|
|
@@ -45,6 +45,8 @@ export const supportAgent = new Agent({
|
|
|
45
45
|
|
|
46
46
|
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the \[Chat SDK]\(https\://chat-sdk.dev/docs/usage). Use for advanced configuration such as \`dedupeTtlMs\`, \`fallbackStreamingPlaceholderText\`, \`lockScope\`, and \`messageHistory\`.
|
|
47
47
|
|
|
48
|
+
**resolveResourceId** (`(ctx: ResolveResourceIdContext) => string | Promise<string>`): Decide which \`resourceId\` owns resource-level memory for a channel thread, separately from who sent the message. Runs only when a new thread is created; reused threads keep their stored owner and never call the hook. Return \`ctx.defaultResourceId\` (\`${platform}:${message.author.userId}\`) to keep the built-in behavior.
|
|
49
|
+
|
|
48
50
|
## Per-adapter options
|
|
49
51
|
|
|
50
52
|
Wrap an adapter in a `ChannelAdapterConfig` object to set per-adapter options:
|
|
@@ -57,7 +59,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
57
59
|
const agent = new Agent({
|
|
58
60
|
name: 'Example',
|
|
59
61
|
instructions: '...',
|
|
60
|
-
model: 'openai/gpt-5.
|
|
62
|
+
model: 'openai/gpt-5.5',
|
|
61
63
|
channels: {
|
|
62
64
|
adapters: {
|
|
63
65
|
discord: {
|
|
@@ -112,7 +114,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
112
114
|
const agent = new Agent({
|
|
113
115
|
name: 'Streaming Agent',
|
|
114
116
|
instructions: '...',
|
|
115
|
-
model: 'openai/gpt-5.
|
|
117
|
+
model: 'openai/gpt-5.5',
|
|
116
118
|
channels: {
|
|
117
119
|
adapters: {
|
|
118
120
|
slack: {
|
|
@@ -139,7 +141,7 @@ import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
|
139
141
|
const agent = new Agent({
|
|
140
142
|
name: 'Custom Typing Agent',
|
|
141
143
|
instructions: '...',
|
|
142
|
-
model: 'openai/gpt-5.
|
|
144
|
+
model: 'openai/gpt-5.5',
|
|
143
145
|
channels: {
|
|
144
146
|
adapters: {
|
|
145
147
|
discord: {
|
|
@@ -171,7 +173,7 @@ import { createSlackAdapter } from '@chat-adapter/slack'
|
|
|
171
173
|
const agent = new Agent({
|
|
172
174
|
name: 'Custom Handler Agent',
|
|
173
175
|
instructions: '...',
|
|
174
|
-
model: 'openai/gpt-5.
|
|
176
|
+
model: 'openai/gpt-5.5',
|
|
175
177
|
channels: {
|
|
176
178
|
adapters: {
|
|
177
179
|
slack: createSlackAdapter(),
|
|
@@ -203,6 +205,46 @@ type ChannelHandler = (
|
|
|
203
205
|
) => Promise<void>
|
|
204
206
|
```
|
|
205
207
|
|
|
208
|
+
## Resource ID resolution
|
|
209
|
+
|
|
210
|
+
By default a channel thread's memory `resourceId` is `${platform}:${message.author.userId}`. The sender owns the memory, scoped per platform. For apps with a shared identity, such as single sign-on (SSO), this splits memory: the same user gets `feishu:user_123` in a Feishu DM but `user_123` on the web.
|
|
211
|
+
|
|
212
|
+
Pass `resolveResourceId` to decide memory ownership separately from the sender. It runs only when a new thread is created. Reused threads keep their stored `resourceId` and never call the hook, so existing conversations don't depend on the resolver being available. Return `ctx.defaultResourceId` to fall back to the built-in behavior.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { Agent } from '@mastra/core/agent'
|
|
216
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
217
|
+
|
|
218
|
+
const agent = new Agent({
|
|
219
|
+
name: 'SSO Agent',
|
|
220
|
+
instructions: '...',
|
|
221
|
+
model: 'openai/gpt-5.5',
|
|
222
|
+
channels: {
|
|
223
|
+
adapters: {
|
|
224
|
+
slack: createSlackAdapter(),
|
|
225
|
+
},
|
|
226
|
+
resolveResourceId: async ({ thread, message }) => {
|
|
227
|
+
// DM: share resource-level memory with the web app by using the bare SSO id
|
|
228
|
+
if (thread.isDM) {
|
|
229
|
+
return await resolveSsoUserId(message)
|
|
230
|
+
}
|
|
231
|
+
// Group chat: the conversation owns the memory; the sender stays the actor
|
|
232
|
+
return thread.channelId
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
})
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The `ResolveResourceIdContext` passed to the function:
|
|
239
|
+
|
|
240
|
+
**platform** (`string`): Platform name (e.g. \`slack\`, \`discord\`).
|
|
241
|
+
|
|
242
|
+
**thread** (`Thread`): The channel thread the message arrived on. Use \`thread.isDM\` to tell DMs apart from group/channel threads.
|
|
243
|
+
|
|
244
|
+
**message** (`Message`): The incoming message. \`message.author.userId\` is the actor/sender, not necessarily the memory owner.
|
|
245
|
+
|
|
246
|
+
**defaultResourceId** (`string`): The built-in default (\`${platform}:${message.author.userId}\`). Return this to keep the current behavior.
|
|
247
|
+
|
|
206
248
|
## Inline media
|
|
207
249
|
|
|
208
250
|
Controls which attachment types (images, video, PDFs, etc.) are sent as file parts to the model. Types that do not match are described as text summaries so the agent knows about the file without crashing models that reject unsupported types.
|