mastracode 0.40.1-alpha.0 → 0.41.0-alpha.10

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 (73) hide show
  1. package/dist/cli.cjs +4 -2
  2. package/dist/cli.cjs.map +1 -1
  3. package/dist/cli.js +4 -2
  4. package/dist/cli.js.map +1 -1
  5. package/dist/tui/assistant-render-registry.d.ts.map +1 -1
  6. package/dist/tui/background-activity.d.ts +25 -0
  7. package/dist/tui/background-activity.d.ts.map +1 -0
  8. package/dist/tui/background-tool-result.d.ts +2 -0
  9. package/dist/tui/background-tool-result.d.ts.map +1 -0
  10. package/dist/tui/commands/clone.d.ts.map +1 -1
  11. package/dist/tui/commands/goal.d.ts +1 -6
  12. package/dist/tui/commands/goal.d.ts.map +1 -1
  13. package/dist/tui/commands/login.d.ts.map +1 -1
  14. package/dist/tui/commands/models-pack.d.ts +24 -0
  15. package/dist/tui/commands/models-pack.d.ts.map +1 -1
  16. package/dist/tui/commands/models.d.ts.map +1 -1
  17. package/dist/tui/commands/new.d.ts.map +1 -1
  18. package/dist/tui/commands/settings.d.ts.map +1 -1
  19. package/dist/tui/commands/threads.d.ts.map +1 -1
  20. package/dist/tui/components/account-switch-notice.d.ts +24 -0
  21. package/dist/tui/components/account-switch-notice.d.ts.map +1 -0
  22. package/dist/tui/components/background-activity-selector.d.ts +19 -0
  23. package/dist/tui/components/background-activity-selector.d.ts.map +1 -0
  24. package/dist/tui/components/custom-editor.d.ts +5 -1
  25. package/dist/tui/components/custom-editor.d.ts.map +1 -1
  26. package/dist/tui/components/global-background-notice.d.ts +8 -0
  27. package/dist/tui/components/global-background-notice.d.ts.map +1 -0
  28. package/dist/tui/components/login-account-manager.d.ts +39 -0
  29. package/dist/tui/components/login-account-manager.d.ts.map +1 -0
  30. package/dist/tui/components/login-dialog.d.ts +10 -0
  31. package/dist/tui/components/login-dialog.d.ts.map +1 -1
  32. package/dist/tui/components/login-selector.d.ts +2 -0
  33. package/dist/tui/components/login-selector.d.ts.map +1 -1
  34. package/dist/tui/components/masked-input.d.ts +6 -0
  35. package/dist/tui/components/masked-input.d.ts.map +1 -1
  36. package/dist/tui/components/notification.d.ts +8 -0
  37. package/dist/tui/components/notification.d.ts.map +1 -1
  38. package/dist/tui/components/settings.d.ts +2 -0
  39. package/dist/tui/components/settings.d.ts.map +1 -1
  40. package/dist/tui/components/subagent-execution.d.ts +4 -0
  41. package/dist/tui/components/subagent-execution.d.ts.map +1 -1
  42. package/dist/tui/components/tool-execution-enhanced.d.ts +5 -0
  43. package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
  44. package/dist/tui/components/tool-execution-interface.d.ts +2 -0
  45. package/dist/tui/components/tool-execution-interface.d.ts.map +1 -1
  46. package/dist/tui/db-message-parts.d.ts +26 -1
  47. package/dist/tui/db-message-parts.d.ts.map +1 -1
  48. package/dist/tui/event-dispatch.d.ts.map +1 -1
  49. package/dist/tui/handlers/index.d.ts +1 -1
  50. package/dist/tui/handlers/index.d.ts.map +1 -1
  51. package/dist/tui/handlers/message.d.ts +14 -11
  52. package/dist/tui/handlers/message.d.ts.map +1 -1
  53. package/dist/tui/handlers/tool.d.ts +2 -0
  54. package/dist/tui/handlers/tool.d.ts.map +1 -1
  55. package/dist/tui/handlers/types.d.ts +1 -2
  56. package/dist/tui/handlers/types.d.ts.map +1 -1
  57. package/dist/tui/mastra-tui.d.ts +8 -0
  58. package/dist/tui/mastra-tui.d.ts.map +1 -1
  59. package/dist/tui/render-messages.d.ts.map +1 -1
  60. package/dist/tui/setup.d.ts +2 -0
  61. package/dist/tui/setup.d.ts.map +1 -1
  62. package/dist/tui/state.d.ts +17 -0
  63. package/dist/tui/state.d.ts.map +1 -1
  64. package/dist/tui/status-line.d.ts.map +1 -1
  65. package/dist/{tui-GNGQoTIY.js → tui-J0cKeh-t.js} +1799 -200
  66. package/dist/tui-J0cKeh-t.js.map +1 -0
  67. package/dist/{tui-B64FvoTy.cjs → tui-V-RCfOzz.cjs} +1796 -197
  68. package/dist/tui-V-RCfOzz.cjs.map +1 -0
  69. package/dist/tui.cjs +1 -1
  70. package/dist/tui.js +1 -1
  71. package/package.json +20 -20
  72. package/dist/tui-B64FvoTy.cjs.map +0 -1
  73. package/dist/tui-GNGQoTIY.js.map +0 -1
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_tui = require("./tui-B64FvoTy.cjs");
2
+ const require_tui = require("./tui-V-RCfOzz.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);
@@ -46,7 +46,7 @@ function resolveTuiSubagents(enabled) {
46
46
  //#endregion
47
47
  //#region src/version.ts
48
48
  function getCurrentVersion() {
49
- return "0.40.1-alpha.0";
49
+ return "0.41.0-alpha.10";
50
50
  }
51
51
  //#endregion
52
52
  //#region src/main.ts
@@ -157,6 +157,8 @@ async function tuiMain(pipedInput) {
157
157
  version: getCurrentVersion(),
158
158
  inlineQuestions: true,
159
159
  githubSignals: result.githubSignals,
160
+ backgroundToolsEnabled: result.backgroundToolsEnabled,
161
+ backgroundCompletionEvents: result.backgroundCompletionEvents,
160
162
  exit: (exitCode) => void shutdownAndExit(exitCode),
161
163
  ...pipedInput ? { initialMessage: `The following was piped via stdin:\n\n${pipedInput}` } : {}
162
164
  });
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","names":["createProcessMemoryDiagnosticsFromEnvironment","TUI_CO_AUTHOR","detectTerminalTheme","MastraTUI"],"sources":["../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["import {\n createProcessMemoryDiagnosticsFromEnvironment,\n startConfiguredProcessMemoryDiagnostics,\n type ProcessMemoryDiagnostics,\n type ProcessMemoryDiagnosticsEnvironment,\n type ProcessMemoryDiagnosticsSetup,\n} from '@mastra/code-sdk/process-memory-diagnostics';\n\nexport async function startTuiProcessMemoryDiagnostics(\n env: ProcessMemoryDiagnosticsEnvironment,\n warn: (message: string) => void,\n createSetup: (\n env: ProcessMemoryDiagnosticsEnvironment,\n ) => ProcessMemoryDiagnosticsSetup = createProcessMemoryDiagnosticsFromEnvironment,\n): Promise<ProcessMemoryDiagnostics> {\n return startConfiguredProcessMemoryDiagnostics(createSetup(env), warn);\n}\n\nexport function createOneShotFatalErrorHandler(handle: (error: unknown) => void): (error: unknown) => void {\n let handlingFatalError = false;\n return error => {\n if (handlingFatalError) return;\n handlingFatalError = true;\n handle(error);\n };\n}\n\nexport function createShutdownCoordinator(\n cleanup: () => Promise<void>,\n exit: (exitCode: number) => never,\n timeoutMs = 5_000,\n): (exitCode: number) => Promise<void> {\n let shutdownPromise: Promise<void> | null = null;\n return exitCode => {\n shutdownPromise ??= (async () => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([\n cleanup().catch(() => undefined),\n new Promise<void>(resolve => {\n timeout = setTimeout(resolve, timeoutMs);\n }),\n ]);\n if (timeout) clearTimeout(timeout);\n exit(exitCode);\n })();\n return shutdownPromise;\n };\n}\n","export function resolveTuiSubagents(enabled: boolean): undefined | [] {\n return enabled ? undefined : [];\n}\n","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 {\n stopProcessMemoryDiagnosticsWithTimeout,\n type ProcessMemoryDiagnostics,\n} from '@mastra/code-sdk/process-memory-diagnostics';\nimport { setupDebugLogging, truncateLogFile } 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 { TUI_CO_AUTHOR } from './commit-attribution.js';\nimport {\n createOneShotFatalErrorHandler,\n createShutdownCoordinator,\n startTuiProcessMemoryDiagnostics,\n} from './process-memory-diagnostics-lifecycle.js';\nimport { resolveTuiSubagents } from './subagent-settings.js';\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 processMemoryDiagnostics: ProcessMemoryDiagnostics | undefined;\nlet storageClosed = false;\nlet cleanupPromise: Promise<void> | null = null;\n\nconst CRASH_LOG_PATH = '/tmp/mastra-crash.log';\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 processMemoryDiagnostics = await startTuiProcessMemoryDiagnostics(process.env, warning => {\n console.info(`⚠ ${warning}`);\n });\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 coAuthor: TUI_CO_AUTHOR,\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n subagents: resolveTuiSubagents(settings.preferences.subagentsEnabled),\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 processMemoryDiagnostics,\n knowledgeInspector: result.knowledgeInspector,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n exit: exitCode => void shutdownAndExit(exitCode),\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 = (): Promise<void> => {\n cleanupPromise ??= (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 diagnosticsShutdown = processMemoryDiagnostics\n ? stopProcessMemoryDiagnosticsWithTimeout(processMemoryDiagnostics, message => console.warn(message))\n : undefined;\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([mcpManager?.disconnect(), controller?.stopIntervals(), closeSignalsPubSub?.()]);\n // Mastra owns the workspaces and must destroy them to stop retained language\n // servers before storage is closed.\n await Promise.allSettled([controller?.getMastra()?.shutdown(), analytics?.shutdown()]);\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 await diagnosticsShutdown;\n })();\n return cleanupPromise;\n};\n\nconst shutdownAndExit = createShutdownCoordinator(asyncCleanup, exitCode => process.exit(exitCode));\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// Start durable diagnostics shutdown before synchronous TUI teardown so a stalled\n// terminal cleanup cannot prevent the final profile capture. The exit handler still\n// provides a failsafe terminal reset if teardown throws.\nconst handleTermSignal = () => {\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void shutdownAndExit(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\nconst handleFatalError = createOneShotFatalErrorHandler((error: unknown): void => {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => {\n try {\n process.stderr.write(msg + '\\n');\n } catch {}\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 void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(1);\n return;\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 truncateLogFile(CRASH_LOG_PATH);\n fs.appendFileSync(CRASH_LOG_PATH, crashLog);\n truncateLogFile(CRASH_LOG_PATH);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(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(undefined, { coAuthor: TUI_CO_AUTHOR });\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({\n dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve'),\n coAuthor: TUI_CO_AUTHOR,\n });\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, { coAuthor: TUI_CO_AUTHOR });\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAQA,eAAsB,iCACpB,KACA,MACA,cAEqCA,4CAAAA,+CACF;CACnC,QAAA,GAAA,4CAAA,wCAAA,CAA+C,YAAY,GAAG,GAAG,IAAI;AACvE;AAEA,SAAgB,+BAA+B,QAA4D;CACzG,IAAI,qBAAqB;CACzB,QAAO,UAAS;EACd,IAAI,oBAAoB;EACxB,qBAAqB;EACrB,OAAO,KAAK;CACd;AACF;AAEA,SAAgB,0BACd,SACA,MACA,YAAY,KACyB;CACrC,IAAI,kBAAwC;CAC5C,QAAO,aAAY;EACjB,qBAAqB,YAAY;GAC/B,IAAI;GACJ,MAAM,QAAQ,KAAK,CACjB,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS,GAC/B,IAAI,SAAc,YAAW;IAC3B,UAAU,WAAW,SAAS,SAAS;GACzC,CAAC,CACH,CAAC;GACD,IAAI,SAAS,aAAa,OAAO;GACjC,KAAK,QAAQ;EACf,EAAA,CAAG;EACH,OAAO;CACT;AACF;;;AC/CA,SAAgB,oBAAoB,SAAkC;CACpE,OAAO,UAAU,KAAA,IAAY,CAAC;AAChC;;;ACEA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACoBA,IAAI;A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AAC;AAED,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,KAAA,GAAW,EAAE,UAAUF,YAAAA,cAAc,CAAC;CAGxD,IAAI,QAAQ,KAAK,SAAS,OAAO,GAAG;EAClC,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ;GACb,sBAAsB,QAAQ,KAAK,SAAS,0BAA0B;GACtE,UAAUA,YAAAA;EACZ,CAAC;CACH;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,YAAY,EAAE,UAAUA,YAAAA,cAAc,CAAC;EACzD;CACF;CAEA,OAAO,QAAQ,UAAU;AAC3B;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
1
+ {"version":3,"file":"cli.cjs","names":["createProcessMemoryDiagnosticsFromEnvironment","TUI_CO_AUTHOR","detectTerminalTheme","MastraTUI"],"sources":["../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["import {\n createProcessMemoryDiagnosticsFromEnvironment,\n startConfiguredProcessMemoryDiagnostics,\n type ProcessMemoryDiagnostics,\n type ProcessMemoryDiagnosticsEnvironment,\n type ProcessMemoryDiagnosticsSetup,\n} from '@mastra/code-sdk/process-memory-diagnostics';\n\nexport async function startTuiProcessMemoryDiagnostics(\n env: ProcessMemoryDiagnosticsEnvironment,\n warn: (message: string) => void,\n createSetup: (\n env: ProcessMemoryDiagnosticsEnvironment,\n ) => ProcessMemoryDiagnosticsSetup = createProcessMemoryDiagnosticsFromEnvironment,\n): Promise<ProcessMemoryDiagnostics> {\n return startConfiguredProcessMemoryDiagnostics(createSetup(env), warn);\n}\n\nexport function createOneShotFatalErrorHandler(handle: (error: unknown) => void): (error: unknown) => void {\n let handlingFatalError = false;\n return error => {\n if (handlingFatalError) return;\n handlingFatalError = true;\n handle(error);\n };\n}\n\nexport function createShutdownCoordinator(\n cleanup: () => Promise<void>,\n exit: (exitCode: number) => never,\n timeoutMs = 5_000,\n): (exitCode: number) => Promise<void> {\n let shutdownPromise: Promise<void> | null = null;\n return exitCode => {\n shutdownPromise ??= (async () => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([\n cleanup().catch(() => undefined),\n new Promise<void>(resolve => {\n timeout = setTimeout(resolve, timeoutMs);\n }),\n ]);\n if (timeout) clearTimeout(timeout);\n exit(exitCode);\n })();\n return shutdownPromise;\n };\n}\n","export function resolveTuiSubagents(enabled: boolean): undefined | [] {\n return enabled ? undefined : [];\n}\n","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 {\n stopProcessMemoryDiagnosticsWithTimeout,\n type ProcessMemoryDiagnostics,\n} from '@mastra/code-sdk/process-memory-diagnostics';\nimport { setupDebugLogging, truncateLogFile } 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 { TUI_CO_AUTHOR } from './commit-attribution.js';\nimport {\n createOneShotFatalErrorHandler,\n createShutdownCoordinator,\n startTuiProcessMemoryDiagnostics,\n} from './process-memory-diagnostics-lifecycle.js';\nimport { resolveTuiSubagents } from './subagent-settings.js';\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 processMemoryDiagnostics: ProcessMemoryDiagnostics | undefined;\nlet storageClosed = false;\nlet cleanupPromise: Promise<void> | null = null;\n\nconst CRASH_LOG_PATH = '/tmp/mastra-crash.log';\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 processMemoryDiagnostics = await startTuiProcessMemoryDiagnostics(process.env, warning => {\n console.info(`⚠ ${warning}`);\n });\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 coAuthor: TUI_CO_AUTHOR,\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n subagents: resolveTuiSubagents(settings.preferences.subagentsEnabled),\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 processMemoryDiagnostics,\n knowledgeInspector: result.knowledgeInspector,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n backgroundToolsEnabled: result.backgroundToolsEnabled,\n backgroundCompletionEvents: result.backgroundCompletionEvents,\n exit: exitCode => void shutdownAndExit(exitCode),\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 = (): Promise<void> => {\n cleanupPromise ??= (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 diagnosticsShutdown = processMemoryDiagnostics\n ? stopProcessMemoryDiagnosticsWithTimeout(processMemoryDiagnostics, message => console.warn(message))\n : undefined;\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([mcpManager?.disconnect(), controller?.stopIntervals(), closeSignalsPubSub?.()]);\n // Mastra owns the workspaces and must destroy them to stop retained language\n // servers before storage is closed.\n await Promise.allSettled([controller?.getMastra()?.shutdown(), analytics?.shutdown()]);\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 await diagnosticsShutdown;\n })();\n return cleanupPromise;\n};\n\nconst shutdownAndExit = createShutdownCoordinator(asyncCleanup, exitCode => process.exit(exitCode));\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// Start durable diagnostics shutdown before synchronous TUI teardown so a stalled\n// terminal cleanup cannot prevent the final profile capture. The exit handler still\n// provides a failsafe terminal reset if teardown throws.\nconst handleTermSignal = () => {\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void shutdownAndExit(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\nconst handleFatalError = createOneShotFatalErrorHandler((error: unknown): void => {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => {\n try {\n process.stderr.write(msg + '\\n');\n } catch {}\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 void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(1);\n return;\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 truncateLogFile(CRASH_LOG_PATH);\n fs.appendFileSync(CRASH_LOG_PATH, crashLog);\n truncateLogFile(CRASH_LOG_PATH);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(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(undefined, { coAuthor: TUI_CO_AUTHOR });\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({\n dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve'),\n coAuthor: TUI_CO_AUTHOR,\n });\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, { coAuthor: TUI_CO_AUTHOR });\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAQA,eAAsB,iCACpB,KACA,MACA,cAEqCA,4CAAAA,+CACF;CACnC,QAAA,GAAA,4CAAA,wCAAA,CAA+C,YAAY,GAAG,GAAG,IAAI;AACvE;AAEA,SAAgB,+BAA+B,QAA4D;CACzG,IAAI,qBAAqB;CACzB,QAAO,UAAS;EACd,IAAI,oBAAoB;EACxB,qBAAqB;EACrB,OAAO,KAAK;CACd;AACF;AAEA,SAAgB,0BACd,SACA,MACA,YAAY,KACyB;CACrC,IAAI,kBAAwC;CAC5C,QAAO,aAAY;EACjB,qBAAqB,YAAY;GAC/B,IAAI;GACJ,MAAM,QAAQ,KAAK,CACjB,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS,GAC/B,IAAI,SAAc,YAAW;IAC3B,UAAU,WAAW,SAAS,SAAS;GACzC,CAAC,CACH,CAAC;GACD,IAAI,SAAS,aAAa,OAAO;GACjC,KAAK,QAAQ;EACf,EAAA,CAAG;EACH,OAAO;CACT;AACF;;;AC/CA,SAAgB,oBAAoB,SAAkC;CACpE,OAAO,UAAU,KAAA,IAAY,CAAC;AACh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,MAAM,MAAM,KAAK;CAEnB,aAAkB;CAClB,IAAI;EACF,KAAK,KAAK;CACZ,QAAQ,CAAC;CACT,gBAAqB,CAAC;AACxB,CAAC;AAED,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,KAAA,GAAW,EAAE,UAAUF,YAAAA,cAAc,CAAC;CAGxD,IAAI,QAAQ,KAAK,SAAS,OAAO,GAAG;EAClC,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ;GACb,sBAAsB,QAAQ,KAAK,SAAS,0BAA0B;GACtE,UAAUA,YAAAA;EACZ,CAAC;CACH;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,YAAY,EAAE,UAAUA,YAAAA,cAAc,CAAC;EACzD;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 { b as TUI_CO_AUTHOR, d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-GNGQoTIY.js";
2
+ import { b as TUI_CO_AUTHOR, d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-J0cKeh-t.js";
3
3
  import { createMastraCode } from "@mastra/code-sdk";
4
4
  import fs from "fs";
5
5
  import { createMastraCodeAnalytics } from "@mastra/code-sdk/analytics";
@@ -45,7 +45,7 @@ function resolveTuiSubagents(enabled) {
45
45
  //#endregion
46
46
  //#region src/version.ts
47
47
  function getCurrentVersion() {
48
- return "0.40.1-alpha.0";
48
+ return "0.41.0-alpha.10";
49
49
  }
50
50
  //#endregion
51
51
  //#region src/main.ts
@@ -156,6 +156,8 @@ async function tuiMain(pipedInput) {
156
156
  version: getCurrentVersion(),
157
157
  inlineQuestions: true,
158
158
  githubSignals: result.githubSignals,
159
+ backgroundToolsEnabled: result.backgroundToolsEnabled,
160
+ backgroundCompletionEvents: result.backgroundCompletionEvents,
159
161
  exit: (exitCode) => void shutdownAndExit(exitCode),
160
162
  ...pipedInput ? { initialMessage: `The following was piped via stdin:\n\n${pipedInput}` } : {}
161
163
  });
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["import {\n createProcessMemoryDiagnosticsFromEnvironment,\n startConfiguredProcessMemoryDiagnostics,\n type ProcessMemoryDiagnostics,\n type ProcessMemoryDiagnosticsEnvironment,\n type ProcessMemoryDiagnosticsSetup,\n} from '@mastra/code-sdk/process-memory-diagnostics';\n\nexport async function startTuiProcessMemoryDiagnostics(\n env: ProcessMemoryDiagnosticsEnvironment,\n warn: (message: string) => void,\n createSetup: (\n env: ProcessMemoryDiagnosticsEnvironment,\n ) => ProcessMemoryDiagnosticsSetup = createProcessMemoryDiagnosticsFromEnvironment,\n): Promise<ProcessMemoryDiagnostics> {\n return startConfiguredProcessMemoryDiagnostics(createSetup(env), warn);\n}\n\nexport function createOneShotFatalErrorHandler(handle: (error: unknown) => void): (error: unknown) => void {\n let handlingFatalError = false;\n return error => {\n if (handlingFatalError) return;\n handlingFatalError = true;\n handle(error);\n };\n}\n\nexport function createShutdownCoordinator(\n cleanup: () => Promise<void>,\n exit: (exitCode: number) => never,\n timeoutMs = 5_000,\n): (exitCode: number) => Promise<void> {\n let shutdownPromise: Promise<void> | null = null;\n return exitCode => {\n shutdownPromise ??= (async () => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([\n cleanup().catch(() => undefined),\n new Promise<void>(resolve => {\n timeout = setTimeout(resolve, timeoutMs);\n }),\n ]);\n if (timeout) clearTimeout(timeout);\n exit(exitCode);\n })();\n return shutdownPromise;\n };\n}\n","export function resolveTuiSubagents(enabled: boolean): undefined | [] {\n return enabled ? undefined : [];\n}\n","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 {\n stopProcessMemoryDiagnosticsWithTimeout,\n type ProcessMemoryDiagnostics,\n} from '@mastra/code-sdk/process-memory-diagnostics';\nimport { setupDebugLogging, truncateLogFile } 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 { TUI_CO_AUTHOR } from './commit-attribution.js';\nimport {\n createOneShotFatalErrorHandler,\n createShutdownCoordinator,\n startTuiProcessMemoryDiagnostics,\n} from './process-memory-diagnostics-lifecycle.js';\nimport { resolveTuiSubagents } from './subagent-settings.js';\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 processMemoryDiagnostics: ProcessMemoryDiagnostics | undefined;\nlet storageClosed = false;\nlet cleanupPromise: Promise<void> | null = null;\n\nconst CRASH_LOG_PATH = '/tmp/mastra-crash.log';\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 processMemoryDiagnostics = await startTuiProcessMemoryDiagnostics(process.env, warning => {\n console.info(`⚠ ${warning}`);\n });\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 coAuthor: TUI_CO_AUTHOR,\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n subagents: resolveTuiSubagents(settings.preferences.subagentsEnabled),\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 processMemoryDiagnostics,\n knowledgeInspector: result.knowledgeInspector,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n exit: exitCode => void shutdownAndExit(exitCode),\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 = (): Promise<void> => {\n cleanupPromise ??= (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 diagnosticsShutdown = processMemoryDiagnostics\n ? stopProcessMemoryDiagnosticsWithTimeout(processMemoryDiagnostics, message => console.warn(message))\n : undefined;\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([mcpManager?.disconnect(), controller?.stopIntervals(), closeSignalsPubSub?.()]);\n // Mastra owns the workspaces and must destroy them to stop retained language\n // servers before storage is closed.\n await Promise.allSettled([controller?.getMastra()?.shutdown(), analytics?.shutdown()]);\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 await diagnosticsShutdown;\n })();\n return cleanupPromise;\n};\n\nconst shutdownAndExit = createShutdownCoordinator(asyncCleanup, exitCode => process.exit(exitCode));\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// Start durable diagnostics shutdown before synchronous TUI teardown so a stalled\n// terminal cleanup cannot prevent the final profile capture. The exit handler still\n// provides a failsafe terminal reset if teardown throws.\nconst handleTermSignal = () => {\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void shutdownAndExit(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\nconst handleFatalError = createOneShotFatalErrorHandler((error: unknown): void => {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => {\n try {\n process.stderr.write(msg + '\\n');\n } catch {}\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 void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(1);\n return;\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 truncateLogFile(CRASH_LOG_PATH);\n fs.appendFileSync(CRASH_LOG_PATH, crashLog);\n truncateLogFile(CRASH_LOG_PATH);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(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(undefined, { coAuthor: TUI_CO_AUTHOR });\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({\n dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve'),\n coAuthor: TUI_CO_AUTHOR,\n });\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, { coAuthor: TUI_CO_AUTHOR });\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAQA,eAAsB,iCACpB,KACA,MACA,cAEqC,+CACF;CACnC,OAAO,wCAAwC,YAAY,GAAG,GAAG,IAAI;AACvE;AAEA,SAAgB,+BAA+B,QAA4D;CACzG,IAAI,qBAAqB;CACzB,QAAO,UAAS;EACd,IAAI,oBAAoB;EACxB,qBAAqB;EACrB,OAAO,KAAK;CACd;AACF;AAEA,SAAgB,0BACd,SACA,MACA,YAAY,KACyB;CACrC,IAAI,kBAAwC;CAC5C,QAAO,aAAY;EACjB,qBAAqB,YAAY;GAC/B,IAAI;GACJ,MAAM,QAAQ,KAAK,CACjB,QAAQ,CAAC,CAAC,YAAY,KAAA,CAAS,GAC/B,IAAI,SAAc,YAAW;IAC3B,UAAU,WAAW,SAAS,SAAS;GACzC,CAAC,CACH,CAAC;GACD,IAAI,SAAS,aAAa,OAAO;GACjC,KAAK,QAAQ;EACf,EAAA,CAAG;EACH,OAAO;CACT;AACF;;;AC/CA,SAAgB,oBAAoB,SAAkC;CACpE,OAAO,UAAU,KAAA,IAAY,CAAC;AAChC;;;ACEA,SAAgB,oBAA4B;CAExC,OAAA;AAKJ;;;;;;ACoBA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI,gBAAgB;AACpB,IAAI,iBAAuC;AAE3C,MAAM,iBAAiB;AAEvB,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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B,CAAC"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["import {\n createProcessMemoryDiagnosticsFromEnvironment,\n startConfiguredProcessMemoryDiagnostics,\n type ProcessMemoryDiagnostics,\n type ProcessMemoryDiagnosticsEnvironment,\n type ProcessMemoryDiagnosticsSetup,\n} from '@mastra/code-sdk/process-memory-diagnostics';\n\nexport async function startTuiProcessMemoryDiagnostics(\n env: ProcessMemoryDiagnosticsEnvironment,\n warn: (message: string) => void,\n createSetup: (\n env: ProcessMemoryDiagnosticsEnvironment,\n ) => ProcessMemoryDiagnosticsSetup = createProcessMemoryDiagnosticsFromEnvironment,\n): Promise<ProcessMemoryDiagnostics> {\n return startConfiguredProcessMemoryDiagnostics(createSetup(env), warn);\n}\n\nexport function createOneShotFatalErrorHandler(handle: (error: unknown) => void): (error: unknown) => void {\n let handlingFatalError = false;\n return error => {\n if (handlingFatalError) return;\n handlingFatalError = true;\n handle(error);\n };\n}\n\nexport function createShutdownCoordinator(\n cleanup: () => Promise<void>,\n exit: (exitCode: number) => never,\n timeoutMs = 5_000,\n): (exitCode: number) => Promise<void> {\n let shutdownPromise: Promise<void> | null = null;\n return exitCode => {\n shutdownPromise ??= (async () => {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n await Promise.race([\n cleanup().catch(() => undefined),\n new Promise<void>(resolve => {\n timeout = setTimeout(resolve, timeoutMs);\n }),\n ]);\n if (timeout) clearTimeout(timeout);\n exit(exitCode);\n })();\n return shutdownPromise;\n };\n}\n","export function resolveTuiSubagents(enabled: boolean): undefined | [] {\n return enabled ? undefined : [];\n}\n","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 {\n stopProcessMemoryDiagnosticsWithTimeout,\n type ProcessMemoryDiagnostics,\n} from '@mastra/code-sdk/process-memory-diagnostics';\nimport { setupDebugLogging, truncateLogFile } 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 { TUI_CO_AUTHOR } from './commit-attribution.js';\nimport {\n createOneShotFatalErrorHandler,\n createShutdownCoordinator,\n startTuiProcessMemoryDiagnostics,\n} from './process-memory-diagnostics-lifecycle.js';\nimport { resolveTuiSubagents } from './subagent-settings.js';\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 processMemoryDiagnostics: ProcessMemoryDiagnostics | undefined;\nlet storageClosed = false;\nlet cleanupPromise: Promise<void> | null = null;\n\nconst CRASH_LOG_PATH = '/tmp/mastra-crash.log';\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 processMemoryDiagnostics = await startTuiProcessMemoryDiagnostics(process.env, warning => {\n console.info(`⚠ ${warning}`);\n });\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 coAuthor: TUI_CO_AUTHOR,\n unixSocketPubSub: !isTruthyEnv('MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB'),\n disableMcp: isTruthyEnv('MASTRACODE_DISABLE_MCP'),\n disableHooks: isTruthyEnv('MASTRACODE_DISABLE_HOOKS'),\n subagents: resolveTuiSubagents(settings.preferences.subagentsEnabled),\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 processMemoryDiagnostics,\n knowledgeInspector: result.knowledgeInspector,\n appName: 'Mastra Code',\n version: getCurrentVersion(),\n inlineQuestions: true,\n githubSignals: result.githubSignals,\n backgroundToolsEnabled: result.backgroundToolsEnabled,\n backgroundCompletionEvents: result.backgroundCompletionEvents,\n exit: exitCode => void shutdownAndExit(exitCode),\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 = (): Promise<void> => {\n cleanupPromise ??= (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 diagnosticsShutdown = processMemoryDiagnostics\n ? stopProcessMemoryDiagnosticsWithTimeout(processMemoryDiagnostics, message => console.warn(message))\n : undefined;\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([mcpManager?.disconnect(), controller?.stopIntervals(), closeSignalsPubSub?.()]);\n // Mastra owns the workspaces and must destroy them to stop retained language\n // servers before storage is closed.\n await Promise.allSettled([controller?.getMastra()?.shutdown(), analytics?.shutdown()]);\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 await diagnosticsShutdown;\n })();\n return cleanupPromise;\n};\n\nconst shutdownAndExit = createShutdownCoordinator(asyncCleanup, exitCode => process.exit(exitCode));\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// Start durable diagnostics shutdown before synchronous TUI teardown so a stalled\n// terminal cleanup cannot prevent the final profile capture. The exit handler still\n// provides a failsafe terminal reset if teardown throws.\nconst handleTermSignal = () => {\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {\n // ignored — exit handler has failsafe reset\n }\n void shutdownAndExit(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\nconst handleFatalError = createOneShotFatalErrorHandler((error: unknown): void => {\n // Always write to real stderr, even if console.error was overridden\n const write = (msg: string) => {\n try {\n process.stderr.write(msg + '\\n');\n } catch {}\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 void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(1);\n return;\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 truncateLogFile(CRASH_LOG_PATH);\n fs.appendFileSync(CRASH_LOG_PATH, crashLog);\n truncateLogFile(CRASH_LOG_PATH);\n } catch {}\n if (error instanceof Error && error.stack) {\n write(error.stack);\n }\n void asyncCleanup();\n try {\n tui?.stop();\n } catch {}\n void shutdownAndExit(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(undefined, { coAuthor: TUI_CO_AUTHOR });\n }\n\n if (process.argv.includes('--acp')) {\n const { acpMain } = await import('@mastra/code-sdk/acp/index');\n return acpMain({\n dangerousAutoApprove: process.argv.includes('--dangerous-auto-approve'),\n coAuthor: TUI_CO_AUTHOR,\n });\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, { coAuthor: TUI_CO_AUTHOR });\n }\n }\n\n return tuiMain(pipedInput);\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAQA,eAAsB,iCACpB,KACA,MACA,cAEqC,+CACF;CACnC,OAAO,wCAAwC,YAAY,GAAG,GAAG,IAAI;AACvE;AAEA,SAAgB,+BAA+B,QAA4D;CACzG,IAAI,qBAAqB;CACzB,QAAO,UAAS;EACd,IAAI,oBAAoB;EACxB,qBAAqB;EACrB,OAAO,KAAK;CACd;AACF;AAEA,SAAgB,0BACd,SACA,MACA,YAAY,KACyB;CACrC,IAAI,kBAAwC;CAC5C,QAAO,aAAY;EACjB,qBAAqB,YAAY;GAC/B,IAAI;GACJ,MAAM,QAAQ,KAAK,CACjB,QAAQ,CAAC,CAAC,YAAY,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jE"}
1
+ {"version":3,"file":"assistant-render-registry.d.ts","sourceRoot":"","sources":["../../src/tui/assistant-render-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAGtG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,UAAU,wBAAwB;IAChC,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,oBAAoB;IAC5B,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,cAAc,EAAE,uBAAuB,CAAC;CACzC;AAED,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,yBAAyB,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACzC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,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AAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE;IAiB7D,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,YAAY;IA2CpB,OAAO,CAAC,YAAY;CAiBrB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,SAAS,EAAE,yBAAyB,KAAK,IAAI,EACxD,mBAAmB,CAAC,EAAE,MAAM,GAC3B,yBAAyB,CAU3B;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAKhE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAIjE"}
@@ -0,0 +1,25 @@
1
+ import type { BackgroundCompletionEvent } from '@mastra/code-sdk/agents/background-completion-events';
2
+ export type BackgroundActivityStatus = 'accepted' | 'completed' | 'failed' | 'cancelled';
3
+ export interface BackgroundActivity {
4
+ id: string;
5
+ taskId: string;
6
+ toolCallId: string;
7
+ toolName: string;
8
+ resourceId: string;
9
+ threadId: string;
10
+ status: BackgroundActivityStatus;
11
+ createdAt: number;
12
+ completedAt?: number;
13
+ }
14
+ export interface BackgroundToolContext {
15
+ toolName: string;
16
+ resourceId: string;
17
+ threadId: string;
18
+ createdAt: number;
19
+ }
20
+ export declare function acceptBackgroundActivity(activities: Map<string, BackgroundActivity>, taskId: string, toolCallId: string, context: BackgroundToolContext): void;
21
+ export declare function completeBackgroundActivity(activities: Map<string, BackgroundActivity>, event: BackgroundCompletionEvent): void;
22
+ export declare function compareBackgroundActivities(a: BackgroundActivity, b: BackgroundActivity): number;
23
+ export declare function getBackgroundActivitiesForTarget(activities: Map<string, BackgroundActivity>, resourceId: string, threadId: string | null): BackgroundActivity[];
24
+ export declare function clearCompletedBackgroundActivitiesForTarget(activities: Map<string, BackgroundActivity>, resourceId: string, threadId: string | null): void;
25
+ //# sourceMappingURL=background-activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-activity.d.ts","sourceRoot":"","sources":["../../src/tui/background-activity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;AAEtG,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEzF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,wBAAwB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC3C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAcN;AAED,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC3C,KAAK,EAAE,yBAAyB,GAC/B,IAAI,CAcN;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAIhG;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC3C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,kBAAkB,EAAE,CAKtB;AAED,wBAAgB,2CAA2C,CACzD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC3C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,IAAI,CAON"}
@@ -0,0 +1,2 @@
1
+ export declare function parseBackgroundToolTaskId(result: string): string | undefined;
2
+ //# sourceMappingURL=background-tool-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-tool-result.d.ts","sourceRoot":"","sources":["../../src/tui/background-tool-result.ts"],"names":[],"mappings":"AAEA,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/clone.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;4EAC4E;AAC5E,UAAU,iBAAiB;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU1F;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAI1E;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBlG;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhF"}
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/clone.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;4EAC4E;AAC5E,UAAU,iBAAiB;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU1F;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAI1E;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BlG;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhF"}
@@ -1,11 +1,6 @@
1
- import type { MastraDBMessage } from '@mastra/core/agent-controller';
2
1
  import type { SlashCommandContext } from './types.js';
3
- export interface StartGoalOptions {
4
- trigger?: 'send' | 'none';
5
- }
6
2
  export declare function handleGoalCommand(ctx: SlashCommandContext, args: string[]): Promise<void>;
7
3
  export declare function handleJudgeCommand(ctx: SlashCommandContext): Promise<void>;
8
- export declare function startGoalWithDefaults(ctx: SlashCommandContext, objective: string, cancelMessage?: string, options?: StartGoalOptions): Promise<void>;
9
- export declare function createGoalReminderMessage(goalId: string, objective: string, maxTurns: number, judgeModelId: string): MastraDBMessage;
4
+ export declare function startGoalWithDefaults(ctx: SlashCommandContext, objective: string, cancelMessage?: string): Promise<void>;
10
5
  export declare function createGoalReminderXml(message: string): string;
11
6
  //# sourceMappingURL=goal.d.ts.map
@@ -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,CA2G/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;AAgJD,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"}
1
+ {"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/goal.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkG/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,GAChC,OAAO,CAAC,IAAI,CAAC,CAMf;AAuID,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/login.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA2EtD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA2D1G"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/login.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoNtD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE1G"}
@@ -5,8 +5,32 @@ import type { SlashCommandContext } from './types.js';
5
5
  export { removeCustomPackFromSettings };
6
6
  export declare function serializePack(pack: ModePack): string;
7
7
  export declare function deserializePack(input: string): ModePack | null;
8
+ type AccountLabelLookup = (providerId: string) => Array<{
9
+ id: string;
10
+ label: string;
11
+ }>;
12
+ export declare function formatPackAccountRoutingSummary(settings: GlobalSettings, pack: ModePack, lookupAccounts?: AccountLabelLookup): string;
13
+ /** "Activate" detail: the pack's model lines plus its fallback chain when one is set. */
14
+ export declare function activateActionDetail(baseDetail: string, settings: GlobalSettings, packs: ModePack[], packId: string): string;
15
+ /**
16
+ * Set (or clear, with null) a pack's fallback pack. Values come from the
17
+ * /models picker, which only lists known packs — write-time validation is the
18
+ * picker itself. Load-time dangling tolerance lives in settings parsing.
19
+ */
20
+ export declare function setPackFallback(settings: GlobalSettings, packId: string, fallbackId: string | null): void;
21
+ /** Picker candidates for a pack's fallback: every pack except the pack itself (and the "New Custom" pseudo-row). */
22
+ export declare function fallbackPackCandidates(packs: ModePack[], packId: string): ModePack[];
8
23
  export declare function resetBuiltinPackOverrides(settings: GlobalSettings, packId: string): void;
9
24
  export declare function upsertCustomPackInSettings(settings: GlobalSettings, pack: ModePack, modeDefaults: Record<string, string>, previousPackId?: string, setActive?: boolean): void;
10
25
  export declare function getOverriddenPackModes(pack: ModePack, builtinPack: ModePack): Array<'plan' | 'build' | 'fast'>;
26
+ /**
27
+ * Render the fallback chain a pack implies, e.g. "OpenAI → GitHub Copilot".
28
+ * Returns null when the pack has no fallback. The walk is the SDK's
29
+ * construction-capped one, so the display matches what a cascade would do.
30
+ */
31
+ export declare function formatPackFallbackChain(settings: GlobalSettings, packs: ModePack[], packId: string): string | null;
32
+ export declare function formatFallbackChainPreview(settings: GlobalSettings, packs: ModePack[], pack: ModePack, fallbackId: string | null): string;
33
+ /** Picker preview line: dim lead-in with the chain highlighted so it stands out. */
34
+ export declare function formatFallbackChainPreviewStyled(settings: GlobalSettings, packs: ModePack[], pack: ModePack, fallbackId: string | null): string;
11
35
  export declare function handleModelsPackCommand(ctx: SlashCommandContext): Promise<void>;
12
36
  //# sourceMappingURL=models-pack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models-pack.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/models-pack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0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CAE9G;AAwKD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQlH;AA2BD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,QAAQ,EAAE,EACjB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,MAAM,CAGR;AAED,oFAAoF;AACpF,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,QAAQ,EAAE,EACjB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,MAAM,CAGR;AAgND,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+RrF"}
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/models.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAmHtD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEhF"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/models.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAiKtD,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiEhF"}
@@ -1 +1 @@
1
- {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/new.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC9E"}
1
+ {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/new.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/settings.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgLtD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqHnF"}
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/settings.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgLtD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4HnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/threads.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,mBAAmB,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,IAAI,CAuCN;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2HlF"}
1
+ {"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/threads.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,mBAAmB,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,IAAI,CAuCN;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8HlF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * One-line transcript notice for persisted `data-mastracode-account-switch`
3
+ * parts: account rotations, pool exhaustion, and starting-on-account notices.
4
+ * Modeled on OMMarkerComponent (single themed Text row). The copy comes from
5
+ * the SDK's shared formatter so live `info`-event lines and history-reloaded
6
+ * part lines read identically.
7
+ */
8
+ import { Container } from '@earendil-works/pi-tui';
9
+ import type { AccountSwitchPartData, PackFallbackPartData } from '@mastra/code-sdk/auth/account-rotation-processor';
10
+ import type { ChatSpacingKind } from './chat-spacing.js';
11
+ export type AccountSwitchNoticeData = AccountSwitchPartData;
12
+ export declare function formatAccountSwitchNotice(data: AccountSwitchNoticeData): string;
13
+ export declare class AccountSwitchNoticeComponent extends Container {
14
+ private textChild;
15
+ constructor(data: AccountSwitchNoticeData);
16
+ getChatSpacingKind(): ChatSpacingKind;
17
+ }
18
+ export type PackFallbackNoticeData = PackFallbackPartData;
19
+ export declare class PackFallbackNoticeComponent extends Container {
20
+ private textChild;
21
+ constructor(data: PackFallbackNoticeData);
22
+ getChatSpacingKind(): ChatSpacingKind;
23
+ }
24
+ //# sourceMappingURL=account-switch-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-switch-notice.d.ts","sourceRoot":"","sources":["../../../src/tui/components/account-switch-notice.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAQ,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAGpH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE5D,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,CAE/E;AAED,qBAAa,4BAA6B,SAAQ,SAAS;IACzD,OAAO,CAAC,SAAS,CAAO;gBAEZ,IAAI,EAAE,uBAAuB;IAMzC,kBAAkB,IAAI,eAAe;CAGtC;AAED,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE1D,qBAAa,2BAA4B,SAAQ,SAAS;IACxD,OAAO,CAAC,SAAS,CAAO;gBAEZ,IAAI,EAAE,sBAAsB;IAMxC,kBAAkB,IAAI,eAAe;CAGtC"}
@@ -0,0 +1,19 @@
1
+ import { Box } from '@earendil-works/pi-tui';
2
+ import type { TUI } from '@earendil-works/pi-tui';
3
+ import type { BackgroundActivity } from '../background-activity.js';
4
+ export interface BackgroundActivitySelectorOptions {
5
+ tui: TUI;
6
+ activities: BackgroundActivity[];
7
+ getActivity: (taskId: string) => BackgroundActivity | undefined;
8
+ onCancel: () => void;
9
+ onAbort: (activity: BackgroundActivity) => void;
10
+ }
11
+ export declare class BackgroundActivitySelectorComponent extends Box {
12
+ focused: boolean;
13
+ private readonly list;
14
+ private readonly getActivity;
15
+ private readonly onAbort;
16
+ constructor(options: BackgroundActivitySelectorOptions);
17
+ handleInput(data: string): void;
18
+ }
19
+ //# sourceMappingURL=background-activity-selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background-activity-selector.d.ts","sourceRoot":"","sources":["../../../src/tui/components/background-activity-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAgB,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAA+B,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,MAAM,WAAW,iCAAiC;IAChD,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAChE,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACjD;AAED,qBAAa,mCAAoC,SAAQ,GAAG;IAC1D,OAAO,UAAS;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqD;IACjF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;gBAErD,OAAO,EAAE,iCAAiC;IA2CtD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAUhC"}
@@ -17,7 +17,7 @@ export interface VoiceInputHook {
17
17
  startRecording(): void;
18
18
  stopRecording(): void | Promise<void>;
19
19
  }
20
- export type AppAction = 'clear' | 'exit' | 'suspend' | 'undo' | 'toggleThinking' | 'expandTools' | 'followUp' | 'queueFollowUp' | 'cycleMode' | 'toggleYolo';
20
+ export type AppAction = 'clear' | 'exit' | 'suspend' | 'undo' | 'toggleThinking' | 'expandTools' | 'openBackgroundActivityCenter' | 'clearFinishedBackgroundActivities' | 'followUp' | 'queueFollowUp' | 'cycleMode' | 'toggleYolo';
21
21
  export declare class CustomEditor extends Editor {
22
22
  private actionHandlers;
23
23
  onCtrlD?: () => void;
@@ -61,6 +61,10 @@ export declare class CustomEditor extends Editor {
61
61
  private normalizePastedFilePath;
62
62
  private getImageMimeType;
63
63
  private handleExplicitPaste;
64
+ /**
65
+ * Accept the highlighted autocomplete item, repairing the leading slash that
66
+ * pi-tui's applyCompletion drops for namespaced commands like `skill/<name>`.
67
+ */
64
68
  private completeAutocompleteSelection;
65
69
  /**
66
70
  * Capture the cursor position where dictation begins so the dictated run can be
@@ -1 +1 @@
1
- {"version":3,"file":"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BAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMhD;;;;OAIG;IACI,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOjD;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAWtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,eAAe;IAqEvB;;;;OAIG;IACI,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAiBlD;;;;;;;;;OASG;IACH,OAAO,CAAC,qBAAqB;IA4C7B,OAAO,CAAC,oBAAoB;IAa5B,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAoJhC"}
@@ -0,0 +1,8 @@
1
+ import { Container } from '@earendil-works/pi-tui';
2
+ import type { BackgroundActivity } from '../background-activity.js';
3
+ export declare class GlobalBackgroundNoticeComponent extends Container {
4
+ private activities;
5
+ setActivities(activities: BackgroundActivity[]): void;
6
+ private rebuild;
7
+ }
8
+ //# sourceMappingURL=global-background-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-background-notice.d.ts","sourceRoot":"","sources":["../../../src/tui/components/global-background-notice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,qBAAa,+BAAgC,SAAQ,SAAS;IAC5D,OAAO,CAAC,UAAU,CAA4B;IAE9C,aAAa,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAKrD,OAAO,CAAC,OAAO;CAuBhB"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Account manager component for providers with registered accounts —
3
+ * opened by /login on an already-connected provider.
4
+ *
5
+ * Lists the provider's accounts (label + active marker) plus
6
+ * Add another account / Back. Selecting an account opens a submenu for
7
+ * it: Set as active / Re-authenticate… / Remove… / Back.
8
+ */
9
+ import { Box } from '@earendil-works/pi-tui';
10
+ export interface ManagedAccount {
11
+ id: string;
12
+ label: string;
13
+ active: boolean;
14
+ }
15
+ export interface LoginAccountManagerCallbacks {
16
+ onAddAnother(): void;
17
+ onReauthenticate(accountId: string): void;
18
+ onRemove(accountId: string): void;
19
+ onActivate(accountId: string): void;
20
+ onBack(): void;
21
+ }
22
+ export declare class LoginAccountManagerComponent extends Box {
23
+ private listContainer;
24
+ private mode;
25
+ private accounts;
26
+ private selectedIndex;
27
+ private callbacks;
28
+ private selectedAccount?;
29
+ private confirmTarget?;
30
+ private readonly providerName;
31
+ constructor(providerName: string, accounts: ManagedAccount[], callbacks: LoginAccountManagerCallbacks);
32
+ /** Accounts may have changed (e.g. after an in-place re-auth); refresh rows. */
33
+ setAccounts(accounts: ManagedAccount[]): void;
34
+ private rows;
35
+ private backToMenu;
36
+ private updateList;
37
+ handleInput(keyData: string): void;
38
+ }
39
+ //# sourceMappingURL=login-account-manager.d.ts.map