Commit Graph

27 Commits

Author SHA1 Message Date
William Valentin 1c2f54fae3 feat: implement tier 1 quick wins (tool groups, typing, pruning, verbose, think)
Five additive features with no breaking changes:

- Tool groups: group:fs, group:runtime, group:web, group:memory syntactic
  sugar for allow/deny lists in tool policy config
- Typing indicators: Discord sendTyping() and WhatsApp sendStateTyping()
  on message receipt for better UX feedback
- Session pruning: TTL-based auto-cleanup via sessions.ttl config with
  hourly daemon timer and SQLite GROUP BY pruning
- /verbose command: TUI command parser toggle for raw streaming display
- !!think prefix: per-message extended thinking mode wired through
  Anthropic (budget_tokens), OpenAI/GitHub (reasoning_effort), and
  Gemini (thinkingConfig) providers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:35:00 -08:00
William Valentin d4530a7034 feat: add runtime provider/model switching via /model <tier> <provider/model>
- ModelRouter: add setClient(), labels map, getLabel(), getAllLabels()
- TUI commands: parse /model <tier> <provider/model> syntax with autocompletion
- TUI minimal: handle provider switching via createClientFromConfig factory
- Daemon: wire initial labels into router config
- Fix /model alias mappings (opus=complex, sonnet=default, haiku=fast)
- Add design doc and update state.json with feature status
2026-02-06 23:42:14 -08:00
William Valentin f363717f5f feat: add GitHub Copilot model provider with OAuth device flow
Add a new 'github' model provider backed by the Copilot API
(api.githubcopilot.com), with OAuth device flow for authentication.

- New src/auth/github.ts: device flow login, token storage at
  ~/.config/flynn/auth.json with 0600 permissions
- New src/models/github.ts: OpenAI-compatible client with streaming,
  tool calling, and Copilot-specific headers
- Add 'github' to provider enum in config schema
- Register provider in daemon factory and TUI client factory
- Refactor TUI to use provider-agnostic client factory (was hardcoded
  to AnthropicClient for all tiers)
- Add /login command to TUI for interactive OAuth authorization
- Add Copilot model cost tracking entries
2026-02-06 22:26:52 -08:00
William Valentin a515912537 feat: add multimodal media pipeline for image support across all providers and channels
Widen Message.content from string to string | MessageContentPart[] to support
multimodal content. Add Attachment type to channel layer, media conversion
utilities, and image extraction to all channel adapters (Telegram, Discord,
Slack, WhatsApp). Update all model clients (Anthropic, OpenAI, Gemini, Bedrock)
to convert structured content to provider-specific formats. Fix downstream
consumers (tokens, compaction, TUI, local models) to handle the widened type
via getMessageText() helper.
2026-02-06 17:17:21 -08:00
William Valentin 4316dbd3be feat: add P2 features — retry policy, prompt templating, usage tracking, tech debt cleanup
- Extract shared splitMessage() into channels/utils.ts (dedup 4 adapters)
- Add Slack user name resolution with caching (users.info API)
- Add withRetry() with exponential backoff + jitter, isRetryable() filter
- Wire retry config into ModelRouter.chat() (non-streaming only)
- Add assembleSystemPrompt() multi-file template system (SOUL/AGENTS/IDENTITY/USER/TOOLS.md)
- Add usage tracking accumulators in NativeAgent + AgentOrchestrator
- Add estimateCost() with per-model pricing table
- Add /usage TUI command with full usage report formatting
- Add retrySchema and promptSchema to config schema

Tests: 569 passing, typecheck clean
2026-02-06 15:12:35 -08:00
William Valentin 306e11bd2e feat: add multi-model delegation (Phase 0) and context compaction (Phase 1)
Phase 0 — Multi-Model Delegation:
- AgentOrchestrator wraps NativeAgent with delegate() for stateless
  single-turn calls to any model tier (fast/default/complex/local)
- DelegationConfig maps task types (compaction, classification, etc.)
  to model tiers
