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:
@@ -80,6 +80,24 @@ type LLMProviderCfg struct {
|
||||
BaseURL string `yaml:"base_url"`
|
||||
MaxTokens int `yaml:"max_tokens"`
|
||||
Temperature float64 `yaml:"temperature"`
|
||||
|
||||
// ClaudeCode holds configuration for the claude-code provider (claude -p).
|
||||
ClaudeCode ClaudeCodeCfg `yaml:"claude_code"`
|
||||
}
|
||||
|
||||
// ClaudeCodeCfg configures the claude -p subprocess provider.
|
||||
type ClaudeCodeCfg struct {
|
||||
Binary string `yaml:"binary"` // path to claude binary (default: "claude")
|
||||
Timeout time.Duration `yaml:"timeout"` // subprocess timeout (default: 5m)
|
||||
DisableTools bool `yaml:"disable_tools"` // pass --tools "" to disable all internal tools
|
||||
AllowedTools []string `yaml:"allowed_tools"` // tools claude -p can use internally (e.g. Bash, Read, Edit)
|
||||
DisallowedTools []string `yaml:"disallowed_tools"` // tools to block
|
||||
WorkingDir string `yaml:"working_dir"` // working directory for claude -p
|
||||
PermissionMode string `yaml:"permission_mode"` // default, acceptEdits, bypassPermissions, plan
|
||||
Model string `yaml:"model"` // inner model: sonnet, opus, haiku, or full name
|
||||
FallbackModel string `yaml:"fallback_model"` // fallback model if primary is overloaded
|
||||
SessionID string `yaml:"session_id"` // fixed session ID for continuity
|
||||
AddDirs []string `yaml:"add_dirs"` // additional directories accessible
|
||||
}
|
||||
|
||||
type LLMReasoningCfg struct {
|
||||
|
||||
Reference in New Issue
Block a user