Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.
The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.
Run on mote at f44fa2ef6 + this change. After rebasing on acd789d45 (an
unrelated responses_ws change), go build ./... and -run "Search|Budget"
on plugin, gateway and provider are ok again at this tree.
- gofmt -l clean; go vet ./internal/... ok; Linux and Windows vet of
plugin/gateway/provider/gui ok
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
./internal/gateway ./internal/gui: plugin, provider and gateway
ok; gui red only in TestMainWindowCorners/macOS_26_SDK, mote's
macOS 27 title bar, already filed as #3949
- node --test on 15 GUI files: search-signs-in, search-api, search-keys,
search-order, search-all, search-first, search-instead, searcher-pick,
searcher-then, provider-search, settings-search, i18n-keys, gui-zh-tw,
gui-ja, gui-de. 207 of 207 pass (chromium and webkit, 980/420px, en/zh).
Broken by hand. Each break made its test red:
- B1, no ctx.getAuth: plugin TestPluginSearchSignsIn "ctx.getAuth is not a
function"
- B2, no renewal: "searched as due@seek acc-due", "the renewal never began"
- B3, gateway with no auth branch: gateway TestPluginSearchSignsIn "signed
in: k9 undefined"
- B4, a refusal that also rests the model account: "a search's rate limit
rested a@seek for its models"
- B5, getAuth handing out the provider's first account: "as the second
account: a@seek acc-a"
- B6, the hook run outside inScope: "a token saved while searching as b: a
rotated-b@seek"
- B7, getAuth given to every entry: "keyed: k9 function"
- settings.js showing the key field for a bound entry: search-signs-in red
in every engine, width and language
Not tried: a real search vendor or Axel's own plugin; real accounts; runs
on the Windows or Linux boxes; the full GUI suite. The full go test ./...
runs after the push.