Skip to content

Several AI connections at once, one per provider - #2069

Draft
guidovizoso wants to merge 13 commits into
mainfrom
guido/multiple-subs
Draft

guidovizoso wants to merge 13 commits into
mainfrom
guido/multiple-subs

Conversation

@guidovizoso

Copy link
Copy Markdown
Collaborator

What this changes

Several AI connections at once, one per provider. A person who pays for a Claude plan and a ChatGPT plan, or holds a few keys, keeps all of them connected and picks a model from any of them per conversation, instead of switching one connection that moves every Bot and conversation.

API (api/openapi/model-connections.yaml, bots.yaml). Only grows; nothing existing changes meaning. Today's single-connection operations describe the default connection.

  • Organization (admins): listAiConnections, connectAiConnection, removeAiConnection, makeAiConnectionDefault under /ai-connections.
  • A person's own (OpenBot Cloud): the same four under /people/{personId}/ai-connections.
  • Organization sign-ins: startAiSignIn, getAiSignIn, finishAiSignIn under /ai-connection-sign-ins, as the personal ones, on OpenBot Cloud and a self-hosted OpenBot. OpenBot Desktop running its own OpenBot keeps its own plan sign-in (signIns empty).
  • Optional fields: ModelCatalogue.connections (each connection's models, owner, source, ready, problem), ModelChoice.connection and stopped, ModelChoiceInput.connection, and a Bot's defaultModel input source.
  • Rules: connecting a provider that already has a connection replaces it and keeps its id; the first is the default; a removal that leaves exactly one makes it the default; with more and none the default, a run with no pick gets a stopped choice (no-default). Ids are unique within their list only.

App.

  • Settings (AI model, Your AI, Admin, Providers): one row per connection, Default tag, Make default, Change, Disconnect, Connect another AI; a stopped row leads with Sign in again or Replace key.
  • The composer's model picker groups models under each connection, the default first, and a pick saves its connection.
  • A refused turn whose connection stopped working says so, with Reconnect for whoever can fix it and Choose another model; with no default, Choose a default.
  • A Bot's default model applies on any of a person's connections of its kind.
  • Against an OpenBot without the list (404), every screen draws what it drew before.

The backend half follows and is pinned to this branch. Draft until it is in.

Where it runs

  • New state that outlives a request? None in the app. Connections and the default live in the database, behind the backend's half.
  • What happens on the second replica? Nothing new here: every read goes to the API, and the app keeps no state of its own beyond the query cache.
  • Anything serialised? Not here. Making a default and removing one are separate requests; the backend's half answers for doing them at once.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway: resolve, decide, audit, then act.
  • New refusals and new failures each write a row (in the backend's half: connect, remove and make-default are audited).
  • Nothing new is trusted from the client that the server can resolve itself: a run reads the pick from the server's record, never from the browser.

API and database

  • It changes api/ and keeps every rule: only new operations and optional fields, new answer enums open (x-extensible-enum, never reachable from a request), no key or address in any answer, and the existing operations keep their meaning so a released app behaves as before. No database change in this repository.

Changelog

  • A line in CHANGELOG.md under Unreleased, API.

Proof

  • bun run api:lint, bun test api/ (78 pass), bun run format:check, bun run lint, bun run typecheck.
  • App tests for every touched screen in happy-dom (150 pass), and the Settings files that need a real browser in Chromium (OPENBOT_APP_BROWSER=1, 58 pass).
  • Not yet seen against a backend that answers the new operations; that comes with the backend's half.

List, connect, remove and make default the organization's AI connections
and a person's own, and sign the organization in to a provider the way a
person signs in. The single-connection operations keep their meaning and
describe the default connection. The model catalogue lists each
connection's models, a model choice names its connection and says when it
stopped, and a Bot's default model input can name its source. Every new
field is optional, so an older client sends and reads what it did.
AI model, Your AI and Admin, Providers draw one row per connection where
the server lists them: the default tagged once there are two, Make
default, Change and Disconnect in each row's dialog, and Connect another
AI with the shared chooser in a new adding mode. Disconnecting the
default asks which connection takes over and makes it the default first.
Connections with no default say so. The organization's sign-ins go
through its own sign-in operations. Against a server older than the list,
or with nothing connected yet, the sections draw the one row they drew
before.
… connection

With several connections the composer's picker lists each one's models
under its name, the default first, and a stopped connection's group says
why in place of its models. Picking saves the connection with the model,
so the same model on two connections is two choices and changing the
default never moves a pick. A pick whose connection is gone shows the
default and saves nothing; with no default the picker asks to choose.
With one connection it is the picker it was.
After a refused turn the conversation reads its model choice again. When
the server says the connection the next run would use is connected but
can't run, a notice under the turn gives its sentence, Reconnect into
that connection's row in Settings for whoever can fix it, and Choose
another model, which opens the composer's picker. The picker's trigger
carries a warning mark meanwhile. Nothing reads the refusal's own words,
and an older server draws nothing new.
A Bot is shared and each person runs it on their own connections, so its
default keeps naming a kind of connection. With several connections it
applies on the first ready connection of that kind that lists the model,
not only on the one in use, and falls back to the default connection's
default otherwise. The Default model section picks from the grouped list
and saves the group's kind as the source; with one connection it sends
none, as before.
…tays put

When an older app disconnects the default and one connection is left, the
picker names it so a conversation can still run on it. A pick on a
connection that stopped working is shown on that connection, by its id
if the connection lists nothing, instead of moving to the default's
model.
…efault

The sentence after Connect another AI or a row's Change read whether the
new connection is the default from the list as it stood, and was wrong
with no default or when the default's own provider was connected again.
It now follows the server's answer.
A conversation's Reconnect link now says whose connection it is, and only
that list in Settings opens its row: on OpenBot Cloud an admin's own
connection and the organization's may share an id, and both dialogs used
to open. The API says ids are unique within their list only.
In Settings a stopped row's dialog leads with Sign in again or Replace
key, which opens the chooser on that provider under a title naming the
fix. In the model picker, a stopped connection of the person's own gets
a Reconnect link in its group; the organization's waits on an admin.
When the last connection that can run is disconnected, the confirm step
uses the sentences the single connection's dialogs always used: a
person's runs fall back to the organization's AI, the organization's on
OpenBot Cloud leaves only people with their own, otherwise Bots can't
run. A person left with no AI where one is required is sent to connect
one again.
As agreed for the backend: when a removal leaves exactly one AI
connection, the server makes it the default, so disconnecting the default
with one other left asks nothing. With more left and none the default, a
run with no pick is refused and the conversation's model choice says so
(stopped, no-default), and the notice links to choosing a default.
Organization sign-ins are offered on OpenBot Cloud and a self-hosted
OpenBot; OpenBot Desktop keeps its own plan sign-in.
…rs do

Since TrustedRouter, a provider in an answer is AiConnectionProviderAnswer,
so a released app doesn't break when one is added. The connection list
and the catalogue's connections now use it too, and the app's names
accept a provider it doesn't know.
…lt example that can happen

Words for three new audit events the backend records: the organization's
or a person's default AI changed, and an organization sign-in. The
example of connections with no default now shows two left, since one
left becomes the default.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant