* Build AuthDeps from InitDeps. `stdout` is intentionally suppressed here * because runInit owns the final output — runConfigure's success message * and runWhoami's identity block are replaced by the init summary. * stderr (advisory messages, errors) flows through.
(deps: InitDeps, apiKey?: string, commandTag?: string)
| 111 | * stderr (advisory messages, errors) flows through. |
| 112 | */ |
| 113 | function toAuthDeps(deps: InitDeps, apiKey?: string, commandTag?: string): AuthDeps { |
| 114 | return { |
| 115 | env: deps.env, |
| 116 | credentialsPath: deps.credentialsPath, |
| 117 | fetchImpl: deps.fetchImpl, |
| 118 | stdout: _suppressedStdout, |
| 119 | stderr: deps.stderr, |
| 120 | // Forward the preludeWrite so injected tests can capture the "Configuring |
| 121 | // profile..." line, but default to a no-op so tests that don't care don't |
| 122 | // see it on real process.stdout. |
| 123 | preludeWrite: deps.preludeWrite ?? _suppressedStdout, |
| 124 | // If an explicit API key was provided, override the prompt so configure |
| 125 | // never actually prompts the user. |
| 126 | prompt: apiKey ? { secret: async (_q: string) => apiKey } : deps.prompt, |
| 127 | // Telemetry attribution for the configure-validate GET /me. Passed only for |
| 128 | // the configure step (see runInit) — never whoami — so each init run emits |
| 129 | // exactly one cli.initialized event on the backend. |
| 130 | commandTag, |
| 131 | }; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Build AgentDeps from InitDeps. `stdout` is suppressed for the same reason — |