Commit Graph

93 Commits

Author SHA1 Message Date
William Valentin b9e008ea23 feat(automation): add CronScheduler channel adapter
Implements CronScheduler as a ChannelAdapter that fires InboundMessages
on cron schedules and routes agent responses to configured output
channels (e.g. Telegram). Includes 9 tests.
2026-02-05 22:22:13 -08:00
William Valentin c4d30fd0d3 feat(cli): implement doctor diagnostics with 10 health checks
Replace doctor stub with full implementation including checks for:
config existence, YAML parsing, schema validation, env vars,
data directory writability, session DB, model config, Telegram,
MCP servers, and skills loading.
2026-02-05 22:20:37 -08:00
William Valentin 826e217dce refactor: retire old entry points, delegate to CLI 2026-02-05 22:18:16 -08:00
William Valentin 1ed9a34715 feat(cli): implement tui command wrapping existing TUI logic 2026-02-05 22:17:44 -08:00
William Valentin 117f3405ce feat(cli): implement config display command 2026-02-05 22:16:58 -08:00
William Valentin 0699730627 feat(cli): implement sessions list command 2026-02-05 22:16:29 -08:00
William Valentin 237246a8cf feat(cli): implement send command for one-shot agent messages 2026-02-05 22:15:46 -08:00
William Valentin 72c75a8bd7 feat(cli): add CLI entry point with commander and start command 2026-02-05 22:14:42 -08:00
William Valentin 6f7b5b8f0f feat(cli): add shared utilities for config loading and output 2026-02-05 22:13:05 -08:00
William Valentin e157bc6102 feat(config): add automation.cron schema for scheduled jobs 2026-02-05 22:12:12 -08:00
William Valentin 69fc4dd531 chore: add commander and croner dependencies 2026-02-05 22:10:44 -08:00
William Valentin 224c023028 docs: add Phase 5a design and implementation plans 2026-02-05 22:10:41 -08:00
William Valentin 7c41ffad71 feat: add skills system for extensible capability packages
Implement a three-tier skill system (bundled/managed/workspace) that
extends Flynn's abilities via SKILL.md instructions injected into the
system prompt.

- SkillManifest/Skill types with requirements gating (OS, binaries, env)
- Loader: discovers skills from directories, validates manifests,
  checks system requirements, infers manifest from SKILL.md if missing
- SkillRegistry: holds skills, generates system prompt additions,
  supports override by name (workspace > managed > bundled)
- SkillInstaller: copies/removes skills in managed directory with
  upgrade support
- Config: add skills.workspace_dir, managed_dir, bundled_dir options
- Daemon: loads all skills at startup, injects available skill
  instructions into the system prompt
- Tests: 45 new tests (loader 22, registry 11, installer 12)
2026-02-05 20:20:03 -08:00
William Valentin cd839c7f0c feat: add MCP integration for external tool servers
Implement Model Context Protocol (MCP) support so Flynn can spawn MCP
server processes, discover their tools, and make them available to the
agent alongside builtin tools.

- McpClient: wraps @modelcontextprotocol/sdk with StdioClientTransport
  for process lifecycle, tool discovery (listTools), and invocation (callTool)
- McpManager: lifecycle management for multiple MCP servers with
  startAll/stopAll/restart, tool bridging into ToolRegistry
- Bridge: converts MCP tools to Flynn Tool interface with mcp:<server>:<tool>
  namespacing to avoid collisions with builtin tools
- Config: add env and cwd fields to mcp server schema
- ToolRegistry: add unregister() method for MCP server cleanup
- Daemon: wire McpManager into startup and shutdown lifecycle
- Tests: 28 new tests (bridge, manager, registry unregister)
2026-02-05 20:10:37 -08:00
William Valentin aa95f2132c feat: add channel adapter abstraction with Telegram and WebChat adapters
Implement Phase 3 channel adapters that decouple message sources from
the agent via a uniform ChannelAdapter interface and ChannelRegistry.

