feat: añadir claude-code como proveedor LLM via claude -p
Implementa un nuevo proveedor LLM que ejecuta 'claude -p' como subproceso, permitiendo usar Claude Code como backend de cualquier agente Matrix. Cambios: - pkg/llm/types.go: nueva constante ProviderClaudeCode - pkg/llm/router.go: routing de 'claude-code' antes de 'claude*' (Anthropic API) - internal/config/schema.go: nuevo tipo ClaudeCodeCfg con campos para binary, timeout, disable_tools, allowed/disallowed tools, permission_mode, model, fallback_model, session_id y add_dirs - shell/llm/claudecode.go: provider completo — buildClaudeArgs(), flattenMessages(), parseClaudeOutput() y filterEnv() para limpiar ANTHROPIC_API_KEY del entorno y que claude use su propia auth OAuth - shell/llm/factory.go: case 'claude-code' en FromConfig(), WithFallback() ahora recibe fallbackCfg para sobreescribir model/max_tokens al hacer fallback - agents/runtime.go: actualizado para pasar fallbackCfg a WithFallback() No se tocó: los proveedores existentes (anthropic.go, openai.go), el core puro de decision ni el listener de Matrix.
This commit is contained in:
@@ -5,6 +5,8 @@ import "strings"
|
||||
// Route maps a model string to its provider. Pure function.
|
||||
func Route(model string) ProviderID {
|
||||
switch {
|
||||
case model == "claude-code" || strings.HasPrefix(model, "claude-code/"):
|
||||
return ProviderClaudeCode
|
||||
case strings.HasPrefix(model, "claude"):
|
||||
return ProviderAnthropic
|
||||
case strings.HasPrefix(model, "gpt"), strings.HasPrefix(model, "o1"), strings.HasPrefix(model, "o3"):
|
||||
|
||||
+4
-3
@@ -16,9 +16,10 @@ const (
|
||||
type ProviderID string
|
||||
|
||||
const (
|
||||
ProviderAnthropic ProviderID = "anthropic"
|
||||
ProviderOpenAI ProviderID = "openai"
|
||||
ProviderOllama ProviderID = "ollama"
|
||||
ProviderAnthropic ProviderID = "anthropic"
|
||||
ProviderOpenAI ProviderID = "openai"
|
||||
ProviderOllama ProviderID = "ollama"
|
||||
ProviderClaudeCode ProviderID = "claude-code"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
|
||||
Reference in New Issue
Block a user