- Delegation prompts for compaction, memory extraction, classification,
  and tool summarisation
- Per-tier usage tracking for cost visibility
- Config schema: agents.delegation and agents.primary_tier

Phase 1 — Context Compaction:
- Token estimation (char/4 heuristic) with context window lookup
- shouldCompact() threshold check against context window percentage
- compactHistory() splits old/recent messages, delegates summary to
  fast tier, returns CompactionResult
- Automatic compaction in AgentOrchestrator.process() when configured
- Force-compact via orchestrator.compact() with session persistence
- Session.replaceHistory() with atomic SQLite transaction
- /compact TUI command with feedback on compacted token counts
- Config schema: compaction.enabled, threshold_pct, keep_turns,
  summary_max_tokens

Tests: 385 passing across 50 files (22 new tests in 2 new test files)
2026-02-06 13:17:02 -08:00
William Valentin f7cc87a4bb fix: sync agent tier when /model command switches model
The /model command was only updating the router's currentTier but not
the agent's currentTier. Since NativeAgent.chatWithRouter() passes its
own tier to router.chat(), switching to 'local' still sent requests
through the default (Anthropic) client first.
2026-02-06 10:05:32 -08:00
William Valentin e4b7f96d33 fix: provider-aware model routing with fallback visibility
- Extract createClientFromConfig() to dispatch on provider field instead
  of hardcoding all tiers as AnthropicClient
- Add fallback/fallbackReason metadata to ChatResponse and ChatStreamEvent
  so callers know when a fallback model was used
- Enhance doctor check to report full model stack and warn on missing
  API keys for cloud providers
- Log fallback warnings in NativeAgent and display them in TUI
- Support tier names and local_providers entries in fallback_chain
- Add 8 tests for createClientFromConfig covering all provider types
2026-02-06 09:58:56 -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 c1f64d6ded feat: enhance TUI with colors, command hints, and improved rendering 2026-02-05 15:51:29 -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 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
William Valentin 0490d2fe39 feat(tui): add markdown rendering and scroll support to MessageList 2026-02-05 10:56:23 -08:00
William Valentin 7391b50d6d feat(tui): enhance StatusBar with token usage and streaming indicator 2026-02-05 10:56:19 -08:00
William Valentin 83a750f484 feat(tui): update fullscreen config for model router 2026-02-05 10:56:16 -08:00
William Valentin f115407af3 feat(tui): add streaming and model switching to minimal mode 2026-02-05 10:53:41 -08:00
William Valentin 435146344e feat(tui): add unified command parser with model switching 2026-02-05 10:52:49 -08:00
William Valentin da2bb57488 feat(tui): add markdown rendering utility 2026-02-05 10:52:00 -08:00
William Valentin f671ea5ab5 feat: add fullscreen TUI mode with Ink React components 2026-02-05 00:41:17 -08:00
William Valentin 53a8bd97eb feat: add Ink-based fullscreen TUI components 2026-02-05 00:39:53 -08:00
William Valentin f792f8407a feat: add minimal TUI with readline interface 2026-02-05 00:36:16 -08:00
William Valentin 6e6c263e14 feat: integrate model router, session persistence, and hook engine
- NativeAgent now loads/saves messages to SessionStore
- Daemon creates ModelRouter with fallback chain support
- Telegram bot handles confirmation callbacks from HookEngine
- Session data stored in ~/.local/share/flynn/sessions.db

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 00:05:42 -08:00
William Valentin 298f87615d feat: add Telegram confirmation UI components
Implements Phase 2 Task 7 - Telegram Confirmation UI:
- formatConfirmationMessage(): formats tool and args into readable message
- createConfirmationKeyboard(): creates approve/deny inline keyboard
- parseConfirmationCallback(): parses callback data from button clicks
- Full test coverage with vitest

All tests passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 00:29:32 -08:00
William Valentin d0fe4c5b35 feat: add Telegram bot frontend with message handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 20:59:17 -08:00