feat: register web search and process tools in TUI mode
Previously these tools were only available in daemon mode. Now TUI mode also registers web search tools (when credentials are configured) and process management tools with proper cleanup on exit.
This commit is contained in:
+26
-1
@@ -46,7 +46,7 @@ export function registerTuiCommand(program: Command): void {
|
||||
const { AnthropicClient, OpenAIClient, OllamaClient, LlamaCppClient, GitHubModelsClient, GeminiClient, BedrockClient, ModelRouter } = await import('../models/index.js');
|
||||
const { MinimalTui, startFullscreenTui } = await import('../frontends/tui/index.js');
|
||||
const { NativeAgent } = await import('../backends/index.js');
|
||||
const { ToolRegistry, ToolExecutor, allBuiltinTools } = await import('../tools/index.js');
|
||||
const { ToolRegistry, ToolExecutor, allBuiltinTools, createWebSearchTools, createProcessTools, ProcessManager } = await import('../tools/index.js');
|
||||
const { HookEngine } = await import('../hooks/index.js');
|
||||
|
||||
const dataDir = resolve(homedir(), '.local/share/flynn');
|
||||
@@ -122,6 +122,30 @@ export function registerTuiCommand(program: Command): void {
|
||||
for (const tool of allBuiltinTools) {
|
||||
toolRegistry.register(tool);
|
||||
}
|
||||
|
||||
// Register web search tools if configured with credentials
|
||||
if (config.web_search.api_key || config.web_search.endpoint) {
|
||||
for (const tool of createWebSearchTools({
|
||||
provider: config.web_search.provider,
|
||||
apiKey: config.web_search.api_key,
|
||||
endpoint: config.web_search.endpoint,
|
||||
maxResults: config.web_search.max_results,
|
||||
})) {
|
||||
toolRegistry.register(tool);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize process manager and register process tools
|
||||
const processManager = new ProcessManager({
|
||||
maxConcurrent: config.process.max_concurrent,
|
||||
maxRuntimeMinutes: config.process.max_runtime_minutes,
|
||||
bufferSize: config.process.buffer_size,
|
||||
});
|
||||
|
||||
for (const tool of createProcessTools(processManager)) {
|
||||
toolRegistry.register(tool);
|
||||
}
|
||||
|
||||
const toolExecutor = new ToolExecutor(toolRegistry, hookEngine);
|
||||
|
||||
const session = sessionManager.getSession('tui', 'local');
|
||||
@@ -147,6 +171,7 @@ export function registerTuiCommand(program: Command): void {
|
||||
});
|
||||
|
||||
const cleanup = () => {
|
||||
processManager.shutdown();
|
||||
sessionStore.close();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user