Two plugins can sign in to one provider id. On the owner's MacBook Air,
tianpeng-dev's opencode-doubao-work-auth 1.1.6 was installed before
@magpie-community/opencode-doubao-work-auth 0.1.2. Both name
doubao-work. The third party's config hook ran first and wrote
cfg.provider["doubao-work"] with models: {}. Ours writes its entry with
??=, so it added nothing. Ours served the id, being the last to name it,
but info() read the shared config.provider entry: the provider showed
the other plugin's name and api and 0 models.
The config hooks still share one config object. Before each hook runs,
every provider it signs in to is set to the user's own entry, or to
this plugin's entry from the last load, never to another plugin's.
What the hook leaves there is kept as that plugin's (ownConfig).
info() reads the serving plugin's entry (providerConfig), so Prefer
moves the name, api and models with the provider.
Run (mote, at c056b7c8c plus this change):
- go test ./internal/plugin/ ./internal/provider/ ./internal/gateway/
-count=1 -timeout 45m: ok (plugin 136s, provider 159s, gateway 879s)
- GOOS=linux and GOOS=windows go vet ./internal/plugin/: ok
- gofmt -l: clean
Broken by hand:
- With host.js as at c056b7c8c,
TestServingPluginsConfigIsTheProviders is red with the Air's case:
served by mine, but named "Theirs", with theirs' api and no models.
- With info() alone back on config.provider[id], it is red after
Prefer(theirs): theirs serves, but with mine's name and models.
Not tried: the Air itself, before the release reaches it.