feat(tui): display tool execution status in minimal TUI

TUI now creates a NativeAgent with tool registry/executor and uses
agent.process() for message handling. Tool calls display status lines
showing tool name, args, and success/error result. Falls back to
direct model client when agent is not configured.
This commit is contained in:
William Valentin
2026-02-05 17:53:00 -08:00
parent df92a9d95f
commit 5088f7a6be
2 changed files with 74 additions and 8 deletions
+14 -2
View File
@@ -2,6 +2,7 @@ import * as readline from 'node:readline';
import type { ManagedSession } from '../../session/index.js';
import type { ModelClient, TokenUsage } from '../../models/types.js';
import type { ModelRouter, ModelTier } from '../../models/router.js';
import type { NativeAgent } from '../../backends/native/agent.js';
import { parseCommand, getHelpText, resolveModelAlias, getCommandCompletions, getCommandTooltip, type Command } from './commands.js';
import { renderMarkdown } from './markdown.js';
import type { ModelConfig } from '../../config/schema.js';
@@ -32,6 +33,7 @@ export interface MinimalTuiConfig {
modelClient: ModelClient;
modelRouter?: ModelRouter;
systemPrompt: string;
agent?: NativeAgent;
onFullscreen?: () => void;
onTransfer?: (target: string) => void;
localProviders?: Record<string, ModelConfig>;
@@ -285,12 +287,22 @@ export class MinimalTui {
}
private async handleMessage(content: string): Promise<void> {
this.config.session.addMessage({ role: 'user', content });
// Print Flynn label before response
process.stdout.write(`\n${colors.orange}${colors.bold}Flynn:${colors.reset}\n`);
try {
// Use agent if available (supports tool loop)
if (this.config.agent) {
const response = await this.config.agent.process(content);
const rendered = renderMarkdown(response);
console.log(rendered);
console.log();
return;
}
// Fallback: direct model client (no tool support)
this.config.session.addMessage({ role: 'user', content });
// Try streaming if available
if (this.config.modelClient.chatStream) {
let fullContent = '';