resolveLaunchSelection produces the concrete tool/endpoint/model triple by either invoking the interactive wizard (TTY + any field unpinned) or by auto-resolving from the SQLite provider store (non-TTY).
( out io.Writer, stderr io.Writer, file providers.File, registry *tools.Registry, pinned launchSelection, )
| 136 | // triple by either invoking the interactive wizard (TTY + any field |
| 137 | // unpinned) or by auto-resolving from the SQLite provider store (non-TTY). |
| 138 | func resolveLaunchSelection( |
| 139 | out io.Writer, |
| 140 | stderr io.Writer, |
| 141 | file providers.File, |
| 142 | registry *tools.Registry, |
| 143 | pinned launchSelection, |
| 144 | ) (launchSelection, bool, error) { |
| 145 | in := wizardInput{ |
| 146 | Pinned: pinned, |
| 147 | Providers: file, |
| 148 | Registry: registry, |
| 149 | ResolveModels: func(ep providers.Endpoint, epName string) ([]string, error) { |
| 150 | return providers.ResolveModels(ep, epName, cacheTTLFromCommon(file.Common), "", os.Getenv) |
| 151 | }, |
| 152 | } |
| 153 | |
| 154 | if outIsTTY(out) && (pinned.Tool.Name == "" || pinned.EndpointName == "" || pinned.Model == "") { |
| 155 | return runLaunchWizard(out, in) |
| 156 | } |
| 157 | |
| 158 | // Non-TTY (or fully pinned): auto-resolve any missing pieces. |
| 159 | sel, err := autoResolve(in, stderr) |
| 160 | return sel, false, err |
| 161 | } |
| 162 | |
| 163 | // outIsTTY reports whether the provided writer is a *os.File backed by |
| 164 | // a terminal. Tests pass *bytes.Buffer, which returns false; the live |
no test coverage detected