- Fix provider switch not taking effect: clear agent session ID on switch to force fresh session instead of resuming with stale config - Fix ANTHROPIC_MODEL env leak from cc-switch: explicitly set model env when provider has custom BaseURL - Add "clear provider" option in Feishu card for unsetting active provider - Add debug logging for provider env vars and session startup commands (with secret redaction via RedactEnv/RedactArgs) - Web UI: add agent type switcher in project settings with provider compatibility filtering and restart-required flow - Web UI: filter global providers by agent_types when linking to project - Web UI: fix heartbeat tab showing "running" for all projects (now shows "not configured" when heartbeat is not enabled) - Web UI: fix page not refreshing after agent type change + restart - Add comprehensive integration tests for both claudecode and codex provider switching (env vars, session args, config writing, send/receive) - Complete i18n for all 5 languages: replyFooter, injectSender, thinkingMessages, toolMessages and their hints Made-with: Cursor
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package core
|
|
|
|
import "fmt"
|
|
|
|
// PlatformFactory creates a Platform from config options.
|
|
type PlatformFactory func(opts map[string]any) (Platform, error)
|
|
|
|
// AgentFactory creates an Agent from config options.
|
|
type AgentFactory func(opts map[string]any) (Agent, error)
|
|
|
|
var (
|
|
platformFactories = make(map[string]PlatformFactory)
|
|
agentFactories = make(map[string]AgentFactory)
|
|
)
|
|
|
|
func RegisterPlatform(name string, factory PlatformFactory) {
|
|
platformFactories[name] = factory
|
|
}
|
|
|
|
func RegisterAgent(name string, factory AgentFactory) {
|
|
agentFactories[name] = factory
|
|
}
|
|
|
|
func CreatePlatform(name string, opts map[string]any) (Platform, error) {
|
|
f, ok := platformFactories[name]
|
|
if !ok {
|
|
available := make([]string, 0, len(platformFactories))
|
|
for k := range platformFactories {
|
|
available = append(available, k)
|
|
}
|
|
return nil, fmt.Errorf("unknown platform %q, available: %v", name, available)
|
|
}
|
|
return f(opts)
|
|
}
|
|
|
|
func ListRegisteredAgents() []string {
|
|
names := make([]string, 0, len(agentFactories))
|
|
for k := range agentFactories {
|
|
names = append(names, k)
|
|
}
|
|
return names
|
|
}
|
|
|
|
func ListRegisteredPlatforms() []string {
|
|
names := make([]string, 0, len(platformFactories))
|
|
for k := range platformFactories {
|
|
names = append(names, k)
|
|
}
|
|
return names
|
|
}
|
|
|
|
func CreateAgent(name string, opts map[string]any) (Agent, error) {
|
|
f, ok := agentFactories[name]
|
|
if !ok {
|
|
available := make([]string, 0, len(agentFactories))
|
|
for k := range agentFactories {
|
|
available = append(available, k)
|
|
}
|
|
return nil, fmt.Errorf("unknown agent %q, available: %v", name, available)
|
|
}
|
|
return f(opts)
|
|
}
|