feat: implement Tier 3 features — lane queue, credential redaction, token dashboard, xAI, Voyage AI
- Lane Queue: per-session FIFO queue in gateway replacing reject-when-busy (9 tests) - Credential Redaction: redactConfig() expanded to cover 18+ secret fields (16 tests) - Web UI Token Dashboard: system.tokenUsage endpoint + Usage page with summary cards - xAI (Grok) Provider: OpenAI-compatible client with model pricing - Voyage AI Embeddings: new embedding provider with configurable dimensions (5 tests) - Update gap analysis: 90→95 match (70%→74%), Tier 3 section marked DONE - Update state.json: test count 1001→1034, add tier3_completion entry Total: 1034 tests passing across 85 files, typecheck clean
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
- **Parallelise with subagents:** For every task, use multiple subagents with the appropriate model to work more efficiently. Dispatch independent subtasks in parallel rather than executing them sequentially.
|
||||
- **Subagent model selection (MANDATORY):** You MUST use the right model tier for each subagent — `claude-haiku-4.5` for fast/simple/mechanical tasks, `claude-sonnet-4.5` for default/standard implementation work, and `claude-opus-4.6` for complex reasoning or architecture decisions. Never use the same model for all subagents.
|
||||
- **Minimize main agent context:** Always delegate tasks to subagents with the right model to execute each task more efficiently and keep the main agent context window usage minimum. The main agent should coordinate and synthesize, not perform detailed implementation work.
|
||||
- **Commit often:** `git commit` frequently — after each meaningful unit of work, not just at the end of a task.
|
||||
- **Update state.json:** After every feature implementation, modification, or significant change, update `docs/plans/state.json` accordingly — add new phases/entries, update test counts, adjust the `overall_progress` section, and update the `feature_gap_scorecard` if the gap analysis is affected. Commit state.json alongside the feature change, not as a separate afterthought.
|
||||
|
||||
@@ -25,12 +26,45 @@ pnpm start # Start production build
|
||||
# Testing
|
||||
pnpm test # Run tests in watch mode
|
||||
pnpm test:run # Run tests once (no watch)
|
||||
pnpm test:run src/path/to/file.test.ts # Run a single test file
|
||||
|
||||
# Linting and Type Checking
|
||||
pnpm lint # Run ESLint
|
||||
pnpm typecheck # Run TypeScript compiler (no emit)
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
Flynn is a multi-channel AI assistant daemon. Messages flow: **Channel Adapter → AgentOrchestrator → NativeAgent → ModelClient**, with tools executed in the agent loop.
|
||||
|
||||
### Core Abstractions
|
||||
|
||||
**ModelClient** (`src/models/types.ts`): `chat(request): Promise<ChatResponse>`. Providers: Anthropic, OpenAI, Gemini, Bedrock, Ollama, llama.cpp, GitHub Models, OpenRouter, Zhipu. Factory in `src/daemon/index.ts` (`createClientFromConfig()`). **ModelRouter** (`src/models/router.ts`) manages tiers (default/fast/complex/local) with fallback chains.
|
||||
|
||||
**ChannelAdapter** (`src/channels/types.ts`): `connect()`, `disconnect()`, `send()`, `onMessage()`. Adapters: Telegram, Discord, Slack, WhatsApp, WebChat. Registered in `ChannelRegistry`, each channel+sender pair gets its own session.
|
||||
|
||||
**Tool** (`src/tools/types.ts`): `{ name, description, inputSchema, execute(args): Promise<ToolResult> }`. Three patterns:
|
||||
- Static: `export const fooTool: Tool = { ... }` (no deps)
|
||||
- Factory: `export function createFooTool(dep): Tool` (single tool needing deps)
|
||||
- Multi-factory: `export function createFooTools(dep): Tool[]` (related tool set)
|
||||
|
||||
Registration chain: tool file → `src/tools/builtin/index.ts` → `src/tools/index.ts` → registered in `src/daemon/index.ts`.
|
||||
|
||||
**Tool Policy** (`src/tools/policy.ts`): Profiles (minimal/messaging/coding/full), groups (group:fs/runtime/web/memory), allow/deny with glob patterns.
|
||||
|
||||
**NativeAgent** (`src/backends/native/agent.ts`): Core agent loop with tool execution. **AgentOrchestrator** (`src/backends/native/orchestrator.ts`) wraps it with session management, compaction, memory extraction, and delegation to different model tiers.
|
||||
|
||||
### Other Key Systems
|
||||
|
||||
- **Config**: YAML + Zod validation (`src/config/schema.ts`). Supports `${ENV_VAR}` expansion.
|
||||
- **Sessions**: SQLite via `SessionStore` (`src/session/store.ts`). TTL-based pruning.
|
||||
- **Memory**: Namespace-based files + hybrid search (keyword + vector). Embedding providers configurable.
|
||||
- **Hooks**: Pattern-based confirmation engine (`src/hooks/`). Actions: confirm/log/silent.
|
||||
- **Sandbox**: Docker per-session containers (`src/sandbox/manager.ts`).
|
||||
- **Automation**: Cron scheduler, webhooks (HMAC), heartbeat monitor, Gmail watcher (`src/automation/`).
|
||||
- **Gateway**: WebSocket JSON-RPC + HTTP server + vanilla JS dashboard (`src/gateway/`).
|
||||
- **System Prompt**: Template search for SOUL.md/AGENTS.md/IDENTITY.md/USER.md/TOOLS.md (`src/prompt/template.ts`).
|
||||
|
||||
## Code Style Guidelines
|
||||
|
||||
### Imports
|
||||
@@ -55,6 +89,7 @@ pnpm typecheck # Run TypeScript compiler (no emit)
|
||||
- Module resolution: NodeNext
|
||||
- Module format: NodeNext
|
||||
- Enables `declaration`, `declarationMap`, and `sourceMap` for all builds
|
||||
- Requires Node.js >=22
|
||||
|
||||
### Error Handling
|
||||
|
||||
|
||||
Reference in New Issue
Block a user