c51b0ca9fab9f1afc86d3098dfd1202ebbe673b3
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e115b96411 |
plugin: an api sign-in whose prompts ask the key asks no second key
An OpenCode plugin's "api" auth method with its own prompts and an authorize (inkstone's API key ways, Devin's session token in magpie-community/plugins#928) asks the key in its prompts and returns it from authorize(inputs). The GUI asked those prompts and then always showed a key field of its own, so the user typed the same token twice and the second entry went nowhere. The host's save() also copied every answer into the account's metadata, so the token sat there a second time in plain text. - host.js marks such a method keyAsked (type api, prompts, authorize). The GUI's startPluginSignIn signs in with no key field for it, as for keyless, and a rejected answer asks the prompts again on Try again. PluginAPIKey and `magpie plugin` login skip the empty-key check for it (Method.NoKey). - save() keeps only select answers (choices, never secrets) beside the authorize result's own metadata. A method with no authorize still keeps every answer, as OpenCode does. - An authorize that gives no key, with no key typed, is now an error instead of an "ok" that saved nothing. OpenCode itself differs: its v1 CLI (providers.ts) asks the prompts, then always asks "Enter your API key", saves result.key ?? the typed key, and merges the answers into metadata; its TUI never calls authorize for api methods. magpie-community plugins are written for magpie's flow and read the key from inputs, so this follows them. Plugins that read prompt answers back from metadata (grep of magpie-community/plugins packages): zcode (site, a select), joycode (tenant) and agnes (keyProfile, consoleToken). None has an authorize, so none changes. Every api+authorize plugin (inkstone, cloudflare-workers-ai, sensenova, agnes-code, astudio, sap-aicore, Devin #928) puts what it needs in its result's metadata itself; sensenova's apiKey: undefined workaround is now moot. Run on mote (macOS 27, Go 1.26.8, Playwright 1.62.0) at this change on origin/main |