mastracode 0.27.1-alpha.2 → 0.28.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/{acp-6YKB4QYA.js → acp-CSOZEQ7K.js} +4 -4
  3. package/dist/{acp-6YKB4QYA.js.map → acp-CSOZEQ7K.js.map} +1 -1
  4. package/dist/{acp-RDIS23UX.cjs → acp-HRYTQRAO.cjs} +6 -6
  5. package/dist/{acp-RDIS23UX.cjs.map → acp-HRYTQRAO.cjs.map} +1 -1
  6. package/dist/{chunk-M4LREDYM.js → chunk-L2WPY5DE.js} +125 -27
  7. package/dist/chunk-L2WPY5DE.js.map +1 -0
  8. package/dist/{chunk-LZVLLFAV.cjs → chunk-LLFHXT5E.cjs} +1092 -994
  9. package/dist/chunk-LLFHXT5E.cjs.map +1 -0
  10. package/dist/{chunk-T2GVODUO.cjs → chunk-POOGOLWK.cjs} +237 -556
  11. package/dist/chunk-POOGOLWK.cjs.map +1 -0
  12. package/dist/{chunk-XWZSUFQP.js → chunk-QK7PXNAX.js} +163 -482
  13. package/dist/chunk-QK7PXNAX.js.map +1 -0
  14. package/dist/{chunk-GAPPKMQT.js → chunk-RHWBSPSP.js} +511 -39
  15. package/dist/chunk-RHWBSPSP.js.map +1 -0
  16. package/dist/{chunk-WX46SWL3.cjs → chunk-T5FGP3US.cjs} +537 -62
  17. package/dist/chunk-T5FGP3US.cjs.map +1 -0
  18. package/dist/cli.cjs +23 -23
  19. package/dist/cli.js +4 -4
  20. package/dist/headless.cjs +18 -18
  21. package/dist/headless.js +1 -1
  22. package/dist/hooks/config.d.ts +2 -1
  23. package/dist/hooks/config.d.ts.map +1 -1
  24. package/dist/hooks/index.d.ts +2 -2
  25. package/dist/hooks/index.d.ts.map +1 -1
  26. package/dist/hooks/manager.d.ts +19 -1
  27. package/dist/hooks/manager.d.ts.map +1 -1
  28. package/dist/hooks/types.d.ts +69 -2
  29. package/dist/hooks/types.d.ts.map +1 -1
  30. package/dist/index.cjs +17 -17
  31. package/dist/index.js +1 -1
  32. package/dist/tui/commands/hooks.d.ts.map +1 -1
  33. package/dist/tui/components/login-dialog.d.ts.map +1 -1
  34. package/dist/tui/handlers/prompts.d.ts.map +1 -1
  35. package/dist/tui/handlers/tool.d.ts.map +1 -1
  36. package/dist/tui/mastra-tui.d.ts +4 -0
  37. package/dist/tui/mastra-tui.d.ts.map +1 -1
  38. package/dist/tui/setup.d.ts.map +1 -1
  39. package/dist/tui.cjs +19 -19
  40. package/dist/tui.js +2 -2
  41. package/package.json +19 -13
  42. package/dist/chunk-GAPPKMQT.js.map +0 -1
  43. package/dist/chunk-LZVLLFAV.cjs.map +0 -1
  44. package/dist/chunk-M4LREDYM.js.map +0 -1
  45. package/dist/chunk-T2GVODUO.cjs.map +0 -1
  46. package/dist/chunk-WX46SWL3.cjs.map +0 -1
  47. package/dist/chunk-XWZSUFQP.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,94 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.28.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Removed named exports from the `@mastra/playground-ui` root entry. Import public APIs from exact package subpaths instead. ([#18791](https://github.com/mastra-ai/mastra/pull/18791))
8
+
9
+ **Before**
10
+
11
+ ```ts
12
+ import { Button } from '@mastra/playground-ui';
13
+ ```
14
+
15
+ **After**
16
+
17
+ ```ts
18
+ import { Button } from '@mastra/playground-ui/components/Button';
19
+ ```
20
+
21
+ `mastracode` now uses the exact subpath imports, and lint rules prevent new broad `@mastra/playground-ui` imports.
22
+
23
+ - Updated dependencies [[`6a61846`](https://github.com/mastra-ai/mastra/commit/6a61846eeda29fb714549b70f1bee2bf6b141c44), [`7952b3d`](https://github.com/mastra-ai/mastra/commit/7952b3d90e2437093ee322585e361ea6e62ed497)]:
24
+ - @mastra/core@1.49.0-alpha.4
25
+ - @mastra/playground-ui@38.1.0-alpha.4
26
+ - @mastra/client-js@1.29.1-alpha.4
27
+ - @mastra/react@1.2.2-alpha.4
28
+ - @mastra/server@1.49.0-alpha.4
29
+ - @mastra/hono@1.5.4-alpha.4
30
+
31
+ ## 0.28.0-alpha.3
32
+
33
+ ### Minor Changes
34
+
35
+ - Added lifecycle hook events and a per-run `run_id` field so external orchestrators can track agent lifecycle states directly instead of inferring them from coarse prompt, tool, and stop signals. ([#18607](https://github.com/mastra-ai/mastra/pull/18607))
36
+
37
+ **New events:** AgentStart, AgentEnd, PermissionRequest, PermissionResult, Interrupt, SubagentStart, and SubagentEnd. All new lifecycle events are non-blocking. Existing blocking events, including PreToolUse, Stop, and UserPromptSubmit, keep their current behavior.
38
+
39
+ Every hook stdin now includes a `run_id` during an active run. Permission decisions and interrupts only emit while a run is active, so consumers can reliably correlate them with the run that produced them.
40
+
41
+ PostToolUse continues to fire from the agent tool hook wrapper after a tool call completes. It is not emitted from the TUI lifecycle dispatcher.
42
+
43
+ **Why**
44
+
45
+ External orchestrators needed first-class signals for permission gates, interrupts, and subagent delegation. The previous hook surface only offered coarse prompt, tool, and stop events, forcing integrators to guess at lifecycle state.
46
+
47
+ ```json
48
+ {
49
+ "AgentStart": [{ "type": "command", "command": "echo started >> /tmp/lifecycle.log" }],
50
+ "AgentEnd": [{ "type": "command", "command": "echo ended >> /tmp/lifecycle.log" }],
51
+ "Interrupt": [{ "type": "command", "command": "echo interrupted >> /tmp/lifecycle.log" }]
52
+ }
53
+ ```
54
+
55
+ AgentStart stdin includes the shared `run_id`:
56
+
57
+ ```json
58
+ { "hook_event_name": "AgentStart", "run_id": "a1b2c3d4", "session_id": "...", "cwd": "/path/to/project" }
59
+ ```
60
+
61
+ ### Patch Changes
62
+
63
+ - Hardened child-process invocations against shell command injection. Package installs and codemod runs now pass arguments as arrays instead of interpolating them into shell strings, the deployer's shared child-process logger rejects arguments containing shell metacharacters, and the login dialog validates auth URLs and opens the browser without a shell. As a side effect, `mastra codemod` now works on project paths containing spaces. ([#18804](https://github.com/mastra-ai/mastra/pull/18804))
64
+
65
+ - Security hardening from CodeQL review: MCP serverless 500 responses no longer echo internal error messages to clients (details are still logged server-side), and macOS system notifications now escape backslashes and run osascript without a shell so notification text can't inject commands. ([#18805](https://github.com/mastra-ai/mastra/pull/18805))
66
+
67
+ - Rebuilt the MastraCode web studio UI on the @mastra/playground-ui design system. Theme switching, settings, command palette, sidebar, and the conversation transcript now use shared design-system components for a consistent look and accessible controls, replacing the previous custom stylesheet, and the bespoke inline-SVG icon set was replaced with lucide-react icons (the decorative brand wordmark/logo was removed while preserving accessible labels). ([#18782](https://github.com/mastra-ai/mastra/pull/18782))
68
+
69
+ Cleaned up the studio chrome: removed the duplicate top-level project switcher, theme toggle, and mode switcher from the header (the sidebar switcher is the single project switcher, the theme is set only from Settings), moved the Settings button into the sidebar footer, and moved the session mode selector into a single unified status row below the composer. The header is now reduced to just the mobile sidebar toggle. The chat message column, composer, and status line share the same `max-w-[80ch] w-full` column with container border/background removed so they align cleanly.
70
+
71
+ Simplified the chat message UI to match the Studio playground: user messages are plain right-aligned rounded bubbles (no "YOU" label or avatar) rendered as markdown, and assistant messages render as label-free full-width markdown prose.
72
+
73
+ Improved tool-call rendering: tool arguments, results, and full-file writes render through the design-system `CodeBlock` component (shiki highlighting, built-in copy, softer rounded shape) instead of plain monospace `<pre>` blocks. Consecutive tool calls now merge into a single bordered, rounded container with divider-separated full-width collapsible rows (no per-item stacked-card look), and the collapse control uses a standard chevron instead of a rotating icon.
74
+
75
+ Improved the "Open a project" dialog: the current path uses the shared breadcrumb component and navigating up a folder is a single click on a parent crumb; removed the double-click-to-select behavior and hint text so a single click browses and "Use this folder" selects.
76
+
77
+ Improved web session caching and settings refresh behavior.
78
+
79
+ - Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`9fe9d2d`](https://github.com/mastra-ai/mastra/commit/9fe9d2d905a84409202fe222eab698216704e4e7), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`df25635`](https://github.com/mastra-ai/mastra/commit/df25635b954e63b5dbf8f1636af953b95c631809), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`27826bc`](https://github.com/mastra-ai/mastra/commit/27826bc8ec20d6b4597ba456e506d65f45656c8f), [`e8eee50`](https://github.com/mastra-ai/mastra/commit/e8eee5087937c9db1a57167119813861328e22ce), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b)]:
80
+ - @mastra/core@1.49.0-alpha.3
81
+ - @mastra/playground-ui@38.1.0-alpha.3
82
+ - @mastra/libsql@1.15.0-alpha.0
83
+ - @mastra/mcp@1.13.0-alpha.1
84
+ - @mastra/server@1.49.0-alpha.3
85
+ - @mastra/hono@1.5.4-alpha.3
86
+ - @mastra/pg@1.15.0-alpha.0
87
+ - @mastra/memory@1.22.1-alpha.1
88
+ - @mastra/client-js@1.29.1-alpha.3
89
+ - @mastra/auth-workos@1.6.2-alpha.0
90
+ - @mastra/react@1.2.2-alpha.3
91
+
3
92
  ## 0.27.1-alpha.2
4
93
 
5
94
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import { setAutoApprove, MastraCodeAcpAgent } from './chunk-IFUIWWGJ.js';
2
- import { createMastraCode } from './chunk-XWZSUFQP.js';
3
- import { releaseAllThreadLocks } from './chunk-GAPPKMQT.js';
2
+ import { createMastraCode } from './chunk-QK7PXNAX.js';
3
+ import { releaseAllThreadLocks } from './chunk-RHWBSPSP.js';
4
4
  import { randomUUID } from 'crypto';
5
5
  import { Readable, Writable } from 'stream';
6
6
  import { ndJsonStream, AgentSideConnection } from '@agentclientprotocol/sdk';
@@ -81,5 +81,5 @@ async function acpMain(options) {
81
81
  }
82
82
 
83
83
  export { acpMain };
84
- //# sourceMappingURL=acp-6YKB4QYA.js.map
85
- //# sourceMappingURL=acp-6YKB4QYA.js.map
84
+ //# sourceMappingURL=acp-CSOZEQ7K.js.map
85
+ //# sourceMappingURL=acp-CSOZEQ7K.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":";;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,I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AA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-6YKB4QYA.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":";;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC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GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-CSOZEQ7K.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkVBH3L4LD_cjs = require('./chunk-VBH3L4LD.cjs');
4
- var chunkT2GVODUO_cjs = require('./chunk-T2GVODUO.cjs');
5
- var chunkWX46SWL3_cjs = require('./chunk-WX46SWL3.cjs');
4
+ var chunkPOOGOLWK_cjs = require('./chunk-POOGOLWK.cjs');
5
+ var chunkT5FGP3US_cjs = require('./chunk-T5FGP3US.cjs');
6
6
  var crypto = require('crypto');
7
7
  var stream = require('stream');
8
8
  var sdk = require('@agentclientprotocol/sdk');
@@ -45,7 +45,7 @@ async function acpMain(options) {
45
45
  };
46
46
  let result;
47
47
  try {
48
- result = await chunkT2GVODUO_cjs.createMastraCode({
48
+ result = await chunkPOOGOLWK_cjs.createMastraCode({
49
49
  unixSocketPubSub: false,
50
50
  disableMcp: false,
51
51
  disableHooks: false
@@ -57,7 +57,7 @@ async function acpMain(options) {
57
57
  { id: "fast", name: "Fast" }
58
58
  ];
59
59
  const cleanup = async () => {
60
- chunkWX46SWL3_cjs.releaseAllThreadLocks();
60
+ chunkT5FGP3US_cjs.releaseAllThreadLocks();
61
61
  const closeSignalsPubSub = signalsPubSub?.close;
62
62
  await Promise.allSettled([
63
63
  mcpManager?.disconnect(),
@@ -83,5 +83,5 @@ async function acpMain(options) {
83
83
  }
84
84
 
85
85
  exports.acpMain = acpMain;
86
- //# sourceMappingURL=acp-RDIS23UX.cjs.map
87
- //# sourceMappingURL=acp-RDIS23UX.cjs.map
86
+ //# sourceMappingURL=acp-HRYTQRAO.cjs.map
87
+ //# sourceMappingURL=acp-HRYTQRAO.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQA,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAASC,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAMC,QAAA,GAASC,gBAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,KAAA;AAGJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,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B;AACF","file":"acp-RDIS23UX.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQA,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAASC,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAMC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CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-HRYTQRAO.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopIntervals(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { tintHex, mastra, theme, getMarkdownTheme, CHAT_INDENT, BOX_INDENT, getTermWidth, ensureTerminalGlyphContrast, TERM_WIDTH_BUFFER, getEditorTheme, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, resolveThreadActiveModelPackId, saveSettings, getAvailableOmPacks, ONBOARDING_VERSION, THREAD_ACTIVE_MODEL_PACK_ID_KEY, BOX_INDENT_STR, ThreadLockError, resolvePlanPath, readPlanFile, getSelectListTheme, luminance, extendedColors, mastraBrand, MEMORY_GATEWAY_DEFAULT_URL, getThemeMode, applyThemeMode, createBrowserFromSettings, setProfileProvider, getCustomProviderId, OBSERVABILITY_AUTH_PREFIX, checkProfileProviderMismatch, getSettingsListTheme, resolveSTTModel, approvePlanFile, sttModelsForProvider, sttProviders, defaultModelForProvider, toCustomProviderModelId, DEFAULT_STT_MODEL } from './chunk-GAPPKMQT.js';
1
+ import { tintHex, mastra, theme, getMarkdownTheme, CHAT_INDENT, BOX_INDENT, getTermWidth, ensureTerminalGlyphContrast, TERM_WIDTH_BUFFER, getEditorTheme, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, resolveThreadActiveModelPackId, saveSettings, getAvailableOmPacks, ONBOARDING_VERSION, THREAD_ACTIVE_MODEL_PACK_ID_KEY, BOX_INDENT_STR, ThreadLockError, resolvePlanPath, readPlanFile, getSelectListTheme, luminance, extendedColors, mastraBrand, MEMORY_GATEWAY_DEFAULT_URL, getThemeMode, applyThemeMode, createBrowserFromSettings, setProfileProvider, VALID_EVENTS, getCustomProviderId, OBSERVABILITY_AUTH_PREFIX, checkProfileProviderMismatch, getSettingsListTheme, resolveSTTModel, approvePlanFile, sttModelsForProvider, sttProviders, defaultModelForProvider, toCustomProviderModelId, DEFAULT_STT_MODEL } from './chunk-RHWBSPSP.js';
2
2
  import { getOAuthProviders, detectProject, DEFAULT_CONFIG_DIR, getUserId, getCurrentGitBranchAsync, getUserName, PROVIDER_DEFAULT_MODELS } from './chunk-GETSQXPO.js';
3
3
  import { MC_TOOLS, getToolCategory, TOOL_CATEGORIES } from './chunk-UOFNLVKF.js';
4
- import { exec, spawn, execFile, execSync, execFileSync } from 'child_process';
4
+ import { spawn, execFile, execSync, execFileSync } from 'child_process';
5
+ import { randomUUID, createHash } from 'crypto';
5
6
  import { visibleWidth, Box, Text, Spacer, Input, Container, fuzzyFilter, getKeybindings, Markdown, ProcessTerminal, TUI, truncateToWidth, Editor, matchesKey, CombinedAutocompleteProvider, SelectList, wrapTextWithAnsi, SettingsList, parseKey } from '@earendil-works/pi-tui';
6
7
  import chalk15 from 'chalk';
7
8
  import fs2, { existsSync, statSync, readFileSync, realpathSync, promises, unlinkSync } from 'fs';
8
9
  import * as path4 from 'path';
9
10
  import path4__default, { dirname, join, extname } from 'path';
10
11
  import { fileURLToPath } from 'url';
11
- import { randomUUID, createHash } from 'crypto';
12
12
  import { Readable } from 'stream';
13
13
  import { DeepgramVoice } from '@mastra/voice-deepgram';
14
14
  import { OpenAIVoice } from '@mastra/voice-openai';
@@ -1178,7 +1178,7 @@ function getInstallCommand(pm, version) {
1178
1178
  }
1179
1179
  function getCurrentVersion() {
1180
1180
  {
1181
- return "0.27.1-alpha.2";
1181
+ return "0.28.0-alpha.4";
1182
1182
  }
1183
1183
  }
1184
1184
  async function fetchLatestVersion() {
@@ -3372,15 +3372,7 @@ Example hooks.json:
3372
3372
  lines.push(` Project: ${paths.project}`);
3373
3373
  lines.push(` Global: ${paths.global}`);
3374
3374
  lines.push("");
3375
- const eventNames = [
3376
- "PreToolUse",
3377
- "PostToolUse",
3378
- "Stop",
3379
- "UserPromptSubmit",
3380
- "SessionStart",
3381
- "SessionEnd",
3382
- "Notification"
3383
- ];
3375
+ const eventNames = VALID_EVENTS;
3384
3376
  for (const event of eventNames) {
3385
3377
  const hooks = hookConfig[event];
3386
3378
  if (hooks && hooks.length > 0) {
@@ -3981,8 +3973,10 @@ function sendSystemNotification(reason, message) {
3981
3973
  if (process.platform === "darwin") {
3982
3974
  const title = "Mastra Code";
3983
3975
  const body = message || reasonToMessage(reason);
3984
- const escaped = body.replace(/"/g, '\\"');
3985
- exec(`osascript -e 'display notification "${escaped}" with title "${title}"'`);
3976
+ const escaped = body.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
3977
+ const script = `display notification "${escaped}" with title "${title}"`;
3978
+ execFile("osascript", ["-e", script], () => {
3979
+ });
3986
3980
  }
3987
3981
  }
3988
3982
  function reasonToMessage(reason) {
@@ -8670,6 +8664,10 @@ function handleToolApprovalRequired(ctx, toolCallId, toolName, args) {
8670
8664
  const category = getToolCategory(toolName);
8671
8665
  const categoryLabel = category ? TOOL_CATEGORIES[category]?.label : void 0;
8672
8666
  ctx.notify("tool_approval", `Approve ${toolName}?`);
8667
+ const firePermissionResult = (decision) => {
8668
+ state.hookManager?.runPermissionResult("tool_approval", toolCallId, toolName, decision, args).catch(() => {
8669
+ });
8670
+ };
8673
8671
  const dialog = new ToolApprovalDialogComponent({
8674
8672
  toolCallId,
8675
8673
  toolName,
@@ -8679,13 +8677,17 @@ function handleToolApprovalRequired(ctx, toolCallId, toolName, args) {
8679
8677
  state.ui.hideOverlay();
8680
8678
  state.pendingApprovalDismiss = null;
8681
8679
  if (action.type === "approve") {
8680
+ firePermissionResult("approved");
8682
8681
  state.session.respondToToolApproval({ decision: "approve" });
8683
8682
  } else if (action.type === "always_allow_category") {
8683
+ firePermissionResult("approved");
8684
8684
  state.session.respondToToolApproval({ decision: "always_allow_category" });
8685
8685
  } else if (action.type === "yolo") {
8686
+ firePermissionResult("auto_approved");
8686
8687
  void state.session.state.set({ yolo: true });
8687
8688
  state.session.respondToToolApproval({ decision: "approve" });
8688
8689
  } else {
8690
+ firePermissionResult("declined");
8689
8691
  state.session.respondToToolApproval({ decision: "decline" });
8690
8692
  }
8691
8693
  }
@@ -8693,6 +8695,7 @@ function handleToolApprovalRequired(ctx, toolCallId, toolName, args) {
8693
8695
  state.pendingApprovalDismiss = (declineContext) => {
8694
8696
  state.ui.hideOverlay();
8695
8697
  state.pendingApprovalDismiss = null;
8698
+ firePermissionResult("dismissed");
8696
8699
  state.session.respondToToolApproval({ decision: "decline", declineContext });
8697
8700
  };
8698
8701
  showModalOverlay(state.ui, dialog, { widthPercent: 0.7 });
@@ -14114,6 +14117,22 @@ Run /browser on to apply.`);
14114
14117
  }
14115
14118
  ctx.showInfo(summary.join("\n"));
14116
14119
  }
14120
+ function openUrlInBrowser(url) {
14121
+ let parsed;
14122
+ try {
14123
+ parsed = new URL(url);
14124
+ } catch {
14125
+ return;
14126
+ }
14127
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
14128
+ return;
14129
+ }
14130
+ const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url]] : ["xdg-open", [url]];
14131
+ const child = spawn(cmd, args, { stdio: "ignore", detached: true });
14132
+ child.on("error", () => {
14133
+ });
14134
+ child.unref();
14135
+ }
14117
14136
  var LoginDialogComponent = class extends Box {
14118
14137
  constructor(tui, providerId, onComplete) {
14119
14138
  super(2, 1, (text) => theme.bg("overlayBg", text));
@@ -14181,8 +14200,7 @@ var LoginDialogComponent = class extends Box {
14181
14200
  this.contentContainer.addChild(new Spacer(1));
14182
14201
  this.contentContainer.addChild(new Text(theme.fg("warning", instructions)));
14183
14202
  }
14184
- const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
14185
- exec(`${openCmd} "${url}"`);
14203
+ openUrlInBrowser(url);
14186
14204
  this.tui.requestRender();
14187
14205
  }
14188
14206
  /**
@@ -15547,9 +15565,9 @@ async function syncGithubSubscriptions(ctx) {
15547
15565
  }
15548
15566
  }
15549
15567
  async function detectCurrentPullRequest(ctx) {
15550
- const { execFile: execFile3 } = await import('child_process');
15568
+ const { execFile: execFile4 } = await import('child_process');
15551
15569
  return new Promise((resolve3) => {
15552
- execFile3(
15570
+ execFile4(
15553
15571
  "gh",
15554
15572
  ["pr", "view", "--json", "url", "--jq", ".url"],
15555
15573
  { cwd: ctx.state.projectInfo.rootPath },
@@ -16863,6 +16881,10 @@ async function handleAskQuestion(ctx, toolCallId, question, options, selectionMo
16863
16881
  async function handleSandboxAccessRequest(ctx, toolCallId, requestedPath, reason) {
16864
16882
  const { state } = ctx;
16865
16883
  return new Promise((resolve3) => {
16884
+ const firePermissionResult = (decision) => {
16885
+ state.hookManager?.runPermissionResult("sandbox_access", toolCallId, "request_access", decision, { path: requestedPath, reason }).catch(() => {
16886
+ });
16887
+ };
16866
16888
  const activate = () => {
16867
16889
  const questionComponent = new AskQuestionInlineComponent(
16868
16890
  {
@@ -16874,12 +16896,14 @@ ${theme.fg("dim", `Reason: ${reason}`)}`,
16874
16896
  ],
16875
16897
  onSubmit: (answer) => {
16876
16898
  state.activeInlineQuestion = void 0;
16899
+ firePermissionResult(answer.toLowerCase().startsWith("y") ? "approved" : "declined");
16877
16900
  state.session.respondToToolSuspension({ toolCallId, resumeData: answer });
16878
16901
  resolve3();
16879
16902
  processNextInlineQuestion(state);
16880
16903
  },
16881
16904
  onCancel: () => {
16882
16905
  state.activeInlineQuestion = void 0;
16906
+ firePermissionResult("dismissed");
16883
16907
  state.session.respondToToolSuspension({ toolCallId, resumeData: "No" });
16884
16908
  resolve3();
16885
16909
  processNextInlineQuestion(state);
@@ -16954,6 +16978,10 @@ async function handlePlanApproval(ctx, toolCallId, submittedPath) {
16954
16978
  }
16955
16979
  return new Promise((resolve3) => {
16956
16980
  const planFilename = snapshotKey;
16981
+ const firePermissionResult = (decision) => {
16982
+ state.hookManager?.runPermissionResult("plan_approval", toolCallId, "submit_plan", decision, { path: snapshotKey }).catch(() => {
16983
+ });
16984
+ };
16957
16985
  const approvalOptions = {
16958
16986
  toolCallId,
16959
16987
  title: resolvedTitle,
@@ -16963,12 +16991,14 @@ async function handlePlanApproval(ctx, toolCallId, submittedPath) {
16963
16991
  onApprove: async () => {
16964
16992
  state.activeInlinePlanApproval = void 0;
16965
16993
  state.ui.setFocus(state.editor);
16994
+ firePermissionResult("approved");
16966
16995
  await approvePlan(ctx, toolCallId, resolvedTitle, plan, planPath, snapshotKey);
16967
16996
  resolve3();
16968
16997
  },
16969
16998
  onGoal: async () => {
16970
16999
  state.activeInlinePlanApproval = void 0;
16971
17000
  state.ui.setFocus(state.editor);
17001
+ firePermissionResult("approved");
16972
17002
  await approvePlan(ctx, toolCallId, resolvedTitle, plan, planPath, snapshotKey);
16973
17003
  const objective = formatPlanGoalObjective(resolvedTitle, plan);
16974
17004
  await ctx.startGoal(objective, "Goal cancelled.");
@@ -16981,6 +17011,7 @@ async function handlePlanApproval(ctx, toolCallId, submittedPath) {
16981
17011
  onReject: () => {
16982
17012
  state.activeInlinePlanApproval = void 0;
16983
17013
  state.ui.setFocus(state.editor);
17014
+ firePermissionResult("declined");
16984
17015
  void (async () => {
16985
17016
  try {
16986
17017
  await state.session.respondToToolSuspension({
@@ -19796,6 +19827,8 @@ function setupKeyboardShortcuts(state, callbacks) {
19796
19827
  state.pendingInlineQuestions.length = 0;
19797
19828
  state.pendingAskUserComponents?.clear();
19798
19829
  state.userInitiatedAbort = true;
19830
+ state.hookManager?.runInterrupt("user_interrupt").catch(() => {
19831
+ });
19799
19832
  state.session.abort();
19800
19833
  } else {
19801
19834
  const current = state.editor.getText();
@@ -19913,6 +19946,8 @@ function abortActiveGoalJudge(state) {
19913
19946
  const activeGoalJudge = state.activeGoalJudge;
19914
19947
  if (!activeGoalJudge) return false;
19915
19948
  state.userInitiatedAbort = true;
19949
+ state.hookManager?.runInterrupt("goal_judge_interrupt").catch(() => {
19950
+ });
19916
19951
  activeGoalJudge.abortController.abort();
19917
19952
  activeGoalJudge.component.setInterrupted();
19918
19953
  state.session.abort();
@@ -20141,13 +20176,21 @@ function setupKeyHandlers(state, callbacks) {
20141
20176
  }
20142
20177
  if (state.pendingApprovalDismiss) {
20143
20178
  state.pendingApprovalDismiss();
20179
+ state.activeInlinePlanApproval = void 0;
20180
+ state.activeInlineQuestion = void 0;
20181
+ state.pendingInlineQuestions.length = 0;
20182
+ return;
20183
+ }
20184
+ if (state.session.run.isRunning() || state.session.suspensions.hasPending()) {
20185
+ state.activeInlinePlanApproval = void 0;
20186
+ state.activeInlineQuestion = void 0;
20187
+ state.pendingInlineQuestions.length = 0;
20188
+ state.pendingAskUserComponents?.clear();
20189
+ state.userInitiatedAbort = true;
20190
+ state.hookManager?.runInterrupt("process_sigint").catch(() => {
20191
+ });
20192
+ state.session.abort();
20144
20193
  }
20145
- state.activeInlinePlanApproval = void 0;
20146
- state.activeInlineQuestion = void 0;
20147
- state.pendingInlineQuestions.length = 0;
20148
- state.pendingAskUserComponents?.clear();
20149
- state.userInitiatedAbort = true;
20150
- state.session.abort();
20151
20194
  };
20152
20195
  process.on("SIGINT", sigintHandler);
20153
20196
  state.ui.onDebug = () => {
@@ -20966,6 +21009,7 @@ var MastraTUI = class _MastraTUI {
20966
21009
  this.clearStatusTimingTicker();
20967
21010
  this.startCaffeinate();
20968
21011
  this.lastStreamError = null;
21012
+ this.beginLifecycleRun();
20969
21013
  }
20970
21014
  if (event.type === "error" && "error" in event && !event.retryable) {
20971
21015
  const msg = event.error?.message || String(event.error);
@@ -20975,6 +21019,7 @@ var MastraTUI = class _MastraTUI {
20975
21019
  }
20976
21020
  }
20977
21021
  try {
21022
+ this.fireLifecycleHooksForEvent(event);
20978
21023
  await dispatchEvent(event, this.getEventContext(), this.state);
20979
21024
  this.captureAgentControllerAnalytics(event);
20980
21025
  if (event.type === "thread_created") {
@@ -20988,6 +21033,7 @@ var MastraTUI = class _MastraTUI {
20988
21033
  if (event.type === "agent_end") {
20989
21034
  const stopReason = event.reason === "aborted" ? "aborted" : event.reason === "error" ? "error" : "complete";
20990
21035
  this.startIdleStatusTimingTicker();
21036
+ await this.runAgentEndHook(event.reason ?? "complete");
20991
21037
  await this.runStopHook(stopReason);
20992
21038
  if (event.reason === "error" && this.lastStreamError) {
20993
21039
  this.emitErrorFeedback(this.lastStreamError);
@@ -20997,6 +21043,7 @@ var MastraTUI = class _MastraTUI {
20997
21043
  } finally {
20998
21044
  if (event.type === "agent_end") {
20999
21045
  this.stopCaffeinate();
21046
+ this.endLifecycleRun();
21000
21047
  }
21001
21048
  }
21002
21049
  }
@@ -21150,6 +21197,57 @@ var MastraTUI = class _MastraTUI {
21150
21197
  showInfo(this.state, `[${event}] ${warning}`);
21151
21198
  }
21152
21199
  }
21200
+ beginLifecycleRun() {
21201
+ const hookMgr = this.state.hookManager;
21202
+ if (!hookMgr) return;
21203
+ const runId = randomUUID();
21204
+ hookMgr.setRunId(runId);
21205
+ hookMgr.runAgentStart().catch(() => {
21206
+ });
21207
+ }
21208
+ fireLifecycleHooksForEvent(event) {
21209
+ const hookMgr = this.state.hookManager;
21210
+ if (!hookMgr) return;
21211
+ switch (event.type) {
21212
+ case "tool_approval_required":
21213
+ hookMgr.runPermissionRequest("tool_approval", event.toolCallId, event.toolName, event.args).catch(() => {
21214
+ });
21215
+ break;
21216
+ case "tool_suspended": {
21217
+ const payload = event.suspendPayload ?? {};
21218
+ if (event.toolName === "request_access" || payload.kind === "sandbox_access_request") {
21219
+ hookMgr.runPermissionRequest("sandbox_access", event.toolCallId, event.toolName, payload).catch(() => {
21220
+ });
21221
+ } else if (event.toolName === "submit_plan") {
21222
+ hookMgr.runPermissionRequest("plan_approval", event.toolCallId, event.toolName, payload).catch(() => {
21223
+ });
21224
+ }
21225
+ break;
21226
+ }
21227
+ case "subagent_start":
21228
+ hookMgr.runSubagentStart(event.toolCallId, event.agentType, event.task, event.modelId, event.forked).catch(() => {
21229
+ });
21230
+ break;
21231
+ case "subagent_end":
21232
+ hookMgr.runSubagentEnd(event.toolCallId, event.agentType, event.result, event.isError, event.durationMs).catch(() => {
21233
+ });
21234
+ break;
21235
+ }
21236
+ }
21237
+ async runAgentEndHook(reason) {
21238
+ const hookMgr = this.state.hookManager;
21239
+ if (!hookMgr) return;
21240
+ try {
21241
+ const result = await hookMgr.runAgentEnd(reason);
21242
+ this.showHookWarnings("AgentEnd", result.warnings);
21243
+ } catch (error) {
21244
+ showError(this.state, `AgentEnd hook failed: ${error instanceof Error ? error.message : String(error)}`);
21245
+ }
21246
+ }
21247
+ endLifecycleRun() {
21248
+ const hookMgr = this.state.hookManager;
21249
+ hookMgr?.clearRunId();
21250
+ }
21153
21251
  async runStopHook(stopReason) {
21154
21252
  const hookMgr = this.state.hookManager;
21155
21253
  if (!hookMgr) return;
@@ -21688,5 +21786,5 @@ Would you like to update now?`;
21688
21786
  };
21689
21787
 
21690
21788
  export { AssistantMessageComponent, LoginDialogComponent, LoginSelectorComponent, MastraTUI, ModelSelectorComponent, OMProgressComponent, ToolExecutionComponentEnhanced, UserMessageComponent, createTUIState, detectTerminalTheme, formatOMStatus, getCurrentVersion };
21691
- //# sourceMappingURL=chunk-M4LREDYM.js.map
21692
- //# sourceMappingURL=chunk-M4LREDYM.js.map
21789
+ //# sourceMappingURL=chunk-L2WPY5DE.js.map
21790
+ //# sourceMappingURL=chunk-L2WPY5DE.js.map