diff --git a/cmd/gateway_providers.go b/cmd/gateway_providers.go index c4e365a9..2ad00776 100644 --- a/cmd/gateway_providers.go +++ b/cmd/gateway_providers.go @@ -294,6 +294,7 @@ func registerProvidersFromDB(registry *providers.Registry, provStore store.Provi continue } var cliOpts []providers.ClaudeCLIOption + cliOpts = append(cliOpts, providers.WithClaudeCLIName(p.Name)) cliOpts = append(cliOpts, providers.WithClaudeCLISecurityHooks("", true)) if gatewayAddr != "" { mcpData := providers.BuildCLIMCPConfigData(nil, gatewayAddr, gatewayToken) @@ -341,6 +342,7 @@ func registerProvidersFromDB(registry *providers.Registry, provStore store.Provi registry.RegisterForTenant(p.TenantID, codex) case store.ProviderAnthropicNative: registry.RegisterForTenant(p.TenantID, providers.NewAnthropicProvider(p.APIKey, + providers.WithAnthropicName(p.Name), providers.WithAnthropicBaseURL(p.APIBase))) case store.ProviderDashScope: registry.RegisterForTenant(p.TenantID, providers.NewDashScopeProvider(p.Name, p.APIKey, p.APIBase, "")) @@ -483,6 +485,7 @@ func registerACPFromDB(registry *providers.Registry, p store.LLMProviderData) { } registry.RegisterForTenant(p.TenantID, providers.NewACPProvider( binary, settings.Args, workDir, idleTTL, tools.DefaultDenyPatterns(), + providers.WithACPName(p.Name), providers.WithACPModel(p.Name), )) slog.Info("registered provider from DB", "name", p.Name, "type", "acp") diff --git a/internal/providers/acp_provider.go b/internal/providers/acp_provider.go index 55b10df8..1cc2e10c 100644 --- a/internal/providers/acp_provider.go +++ b/internal/providers/acp_provider.go @@ -16,6 +16,7 @@ import ( // ACPProvider implements Provider by orchestrating ACP-compatible agent subprocesses. // It delegates to a ProcessPool that manages agent lifecycle over JSON-RPC 2.0 stdio. type ACPProvider struct { + name string // provider name (default: "acp") pool *acp.ProcessPool bridge *acp.ToolBridge defaultModel string @@ -26,6 +27,15 @@ type ACPProvider struct { // ACPOption configures an ACPProvider. type ACPOption func(*ACPProvider) +// WithACPName overrides the provider name (default: "acp"). +func WithACPName(name string) ACPOption { + return func(p *ACPProvider) { + if name != "" { + p.name = name + } + } +} + // WithACPModel sets the default model/agent name. func WithACPModel(model string) ACPOption { return func(p *ACPProvider) { @@ -47,6 +57,7 @@ func WithACPPermMode(mode string) ACPOption { // NewACPProvider creates a provider that orchestrates ACP agents as subprocesses. func NewACPProvider(binary string, args []string, workDir string, idleTTL time.Duration, denyPatterns []*regexp.Regexp, opts ...ACPOption) *ACPProvider { p := &ACPProvider{ + name: "acp", defaultModel: "claude", } for _, opt := range opts { @@ -70,7 +81,7 @@ func NewACPProvider(binary string, args []string, workDir string, idleTTL time.D return p } -func (p *ACPProvider) Name() string { return "acp" } +func (p *ACPProvider) Name() string { return p.name } func (p *ACPProvider) DefaultModel() string { return p.defaultModel } // Chat sends a prompt and returns the complete response (non-streaming). diff --git a/internal/providers/anthropic.go b/internal/providers/anthropic.go index 0615e424..433f1cb4 100644 --- a/internal/providers/anthropic.go +++ b/internal/providers/anthropic.go @@ -38,6 +38,7 @@ func resolveAnthropicModel(model, defaultModel string) string { // AnthropicProvider implements Provider using the Anthropic Claude API via net/http. type AnthropicProvider struct { + name string // provider name (default: "anthropic") apiKey string baseURL string defaultModel string @@ -48,6 +49,7 @@ type AnthropicProvider struct { // NewAnthropicProvider creates a new Anthropic provider. func NewAnthropicProvider(apiKey string, opts ...AnthropicOption) *AnthropicProvider { p := &AnthropicProvider{ + name: "anthropic", apiKey: apiKey, baseURL: anthropicAPIBase, defaultModel: defaultClaudeModel, @@ -62,6 +64,15 @@ func NewAnthropicProvider(apiKey string, opts ...AnthropicOption) *AnthropicProv type AnthropicOption func(*AnthropicProvider) +// WithAnthropicName overrides the provider name (default: "anthropic"). +func WithAnthropicName(name string) AnthropicOption { + return func(p *AnthropicProvider) { + if name != "" { + p.name = name + } + } +} + func WithAnthropicModel(model string) AnthropicOption { return func(p *AnthropicProvider) { p.defaultModel = model } } @@ -74,7 +85,7 @@ func WithAnthropicBaseURL(baseURL string) AnthropicOption { } } -func (p *AnthropicProvider) Name() string { return "anthropic" } +func (p *AnthropicProvider) Name() string { return p.name } func (p *AnthropicProvider) DefaultModel() string { return p.defaultModel } func (p *AnthropicProvider) SupportsThinking() bool { return true } diff --git a/internal/providers/claude_cli.go b/internal/providers/claude_cli.go index 49849133..2f8048d7 100644 --- a/internal/providers/claude_cli.go +++ b/internal/providers/claude_cli.go @@ -39,6 +39,7 @@ const OptTenantID = "tenant_id" // It acts as a thin proxy: CLI manages session history, tool execution, and context. // GoClaw only forwards the latest user message and streams back the response. type ClaudeCLIProvider struct { + name string // provider name (default: "claude-cli") cliPath string // path to claude binary (default: "claude") defaultModel string // default: "sonnet" baseWorkDir string // base dir for agent workspaces @@ -54,6 +55,15 @@ type ClaudeCLIProvider struct { // ClaudeCLIOption configures the provider. type ClaudeCLIOption func(*ClaudeCLIProvider) +// WithClaudeCLIName overrides the provider name (default: "claude-cli"). +func WithClaudeCLIName(name string) ClaudeCLIOption { + return func(p *ClaudeCLIProvider) { + if name != "" { + p.name = name + } + } +} + // WithClaudeCLIModel sets the default model alias. func WithClaudeCLIModel(model string) ClaudeCLIOption { return func(p *ClaudeCLIProvider) { @@ -110,6 +120,7 @@ func NewClaudeCLIProvider(cliPath string, opts ...ClaudeCLIOption) *ClaudeCLIPro cliPath = "claude" } p := &ClaudeCLIProvider{ + name: "claude-cli", cliPath: cliPath, defaultModel: "sonnet", baseWorkDir: defaultCLIWorkDir(), @@ -122,7 +133,7 @@ func NewClaudeCLIProvider(cliPath string, opts ...ClaudeCLIOption) *ClaudeCLIPro return p } -func (p *ClaudeCLIProvider) Name() string { return "claude-cli" } +func (p *ClaudeCLIProvider) Name() string { return p.name } func (p *ClaudeCLIProvider) DefaultModel() string { return p.defaultModel } // Close cleans up temp files (per-session MCP configs, hooks settings). Implements io.Closer.