diff --git a/AGENTS.md b/AGENTS.md index 2f7970c6..b3f72d65 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -214,7 +214,7 @@ A user's own running browser, reached over a browser MCP server they run beside ### Connectors (`connector_connections`, `connectors`, `bot_connectors`, `workspace_connectors`, `connector_accounts`, `connector_sessions`, `connector_requests`) -A user's access to an outside app (Gmail, Slack, ...) as themselves, reached through a provider that holds the OAuth app and the connected account (Settings > Connectors). Composio is the first provider: one file under `src/harness/connectors/providers/` and the preset in `src/dict/connector-dict.ts`. **A connection is one provider account, not an app**: `connector_connections` has one row per provider account (Composio Personal, Composio Work, ...), each with its own encrypted `api_key`, added in Settings > Connectors; the form's **paradigm** (`provider`, Composio the first) decides how that connection's apps are reached, and more paradigms can be added; that form names the key a paradigm wants and links where to make it (`key_help`, `key_url`, `key_url_title` in the preset: Composio wants a project API key `ak_...` from its Project Settings > API Keys, not a `ck_...` key made for `connect.composio.dev/mcp`, whose router signs everyone in as the key's owner); `connectorProviderFor` builds the provider from that key, so no install-wide key is read from Environment. `syncConnectorConnection({ connection_id })` reads every app the connection offers into `connectors` (`connectors.connection_id`; `planConnectorSync` derives each slug and names a second connection's app after it, `gmail-work`), so nothing is added or edited app by app; a stored app follows the provider's name, description and logo only, keeping its slug, reach and accounts. A thousand apps cost nothing until one is used: its tools are read when it is first given to a bot or workspace (`syncConnector` from `set-bot-connector`/`set-connector-access` when `tools` is empty) and by the cron for assigned apps alone. **An account is a person's own** (`connector_accounts.user_id`), several per app, and its owner's runs always reach it; its owner or a super admin can also give it out (`connector_accounts.all_bots`, `connector_account_workspaces`, `connector_account_bots`, written by `setConnectorAccountAccess`), so every run in a workspace or on a bot reaches it too, whoever signed in (and giving an account out brings its app along to that bot or workspace, since `botConnectorsSql` counts a connected account given there), and the session is built as the account's owner (`openBotConnectors` passes `account.user_id`, and a shared line names whose account it is). Its owner or a super admin renames it (`saveConnectorAccount`, which regenerates the slug, so a namespace follows its label); a member can only give an account to places they reach, and only a super admin sets `all_bots`. Credentials never reach this app or a model, and a run gets tools from an endpoint the provider builds for one account. **Where a connector reaches:** `all_bots` (every bot, every user) and `workspace_connectors` are the install's and only a super admin sets them; `bot_connectors.user_id` is NOT NULL, so a bot row is always personal to whoever made it and shows only in their runs (`botConnectorsSql`). Runs get deferred tools through `openBotConnectors` (`__`, or `-__` when the user has more than one account) and `ConnectorsNote`, opened beside `openBotExtensions`/`openBotBrowsers` in replies and task runs. Tool names and the action cap (`connectors_actions_per_run`, an `app_settings` row, 50 by default) come from the app. Transport is the MCP lane; when a provider can't pin an account at a session endpoint (`endpoint` throws), `ensure-connector-endpoint` records `session_id = "rest"` and the tools call `provider.execute({tool, args, account})` with the account, so the model's surface never changes. Composio's tool router answers with a URL and no headers and rejects a keyless call (401 "API key is required"), so the adapter sends the connection's project key as `x-api-key` on every session call; a cached session whose stored headers can't be read is rebuilt, never used keyless. **Bots never make or change a connector:** a missing account in an attended reply makes the app create `connector_requests` and show `[connect:ID]` (`ConnectRefCard`, the sign-in opened from there, then read by asking the provider's accounts), and a note line says so; a task, routine, hook call or crew request never gets the card. **The settings page lists connections only** (super admin: add, edit, delete, sync; everyone: their own sign-in); each connection's apps live at `/admin/settings/connectors/`, `ConnectorAppsPageSize` (24) a page, searched on the server over name, app and description by `grabConnectorApps`, so a connection holding 1,842 apps never renders them all; that read puts apps with a connected account the viewer can see first and filters to `all` / `connected` / `unconnected` (`ConnectorAppFilters`), returning each tab's count with the page. A row's one assignment control is who gets the app; its account chips (`ConnectorAccounts`) show the label and where each is in force, "New connection" opens the sign-in modal (the app's logo beside its title, Connect the only primary button), an account chip opens its own modal: the name, `all_bots` and the bots and workspaces it reaches (reach-checked lists), and Disconnect; the row's New connection line leads with how many of the app's accounts are connected (`N accounts`, in the success colour, and nothing while none is). A conversation's composer tools modal ends with a **Connectors** section (`ComposerConnectorsSection`), read by `grabBotConnectors` when the modal opens (never by the page): each app the bot reaches there (its title tagged with the connection's name, and with the account's label when an account given here is what brings it), where it comes from (every bot, this workspace, only you, or an account given here) and the accounts that reach there (this user's own, whatever their status, and connected ones given here, with their owner), or that none is connected yet, with a Manage link to Settings > Connectors, and Add/remove: Add opens a modal that walks down from the connection, to the app (searched on the server through `grabAttachableConnectors` with its `connection_id`, 20 at a time, listing only apps with a connected account of the user's and never one they already attached to this bot), to that app's own accounts (`grabConnectorOwnAccounts`, which leaves out an account already given here) or All accounts for the app alone, and gives the app to this bot for this user (`connectors/set-bot`, so every account they have of it reaches the bot, ones connected later included), plus the picked account to this bot (`connectors/set-account-access`); Remove is the row's X (shown when `entry.removable`) and calls `connectors/detach`, taking away this user's own attachment there and their own account given to that bot alone, while a workspace's, the install's or an account given to every bot shows no X. `sync-connectors` (`*/15`) refreshes every connection's apps, assigned apps' tools and the accounts a sign-in left waiting (pending requests and any account not yet `connected`, so an OAuth callback that lands after the poll is picked up); `prune-connector-requests` takes old requests. A request is only settled as connected once the provider reports an account connected, never on a sync that found none. Deleting a connection removes its apps, sessions, requests, accounts and grants explicitly. Connectors travel in no extension bundle. +A user's access to an outside app (Gmail, Slack, ...) as themselves, reached through a provider that holds the OAuth app and the connected account (Settings > Connectors). Composio is the first provider: one file under `src/harness/connectors/providers/` and the preset in `src/dict/connector-dict.ts`. **A connection is one provider account, not an app**: `connector_connections` has one row per provider account (Composio Personal, Composio Work, ...), each with its own encrypted `api_key`, added in Settings > Connectors; the form's **paradigm** (`provider`, Composio the first) decides how that connection's apps are reached, and more paradigms can be added; that form names the key a paradigm wants and links where to make it (`key_help`, `key_url`, `key_url_title` in the preset: Composio wants a project API key `ak_...` from its Project Settings > API Keys, not a `ck_...` key made for `connect.composio.dev/mcp`, whose router signs everyone in as the key's owner); `connectorProviderFor` builds the provider from that key, so no install-wide key is read from Environment. `syncConnectorConnection({ connection_id })` reads every app the connection offers into `connectors` (`connectors.connection_id`; `planConnectorSync` derives each slug and names a second connection's app after it, `gmail-work`), so nothing is added or edited app by app; a stored app follows the provider's name, description and logo only, keeping its slug, reach and accounts. A thousand apps cost nothing until one is used: its tools are read when it is first given to a bot or workspace (`syncConnector` from `set-bot-connector`/`set-connector-access` when `tools` is empty) and by the cron for assigned apps alone. **An account is a person's own** (`connector_accounts.user_id`), several per app, and its owner's runs always reach it; its owner or a super admin can also give it out (`connector_accounts.all_bots`, `connector_account_workspaces`, `connector_account_bots`, written by `setConnectorAccountAccess`), so every run in a workspace or on a bot reaches it too, whoever signed in (and giving an account out brings its app along to that bot or workspace, since `botConnectorsSql` counts a connected account given there), and the session is built as the account's owner (`openBotConnectors` passes `account.user_id`, and a shared line names whose account it is). Its owner or a super admin renames it (`saveConnectorAccount`, which regenerates the slug, so a namespace follows its label); a member can only give an account to places they reach, and only a super admin sets `all_bots`. **A second account is a new sign-in, never the first one reused:** `startConnectorConnection` always makes a link (an account already connected never stands in for the new one), and a request is settled only by the account it made (`connector_requests.provider_account_id`, matched in `settleRequests` and `grabConnectorRequestView`), so a request the user has not finished cannot show the label of an account that was already there. The sign-in itself must never replace the app's earlier account: Composio's plain `connected_accounts/link` does exactly that, so the adapter first opens a multi-account tool-router session and takes its link (`/tool_router/session//link`), which keeps the other sign-ins; tool sessions stay single-account, pinning one in `connected_accounts`, since a multi-account session exposes only the router's meta tools and refuses `preload`. Credentials never reach this app or a model, and a run gets tools from an endpoint the provider builds for one account. **Where a connector reaches:** `all_bots` (every bot, every user) and `workspace_connectors` are the install's and only a super admin sets them; `bot_connectors.user_id` is NOT NULL, so a bot row is always personal to whoever made it and shows only in their runs (`botConnectorsSql`). Runs get deferred tools through `openBotConnectors` (`__`, or `-__` when the user has more than one account) and `ConnectorsNote`, opened beside `openBotExtensions`/`openBotBrowsers` in replies and task runs. Tool names and the action cap (`connectors_actions_per_run`, an `app_settings` row, 50 by default) come from the app. Transport is the MCP lane; when a provider can't pin an account at a session endpoint (`endpoint` throws), `ensure-connector-endpoint` records `session_id = "rest"` and the tools call `provider.execute({tool, args, account})` with the account, so the model's surface never changes. Composio's tool router answers with a URL and no headers and rejects a keyless call (401 "API key is required"), so the adapter sends the connection's project key as `x-api-key` on every session call; a cached session whose stored headers can't be read is rebuilt, never used keyless. **Bots never make or change a connector:** a missing account in an attended reply makes the app create `connector_requests` and show `[connect:ID]` (`ConnectRefCard`, the sign-in opened from there, then read by asking the provider's accounts), and a note line says so; a task, routine, hook call or crew request never gets the card. **The settings page lists connections only** (super admin: add, edit, delete, sync; everyone: their own sign-in); each connection's apps live at `/admin/settings/connectors/`, `ConnectorAppsPageSize` (24) a page, searched on the server over name, app and description by `grabConnectorApps`, so a connection holding 1,842 apps never renders them all; that read puts apps with a connected account the viewer can see first and filters to `all` / `connected` / `unconnected` (`ConnectorAppFilters`), returning each tab's count with the page. A row's one assignment control is who gets the app; its account chips (`ConnectorAccounts`) show the label and where each is in force, "New connection" opens the sign-in modal (the app's logo beside its title, Connect the only primary button), an account chip opens its own modal: the name, `all_bots` and the bots and workspaces it reaches (reach-checked lists), and Disconnect; the row's New connection line leads with how many of the app's accounts are connected (`N accounts`, in the success colour, and nothing while none is). A conversation's composer tools modal ends with a **Connectors** section (`ComposerConnectorsSection`), read by `grabBotConnectors` when the modal opens (never by the page): each app the bot reaches there (its title tagged with the connection's name, and with the account's label when an account given here is what brings it), where it comes from (every bot, this workspace, only you, or an account given here) and the accounts that reach there (this user's own, whatever their status, and connected ones given here, with their owner), or that none is connected yet, with a Manage link to Settings > Connectors, and Add/remove: Add opens a modal that walks down from the connection, to the app (searched on the server through `grabAttachableConnectors` with its `connection_id`, 20 at a time, listing only apps with a connected account of the user's and never one they already attached to this bot), to that app's own accounts (`grabConnectorOwnAccounts`, which leaves out an account already given here) or All accounts for the app alone, and gives the app to this bot for this user (`connectors/set-bot`, so every account they have of it reaches the bot, ones connected later included), plus the picked account to this bot (`connectors/set-account-access`); Remove is the row's X (shown when `entry.removable`) and calls `connectors/detach`, taking away this user's own attachment there and their own account given to that bot alone, while a workspace's, the install's or an account given to every bot shows no X. `sync-connectors` (`*/15`) refreshes every connection's apps, assigned apps' tools and the accounts a sign-in left waiting (pending requests and any account not yet `connected`, so an OAuth callback that lands after the poll is picked up); `prune-connector-requests` takes old requests. A request is only settled as connected once the provider reports an account connected, never on a sync that found none. Deleting a connection removes its apps, sessions, requests, accounts and grants explicitly. Connectors travel in no extension bundle. ### Knowledgebases diff --git a/package.json b/package.json index 8a5e5be1..6ecbbe36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cobble", - "version": "0.27.0", + "version": "0.27.1", "module": "index.ts", "type": "module", "private": true, diff --git a/src/functions/backend/db/connectors/create-connector-request.ts b/src/functions/backend/db/connectors/create-connector-request.ts index be0e199d..1583a3d5 100644 --- a/src/functions/backend/db/connectors/create-connector-request.ts +++ b/src/functions/backend/db/connectors/create-connector-request.ts @@ -40,10 +40,11 @@ export default async function createConnectorRequest({ label, }: Params): Promise { const now = Date.now(); + const name = label || connector.name; const open = ( await BunSQLite.sql({ - sql: `SELECT * FROM connector_requests WHERE connector_id = ? AND user_id = ? AND status = 'pending' AND expires_at > ? ORDER BY id DESC LIMIT 1`, - values: [connector.id, user_id, now], + sql: `SELECT * FROM connector_requests WHERE connector_id = ? AND user_id = ? AND label = ? AND status = 'pending' AND expires_at > ? ORDER BY id DESC LIMIT 1`, + values: [connector.id, user_id, name, now], }) ).payload?.[0]; @@ -53,7 +54,7 @@ export default async function createConnectorRequest({ const started = await provider.startConnect({ app: connector.app, user_id, - label: label || connector.name, + label: name, auth_config_id: connector.auth_config_id, }); @@ -84,7 +85,7 @@ export default async function createConnectorRequest({ user_id, bot_id: bot_id ?? undefined, bot_session_id: session_id ?? undefined, - label: label || connector.name, + label: name, url: started.url, provider_account_id: started.provider_account_id || undefined, status: "pending", diff --git a/src/functions/backend/db/connectors/grab-connector-request-view.ts b/src/functions/backend/db/connectors/grab-connector-request-view.ts index e2f991bd..24c6071a 100644 --- a/src/functions/backend/db/connectors/grab-connector-request-view.ts +++ b/src/functions/backend/db/connectors/grab-connector-request-view.ts @@ -40,15 +40,23 @@ export default async function grabConnectorRequestView({ request_id, user_id }: }); } + const request_account = String(row.provider_account_id || ""); + + // Only the account this request made counts: any connected one would + // close a second sign-in with the first account's label, which is how a + // second Gmail account looked already connected. const accountRows = ( await BunSQLite.sql({ - sql: `SELECT * FROM connector_accounts WHERE connector_id = ? AND user_id = ? AND status = 'connected' ORDER BY id ASC`, - values: [connector.id, Number(user_id)], + sql: request_account + ? `SELECT * FROM connector_accounts WHERE connector_id = ? AND user_id = ? AND status = 'connected' AND provider_account_id = ? LIMIT 1` + : `SELECT * FROM connector_accounts WHERE connector_id = ? AND user_id = ? AND status = 'connected' AND created_at >= ? ORDER BY id ASC LIMIT 1`, + values: request_account + ? [connector.id, Number(user_id), request_account] + : [connector.id, Number(user_id), Number(row.created_at || 0)], }) ).payload || []; - const matching = - accountRows.find((account) => account.provider_account_id == row.provider_account_id) || accountRows[0] || null; + const matching = accountRows[0] || null; if (status == "pending" && matching) { status = "connected"; diff --git a/src/functions/backend/db/connectors/start-connector-connection.ts b/src/functions/backend/db/connectors/start-connector-connection.ts index 791e2966..ee6c8987 100644 --- a/src/functions/backend/db/connectors/start-connector-connection.ts +++ b/src/functions/backend/db/connectors/start-connector-connection.ts @@ -18,18 +18,18 @@ type Params = { type Result = { /** - * Null when the user already has a connected account: there is nothing - * to sign in to. + * The sign-in link. Always made: a person can keep several accounts on + * one app (a work Gmail beside a personal one), so an account already + * connected never stands in for the new one. */ request: ConnectorRequestPayload | null; accounts: ConnectorAccountRecord[]; }; /** - * Starts (or finds) a sign-in for one connector, after reading what the - * provider already has: a user who connected it before gets no second link. - * The request outlives the page that made it, so the card under a reply and - * Settings > Connectors both read it the same way. + * Starts a sign-in for one connector. The request outlives the page that + * made it, so the card under a reply and Settings > Connectors both read it + * the same way. */ export default async function startConnectorConnection({ user_id, @@ -43,9 +43,6 @@ export default async function startConnectorConnection({ if (!connector.enabled) throw new AppError(`${connector.name} is turned off, so it can't be connected right now.`); const accounts = await syncConnectorAccounts({ user_id, connector_id: connector.id, label }); - const connected = accounts.filter((account) => account.status == "connected"); - - if (connected.length) return { request: null, accounts }; const request = await createConnectorRequest({ user_id: Number(user_id), diff --git a/src/functions/backend/db/connectors/sync-connector-accounts.ts b/src/functions/backend/db/connectors/sync-connector-accounts.ts index 293dd361..149bc552 100644 --- a/src/functions/backend/db/connectors/sync-connector-accounts.ts +++ b/src/functions/backend/db/connectors/sync-connector-accounts.ts @@ -72,8 +72,17 @@ export default async function syncConnectorAccounts({ user_id, connector_id, lab await BunSQLite.sql({ sql: `UPDATE connector_accounts SET is_default = 1 WHERE id = ?`, values: [firstConnected] }); } - if (accounts.some((account) => account.status == "connected")) { - await settleRequests({ connector_id: connector.id, user_id: Number(user_id) }); + const connected_ids = accounts + .filter((account) => account.status == "connected") + .map((account) => account.provider_account_id) + .filter(Boolean); + + if (connected_ids.length) { + await settleRequests({ + connector_id: connector.id, + user_id: Number(user_id), + provider_account_ids: connected_ids, + }); } return grabUserAccounts({ connector_id: connector.id, user_id: Number(user_id) }); @@ -151,20 +160,35 @@ async function upsertAccount({ connector_id, user_id, account, fallback_label }: type SettleParams = { connector_id: number; user_id: number; + provider_account_ids: string[]; }; /** - * A connect request is done the moment an account is connected: the card - * under the reply says so instead of offering the link again. + * A connect request is done only when the account it made is connected: a + * second sign-in must not be closed by the first account that was already + * there (`provider_account_id` is what the provider returned for this link). + * A request the provider gave no id for falls back to an account created + * after the request. */ -async function settleRequests({ connector_id, user_id }: SettleParams) { +async function settleRequests({ connector_id, user_id, provider_account_ids }: SettleParams) { const now = Date.now(); + const placeholders = provider_account_ids.map(() => "?").join(", "); await BunSQLite.sql({ sql: `UPDATE connector_requests SET status = 'connected', updated_at = ? WHERE connector_id = ? AND user_id = ? AND status = 'pending' - AND expires_at > ?`, - values: [now, connector_id, user_id, now], + AND expires_at > ? + AND ( + (provider_account_id != '' AND provider_account_id IN (${placeholders})) + OR (provider_account_id == '' AND EXISTS ( + SELECT 1 FROM connector_accounts a + WHERE a.connector_id = connector_requests.connector_id + AND a.user_id = connector_requests.user_id + AND a.status = 'connected' + AND a.created_at >= connector_requests.created_at + )) + )`, + values: [now, connector_id, user_id, now, ...provider_account_ids], }); } diff --git a/src/harness/connectors/providers/composio.test.ts b/src/harness/connectors/providers/composio.test.ts index 6fa38a86..5780005c 100644 --- a/src/harness/connectors/providers/composio.test.ts +++ b/src/harness/connectors/providers/composio.test.ts @@ -132,16 +132,14 @@ describe("composioConnectorProvider", () => { test("starts a sign-in with the app's sign-in setup and keeps what the provider returns", async () => { const { fetchImpl, calls } = stub({ - answer: ({ url, method }) => - url.pathname.endsWith("/auth_configs") && method == "GET" - ? { body: { items: [{ id: "ac_1", auth_scheme: "OAUTH2" }] } } - : { - body: { - redirect_url: "https://connect/x", - connected_account_id: "ca_9", - expires_at: "2027-01-01T00:00:00Z", - }, - }, + answer: ({ url, method }) => { + if (url.pathname.endsWith("/tool_router/session")) return { status: 201, body: { session_id: "trs_1" } }; + if (url.pathname.endsWith("/tool_router/session/trs_1/link")) { + return { status: 201, body: { redirect_url: "https://connect/x", connected_account_id: "ca_9", expires_at: "2027-01-01T00:00:00Z" } }; + } + + return method == "GET" ? { body: { items: [{ id: "ac_1", auth_scheme: "OAUTH2" }] } } : { body: {} }; + }, }); const started = await composioConnectorProvider({ key: "k", fetchImpl }).startConnect({ @@ -155,20 +153,24 @@ describe("composioConnectorProvider", () => { expect(started.provider_account_id).toBe("ca_9"); expect(started.expires_at).toBe(Date.parse("2027-01-01T00:00:00Z")); - const link = calls.find((call) => call.url.pathname.endsWith("/connected_accounts/link"))!; + const session = calls.find((call) => call.url.pathname.endsWith("/tool_router/session"))!; - expect(link.body.toolkit_slug).toBe("gmail"); + expect(session.body.multi_account).toEqual({ enable: true, max_accounts_per_toolkit: 5 }); + + const link = calls.find((call) => call.url.pathname.endsWith("/tool_router/session/trs_1/link"))!; + + expect(link.body.toolkit).toBe("gmail"); expect(link.body.auth_config_id).toBe("ac_1"); - expect(link.body.account_label).toBe("Work"); expect(link.body.callback_url).toBeUndefined(); + expect(calls.some((call) => call.url.pathname.endsWith("/connected_accounts/link"))).toBe(false); }); test("makes a managed sign-in setup when the app has none", async () => { const { fetchImpl, calls } = stub({ answer: ({ url, method }) => { - if (!url.pathname.endsWith("/auth_configs")) { - return { body: { redirect_url: "https://connect/y" } }; - } + if (url.pathname.endsWith("/tool_router/session")) return { status: 201, body: { session_id: "trs_1" } }; + if (url.pathname.endsWith("/link")) return { status: 201, body: { redirect_url: "https://connect/y" } }; + if (!url.pathname.endsWith("/auth_configs")) return { body: {} }; return method == "POST" ? { status: 201, body: { auth_config: { id: "ac_new" } } } : { body: { items: [] } }; }, diff --git a/src/harness/connectors/providers/composio.ts b/src/harness/connectors/providers/composio.ts index 24eca6bf..086a4036 100644 --- a/src/harness/connectors/providers/composio.ts +++ b/src/harness/connectors/providers/composio.ts @@ -23,6 +23,8 @@ type Params = { const DefaultBaseUrl = "https://backend.composio.dev/api/v3.1"; const PageLimit = 100; +/** Composio keeps one account per app unless a session allows more; 5 is its own ceiling in the docs. */ +const MaxAccountsPerToolkit = 5; const MaxPages = 20; const Statuses: Record = { @@ -230,19 +232,36 @@ export default function composioConnectorProvider({ key, base_url, fetchImpl }: } satisfies ConnectorEndpoint; }, - async startConnect({ app, user_id, label, auth_config_id, callback_url }: StartConnectParams) { + async startConnect({ app, user_id, auth_config_id, callback_url }: StartConnectParams) { const config = await authConfigFor({ app, auth_config_id }); + // A plain connected-accounts link replaces the app's account for + // that user, so a second sign-in would take the first one away. + // A multi-account session keeps both, which is what a connection + // named "Work" beside one named "Personal" needs. + const session = await request({ + path: "/tool_router/session", + method: "POST", + what: `a sign-in session for ${app}`, + body: { + user_id: `cobble-user-${user_id}`, + toolkits: { enable: [app] }, + multi_account: { enable: true, max_accounts_per_toolkit: MaxAccountsPerToolkit }, + }, + }); + + const session_id = session.session_id || session.id; + + if (!session_id) throw new AppError(`Composio didn't open a sign-in session for ${app}.`); + const answer = await request({ - path: "/connected_accounts/link", + path: `/tool_router/session/${session_id}/link`, method: "POST", what: `a sign-in link for ${app}`, body: { - toolkit_slug: app, - user_id: `cobble-user-${user_id}`, + toolkit: app, auth_config_id: config, - callback_url, - ...(label ? { account_label: label } : {}), + ...(callback_url ? { callback_url } : {}), }, }); diff --git a/src/pages/admin/settings/connectors/(partials)/connector-connect-modal.tsx b/src/pages/admin/settings/connectors/(partials)/connector-connect-modal.tsx index 598c33dd..c1e85e8c 100644 --- a/src/pages/admin/settings/connectors/(partials)/connector-connect-modal.tsx +++ b/src/pages/admin/settings/connectors/(partials)/connector-connect-modal.tsx @@ -39,7 +39,21 @@ export default function ConnectorConnectModal({ connector, onConnected, onCancel title={`New ${connector.name} connection`} description="The sign-in happens at the provider, and it keeps the credentials. Your bots only ever reach the account it makes." > -
{ setError(""); connect.start({ connector_id: connector.id, label }); }}> + { + const name = label.trim(); + + if (!name) { + setError("Name this connection, so you can tell it apart from another account of the same app."); + + return; + } + + setError(""); + connect.start({ connector_id: connector.id, label: name }); + }} + >