MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / autoResolve

Function autoResolve

internal/cli/launch.go:198–257  ·  view source on GitHub ↗

autoResolve fills missing pinned fields using today's auto-selection logic (first matching endpoint, first model). Used when stdin is not a TTY, or when there's nothing left to ask the user.

(in wizardInput, stderr io.Writer)

Source from the content-addressed store, hash-verified

196// when stdin is not a TTY, or when there's nothing left to ask the
197// user.
198func autoResolve(in wizardInput, stderr io.Writer) (launchSelection, error) {
199 sel := in.Pinned
200
201 if sel.Tool.Name == "" {
202 return launchSelection{}, fmt.Errorf("launch: no tool specified and no TTY for interactive selection; pass a tool name")
203 }
204
205 if sel.EndpointName == "" {
206 client := sel.Tool.LaunchCommand()
207 for _, name := range in.Providers.SortedNames() {
208 ep := in.Providers.Endpoints[name]
209 if !ep.IsEnabled() {
210 continue
211 }
212 if !ep.SupportsClient(client) {
213 continue
214 }
215 sel.EndpointName = name
216 sel.Endpoint = ep
217 if stderr != nil {
218 fmt.Fprintf(stderr, "[cam] auto-selected endpoint: %s\n", name)
219 }
220 break
221 }
222 if sel.EndpointName == "" {
223 return launchSelection{}, fmt.Errorf("no provider supports tool: %s", client)
224 }
225 } else {
226 ep, ok := in.Providers.Endpoints[sel.EndpointName]
227 if !ok {
228 return launchSelection{}, fmt.Errorf("Unknown endpoint: %s", sel.EndpointName)
229 }
230 if !ep.SupportsClient(sel.Tool.LaunchCommand()) {
231 return launchSelection{}, fmt.Errorf(
232 "endpoint %s does not support tool %s (check supported_client)",
233 sel.EndpointName, sel.Tool.LaunchCommand())
234 }
235 sel.Endpoint = ep
236 }
237
238 if sel.Model == "" {
239 models, mErr := in.ResolveModels(sel.Endpoint, sel.EndpointName)
240 if mErr != nil {
241 return launchSelection{}, fmt.Errorf(
242 "launch: discover models for endpoint %s: %w (pass --model to skip discovery)",
243 sel.EndpointName, mErr)
244 }
245 if len(models) == 0 {
246 return launchSelection{}, fmt.Errorf(
247 "launch: endpoint %s has no discovered models; pass --model",
248 sel.EndpointName)
249 }
250 sel.Model = models[0]
251 if stderr != nil {
252 fmt.Fprintf(stderr, "[cam] auto-selected model: %s\n", sel.Model)
253 }
254 }
255

Callers 1

resolveLaunchSelectionFunction · 0.85

Calls 5

LaunchCommandMethod · 0.80
SortedNamesMethod · 0.80
SupportsClientMethod · 0.80
IsEnabledMethod · 0.45
ResolveModelsMethod · 0.45

Tested by

no test coverage detected