(config: Config, flags: GlobalFlags)
| 306 | 'mmx text repl --temperature 0.7 --max-tokens 8192', |
| 307 | ], |
| 308 | async run(config: Config, flags: GlobalFlags) { |
| 309 | if (!isInteractive({ nonInteractive: config.nonInteractive })) { |
| 310 | throw new CLIError( |
| 311 | 'The repl command requires an interactive terminal.', |
| 312 | ExitCode.USAGE, |
| 313 | 'mmx text repl', |
| 314 | ); |
| 315 | } |
| 316 | |
| 317 | if (!process.stdin.isTTY) { |
| 318 | throw new CLIError('The repl command requires a TTY.', ExitCode.USAGE); |
| 319 | } |
| 320 | |
| 321 | const dim = config.noColor ? '' : '\x1b[2m'; |
| 322 | const reset = config.noColor ? '' : '\x1b[0m'; |
| 323 | |
| 324 | // ---- Initialize state ---- |
| 325 | const state: ReplState = { |
| 326 | messages: [], |
| 327 | system: flags.system as string | undefined, |
| 328 | model: (flags.model as string) || config.defaultTextModel || 'MiniMax-M2.7', |
| 329 | maxTokens: (flags.maxTokens as number) ?? 4096, |
| 330 | temperature: flags.temperature !== undefined ? flags.temperature as number : undefined, |
| 331 | topP: flags.topP !== undefined ? flags.topP as number : undefined, |
| 332 | }; |
| 333 | |
| 334 | const bold = config.noColor ? '' : '\x1b[1m'; |
| 335 | |
| 336 | process.stdout.write(`\n${bold}MiniMax Chat REPL${reset}\n`); |
| 337 | process.stdout.write(`${dim}Model: ${state.model}${reset}\n`); |
| 338 | if (state.system) { |
| 339 | process.stdout.write(`${dim}System: ${state.system.slice(0, 80)}${state.system.length > 80 ? '...' : ''}${reset}\n`); |
| 340 | } |
| 341 | process.stdout.write(`${dim}Type / to see commands, /exit to quit.${reset}\n`); |
| 342 | |
| 343 | const stdin = process.stdin; |
| 344 | const stdout = process.stdout; |
| 345 | |
| 346 | if (typeof stdin.setRawMode === 'function') { |
| 347 | stdin.setRawMode(true); |
| 348 | } |
| 349 | stdin.resume(); |
| 350 | stdin.setEncoding('utf8'); |
| 351 | |
| 352 | let waitingForResponse = false; |
| 353 | let sigintCount = 0; |
| 354 | |
| 355 | // ---- Helper: send messages and stream response ---- |
| 356 | async function sendMessages(): Promise<void> { |
| 357 | if (state.messages.length === 0) { |
| 358 | stdout.write(`${dim}No messages to send. Type something first.${reset}\n`); |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | const body: ChatRequest = { |
| 363 | model: state.model, |
| 364 | messages: state.messages, |
| 365 | max_tokens: state.maxTokens, |
nothing calls this directly
no test coverage detected