@mastra/acp 0.4.1-alpha.0 → 0.4.1

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/README.md CHANGED
@@ -8,157 +8,7 @@
8
8
  npm install @mastra/acp
9
9
  ```
10
10
 
11
- ## Overview
12
-
13
- The package exports:
14
-
15
- - `createACPTool`: Creates a Mastra tool that sends a task to an ACP agent and returns the completed output.
16
- - `AcpAgent`: Wraps an ACP agent as a Mastra sub-agent with `generate()` and `stream()` support.
17
-
18
- Use `createACPTool` when the ACP agent should be callable as a tool. Use `AcpAgent` when the ACP agent should participate in Mastra agent delegation.
19
-
20
- ## Create an ACP tool
21
-
22
- The following example creates a tool that starts an ACP-compatible agent process and sends the provided task to it.
23
-
24
- ```typescript
25
- import { Agent } from '@mastra/core/agent';
26
- import { createACPTool } from '@mastra/acp';
27
-
28
- const codeAgentTool = createACPTool({
29
- id: 'code-agent',
30
- description: 'Use an ACP-compatible coding agent to make code changes',
31
- command: 'acp-agent',
32
- args: ['--stdio'],
33
- cwd: process.cwd(),
34
- });
35
-
36
- export const agent = new Agent({
37
- name: 'supervisor',
38
- instructions: 'Use the code-agent tool when a task requires editing code.',
39
- model,
40
- tools: {
41
- codeAgentTool,
42
- },
43
- });
44
- ```
45
-
46
- The tool accepts a `task` string and returns an `output` string.
47
-
48
- ```typescript
49
- const result = await codeAgentTool.execute({
50
- context: {
51
- task: 'Update the README with setup instructions.',
52
- },
53
- });
54
-
55
- console.log(result.output);
56
- ```
57
-
58
- ## Use an ACP agent as a sub-agent
59
-
60
- `AcpAgent` implements Mastra's `SubAgent` interface. Add it to another agent's `agents` configuration to let the supervisor delegate work to the ACP agent.
61
-
62
- ```typescript
63
- import { Agent } from '@mastra/core/agent';
64
- import { AcpAgent } from '@mastra/acp';
65
-
66
- const codeAgent = new AcpAgent({
67
- id: 'code-agent',
68
- name: 'Code agent',
69
- description: 'An ACP-compatible coding agent that can inspect and edit files',
70
- command: 'acp-agent',
71
- args: ['--stdio'],
72
- cwd: process.cwd(),
73
- });
74
-
75
- export const supervisor = new Agent({
76
- name: 'supervisor',
77
- instructions: 'Delegate code editing tasks to the code-agent sub-agent.',
78
- model,
79
- agents: {
80
- codeAgent,
81
- },
82
- });
83
- ```
84
-
85
- `AcpAgent.generate()` buffers the ACP response and returns it as text. `AcpAgent.stream()` emits Mastra `text-delta` chunks as ACP `agent_message_chunk` updates arrive.
86
-
87
- ## Configure permissions
88
-
89
- ACP agents may request permission before running actions. By default, `@mastra/acp` selects the first permission option. Pass `onPermissionRequest` to handle permission requests yourself.
90
-
91
- ```typescript
92
- import { createACPTool } from '@mastra/acp';
93
-
94
- const codeAgentTool = createACPTool({
95
- id: 'code-agent',
96
- description: 'Use an ACP-compatible coding agent',
97
- command: 'acp-agent',
98
- args: ['--stdio'],
99
- async onPermissionRequest(request) {
100
- const option = request.options.find(option => option.name === 'Allow');
101
-
102
- if (!option) {
103
- return { outcome: { outcome: 'cancelled' } };
104
- }
105
-
106
- return {
107
- outcome: {
108
- outcome: 'selected',
109
- optionId: option.optionId,
110
- },
111
- };
112
- },
113
- });
114
- ```
115
-
116
- ## Session and workspace behavior
117
-
118
- `createACPTool` and `AcpAgent` start the configured command on first use and create an ACP session. Sessions persist across calls by default. Set `persistSession: false` to stop the ACP process after each prompt.
119
-
120
- ```typescript
121
- const codeAgent = new AcpAgent({
122
- id: 'code-agent',
123
- description: 'Run one isolated ACP task',
124
- command: 'acp-agent',
125
- args: ['--stdio'],
126
- cwd: process.cwd(),
127
- persistSession: false,
128
- });
129
- ```
130
-
131
- By default, the ACP workspace uses `cwd` as its filesystem root. Pass a Mastra `Workspace` with a custom filesystem when you need explicit workspace control.
132
-
133
- ## Configuration
134
-
135
- `createACPTool` and `AcpAgent` accept the same ACP connection options.
136
-
137
- | Option | Type | Description |
138
- | --------------------- | -------------------------------- | -------------------------------------------------------------------------------------- |
139
- | `id` | `string` | Unique tool or sub-agent identifier. |
140
- | `description` | `string` | Description shown to the model when it can call the tool or delegate to the sub-agent. |
141
- | `command` | `string` | ACP agent executable to spawn. |
142
- | `args` | `string[]` | Arguments passed to the ACP agent executable. |
143
- | `env` | `Record<string, string>` | Environment variables to merge with the current process environment. |
144
- | `cwd` | `string` | Working directory for the ACP process and default workspace. |
145
- | `session` | `Partial<NewSessionRequest>` | ACP session creation options. |
146
- | `initialize` | `Partial<InitializeRequest>` | ACP initialization options. |
147
- | `authMethodId` | `string` | ACP authentication method ID to invoke after initialization. |
148
- | `persistSession` | `boolean` | Keep the ACP process alive after execution. Defaults to `true`. |
149
- | `onPermissionRequest` | `(request) => Promise<Response>` | Callback for ACP permission requests. |
150
- | `workspace` | `Workspace` | Workspace used for ACP file reads and writes. |
151
- | `model` | `string` | Model ID to select after session creation via the ACP `session/set_model` method. |
152
-
153
- `AcpAgent` also accepts `name` to set the display name used by Mastra agent delegation.
154
-
155
- ## Configure the model
156
-
157
- ACP agents may expose selectable models. Instead of setting an environment variable like `ANTHROPIC_MODEL`, you can pass a `model` ID directly in the configuration.
158
-
159
- ### Discover available models
160
-
161
- Call `getAvailableModels()` to see which models the ACP agent supports. This starts the agent process and returns the model list from the session:
11
+ ## Usage
162
12
 
163
13
  ```typescript
