How lschaffer/tealkit works
Purpose and Entry Points
TealKit is a privacy-oriented, cross-platform agentic AI system: a local Flutter client creates, tests, schedules, and monitors workflows; an optional headless Dart server runs them continuously. Main entry points are the Flutter app at src/lib/main.dart and server daemon at src/server/bin/tealkit_server.dart. Deployment is Docker-oriented through src/server/Dockerfile and src/server/docker-compose.yml.
Client Application and UI State
The Flutter client presents the playground, workflow editors/list, interactive chat, settings, and visual pipeline builder. UI state is provider-backed and separates active task, LLM configuration, external tools, data sources, and local/remote server mode.
• src/lib/screens/playground_screen.dart
• src/lib/screens/workflow_edit_screen.dart
• src/lib/providers/server_mode_provider.dart
The client can execute locally or switch repositories/API clients to a configured headless server boundary.
Workflow Model, Persistence, and Execution
Workflows are modeled as tasks with steps, tool selection, LLM settings, schedules, outputs, and chained/conditional follow-on tasks. The local execution path coordinates prompt steps, tool calls, task outputs, delivery, and scheduling.
• src/lib/models/workflow_task.dart
• src/lib/services/task_runner_service.dart
• src/lib/services/scheduler_service.dart
Persistence is abstracted behind task repositories, allowing the same workflow-oriented UI to target local DuckDB or remote server APIs.
• src/lib/repositories/i_task_repository.dart
• src/lib/repositories/local_task_repository.dart
• src/lib/repositories/remote_task_repository.dart
LLM and Prompt Orchestration
LLM access is provider-independent, supporting configured remote providers/local OpenAI-compatible endpoints and embedded GGUF inference. Task execution can use multi-step prompts, passing prior raw tool/LLM results forward; workflow chaining passes completed task results to downstream workflows.
• src/lib/services/llm_service.dart
• src/lib/services/embedded_llm/embedded_llm_adapter.dart
• src/lib/services/function_hint_generation_service.dart
Function hints and tool usage rules form the model-facing contract that constrains and explains available operations.
• src/lib/models/function_hint.dart
• src/lib/config/tool_usage_rules.dart
Tool and MCP Integration Boundary
Tools are normalized through MCP clients/managers and an internal MCP registry. Built-in servers cover files, documents, Excel/PDF/chart generation, Gmail/Google services, web search, weather, SSH, shell, JavaScript/Python/PowerShell bridges, GitHub, and Home Assistant.
• src/lib/services/multi_mcp_manager.dart
• src/lib/mcp/internal_mcp_registry.dart
• src/lib/utils/tool_router.dart
External MCP servers may be remote or locally launched runtimes; registry/discovery and GitHub installation services manage this extensibility boundary.
• src/lib/services/mcp_client.dart
• src/lib/services/github_mcp_runtime_service.dart
• src/lib/services/github_mcp_registry_service.dart
Headless Server Runtime
The server owns its own DuckDB state, encrypted secrets, workflow runner, scheduler, tool registry, and server-side LLM/MCP adapters. It exposes the remote execution/control plane consumed by the client API package.
• src/server/lib/runner/server_task_runner.dart
• src/server/lib/scheduler/server_scheduler.dart
• src/server/lib/database/server_duckdb_service.dart
Server configuration, persistent database/output volumes, and encrypted credentials reside under src/server/config/ and src/server/data/. Container deployment supports local, production, and WSL2 compose variants.
External Services and Offline Assets
Primary integrations include Gemini, OpenAI-compatible APIs, Anthropic, Mistral, Ollama/LM Studio, Hugging Face GGUF downloads, Gmail/Google Calendar/Drive, IMAP/SMTP, SSH/SFTP, SerpApi/DuckDuckGo, Slack/WhatsApp delivery, and remote MCP endpoints. DuckDB backs local/server workflow and RAG-style data storage; vendored native support exists in src/third_party/dart_duckdb/.
A separate Python training area produces and validates tool-calling datasets/contracts and LoRA-oriented artifacts; it is not on the application request path.
• training/common/py/dataset/train_dataset_cli.py
• training/quality_gate/py/quality_gate.py
• training/train/py/train_lora.py
Main entry points: server_task_runner.dart Server workflow runner · playground_screen.dart Playground and editors · task_runner_service.dart Local task runner · tealkit_server.dart Server daemon
Components 22
Flutter client
- Flutter app
src/lib/main.dart - Playground and editors · Workflow editing, chat, settings, and visual pipeline views.
src/lib/screens/playground_screen.dart - Server mode · Selects local repositories or the remote server boundary.
src/lib/providers/server_mode_provider.dart - Workflow task · Tasks contain steps, tools, LLM settings, schedules, outputs, and follow-ons.
src/lib/models/workflow_task.dart - Task repositories · Common local and remote workflow access contract.
src/lib/repositories/i_task_repository.dart - Local task repository
src/lib/repositories/local_task_repository.dart - Remote task repository
src/lib/repositories/remote_task_repository.dart - Local task runner · Coordinates prompt steps, tools, outputs, delivery, and chained tasks.
src/lib/services/task_runner_service.dart - Local scheduler
src/lib/services/scheduler_service.dart
Headless server
- Server daemon
src/server/bin/tealkit_server.dart - Server workflow runner · Continuously executes remotely controlled workflows.
src/server/lib/runner/server_task_runner.dart - Server scheduler
src/server/lib/scheduler/server_scheduler.dart - Server DuckDB state · Server-owned workflow state, outputs, and encrypted-secret context.
src/server/lib/database/server_duckdb_service.dart - Docker deployment · Supports persistent server state and compose-based deployment variants.
src/server/Dockerfile
AI and tool boundary
- LLM orchestration · Runs provider-independent multi-step prompts and forwards prior results.
src/lib/services/llm_service.dart - Embedded GGUF inference
src/lib/services/embedded_llm/embedded_llm_adapter.dart - Function hints and rules · Constrains and explains available operations to models.
src/lib/services/function_hint_generation_service.dart - MCP tool manager · Normalizes built-in, remote, and locally launched tool runtimes.
src/lib/services/multi_mcp_manager.dart - Internal MCP registry · Built-in tools span files, cloud services, code bridges, search, and automation.
src/lib/mcp/internal_mcp_registry.dart
Training pipeline
Offline dataset and LoRA artifact production.
- Dataset builder
training/common/py/dataset/train_dataset_cli.py - Contract quality gate
training/quality_gate/py/quality_gate.py - LoRA training · Produces offline fine-tuning artifacts.
training/train/py/train_lora.py
Connections 25
- Flutter app → Playground and editors: renders
- Playground and editors → Server mode: selects mode
- Playground and editors → Workflow task: edits
- Playground and editors → Task repositories: loads and saves
- Server mode → Local task repository: local mode
- Server mode → Remote task repository: remote mode
- Task repositories → Local task repository: implemented by
- Task repositories → Remote task repository: implemented by
- Workflow task → Local task runner: executes locally
- Local scheduler → Local task runner: triggers
- Local task runner → LLM orchestration: runs prompts
- Local task runner → MCP tool manager: calls tools
- LLM orchestration → Embedded GGUF inference: can use
- Function hints and rules → LLM orchestration: guides tool use
- MCP tool manager → Internal MCP registry: resolves built-ins
- Remote task repository → Server daemon: remote control plane
- Server daemon → Server workflow runner: hosts
- Server daemon → Server scheduler: hosts
- Server workflow runner → Server DuckDB state: persists state
- Server scheduler → Server workflow runner: triggers
- Server workflow runner → LLM orchestration: uses LLM adapters
- Server workflow runner → MCP tool manager: uses tool adapters
- Docker deployment → Server daemon: deploys
- Dataset builder → Contract quality gate: validates datasets
- Contract quality gate → LoRA training: approved data