How wsshow/feikong-teams works
Purpose and Entry Points
fkteams is a locally runnable Go multi-agent AI assistant for development, research, analysis, remote operations, and automation. The binary starts at cmd/fkteams/main.go; Cobra-style CLI commands expose interactive CLI/TUI, Web, API server, login, model management, sessions, skills, tools, and updates under internal/adapters/transport/cli/commands/. fkteams web/serve host the HTTP API and embedded React frontend.
Layering and Composition
The repository follows ports-and-adapters boundaries: domain types/events in internal/domain/, application orchestration in internal/app/, contracts in internal/ports/, and implementations in internal/adapters/. Bootstrap assembles configured runtimes, tools, skills, channels, schedulers, and environment dependencies through internal/bootstrap/runtimes/runtimes.go, internal/bootstrap/tools/tools.go, and internal/bootstrap/services/.
Agent Catalog and Task Orchestration
Agent definitions include coordinator, coder, researcher, analyst, tasker, moderator, and custom agents. The catalog/registry selects agent behavior and prompts from internal/app/agent/catalog/registry.go and internal/app/agent/catalog/; internal/app/agent/runner.go executes selected agents. Chat lifecycle and long-running task ownership—including interruption and queued follow-ups—are coordinated by internal/app/chat/service.go and internal/app/chat/taskstream/manager.go.
Runtime Execution Pipeline
The Eino runtime adapter is the primary agent execution engine: internal/adapters/runtime/eino/engine/engine.go, internal/adapters/runtime/eino/runner.go, and internal/adapters/runtime/eino/factory.go. It routes model messages and tool calls through middleware for dispatch, skills/context injection, summaries, steering, filesystem access, result trimming, patching, and destructive-operation checks. Runtime-facing abstractions preserve the boundary in internal/ports/runtime/runtime.go; turn execution, approvals, checkpoints, and event emission are handled in internal/runtime/turn/, internal/runtime/approval/, and internal/runtime/events/.
Models, Tools, and Extensions
Model providers are registered behind runtime provider adapters, including OpenAI-compatible services, Claude, Gemini, DeepSeek, Ollama, Qwen, Ark, OpenRouter, and GitHub Copilot (internal/adapters/runtime/eino/providers/register/register.go, internal/adapters/model/providers/copilot/copilot.go). Built-in tools cover filesystem, command execution, Git, SSH, search, documents, spreadsheets, scripts, and scheduling under internal/adapters/tools/builtin/. MCP clients (internal/adapters/tools/mcp/client.go) and SkillHub-backed skills (internal/adapters/skill/skillhub/provider.go) extend the tool/knowledge surface.
Persistence, Memory, and Scheduled Work
Local file storage persists sessions, transcripts, attachments, metadata, and memory via internal/adapters/storage/file/history/. Application memory extracts, ranks, injects, and manages long-term context in internal/app/memory/; the memory model adapter is internal/adapters/model/memory/adapter.go. Scheduled tasks are collected/executed in internal/app/schedule/ and persist through the file-backed cron adapter at internal/adapters/scheduler/filecron/scheduler.go.
Transports and External Interfaces
The HTTP server routes chat, streaming/WebSocket events, OpenAI-compatible endpoints, session/file/share/skill/schedule APIs, authentication, and preview endpoints through internal/adapters/transport/http/server.go, internal/adapters/transport/http/router/router.go, and internal/adapters/transport/http/handler/. The embedded Bun/Vite React UI begins at web/src/main.tsx and drives task-stream chat from web/src/features/chat/TaskStreamController.tsx. CLI/TUI rendering consumes the same event model through internal/adapters/transport/cli/runtime/. Channel bridges connect Discord, QQ, and Weixin in internal/adapters/transport/channel/.
Runtime and Deployment Boundaries
The backend is Go; the embedded frontend is TypeScript/React built with Bun. Docker deployment is supplied by Dockerfile and docker-compose.yml. External dependencies include configured LLM providers, GitHub Copilot OAuth, optional MCP servers, SkillHub, Discord, QQ, Weixin, DuckDuckGo search, and local executables such as Git, SSH, Bun, and uv. Local workspace and tool policies are central security boundaries, enforced by command security, path guarding, approvals, and runtime tool policy.
Main entry points: service.go Chat service · engine.go Eino engine · runtimes.go Runtime bootstrap · main.go Go binary
Components 22
Entry & Transports
- Go binary
cmd/fkteams/main.go - CLI commands · Interactive, server, login, model, session, skill, and tool commands.
- HTTP server · Hosts APIs, streaming, WebSocket, and embedded web app.
internal/adapters/transport/http/server.go - API router & handlers
internal/adapters/transport/http/router/router.go - React frontend
web/src/main.tsx - Task-stream chat UI
web/src/features/chat/TaskStreamController.tsx - Channel bridges
Application Core
- Runtime bootstrap · Assembles configured runtimes, services, tools, skills, and channels.
internal/bootstrap/runtimes/runtimes.go - Agent catalog
internal/app/agent/catalog/registry.go - Agent runner
internal/app/agent/runner.go - Chat service · Owns chat lifecycle and long-running tasks.
internal/app/chat/service.go - Task-stream manager · Coordinates interruption and queued follow-ups.
internal/app/chat/taskstream/manager.go
Agent Runtime
- Eino engine · Runs model turns and middleware-based tool workflows.
internal/adapters/runtime/eino/engine/engine.go - Runtime port
internal/ports/runtime/runtime.go - Turn, approval & events · Handles checkpoints, approvals, and emitted events.
Tools & Providers
- LLM providers · Registers configured hosted and local model providers.
internal/adapters/runtime/eino/providers/register/register.go - Built-in tools · Filesystem, commands, Git, SSH, search, documents, and scheduling.
- MCP clients
internal/adapters/tools/mcp/client.go - SkillHub skills
internal/adapters/skill/skillhub/provider.go
State & Scheduling
- Memory service · Extracts, ranks, injects, and manages long-term context.
- File history storage · Persists sessions, transcripts, attachments, metadata, and memory.
- Scheduled work · Collects and executes persisted scheduled tasks.
Connections 25
- Go binary → CLI commands: starts
- Go binary → Runtime bootstrap: composes
- CLI commands → Chat service: submits chat
- HTTP server → API router & handlers: serves
- API router & handlers → Chat service: chat APIs
- React frontend → Task-stream chat UI: mounts
- Task-stream chat UI → HTTP server: streams tasks
- Channel bridges → Chat service: bridges messages
- Runtime bootstrap → LLM providers: registers
- Runtime bootstrap → Built-in tools: assembles
- Runtime bootstrap → SkillHub skills: loads
- Chat service → Task-stream manager: coordinates
- Task-stream manager → Agent catalog: selects agent
- Agent catalog → Agent runner: configures
- Agent runner → Runtime port: executes via
- Runtime port → Eino engine: implemented by
- Eino engine → Turn, approval & events: runs controlled turns
- Eino engine → LLM providers: invokes models
- Eino engine → Built-in tools: dispatches calls
- Eino engine → MCP clients: extends tools
- Eino engine → SkillHub skills: injects context
- Chat service → Memory service: uses context
- Memory service → File history storage: persists
- Chat service → File history storage: stores sessions
- Scheduled work → Chat service: triggers work