OAuth method defines no prompts, so OpenCode TUI /connect collides with the plugin's own stdin menu (EALREADY)
Summary
On OpenCode 1.18.34, using the OpenCode prompt/TUI path (/connect, or opencode auth login -p openai) to add a Codex account fails:
{"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_981ffed9"}}
and the OpenCode prompt input can wedge afterward. Running the same login from a separate terminal (opencode auth login -p openai) works. Verified on [email protected]; the same absence of prompts is present in the 6.27.0 tarball.
Root cause
The plugin's auth method uses OpenCode's plugin AuthHook but does not declare prompts. From @opencode-ai/plugin 1.18.18:
export type AuthHook = {
provider: string;
methods: ({
type: "oauth";
label: string;
prompts?: Array<
| { type: "text"; key: string; message: string; placeholder?: string; ... }
| { type: "select"; key: string; message: string; options: Array<{label;value;hint?}>; ... }
>;
authorize(inputs?: Record<string, string>): Promise<AuthOAuthResult>;
} | ...)[];
};
When prompts is absent, OpenCode does not render an input form for the method, so the plugin drives its own interactive menu (dist/lib/ui/select.js -> showAuthMenu -> promptLoginMode) reading stdin directly. Inside the OpenCode TUI, stdin is already owned by the host, so the re-open fails:
Error: EALREADY: connection already in progress, open
at select (.../oc-codex-multi-auth/dist/lib/ui/select.js:346)
at showAuthMenu (.../lib/ui/auth-menu.js:132)
at promptLoginMode (.../lib/cli.js:114)
at .../index.js:3683
at ProviderAuth.authorize (...)
This surfaces as UnknownError and can leave the TUI input broken.
Notably, authorize(inputs) already reads inputs.loginMode (explicitLoginMode, index.js:3150) and inputs.accountCount (index.js:3774), and skips promptLoginMode when explicitLoginMode is set (index.js:3633). So the interactive fallback happens precisely because the prompts that would supply those inputs are never declared.
Reproduction
- OpenCode 1.18.34 +
[email protected]. - In the OpenCode prompt, run
/connect(or in a terminal,opencode auth login -p openai). - Choose the OpenAI provider and the
Codex OAuth (ChatGPT Plus/Pro)method. - Expected: an OpenCode input form. Actual:
UnknownError(EALREADYinopencode.log) and/or wedged input.
Suggested fix
Declare prompts on the OAuth method (and keep the existing inputs handling):
{
type: "oauth",
label: AUTH_LABELS.OAUTH,
prompts: [
{ type: "select", key: "loginMode", message: "Codex account action",
options: [ { label: "Add account", value: "add" },
{ label: "Start fresh (replace pool)", value: "fresh" } ] },
{ type: "select", key: "accountCount", message: "How many accounts to add",
options: [ { label: "1", value: "1" }, { label: "2", value: "2" }, { label: "3", value: "3" } ] },
],
authorize: async (inputs) => { /* unchanged */ },
}
With prompts present, OpenCode renders the form and passes the values into authorize(inputs), so the plugin no longer needs to read stdin and the collision disappears. A local patch adding exactly this has been verified to work (OpenCode TUI form renders; /connect -> add account succeeds).
Environment
- OpenCode
1.18.34(plugin API@opencode-ai/[email protected]) oc-codex-multi-auth6.24.0(also reproduced as missingpromptsin6.27.0)- Windows 11