mastracode 0.33.0-alpha.8 → 0.33.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/CHANGELOG.md +209 -0
- package/README.md +21 -0
- package/dist/cli.cjs +7 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +7 -2
- package/dist/cli.js.map +1 -1
- package/dist/tui/command-dispatch.d.ts.map +1 -1
- package/dist/tui/commands/goal.d.ts.map +1 -1
- package/dist/tui/commands/index.d.ts +1 -0
- package/dist/tui/commands/index.d.ts.map +1 -1
- package/dist/tui/commands/workflows.d.ts +3 -0
- package/dist/tui/commands/workflows.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -1
- package/dist/tui/display.d.ts +8 -9
- package/dist/tui/display.d.ts.map +1 -1
- package/dist/tui/handlers/prompts.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts +8 -0
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/setup.d.ts +1 -0
- package/dist/tui/setup.d.ts.map +1 -1
- package/dist/tui/state.d.ts +7 -0
- package/dist/tui/state.d.ts.map +1 -1
- package/dist/{tui-tFzKFnpk.cjs → tui-C-5CxtMW.cjs} +449 -37
- package/dist/tui-C-5CxtMW.cjs.map +1 -0
- package/dist/{tui-IdBfDUUa.js → tui-D-aJNadI.js} +449 -37
- package/dist/tui-D-aJNadI.js.map +1 -0
- package/dist/tui.cjs +1 -1
- package/dist/tui.js +1 -1
- package/package.json +15 -15
- package/dist/tui-IdBfDUUa.js.map +0 -1
- package/dist/tui-tFzKFnpk.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,214 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Plugins installed with `/plugins` can now contribute processors and signal providers, not just tools, commands, skills, and instructions. Author them against `mastracode/plugin` with the new `processors` and `signalProviders` fields. ([#20848](https://github.com/mastra-ai/mastra/pull/20848))
|
|
8
|
+
|
|
9
|
+
- Add a reasoning-effort configuration surface across mastracode and Factory (fixes #20766): ([#20884](https://github.com/mastra-ai/mastra/pull/20884))
|
|
10
|
+
|
|
11
|
+
- New `max` thinking level (mapped to `reasoning effort: max` for OpenAI Codex and Anthropic `effort`).
|
|
12
|
+
- Anthropic extended-thinking wiring: the session thinking level now applies to anthropic/claude-opus-4-7 and other Anthropic models via provider thinking/effort options (previously OpenAI-only).
|
|
13
|
+
- New `models.modeThinkingDefaults` setting: per-mode (build/plan/fast) default thinking levels, resolved at request time with precedence session override → mode default → global `preferences.thinkingLevel`. Configuration changes now apply to the next request of every session, including automated Factory runs.
|
|
14
|
+
- Factory: new Settings → Defaults controls for editing global and per-mode thinking defaults in local deployments.
|
|
15
|
+
- TUI: `/think` now sets a session-only override, supports `/think default` to clear it, and `/think status` reports the effective level with provenance (session override / mode default / global default).
|
|
16
|
+
|
|
17
|
+
Example `settings.json` configuration:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"preferences": { "thinkingLevel": "medium" },
|
|
22
|
+
"models": {
|
|
23
|
+
"modeThinkingDefaults": {
|
|
24
|
+
"build": "high",
|
|
25
|
+
"plan": "max",
|
|
26
|
+
"fast": "off"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Added the ability to disable MCP servers without editing configuration files. ([#20834](https://github.com/mastra-ai/mastra/pull/20834))
|
|
33
|
+
|
|
34
|
+
- **Disable and enable servers**: Run `/mcp disable <server-name|all>` to turn servers off and `/mcp enable <server-name|all>` to turn them back on, or toggle individual servers from the interactive `/mcp` selector.
|
|
35
|
+
- **Global scope**: Add `--global` to apply the change to every project. `/mcp disable all --global` acts as a kill switch for all MCP servers.
|
|
36
|
+
- **Persistence**: Disabled servers stay visible in `/mcp status` with a marker for the scope that disabled them, their tools are removed from the agent, and the state survives restarts.
|
|
37
|
+
|
|
38
|
+
- Added the `/workflows` command for listing, inspecting, running, and deleting chat-built workflows. ([#21210](https://github.com/mastra-ai/mastra/pull/21210))
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- A plan approval arriving while a command overlay (such as the /models pack selector) is open no longer steals focus from the overlay or deadlocks it. The approval defers its focus until the overlay closes, then takes focus so it must still be answered. ([#21142](https://github.com/mastra-ai/mastra/pull/21142))
|
|
43
|
+
|
|
44
|
+
- Fixed `/workflows` command errors so the message from a failure is shown, whether the failure is a string or an object with a message, instead of `[object Object]`. ([#21287](https://github.com/mastra-ai/mastra/pull/21287))
|
|
45
|
+
|
|
46
|
+
- Add `/browser set viewport` and `/browser clear viewport`. Pass a preset (`desktop`, `desktop-hd`, `laptop`, `tablet`, `mobile`), a custom `WIDTHxHEIGHT` size, or `window` to match the real browser window; omit the value to pick a preset from a list. `window` is rejected on providers that cannot honor it. ([#21010](https://github.com/mastra-ai/mastra/pull/21010))
|
|
47
|
+
|
|
48
|
+
- Fixed a goal started on a new thread being cleared moments after it was set. Starting a goal that creates its own thread now persists that goal to the new thread instead of dropping it. ([#21255](https://github.com/mastra-ai/mastra/pull/21255))
|
|
49
|
+
|
|
50
|
+
- dependencies updates: ([#19783](https://github.com/mastra-ai/mastra/pull/19783))
|
|
51
|
+
- Updated dependency [`posthog-node@^5.46.1` ↗︎](https://www.npmjs.com/package/posthog-node/v/5.46.1) (from `^5.37.0`, in `dependencies`)
|
|
52
|
+
|
|
53
|
+
- dependencies updates: ([#20406](https://github.com/mastra-ai/mastra/pull/20406))
|
|
54
|
+
- Updated dependency [`@aws-sdk/credential-providers@^3.1095.0` ↗︎](https://www.npmjs.com/package/@aws-sdk/credential-providers/v/3.1095.0) (from `^3.864.0`, in `dependencies`)
|
|
55
|
+
|
|
56
|
+
- Added a configurable model for Stagehand browser automation, which previously ran on a fixed default. Run `/browser set model` with no value to choose from a picker, or name one directly: ([#20993](https://github.com/mastra-ai/mastra/pull/20993))
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
/browser set model anthropic/claude-sonnet-4-5
|
|
60
|
+
/browser clear model
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Only providers Stagehand supports are accepted, and you are prompted for the provider's API key when it is missing.
|
|
64
|
+
|
|
65
|
+
- The web sign-in page now explains when the identity provider denies access — showing the reason and a hint to ask an organization admin to add the account — instead of silently returning to the sign-in button. ([#21166](https://github.com/mastra-ai/mastra/pull/21166))
|
|
66
|
+
|
|
67
|
+
- Fixed notifications for assistant questions, plan approvals, sandbox access requests, and tool approvals so the bell, system notification, and Notification hooks fire the moment Mastra Code starts waiting for input — even while an earlier prompt is still pending. Fixes #20398. ([#20857](https://github.com/mastra-ai/mastra/pull/20857))
|
|
68
|
+
|
|
69
|
+
- Fixed custom provider models saved with a stray `mastracode/` prefix in settings, which broke selecting and using them after choosing them from `/models` (#20799) ([#20804](https://github.com/mastra-ai/mastra/pull/20804))
|
|
70
|
+
|
|
71
|
+
- Dispatch PermissionRequest hooks and the agent_done notification at event receipt instead of from the TUI's serialized event queue, so external integrations hear about new permission prompts and finished runs even while an earlier prompt is pending. Also removes the spurious agent_done ping that fired after answering a suspended run's prompt. ([#20923](https://github.com/mastra-ai/mastra/pull/20923))
|
|
72
|
+
|
|
73
|
+
- Fixed duplicate `Thinking...` lines in the chat transcript. When a model emitted more than one reasoning span in a single step, each span rendered its own label; consecutive hidden reasoning parts now collapse into a single `Thinking...` line. ([#21134](https://github.com/mastra-ai/mastra/pull/21134))
|
|
74
|
+
|
|
75
|
+
- Keep input typed while the TUI is handling a slash command or a `!` shell command. Submitting during that window used to be swallowed — the editor cleared, nothing ran, and the text was gone — because the input loop had already moved on and no longer had a read pending. Submissions made while the loop is busy are now held and delivered in order on its next read, so a quick sequence like: ([#21100](https://github.com/mastra-ai/mastra/pull/21100))
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
!echo hi
|
|
79
|
+
/browser clear viewport
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
runs both commands instead of only the first.
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [[`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`ae0e985`](https://github.com/mastra-ai/mastra/commit/ae0e985e8f1186a8ecfcf0de6dd36ac12ef85324), [`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`b8ce7ec`](https://github.com/mastra-ai/mastra/commit/b8ce7ec96e39343c6c2f36d12d68a9ad816c09f7), [`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`45a9147`](https://github.com/mastra-ai/mastra/commit/45a914741f578754d79d8b7de7b4e4f304d8e14a), [`a3a3624`](https://github.com/mastra-ai/mastra/commit/a3a3624f646b98e409424d8defccbd334da9e8b8), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`6246914`](https://github.com/mastra-ai/mastra/commit/62469146636911f3cbbe0880bd011c6a897a59a7), [`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`1315d8f`](https://github.com/mastra-ai/mastra/commit/1315d8f17e8e7acb61cca46b72a1d42f6d00d289), [`86b7b77`](https://github.com/mastra-ai/mastra/commit/86b7b777980d30f66e1fd134a37d2af4c22e54cc), [`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`296dc9a`](https://github.com/mastra-ai/mastra/commit/296dc9af29f3616e786c7825ec32e0df92d754c5), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`1bdfde1`](https://github.com/mastra-ai/mastra/commit/1bdfde1f4061b7c0550253a1512a2118debe7996), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448), [`3f73c07`](https://github.com/mastra-ai/mastra/commit/3f73c076727e8c36b4fff7a1b40290fb68957fa8), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`6bff877`](https://github.com/mastra-ai/mastra/commit/6bff877e214695ff8d9c84b06c13a6e6bcf9f1ed), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`d7cf7fa`](https://github.com/mastra-ai/mastra/commit/d7cf7fafc1ae1b50bd8462dd0e6c671a8606db93), [`7c1ebb1`](https://github.com/mastra-ai/mastra/commit/7c1ebb15690c4b3f0eabb19077cf8af573311e57), [`0f9a448`](https://github.com/mastra-ai/mastra/commit/0f9a448502157e59f7b76f24360ad497168f5ef8), [`f5a17d9`](https://github.com/mastra-ai/mastra/commit/f5a17d95c19e7d4149996932bd8d1905089f031d), [`578bf2e`](https://github.com/mastra-ai/mastra/commit/578bf2e6a88e9d5b8bf502204e15a95dfbb679ae), [`3e50f63`](https://github.com/mastra-ai/mastra/commit/3e50f63db85e9fe365b4ce5daecb0ac0dc464d93), [`25956fc`](https://github.com/mastra-ai/mastra/commit/25956fc8841780d506acb22b618fdb4dcf6c4e21), [`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`deaf0c4`](https://github.com/mastra-ai/mastra/commit/deaf0c4c38fe2e988a094c63bbd8899436f4e579), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`4f16ff8`](https://github.com/mastra-ai/mastra/commit/4f16ff824bf2f9b0ddc93f210477c10c8a4fb1ab), [`b4c89b4`](https://github.com/mastra-ai/mastra/commit/b4c89b4371b0c86da57403ad1a3b3ef0681f3128), [`e6534fa`](https://github.com/mastra-ai/mastra/commit/e6534fab031216f6cb48c4c9907cbfdce9d60bc6), [`210cb7a`](https://github.com/mastra-ai/mastra/commit/210cb7a167998c7bbf72cb3b93e6eb0563330239), [`06b2d87`](https://github.com/mastra-ai/mastra/commit/06b2d87e63bcdd0ed59215c6789692b9b12de376), [`1c67d85`](https://github.com/mastra-ai/mastra/commit/1c67d85e9da8285662f4dbbf47e0378c3fee0747), [`ac01d63`](https://github.com/mastra-ai/mastra/commit/ac01d6355974aec73fdb8781449ed12bac582094), [`8627c23`](https://github.com/mastra-ai/mastra/commit/8627c23d794485fb97d533fc2a7a8323bfec2225), [`03ebe06`](https://github.com/mastra-ai/mastra/commit/03ebe06aeb671d7127b700e53853ed0759e4c19f), [`80a3324`](https://github.com/mastra-ai/mastra/commit/80a33245d3110204de6f56d61211523ffe338692), [`e44e8f3`](https://github.com/mastra-ai/mastra/commit/e44e8f370b66c339ddcaba946d33da6d3c3f06cd), [`d9d2881`](https://github.com/mastra-ai/mastra/commit/d9d2881ede6dd6c023d144215fc812062aed0890), [`a810a05`](https://github.com/mastra-ai/mastra/commit/a810a058f62ad407cfc1701e0be36ae91145d7cf), [`ba24be6`](https://github.com/mastra-ai/mastra/commit/ba24be662439c331ab23a600041f93803c89eca8), [`842b5fe`](https://github.com/mastra-ai/mastra/commit/842b5fe22b6a7fa811bd14e48eb9af523ac989f2), [`26ff3b9`](https://github.com/mastra-ai/mastra/commit/26ff3b9144132bd8570e4796d436fb57a9a2bf24), [`3ff2be3`](https://github.com/mastra-ai/mastra/commit/3ff2be3a5a579d2e2d7084ba0624ec24faadce4d), [`990611b`](https://github.com/mastra-ai/mastra/commit/990611ba76eb876d86c9c594371ae5f02f94b432), [`80bdf3a`](https://github.com/mastra-ai/mastra/commit/80bdf3ae16ade6ff63bde0cb16fa2df8ab7dd4dd), [`c967a5e`](https://github.com/mastra-ai/mastra/commit/c967a5eec150c5dc5418c4a4388982d1fb7ad27c), [`195e83c`](https://github.com/mastra-ai/mastra/commit/195e83c077687f6016fd8090324975c8d8cea50b), [`1315d8f`](https://github.com/mastra-ai/mastra/commit/1315d8f17e8e7acb61cca46b72a1d42f6d00d289), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`fd96298`](https://github.com/mastra-ai/mastra/commit/fd96298a8367622f4ebfcaa97b5b6c1fbbd14564), [`66bbfb5`](https://github.com/mastra-ai/mastra/commit/66bbfb5f05b473d39f88c0e4a481ccac41634f3a), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`f8da216`](https://github.com/mastra-ai/mastra/commit/f8da21633e7eb0e31c9ce0fc30567870d19416d3), [`9168b80`](https://github.com/mastra-ai/mastra/commit/9168b80120a82816b1b9f2385e788bf86fa5d9cd), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`4a09a9c`](https://github.com/mastra-ai/mastra/commit/4a09a9c0474ef643558fcb5f0edc542b82f1cab0), [`5f798b3`](https://github.com/mastra-ai/mastra/commit/5f798b3362e9bdf4d690f85245606e146eef60b9), [`6a84954`](https://github.com/mastra-ai/mastra/commit/6a84954a2667f85b6d59da652dab1bbff007ccb0), [`1e83a47`](https://github.com/mastra-ai/mastra/commit/1e83a4734ab61ba5926af6793e3569a78b72ed37), [`52d8ef0`](https://github.com/mastra-ai/mastra/commit/52d8ef03801f1deb7ee48532fc4190dd4a33916c), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`7fdcaa6`](https://github.com/mastra-ai/mastra/commit/7fdcaa66105d64290f9b14432a12ec99f39c4d3a), [`d6c56f9`](https://github.com/mastra-ai/mastra/commit/d6c56f951db3213330b98b0abafa9778c8770e58), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`bf936e2`](https://github.com/mastra-ai/mastra/commit/bf936e2c89b2ff0dad5695b873ddc009ba96d41e), [`7fb580a`](https://github.com/mastra-ai/mastra/commit/7fb580ac73fbcacf2ff00872a3395f73ae1b9fa5), [`59866f2`](https://github.com/mastra-ai/mastra/commit/59866f2e0a7986bea3b418aaa2c2f79a77d33719), [`ed5d606`](https://github.com/mastra-ai/mastra/commit/ed5d606739c5e3fbdfa9f272df7809aa5ab43b1d), [`c71e307`](https://github.com/mastra-ai/mastra/commit/c71e3077e69eae3f25aa628e3778f153a9d6ab36), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`f53d5bd`](https://github.com/mastra-ai/mastra/commit/f53d5bd4885b29e4ac29a428a6044088ea8d6aa3), [`87db0e4`](https://github.com/mastra-ai/mastra/commit/87db0e49a8c04030eb74fff7f051fac330678839), [`32980a3`](https://github.com/mastra-ai/mastra/commit/32980a3e2413d0274ac244d32c37d910edc13f00), [`a4f6806`](https://github.com/mastra-ai/mastra/commit/a4f68065d082af57770e7ee3d34996fdc914dbd1), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`82e3365`](https://github.com/mastra-ai/mastra/commit/82e3365ef7c9bf7bee2e7a7029035ea262d68895), [`6104347`](https://github.com/mastra-ai/mastra/commit/61043473ba6bfd0a25156824e853e13165562e6c), [`261edb9`](https://github.com/mastra-ai/mastra/commit/261edb9bc0cfbed2b77090b87562307a360f1a04), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`a53f19b`](https://github.com/mastra-ai/mastra/commit/a53f19b9badb8bd349fe2f885814e9db6b7d3c4b), [`edfe906`](https://github.com/mastra-ai/mastra/commit/edfe906f7926faf8c63c21b3c87e797985557feb), [`ffdfa25`](https://github.com/mastra-ai/mastra/commit/ffdfa25b5cdf3ecfd0c5a2e96363c3ba50995ce9), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`65b1183`](https://github.com/mastra-ai/mastra/commit/65b11832834f87a9bc8719391deb27559de5138a), [`0ce1d05`](https://github.com/mastra-ai/mastra/commit/0ce1d054586c5d348543d2749067b40adbc9b783), [`6698e16`](https://github.com/mastra-ai/mastra/commit/6698e168d74e054fc3efa97b19025fb2d1dafc45), [`333785c`](https://github.com/mastra-ai/mastra/commit/333785c93cbb01e42c60167e995457c28897ddbf), [`bda2235`](https://github.com/mastra-ai/mastra/commit/bda22353ee28f2df0eaea555f7cae1549f979c0b), [`efd5c81`](https://github.com/mastra-ai/mastra/commit/efd5c81cc25fde3c2ddd86fc1178deb4ec176e19), [`a04d1a6`](https://github.com/mastra-ai/mastra/commit/a04d1a642ccae3ea3b28be37067480d49bcb1b7d), [`1b482c2`](https://github.com/mastra-ai/mastra/commit/1b482c2d89244dd758c41e5f927a2b44041388d2), [`5dba2a4`](https://github.com/mastra-ai/mastra/commit/5dba2a41600385751f5aace79878904e1972609d), [`45bfb88`](https://github.com/mastra-ai/mastra/commit/45bfb88fd52f1dd3be20e2a38905777c96499c90), [`ff28284`](https://github.com/mastra-ai/mastra/commit/ff2828416f14daff9d956e6a352fdaa23c950979), [`4bcdfaf`](https://github.com/mastra-ai/mastra/commit/4bcdfaf0eac3199d7cb171b0a19a92c9c341eea4), [`e3b9307`](https://github.com/mastra-ai/mastra/commit/e3b9307098daefbfae2a52ae2ef51bc9fc701190), [`d6834c5`](https://github.com/mastra-ai/mastra/commit/d6834c5a7866b16734d23900163c2414ed70d791), [`43ea2a1`](https://github.com/mastra-ai/mastra/commit/43ea2a1f5c5867d0f41254047a786e96cd00798b), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`cfd0d9e`](https://github.com/mastra-ai/mastra/commit/cfd0d9ec77ec3c69dd96f79cdb579e03d79f22ce), [`acc3513`](https://github.com/mastra-ai/mastra/commit/acc3513b19f79bf0a7ec2998694580edca54086c), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448), [`a7eb4a1`](https://github.com/mastra-ai/mastra/commit/a7eb4a11450f6170274ed5141bffe821d4fdd5a6), [`1b1dd7b`](https://github.com/mastra-ai/mastra/commit/1b1dd7bc0e59b7a8bfabd09a3eec1ccd95b4c2f3), [`0976933`](https://github.com/mastra-ai/mastra/commit/0976933142333ec78451feef265b68bcb45aa5e7), [`242b945`](https://github.com/mastra-ai/mastra/commit/242b94558777bfbdeb42cbfea84afff0b6ad0633), [`c52d346`](https://github.com/mastra-ai/mastra/commit/c52d3462ec831a5d95926ecd3d3373f5928ad2e5), [`af4636a`](https://github.com/mastra-ai/mastra/commit/af4636a74463275d71c1d13a38f7d2b738f128bf), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`2eabc09`](https://github.com/mastra-ai/mastra/commit/2eabc097d86d52fbd0123da36a7c874154cc384f), [`0023e79`](https://github.com/mastra-ai/mastra/commit/0023e7919431078280abd11c89d1edeae35fcc69), [`c2ad51e`](https://github.com/mastra-ai/mastra/commit/c2ad51e2467f901eecba8c9f4a45e22a50bd7c18), [`25ca73d`](https://github.com/mastra-ai/mastra/commit/25ca73d25dee7ce9f0ca72939e3a505c4db7257e), [`2f9ef3f`](https://github.com/mastra-ai/mastra/commit/2f9ef3f4ca06fc2dcdd5088c26b7f4da6a016791), [`e7eefcb`](https://github.com/mastra-ai/mastra/commit/e7eefcb162cda7c493e8c3bf43050ead0efbcb2c), [`fea5cae`](https://github.com/mastra-ai/mastra/commit/fea5caedc7e2cfea51784a15e015952692027abf), [`72ce266`](https://github.com/mastra-ai/mastra/commit/72ce2669506e755c0bbe73baf3a7e8ea5208bdad), [`4d7aca2`](https://github.com/mastra-ai/mastra/commit/4d7aca2fe75f225c83d1502d63079568e6ec163f), [`e1cead1`](https://github.com/mastra-ai/mastra/commit/e1cead17b5f3653cf00d2f90cc19b113119c02ba), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`25956fc`](https://github.com/mastra-ai/mastra/commit/25956fc8841780d506acb22b618fdb4dcf6c4e21), [`d9d93b2`](https://github.com/mastra-ai/mastra/commit/d9d93b25e4a65ad5fa153fa35be7ed149c8d587f), [`c4ec889`](https://github.com/mastra-ai/mastra/commit/c4ec889561c0264c43f66d04d587bee4ce35e792), [`4b59f78`](https://github.com/mastra-ai/mastra/commit/4b59f786cbc9a7d1ef07a07517dbd4b96865e99d), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`3dc97ea`](https://github.com/mastra-ai/mastra/commit/3dc97ea415fad353b48a13095fad1835933cc12a), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`94e7ae9`](https://github.com/mastra-ai/mastra/commit/94e7ae970b37c888cd1244ef013292639a2fe6d1), [`d97107a`](https://github.com/mastra-ai/mastra/commit/d97107a7edc517ae8feddf914fc43cd80a66c0a8), [`e6a2860`](https://github.com/mastra-ai/mastra/commit/e6a2860649cc51f87d32d78b766ae2126446ba07), [`7010c5d`](https://github.com/mastra-ai/mastra/commit/7010c5d15728bf9c5dfe4fb6b1bf80ce23bf143a), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7), [`3d01cd3`](https://github.com/mastra-ai/mastra/commit/3d01cd387321b6f9c5cac31d487c84bf51b19c78), [`7bf3086`](https://github.com/mastra-ai/mastra/commit/7bf308663f0115ca74ad20554ade740f06640859), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72), [`0282e16`](https://github.com/mastra-ai/mastra/commit/0282e16115538c8e9b248b90f0748eb01cb5dc98), [`a8dd139`](https://github.com/mastra-ai/mastra/commit/a8dd1391a9fe9a6632c25809ef236980afa9a020), [`6a667b4`](https://github.com/mastra-ai/mastra/commit/6a667b4b7cd6a93fe41fcdd357b08c5a8c09b9ab), [`9be8878`](https://github.com/mastra-ai/mastra/commit/9be8878dcf0388e84fc4873e0eec27bd49b881a4), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`2440e09`](https://github.com/mastra-ai/mastra/commit/2440e096ea6c2def1ccc1eb2d0f3f5b88c4af940), [`d6c63e4`](https://github.com/mastra-ai/mastra/commit/d6c63e4b757babb95a735d0e421d4dac67c1dcf1), [`2093fbd`](https://github.com/mastra-ai/mastra/commit/2093fbd53bb744bae19ec89f6d73db9a66fbe8a7), [`a59049b`](https://github.com/mastra-ai/mastra/commit/a59049b1652a13efff66ac826326b5ed9a550342), [`7bd85ea`](https://github.com/mastra-ai/mastra/commit/7bd85ea7588b71c25ce9f4019c88f8539be5dcbc), [`83fa004`](https://github.com/mastra-ai/mastra/commit/83fa0044bfda8b703a83883dbd8bef204844d13f), [`833432b`](https://github.com/mastra-ai/mastra/commit/833432b92612b7f122aa7342132ea37f2ad96e77), [`a463cdf`](https://github.com/mastra-ai/mastra/commit/a463cdf1c95c3059e70f0bff27959e8558bb899d), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`e4d3761`](https://github.com/mastra-ai/mastra/commit/e4d376143cf3322885a7e6e4048e536ce441f785), [`7b4393d`](https://github.com/mastra-ai/mastra/commit/7b4393d557411fdcf07b0e30e5acaf7cc85154ae), [`0ea6b80`](https://github.com/mastra-ai/mastra/commit/0ea6b8001408ce02b56e8be0536b0fd8cbaf8ad2)]:
|
|
85
|
+
- @mastra/code-sdk@1.2.0
|
|
86
|
+
- @mastra/core@1.58.0
|
|
87
|
+
- @mastra/libsql@1.20.0
|
|
88
|
+
- @mastra/pg@1.20.0
|
|
89
|
+
- @mastra/github-signals@0.2.5
|
|
90
|
+
- @mastra/agent-browser@0.5.1
|
|
91
|
+
- @mastra/stagehand@0.3.2
|
|
92
|
+
- @mastra/observability@1.16.6
|
|
93
|
+
- @mastra/schema-compat@1.3.6
|
|
94
|
+
- @mastra/memory@1.26.1
|
|
95
|
+
- @mastra/mcp@1.16.0
|
|
96
|
+
- @mastra/duckdb@1.6.1
|
|
97
|
+
|
|
98
|
+
## 0.33.0-alpha.17
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- Added the `/workflows` command for listing, inspecting, running, and deleting chat-built workflows. ([#21210](https://github.com/mastra-ai/mastra/pull/21210))
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Fixed `/workflows` command errors so the message from a failure is shown, whether the failure is a string or an object with a message, instead of `[object Object]`. ([#21287](https://github.com/mastra-ai/mastra/pull/21287))
|
|
107
|
+
|
|
108
|
+
- Fixed a goal started on a new thread being cleared moments after it was set. Starting a goal that creates its own thread now persists that goal to the new thread instead of dropping it. ([#21255](https://github.com/mastra-ai/mastra/pull/21255))
|
|
109
|
+
|
|
110
|
+
- Updated dependencies [[`296dc9a`](https://github.com/mastra-ai/mastra/commit/296dc9af29f3616e786c7825ec32e0df92d754c5), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448), [`4a09a9c`](https://github.com/mastra-ai/mastra/commit/4a09a9c0474ef643558fcb5f0edc542b82f1cab0), [`1e83a47`](https://github.com/mastra-ai/mastra/commit/1e83a4734ab61ba5926af6793e3569a78b72ed37), [`ff28284`](https://github.com/mastra-ai/mastra/commit/ff2828416f14daff9d956e6a352fdaa23c950979), [`1670533`](https://github.com/mastra-ai/mastra/commit/1670533986f6bacf567746245348125e3a106448)]:
|
|
111
|
+
- @mastra/core@1.58.0-alpha.16
|
|
112
|
+
- @mastra/code-sdk@1.2.0-alpha.18
|
|
113
|
+
|
|
114
|
+
## 0.33.0-alpha.16
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [[`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b), [`dc4a25d`](https://github.com/mastra-ai/mastra/commit/dc4a25d41af4e2fe97a816070eaec6aa963ab53b)]:
|
|
119
|
+
- @mastra/memory@1.26.1-alpha.7
|
|
120
|
+
- @mastra/core@1.58.0-alpha.15
|
|
121
|
+
- @mastra/libsql@1.20.0-alpha.3
|
|
122
|
+
- @mastra/pg@1.20.0-alpha.4
|
|
123
|
+
- @mastra/code-sdk@1.2.0-alpha.17
|
|
124
|
+
|
|
125
|
+
## 0.33.0-alpha.15
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- Updated dependencies [[`210cb7a`](https://github.com/mastra-ai/mastra/commit/210cb7a167998c7bbf72cb3b93e6eb0563330239), [`5f798b3`](https://github.com/mastra-ai/mastra/commit/5f798b3362e9bdf4d690f85245606e146eef60b9), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`25ca73d`](https://github.com/mastra-ai/mastra/commit/25ca73d25dee7ce9f0ca72939e3a505c4db7257e), [`e1cead1`](https://github.com/mastra-ai/mastra/commit/e1cead17b5f3653cf00d2f90cc19b113119c02ba), [`01a2943`](https://github.com/mastra-ai/mastra/commit/01a2943a7d886edefdff072bfa51f055bab54437), [`d97107a`](https://github.com/mastra-ai/mastra/commit/d97107a7edc517ae8feddf914fc43cd80a66c0a8)]:
|
|
130
|
+
- @mastra/core@1.58.0-alpha.14
|
|
131
|
+
- @mastra/observability@1.16.6-alpha.4
|
|
132
|
+
- @mastra/code-sdk@1.2.0-alpha.16
|
|
133
|
+
- @mastra/mcp@1.16.0-alpha.2
|
|
134
|
+
|
|
135
|
+
## 0.33.0-alpha.14
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- The web sign-in page now explains when the identity provider denies access — showing the reason and a hint to ask an organization admin to add the account — instead of silently returning to the sign-in button. ([#21166](https://github.com/mastra-ai/mastra/pull/21166))
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [[`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`d6c56f9`](https://github.com/mastra-ai/mastra/commit/d6c56f951db3213330b98b0abafa9778c8770e58), [`9571e3a`](https://github.com/mastra-ai/mastra/commit/9571e3a06ed2c5220196460bf82a2129255c3a8b), [`a04d1a6`](https://github.com/mastra-ai/mastra/commit/a04d1a642ccae3ea3b28be37067480d49bcb1b7d), [`acc3513`](https://github.com/mastra-ai/mastra/commit/acc3513b19f79bf0a7ec2998694580edca54086c), [`94e7ae9`](https://github.com/mastra-ai/mastra/commit/94e7ae970b37c888cd1244ef013292639a2fe6d1), [`6a667b4`](https://github.com/mastra-ai/mastra/commit/6a667b4b7cd6a93fe41fcdd357b08c5a8c09b9ab), [`2440e09`](https://github.com/mastra-ai/mastra/commit/2440e096ea6c2def1ccc1eb2d0f3f5b88c4af940), [`a59049b`](https://github.com/mastra-ai/mastra/commit/a59049b1652a13efff66ac826326b5ed9a550342)]:
|
|
142
|
+
- @mastra/core@1.58.0-alpha.13
|
|
143
|
+
- @mastra/code-sdk@1.2.0-alpha.15
|
|
144
|
+
|
|
145
|
+
## 0.33.0-alpha.13
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- A plan approval arriving while a command overlay (such as the /models pack selector) is open no longer steals focus from the overlay or deadlocks it. The approval defers its focus until the overlay closes, then takes focus so it must still be answered. ([#21142](https://github.com/mastra-ai/mastra/pull/21142))
|
|
150
|
+
|
|
151
|
+
- Fixed duplicate `Thinking...` lines in the chat transcript. When a model emitted more than one reasoning span in a single step, each span rendered its own label; consecutive hidden reasoning parts now collapse into a single `Thinking...` line. ([#21134](https://github.com/mastra-ai/mastra/pull/21134))
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [[`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`2e4624e`](https://github.com/mastra-ai/mastra/commit/2e4624edb6917e61249cb60ee377735e7af7e4a9), [`e6534fa`](https://github.com/mastra-ai/mastra/commit/e6534fab031216f6cb48c4c9907cbfdce9d60bc6), [`7fdcaa6`](https://github.com/mastra-ai/mastra/commit/7fdcaa66105d64290f9b14432a12ec99f39c4d3a), [`65b1183`](https://github.com/mastra-ai/mastra/commit/65b11832834f87a9bc8719391deb27559de5138a), [`5dba2a4`](https://github.com/mastra-ai/mastra/commit/5dba2a41600385751f5aace79878904e1972609d), [`cfd0d9e`](https://github.com/mastra-ai/mastra/commit/cfd0d9ec77ec3c69dd96f79cdb579e03d79f22ce), [`d9d93b2`](https://github.com/mastra-ai/mastra/commit/d9d93b25e4a65ad5fa153fa35be7ed149c8d587f)]:
|
|
154
|
+
- @mastra/core@1.58.0-alpha.12
|
|
155
|
+
- @mastra/code-sdk@1.2.0-alpha.13
|
|
156
|
+
- @mastra/observability@1.16.6-alpha.3
|
|
157
|
+
- @mastra/schema-compat@1.3.6-alpha.3
|
|
158
|
+
- @mastra/mcp@1.16.0-alpha.2
|
|
159
|
+
- @mastra/memory@1.26.1-alpha.6
|
|
160
|
+
|
|
161
|
+
## 0.33.0-alpha.12
|
|
162
|
+
|
|
163
|
+
### Minor Changes
|
|
164
|
+
|
|
165
|
+
- Plugins installed with `/plugins` can now contribute processors and signal providers, not just tools, commands, skills, and instructions. Author them against `mastracode/plugin` with the new `processors` and `signalProviders` fields. ([#20848](https://github.com/mastra-ai/mastra/pull/20848))
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- Keep input typed while the TUI is handling a slash command or a `!` shell command. Submitting during that window used to be swallowed — the editor cleared, nothing ran, and the text was gone — because the input loop had already moved on and no longer had a read pending. Submissions made while the loop is busy are now held and delivered in order on its next read, so a quick sequence like: ([#21100](https://github.com/mastra-ai/mastra/pull/21100))
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
!echo hi
|
|
173
|
+
/browser clear viewport
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
runs both commands instead of only the first.
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [[`b8ce7ec`](https://github.com/mastra-ai/mastra/commit/b8ce7ec96e39343c6c2f36d12d68a9ad816c09f7), [`a3a3624`](https://github.com/mastra-ai/mastra/commit/a3a3624f646b98e409424d8defccbd334da9e8b8), [`6246914`](https://github.com/mastra-ai/mastra/commit/62469146636911f3cbbe0880bd011c6a897a59a7), [`1315d8f`](https://github.com/mastra-ai/mastra/commit/1315d8f17e8e7acb61cca46b72a1d42f6d00d289), [`3f73c07`](https://github.com/mastra-ai/mastra/commit/3f73c076727e8c36b4fff7a1b40290fb68957fa8), [`7c1ebb1`](https://github.com/mastra-ai/mastra/commit/7c1ebb15690c4b3f0eabb19077cf8af573311e57), [`1315d8f`](https://github.com/mastra-ai/mastra/commit/1315d8f17e8e7acb61cca46b72a1d42f6d00d289), [`32980a3`](https://github.com/mastra-ai/mastra/commit/32980a3e2413d0274ac244d32c37d910edc13f00), [`261edb9`](https://github.com/mastra-ai/mastra/commit/261edb9bc0cfbed2b77090b87562307a360f1a04), [`4bcdfaf`](https://github.com/mastra-ai/mastra/commit/4bcdfaf0eac3199d7cb171b0a19a92c9c341eea4), [`1b1dd7b`](https://github.com/mastra-ai/mastra/commit/1b1dd7bc0e59b7a8bfabd09a3eec1ccd95b4c2f3), [`af4636a`](https://github.com/mastra-ai/mastra/commit/af4636a74463275d71c1d13a38f7d2b738f128bf), [`a463cdf`](https://github.com/mastra-ai/mastra/commit/a463cdf1c95c3059e70f0bff27959e8558bb899d), [`0ea6b80`](https://github.com/mastra-ai/mastra/commit/0ea6b8001408ce02b56e8be0536b0fd8cbaf8ad2)]:
|
|
179
|
+
- @mastra/core@1.58.0-alpha.11
|
|
180
|
+
- @mastra/github-signals@0.2.5-alpha.1
|
|
181
|
+
- @mastra/code-sdk@1.2.0-alpha.12
|
|
182
|
+
- @mastra/memory@1.26.1-alpha.5
|
|
183
|
+
- @mastra/mcp@1.16.0-alpha.2
|
|
184
|
+
|
|
185
|
+
## 0.33.0-alpha.11
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies [[`66bbfb5`](https://github.com/mastra-ai/mastra/commit/66bbfb5f05b473d39f88c0e4a481ccac41634f3a)]:
|
|
190
|
+
- @mastra/core@1.58.0-alpha.10
|
|
191
|
+
- @mastra/code-sdk@1.2.0-alpha.11
|
|
192
|
+
|
|
193
|
+
## 0.33.0-alpha.10
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies [[`86b7b77`](https://github.com/mastra-ai/mastra/commit/86b7b777980d30f66e1fd134a37d2af4c22e54cc), [`80a3324`](https://github.com/mastra-ai/mastra/commit/80a33245d3110204de6f56d61211523ffe338692), [`d9d2881`](https://github.com/mastra-ai/mastra/commit/d9d2881ede6dd6c023d144215fc812062aed0890), [`82e3365`](https://github.com/mastra-ai/mastra/commit/82e3365ef7c9bf7bee2e7a7029035ea262d68895), [`1b482c2`](https://github.com/mastra-ai/mastra/commit/1b482c2d89244dd758c41e5f927a2b44041388d2), [`e6a2860`](https://github.com/mastra-ai/mastra/commit/e6a2860649cc51f87d32d78b766ae2126446ba07), [`7bd85ea`](https://github.com/mastra-ai/mastra/commit/7bd85ea7588b71c25ce9f4019c88f8539be5dcbc), [`833432b`](https://github.com/mastra-ai/mastra/commit/833432b92612b7f122aa7342132ea37f2ad96e77)]:
|
|
198
|
+
- @mastra/core@1.58.0-alpha.9
|
|
199
|
+
- @mastra/code-sdk@1.2.0-alpha.10
|
|
200
|
+
|
|
201
|
+
## 0.33.0-alpha.9
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- Updated dependencies [[`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`a53f19b`](https://github.com/mastra-ai/mastra/commit/a53f19b9badb8bd349fe2f885814e9db6b7d3c4b), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72)]:
|
|
206
|
+
- @mastra/core@1.58.0-alpha.8
|
|
207
|
+
- @mastra/memory@1.26.1-alpha.4
|
|
208
|
+
- @mastra/libsql@1.20.0-alpha.2
|
|
209
|
+
- @mastra/pg@1.20.0-alpha.3
|
|
210
|
+
- @mastra/code-sdk@1.2.0-alpha.9
|
|
211
|
+
|
|
3
212
|
## 0.33.0-alpha.8
|
|
4
213
|
|
|
5
214
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Learn more in the [documentation](https://code.mastra.ai/) and [announcement pos
|
|
|
13
13
|
- **OAuth login**: Authenticate with Anthropic (Claude Max) and OpenAI (ChatGPT Plus/Codex)
|
|
14
14
|
- **Persistent conversations**: Threads are saved per-project and resume automatically
|
|
15
15
|
- **Coding tools**: View files, edit code, run shell commands
|
|
16
|
+
- **Dynamic workflows**: Build workflows through chat, then list, inspect, run, and delete them from the TUI
|
|
16
17
|
- **Goals**: Pursue longer-running objectives with configurable judge models and goal-enabled commands/skills
|
|
17
18
|
- **Plan persistence**: Approved plans are saved as markdown files for future reference
|
|
18
19
|
- **Token tracking**: Monitor usage with persistent token counts per thread
|
|
@@ -102,6 +103,7 @@ Select a suggestion with arrow keys and press Tab to insert it.
|
|
|
102
103
|
| `/sandbox` | Manage allowed paths (add/remove dirs) |
|
|
103
104
|
| `/permissions` | View/manage tool approval permissions |
|
|
104
105
|
| `/plugins` | Install and manage trusted Mastra Code plugins |
|
|
106
|
+
| `/workflows` | List, inspect, run, and delete chat-built workflows |
|
|
105
107
|
| `/settings` | General settings (notifications, YOLO, etc.) |
|
|
106
108
|
| `/yolo` | Toggle YOLO mode (auto-approve all tools) |
|
|
107
109
|
| `/resource` | Show/switch resource ID (tag for sharing) |
|
|
@@ -112,6 +114,25 @@ Select a suggestion with arrow keys and press Tab to insert it.
|
|
|
112
114
|
| `/help` | Show available commands |
|
|
113
115
|
| `/exit` | Exit the TUI |
|
|
114
116
|
|
|
117
|
+
### Dynamic workflows
|
|
118
|
+
|
|
119
|
+
Create a workflow by describing it in build-mode chat. For example:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Build me a workflow that accepts a topic, researches it, and returns a concise summary.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Mastra Code discovers the registered agents, tools, and workflows, builds a complete workflow definition, validates it, and saves it for future sessions. Workflow creation is chat-driven; `/workflows` manages workflows that have already been saved.
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
/workflows list
|
|
129
|
+
/workflows show research-summary
|
|
130
|
+
/workflows run research-summary {"topic":"dynamic workflows"}
|
|
131
|
+
/workflows delete research-summary
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Run `/workflows help` for the full command reference.
|
|
135
|
+
|
|
115
136
|
### Plugins
|
|
116
137
|
|
|
117
138
|
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.
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_tui = require("./tui-
|
|
2
|
+
const require_tui = require("./tui-C-5CxtMW.cjs");
|
|
3
3
|
let _mastra_code_sdk = require("@mastra/code-sdk");
|
|
4
4
|
let fs = require("fs");
|
|
5
5
|
fs = require_tui.__toESM(fs, 1);
|
|
@@ -13,7 +13,7 @@ let _mastra_code_sdk_utils_stdin_pipe = require("@mastra/code-sdk/utils/stdin-pi
|
|
|
13
13
|
let _mastra_code_sdk_utils_thread_lock = require("@mastra/code-sdk/utils/thread-lock");
|
|
14
14
|
//#region src/version.ts
|
|
15
15
|
function getCurrentVersion() {
|
|
16
|
-
return "0.33.0
|
|
16
|
+
return "0.33.0";
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/main.ts
|
|
@@ -26,6 +26,7 @@ let hookManager;
|
|
|
26
26
|
let authStorage;
|
|
27
27
|
let signalsPubSub;
|
|
28
28
|
let storageMaintenance;
|
|
29
|
+
let stopPluginSignalProviders;
|
|
29
30
|
let analytics;
|
|
30
31
|
let tui;
|
|
31
32
|
let storageClosed = false;
|
|
@@ -73,6 +74,7 @@ async function tuiMain(pipedInput) {
|
|
|
73
74
|
authStorage = result.authStorage;
|
|
74
75
|
signalsPubSub = result.signalsPubSub;
|
|
75
76
|
storageMaintenance = result.storageMaintenance;
|
|
77
|
+
stopPluginSignalProviders = result.stopPluginSignalProviders;
|
|
76
78
|
if (result.storageWarning) console.info(`⚠ ${result.storageWarning}`);
|
|
77
79
|
if (result.observabilityWarning) console.info(`⚠ ${result.observabilityWarning}`);
|
|
78
80
|
(0, _mastra_code_sdk_utils_debug_log.setupDebugLogging)();
|
|
@@ -125,6 +127,9 @@ async function tuiMain(pipedInput) {
|
|
|
125
127
|
}
|
|
126
128
|
const asyncCleanup = async () => {
|
|
127
129
|
(0, _mastra_code_sdk_utils_thread_lock.releaseAllThreadLocks)();
|
|
130
|
+
try {
|
|
131
|
+
stopPluginSignalProviders?.();
|
|
132
|
+
} catch {}
|
|
128
133
|
const closeSignalsPubSub = signalsPubSub?.close;
|
|
129
134
|
await Promise.allSettled([
|
|
130
135
|
mcpManager?.disconnect(),
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["detectTerminalTheme","MastraTUI"],"sources":["../src/version.ts","../src/main.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n\n const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n","#!/usr/bin/env node\n/**\n * Main entry point for Mastra Code TUI.\n */\nimport fs from 'node:fs';\n\nimport { createMastraCode } from '@mastra/code-sdk';\nimport { createMastraCodeAnalytics } from '@mastra/code-sdk/analytics';\nimport { isStreamDestroyedError } from '@mastra/code-sdk/error-classification';\nimport { hasHeadlessFlag, runMCCli } from '@mastra/code-sdk/headless/index';\nimport { createBrowserFromSettings, loadSettings } from '@mastra/code-sdk/onboarding/settings';\nimport { formatScaffoldSuccess, scaffoldPlugin } from '@mastra/code-sdk/plugins/scaffold';\nimport { setupDebugLogging } from '@mastra/code-sdk/utils/debug-log';\nimport { drainPipedStdin, reopenStdinFromTTY } from '@mastra/code-sdk/utils/stdin-pipe';\nimport { releaseAllThreadLocks } from '@mastra/code-sdk/utils/thread-lock';\nimport { detectTerminalTheme } from './tui/detect-theme.js';\nimport { MastraTUI } from './tui/index.js';\nimport { applyThemeMode, restoreTerminalForeground } from './tui/theme.js';\nimport { getCurrentVersion } from './version.js';\n\nlet controller: Awaited<ReturnType<typeof createMastraCode>>['controller'];\nlet mcpManager: Awaited<ReturnType<typeof createMastraCode>>['mcpManager'];\nlet hookManager: Awaited<ReturnType<typeof createMastraCode>>['hookManager'];\nlet authStorage: Awaited<ReturnType<typeof createMastraCode>>['authStorage'];\nlet signalsPubSub: Awaited<ReturnType<typeof createMastraCode>>['signalsPubSub'];\nlet storageMaintenance: Awaited<ReturnType<typeof createMastraCode>>['storageMaintenance'];\nlet analytics: ReturnType<typeof createMastraCodeAnalytics> | undefined;\nlet tui: MastraTUI | undefined;\nlet storageClosed = false;\n\nfunction isTruthyEnv(name: string): boolean {\n return ['1', 'true', 'yes', 'on'].includes(process.env[name]?.trim().toLowerCase() ?? '');\n}\n\nfunction resolveInitialStateFromEnv() {\n const currentModelId = process.env.MASTRACODE_MODEL_ID?.trim();\n const initialState: Record<string, unknown> = {};\n if (currentModelId) initialState.currentModelId = currentModelId;\n if (isTruthyEnv('MASTRACODE_YOLO')) initialState.yolo = true;\n return Object.keys(initialState).length > 0 ? initialState : undefined;\n}\n\n// Global safety nets — catch any uncaught errors from storage init, etc.\nprocess.on('uncaughtException', error => {\n // ERR_STREAM_DESTROYED is non-fatal — happens routinely when streams close\n // during shutdown, cancelled LLM requests, or LSP/subprocess exits (#13548, #13549)\n if (isStreamDestroyedError(error)) return;\n handleFatalError(error);\n});\nprocess.on('unhandledRejection', reason => {\n if (isStreamDestroyedError(reason)) return;\n handleFatalError(reason instanceof Error ? reason : new Error(String(reason)));\n});\n\nasync function tuiMain(pipedInput?: string | null) {\n const settings = loadSettings();\n let browserPromise: ReturnType<typeof createBrowserFromSettings> | undefined;\n const loadBrowser = () => {\n browserPromise ??= createBrowserFromSettings(settings.browser);\n return browserPromise;\n };\n\n const initialState = resolveInitialStateFromEnv();\n const result = await createMastraCode({\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n ...(isTruthyEnv('MASTRACODE_DISABLE_MEMORY') ? { memory: false as never } : {}),\n ...(initialState ? { initialState: initialState as never } : {}),\n });\n controller = result.controller;\n mcpManager = result.mcpManager;\n hookManager = result.hookManager;\n authStorage = result.authStorage;\n signalsPubSub = result.signalsPubSub;\n storageMaintenance = result.storageMaintenance;\n\n if (result.storageWarning) {\n console.info(`⚠ ${result.storageWarning}`);\n }\n if (result.observabilityWarning) {\n console.info(`⚠ ${result.observabilityWarning}`);\n }\n\n // MCP connection is deferred to TUI.init() (after ui.start()) so that\n // status messages use showInfo() instead of console.info(), which would\n // corrupt the terminal. Headless mode still inits from headless/cli.ts.\n\n setupDebugLogging();\n\n // Detect and apply terminal theme\n // MASTRA_THEME env var is the highest-priority override\n const envTheme = process.env.MASTRA_THEME?.toLowerCase();\n let themeMode: 'dark' | 'light';\n let detectedBgHex: string | undefined;\n if (envTheme === 'dark' || envTheme === 'light') {\n themeMode = envTheme;\n } else {\n const settings = loadSettings();\n const themePref = settings.preferences.theme;\n if (themePref === 'dark' || themePref === 'light') {\n themeMode = themePref;\n } else {\n const detection = await detectTerminalTheme();\n themeMode = detection.mode;\n detectedBgHex = detection.detectedBgHex;\n }\n }\n applyThemeMode(themeMode, detectedBgHex);\n\n // createMastraCode() brought up shared resources and minted the single\n // session that all work runs through. The AgentController owns no session of its own.\n const session = result.session;\n\n analytics = createMastraCodeAnalytics({ version: getCurrentVersion() });\n analytics.capture('mastracode_session_started', {\n mode: session.mode.get(),\n resourceId: session.identity.getResourceId(),\n hasAuthStorage: Boolean(authStorage),\n hasMcp: Boolean(mcpManager),\n theme: themeMode,\n });\n\n tui = new MastraTUI({\n controller: controller,\n session,\n hookManager,\n analytics,\n authStorage,\n mcpManager,\n pluginManager: result.pluginManager,\n storageMaintenance: result.storageMaintenance,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n ...(pipedInput ? { initialMessage: `The following was piped via stdin:\\n\\n${pipedInput}` } : {}),\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n void loadBrowser()\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state.set({ activeBrowserSettings: settings.browser } as any).catch(() => {});\n })\n .catch(() => {});\n }\n}\n\nconst asyncCleanup = 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 analytics?.shutdown(),\n ]);\n // Checkpoint WAL and close the local storage connection after all producers\n // and timers are quiesced. Idempotent — repeated signals (SIGINT then SIGHUP)\n // close only once. LibSQLStore.close()/LibSQLVector.close() truncate the WAL\n // and switch back to DELETE journal mode for a clean shutdown.\n if (!storageClosed) {\n storageClosed = true;\n await storageMaintenance?.closeStorage?.().catch(() => {\n // Swallow — best-effort cleanup during shutdown. The process is exiting.\n });\n }\n};\n\nprocess.on('beforeExit', () => {\n void asyncCleanup();\n});\nprocess.on('exit', () => {\n // Ensure terminal protocols (kitty keyboard, modifyOtherKeys, bracketed paste,\n // raw mode) are disabled on ANY exit path. Without this, killing the process\n // via SIGINT/SIGTERM leaves the terminal in a corrupted state where keypresses\n // produce escape sequences like \"5;99~\" instead of normal characters.\n try {\n tui?.stop();\n } catch {\n // Failsafe: even if MastraTUI.stop() throws, write raw terminal reset\n // sequences to disable Kitty keyboard protocol, bracketed paste, and\n // modifyOtherKeys. These are the exact sequences pi-tui's terminal.stop()\n // would write.\n }\n // Belt-and-suspenders: always write terminal reset sequences directly,\n // regardless of whether tui.stop() succeeded. Writing them twice is harmless\n // but missing them leaves the terminal in a corrupted state.\n try {\n process.stdout.write(\n '\\x1b[?2004l' + // disable bracketed paste\n '\\x1b[<u' + // pop kitty keyboard protocol\n '\\x1b[>4;0m' + // disable modifyOtherKeys\n '\\x1b[?25h', // show cursor\n );\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // stdout may already be closed during exit\n }\n restoreTerminalForeground();\n releaseAllThreadLocks();\n});\n\n// For all termination signals: stop the TUI FIRST (synchronous, disables keyboard\n// protocol immediately) before doing any async cleanup. This ensures the terminal\n// escape sequences are written even if asyncCleanup hangs or the process is killed\n// during cleanup.\nconst handleTermSignal = () => {\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void asyncCleanup().finally(() => process.exit(0));\n};\nprocess.on('SIGINT', handleTermSignal);\nprocess.on('SIGTERM', handleTermSignal);\nprocess.on('SIGHUP', handleTermSignal);\n\nfunction hasEconnrefused(err: unknown, depth = 0): boolean {\n if (!err || depth > 5) return false;\n const e = err as any;\n if (e.code === 'ECONNREFUSED') return true;\n if (e.cause) return hasEconnrefused(e.cause, depth + 1);\n // AggregateError has .errors array\n if (Array.isArray(e.errors)) return e.errors.some((inner: unknown) => hasEconnrefused(inner, depth + 1));\n return false;\n}\n\nfunction pluginMain(args: string[]): void {\n if (args[0] !== 'scaffold') {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const dir = args[1];\n if (!dir) {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const id = readFlag(args, '--id');\n const name = readFlag(args, '--name');\n const targetDir = scaffoldPlugin(dir, { ...(id ? { id } : {}), ...(name ? { name } : {}) });\n process.stdout.write(`${formatScaffoldSuccess(targetDir)}\\n`);\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index === -1) return undefined;\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new Error(`Missing value for ${flag}`);\n }\n return value;\n}\n\nfunction handleFatalError(error: unknown): never {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => process.stderr.write(msg + '\\n');\n\n if (hasEconnrefused(error)) {\n const settings = loadSettings();\n const connStr = settings.storage?.pg?.connectionString;\n const target = connStr ?? 'localhost:5432';\n write(\n `\\nFailed to connect to PostgreSQL at ${target}.` +\n `\\nMake sure the database is running and accessible.` +\n `\\n\\nTo switch back to LibSQL:` +\n `\\n Set MASTRA_STORAGE_BACKEND=libsql or change the backend in /settings\\n`,\n );\n process.exit(1);\n }\n\n const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;\n write(msg);\n // Write crash log to file so it persists even if terminal closes\n try {\n const crashLog = `[${new Date().toISOString()}] ${msg}\\n${error instanceof Error && error.stack ? error.stack + '\\n' : ''}`;\n fs.appendFileSync('/tmp/mastra-crash.log', crashLog);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n process.exit(1);\n}\n\nasync function main() {\n if (process.argv[2] === 'plugin') {\n return pluginMain(process.argv.slice(3));\n }\n\n if (hasHeadlessFlag(process.argv) || process.argv.includes('--help') || process.argv.includes('-h')) {\n return runMCCli();\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({ dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve') });\n }\n\n // When stdin is piped (e.g. `cat foo | mastracode`), drain the pipe fully\n // before starting the TUI. The drain blocks until the sender process exits\n // and closes its stdout, so we never see partial output.\n let pipedInput: string | null = null;\n if (!process.stdin.isTTY) {\n process.stderr.write('Reading piped input...\\n');\n pipedInput = await drainPipedStdin();\n\n // Always reopen a real TTY — even if the pipe was empty, the original\n // stdin is consumed/closed and the TUI needs a live TTY for keyboard input.\n const reopenedStdin = reopenStdinFromTTY();\n if (!reopenedStdin) {\n process.stderr.write('No TTY available — falling back to headless mode.\\n');\n return runMCCli(pipedInput);\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACSA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,gBAAgB;AAEpB,SAAS,YAAY,MAAuB;CAC1C,OAAO;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAAC,SAAS,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK,EAAE;AAC1F;AAEA,SAAS,6BAA6B;CACpC,MAAM,iBAAiB,QAAQ,IAAI,qBAAqB,KAAK;CAC7D,MAAM,eAAwC,CAAC;CAC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KAAK,CAAC;AAChB;AAEA,eAAe,OAAO;CACpB,IAAI,QAAQ,KAAK,OAAO,UACtB,OAAO,WAAW,QAAQ,KAAK,MAAM,CAAC,CAAC;CAGzC,KAAA,GAAA,gCAAA,gBAAA,CAAoB,QAAQ,IAAI,KAAK,QAAQ,KAAK,SAAS,QAAQ,KAAK,QAAQ,KAAK,SAAS,IAAI,GAChG,QAAA,GAAA,gCAAA,SAAA,CAAgB;CAGlB,IAAI,QAAQ,KAAK,SAAS,OAAO,GAAG;EAClC,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ,EAAE,sBAAsB,QAAQ,KAAK,SAAS,0BAA0B,EAAE,CAAC;CAC5F;CAKA,IAAI,aAA4B;CAChC,IAAI,CAAC,QAAQ,MAAM,OAAO;EACxB,QAAQ,OAAO,MAAM,0BAA0B;EAC/C,aAAa,OAAA,GAAA,kCAAA,gBAAA,CAAsB;EAKnC,IAAI,EAAA,GAAA,kCAAA,mBAAA,CAAa,GAAG;GAClB,QAAQ,OAAO,MAAM,qDAAqD;GAC1E,QAAA,GAAA,gCAAA,SAAA,CAAgB,UAAU;EAC5B;CACF;CAEA,OAAO,QAAQ,UAAU;AAC3B;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["detectTerminalTheme","MastraTUI"],"sources":["../src/version.ts","../src/main.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n\n const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n","#!/usr/bin/env node\n/**\n * Main entry point for Mastra Code TUI.\n */\nimport fs from 'node:fs';\n\nimport { createMastraCode } from '@mastra/code-sdk';\nimport { createMastraCodeAnalytics } from '@mastra/code-sdk/analytics';\nimport { isStreamDestroyedError } from '@mastra/code-sdk/error-classification';\nimport { hasHeadlessFlag, runMCCli } from '@mastra/code-sdk/headless/index';\nimport { createBrowserFromSettings, loadSettings } from '@mastra/code-sdk/onboarding/settings';\nimport { formatScaffoldSuccess, scaffoldPlugin } from '@mastra/code-sdk/plugins/scaffold';\nimport { setupDebugLogging } from '@mastra/code-sdk/utils/debug-log';\nimport { drainPipedStdin, reopenStdinFromTTY } from '@mastra/code-sdk/utils/stdin-pipe';\nimport { releaseAllThreadLocks } from '@mastra/code-sdk/utils/thread-lock';\nimport { detectTerminalTheme } from './tui/detect-theme.js';\nimport { MastraTUI } from './tui/index.js';\nimport { applyThemeMode, restoreTerminalForeground } from './tui/theme.js';\nimport { getCurrentVersion } from './version.js';\n\nlet controller: Awaited<ReturnType<typeof createMastraCode>>['controller'];\nlet mcpManager: Awaited<ReturnType<typeof createMastraCode>>['mcpManager'];\nlet hookManager: Awaited<ReturnType<typeof createMastraCode>>['hookManager'];\nlet authStorage: Awaited<ReturnType<typeof createMastraCode>>['authStorage'];\nlet signalsPubSub: Awaited<ReturnType<typeof createMastraCode>>['signalsPubSub'];\nlet storageMaintenance: Awaited<ReturnType<typeof createMastraCode>>['storageMaintenance'];\nlet stopPluginSignalProviders: Awaited<ReturnType<typeof createMastraCode>>['stopPluginSignalProviders'] | undefined;\nlet analytics: ReturnType<typeof createMastraCodeAnalytics> | undefined;\nlet tui: MastraTUI | undefined;\nlet storageClosed = false;\n\nfunction isTruthyEnv(name: string): boolean {\n return ['1', 'true', 'yes', 'on'].includes(process.env[name]?.trim().toLowerCase() ?? '');\n}\n\nfunction resolveInitialStateFromEnv() {\n const currentModelId = process.env.MASTRACODE_MODEL_ID?.trim();\n const initialState: Record<string, unknown> = {};\n if (currentModelId) initialState.currentModelId = currentModelId;\n if (isTruthyEnv('MASTRACODE_YOLO')) initialState.yolo = true;\n return Object.keys(initialState).length > 0 ? initialState : undefined;\n}\n\n// Global safety nets — catch any uncaught errors from storage init, etc.\nprocess.on('uncaughtException', error => {\n // ERR_STREAM_DESTROYED is non-fatal — happens routinely when streams close\n // during shutdown, cancelled LLM requests, or LSP/subprocess exits (#13548, #13549)\n if (isStreamDestroyedError(error)) return;\n handleFatalError(error);\n});\nprocess.on('unhandledRejection', reason => {\n if (isStreamDestroyedError(reason)) return;\n handleFatalError(reason instanceof Error ? reason : new Error(String(reason)));\n});\n\nasync function tuiMain(pipedInput?: string | null) {\n const settings = loadSettings();\n let browserPromise: ReturnType<typeof createBrowserFromSettings> | undefined;\n const loadBrowser = () => {\n browserPromise ??= createBrowserFromSettings(settings.browser);\n return browserPromise;\n };\n\n const initialState = resolveInitialStateFromEnv();\n const result = await createMastraCode({\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n ...(isTruthyEnv('MASTRACODE_DISABLE_MEMORY') ? { memory: false as never } : {}),\n ...(initialState ? { initialState: initialState as never } : {}),\n });\n controller = result.controller;\n mcpManager = result.mcpManager;\n hookManager = result.hookManager;\n authStorage = result.authStorage;\n signalsPubSub = result.signalsPubSub;\n storageMaintenance = result.storageMaintenance;\n stopPluginSignalProviders = result.stopPluginSignalProviders;\n\n if (result.storageWarning) {\n console.info(`⚠ ${result.storageWarning}`);\n }\n if (result.observabilityWarning) {\n console.info(`⚠ ${result.observabilityWarning}`);\n }\n\n // MCP connection is deferred to TUI.init() (after ui.start()) so that\n // status messages use showInfo() instead of console.info(), which would\n // corrupt the terminal. Headless mode still inits from headless/cli.ts.\n\n setupDebugLogging();\n\n // Detect and apply terminal theme\n // MASTRA_THEME env var is the highest-priority override\n const envTheme = process.env.MASTRA_THEME?.toLowerCase();\n let themeMode: 'dark' | 'light';\n let detectedBgHex: string | undefined;\n if (envTheme === 'dark' || envTheme === 'light') {\n themeMode = envTheme;\n } else {\n const settings = loadSettings();\n const themePref = settings.preferences.theme;\n if (themePref === 'dark' || themePref === 'light') {\n themeMode = themePref;\n } else {\n const detection = await detectTerminalTheme();\n themeMode = detection.mode;\n detectedBgHex = detection.detectedBgHex;\n }\n }\n applyThemeMode(themeMode, detectedBgHex);\n\n // createMastraCode() brought up shared resources and minted the single\n // session that all work runs through. The AgentController owns no session of its own.\n const session = result.session;\n\n analytics = createMastraCodeAnalytics({ version: getCurrentVersion() });\n analytics.capture('mastracode_session_started', {\n mode: session.mode.get(),\n resourceId: session.identity.getResourceId(),\n hasAuthStorage: Boolean(authStorage),\n hasMcp: Boolean(mcpManager),\n theme: themeMode,\n });\n\n tui = new MastraTUI({\n controller: controller,\n session,\n hookManager,\n analytics,\n authStorage,\n mcpManager,\n pluginManager: result.pluginManager,\n storageMaintenance: result.storageMaintenance,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n ...(pipedInput ? { initialMessage: `The following was piped via stdin:\\n\\n${pipedInput}` } : {}),\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n void loadBrowser()\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state.set({ activeBrowserSettings: settings.browser } as any).catch(() => {});\n })\n .catch(() => {});\n }\n}\n\nconst asyncCleanup = async () => {\n releaseAllThreadLocks();\n // Stop plugin-contributed signal providers (and the plugin reload listener)\n // before quiescing workers: a provider that keeps polling past this point\n // could dispatch into a controller that is shutting down.\n try {\n stopPluginSignalProviders?.();\n } catch {\n // Best-effort — the process is exiting.\n }\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 analytics?.shutdown(),\n ]);\n // Checkpoint WAL and close the local storage connection after all producers\n // and timers are quiesced. Idempotent — repeated signals (SIGINT then SIGHUP)\n // close only once. LibSQLStore.close()/LibSQLVector.close() truncate the WAL\n // and switch back to DELETE journal mode for a clean shutdown.\n if (!storageClosed) {\n storageClosed = true;\n await storageMaintenance?.closeStorage?.().catch(() => {\n // Swallow — best-effort cleanup during shutdown. The process is exiting.\n });\n }\n};\n\nprocess.on('beforeExit', () => {\n void asyncCleanup();\n});\nprocess.on('exit', () => {\n // Ensure terminal protocols (kitty keyboard, modifyOtherKeys, bracketed paste,\n // raw mode) are disabled on ANY exit path. Without this, killing the process\n // via SIGINT/SIGTERM leaves the terminal in a corrupted state where keypresses\n // produce escape sequences like \"5;99~\" instead of normal characters.\n try {\n tui?.stop();\n } catch {\n // Failsafe: even if MastraTUI.stop() throws, write raw terminal reset\n // sequences to disable Kitty keyboard protocol, bracketed paste, and\n // modifyOtherKeys. These are the exact sequences pi-tui's terminal.stop()\n // would write.\n }\n // Belt-and-suspenders: always write terminal reset sequences directly,\n // regardless of whether tui.stop() succeeded. Writing them twice is harmless\n // but missing them leaves the terminal in a corrupted state.\n try {\n process.stdout.write(\n '\\x1b[?2004l' + // disable bracketed paste\n '\\x1b[<u' + // pop kitty keyboard protocol\n '\\x1b[>4;0m' + // disable modifyOtherKeys\n '\\x1b[?25h', // show cursor\n );\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // stdout may already be closed during exit\n }\n restoreTerminalForeground();\n releaseAllThreadLocks();\n});\n\n// For all termination signals: stop the TUI FIRST (synchronous, disables keyboard\n// protocol immediately) before doing any async cleanup. This ensures the terminal\n// escape sequences are written even if asyncCleanup hangs or the process is killed\n// during cleanup.\nconst handleTermSignal = () => {\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void asyncCleanup().finally(() => process.exit(0));\n};\nprocess.on('SIGINT', handleTermSignal);\nprocess.on('SIGTERM', handleTermSignal);\nprocess.on('SIGHUP', handleTermSignal);\n\nfunction hasEconnrefused(err: unknown, depth = 0): boolean {\n if (!err || depth > 5) return false;\n const e = err as any;\n if (e.code === 'ECONNREFUSED') return true;\n if (e.cause) return hasEconnrefused(e.cause, depth + 1);\n // AggregateError has .errors array\n if (Array.isArray(e.errors)) return e.errors.some((inner: unknown) => hasEconnrefused(inner, depth + 1));\n return false;\n}\n\nfunction pluginMain(args: string[]): void {\n if (args[0] !== 'scaffold') {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const dir = args[1];\n if (!dir) {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const id = readFlag(args, '--id');\n const name = readFlag(args, '--name');\n const targetDir = scaffoldPlugin(dir, { ...(id ? { id } : {}), ...(name ? { name } : {}) });\n process.stdout.write(`${formatScaffoldSuccess(targetDir)}\\n`);\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index === -1) return undefined;\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new Error(`Missing value for ${flag}`);\n }\n return value;\n}\n\nfunction handleFatalError(error: unknown): never {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => process.stderr.write(msg + '\\n');\n\n if (hasEconnrefused(error)) {\n const settings = loadSettings();\n const connStr = settings.storage?.pg?.connectionString;\n const target = connStr ?? 'localhost:5432';\n write(\n `\\nFailed to connect to PostgreSQL at ${target}.` +\n `\\nMake sure the database is running and accessible.` +\n `\\n\\nTo switch back to LibSQL:` +\n `\\n Set MASTRA_STORAGE_BACKEND=libsql or change the backend in /settings\\n`,\n );\n process.exit(1);\n }\n\n const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;\n write(msg);\n // Write crash log to file so it persists even if terminal closes\n try {\n const crashLog = `[${new Date().toISOString()}] ${msg}\\n${error instanceof Error && error.stack ? error.stack + '\\n' : ''}`;\n fs.appendFileSync('/tmp/mastra-crash.log', crashLog);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n process.exit(1);\n}\n\nasync function main() {\n if (process.argv[2] === 'plugin') {\n return pluginMain(process.argv.slice(3));\n }\n\n if (hasHeadlessFlag(process.argv) || process.argv.includes('--help') || process.argv.includes('-h')) {\n return runMCCli();\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({ dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve') });\n }\n\n // When stdin is piped (e.g. `cat foo | mastracode`), drain the pipe fully\n // before starting the TUI. The drain blocks until the sender process exits\n // and closes its stdout, so we never see partial output.\n let pipedInput: string | null = null;\n if (!process.stdin.isTTY) {\n process.stderr.write('Reading piped input...\\n');\n pipedInput = await drainPipedStdin();\n\n // Always reopen a real TTY — even if the pipe was empty, the original\n // stdin is consumed/closed and the TUI needs a live TTY for keyboard input.\n const reopenedStdin = reopenStdinFromTTY();\n if (!reopenedStdin) {\n process.stderr.write('No TTY available — falling back to headless mode.\\n');\n return runMCCli(pipedInput);\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACSA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,gBAAgB;AAEpB,SAAS,YAAY,MAAuB;CAC1C,OAAO;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAAC,SAAS,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK,EAAE;AAC1F;AAEA,SAAS,6BAA6B;CACpC,MAAM,iBAAiB,QAAQ,IAAI,qBAAqB,KAAK;CAC7D,MAAM,eAAwC,CAAC;CAC/C,IAAI,gBAAgB,aAAa,iBAAiB;CAClD,IAA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M,KAAK;CAEnB,QAAQ,KAAK,CAAC;AAChB;AAEA,eAAe,OAAO;CACpB,IAAI,QAAQ,KAAK,OAAO,UACtB,OAAO,WAAW,QAAQ,KAAK,MAAM,CAAC,CAAC;CAGzC,KAAA,GAAA,gCAAA,gBAAA,CAAoB,QAAQ,IAAI,KAAK,QAAQ,KAAK,SAAS,QAAQ,KAAK,QAAQ,KAAK,SAAS,IAAI,GAChG,QAAA,GAAA,gCAAA,SAAA,CAAgB;CAGlB,IAAI,QAAQ,KAAK,SAAS,OAAO,GAAG;EAClC,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ,EAAE,sBAAsB,QAAQ,KAAK,SAAS,0BAA0B,EAAE,CAAC;CAC5F;CAKA,IAAI,aAA4B;CAChC,IAAI,CAAC,QAAQ,MAAM,OAAO;EACxB,QAAQ,OAAO,MAAM,0BAA0B;EAC/C,aAAa,OAAA,GAAA,kCAAA,gBAAA,CAAsB;EAKnC,IAAI,EAAA,GAAA,kCAAA,mBAAA,CAAa,GAAG;GAClB,QAAQ,OAAO,MAAM,qDAAqD;GAC1E,QAAA,GAAA,gCAAA,SAAA,CAAgB,UAAU;EAC5B;CACF;CAEA,OAAO,QAAQ,UAAU;AAC3B;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-
|
|
2
|
+
import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-D-aJNadI.js";
|
|
3
3
|
import { createMastraCode } from "@mastra/code-sdk";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import { createMastraCodeAnalytics } from "@mastra/code-sdk/analytics";
|
|
@@ -12,7 +12,7 @@ import { drainPipedStdin, reopenStdinFromTTY } from "@mastra/code-sdk/utils/stdi
|
|
|
12
12
|
import { releaseAllThreadLocks } from "@mastra/code-sdk/utils/thread-lock";
|
|
13
13
|
//#region src/version.ts
|
|
14
14
|
function getCurrentVersion() {
|
|
15
|
-
return "0.33.0
|
|
15
|
+
return "0.33.0";
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/main.ts
|
|
@@ -25,6 +25,7 @@ let hookManager;
|
|
|
25
25
|
let authStorage;
|
|
26
26
|
let signalsPubSub;
|
|
27
27
|
let storageMaintenance;
|
|
28
|
+
let stopPluginSignalProviders;
|
|
28
29
|
let analytics;
|
|
29
30
|
let tui;
|
|
30
31
|
let storageClosed = false;
|
|
@@ -72,6 +73,7 @@ async function tuiMain(pipedInput) {
|
|
|
72
73
|
authStorage = result.authStorage;
|
|
73
74
|
signalsPubSub = result.signalsPubSub;
|
|
74
75
|
storageMaintenance = result.storageMaintenance;
|
|
76
|
+
stopPluginSignalProviders = result.stopPluginSignalProviders;
|
|
75
77
|
if (result.storageWarning) console.info(`⚠ ${result.storageWarning}`);
|
|
76
78
|
if (result.observabilityWarning) console.info(`⚠ ${result.observabilityWarning}`);
|
|
77
79
|
setupDebugLogging();
|
|
@@ -124,6 +126,9 @@ async function tuiMain(pipedInput) {
|
|
|
124
126
|
}
|
|
125
127
|
const asyncCleanup = async () => {
|
|
126
128
|
releaseAllThreadLocks();
|
|
129
|
+
try {
|
|
130
|
+
stopPluginSignalProviders?.();
|
|
131
|
+
} catch {}
|
|
127
132
|
const closeSignalsPubSub = signalsPubSub?.close;
|
|
128
133
|
await Promise.allSettled([
|
|
129
134
|
mcpManager?.disconnect(),
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/version.ts","../src/main.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n\n const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n","#!/usr/bin/env node\n/**\n * Main entry point for Mastra Code TUI.\n */\nimport fs from 'node:fs';\n\nimport { createMastraCode } from '@mastra/code-sdk';\nimport { createMastraCodeAnalytics } from '@mastra/code-sdk/analytics';\nimport { isStreamDestroyedError } from '@mastra/code-sdk/error-classification';\nimport { hasHeadlessFlag, runMCCli } from '@mastra/code-sdk/headless/index';\nimport { createBrowserFromSettings, loadSettings } from '@mastra/code-sdk/onboarding/settings';\nimport { formatScaffoldSuccess, scaffoldPlugin } from '@mastra/code-sdk/plugins/scaffold';\nimport { setupDebugLogging } from '@mastra/code-sdk/utils/debug-log';\nimport { drainPipedStdin, reopenStdinFromTTY } from '@mastra/code-sdk/utils/stdin-pipe';\nimport { releaseAllThreadLocks } from '@mastra/code-sdk/utils/thread-lock';\nimport { detectTerminalTheme } from './tui/detect-theme.js';\nimport { MastraTUI } from './tui/index.js';\nimport { applyThemeMode, restoreTerminalForeground } from './tui/theme.js';\nimport { getCurrentVersion } from './version.js';\n\nlet controller: Awaited<ReturnType<typeof createMastraCode>>['controller'];\nlet mcpManager: Awaited<ReturnType<typeof createMastraCode>>['mcpManager'];\nlet hookManager: Awaited<ReturnType<typeof createMastraCode>>['hookManager'];\nlet authStorage: Awaited<ReturnType<typeof createMastraCode>>['authStorage'];\nlet signalsPubSub: Awaited<ReturnType<typeof createMastraCode>>['signalsPubSub'];\nlet storageMaintenance: Awaited<ReturnType<typeof createMastraCode>>['storageMaintenance'];\nlet analytics: ReturnType<typeof createMastraCodeAnalytics> | undefined;\nlet tui: MastraTUI | undefined;\nlet storageClosed = false;\n\nfunction isTruthyEnv(name: string): boolean {\n return ['1', 'true', 'yes', 'on'].includes(process.env[name]?.trim().toLowerCase() ?? '');\n}\n\nfunction resolveInitialStateFromEnv() {\n const currentModelId = process.env.MASTRACODE_MODEL_ID?.trim();\n const initialState: Record<string, unknown> = {};\n if (currentModelId) initialState.currentModelId = currentModelId;\n if (isTruthyEnv('MASTRACODE_YOLO')) initialState.yolo = true;\n return Object.keys(initialState).length > 0 ? initialState : undefined;\n}\n\n// Global safety nets — catch any uncaught errors from storage init, etc.\nprocess.on('uncaughtException', error => {\n // ERR_STREAM_DESTROYED is non-fatal — happens routinely when streams close\n // during shutdown, cancelled LLM requests, or LSP/subprocess exits (#13548, #13549)\n if (isStreamDestroyedError(error)) return;\n handleFatalError(error);\n});\nprocess.on('unhandledRejection', reason => {\n if (isStreamDestroyedError(reason)) return;\n handleFatalError(reason instanceof Error ? reason : new Error(String(reason)));\n});\n\nasync function tuiMain(pipedInput?: string | null) {\n const settings = loadSettings();\n let browserPromise: ReturnType<typeof createBrowserFromSettings> | undefined;\n const loadBrowser = () => {\n browserPromise ??= createBrowserFromSettings(settings.browser);\n return browserPromise;\n };\n\n const initialState = resolveInitialStateFromEnv();\n const result = await createMastraCode({\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n ...(isTruthyEnv('MASTRACODE_DISABLE_MEMORY') ? { memory: false as never } : {}),\n ...(initialState ? { initialState: initialState as never } : {}),\n });\n controller = result.controller;\n mcpManager = result.mcpManager;\n hookManager = result.hookManager;\n authStorage = result.authStorage;\n signalsPubSub = result.signalsPubSub;\n storageMaintenance = result.storageMaintenance;\n\n if (result.storageWarning) {\n console.info(`⚠ ${result.storageWarning}`);\n }\n if (result.observabilityWarning) {\n console.info(`⚠ ${result.observabilityWarning}`);\n }\n\n // MCP connection is deferred to TUI.init() (after ui.start()) so that\n // status messages use showInfo() instead of console.info(), which would\n // corrupt the terminal. Headless mode still inits from headless/cli.ts.\n\n setupDebugLogging();\n\n // Detect and apply terminal theme\n // MASTRA_THEME env var is the highest-priority override\n const envTheme = process.env.MASTRA_THEME?.toLowerCase();\n let themeMode: 'dark' | 'light';\n let detectedBgHex: string | undefined;\n if (envTheme === 'dark' || envTheme === 'light') {\n themeMode = envTheme;\n } else {\n const settings = loadSettings();\n const themePref = settings.preferences.theme;\n if (themePref === 'dark' || themePref === 'light') {\n themeMode = themePref;\n } else {\n const detection = await detectTerminalTheme();\n themeMode = detection.mode;\n detectedBgHex = detection.detectedBgHex;\n }\n }\n applyThemeMode(themeMode, detectedBgHex);\n\n // createMastraCode() brought up shared resources and minted the single\n // session that all work runs through. The AgentController owns no session of its own.\n const session = result.session;\n\n analytics = createMastraCodeAnalytics({ version: getCurrentVersion() });\n analytics.capture('mastracode_session_started', {\n mode: session.mode.get(),\n resourceId: session.identity.getResourceId(),\n hasAuthStorage: Boolean(authStorage),\n hasMcp: Boolean(mcpManager),\n theme: themeMode,\n });\n\n tui = new MastraTUI({\n controller: controller,\n session,\n hookManager,\n analytics,\n authStorage,\n mcpManager,\n pluginManager: result.pluginManager,\n storageMaintenance: result.storageMaintenance,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n ...(pipedInput ? { initialMessage: `The following was piped via stdin:\\n\\n${pipedInput}` } : {}),\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n void loadBrowser()\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state.set({ activeBrowserSettings: settings.browser } as any).catch(() => {});\n })\n .catch(() => {});\n }\n}\n\nconst asyncCleanup = 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 analytics?.shutdown(),\n ]);\n // Checkpoint WAL and close the local storage connection after all producers\n // and timers are quiesced. Idempotent — repeated signals (SIGINT then SIGHUP)\n // close only once. LibSQLStore.close()/LibSQLVector.close() truncate the WAL\n // and switch back to DELETE journal mode for a clean shutdown.\n if (!storageClosed) {\n storageClosed = true;\n await storageMaintenance?.closeStorage?.().catch(() => {\n // Swallow — best-effort cleanup during shutdown. The process is exiting.\n });\n }\n};\n\nprocess.on('beforeExit', () => {\n void asyncCleanup();\n});\nprocess.on('exit', () => {\n // Ensure terminal protocols (kitty keyboard, modifyOtherKeys, bracketed paste,\n // raw mode) are disabled on ANY exit path. Without this, killing the process\n // via SIGINT/SIGTERM leaves the terminal in a corrupted state where keypresses\n // produce escape sequences like \"5;99~\" instead of normal characters.\n try {\n tui?.stop();\n } catch {\n // Failsafe: even if MastraTUI.stop() throws, write raw terminal reset\n // sequences to disable Kitty keyboard protocol, bracketed paste, and\n // modifyOtherKeys. These are the exact sequences pi-tui's terminal.stop()\n // would write.\n }\n // Belt-and-suspenders: always write terminal reset sequences directly,\n // regardless of whether tui.stop() succeeded. Writing them twice is harmless\n // but missing them leaves the terminal in a corrupted state.\n try {\n process.stdout.write(\n '\\x1b[?2004l' + // disable bracketed paste\n '\\x1b[<u' + // pop kitty keyboard protocol\n '\\x1b[>4;0m' + // disable modifyOtherKeys\n '\\x1b[?25h', // show cursor\n );\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // stdout may already be closed during exit\n }\n restoreTerminalForeground();\n releaseAllThreadLocks();\n});\n\n// For all termination signals: stop the TUI FIRST (synchronous, disables keyboard\n// protocol immediately) before doing any async cleanup. This ensures the terminal\n// escape sequences are written even if asyncCleanup hangs or the process is killed\n// during cleanup.\nconst handleTermSignal = () => {\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void asyncCleanup().finally(() => process.exit(0));\n};\nprocess.on('SIGINT', handleTermSignal);\nprocess.on('SIGTERM', handleTermSignal);\nprocess.on('SIGHUP', handleTermSignal);\n\nfunction hasEconnrefused(err: unknown, depth = 0): boolean {\n if (!err || depth > 5) return false;\n const e = err as any;\n if (e.code === 'ECONNREFUSED') return true;\n if (e.cause) return hasEconnrefused(e.cause, depth + 1);\n // AggregateError has .errors array\n if (Array.isArray(e.errors)) return e.errors.some((inner: unknown) => hasEconnrefused(inner, depth + 1));\n return false;\n}\n\nfunction pluginMain(args: string[]): void {\n if (args[0] !== 'scaffold') {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const dir = args[1];\n if (!dir) {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const id = readFlag(args, '--id');\n const name = readFlag(args, '--name');\n const targetDir = scaffoldPlugin(dir, { ...(id ? { id } : {}), ...(name ? { name } : {}) });\n process.stdout.write(`${formatScaffoldSuccess(targetDir)}\\n`);\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index === -1) return undefined;\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new Error(`Missing value for ${flag}`);\n }\n return value;\n}\n\nfunction handleFatalError(error: unknown): never {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => process.stderr.write(msg + '\\n');\n\n if (hasEconnrefused(error)) {\n const settings = loadSettings();\n const connStr = settings.storage?.pg?.connectionString;\n const target = connStr ?? 'localhost:5432';\n write(\n `\\nFailed to connect to PostgreSQL at ${target}.` +\n `\\nMake sure the database is running and accessible.` +\n `\\n\\nTo switch back to LibSQL:` +\n `\\n Set MASTRA_STORAGE_BACKEND=libsql or change the backend in /settings\\n`,\n );\n process.exit(1);\n }\n\n const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;\n write(msg);\n // Write crash log to file so it persists even if terminal closes\n try {\n const crashLog = `[${new Date().toISOString()}] ${msg}\\n${error instanceof Error && error.stack ? error.stack + '\\n' : ''}`;\n fs.appendFileSync('/tmp/mastra-crash.log', crashLog);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n process.exit(1);\n}\n\nasync function main() {\n if (process.argv[2] === 'plugin') {\n return pluginMain(process.argv.slice(3));\n }\n\n if (hasHeadlessFlag(process.argv) || process.argv.includes('--help') || process.argv.includes('-h')) {\n return runMCCli();\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({ dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve') });\n }\n\n // When stdin is piped (e.g. `cat foo | mastracode`), drain the pipe fully\n // before starting the TUI. The drain blocks until the sender process exits\n // and closes its stdout, so we never see partial output.\n let pipedInput: string | null = null;\n if (!process.stdin.isTTY) {\n process.stderr.write('Reading piped input...\\n');\n pipedInput = await drainPipedStdin();\n\n // Always reopen a real TTY — even if the pipe was empty, the original\n // stdin is consumed/closed and the TUI needs a live TTY for keyboard input.\n const reopenedStdin = reopenStdinFromTTY();\n if (!reopenedStdin) {\n process.stderr.write('No TTY available — falling back to headless mode.\\n');\n return runMCCli(pipedInput);\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;AAIA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACSA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,gBAAgB;AAEpB,SAAS,YAAY,MAAuB;CAC1C,OAAO;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAAC,SAAS,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK,EAAE;AAC1F;AAEA,SAAS,6BAA6B;CACpC,MAAM,iBAAiB,QAAQ,IAAI,qBAAqB,KAAK;CAC7D,MAAM,eAAwC,CAAC;CAC/C,IAAI,gBAAgB,aAAa,iBAAiB;CAClD,IAAI,YAAY,iBAAiB,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BAA0B,EAAE,CAAC;CAC5F;CAKA,IAAI,aAA4B;CAChC,IAAI,CAAC,QAAQ,MAAM,OAAO;EACxB,QAAQ,OAAO,MAAM,0BAA0B;EAC/C,aAAa,MAAM,gBAAgB;EAKnC,IAAI,CADkB,mBACL,GAAG;GAClB,QAAQ,OAAO,MAAM,qDAAqD;GAC1E,OAAO,SAAS,UAAU;EAC5B;CACF;CAEA,OAAO,QAAQ,UAAU;AAC3B;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/version.ts","../src/main.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n\n const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string };\n return pkg.version;\n}\n","#!/usr/bin/env node\n/**\n * Main entry point for Mastra Code TUI.\n */\nimport fs from 'node:fs';\n\nimport { createMastraCode } from '@mastra/code-sdk';\nimport { createMastraCodeAnalytics } from '@mastra/code-sdk/analytics';\nimport { isStreamDestroyedError } from '@mastra/code-sdk/error-classification';\nimport { hasHeadlessFlag, runMCCli } from '@mastra/code-sdk/headless/index';\nimport { createBrowserFromSettings, loadSettings } from '@mastra/code-sdk/onboarding/settings';\nimport { formatScaffoldSuccess, scaffoldPlugin } from '@mastra/code-sdk/plugins/scaffold';\nimport { setupDebugLogging } from '@mastra/code-sdk/utils/debug-log';\nimport { drainPipedStdin, reopenStdinFromTTY } from '@mastra/code-sdk/utils/stdin-pipe';\nimport { releaseAllThreadLocks } from '@mastra/code-sdk/utils/thread-lock';\nimport { detectTerminalTheme } from './tui/detect-theme.js';\nimport { MastraTUI } from './tui/index.js';\nimport { applyThemeMode, restoreTerminalForeground } from './tui/theme.js';\nimport { getCurrentVersion } from './version.js';\n\nlet controller: Awaited<ReturnType<typeof createMastraCode>>['controller'];\nlet mcpManager: Awaited<ReturnType<typeof createMastraCode>>['mcpManager'];\nlet hookManager: Awaited<ReturnType<typeof createMastraCode>>['hookManager'];\nlet authStorage: Awaited<ReturnType<typeof createMastraCode>>['authStorage'];\nlet signalsPubSub: Awaited<ReturnType<typeof createMastraCode>>['signalsPubSub'];\nlet storageMaintenance: Awaited<ReturnType<typeof createMastraCode>>['storageMaintenance'];\nlet stopPluginSignalProviders: Awaited<ReturnType<typeof createMastraCode>>['stopPluginSignalProviders'] | undefined;\nlet analytics: ReturnType<typeof createMastraCodeAnalytics> | undefined;\nlet tui: MastraTUI | undefined;\nlet storageClosed = false;\n\nfunction isTruthyEnv(name: string): boolean {\n return ['1', 'true', 'yes', 'on'].includes(process.env[name]?.trim().toLowerCase() ?? '');\n}\n\nfunction resolveInitialStateFromEnv() {\n const currentModelId = process.env.MASTRACODE_MODEL_ID?.trim();\n const initialState: Record<string, unknown> = {};\n if (currentModelId) initialState.currentModelId = currentModelId;\n if (isTruthyEnv('MASTRACODE_YOLO')) initialState.yolo = true;\n return Object.keys(initialState).length > 0 ? initialState : undefined;\n}\n\n// Global safety nets — catch any uncaught errors from storage init, etc.\nprocess.on('uncaughtException', error => {\n // ERR_STREAM_DESTROYED is non-fatal — happens routinely when streams close\n // during shutdown, cancelled LLM requests, or LSP/subprocess exits (#13548, #13549)\n if (isStreamDestroyedError(error)) return;\n handleFatalError(error);\n});\nprocess.on('unhandledRejection', reason => {\n if (isStreamDestroyedError(reason)) return;\n handleFatalError(reason instanceof Error ? reason : new Error(String(reason)));\n});\n\nasync function tuiMain(pipedInput?: string | null) {\n const settings = loadSettings();\n let browserPromise: ReturnType<typeof createBrowserFromSettings> | undefined;\n const loadBrowser = () => {\n browserPromise ??= createBrowserFromSettings(settings.browser);\n return browserPromise;\n };\n\n const initialState = resolveInitialStateFromEnv();\n const result = await createMastraCode({\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n ...(isTruthyEnv('MASTRACODE_DISABLE_MEMORY') ? { memory: false as never } : {}),\n ...(initialState ? { initialState: initialState as never } : {}),\n });\n controller = result.controller;\n mcpManager = result.mcpManager;\n hookManager = result.hookManager;\n authStorage = result.authStorage;\n signalsPubSub = result.signalsPubSub;\n storageMaintenance = result.storageMaintenance;\n stopPluginSignalProviders = result.stopPluginSignalProviders;\n\n if (result.storageWarning) {\n console.info(`⚠ ${result.storageWarning}`);\n }\n if (result.observabilityWarning) {\n console.info(`⚠ ${result.observabilityWarning}`);\n }\n\n // MCP connection is deferred to TUI.init() (after ui.start()) so that\n // status messages use showInfo() instead of console.info(), which would\n // corrupt the terminal. Headless mode still inits from headless/cli.ts.\n\n setupDebugLogging();\n\n // Detect and apply terminal theme\n // MASTRA_THEME env var is the highest-priority override\n const envTheme = process.env.MASTRA_THEME?.toLowerCase();\n let themeMode: 'dark' | 'light';\n let detectedBgHex: string | undefined;\n if (envTheme === 'dark' || envTheme === 'light') {\n themeMode = envTheme;\n } else {\n const settings = loadSettings();\n const themePref = settings.preferences.theme;\n if (themePref === 'dark' || themePref === 'light') {\n themeMode = themePref;\n } else {\n const detection = await detectTerminalTheme();\n themeMode = detection.mode;\n detectedBgHex = detection.detectedBgHex;\n }\n }\n applyThemeMode(themeMode, detectedBgHex);\n\n // createMastraCode() brought up shared resources and minted the single\n // session that all work runs through. The AgentController owns no session of its own.\n const session = result.session;\n\n analytics = createMastraCodeAnalytics({ version: getCurrentVersion() });\n analytics.capture('mastracode_session_started', {\n mode: session.mode.get(),\n resourceId: session.identity.getResourceId(),\n hasAuthStorage: Boolean(authStorage),\n hasMcp: Boolean(mcpManager),\n theme: themeMode,\n });\n\n tui = new MastraTUI({\n controller: controller,\n session,\n hookManager,\n analytics,\n authStorage,\n mcpManager,\n pluginManager: result.pluginManager,\n storageMaintenance: result.storageMaintenance,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n ...(pipedInput ? { initialMessage: `The following was piped via stdin:\\n\\n${pipedInput}` } : {}),\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n void loadBrowser()\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state.set({ activeBrowserSettings: settings.browser } as any).catch(() => {});\n })\n .catch(() => {});\n }\n}\n\nconst asyncCleanup = async () => {\n releaseAllThreadLocks();\n // Stop plugin-contributed signal providers (and the plugin reload listener)\n // before quiescing workers: a provider that keeps polling past this point\n // could dispatch into a controller that is shutting down.\n try {\n stopPluginSignalProviders?.();\n } catch {\n // Best-effort — the process is exiting.\n }\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 analytics?.shutdown(),\n ]);\n // Checkpoint WAL and close the local storage connection after all producers\n // and timers are quiesced. Idempotent — repeated signals (SIGINT then SIGHUP)\n // close only once. LibSQLStore.close()/LibSQLVector.close() truncate the WAL\n // and switch back to DELETE journal mode for a clean shutdown.\n if (!storageClosed) {\n storageClosed = true;\n await storageMaintenance?.closeStorage?.().catch(() => {\n // Swallow — best-effort cleanup during shutdown. The process is exiting.\n });\n }\n};\n\nprocess.on('beforeExit', () => {\n void asyncCleanup();\n});\nprocess.on('exit', () => {\n // Ensure terminal protocols (kitty keyboard, modifyOtherKeys, bracketed paste,\n // raw mode) are disabled on ANY exit path. Without this, killing the process\n // via SIGINT/SIGTERM leaves the terminal in a corrupted state where keypresses\n // produce escape sequences like \"5;99~\" instead of normal characters.\n try {\n tui?.stop();\n } catch {\n // Failsafe: even if MastraTUI.stop() throws, write raw terminal reset\n // sequences to disable Kitty keyboard protocol, bracketed paste, and\n // modifyOtherKeys. These are the exact sequences pi-tui's terminal.stop()\n // would write.\n }\n // Belt-and-suspenders: always write terminal reset sequences directly,\n // regardless of whether tui.stop() succeeded. Writing them twice is harmless\n // but missing them leaves the terminal in a corrupted state.\n try {\n process.stdout.write(\n '\\x1b[?2004l' + // disable bracketed paste\n '\\x1b[<u' + // pop kitty keyboard protocol\n '\\x1b[>4;0m' + // disable modifyOtherKeys\n '\\x1b[?25h', // show cursor\n );\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // stdout may already be closed during exit\n }\n restoreTerminalForeground();\n releaseAllThreadLocks();\n});\n\n// For all termination signals: stop the TUI FIRST (synchronous, disables keyboard\n// protocol immediately) before doing any async cleanup. This ensures the terminal\n// escape sequences are written even if asyncCleanup hangs or the process is killed\n// during cleanup.\nconst handleTermSignal = () => {\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void asyncCleanup().finally(() => process.exit(0));\n};\nprocess.on('SIGINT', handleTermSignal);\nprocess.on('SIGTERM', handleTermSignal);\nprocess.on('SIGHUP', handleTermSignal);\n\nfunction hasEconnrefused(err: unknown, depth = 0): boolean {\n if (!err || depth > 5) return false;\n const e = err as any;\n if (e.code === 'ECONNREFUSED') return true;\n if (e.cause) return hasEconnrefused(e.cause, depth + 1);\n // AggregateError has .errors array\n if (Array.isArray(e.errors)) return e.errors.some((inner: unknown) => hasEconnrefused(inner, depth + 1));\n return false;\n}\n\nfunction pluginMain(args: string[]): void {\n if (args[0] !== 'scaffold') {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const dir = args[1];\n if (!dir) {\n process.stderr.write('Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\\n');\n process.exit(1);\n }\n\n const id = readFlag(args, '--id');\n const name = readFlag(args, '--name');\n const targetDir = scaffoldPlugin(dir, { ...(id ? { id } : {}), ...(name ? { name } : {}) });\n process.stdout.write(`${formatScaffoldSuccess(targetDir)}\\n`);\n}\n\nfunction readFlag(args: string[], flag: string): string | undefined {\n const index = args.indexOf(flag);\n if (index === -1) return undefined;\n const value = args[index + 1];\n if (!value || value.startsWith('--')) {\n throw new Error(`Missing value for ${flag}`);\n }\n return value;\n}\n\nfunction handleFatalError(error: unknown): never {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => process.stderr.write(msg + '\\n');\n\n if (hasEconnrefused(error)) {\n const settings = loadSettings();\n const connStr = settings.storage?.pg?.connectionString;\n const target = connStr ?? 'localhost:5432';\n write(\n `\\nFailed to connect to PostgreSQL at ${target}.` +\n `\\nMake sure the database is running and accessible.` +\n `\\n\\nTo switch back to LibSQL:` +\n `\\n Set MASTRA_STORAGE_BACKEND=libsql or change the backend in /settings\\n`,\n );\n process.exit(1);\n }\n\n const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;\n write(msg);\n // Write crash log to file so it persists even if terminal closes\n try {\n const crashLog = `[${new Date().toISOString()}] ${msg}\\n${error instanceof Error && error.stack ? error.stack + '\\n' : ''}`;\n fs.appendFileSync('/tmp/mastra-crash.log', crashLog);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n process.exit(1);\n}\n\nasync function main() {\n if (process.argv[2] === 'plugin') {\n return pluginMain(process.argv.slice(3));\n }\n\n if (hasHeadlessFlag(process.argv) || process.argv.includes('--help') || process.argv.includes('-h')) {\n return runMCCli();\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({ dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve') });\n }\n\n // When stdin is piped (e.g. `cat foo | mastracode`), drain the pipe fully\n // before starting the TUI. The drain blocks until the sender process exits\n // and closes its stdout, so we never see partial output.\n let pipedInput: string | null = null;\n if (!process.stdin.isTTY) {\n process.stderr.write('Reading piped input...\\n');\n pipedInput = await drainPipedStdin();\n\n // Always reopen a real TTY — even if the pipe was empty, the original\n // stdin is consumed/closed and the TUI needs a live TTY for keyboard input.\n const reopenedStdin = reopenStdinFromTTY();\n if (!reopenedStdin) {\n process.stderr.write('No TTY available — falling back to headless mode.\\n');\n return runMCCli(pipedInput);\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;AAIA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACSA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,gBAAgB;AAEpB,SAAS,YAAY,MAAuB;CAC1C,OAAO;EAAC;EAAK;EAAQ;EAAO;CAAI,CAAC,CAAC,SAAS,QAAQ,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK,EAAE;AAC1F;AAEA,SAAS,6BAA6B;CACpC,MAAM,iBAAiB,QAAQ,IAAI,qBAAqB,KAAK;CAC7D,MAAM,eAAwC,CAAC;CAC/C,IAAI,gBAAgB,aAAa,iBAAiB;CAClD,IAAI,YAAY,iBAAiB,GAAG,aAAa,OAAO;CACxD,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,eAAe,KAAA;AAC/D;AAGA,QAAQ,GAAG,sBAAqB,UAAS;CAGvC,IAAI,uBAAuB,KAAK,GAAG;CACnC,iBAAiB,KAAK;AACxB,CAAC;AACD,QAAQ,GAAG,uBAAsB,WAAU;CACzC,IAAI,uBAAuB,MAAM,GAAG;CACpC,iBAAiB,kBAAkB,QAAQ,SAAS,IAAI,MAAM,OAAO,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED,eAAe,QAAQ,YAA4B;CACjD,MAAM,WAAW,aAAa;CAC9B,IAAI;CACJ,MAAM,oBAAoB;EACxB,mBAAmB,0BAA0B,SAAS,OAAO;EAC7D,OAAO;CAC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sourceRoot":"","sources":["../../src/tui/command-dispatch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-dispatch.d.ts","sourceRoot":"","sources":["../../src/tui/command-dispatch.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,MAAM,mBAAmB,GAClC,OAAO,CAAC,OAAO,CAAC,CA0NlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/goal.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAWrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmG/F;AA8ED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhF;AAOD,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,mBAAmB,EACxB,SAAS,EAAE,MAAM,EACjB,aAAa,SAAoB,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAMf;
|
|
1
|
+
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/goal.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAWrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmG/F;AA8ED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhF;AAOD,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,mBAAmB,EACxB,SAAS,EAAE,MAAM,EACjB,aAAa,SAAoB,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAMf;AA4ID,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB,eAAe,CASjB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
|
@@ -38,5 +38,6 @@ export { handleFeedbackCommand } from './feedback.js';
|
|
|
38
38
|
export { handleObservabilityCommand } from './observability.js';
|
|
39
39
|
export { handleGithubCommand } from './github.js';
|
|
40
40
|
export { handleGoalCommand, handleJudgeCommand } from './goal.js';
|
|
41
|
+
export { handleWorkflowsCommand } from './workflows.js';
|
|
41
42
|
export { handlePruneCommand } from './prune.js';
|
|
42
43
|
//# sourceMappingURL=index.d.ts.map
|