mastracode 0.42.2-alpha.0 → 0.42.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +15 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +16 -10
- package/dist/cli.js.map +1 -1
- package/dist/tui/commands/browser.d.ts.map +1 -1
- package/dist/tui/commands/settings.d.ts.map +1 -1
- package/dist/tui/components/notification-summary.d.ts +6 -0
- package/dist/tui/components/notification-summary.d.ts.map +1 -1
- package/dist/tui/components/notification.d.ts +8 -0
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/tool-execution-enhanced.d.ts +13 -0
- package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/quiet-mode.d.ts +9 -0
- package/dist/tui/quiet-mode.d.ts.map +1 -0
- package/dist/tui/render-messages.d.ts.map +1 -1
- package/dist/{tui-BS1IUTkx.js → tui-BNnzmiap.js} +187 -51
- package/dist/tui-BNnzmiap.js.map +1 -0
- package/dist/{tui-C79dD8X3.cjs → tui-CJ1G5lRF.cjs} +186 -50
- package/dist/tui-CJ1G5lRF.cjs.map +1 -0
- package/dist/tui.cjs +1 -1
- package/dist/tui.js +1 -1
- package/package.json +10 -10
- package/dist/tui-BS1IUTkx.js.map +0 -1
- package/dist/tui-C79dD8X3.cjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_tui = require("./tui-
|
|
2
|
+
const require_tui = require("./tui-CJ1G5lRF.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);
|
|
@@ -112,7 +112,7 @@ function resolveTuiSubagents(enabled) {
|
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/version.ts
|
|
114
114
|
function getCurrentVersion() {
|
|
115
|
-
return "0.42.2-alpha.
|
|
115
|
+
return "0.42.2-alpha.1";
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/main.ts
|
|
@@ -161,8 +161,8 @@ async function tuiMain(startupMessage = {}) {
|
|
|
161
161
|
console.info(`⚠ ${warning}`);
|
|
162
162
|
});
|
|
163
163
|
let browserPromise;
|
|
164
|
-
const loadBrowser = () => {
|
|
165
|
-
browserPromise ??= (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(settings.browser);
|
|
164
|
+
const loadBrowser = (chatModelId) => {
|
|
165
|
+
browserPromise ??= (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(settings.browser, { chatModelId });
|
|
166
166
|
return browserPromise;
|
|
167
167
|
};
|
|
168
168
|
const initialState = resolveInitialStateFromEnv();
|
|
@@ -231,11 +231,17 @@ async function tuiMain(startupMessage = {}) {
|
|
|
231
231
|
tui.run().catch((error) => {
|
|
232
232
|
handleFatalError(error);
|
|
233
233
|
});
|
|
234
|
-
if (settings.browser.enabled)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
if (settings.browser.enabled) {
|
|
235
|
+
const chatModelId = session.model.get();
|
|
236
|
+
loadBrowser(chatModelId).then((browser) => {
|
|
237
|
+
if (!browser) return;
|
|
238
|
+
controller.setBrowser(browser);
|
|
239
|
+
session.state.set({
|
|
240
|
+
activeBrowserSettings: (0, _mastra_code_sdk_onboarding_settings.toActiveBrowserSettings)(settings.browser),
|
|
241
|
+
activeBrowserModel: (0, _mastra_code_sdk_onboarding_settings.resolveStagehandModel)(settings.browser, { chatModelId })
|
|
242
|
+
}).catch(() => {});
|
|
243
|
+
}).catch(() => {});
|
|
244
|
+
}
|
|
239
245
|
}
|
|
240
246
|
const asyncCleanup = () => {
|
|
241
247
|
cleanupPromise ??= (async () => {
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["createProcessMemoryDiagnosticsFromEnvironment","TUI_CO_AUTHOR","detectTerminalTheme","MastraTUI"],"sources":["../src/initial-prompt.ts","../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["export const INITIAL_PROMPT_FLAG = '--tui-initial-prompt' as const;\nexport const INITIAL_PROMPT_ENV = 'MASTRACODE_TUI_INITIAL_PROMPT';\n\nexport const TUI_PROMPT_FLAG = '--tui-prompt' as const;\n\nexport type InitialPromptArgs = {\n /** argv with the flag and its value removed, so headless detection never mistakes the value for a prompt. */\n argv: string[];\n prompt?: string;\n /** Set when a flag was passed without a value, or both flags were passed. */\n error?: string;\n /** The flag the prompt came from; undefined when it came from the environment. */\n flag?: typeof INITIAL_PROMPT_FLAG | typeof TUI_PROMPT_FLAG;\n /**\n * `--tui-prompt` sends even when startup resumes an existing conversation;\n * `--tui-initial-prompt` and the environment variable only start a new one.\n */\n sendOnResume: boolean;\n};\n\n/**\n * Takes the interactive startup prompt from `--tui-initial-prompt <text>` or\n * `--tui-prompt <text>` (also `--flag=<text>`), falling back to\n * `MASTRACODE_TUI_INITIAL_PROMPT`.\n *\n * The environment variable is always removed from `env`: everything this\n * process spawns inherits its environment, and a nested Mastra Code (or any\n * shell the agent starts) must not send the same prompt again.\n */\nexport function takeInitialPrompt(argv: string[], env: NodeJS.ProcessEnv): InitialPromptArgs {\n const fromEnv = env[INITIAL_PROMPT_ENV];\n delete env[INITIAL_PROMPT_ENV];\n\n const rest: string[] = [];\n const found = new Map<NonNullable<InitialPromptArgs['flag']>, string>();\n let error: string | undefined;\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n const flag = [INITIAL_PROMPT_FLAG, TUI_PROMPT_FLAG].find(f => arg === f || arg.startsWith(`${f}=`));\n if (!flag) {\n rest.push(arg);\n } else if (arg !== flag) {\n found.set(flag, arg.slice(flag.length + 1));\n } else if (argv[i + 1] === undefined) {\n error = `${flag} needs a value`;\n } else {\n found.set(flag, argv[++i]!);\n }\n }\n if (found.size > 1) error = `Use either ${INITIAL_PROMPT_FLAG} or ${TUI_PROMPT_FLAG}, not both`;\n\n const [flag, flagValue] = [...found][0] ?? [];\n const prompt = (flag ? flagValue : fromEnv)?.trim() || undefined;\n return { argv: rest, prompt, error, flag, sendOnResume: flag === TUI_PROMPT_FLAG };\n}\n\n/** The first message the TUI sends: the initial prompt, followed by any piped stdin. */\nexport function composeInitialMessage(prompt: string | undefined, pipedInput: string | null | undefined) {\n const piped = pipedInput ? `The following was piped via stdin:\\n\\n${pipedInput}` : undefined;\n if (prompt && piped) return `${prompt}\\n\\n${piped}`;\n return prompt ?? piped;\n}\n\n/**\n * Why a startup prompt can't be combined with piped stdin, if it can't.\n *\n * The first message is submitted like typed input, so a prompt starting with\n * `/` or `!` is dispatched as a command. Folding piped text into it would make\n * that text part of the command — skill arguments, or a shell script for `!`.\n */\nexport function pipedInputConflict(\n args: Pick<InitialPromptArgs, 'prompt' | 'flag'>,\n pipedInput: string | null | undefined,\n): string | undefined {\n if (!args.prompt || !pipedInput) return undefined;\n if (!args.prompt.startsWith('/') && !args.prompt.startsWith('!')) return undefined;\n const source = args.flag ?? INITIAL_PROMPT_ENV;\n return `${source} can't be combined with piped stdin when it is a slash command or starts with !`;\n}\n\n/** The TUI options for a startup prompt and/or piped stdin. */\nexport function initialMessageOptions(\n args: Pick<InitialPromptArgs, 'prompt' | 'sendOnResume'>,\n pipedInput?: string | null,\n): { initialMessage?: string; resumeSkipNotice?: string } {\n const initialMessage = composeInitialMessage(args.prompt, pipedInput);\n if (!initialMessage) return {};\n // Piped stdin on its own is always sent, as before.\n if (!args.prompt || args.sendOnResume) return { initialMessage };\n const skipped = pipedInput ? 'the initial prompt and piped input were' : 'the initial prompt was';\n return {\n initialMessage,\n resumeSkipNotice: `Resumed the existing conversation for this directory, so ${skipped} not sent. Use ${TUI_PROMPT_FLAG} to send ${pipedInput ? 'them' : 'it'} anyway.`,\n };\n}\n","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 { initialMessageOptions, pipedInputConflict, takeInitialPrompt } from './initial-prompt.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(startupMessage: ReturnType<typeof initialMessageOptions> = {}) {\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 ...startupMessage,\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 const initialPrompt = takeInitialPrompt(process.argv, process.env);\n if (initialPrompt.error) {\n process.stderr.write(`${initialPrompt.error}\\n`);\n process.exit(1);\n }\n if (initialPrompt.flag) process.argv = initialPrompt.argv;\n // The flag only means something to the interactive TUI. Paths that can't run\n // it reject the flag instead of dropping the prompt; an env var prompt is\n // just ignored there.\n const rejectInitialPromptFlag = (reason: string) => {\n if (!initialPrompt.flag) return;\n process.stderr.write(`${initialPrompt.flag} starts the interactive TUI; ${reason}\\n`);\n process.exit(1);\n };\n\n const headless = hasHeadlessFlag(process.argv);\n if (headless) rejectInitialPromptFlag('use --prompt for headless runs');\n if (headless || 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 rejectInitialPromptFlag('it cannot be combined with --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 rejectInitialPromptFlag('no TTY is available, so use --prompt for headless runs');\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 const conflict = pipedInputConflict(initialPrompt, pipedInput);\n if (conflict) {\n process.stderr.write(`${conflict}\\n`);\n process.exit(1);\n }\n\n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MAAM,WAAW,mBAAmB,eAAe,UAAU;CAC7D,IAAI,UAAU;EACZ,QAAQ,OAAO,MAAM,GAAG,SAAS,GAAG;EACpC,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO,QAAQ,sBAAsB,eAAe,UAAU,CAAC;AACjE;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/initial-prompt.ts","../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["export const INITIAL_PROMPT_FLAG = '--tui-initial-prompt' as const;\nexport const INITIAL_PROMPT_ENV = 'MASTRACODE_TUI_INITIAL_PROMPT';\n\nexport const TUI_PROMPT_FLAG = '--tui-prompt' as const;\n\nexport type InitialPromptArgs = {\n /** argv with the flag and its value removed, so headless detection never mistakes the value for a prompt. */\n argv: string[];\n prompt?: string;\n /** Set when a flag was passed without a value, or both flags were passed. */\n error?: string;\n /** The flag the prompt came from; undefined when it came from the environment. */\n flag?: typeof INITIAL_PROMPT_FLAG | typeof TUI_PROMPT_FLAG;\n /**\n * `--tui-prompt` sends even when startup resumes an existing conversation;\n * `--tui-initial-prompt` and the environment variable only start a new one.\n */\n sendOnResume: boolean;\n};\n\n/**\n * Takes the interactive startup prompt from `--tui-initial-prompt <text>` or\n * `--tui-prompt <text>` (also `--flag=<text>`), falling back to\n * `MASTRACODE_TUI_INITIAL_PROMPT`.\n *\n * The environment variable is always removed from `env`: everything this\n * process spawns inherits its environment, and a nested Mastra Code (or any\n * shell the agent starts) must not send the same prompt again.\n */\nexport function takeInitialPrompt(argv: string[], env: NodeJS.ProcessEnv): InitialPromptArgs {\n const fromEnv = env[INITIAL_PROMPT_ENV];\n delete env[INITIAL_PROMPT_ENV];\n\n const rest: string[] = [];\n const found = new Map<NonNullable<InitialPromptArgs['flag']>, string>();\n let error: string | undefined;\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n const flag = [INITIAL_PROMPT_FLAG, TUI_PROMPT_FLAG].find(f => arg === f || arg.startsWith(`${f}=`));\n if (!flag) {\n rest.push(arg);\n } else if (arg !== flag) {\n found.set(flag, arg.slice(flag.length + 1));\n } else if (argv[i + 1] === undefined) {\n error = `${flag} needs a value`;\n } else {\n found.set(flag, argv[++i]!);\n }\n }\n if (found.size > 1) error = `Use either ${INITIAL_PROMPT_FLAG} or ${TUI_PROMPT_FLAG}, not both`;\n\n const [flag, flagValue] = [...found][0] ?? [];\n const prompt = (flag ? flagValue : fromEnv)?.trim() || undefined;\n return { argv: rest, prompt, error, flag, sendOnResume: flag === TUI_PROMPT_FLAG };\n}\n\n/** The first message the TUI sends: the initial prompt, followed by any piped stdin. */\nexport function composeInitialMessage(prompt: string | undefined, pipedInput: string | null | undefined) {\n const piped = pipedInput ? `The following was piped via stdin:\\n\\n${pipedInput}` : undefined;\n if (prompt && piped) return `${prompt}\\n\\n${piped}`;\n return prompt ?? piped;\n}\n\n/**\n * Why a startup prompt can't be combined with piped stdin, if it can't.\n *\n * The first message is submitted like typed input, so a prompt starting with\n * `/` or `!` is dispatched as a command. Folding piped text into it would make\n * that text part of the command — skill arguments, or a shell script for `!`.\n */\nexport function pipedInputConflict(\n args: Pick<InitialPromptArgs, 'prompt' | 'flag'>,\n pipedInput: string | null | undefined,\n): string | undefined {\n if (!args.prompt || !pipedInput) return undefined;\n if (!args.prompt.startsWith('/') && !args.prompt.startsWith('!')) return undefined;\n const source = args.flag ?? INITIAL_PROMPT_ENV;\n return `${source} can't be combined with piped stdin when it is a slash command or starts with !`;\n}\n\n/** The TUI options for a startup prompt and/or piped stdin. */\nexport function initialMessageOptions(\n args: Pick<InitialPromptArgs, 'prompt' | 'sendOnResume'>,\n pipedInput?: string | null,\n): { initialMessage?: string; resumeSkipNotice?: string } {\n const initialMessage = composeInitialMessage(args.prompt, pipedInput);\n if (!initialMessage) return {};\n // Piped stdin on its own is always sent, as before.\n if (!args.prompt || args.sendOnResume) return { initialMessage };\n const skipped = pipedInput ? 'the initial prompt and piped input were' : 'the initial prompt was';\n return {\n initialMessage,\n resumeSkipNotice: `Resumed the existing conversation for this directory, so ${skipped} not sent. Use ${TUI_PROMPT_FLAG} to send ${pipedInput ? 'them' : 'it'} anyway.`,\n };\n}\n","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 {\n createBrowserFromSettings,\n loadSettings,\n resolveStagehandModel,\n toActiveBrowserSettings,\n} 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 { initialMessageOptions, pipedInputConflict, takeInitialPrompt } from './initial-prompt.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(startupMessage: ReturnType<typeof initialMessageOptions> = {}) {\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 = (chatModelId: string | undefined) => {\n browserPromise ??= createBrowserFromSettings(settings.browser, { chatModelId });\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 ...startupMessage,\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n // Captured once: the Stagehand instance is fixed at launch and shared by every thread.\n const chatModelId = session.model.get();\n void loadBrowser(chatModelId)\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state\n .set({\n activeBrowserSettings: toActiveBrowserSettings(settings.browser),\n activeBrowserModel: resolveStagehandModel(settings.browser, { chatModelId }),\n } as any)\n .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 const initialPrompt = takeInitialPrompt(process.argv, process.env);\n if (initialPrompt.error) {\n process.stderr.write(`${initialPrompt.error}\\n`);\n process.exit(1);\n }\n if (initialPrompt.flag) process.argv = initialPrompt.argv;\n // The flag only means something to the interactive TUI. Paths that can't run\n // it reject the flag instead of dropping the prompt; an env var prompt is\n // just ignored there.\n const rejectInitialPromptFlag = (reason: string) => {\n if (!initialPrompt.flag) return;\n process.stderr.write(`${initialPrompt.flag} starts the interactive TUI; ${reason}\\n`);\n process.exit(1);\n };\n\n const headless = hasHeadlessFlag(process.argv);\n if (headless) rejectInitialPromptFlag('use --prompt for headless runs');\n if (headless || 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 rejectInitialPromptFlag('it cannot be combined with --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 rejectInitialPromptFlag('no TTY is available, so use --prompt for headless runs');\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 const conflict = pipedInputConflict(initialPrompt, pipedInput);\n if (conflict) {\n process.stderr.write(`${conflict}\\n`);\n process.exit(1);\n }\n\n return tuiMain(initialMessageOptions(initialPrompt, pipedInput));\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAAA,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAElC,MAAa,kBAAkB;;;;;;;;;;AA0B/B,SAAgB,kBAAkB,MAAgB,KAA2C;CAC3F,MAAM,UAAU,IAAI;CACpB,OAAO,IAAI;CAEX,MAAM,OAAiB,CAAC;CACxB,MAAM,wBAAQ,IAAI,IAAoD;CACtE,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,MAAM,OAAO,CAAC,qBAAqB,eAAe,CAAC,CAAC,MAAK,MAAK,QAAQ,KAAK,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;EAClG,IAAI,CAAC,MACH,KAAK,KAAK,GAAG;OACR,IAAI,QAAQ,MACjB,MAAM,IAAI,MAAM,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC;OACrC,IAAI,KAAK,IAAI,OAAO,KAAA,GACzB,QAAQ,GAAG,KAAK;OAEhB,MAAM,IAAI,MAAM,KAAK,EAAE,EAAG;CAE9B;CACA,IAAI,MAAM,OAAO,GAAG,QAAQ,cAAc,oBAAoB,MAA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AAA,gCAAA,SAAA,CAAgB,KAAA,GAAW,EAAE,UAAUF,YAAAA,cAAc,CAAC;CAGxD,IAAI,QAAQ,KAAK,SAAS,OAAO,GAAG;EAClC,wBAAwB,kCAAkC;EAC1D,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,wBAAwB,wDAAwD;GAChF,QAAQ,OAAO,MAAM,qDAAqD;GAC1E,QAAA,GAAA,gCAAA,SAAA,CAAgB,YAAY,EAAE,UAAUA,YAAAA,cAAc,CAAC;EACzD;CACF;CAEA,MAAM,WAAW,mBAAmB,eAAe,UAAU;CAC7D,IAAI,UAAU;EACZ,QAAQ,OAAO,MAAM,GAAG,SAAS,GAAG;EACpC,QAAQ,KAAK,CAAC;CAChB;CAEA,OAAO,QAAQ,sBAAsB,eAAe,UAAU,CAAC;AACjE;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
2
|
+
import { b as TUI_CO_AUTHOR, d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-BNnzmiap.js";
|
|
3
3
|
import { createMastraCode } from "@mastra/code-sdk";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import { createMastraCodeAnalytics } from "@mastra/code-sdk/analytics";
|
|
6
6
|
import { isStreamDestroyedError } from "@mastra/code-sdk/error-classification";
|
|
7
7
|
import { hasHeadlessFlag, runMCCli } from "@mastra/code-sdk/headless/index";
|
|
8
|
-
import { createBrowserFromSettings, loadSettings } from "@mastra/code-sdk/onboarding/settings";
|
|
8
|
+
import { createBrowserFromSettings, loadSettings, resolveStagehandModel, toActiveBrowserSettings } from "@mastra/code-sdk/onboarding/settings";
|
|
9
9
|
import { formatScaffoldSuccess, scaffoldPlugin } from "@mastra/code-sdk/plugins/scaffold";
|
|
10
10
|
import { createProcessMemoryDiagnosticsFromEnvironment, startConfiguredProcessMemoryDiagnostics, stopProcessMemoryDiagnosticsWithTimeout } from "@mastra/code-sdk/process-memory-diagnostics";
|
|
11
11
|
import { setupDebugLogging, truncateLogFile } from "@mastra/code-sdk/utils/debug-log";
|
|
@@ -111,7 +111,7 @@ function resolveTuiSubagents(enabled) {
|
|
|
111
111
|
//#endregion
|
|
112
112
|
//#region src/version.ts
|
|
113
113
|
function getCurrentVersion() {
|
|
114
|
-
return "0.42.2-alpha.
|
|
114
|
+
return "0.42.2-alpha.1";
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/main.ts
|
|
@@ -160,8 +160,8 @@ async function tuiMain(startupMessage = {}) {
|
|
|
160
160
|
console.info(`⚠ ${warning}`);
|
|
161
161
|
});
|
|
162
162
|
let browserPromise;
|
|
163
|
-
const loadBrowser = () => {
|
|
164
|
-
browserPromise ??= createBrowserFromSettings(settings.browser);
|
|
163
|
+
const loadBrowser = (chatModelId) => {
|
|
164
|
+
browserPromise ??= createBrowserFromSettings(settings.browser, { chatModelId });
|
|
165
165
|
return browserPromise;
|
|
166
166
|
};
|
|
167
167
|
const initialState = resolveInitialStateFromEnv();
|
|
@@ -230,11 +230,17 @@ async function tuiMain(startupMessage = {}) {
|
|
|
230
230
|
tui.run().catch((error) => {
|
|
231
231
|
handleFatalError(error);
|
|
232
232
|
});
|
|
233
|
-
if (settings.browser.enabled)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
if (settings.browser.enabled) {
|
|
234
|
+
const chatModelId = session.model.get();
|
|
235
|
+
loadBrowser(chatModelId).then((browser) => {
|
|
236
|
+
if (!browser) return;
|
|
237
|
+
controller.setBrowser(browser);
|
|
238
|
+
session.state.set({
|
|
239
|
+
activeBrowserSettings: toActiveBrowserSettings(settings.browser),
|
|
240
|
+
activeBrowserModel: resolveStagehandModel(settings.browser, { chatModelId })
|
|
241
|
+
}).catch(() => {});
|
|
242
|
+
}).catch(() => {});
|
|
243
|
+
}
|
|
238
244
|
}
|
|
239
245
|
const asyncCleanup = () => {
|
|
240
246
|
cleanupPromise ??= (async () => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/initial-prompt.ts","../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["export const INITIAL_PROMPT_FLAG = '--tui-initial-prompt' as const;\nexport const INITIAL_PROMPT_ENV = 'MASTRACODE_TUI_INITIAL_PROMPT';\n\nexport const TUI_PROMPT_FLAG = '--tui-prompt' as const;\n\nexport type InitialPromptArgs = {\n /** argv with the flag and its value removed, so headless detection never mistakes the value for a prompt. */\n argv: string[];\n prompt?: string;\n /** Set when a flag was passed without a value, or both flags were passed. */\n error?: string;\n /** The flag the prompt came from; undefined when it came from the environment. */\n flag?: typeof INITIAL_PROMPT_FLAG | typeof TUI_PROMPT_FLAG;\n /**\n * `--tui-prompt` sends even when startup resumes an existing conversation;\n * `--tui-initial-prompt` and the environment variable only start a new one.\n */\n sendOnResume: boolean;\n};\n\n/**\n * Takes the interactive startup prompt from `--tui-initial-prompt <text>` or\n * `--tui-prompt <text>` (also `--flag=<text>`), falling back to\n * `MASTRACODE_TUI_INITIAL_PROMPT`.\n *\n * The environment variable is always removed from `env`: everything this\n * process spawns inherits its environment, and a nested Mastra Code (or any\n * shell the agent starts) must not send the same prompt again.\n */\nexport function takeInitialPrompt(argv: string[], env: NodeJS.ProcessEnv): InitialPromptArgs {\n const fromEnv = env[INITIAL_PROMPT_ENV];\n delete env[INITIAL_PROMPT_ENV];\n\n const rest: string[] = [];\n const found = new Map<NonNullable<InitialPromptArgs['flag']>, string>();\n let error: string | undefined;\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n const flag = [INITIAL_PROMPT_FLAG, TUI_PROMPT_FLAG].find(f => arg === f || arg.startsWith(`${f}=`));\n if (!flag) {\n rest.push(arg);\n } else if (arg !== flag) {\n found.set(flag, arg.slice(flag.length + 1));\n } else if (argv[i + 1] === undefined) {\n error = `${flag} needs a value`;\n } else {\n found.set(flag, argv[++i]!);\n }\n }\n if (found.size > 1) error = `Use either ${INITIAL_PROMPT_FLAG} or ${TUI_PROMPT_FLAG}, not both`;\n\n const [flag, flagValue] = [...found][0] ?? [];\n const prompt = (flag ? flagValue : fromEnv)?.trim() || undefined;\n return { argv: rest, prompt, error, flag, sendOnResume: flag === TUI_PROMPT_FLAG };\n}\n\n/** The first message the TUI sends: the initial prompt, followed by any piped stdin. */\nexport function composeInitialMessage(prompt: string | undefined, pipedInput: string | null | undefined) {\n const piped = pipedInput ? `The following was piped via stdin:\\n\\n${pipedInput}` : undefined;\n if (prompt && piped) return `${prompt}\\n\\n${piped}`;\n return prompt ?? piped;\n}\n\n/**\n * Why a startup prompt can't be combined with piped stdin, if it can't.\n *\n * The first message is submitted like typed input, so a prompt starting with\n * `/` or `!` is dispatched as a command. Folding piped text into it would make\n * that text part of the command — skill arguments, or a shell script for `!`.\n */\nexport function pipedInputConflict(\n args: Pick<InitialPromptArgs, 'prompt' | 'flag'>,\n pipedInput: string | null | undefined,\n): string | undefined {\n if (!args.prompt || !pipedInput) return undefined;\n if (!args.prompt.startsWith('/') && !args.prompt.startsWith('!')) return undefined;\n const source = args.flag ?? INITIAL_PROMPT_ENV;\n return `${source} can't be combined with piped stdin when it is a slash command or starts with !`;\n}\n\n/** The TUI options for a startup prompt and/or piped stdin. */\nexport function initialMessageOptions(\n args: Pick<InitialPromptArgs, 'prompt' | 'sendOnResume'>,\n pipedInput?: string | null,\n): { initialMessage?: string; resumeSkipNotice?: string } {\n const initialMessage = composeInitialMessage(args.prompt, pipedInput);\n if (!initialMessage) return {};\n // Piped stdin on its own is always sent, as before.\n if (!args.prompt || args.sendOnResume) return { initialMessage };\n const skipped = pipedInput ? 'the initial prompt and piped input were' : 'the initial prompt was';\n return {\n initialMessage,\n resumeSkipNotice: `Resumed the existing conversation for this directory, so ${skipped} not sent. Use ${TUI_PROMPT_FLAG} to send ${pipedInput ? 'them' : 'it'} anyway.`,\n };\n}\n","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 { initialMessageOptions, pipedInputConflict, takeInitialPrompt } from './initial-prompt.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(startupMessage: ReturnType<typeof initialMessageOptions> = {}) {\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 ...startupMessage,\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 const initialPrompt = takeInitialPrompt(process.argv, process.env);\n if (initialPrompt.error) {\n process.stderr.write(`${initialPrompt.error}\\n`);\n process.exit(1);\n }\n if (initialPrompt.flag) process.argv = initialPrompt.argv;\n // The flag only means something to the interactive TUI. Paths that can't run\n // it reject the flag instead of dropping the prompt; an env var prompt is\n // just ignored there.\n const rejectInitialPromptFlag = (reason: string) => {\n if (!initialPrompt.flag) return;\n process.stderr.write(`${initialPrompt.flag} starts the interactive TUI; ${reason}\\n`);\n process.exit(1);\n };\n\n const headless = hasHeadlessFlag(process.argv);\n if (headless) rejectInitialPromptFlag('use --prompt for headless runs');\n if (headless || 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 rejectInitialPromptFlag('it cannot be combined with --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 rejectInitialPromptFlag('no TTY is available, so use --prompt for headless runs');\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 const conflict = pipedInputConflict(initialPrompt, pipedInput);\n if (conflict) {\n process.stderr.write(`${conflict}\\n`);\n process.exit(1);\n }\n\n return tuiMain(initialMessageOptions(initialPrompt, pipedInput));\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAElC,MAAa,kBAAkB;;;;;;;;;;AA0B/B,SAAgB,kBAAkB,MAAgB,KAA2C;CAC3F,MAAM,UAAU,IAAI;CACpB,OAAO,IAAI;CAEX,MAAM,OAAiB,CAAC;CACxB,MAAM,wBAAQ,IAAI,IAAoD;CACtE,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,MAAM,OAAO,CAAC,qBAAqB,eAAe,CAAC,CAAC,MAAK,MAAK,QAAQ,KAAK,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;EAClG,IAAI,CAAC,MACH,KAAK,KAAK,GAAG;OACR,IAAI,QAAQ,MACjB,MAAM,IAAI,MAAM,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC;OACrC,IAAI,KAAK,IAAI,OAAO,KAAA,GACzB,QAAQ,GAAG,KAAK;OAEhB,MAAM,IAAI,MAAM,KAAK,EAAE,EAAG;CAE9B;CACA,IAAI,MAAM,OAAO,GAAG,QAAQ,cAAc,oBAAoB,MA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KAAK,CAAC;CAChB;CAEA,OAAO,QAAQ,sBAAsB,eAAe,UAAU,CAAC;AACjE;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/initial-prompt.ts","../src/process-memory-diagnostics-lifecycle.ts","../src/subagent-settings.ts","../src/version.ts","../src/main.ts"],"sourcesContent":["export const INITIAL_PROMPT_FLAG = '--tui-initial-prompt' as const;\nexport const INITIAL_PROMPT_ENV = 'MASTRACODE_TUI_INITIAL_PROMPT';\n\nexport const TUI_PROMPT_FLAG = '--tui-prompt' as const;\n\nexport type InitialPromptArgs = {\n /** argv with the flag and its value removed, so headless detection never mistakes the value for a prompt. */\n argv: string[];\n prompt?: string;\n /** Set when a flag was passed without a value, or both flags were passed. */\n error?: string;\n /** The flag the prompt came from; undefined when it came from the environment. */\n flag?: typeof INITIAL_PROMPT_FLAG | typeof TUI_PROMPT_FLAG;\n /**\n * `--tui-prompt` sends even when startup resumes an existing conversation;\n * `--tui-initial-prompt` and the environment variable only start a new one.\n */\n sendOnResume: boolean;\n};\n\n/**\n * Takes the interactive startup prompt from `--tui-initial-prompt <text>` or\n * `--tui-prompt <text>` (also `--flag=<text>`), falling back to\n * `MASTRACODE_TUI_INITIAL_PROMPT`.\n *\n * The environment variable is always removed from `env`: everything this\n * process spawns inherits its environment, and a nested Mastra Code (or any\n * shell the agent starts) must not send the same prompt again.\n */\nexport function takeInitialPrompt(argv: string[], env: NodeJS.ProcessEnv): InitialPromptArgs {\n const fromEnv = env[INITIAL_PROMPT_ENV];\n delete env[INITIAL_PROMPT_ENV];\n\n const rest: string[] = [];\n const found = new Map<NonNullable<InitialPromptArgs['flag']>, string>();\n let error: string | undefined;\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n const flag = [INITIAL_PROMPT_FLAG, TUI_PROMPT_FLAG].find(f => arg === f || arg.startsWith(`${f}=`));\n if (!flag) {\n rest.push(arg);\n } else if (arg !== flag) {\n found.set(flag, arg.slice(flag.length + 1));\n } else if (argv[i + 1] === undefined) {\n error = `${flag} needs a value`;\n } else {\n found.set(flag, argv[++i]!);\n }\n }\n if (found.size > 1) error = `Use either ${INITIAL_PROMPT_FLAG} or ${TUI_PROMPT_FLAG}, not both`;\n\n const [flag, flagValue] = [...found][0] ?? [];\n const prompt = (flag ? flagValue : fromEnv)?.trim() || undefined;\n return { argv: rest, prompt, error, flag, sendOnResume: flag === TUI_PROMPT_FLAG };\n}\n\n/** The first message the TUI sends: the initial prompt, followed by any piped stdin. */\nexport function composeInitialMessage(prompt: string | undefined, pipedInput: string | null | undefined) {\n const piped = pipedInput ? `The following was piped via stdin:\\n\\n${pipedInput}` : undefined;\n if (prompt && piped) return `${prompt}\\n\\n${piped}`;\n return prompt ?? piped;\n}\n\n/**\n * Why a startup prompt can't be combined with piped stdin, if it can't.\n *\n * The first message is submitted like typed input, so a prompt starting with\n * `/` or `!` is dispatched as a command. Folding piped text into it would make\n * that text part of the command — skill arguments, or a shell script for `!`.\n */\nexport function pipedInputConflict(\n args: Pick<InitialPromptArgs, 'prompt' | 'flag'>,\n pipedInput: string | null | undefined,\n): string | undefined {\n if (!args.prompt || !pipedInput) return undefined;\n if (!args.prompt.startsWith('/') && !args.prompt.startsWith('!')) return undefined;\n const source = args.flag ?? INITIAL_PROMPT_ENV;\n return `${source} can't be combined with piped stdin when it is a slash command or starts with !`;\n}\n\n/** The TUI options for a startup prompt and/or piped stdin. */\nexport function initialMessageOptions(\n args: Pick<InitialPromptArgs, 'prompt' | 'sendOnResume'>,\n pipedInput?: string | null,\n): { initialMessage?: string; resumeSkipNotice?: string } {\n const initialMessage = composeInitialMessage(args.prompt, pipedInput);\n if (!initialMessage) return {};\n // Piped stdin on its own is always sent, as before.\n if (!args.prompt || args.sendOnResume) return { initialMessage };\n const skipped = pipedInput ? 'the initial prompt and piped input were' : 'the initial prompt was';\n return {\n initialMessage,\n resumeSkipNotice: `Resumed the existing conversation for this directory, so ${skipped} not sent. Use ${TUI_PROMPT_FLAG} to send ${pipedInput ? 'them' : 'it'} anyway.`,\n };\n}\n","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 {\n createBrowserFromSettings,\n loadSettings,\n resolveStagehandModel,\n toActiveBrowserSettings,\n} 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 { initialMessageOptions, pipedInputConflict, takeInitialPrompt } from './initial-prompt.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(startupMessage: ReturnType<typeof initialMessageOptions> = {}) {\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 = (chatModelId: string | undefined) => {\n browserPromise ??= createBrowserFromSettings(settings.browser, { chatModelId });\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 ...startupMessage,\n });\n tui.run().catch(error => {\n handleFatalError(error);\n });\n\n if (settings.browser.enabled) {\n // Captured once: the Stagehand instance is fixed at launch and shared by every thread.\n const chatModelId = session.model.get();\n void loadBrowser(chatModelId)\n .then(browser => {\n if (!browser) return;\n controller.setBrowser(browser);\n void session.state\n .set({\n activeBrowserSettings: toActiveBrowserSettings(settings.browser),\n activeBrowserModel: resolveStagehandModel(settings.browser, { chatModelId }),\n } as any)\n .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 const initialPrompt = takeInitialPrompt(process.argv, process.env);\n if (initialPrompt.error) {\n process.stderr.write(`${initialPrompt.error}\\n`);\n process.exit(1);\n }\n if (initialPrompt.flag) process.argv = initialPrompt.argv;\n // The flag only means something to the interactive TUI. Paths that can't run\n // it reject the flag instead of dropping the prompt; an env var prompt is\n // just ignored there.\n const rejectInitialPromptFlag = (reason: string) => {\n if (!initialPrompt.flag) return;\n process.stderr.write(`${initialPrompt.flag} starts the interactive TUI; ${reason}\\n`);\n process.exit(1);\n };\n\n const headless = hasHeadlessFlag(process.argv);\n if (headless) rejectInitialPromptFlag('use --prompt for headless runs');\n if (headless || 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 rejectInitialPromptFlag('it cannot be combined with --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 rejectInitialPromptFlag('no TTY is available, so use --prompt for headless runs');\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 const conflict = pipedInputConflict(initialPrompt, pipedInput);\n if (conflict) {\n process.stderr.write(`${conflict}\\n`);\n process.exit(1);\n }\n\n return tuiMain(initialMessageOptions(initialPrompt, pipedInput));\n}\n\nmain().catch(error => {\n handleFatalError(error);\n});\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAElC,MAAa,kBAAkB;;;;;;;;;;AA0B/B,SAAgB,kBAAkB,MAAgB,KAA2C;CAC3F,MAAM,UAAU,IAAI;CACpB,OAAO,IAAI;CAEX,MAAM,OAAiB,CAAC;CACxB,MAAM,wBAAQ,IAAI,IAAoD;CACtE,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,MAAM,OAAO,CAAC,qBAAqB,eAAe,CAAC,CAAC,MAAK,MAAK,QAAQ,KAAK,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;EAClG,IAAI,CAAC,MACH,KAAK,KAAK,GAAG;OACR,IAAI,QAAQ,MACjB,MAAM,IAAI,MAAM,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC;OACrC,IAAI,KAAK,IAAI,OAAO,KAAA,GACzB,QAAQ,GAAG,KAAK;OAEhB,MAAM,IAAI,MAAM,KAAK,EAAE,EAAG;CAE9B;CACA,IAAI,MAAM,OAAO,GAAG,QAAQ,cAAc,oBAAoB,MAAM,gBAAgB;CAEpF,MAAM,CAAC,MAAM,aAAa,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC;CAE5C,OAAO;EAAE,MAAM;EAAM,SADL,OAAO,YAAY,QAAA,EAAU,KAAK,KAAK,KAAA;EAC1B;EAAO;E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AQ,sBAAsB,eAAe,UAAU,CAAC;AACjE;AAEA,KAAK,CAAC,CAAC,OAAM,UAAS;CACpB,iBAAiB,KAAK;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/browser.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAgVtD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAmpBvG"}
|
|
@@ -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;
|
|
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;AAuKtD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4HnF"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Container } from '@earendil-works/pi-tui';
|
|
2
2
|
import type { ChatSpacingKind } from './chat-spacing.js';
|
|
3
|
+
import type { QuietToolDisplayMode } from './tool-execution-interface.js';
|
|
3
4
|
export interface NotificationSummaryOptions {
|
|
4
5
|
message: string;
|
|
5
6
|
pending: number;
|
|
6
7
|
bySource: Record<string, number>;
|
|
8
|
+
quietDisplayMode?: QuietToolDisplayMode;
|
|
7
9
|
}
|
|
8
10
|
export declare class NotificationSummaryComponent extends Container {
|
|
11
|
+
private readonly options;
|
|
12
|
+
private quietDisplayMode;
|
|
9
13
|
constructor(options: NotificationSummaryOptions);
|
|
14
|
+
setQuietModeDisplay(mode: QuietToolDisplayMode): void;
|
|
15
|
+
private rebuild;
|
|
10
16
|
getChatSpacingKind(): ChatSpacingKind;
|
|
11
17
|
}
|
|
12
18
|
//# sourceMappingURL=notification-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-summary.d.ts","sourceRoot":"","sources":["../../../src/tui/components/notification-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"notification-summary.d.ts","sourceRoot":"","sources":["../../../src/tui/components/notification-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED,qBAAa,4BAA6B,SAAQ,SAAS;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,gBAAgB,CAAuB;gBAEnC,OAAO,EAAE,0BAA0B;IAO/C,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAMrD,OAAO,CAAC,OAAO;IAwBf,kBAAkB,IAAI,eAAe;CAGtC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChatSpacingKind } from './chat-spacing.js';
|
|
2
|
+
import type { QuietToolDisplayMode } from './tool-execution-interface.js';
|
|
2
3
|
import { WidthAwareContainer } from './width-aware-container.js';
|
|
3
4
|
export interface NotificationOptions {
|
|
4
5
|
message: string;
|
|
@@ -6,6 +7,8 @@ export interface NotificationOptions {
|
|
|
6
7
|
kind?: string;
|
|
7
8
|
priority?: string;
|
|
8
9
|
status?: string;
|
|
10
|
+
quietDisplayMode?: QuietToolDisplayMode;
|
|
11
|
+
quietPreviewLineLimit?: number;
|
|
9
12
|
backgroundCompletion?: {
|
|
10
13
|
taskId: string;
|
|
11
14
|
toolName?: string;
|
|
@@ -15,10 +18,15 @@ export interface NotificationOptions {
|
|
|
15
18
|
}
|
|
16
19
|
export declare class NotificationComponent extends WidthAwareContainer {
|
|
17
20
|
private readonly options;
|
|
21
|
+
private quietDisplayMode;
|
|
22
|
+
private quietPreviewLineLimit;
|
|
18
23
|
private expanded;
|
|
19
24
|
constructor(options: NotificationOptions);
|
|
25
|
+
setQuietModeDisplay(mode: QuietToolDisplayMode): void;
|
|
26
|
+
setQuietPreviewLineLimit(limit: number): void;
|
|
20
27
|
setExpanded(expanded: boolean): void;
|
|
21
28
|
protected rebuildForWidth(width: number): void;
|
|
29
|
+
private limitMessageLines;
|
|
22
30
|
getChatSpacingKind(): ChatSpacingKind;
|
|
23
31
|
}
|
|
24
32
|
//# sourceMappingURL=notification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../../src/tui/components/notification.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ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,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAO7C,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAKpC,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA6F9C,OAAO,CAAC,iBAAiB;IAWzB,kBAAkB,IAAI,eAAe;CAGtC"}
|
|
@@ -69,7 +69,20 @@ export declare class ToolExecutionComponentEnhanced extends WidthAwareContainer
|
|
|
69
69
|
private getCollapsedLineLimit;
|
|
70
70
|
private shouldShowLeadingPadding;
|
|
71
71
|
private addLeadingPadding;
|
|
72
|
+
/**
|
|
73
|
+
* Quiet shell output follows the same rule as every other tool's preview:
|
|
74
|
+
* `quietPreviewLineLimit` output lines (the tail, since that is where errors
|
|
75
|
+
* land), or none at all when the limit is 0. Expanding (ctrl+e) shows everything.
|
|
76
|
+
*/
|
|
72
77
|
private limitQuietShellLines;
|
|
78
|
+
/**
|
|
79
|
+
* The command is the shell tool's header, so at least one line always shows;
|
|
80
|
+
* the rest of a long command (heredocs, inline scripts) is capped like output.
|
|
81
|
+
*/
|
|
82
|
+
private limitQuietShellCommandLines;
|
|
83
|
+
/** A `⋯ (+1 line)` marker costs the same row as the line it hides, so just show the line. */
|
|
84
|
+
private fitsQuietLimit;
|
|
85
|
+
private quietHiddenLinesMarker;
|
|
73
86
|
/**
|
|
74
87
|
* Full clear-and-rebuild. Called when:
|
|
75
88
|
* - args change (updateArgs)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-execution-enhanced.d.ts","sourceRoot":"","sources":["../../../src/tui/components/tool-execution-enhanced.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AASlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACX,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AyB;YAezB,IAAI;YAmHJ,sBAAsB;IAKpC,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,6BAA6B;IAYrC,OAAO,CAAC,2BAA2B;YAQrB,wCAAwC;IAkBtD,OAAO,CAAC,uBAAuB;IAe/B,iEAAiE;IACjE,OAAO,CAAC,KAAK,CAAkC;IAE/C,OAAO,CAAC,eAAe;YAOT,WAAW;IAgEzB,OAAO,CAAC,+BAA+B;IAuCvC,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,cAAc;YAUR,mBAAmB;YAmCnB,4BAA4B;IAmC1C,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,0BAA0B;YAoBpB,eAAe;IAU7B,OAAO,CAAC,eAAe;YAKT,WAAW;YAeX,iBAAiB;IAqB/B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAuB/B,OAAO,CAAC,YAAY;IAgEpB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,iBAAiB;YA2BX,kBAAkB;IAQ1B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwE/C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;YAyGvB,qBAAqB;IAiGnC,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,2BAA2B;IAM7B,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC;IA0C5D;;;;;OAKG;YACW,cAAc;IA0C5B;;OAEG;YACW,gBAAgB;CA4D/B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TUIState } from './state.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pushes the current quiet-mode preference into every already-rendered component
|
|
4
|
+
* that renders differently in quiet mode: tool executions, notifications, and
|
|
5
|
+
* notification summaries. Both the onboarding prompt and the `/settings` overlay
|
|
6
|
+
* route through here so the two paths cannot drift.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyQuietModeToRenderedComponents(state: Pick<TUIState, 'allToolComponents'> & Partial<Pick<TUIState, 'messageComponentsById'>>, enabled: boolean, previewLineLimit: number, modeColor: string | undefined): void;
|
|
9
|
+
//# sourceMappingURL=quiet-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quiet-mode.d.ts","sourceRoot":"","sources":["../../src/tui/quiet-mode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC,EAC7F,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,IAAI,CAkBN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-messages.d.ts","sourceRoot":"","sources":["../../src/tui/render-messages.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA+C5E,OAAO,EAAE,gBAAgB,EAAsB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAwD5B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EA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