mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-12 00:45:22 +00:00
The Zed Agent panel (new ACP-based UI) only discovers providers registered
under language_models.openai_compatible.<name>, not language_models.openai.
Each named entry appears as its own provider in the LLM Providers list.
- language_models.openai_compatible.harness-sync-gateway holds gateway URL + models
- agent.default_model.provider = 'harness-sync-gateway' (was 'openai')
- Model entries include capabilities {tools,images,parallel_tool_calls}
- Export common.GatewayProviderID so zed.go can reference it
- Fix staticcheck QF1001 (De Morgan's law) in io.go
- Fix struct field alignment in File (80→72 bytes)
- gofmt remaining files
113 lines
2.5 KiB
Go
113 lines
2.5 KiB
Go
package common
|
|
|
|
import "github.com/lukaszraczylo/harness-sync/internal/canonical"
|
|
|
|
// MCPStyle selects the dialect for MCP server entries.
|
|
type MCPStyle int
|
|
|
|
const (
|
|
// MCPClaudeStyle: claude-code shape — {command, args, env, url, transport}.
|
|
MCPClaudeStyle MCPStyle = iota
|
|
// MCPCrushStyle: crush shape — adds type: stdio|http|sse.
|
|
MCPCrushStyle
|
|
// MCPOpencodeStyle: kilo + opencode shape — type: local|remote, command as []string.
|
|
MCPOpencodeStyle
|
|
// MCPZedStyle: zed context_servers — {enabled, command, args} or {enabled, url}.
|
|
MCPZedStyle
|
|
)
|
|
|
|
// BuildMCPMapStyled returns the MCP map for the given harness dialect.
|
|
func BuildMCPMapStyled(reg *canonical.MCPRegistry, style MCPStyle) map[string]any {
|
|
out := map[string]any{}
|
|
if reg == nil {
|
|
return out
|
|
}
|
|
for _, s := range reg.Servers {
|
|
out[s.Name] = mcpEntry(s, style)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
|
e := map[string]any{}
|
|
switch style {
|
|
case MCPClaudeStyle:
|
|
// Claude Code's actual entry shape uses "type" (not "transport").
|
|
// Default to stdio when no URL is set.
|
|
t := s.Transport
|
|
if s.URL != "" {
|
|
if t == "" {
|
|
t = "http"
|
|
}
|
|
e["type"] = t
|
|
e["url"] = s.URL
|
|
} else {
|
|
if t == "" {
|
|
t = "stdio"
|
|
}
|
|
e["type"] = t
|
|
if s.Command != "" {
|
|
e["command"] = s.Command
|
|
}
|
|
if len(s.Args) > 0 {
|
|
e["args"] = s.Args
|
|
}
|
|
if len(s.Env) > 0 {
|
|
e["env"] = s.Env
|
|
}
|
|
}
|
|
case MCPCrushStyle:
|
|
if s.URL != "" {
|
|
t := s.Transport
|
|
if t == "" {
|
|
t = "http"
|
|
}
|
|
e["type"] = t
|
|
e["url"] = s.URL
|
|
} else {
|
|
e["type"] = "stdio"
|
|
if s.Command != "" {
|
|
e["command"] = s.Command
|
|
}
|
|
if len(s.Args) > 0 {
|
|
e["args"] = s.Args
|
|
}
|
|
if len(s.Env) > 0 {
|
|
e["env"] = s.Env
|
|
}
|
|
}
|
|
case MCPOpencodeStyle:
|
|
if s.URL != "" {
|
|
e["type"] = "remote"
|
|
e["url"] = s.URL
|
|
} else {
|
|
e["type"] = "local"
|
|
cmd := []string{}
|
|
if s.Command != "" {
|
|
cmd = append(cmd, s.Command)
|
|
}
|
|
cmd = append(cmd, s.Args...)
|
|
e["command"] = cmd
|
|
if len(s.Env) > 0 {
|
|
e["environment"] = s.Env
|
|
}
|
|
}
|
|
e["enabled"] = true
|
|
case MCPZedStyle:
|
|
// Do NOT emit "enabled" — Zed 1.3.x has a serde flatten+deny_unknown_fields
|
|
// bug where outer-struct fields bleed into the untagged enum variants and
|
|
// fail all of them. Omitting "enabled" defaults to true.
|
|
if s.URL != "" {
|
|
e["url"] = s.URL
|
|
} else {
|
|
if s.Command != "" {
|
|
e["command"] = s.Command
|
|
}
|
|
if len(s.Args) > 0 {
|
|
e["args"] = s.Args
|
|
}
|
|
}
|
|
}
|
|
return e
|
|
}
|