- Add ChannelAdapter/InboundMessage/OutboundMessage types
- Add ChannelRegistry for adapter lifecycle and message routing
- Add TelegramAdapter (grammy bot, auth middleware, confirmations, chunking)
- Add WebChatAdapter (thin shim over GatewayServer)
- Refactor daemon to use ChannelRegistry with per-channel-per-user agents
- Add config.get/config.patch gateway handlers (Phase 2 loose end)
- Add system.restart gateway handler (Phase 2 loose end)
- Add implementation plans and design docs

Tests: 225 passing (33 new channel adapter + gateway handler tests)
2026-02-05 20:00:36 -08:00
William Valentin 282a15d2b9 feat(gateway): add web UI with dashboard and chat interface
Refactor GatewayServer to serve HTTP and WebSocket on a shared
http.Server. Add static file serving with path traversal protection,
a dark-themed dashboard (system health, sessions, tools) and a
WebSocket chat interface with streaming tool events and markdown
rendering.
2026-02-05 19:39:53 -08:00
William Valentin f30a8bc318 feat(gateway): add WebSocket gateway with JSON-RPC protocol and auth
Phase 2 of the Flynn roadmap. Adds a WebSocket gateway server that
starts alongside the Telegram bot, providing real-time API access to
the agent, sessions, and tools.

Protocol: JSON-RPC-like (request/response/event) over WebSocket.
8 methods: agent.send, agent.cancel, sessions.list, sessions.history,
sessions.create, tools.list, tools.invoke, system.health.

Auth: Bearer token + Tailscale identity header support.
Session bridge: per-connection agent instances with shared model router.

New files: src/gateway/ (protocol, router, server, auth, session-bridge,
handlers for agent/sessions/tools/system).
57 new tests (181 total), typecheck clean.
2026-02-05 19:11:25 -08:00
William Valentin ad7fc241f1 feat(telegram): display tool execution status messages
Telegram bot now shows tool status during execution:
- Sends status message when tool starts (tool name + args snippet)
- Edits status message with result on completion
- Keeps typing indicator active during tool execution
- Adds setOnToolUse() to NativeAgent for per-message callback control
2026-02-05 17:53:54 -08:00
William Valentin 5088f7a6be 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.
2026-02-05 17:53:00 -08:00
William Valentin df92a9d95f feat: add tool capability descriptions to SOUL.md
Lists available tools (shell, file ops, web fetch) so the model knows
what it can do. Keeps SOUL.md as the single source of truth for the
system prompt.
2026-02-05 17:50:47 -08:00
William Valentin b686eb3fa3 test: add end-to-end tool integration tests
Tests the full agent -> tool execution -> model feedback loop:
- Shell tool execution with mock model
- Multi-tool chaining (file.write -> file.read) across iterations
- Verification that tool results are correctly passed back to model
2026-02-05 17:50:17 -08:00
William Valentin b9601b50ab feat(daemon): wire tool registry and executor into agent 2026-02-05 17:49:32 -08:00
William Valentin 4f87643341 feat(agent): add iterative tool use loop with max iterations
Rewrites NativeAgent.process() from single-turn to an iterative tool
loop. When toolRegistry and toolExecutor are provided, the agent calls
the model, executes any requested tool calls, feeds results back, and
loops until the model returns a text response or max iterations hit.

