# scorpiox-bot-plugin-oss-opencode-login A clean-room, zero-dependency, cross-platform SCORPIOX BOT node plugin for **OpenCode device-code login and account token management** on the node it runs on. Binary: `plugin_opencode_login` (Windows: `plugin_opencode_login.exe`). Marketplace slug: `opencode-login`. Category: `devtools`. License: MIT. ``` --meta {"name":"opencode","desc":"OpenCode login"} ?action= status | start | poll | cancel | refresh GET responsive dark/light HTML UI (?embed=1 aware) ``` ## Why it drives a CLI instead of speaking TLS An OAuth device flow is a sequence of HTTPS POSTs. A public clean-room repository cannot ship a client secret, and vendoring a TLS stack into every plugin would be a liability on each node. So this plugin opens **no socket of its own**: it drives the machine-mode login CLI that already ships with SCORPIOX CODE (`SXLOGIN-MACHINE-V1`: `--status`, `--start`, `--poll`, `--cancel`, one JSON line per call) and reads the credential file that CLI writes. The repo contains no secret, no internal address and no emoji. ``` plugin_opencode_login --popen--> scorpiox-opencode-login --status|--start|--poll|--cancel plugin_opencode_login --popen--> scorpiox-opencode-fetchtoken -local ``` Files it reads (all on the local node, all overridable): | Path | Written by | Override | |---|---|---| | `~/.config/opencode/auth.json` | the login CLI | `OPENCODE_CREDS_PATH` | | `~/.opencode/token.json` (fallback when the primary is absent) | hand-written installs | — | | `~/.claude/.login-pending/opencode-default.json` | the login CLI | `OPENCODE_PENDING_PATH` | | `~/.claude/scorpiox-env/superopencode.txt` | the login CLI | `OPENCODE_ENV_DIR` | | the login binary | SCORPIOX CODE | `OPENCODE_LOGIN_BIN` | | the token binary | SCORPIOX CODE | `OPENCODE_TOKEN_BIN` | **No token is ever printed, logged or returned.** `status` reports `logged_in`, `has_refresh`, `expires_at`, `expires_in_sec`, `expired`; `refresh` reports success and the new expiry and discards the payload. The test suite fails if the mock token appears in any response, and if the words `access_token` or `refresh_token` appear at all. ## Actions | Action | Behaviour | |---|---| | `status` (also `format=json`) | credential file + pending marker + CLI JSON merged into one honest picture; `pending` is owned by the marker file and its TTL, the CLI may only add to it | | `start` | returns the CLI's `verify_url`, `user_code`, `expires_in`, `interval`; `already_logged_in` when the node already has credentials (`force=1` replaces them) | | `poll` | one non-blocking round trip: `{state:"pending"}` while waiting, `{state:"done",logged_in:true}` on approval, `{state:"failed",error:...}` on denial or a dead flow | | `cancel` | aborts the pending flow and reports the cleared state | | `refresh` | re-reads the stored token through the node's token CLI and reports the new expiry with the value discarded | | `cli_unavailable` | structured, HTTP 200, when a CLI is missing, so a node without SCORPIOX CODE shows a message, not a broken panel | Auth: `X-Bot-Password`, `Authorization: Bearer` or `?pwd=`; a no-op when `BOT_PASSWORD` is unset; `--meta` is always unauthenticated. ## UI One page, no framework, no CDN, no `