MCPcopy Index your code
hub / github.com/docker/docker-agent / configToMap

Function configToMap

cmd/wasm/bridge.go:109–138  ·  view source on GitHub ↗

configToMap reduces a fully-parsed *latest.Config to the small JS-friendly shape returned by parseConfig. We deliberately omit fields that wouldn't mean anything in the browser (toolsets, hooks, sandbox).

(cfg *latest.Config)

Source from the content-addressed store, hash-verified

107// shape returned by parseConfig. We deliberately omit fields that wouldn't
108// mean anything in the browser (toolsets, hooks, sandbox).
109func configToMap(cfg *latest.Config) map[string]any {
110 agents := make([]any, 0, len(cfg.Agents))
111 for _, a := range cfg.Agents {
112 agents = append(agents, map[string]any{
113 "name": a.Name,
114 "description": a.Description,
115 "model": a.Model,
116 "instruction": a.Instruction,
117 "sub_agents": stringsToAny(a.SubAgents),
118 "handoffs": stringsToAny(a.Handoffs),
119 "add_date": a.AddDate,
120 "add_env_info": a.AddEnvironmentInfo,
121 })
122 }
123
124 models := map[string]any{}
125 for k, m := range cfg.Models {
126 models[k] = map[string]any{
127 "provider": m.Provider,
128 "model": m.Model,
129 "base_url": m.BaseURL,
130 }
131 }
132
133 return map[string]any{
134 "version": cfg.Version,
135 "agents": agents,
136 "models": models,
137 }
138}
139
140// stringsToAny widens a []string to []any so syscall/js.ValueOf accepts it.
141func stringsToAny(in []string) []any {

Callers 1

parseConfigJSFunction · 0.85

Calls 1

stringsToAnyFunction · 0.85

Tested by

no test coverage detected