164
14
  import { AcpAgent } from '@mastra/acp';
@@ -168,38 +18,19 @@ const codeAgent = new AcpAgent({
168
18
  description: 'An ACP-compatible coding agent',
169
19
  command: 'claude',
170
20
  args: ['--acp'],
21
+ model: 'claude-sonnet-4-6',
171
22
  });
172
-
173
- const models = await codeAgent.getAvailableModels();
174
- // [{ modelId: 'claude-sonnet-4-20250514', name: 'Claude Sonnet' }, ...]
175
23
  ```
176
24
 
177
- ### Set the model
178
-
179
- Pass the `model` option to select a model at connection time:
180
-
181
- ```typescript
182
- import { AcpAgent } from '@mastra/acp';
183
-
184
- const codeAgent = new AcpAgent({
185
- id: 'code-agent',
186
- description: 'An ACP-compatible coding agent',
187
- command: 'claude',
188
- args: ['--acp'],
189
- model: 'claude-sonnet-4-20250514',
190
- });
191
- ```
25
+ ## Documentation
192
26
 
193
- You can also change the model at runtime with `setModel()`:
27
+ - [ACP agent reference](https://mastra.ai/reference/acp/acp-agent)
28
+ - [Create an ACP tool](https://mastra.ai/reference/acp/create-acp-tool)
194
29
 
195
- ```typescript
196
- await codeAgent.setModel('claude-sonnet-4-20250514');
197
- ```
30
+ ## Changelog
198
31
 
199
- If the ACP agent advertises available models and your model ID doesn't match any of them, Mastra throws an error listing the valid options:
32
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/agent-sdks/acp/CHANGELOG.md) for version history and release notes.
200
33
 
201
- ```text
202
- Model "bad-model-id" is not available. Available models: claude-sonnet-4-20250514, claude-haiku-4-20250514
203
- ```
34
+ ## Support
204
35
 
205
- If the agent doesn't advertise a model list, the value is passed through without validation.
36
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -3,7 +3,7 @@ name: mastra-acp
3
3
  description: Documentation for @mastra/acp. Use when working with @mastra/acp APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/acp"
6
- version: "0.4.1-alpha.0"
6
+ version: "0.4.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.1-alpha.0",
2
+ "version": "0.4.1",
3
3
  "package": "@mastra/acp",
4
4
  "exports": {},
5
5
  "modules": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/acp",
3
- "version": "0.4.1-alpha.0",
3
+ "version": "0.4.1",
4
4
  "description": "ACP package for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,10 +34,10 @@
34
34
  "typescript": "^7.0.2",
35
35
  "vitest": "4.1.10",
36
36
  "zod": "^4.4.3",
37
- "@internal/types-builder": "0.0.104",
38
- "@internal/ai-sdk-v5": "0.0.76",
39
- "@mastra/core": "1.64.0-alpha.2",
40
- "@internal/lint": "0.0.129"
37
+ "@internal/ai-sdk-v5": "0.0.77",
38
+ "@internal/types-builder": "0.0.105",
39
+ "@internal/lint": "0.0.130",
40
+ "@mastra/core": "1.64.0"
41
41
  },
42
42
  "homepage": "https://mastra.ai",
43
43
  "repository": {