refactor: separar runtime.go en archivos por responsabilidad

Divide agents/runtime.go (1188 lineas) en 5 archivos especializados:

- runtime.go (350 lineas): struct Agent, New(), Run(), Stop(), lifecycle
- handler.go: handleEvent(), executeActions(), command routing, bus, sanitizacion
- llm.go: runLLM(), tool-use loop, system prompt, initLLM(), prompt-commands
- memory.go: ensureWindowLoaded(), appendToWindow(), persistMessage(), ClearWindow()
- registry_build.go: buildToolRegistry(), initToolDeps(), initRateLimiter()

Zero cambios en API publica. Todos los metodos siguen siendo del struct Agent,
solo viven en archivos separados por responsabilidad.

Funciones helper extraidas de New() para reducir su tamaño:
- initCrypto(): inicializacion E2EE
- initLLM(): cliente LLM con fallback
- initMemoryStore(): store SQLite + window size
- initToolDeps(): knowledge, MCP, skills
- initRateLimiter(): rate limiting de tools

Reduccion: 1188 → 350 lineas en runtime.go (70% menos).
This commit is contained in:
2026-04-08 23:17:12 +00:00
parent ac5cde3f3e
commit ee8e74be1b
5 changed files with 1016 additions and 901 deletions
+63 -901
View File
File diff suppressed because it is too large Load Diff