- Backward compatible: works exactly as before without tools
- Supports onToolUse callback for frontend status display
- Max iterations (default 10) prevents infinite loops
- Handles multiple tool calls per model response
- 5 new tests (8 total)
2026-02-05 17:48:38 -08:00
William Valentin 96ade25e98 feat(models): add tool use support to OpenAIClient 2026-02-05 17:44:04 -08:00
William Valentin 36c1cfc768 feat(models): add tool use support to AnthropicClient 2026-02-05 17:44:00 -08:00
William Valentin c96165fb2f feat(tools): add barrel exports and allBuiltinTools list 2026-02-05 17:40:13 -08:00
William Valentin b00706325b feat: add tool framework foundation (types, registry, executor, shell tool, model types, SOUL.md)
- Task 0: SOUL.md + loadSystemPrompt() in daemon
- Task 1: Tool type definitions (Tool, ToolCall, ToolResult, etc.)
- Task 2: ToolRegistry with Anthropic/OpenAI serialization
- Task 3: ToolExecutor with hooks, timeout, truncation
- Task 4: shell.exec builtin tool
- Task 8: Model types updated for tool use (ToolDefinition, ModelToolCall, etc.)
- Task 15: Model index exports for tool types
2026-02-05 17:39:40 -08:00
William Valentin 32dd3ad728 feat(tools): add file read/write/edit/list builtin tools 2026-02-05 17:39:20 -08:00
William Valentin b913941e4f docs: add README and AGENTS.md documentation 2026-02-05 15:51:50 -08:00
William Valentin d2a597d49d fix: add model parameter to LlamaCppClient requests 2026-02-05 15:51:33 -08:00
William Valentin 2fc07b4bca feat: add timestamps to session messages 2026-02-05 15:51:32 -08:00
William Valentin 5558687ab9 feat: wire up num_gpu config and updated clients to daemon and TUI 2026-02-05 15:51:30 -08:00
William Valentin c1f64d6ded feat: enhance TUI with colors, command hints, and improved rendering 2026-02-05 15:51:29 -08:00
William Valentin dbf1acd822 feat: add streaming support and num_gpu option to Ollama client 2026-02-05 15:51:28 -08:00
William Valentin a2e1f73493 feat: wire up localProviders config to TUI
Add LlamaCppClient to imports and handle llamacpp provider in createModelRouter.
Pass localProviders and currentLocalProvider configuration to MinimalTui to enable
the /backend command to access alternate provider configs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:37:26 -08:00
William Valentin f722cf2bf0 feat: add /backend command handler to MinimalTui 2026-02-05 13:36:36 -08:00
William Valentin 465b4a0c3c feat: add /backend command parsing
Add support for /backend command to show or switch local backend providers. Follows the same pattern as /model command with optional argument support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:35:10 -08:00
William Valentin dbeaa78e2c feat: add setLocalClient and getLocalProviderName to ModelRouter 2026-02-05 13:34:25 -08:00
William Valentin 0528b895b0 feat: add local_providers to config schema 2026-02-05 13:33:50 -08:00
William Valentin 61d9358449 docs: add backend switch implementation plan 2026-02-05 13:32:35 -08:00
William Valentin a893460397 docs: add backend switch command design 2026-02-05 13:30:14 -08:00
William Valentin d86710577d feat: wire up LlamaCppClient to model router
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:20:20 -08:00
William Valentin 8e7fa24fd6 feat: add clear error message when llama-server not running 2026-02-05 13:17:56 -08:00
William Valentin e8079347c7 feat: add streaming support to LlamaCppClient
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:15:18 -08:00
William Valentin a20156f8db feat: add LlamaCppClient with basic chat support
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:11:56 -08:00
William Valentin 3cf28df111 docs: add llama.cpp implementation plan 2026-02-05 13:09:23 -08:00
William Valentin 785bbe4acd chore: add .worktrees to gitignore 2026-02-05 13:07:09 -08:00
William Valentin 6f5dd741a9 docs: add llama.cpp integration design
Design for adding LlamaCppClient to support local LLM inference
via llama-server with CUDA. Target model: Qwen 2.5 14B Q4_K_M.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:05:58 -08:00
William Valentin f891c7aee8 fix: add API key/auth token support across all model clients 2026-02-05 10:56:40 -08:00
William Valentin 747a7f44a2 feat(tui): add streaming, scroll, and model switching to fullscreen App 2026-02-05 10:56:27 -08:00