mastracode 0.27.0-alpha.8 → 0.27.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +264 -0
  2. package/README.md +5 -0
  3. package/dist/{acp-PRPUEXM6.cjs → acp-33VZO665.cjs} +4 -4
  4. package/dist/{acp-PRPUEXM6.cjs.map → acp-33VZO665.cjs.map} +1 -1
  5. package/dist/{acp-D6DHF4DU.js → acp-AFC64ZEZ.js} +3 -3
  6. package/dist/{acp-D6DHF4DU.js.map → acp-AFC64ZEZ.js.map} +1 -1
  7. package/dist/agents/instructions.d.ts.map +1 -1
  8. package/dist/agents/tools.d.ts +4 -2
  9. package/dist/agents/tools.d.ts.map +1 -1
  10. package/dist/agents/workspace.d.ts +1 -1
  11. package/dist/agents/workspace.d.ts.map +1 -1
  12. package/dist/{chunk-PDQGX4YS.cjs → chunk-HADE25EX.cjs} +1066 -135
  13. package/dist/chunk-HADE25EX.cjs.map +1 -0
  14. package/dist/{chunk-BFSBA6T4.js → chunk-KBBNY7BJ.js} +897 -275
  15. package/dist/chunk-KBBNY7BJ.js.map +1 -0
  16. package/dist/{chunk-JPWPOFZV.js → chunk-KP5DGNCF.js} +1030 -101
  17. package/dist/chunk-KP5DGNCF.js.map +1 -0
  18. package/dist/{chunk-DEROYEVF.cjs → chunk-R2JUMNGO.cjs} +900 -278
  19. package/dist/chunk-R2JUMNGO.cjs.map +1 -0
  20. package/dist/cli.cjs +187 -16
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +177 -6
  23. package/dist/cli.js.map +1 -1
  24. package/dist/headless.cjs +18 -18
  25. package/dist/headless.js +1 -1
  26. package/dist/index.cjs +17 -17
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/plugin.cjs +40 -0
  31. package/dist/plugin.cjs.map +1 -0
  32. package/dist/plugin.d.ts +81 -0
  33. package/dist/plugin.d.ts.map +1 -0
  34. package/dist/plugin.js +29 -0
  35. package/dist/plugin.js.map +1 -0
  36. package/dist/plugins/install.d.ts +16 -0
  37. package/dist/plugins/install.d.ts.map +1 -0
  38. package/dist/plugins/loader.d.ts +15 -0
  39. package/dist/plugins/loader.d.ts.map +1 -0
  40. package/dist/plugins/manager.d.ts +56 -0
  41. package/dist/plugins/manager.d.ts.map +1 -0
  42. package/dist/plugins/manifest.d.ts +14 -0
  43. package/dist/plugins/manifest.d.ts.map +1 -0
  44. package/dist/plugins/package-link.d.ts +2 -0
  45. package/dist/plugins/package-link.d.ts.map +1 -0
  46. package/dist/plugins/paths.d.ts +10 -0
  47. package/dist/plugins/paths.d.ts.map +1 -0
  48. package/dist/plugins/registry.d.ts +8 -0
  49. package/dist/plugins/registry.d.ts.map +1 -0
  50. package/dist/plugins/scaffold.d.ts +10 -0
  51. package/dist/plugins/scaffold.d.ts.map +1 -0
  52. package/dist/plugins/types.d.ts +45 -0
  53. package/dist/plugins/types.d.ts.map +1 -0
  54. package/dist/schema.d.ts +6 -0
  55. package/dist/schema.d.ts.map +1 -1
  56. package/dist/tui/command-dispatch.d.ts.map +1 -1
  57. package/dist/tui/commands/index.d.ts +1 -0
  58. package/dist/tui/commands/index.d.ts.map +1 -1
  59. package/dist/tui/commands/plugins.d.ts +3 -0
  60. package/dist/tui/commands/plugins.d.ts.map +1 -0
  61. package/dist/tui/commands/types.d.ts +2 -0
  62. package/dist/tui/commands/types.d.ts.map +1 -1
  63. package/dist/tui/components/help-overlay.d.ts.map +1 -1
  64. package/dist/tui/components/idle-counter.d.ts +11 -4
  65. package/dist/tui/components/idle-counter.d.ts.map +1 -1
  66. package/dist/tui/components/subagent-execution.d.ts +36 -3
  67. package/dist/tui/components/subagent-execution.d.ts.map +1 -1
  68. package/dist/tui/event-dispatch.d.ts.map +1 -1
  69. package/dist/tui/handlers/agent-lifecycle.d.ts.map +1 -1
  70. package/dist/tui/handlers/message.d.ts.map +1 -1
  71. package/dist/tui/handlers/tool.d.ts +2 -0
  72. package/dist/tui/handlers/tool.d.ts.map +1 -1
  73. package/dist/tui/mastra-tui.d.ts +8 -3
  74. package/dist/tui/mastra-tui.d.ts.map +1 -1
  75. package/dist/tui/render-messages.d.ts.map +1 -1
  76. package/dist/tui/setup.d.ts.map +1 -1
  77. package/dist/tui/state.d.ts +14 -1
  78. package/dist/tui/state.d.ts.map +1 -1
  79. package/dist/tui/status-duration.d.ts +4 -0
  80. package/dist/tui/status-duration.d.ts.map +1 -0
  81. package/dist/tui/status-line.d.ts.map +1 -1
  82. package/dist/tui.cjs +11 -11
  83. package/dist/tui.js +1 -1
  84. package/dist/utils/slash-command-loader.d.ts +1 -1
  85. package/dist/utils/slash-command-loader.d.ts.map +1 -1
  86. package/package.json +27 -17
  87. package/dist/chunk-BFSBA6T4.js.map +0 -1
  88. package/dist/chunk-DEROYEVF.cjs.map +0 -1
  89. package/dist/chunk-JPWPOFZV.js.map +0 -1
  90. package/dist/chunk-PDQGX4YS.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,269 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.27.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Improved web settings data loading** ([#18518](https://github.com/mastra-ai/mastra/pull/18518))
8
+ - Settings panels now avoid duplicate requests and refresh lists after saves or removals.
9
+ - Provider keys, custom providers, model packs, observational memory, and the directory picker now stay in sync automatically.
10
+ - Streaming chat behavior is unchanged.
11
+
12
+ - Improved push-to-talk voice input in the MastraCode TUI. Enable it with `/voice`, hold the spacebar to dictate, and release to finish — your speech streams into the input box in real time. ([#18624](https://github.com/mastra-ai/mastra/pull/18624))
13
+
14
+ **Choose how you dictate**
15
+
16
+ `/voice` is now an interactive settings menu. You can toggle voice on/off, pick a transcription engine, and (for cloud transcription) pick a provider and model. Run `/voice status` to see the current engine, provider/model, and whether it's ready to use. The quick toggles `/voice on` and `/voice off` still work.
17
+
18
+ **On-device transcription on macOS**
19
+
20
+ On macOS, voice now defaults to a native on-device engine (Apple's `SFSpeechRecognizer`). It's free, works offline, and streams words into the input box with low latency — no API key required.
21
+
22
+ When you turn voice on, the TUI checks the macOS Microphone and Speech Recognition permissions for you and guides you through whatever is needed: if access is blocked it offers to open the exact Privacy & Security pane (and tells you to enable "MastraCode Voice" there); if macOS simply hasn't asked yet, it explains that the first time you hold space it will prompt and you should click Allow. The same guidance appears in `/voice status` and, if dictation ever fails on a permission problem, alongside the error — so you're never left guessing what to do.
23
+
24
+ **Multiple cloud providers, not just OpenAI**
25
+
26
+ Cloud transcription is no longer locked to OpenAI Whisper. You can pick from several providers — OpenAI, Groq and other OpenAI-compatible Whisper hosts, plus Deepgram via its own SDK — and choose a model for each. Set the matching API key via the provider's environment variable or `/api-keys`; if a key is missing, `/voice` points you to `/api-keys`.
27
+
28
+ You still need a local audio recorder on your `PATH` for the cloud engine — `rec`/`sox` (recommended) or `ffmpeg` on macOS, and `pw-record`/`parecord`/`arecord`/`sox` on Linux. Non-macOS systems default to the cloud engine.
29
+
30
+ **Reliability fixes**
31
+
32
+ macOS native engine:
33
+ - It now triggers the permission prompt and works end-to-end. The on-device recognizer ships as a proper `.app` bundle — `Contents/MacOS/<binary>` plus a generated `Contents/Info.plist` with the Speech Recognition and Microphone usage descriptions — that is ad-hoc signed (`codesign -f -s -`) so the plist binds into the signature.
34
+ - The bundle is launched through macOS LaunchServices (`open`), the only launch path that makes macOS show the permission dialogs. A bare command-line executable — even one with an embedded, signed Info.plist — never fires `SFSpeechRecognizer.requestAuthorization`, so the Allow prompt never appeared and the recognizer was silently denied.
35
+ - Because a LaunchServices-launched app has no stdin/stdout pipe back to the CLI, the recognizer talks to the TUI over files: it appends newline-delimited JSON events to an events file the engine tails, and the engine asks it to flush a final result and quit by writing a stop sentinel file the recognizer polls for. The engine buffers partial lines so an event split across reads is never dropped, and it lets the recognizer see the stop sentinel before tearing the process down.
36
+ - `/voice status` does a real readiness check: it verifies the Swift toolchain and probes the actual Speech Recognition and Microphone permission state, naming exactly which one to enable in System Settings (and explaining the first-run prompt when permission hasn't been requested yet). The probe runs through the same `.app` bundle so it reads authorization under the bundle's TCC identity — probing the loose binary would query a different identity and wrongly report "not granted".
37
+ - If the recognizer exits before it can start (suppressed prompt or TCC kill), the engine surfaces a clear, actionable error with its captured output. A not-yet-determined permission state is no longer dressed up as the cause of a real crash, so you no longer see a misleading "macOS will prompt next time" message in red. The recognizer's Swift source and plist ship with the built CLI so the bundle can be built on first use.
38
+
39
+ Cloud engine:
40
+ - The live-partial loop is more robust: non-overlapping ticks and de-duplicated partials, and the terminal callback always fires on stop (final transcript, empty result, or error).
41
+ - First-dictation latency is reduced: the provider client is built once per dictation and reused across ticks so its HTTP connection stays warm (keep-alive), removing the DNS + TLS handshake cost that made the first dictation lag. The loop also polls at a short cadence until the recorder produces usable audio, so the opening partial fires as soon as there's something to transcribe.
42
+
43
+ - Reworked headless mode into a real programmatic API. You can now run MastraCode from Node/CI code with `runMC({ controller, session, prompt })`, which returns a handle that streams live events as an async-iterable and resolves to a typed result with status, text, usage, tool calls, and an exit code — it never calls `process.exit` or writes to global streams. The CLI is now a thin adapter over the same runner. ([#18680](https://github.com/mastra-ai/mastra/pull/18680))
44
+
45
+ ```ts
46
+ import { createMastraCode, runMC } from 'mastracode';
47
+
48
+ const { controller, session } = await createMastraCode({ settingsPath });
49
+
50
+ const run = runMC({ controller, session, prompt: 'Fix the failing test' });
51
+ for await (const event of run) {
52
+ // optional: react to live progress events
53
+ }
54
+ const result = await run.result;
55
+ process.exitCode = result.exitCode; // 0 success, 1 error/aborted/max-turns, 2 timeout
56
+ ```
57
+
58
+ Approvals and suspensions are resolved by a pluggable policy (default keeps the previous auto-approve behavior); a built-in `denyPolicy` plus `permissionModeToPolicy` are exported, and a new `--permission-mode {auto|deny}` flag selects between them. A new `--max-turns` flag (and `maxTurns` option) caps assistant turns and reports a `max_turns` status with exit code 1 when the cap is hit mid-task.
59
+
60
+ Breaking changes / migration:
61
+ - Output flags consolidated: the `--format` and `--output-format` flags are replaced by a single `--output` flag with values `human`, `json`, or `jsonl`.
62
+ - Before: `mastracode --prompt "..." --output-format json`
63
+ - After: `mastracode --prompt "..." --output json`
64
+ - Programmatic entry point changed from the old `runHeadless`/`headlessMain` to `runMC` (pure runner) and `runMCCli` (CLI adapter). `runMC` takes an already-built `controller` + `session` from `createMastraCode` and returns a result object instead of only an exit code.
65
+
66
+ - Added Amazon Bedrock as a model provider in Mastra Code. Bedrock models surfaced by models.dev are now selectable via `/models` and usable as build/plan/fast or subagent models with the `amazon-bedrock/<modelId>` form. Models are only offered when AWS credentials are detected. ([#17937](https://github.com/mastra-ai/mastra/pull/17937))
67
+
68
+ Bedrock authenticates with AWS SigV4 through the standard AWS credential chain (`fromNodeProviderChain`), so environment variables, shared `~/.aws` profiles, SSO, and container/instance roles all work without extra configuration. Set `AWS_REGION` (defaults to `us-east-1`) to target a region, or `AWS_BEARER_TOKEN_BEDROCK` to use Bedrock API-key auth instead.
69
+
70
+ ```sh
71
+ # Pick a Bedrock model from the picker
72
+ /models
73
+
74
+ # Or set it directly via the build/plan/fast slots
75
+ /build amazon-bedrock/<modelId>
76
+ ```
77
+
78
+ - Turned MastraCode Web into a multi-org cloud coding service. When WorkOS auth and a GitHub App are configured, a team can sign in, connect their repos, and run coding agents that branch, commit, push, and open pull requests — all from isolated cloud sandboxes. When the relevant environment variables are absent, the server and UI behave exactly as before (local-path projects, single shared store, no auth UI), so this is fully opt-in. ([#18567](https://github.com/mastra-ai/mastra/pull/18567))
79
+
80
+ **Authentication (WorkOS AuthKit).** Setting `WORKOS_API_KEY` and `WORKOS_CLIENT_ID` protects every route: unauthenticated visitors are redirected to the WorkOS hosted login, signed-in users get an encrypted session, expired sessions bounce back to login, and the sidebar shows the signed-in email with a Sign out button. Users with no WorkOS organization get a personal org bootstrapped on first authenticated use (idempotent, with recovery from partial creations), so personal accounts can use org-scoped features without hand-creating an org.
81
+
82
+ **Org-owned GitHub projects.** With the GitHub App env vars set (`GITHUB_APP_ID`, `GITHUB_APP_PRIVATE_KEY`, `GITHUB_APP_CLIENT_ID`, `GITHUB_APP_CLIENT_SECRET`, `GITHUB_APP_SLUG`, `APP_DATABASE_URL`), users install/connect the app, pick repos they can access, and turn each into a project. The installation and connected repos belong to the WorkOS organization; the same repo can be connected independently by different orgs with no cross-visibility. Each repo is materialized into an isolated cloud sandbox on open — cloned (or pulled) inside the sandbox with a short-lived installation token that never reaches the browser and is scrubbed from the remote afterward.
83
+
84
+ **Cloud coding-agent write-back.** From a connected repo, each user gets their own sandbox, git worktrees, and feature branches. The agent runs against the selected worktree (file edits and commands bind to its path) and can commit, push, and open pull requests via the in-sandbox `gh` CLI, authenticated with short-lived per-operation installation tokens. The sidebar shows a nested project → worktree → conversations tree with a "+ New worktree" affordance; conversations scope per worktree.
85
+
86
+ **Sandbox providers.** A provider is selected automatically: Railway when `RAILWAY_API_TOKEN` is set, otherwise a local provider that runs git directly on the host (single-user local dev only — no tenant isolation). `MASTRACODE_SANDBOX_PROVIDER` overrides explicitly. Idle sandboxes are torn down and re-provisioned on the next open; a per-replica live-sandbox cap (`MASTRACODE_MAX_SANDBOXES`) and a per-user teardown route bound resource use.
87
+
88
+ **Per-(org,user) state isolation.** Agent state (threads, messages, memory, recall vectors) is isolated by the `(organization, user)` pair, each backed by a dedicated libSQL database whose location is derived server-side from a hash of `(orgId, userId)` — never a client-supplied path. By default each tenant gets local libSQL files under `MASTRACODE_TENANT_DB_ROOT`; for hosted deployments, point each tenant at a remote libSQL/Turso database via `MASTRACODE_TENANT_DB_URL_TEMPLATE` (plus optional vector template and auth tokens).
89
+
90
+ **Sandbox isolation hardening.** Commands run in the local sandbox receive only a sanitized allow-list of environment variables (PATH/HOME/locale/git config), so server secrets such as `GITHUB_APP_PRIVATE_KEY`, `WORKOS_API_KEY`, and `APP_DATABASE_URL` are never exposed to code running against an untrusted checkout. Sandbox filesystem write operations (write/append/copy/move/mkdir) now verify the destination's real path — including a symlinked parent directory — stays within the workspace root, preventing a malicious repo's symlink from redirecting writes outside the sandbox.
91
+
92
+ **Multi-replica deployment hardening.** Per-(project,user) git writes are serialized across replicas with Postgres advisory locks (`MASTRACODE_DISTRIBUTED_LOCK`, on by default; requires `APP_DATABASE_URL`). OAuth/install state signing requires a replica-stable secret in multi-replica setups, in-memory tenant stacks are evicted by idle timeout and an LRU cap (`MASTRACODE_TENANT_IDLE_MINUTES`, `MASTRACODE_TENANT_MAX_APPS`), and `MASTRACODE_REQUIRE_REMOTE_TENANT_DB=1` fails startup when no shared remote tenant DB is configured.
93
+
94
+ ```bash
95
+ # Auth + GitHub App (opt-in)
96
+ WORKOS_API_KEY=sk_xxxxxxxx
97
+ WORKOS_CLIENT_ID=client_xxxxxxxx
98
+ GITHUB_APP_ID=123456
99
+ GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
100
+ GITHUB_APP_CLIENT_ID=Iv1.xxxxxxxx
101
+ GITHUB_APP_CLIENT_SECRET=xxxxxxxx
102
+ GITHUB_APP_SLUG=your-app-slug
103
+ APP_DATABASE_URL=postgres://user:pass@host:5432/mastracode_web
104
+
105
+ # Multi-replica hosted deployment
106
+ GITHUB_APP_WEBHOOK_SECRET=... # replica-stable state signing
107
+ MASTRACODE_DISTRIBUTED_LOCK=1 # cross-replica git write locks
108
+ MASTRACODE_REQUIRE_REMOTE_TENANT_DB=1 # require shared remote tenant DBs
109
+ MASTRACODE_TENANT_DB_URL_TEMPLATE=libsql://{id}-org.turso.io
110
+ MASTRACODE_TENANT_IDLE_MINUTES=30
111
+ MASTRACODE_TENANT_MAX_APPS=100
112
+ MASTRACODE_MAX_SANDBOXES=50
113
+ ```
114
+
115
+ Still deferred: collaboration within a project (multiple users sharing one worktree/sandbox/branch), org admin/roles and membership management, and org-level project deletion.
116
+
117
+ - Auto-provision a per-tenant Turso database in deployed MastraCode Web environments. ([#18690](https://github.com/mastra-ai/mastra/pull/18690))
118
+
119
+ Previously, hosting per-`(org, user)` agent state on Turso required each tenant's database to already exist at the URL produced by `MASTRACODE_TENANT_DB_URL_TEMPLATE`. There was no way to create those databases on demand, so the only zero-setup option was server-local libSQL files — which are ephemeral and not shared across replicas.
120
+
121
+ Setting `MASTRACODE_TURSO_PLATFORM_TOKEN` and `MASTRACODE_TURSO_ORG` now enables a third tenant-storage mode: the first time a tenant is seen, its own Turso database is created via the Turso Platform API (idempotent — an "already exists" race recovers the hostname via `databases.get`), a scoped auth token is minted, and the stable database-name/hostname mapping is persisted in the app Postgres (`tenant_databases` table, requires `APP_DATABASE_URL`). All replicas converge on the same database and cold starts never re-create it. Only the durable mapping is stored; the auth token is minted fresh per resolution, so no long-lived credential is persisted.
122
+
123
+ Resolution priority is: explicit `MASTRACODE_TENANT_DB_URL_TEMPLATE` → Turso auto-provisioning → local libSQL files. Turso provisioning also satisfies `MASTRACODE_REQUIRE_REMOTE_TENANT_DB=1`. The `@tursodatabase/api` client is loaded dynamically, so deployments that don't use Turso never pull it in at runtime.
124
+
125
+ ```bash
126
+ MASTRACODE_TURSO_PLATFORM_TOKEN=... # Turso Platform API token
127
+ MASTRACODE_TURSO_ORG=my-org # org that owns provisioned databases
128
+ MASTRACODE_TURSO_GROUP=default # optional group (default "default")
129
+ APP_DATABASE_URL=postgres://... # required for the mapping table
130
+ ```
131
+
132
+ ### Patch Changes
133
+
134
+ - Renamed the AgentController interval API. `heartbeatHandlers` is now `intervalHandlers`, the `HeartbeatHandler` type is now `IntervalHandler`, and the `removeHeartbeat()`/`stopHeartbeats()` methods are now `removeInterval()`/`stopIntervals()`. This better reflects that these are fixed-interval background tasks, not liveness pings, and is distinct from the unrelated `mastra.heartbeats` scheduled-agent feature. ([#18665](https://github.com/mastra-ai/mastra/pull/18665))
135
+
136
+ **Before**
137
+
138
+ ```ts
139
+ const { controller } = await createMastraCode({
140
+ heartbeatHandlers: [{ id: 'sync', intervalMs: 60_000, handler: async () => {} }],
141
+ });
142
+ await controller.removeHeartbeat({ id: 'sync' });
143
+ await controller.stopHeartbeats();
144
+ ```
145
+
146
+ **After**
147
+
148
+ ```ts
149
+ const { controller } = await createMastraCode({
150
+ intervalHandlers: [{ id: 'sync', intervalMs: 60_000, handler: async () => {} }],
151
+ });
152
+ await controller.removeInterval({ id: 'sync' });
153
+ await controller.stopIntervals();
154
+ ```
155
+
156
+ - Set goal judge `maxSteps` to 1000 (matching the main agent) so the judge has ample budget for complex goals requiring heavy verification. ([#18544](https://github.com/mastra-ai/mastra/pull/18544))
157
+
158
+ - Amazon Bedrock models now appear under their own `amazon-bedrock/<model>` provider in the model picker instead of the `mastracode/amazon-bedrock/<model>` namespace. Bedrock is resolved through a dedicated Amazon Bedrock gateway that authenticates with the AWS credential chain (SigV4) and surfaces models from the public models.dev catalog. Saved model selections using the previous `mastracode/amazon-bedrock/...` IDs are still resolved at runtime, so existing config keeps working. ([#17937](https://github.com/mastra-ai/mastra/pull/17937))
159
+
160
+ - MastraCode now builds its code agent through the new `createCodingAgent` factory from `@mastra/core/coding-agent` instead of constructing the `Agent` inline. No user-facing behavior changes — the system prompt and agent configuration are unchanged. ([#18695](https://github.com/mastra-ai/mastra/pull/18695))
161
+
162
+ - Fixed MCP HTTP server URLs so `${VAR}` references resolve from the environment, the same way header values already do. A server configured with `"url": "${MCP_SERVER_URL}"` is now connected instead of being silently skipped as an invalid URL. ([#18579](https://github.com/mastra-ai/mastra/pull/18579))
163
+
164
+ - MCP stdio servers now resolve `${VAR}` references in their `env` values from the host environment, matching the existing behavior for HTTP server headers. You can reference secrets from the environment instead of hardcoding them in `mcp.json`: ([#18529](https://github.com/mastra-ai/mastra/pull/18529))
165
+
166
+ ```json
167
+ {
168
+ "mcpServers": {
169
+ "github": {
170
+ "command": "npx",
171
+ "args": ["-y", "@modelcontextprotocol/server-github"],
172
+ "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ - Improved the Mastra Code status area to show active work time, completed work duration, and idle time. ([#18656](https://github.com/mastra-ai/mastra/pull/18656))
179
+
180
+ - Improved MastraCode web chat so hydrated and streaming messages render consistently, including tool cards, reasoning, and failed-tool states. ([#18620](https://github.com/mastra-ai/mastra/pull/18620))
181
+
182
+ - Added Mastra Code plugin support: ([#18658](https://github.com/mastra-ai/mastra/pull/18658))
183
+ - Install, scaffold, configure, block, and auto-update plugins with local-change backups.
184
+ - Load plugin tools in all modes, including streaming progress and subagent-style rendering.
185
+ - Load bundled plugin commands, skills, and plugin-provided system instructions.
186
+
187
+ Example:
188
+
189
+ ```ts
190
+ import { createTool, defineMastraCodePlugin, z } from 'mastracode/plugin';
191
+
192
+ export default defineMastraCodePlugin({
193
+ id: 'acme.tools',
194
+ tools: {
195
+ echo: {
196
+ tool: createTool({
197
+ id: 'echo',
198
+ inputSchema: z.object({ message: z.string() }),
199
+ execute: async ({ message }) => ({ message }),
200
+ }),
201
+ },
202
+ },
203
+ });
204
+ ```
205
+
206
+ - Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`d0702ee`](https://github.com/mastra-ai/mastra/commit/d0702eedc1594cb2d0d83476440cfc2ec8820adb), [`9feeaa0`](https://github.com/mastra-ai/mastra/commit/9feeaa0f9a1af07039e5b4f22b932b0cb18617e8), [`0969845`](https://github.com/mastra-ai/mastra/commit/09698454036771547961c6d0776e8ee5c6462d4f), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e05dade`](https://github.com/mastra-ai/mastra/commit/e05dade21c3e2551893ad939e6028cdafd84a1b2), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`c607ece`](https://github.com/mastra-ai/mastra/commit/c607eceeda028a80b24d00ee7dae376db73df526), [`65a66db`](https://github.com/mastra-ai/mastra/commit/65a66dbe249a0d92d828c605b955e73a983cf3b0), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
207
+ - @mastra/core@1.48.0
208
+ - @mastra/schema-compat@1.3.2
209
+ - @mastra/railway@0.2.1
210
+ - @mastra/memory@1.22.0
211
+ - @mastra/server@1.48.0
212
+ - @mastra/mcp@1.12.1
213
+ - @mastra/libsql@1.14.3
214
+ - @mastra/pg@1.14.3
215
+ - @mastra/react@1.2.1
216
+ - @mastra/hono@1.5.3
217
+
218
+ ## 0.27.0-alpha.10
219
+
220
+ ### Patch Changes
221
+
222
+ - Improved the Mastra Code status area to show active work time, completed work duration, and idle time. ([#18656](https://github.com/mastra-ai/mastra/pull/18656))
223
+
224
+ - Added Mastra Code plugin support: ([#18658](https://github.com/mastra-ai/mastra/pull/18658))
225
+ - Install, scaffold, configure, block, and auto-update plugins with local-change backups.
226
+ - Load plugin tools in all modes, including streaming progress and subagent-style rendering.
227
+ - Load bundled plugin commands, skills, and plugin-provided system instructions.
228
+
229
+ Example:
230
+
231
+ ```ts
232
+ import { createTool, defineMastraCodePlugin, z } from 'mastracode/plugin';
233
+
234
+ export default defineMastraCodePlugin({
235
+ id: 'acme.tools',
236
+ tools: {
237
+ echo: {
238
+ tool: createTool({
239
+ id: 'echo',
240
+ inputSchema: z.object({ message: z.string() }),
241
+ execute: async ({ message }) => ({ message }),
242
+ }),
243
+ },
244
+ },
245
+ });
246
+ ```
247
+
248
+ - Updated dependencies [[`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
249
+ - @mastra/memory@1.22.0-alpha.3
250
+ - @mastra/core@1.48.0-alpha.10
251
+ - @mastra/server@1.48.0-alpha.10
252
+ - @mastra/libsql@1.14.3-alpha.0
253
+ - @mastra/pg@1.14.3-alpha.0
254
+ - @mastra/hono@1.5.3-alpha.10
255
+ - @mastra/react@1.2.1-alpha.10
256
+
257
+ ## 0.27.0-alpha.9
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [[`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1)]:
262
+ - @mastra/core@1.48.0-alpha.9
263
+ - @mastra/react@1.2.1-alpha.9
264
+ - @mastra/server@1.48.0-alpha.9
265
+ - @mastra/hono@1.5.3-alpha.9
266
+
3
267
  ## 0.27.0-alpha.8
4
268
 
5
269
  ### Patch Changes
package/README.md CHANGED
@@ -101,6 +101,7 @@ Select a suggestion with arrow keys and press Tab to insert it.
101
101
  | `/mcp` | Show/reload MCP server connections |
102
102
  | `/sandbox` | Manage allowed paths (add/remove dirs) |
103
103
  | `/permissions` | View/manage tool approval permissions |
104
+ | `/plugins` | Install and manage trusted Mastra Code plugins |
104
105
  | `/settings` | General settings (notifications, YOLO, etc.) |
105
106
  | `/yolo` | Toggle YOLO mode (auto-approve all tools) |
106
107
  | `/resource` | Show/switch resource ID (tag for sharing) |
@@ -111,6 +112,10 @@ Select a suggestion with arrow keys and press Tab to insert it.
111
112
  | `/help` | Show available commands |
112
113
  | `/exit` | Exit the TUI |
113
114
 
115
+ ### Plugins
116
+
117
+ Use `/plugins` to install and manage trusted local or GitHub plugins. Plugins can add tools, commands, skills, and system instructions. Because plugins execute code inside Mastra Code and their instructions are appended to the agent prompt, only install plugins from sources you trust.
118
+
114
119
  ### Goals
115
120
 
116
121
  Use `/goal <objective>` to have Mastra Code keep working toward an objective across turns. Goals use a judge model to decide whether the goal is complete, should continue, or should wait for an explicit user checkpoint. Configure defaults with `/judge`.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkVBH3L4LD_cjs = require('./chunk-VBH3L4LD.cjs');
4
- var chunkPDQGX4YS_cjs = require('./chunk-PDQGX4YS.cjs');
4
+ var chunkHADE25EX_cjs = require('./chunk-HADE25EX.cjs');
5
5
  var chunkWX46SWL3_cjs = require('./chunk-WX46SWL3.cjs');
6
6
  var crypto = require('crypto');
7
7
  var stream = require('stream');
@@ -45,7 +45,7 @@ async function acpMain(options) {
45
45
  };
46
46
  let result;
47
47
  try {
48
- result = await chunkPDQGX4YS_cjs.createMastraCode({
48
+ result = await chunkHADE25EX_cjs.createMastraCode({
49
49
  unixSocketPubSub: false,
50
50
  disableMcp: false,
51
51
  disableHooks: false
@@ -83,5 +83,5 @@ async function acpMain(options) {
83
83
  }
84
84
 
85
85
  exports.acpMain = acpMain;
86
- //# sourceMappingURL=acp-PRPUEXM6.cjs.map
87
- //# sourceMappingURL=acp-PRPUEXM6.cjs.map
86
+ //# sourceMappingURL=acp-33VZO665.cjs.map
87
+ //# sourceMappingURL=acp-33VZO665.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQA,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAASC,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAMC,QAAA,GAASC,gBAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,KAAA;AAGJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,WAAW,aAAA,CAAc;AAAA,MACvC,EAAA,EAAI,CAAA,IAAA,EAAOC,iBAAA,EAAY,CAAA,CAAA;AAAA,MACvB,OAAA,EAAS,CAAA,UAAA,EAAaA,iBAAA,EAAY,CAAA;AAAA,KACnC,CAAA;AACD,IAAA,MAAM,aAAA,GAAgB,OAAA;AAGtB,IAAA,MAAM,UAAA,GAAa,IAAIC,uBAAA,CAAoB,CAAA,IAAA,KAAQ;AACjD,MAAA,KAAA,GAAQ,IAAIC,oCAAA,CAAmB,IAAA,EAAM,UAAA,EAAY,eAAe,KAAK,CAAA;AACrE,MAAA,OAAO,KAAA;AAAA,IACT,GAAGJ,QAAM,CAAA;AAET,IAAA,MAAM,UAAA,CAAW,MAAA;AAAA,EACnB,CAAA,SAAE;AACA,IAAA,KAAA,EAAO,OAAA,EAAQ;AACf,IAAA,OAAA,EAAS,OAAO,iBAAA,EAAkB;AAClC,IAAA,MAAM,OAAA,EAAS,OAAO,mBAAA,EA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AAAA,QAC1B,kBAAA;AAAqB,OACtB,CAAA;AAID,MAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AAAA,IAChB,CAAA;AAGA,IAAA,MAAM,eAAe,YAAY;AAC/B,MAAA,MAAM,OAAA,EAAQ;AACd,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAA;AAEA,IAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,YAAY,CAAA;AACjC,IAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,YAAY,CAAA;AAElC,IAAA,MAAM,YAAA,CAAa,UAAA,EAAY,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-PRPUEXM6.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQA,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAASC,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAMC,QAAA,GAASC,gBAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,KAAA;AAGJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,WAAW,aAAA,CAAc;AAAA,MACvC,EAAA,EAAI,CAAA,IAAA,EAAOC,iBAAA,EAAY,CAAA,CAAA;AAAA,MACvB,OAAA,EAAS,CAAA,UAAA,EAAaA,iBAAA,EAAY,CAAA;AAAA,KACnC,CAAA;AACD,IAAA,MAAM,aAAA,GAAgB,OAAA;AAGtB,IAAA,MAAM,UAAA,GAAa,IAAIC,uBAAA,CAAoB,CAAA,IAAA,KAAQ;AACjD,MAAA,KAAA,GAAQ,IAAIC,oCAAA,CAAmB,IAAA,EAAM,UAAA,EAAY,eAAe,KAAK,CAAA;AACrE,MAAA,OAAO,KAAA;AAAA,IACT,GAAGJ,QAAM,CAAA;AAET,IAAA,MAAM,UAAA,CAAW,MAAA;AAAA,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AA,MAAM,QAAQ,UAAA,CAAW;AAAA,QACvB,YAAY,UAAA,EAAW;AAAA,QACvB,UAAA,EAAY,SAAA,EAAU,EAAG,WAAA,EAAY;AAAA,QACrC,YAAY,aAAA,EAAc;AAAA,QAC1B,kBAAA;AAAqB,OACtB,CAAA;AAID,MAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AAAA,IAChB,CAAA;AAGA,IAAA,MAAM,eAAe,YAAY;AAC/B,MAAA,MAAM,OAAA,EAAQ;AACd,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAA;AAEA,IAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,YAAY,CAAA;AACjC,IAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,YAAY,CAAA;AAElC,IAAA,MAAM,YAAA,CAAa,UAAA,EAAY,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-33VZO665.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { setAutoApprove, MastraCodeAcpAgent } from './chunk-IFUIWWGJ.js';
2
- import { createMastraCode } from './chunk-JPWPOFZV.js';
2
+ import { createMastraCode } from './chunk-KP5DGNCF.js';
3
3
  import { releaseAllThreadLocks } from './chunk-GAPPKMQT.js';
4
4
  import { randomUUID } from 'crypto';
5
5
  import { Readable, Writable } from 'stream';
@@ -81,5 +81,5 @@ async function acpMain(options) {
81
81
  }
82
82
 
83
83
  export { acpMain };
84
- //# sourceMappingURL=acp-D6DHF4DU.js.map
85
- //# sourceMappingURL=acp-D6DHF4DU.js.map
84
+ //# sourceMappingURL=acp-AFC64ZEZ.js.map
85
+ //# sourceMappingURL=acp-AFC64ZEZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":";;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAA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,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-D6DHF4DU.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":";;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,E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AA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-AFC64ZEZ.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/agents/instructions.ts"],"names":[],"mappings":"AAOA,wBAAsB,sBAAsB,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE;QAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;CAAE,mBAyBjH"}
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/agents/instructions.ts"],"names":[],"mappings":"AAOA,wBAAsB,sBAAsB,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE;QAAE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAA;CAAE,mBAiCjH"}
@@ -8,9 +8,11 @@ export type ToolLike = {
8
8
  execute?: (...args: any[]) => Promise<unknown> | unknown;
9
9
  } & Record<string, any>;
10
10
  export declare function createToolHooks(hookManager?: HookManager): ToolHooks | undefined;
11
- export declare function createDynamicTools(mcpManager?: McpManager, extraTools?: Record<string, ToolLike> | ((ctx: {
11
+ type DynamicToolProvider = Record<string, ToolLike | undefined> | ((ctx: {
12
12
  requestContext: RequestContext;
13
- }) => Record<string, ToolLike>), disabledTools?: string[], storage?: MastraCompositeStore): ({ requestContext }: {
13
+ }) => Record<string, ToolLike | undefined>);
14
+ export declare function createDynamicTools(mcpManager?: McpManager, extraTools?: DynamicToolProvider, disabledTools?: string[], storage?: MastraCompositeStore, pluginTools?: Record<string, ToolLike>): ({ requestContext }: {
14
15
  requestContext: RequestContext;
15
16
  }) => Record<string, ToolLike>;
17
+ export {};
16
18
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agents/tools.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKzC,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAA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ACpC,CAAC,CAAC,GAAG,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC;AAExF,wBAAgB,kBAAkB,CAChC,UAAU,CAAC,EAAE,UAAU,EACvB,UAAU,CAAC,EAAE,mBAAmB,EAChC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAEN,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,8BAyEvF"}
@@ -2,7 +2,7 @@ import type { ToolsInput } from '@mastra/core/agent';
2
2
  import type { Mastra } from '@mastra/core/mastra';
3
3
  import type { RequestContext } from '@mastra/core/request-context';
4
4
  import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
5
- export declare function buildSkillPaths(projectPath: string, configDir: string, homeDir?: string): string[];
5
+ export declare function buildSkillPaths(projectPath: string, configDir: string, homeDir?: string, pluginSkillPaths?: string[]): string[];
6
6
  export declare function getDynamicWorkspace({ requestContext, mastra, }: {
7
7
  requestContext: RequestContext;
8
8
  mastra?: Mastra;
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/agents/workspace.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAwB,MAAM,wBAAwB,CAAC;AAiFxG,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,SAAe,GAAG,MAAM,EAAE,CAgBxG;AAgFD,w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