Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(cursor): a per-user default model, chosen in settings (#5957)

Wolf Mermelsteinb1ce89cd1bd0
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.json
index 096fa9d436..827cbefdd4 100644
--- a/.github/workspace-dep-closures.json
+++ b/.github/workspace-dep-closures.json
@@ -988,6 +988,7 @@
"crates/cowlike",
"crates/crm",
"crates/cursor_api_key",
+ "crates/cursor_cloud_agents",
"crates/database_env_vars",
"crates/decode_jwt",
"crates/document_storage_service_client",
diff --git a/.sqlx/query-61901feef40d440764198abc530ab1d3c70df62f7464438b229d8cdd8ce00ccc.json b/.sqlx/query-61901feef40d440764198abc530ab1d3c70df62f7464438b229d8cdd8ce00ccc.json
new file mode 100644
index 0000000000..63f6ee9106
--- /dev/null
+++ b/.sqlx/query-61901feef40d440764198abc530ab1d3c70df62f7464438b229d8cdd8ce00ccc.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE cursor_configs\n SET default_model_id = $2,\n updated_at = NOW()\n WHERE user_id = $1\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "61901feef40d440764198abc530ab1d3c70df62f7464438b229d8cdd8ce00ccc"
+}
diff --git a/.sqlx/query-72dbba600bc88669c90317e4c215a518d3f93fa0465046486b18d01029b0059b.json b/.sqlx/query-703614ad73a7e8473485059b305aa07056ebc1f111109cb263f39a74f27ad92c.json
similarity index 50%
rename from .sqlx/query-72dbba600bc88669c90317e4c215a518d3f93fa0465046486b18d01029b0059b.json
rename to .sqlx/query-703614ad73a7e8473485059b305aa07056ebc1f111109cb263f39a74f27ad92c.json
index d8162d5137..dfd24d836f 100644
--- a/.sqlx/query-72dbba600bc88669c90317e4c215a518d3f93fa0465046486b18d01029b0059b.json
+++ b/.sqlx/query-703614ad73a7e8473485059b305aa07056ebc1f111109cb263f39a74f27ad92c.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO cursor_api_keys (\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id\n )\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (user_id) DO UPDATE SET\n key_ciphertext = EXCLUDED.key_ciphertext,\n encryption_version = EXCLUDED.encryption_version,\n kms_key_id = EXCLUDED.kms_key_id,\n updated_at = NOW()\n RETURNING\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id,\n created_at,\n updated_at\n ",
+ "query": "\n INSERT INTO cursor_configs (\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id\n )\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (user_id) DO UPDATE SET\n key_ciphertext = EXCLUDED.key_ciphertext,\n encryption_version = EXCLUDED.encryption_version,\n kms_key_id = EXCLUDED.kms_key_id,\n updated_at = NOW()\n RETURNING\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id,\n default_model_id,\n created_at,\n updated_at\n ",
"describe": {
"columns": [
{
@@ -25,11 +25,16 @@
},
{
"ordinal": 4,
+ "name": "default_model_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
"name": "created_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 5,
+ "ordinal": 6,
"name": "updated_at",
"type_info": "Timestamptz"
}
@@ -47,9 +52,10 @@
false,
false,
false,
+ true,
false,
false
]
},
- "hash": "72dbba600bc88669c90317e4c215a518d3f93fa0465046486b18d01029b0059b"
+ "hash": "703614ad73a7e8473485059b305aa07056ebc1f111109cb263f39a74f27ad92c"
}
diff --git a/.sqlx/query-55fb80442146d532ec8f9a8136a8e9da3d48386f72889f254ffd97543d914a7b.json b/.sqlx/query-b54607c3171e2f227e3f001a8bb2612ec3944e0c130df58c40fda8fea8335cf9.json
similarity index 53%
rename from .sqlx/query-55fb80442146d532ec8f9a8136a8e9da3d48386f72889f254ffd97543d914a7b.json
rename to .sqlx/query-b54607c3171e2f227e3f001a8bb2612ec3944e0c130df58c40fda8fea8335cf9.json
index 0097a5b635..c130915198 100644
--- a/.sqlx/query-55fb80442146d532ec8f9a8136a8e9da3d48386f72889f254ffd97543d914a7b.json
+++ b/.sqlx/query-b54607c3171e2f227e3f001a8bb2612ec3944e0c130df58c40fda8fea8335cf9.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "DELETE FROM cursor_api_keys WHERE user_id = $1",
+ "query": "DELETE FROM cursor_configs WHERE user_id = $1",
"describe": {
"columns": [],
"parameters": {
@@ -10,5 +10,5 @@
},
"nullable": []
},
- "hash": "55fb80442146d532ec8f9a8136a8e9da3d48386f72889f254ffd97543d914a7b"
+ "hash": "b54607c3171e2f227e3f001a8bb2612ec3944e0c130df58c40fda8fea8335cf9"
}
diff --git a/.sqlx/query-219dae4b7c1bdcf32e6e78baab6a728bd7dfc09138f53894790ac52b2adb69dc.json b/.sqlx/query-e96ee7a01c4296009ee3f3e9639ee559000daf0746a2d9a72b028c8450a56534.json
similarity index 73%
rename from .sqlx/query-219dae4b7c1bdcf32e6e78baab6a728bd7dfc09138f53894790ac52b2adb69dc.json
rename to .sqlx/query-e96ee7a01c4296009ee3f3e9639ee559000daf0746a2d9a72b028c8450a56534.json
index bb720bb64b..78738d752a 100644
--- a/.sqlx/query-219dae4b7c1bdcf32e6e78baab6a728bd7dfc09138f53894790ac52b2adb69dc.json
+++ b/.sqlx/query-e96ee7a01c4296009ee3f3e9639ee559000daf0746a2d9a72b028c8450a56534.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id,\n created_at,\n updated_at\n FROM cursor_api_keys\n WHERE user_id = $1\n ",
+ "query": "\n SELECT\n user_id,\n key_ciphertext,\n encryption_version,\n kms_key_id,\n default_model_id,\n created_at,\n updated_at\n FROM cursor_configs\n WHERE user_id = $1\n ",
"describe": {
"columns": [
{
@@ -25,11 +25,16 @@
},
{
"ordinal": 4,
+ "name": "default_model_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
"name": "created_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 5,
+ "ordinal": 6,
"name": "updated_at",
"type_info": "Timestamptz"
}
@@ -44,9 +49,10 @@
false,
false,
false,
+ true,
false,
false
]
},
- "hash": "219dae4b7c1bdcf32e6e78baab6a728bd7dfc09138f53894790ac52b2adb69dc"
+ "hash": "e96ee7a01c4296009ee3f3e9639ee559000daf0746a2d9a72b028c8450a56534"
}
diff --git a/Cargo.lock b/Cargo.lock
index b2c0eea362..b4a25e9fae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1470,6 +1470,7 @@ dependencies = [
"cookie",
"cool_asserts",
"cursor_api_key",
+ "cursor_cloud_agents",
"database_env_vars",
"decode_jwt",
"document_storage_service_client",
diff --git a/apps/web/src/features/settings/Cursor.tsx b/apps/web/src/features/settings/Cursor.tsx
index d7e61525eb..d9f1c54027 100644
--- a/apps/web/src/features/settings/Cursor.tsx
+++ b/apps/web/src/features/settings/Cursor.tsx
@@ -2,11 +2,13 @@ import { toast } from '@core/component/Toast/Toast';
import { ThrownResultError } from '@core/util/result';
import {
useCursorApiKeyStatusQuery,
+ useCursorModelsQuery,
useDisconnectCursorApiKey,
useSaveCursorApiKey,
+ useSetCursorDefaultModel,
} from '@queries/auth/cursor-api-key';
import { Button } from '@ui';
-import { createSignal, Match, Show, Switch } from 'solid-js';
+import { createSignal, For, Match, Show, Switch } from 'solid-js';
import { ConnectAction, StatusDot } from './integration-ui';
import { IntegrationRow, SettingsCard, SettingsRow } from './primitives';
@@ -35,6 +37,19 @@ export function CursorCard() {
const [apiKey, setApiKey] = createSignal('');
const registered = () => status.data?.registered ?? false;
+ // Only worth fetching once there is a key to ask Cursor through.
+ const models = useCursorModelsQuery(registered);
+ const setDefaultModel = useSetCursorDefaultModel();
+
+ const handleModelChange = async (modelId: string) => {
+ try {
+ await setDefaultModel.mutateAsync(modelId);
+ toast.success('Default model updated');
+ } catch (error) {
+ toast.failure(failureMessage(error, 'Failed to set your default model'));
+ }
+ };
+
const handleSave = async () => {
const key = apiKey().trim();
if (!key.startsWith(CURSOR_KEY_PREFIX)) {
@@ -129,6 +144,26 @@ export function CursorCard() {
</Switch>
</Show>
</SettingsRow>
+
+ <Show when={registered()}>
+ <SettingsRow
+ label="Default model"
+ description="The model new @cursor sessions start on. You can still switch it per session."
+ >
+ <select
+ class="settings-input w-56"
+ value={status.data?.defaultModelId ?? ''}
+ disabled={setDefaultModel.isPending}
+ onChange={(event) =>
+ void handleModelChange(event.currentTarget.value)
+ }
+ >
+ <For each={models.data?.models ?? []}>
+ {(model) => <option value={model.id}>{model.displayName}</option>}
+ </For>
+ </select>
+ </SettingsRow>
+ </Show>
</SettingsCard>
);
}
diff --git a/apps/web/src/lib/queries/auth/cursor-api-key.ts b/apps/web/src/lib/queries/auth/cursor-api-key.ts
index 39ec1aa4d4..5220badbd9 100644
--- a/apps/web/src/lib/queries/auth/cursor-api-key.ts
+++ b/apps/web/src/lib/queries/auth/cursor-api-key.ts
@@ -15,6 +15,7 @@ import { authKeys } from './keys';
*/
const NOT_CONNECTED: CursorApiKeyStatus = {
registered: false,
+ defaultModelId: null,
updatedAt: null,
};
@@ -70,3 +71,41 @@ export function useDisconnectCursorApiKey() {
},
}));
}
+
+/**
+ * The models the user's Cursor account offers, for the settings dropdown.
+ *
+ * Enabled only once a key is registered: the endpoint asks Cursor live through
+ * that key, and a keyless account has nothing to list. Kept fresh for a while
+ * — the model roster changes rarely, and a settings visit is not worth a round
+ * trip every time.
+ */
+export function useCursorModelsQuery(enabled: () => boolean) {
+ return useQuery(() => ({
+ queryKey: authKeys.cursorModels.queryKey,
+ queryFn: async () =>
+ throwOnErr(async () => await authServiceClient.listCursorModels()),
+ enabled: enabled(),
+ staleTime: 5 * 60 * 1000,
+ }));
+}
+
+/**
+ * Chooses the model the user's sessions start on.
+ *
+ * Invalidates the status query so the picker reflects the stored choice from
+ * one source of truth, exactly as the key mutations do.
+ */
+export function useSetCursorDefaultModel() {
+ return useMutation(() => ({
+ mutationFn: async (modelId: string) =>
+ throwOnErr(
+ async () => await authServiceClient.putCursorDefaultModel(modelId)
+ ),
+ onSuccess: async () => {
+ await queryClient.invalidateQueries({
+ queryKey: authKeys.cursorApiKeyStatus.queryKey,
+ });
+ },
+ }));
+}
diff --git a/apps/web/src/lib/queries/auth/keys.ts b/apps/web/src/lib/queries/auth/keys.ts
index d1e169a9cf..55658c78d2 100644
--- a/apps/web/src/lib/queries/auth/keys.ts
+++ b/apps/web/src/lib/queries/auth/keys.ts
@@ -2,6 +2,7 @@ import { createQueryKeys } from '@lukemorales/query-key-factory';
export const authKeys = createQueryKeys('auth', {
cursorApiKeyStatus: null,
+ cursorModels: null,
githubLinkStatus: null,
userInfo: null,
userName: (userId: string) => ({
diff --git a/apps/web/src/lib/service-clients/service-auth/client.ts b/apps/web/src/lib/service-clients/service-auth/client.ts
index 888d244fbd..d3f6061eb1 100644
--- a/apps/web/src/lib/service-clients/service-auth/client.ts
+++ b/apps/web/src/lib/service-clients/service-auth/client.ts
@@ -16,6 +16,7 @@ import { createSignal } from 'solid-js';
import { fetchWithAuth as _fetchWithAuth } from './fetch';
import type {
CursorApiKeyStatus,
+ CursorModelsResponse,
EnrichGithubPullRequestsProxyRequest,
EnrichGithubPullRequestsResponse,
GithubLinkStatusResponse,
@@ -604,6 +605,39 @@ export const authServiceClient = {
).map((result) => result);
},
+ /**
+ * The models the signed-in user's Cursor account offers, for the settings
+ * dropdown. Asks Cursor live through the stored key, so it needs a connected
+ * account — a caller with none gets the endpoint's own `409` message.
+ */
+ async listCursorModels() {
+ return (
+ await fetchWithAuth<CursorModelsResponse, 'CURSOR_API_KEY_ERROR'>(
+ `${authHost}/cursor-api-key/models`,
+ {
+ method: 'GET',
+ errorResponseHandler: cursorApiKeyErrorResponseHandler,
+ }
+ )
+ ).map((result) => result);
+ },
+
+ /**
+ * Chooses the model the user's sessions start on.
+ */
+ async putCursorDefaultModel(modelId: string) {
+ return (
+ await fetchWithAuth<CursorApiKeyStatus, 'CURSOR_API_KEY_ERROR'>(
+ `${authHost}/cursor-api-key/default-model`,
+ {
+ method: 'PUT',
+ body: JSON.stringify({ modelId }),
+ errorResponseHandler: cursorApiKeyErrorResponseHandler,
+ }
+ )
+ ).map((result) => result);
+ },
+
async checkGithubLinkStatus() {
return (
await fetchWithAuth<
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/client.ts b/apps/web/src/lib/service-clients/service-auth/generated/client.ts
index fe901585c7..bb366c349f 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/client.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/client.ts
@@ -13,6 +13,7 @@ import type {
CreateTeamRequest,
CreateUserRequest,
CursorApiKeyStatus,
+ CursorModelsResponse,
EmptyResponse,
EnrichGithubPullRequestsProxyRequest,
EnrichGithubPullRequestsResponse,
@@ -49,6 +50,7 @@ import type {
PostGetNamesRequestBody,
ProfilePictures,
PutCursorApiKeyRequest,
+ PutCursorDefaultModelRequest,
PutProfilePictureParams,
PutUserNameParams,
ResendFusionauthVerifyUserEmailRequest,
@@ -255,6 +257,148 @@ export const deleteCursorApiKey = async (
} as deleteCursorApiKeyResponse;
};
+/**
+ * Stores the id only; its parameters are resolved from Cursor's own default
+variant at session start. Not validated against the live model list here —
+the settings dropdown offers only real ids, and a stale id degrades to the
+deployment default at spawn rather than failing, so a round trip to Cursor
+on every save would buy nothing.
+ * @summary Choose the model this user's `@cursor` sessions start on.
+ */
+export type putCursorDefaultModelResponse200 = {
+ data: CursorApiKeyStatus;
+ status: 200;
+};
+
+export type putCursorDefaultModelResponse401 = {
+ data: string;
+ status: 401;
+};
+
+export type putCursorDefaultModelResponse403 = {
+ data: ErrorResponse;
+ status: 403;
+};
+
+export type putCursorDefaultModelResponse409 = {
+ data: ErrorResponse;
+ status: 409;
+};
+
+export type putCursorDefaultModelResponseSuccess =
+ putCursorDefaultModelResponse200 & {
+ headers: Headers;
+ };
+export type putCursorDefaultModelResponseError = (
+ | putCursorDefaultModelResponse401
+ | putCursorDefaultModelResponse403
+ | putCursorDefaultModelResponse409
+) & {
+ headers: Headers;
+};
+
+export type putCursorDefaultModelResponse =
+ | putCursorDefaultModelResponseSuccess
+ | putCursorDefaultModelResponseError;
+
+export const getPutCursorDefaultModelUrl = () => {
+ return `/cursor-api-key/default-model`;
+};
+
+export const putCursorDefaultModel = async (
+ putCursorDefaultModelRequest: PutCursorDefaultModelRequest,
+ options?: RequestInit
+): Promise<putCursorDefaultModelResponse> => {
+ const res = await fetch(getPutCursorDefaultModelUrl(), {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(putCursorDefaultModelRequest),
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: putCursorDefaultModelResponse['data'] = body
+ ? JSON.parse(body)
+ : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as putCursorDefaultModelResponse;
+};
+
+/**
+ * Reached only from the settings dropdown, so it decrypts the user's own key
+and asks Cursor directly — the list is per-account and changes, so there is
+nothing to cache statically. Reuses the harness's Cursor client rather than
+reimplementing the `/v1/models` parse, keeping one source of truth for what
+a model is.
+ * @summary List the models the caller's Cursor account offers.
+ */
+export type listCursorModelsResponse200 = {
+ data: CursorModelsResponse;
+ status: 200;
+};
+
+export type listCursorModelsResponse401 = {
+ data: string;
+ status: 401;
+};
+
+export type listCursorModelsResponse403 = {
+ data: ErrorResponse;
+ status: 403;
+};
+
+export type listCursorModelsResponse409 = {
+ data: ErrorResponse;
+ status: 409;
+};
+
+export type listCursorModelsResponse502 = {
+ data: ErrorResponse;
+ status: 502;
+};
+
+export type listCursorModelsResponseSuccess = listCursorModelsResponse200 & {
+ headers: Headers;
+};
+export type listCursorModelsResponseError = (
+ | listCursorModelsResponse401
+ | listCursorModelsResponse403
+ | listCursorModelsResponse409
+ | listCursorModelsResponse502
+) & {
+ headers: Headers;
+};
+
+export type listCursorModelsResponse =
+ | listCursorModelsResponseSuccess
+ | listCursorModelsResponseError;
+
+export const getListCursorModelsUrl = () => {
+ return `/cursor-api-key/models`;
+};
+
+export const listCursorModels = async (
+ options?: RequestInit
+): Promise<listCursorModelsResponse> => {
+ const res = await fetch(getListCursorModelsUrl(), {
+ ...options,
+ method: 'GET',
+ });
+
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
+
+ const data: listCursorModelsResponse['data'] = body ? JSON.parse(body) : {};
+ return {
+ data,
+ status: res.status,
+ headers: res.headers,
+ } as listCursorModelsResponse;
+};
+
/**
* @summary Verifies the user's primary email for FusionAuth
*/
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatus.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatus.ts
index 915312d00b..abfc5cafbb 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatus.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatus.ts
@@ -4,6 +4,7 @@
* authentication_service
* OpenAPI spec version: 0.1.0
*/
+import type { CursorApiKeyStatusDefaultModelId } from './cursorApiKeyStatusDefaultModelId';
import type { CursorApiKeyStatusUpdatedAt } from './cursorApiKeyStatusUpdatedAt';
/**
@@ -18,6 +19,10 @@ operator information: a user who sees it cannot act on it, and a service
that cannot reach KMS does not start.
*/
export interface CursorApiKeyStatus {
+ /** The Cursor model id this user's sessions start on, when they have
+chosen one. `None` means the deployment default is in effect — the
+settings dropdown shows that as its resting value. */
+ defaultModelId?: CursorApiKeyStatusDefaultModelId;
/** Whether this user has a key stored. */
registered: boolean;
/** When the stored key was last replaced, if there is one. */
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatusDefaultModelId.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatusDefaultModelId.ts
new file mode 100644
index 0000000000..e019216495
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorApiKeyStatusDefaultModelId.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The Cursor model id this user's sessions start on, when they have
+chosen one. `None` means the deployment default is in effect — the
+settings dropdown shows that as its resting value.
+ */
+export type CursorApiKeyStatusDefaultModelId = string | null;
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelOption.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelOption.ts
new file mode 100644
index 0000000000..0cc8adce83
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelOption.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * One model the settings dropdown can offer.
+
+Just id and name: the dropdown lists models, not the hundreds of parameter
+variants each carries. The chosen id's parameters are resolved to Cursor's
+default variant at session start.
+ */
+export interface CursorModelOption {
+ /** The human-readable name, e.g. `Cursor Grok 4.6`. */
+ displayName: string;
+ /** The id to store and send, e.g. `grok-4.6`. */
+ id: string;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelsResponse.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelsResponse.ts
new file mode 100644
index 0000000000..ce12585a83
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/cursorModelsResponse.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { CursorModelOption } from './cursorModelOption';
+
+/**
+ * The models this account may choose from.
+ */
+export interface CursorModelsResponse {
+ /** The offered models, in the order Cursor returned them. */
+ models: CursorModelOption[];
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
index fbcded271a..7733234f6c 100644
--- a/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/index.ts
@@ -19,7 +19,10 @@ export * from './createPortalSessionRequest';
export * from './createTeamRequest';
export * from './createUserRequest';
export * from './cursorApiKeyStatus';
+export * from './cursorApiKeyStatusDefaultModelId';
export * from './cursorApiKeyStatusUpdatedAt';
+export * from './cursorModelOption';
+export * from './cursorModelsResponse';
export * from './emptyResponse';
export * from './enrichedGithubPullRequest';
export * from './enrichedGithubPullRequestAdditions';
@@ -100,6 +103,8 @@ export * from './postGetNamesRequestBody';
export * from './profilePictureQueryParams';
export * from './profilePictures';
export * from './putCursorApiKeyRequest';
+export * from './putCursorDefaultModelRequest';
+export * from './putCursorDefaultModelRequestModelId';
export * from './putProfilePictureParams';
export * from './putUserNameParams';
export * from './putUserNameQueryParams';
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequest.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequest.ts
new file mode 100644
index 0000000000..77b9370480
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequest.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { PutCursorDefaultModelRequestModelId } from './putCursorDefaultModelRequestModelId';
+
+/**
+ * The model the user chose for their sessions.
+ */
+export interface PutCursorDefaultModelRequest {
+ /** A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and
+fall back to the deployment default. */
+ modelId?: PutCursorDefaultModelRequestModelId;
+}
diff --git a/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequestModelId.ts b/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequestModelId.ts
new file mode 100644
index 0000000000..6cccc05170
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-auth/generated/schemas/putCursorDefaultModelRequestModelId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * authentication_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and
+fall back to the deployment default.
+ */
+export type PutCursorDefaultModelRequestModelId = string | null;
diff --git a/apps/web/src/lib/service-clients/service-auth/openapi.json b/apps/web/src/lib/service-clients/service-auth/openapi.json
index 3021e2c692..9757c8c8b6 100644
--- a/apps/web/src/lib/service-clients/service-auth/openapi.json
+++ b/apps/web/src/lib/service-clients/service-auth/openapi.json
@@ -146,6 +146,126 @@
}
}
},
+ "/cursor-api-key/default-model": {
+ "put": {
+ "tags": ["crate::api::cursor_api_key::put_cursor_default_model"],
+ "summary": "Choose the model this user's `@cursor` sessions start on.",
+ "description": "Stores the id only; its parameters are resolved from Cursor's own default\nvariant at session start. Not validated against the live model list here —\nthe settings dropdown offers only real ids, and a stale id degrades to the\ndeployment default at spawn rather than failing, so a round trip to Cursor\non every save would buy nothing.",
+ "operationId": "put_cursor_default_model",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PutCursorDefaultModelRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CursorApiKeyStatus"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/cursor-api-key/models": {
+ "get": {
+ "tags": ["crate::api::cursor_api_key::list_cursor_models"],
+ "summary": "List the models the caller's Cursor account offers.",
+ "description": "Reached only from the settings dropdown, so it decrypts the user's own key\nand asks Cursor directly — the list is per-account and changes, so there is\nnothing to cache statically. Reuses the harness's Cursor client rather than\nreimplementing the `/v1/models` parse, keeping one source of truth for what\na model is.",
+ "operationId": "list_cursor_models",
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CursorModelsResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "502": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/email/fusionauth/verify/{verification_id}": {
"get": {
"tags": ["email::verify_fusionauth_user_email"],
@@ -3791,6 +3911,10 @@
"description": "What settings needs to render the Cursor connection.\n\nDeliberately thin. `registered` drives the whole UI; `updatedAt` lets it say\nwhen the key was last replaced, which is the only thing a user can check\nagainst their own memory when a session starts failing.\n\nDeliberately *not* reporting anything about the deployment itself. That is\noperator information: a user who sees it cannot act on it, and a service\nthat cannot reach KMS does not start.",
"required": ["registered"],
"properties": {
+ "defaultModelId": {
+ "type": ["string", "null"],
+ "description": "The Cursor model id this user's sessions start on, when they have\nchosen one. `None` means the deployment default is in effect — the\nsettings dropdown shows that as its resting value."
+ },
"registered": {
"type": "boolean",
"description": "Whether this user has a key stored."
@@ -3802,6 +3926,35 @@
}
}
},
+ "CursorModelOption": {
+ "type": "object",
+ "description": "One model the settings dropdown can offer.\n\nJust id and name: the dropdown lists models, not the hundreds of parameter\nvariants each carries. The chosen id's parameters are resolved to Cursor's\ndefault variant at session start.",
+ "required": ["id", "displayName"],
+ "properties": {
+ "displayName": {
+ "type": "string",
+ "description": "The human-readable name, e.g. `Cursor Grok 4.6`."
+ },
+ "id": {
+ "type": "string",
+ "description": "The id to store and send, e.g. `grok-4.6`."
+ }
+ }
+ },
+ "CursorModelsResponse": {
+ "type": "object",
+ "description": "The models this account may choose from.",
+ "required": ["models"],
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CursorModelOption"
+ },
+ "description": "The offered models, in the order Cursor returned them."
+ }
+ }
+ },
"EmptyResponse": {
"type": "object",
"description": "Empty response is required due to custom fetch forcing `response.json()`"
@@ -4588,6 +4741,16 @@
}
}
},
+ "PutCursorDefaultModelRequest": {
+ "type": "object",
+ "description": "The model the user chose for their sessions.",
+ "properties": {
+ "modelId": {
+ "type": ["string", "null"],
+ "description": "A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and\nfall back to the deployment default."
+ }
+ }
+ },
"PutUserNameQueryParams": {
"type": "object",
"properties": {
diff --git a/crates/agent_harness/src/outbound/cursor/keys.rs b/crates/agent_harness/src/outbound/cursor/keys.rs
index eec1baca01..6a4db8d30a 100644
--- a/crates/agent_harness/src/outbound/cursor/keys.rs
+++ b/crates/agent_harness/src/outbound/cursor/keys.rs
@@ -16,9 +16,19 @@ use sqlx::PgPool;
use crate::domain::error::{HarnessError, Result};
-/// Resolves a user's Cursor API key.
+/// A user's resolved Cursor configuration: the decrypted key their sessions
+/// run on, and the model those sessions start on.
+pub struct ResolvedCursorConfig {
+ /// The decrypted key.
+ pub key: CursorApiKey,
+ /// The Cursor model id the user chose for their sessions, or `None` to
+ /// leave the choice to the deployment default and then Cursor's own.
+ pub default_model_id: Option<String>,
+}
+
+/// Resolves a user's Cursor configuration.
pub trait CursorApiKeys: Send + Sync + 'static {
- /// The key `owner` registered.
+ /// The configuration `owner` registered.
///
/// # Errors
/// [`HarnessError::CursorNotConnected`] when the user has registered no
@@ -27,10 +37,10 @@ pub trait CursorApiKeys: Send + Sync + 'static {
fn resolve(
&self,
owner: &MacroUserIdStr<'_>,
- ) -> impl Future<Output = Result<CursorApiKey>> + Send;
+ ) -> impl Future<Output = Result<ResolvedCursorConfig>> + Send;
}
-/// Reads keys from `cursor_api_keys`, decrypting through `cipher`.
+/// Reads keys from `cursor_configs`, decrypting through `cipher`.
#[derive(Clone)]
pub struct PgCursorApiKeys<Cipher> {
pool: PgPool,
@@ -48,23 +58,28 @@ impl<Cipher> CursorApiKeys for PgCursorApiKeys<Cipher>
where
Cipher: CursorApiKeyCipher + Clone + 'static,
{
- async fn resolve(&self, owner: &MacroUserIdStr<'_>) -> Result<CursorApiKey> {
+ async fn resolve(&self, owner: &MacroUserIdStr<'_>) -> Result<ResolvedCursorConfig> {
let owner = owner.as_ref();
let stored = cursor_api_key::store::get_cursor_api_key(&self.pool, owner)
.await
.map_err(|error| {
- HarnessError::Container(format!("could not read a cursor api key: {error}"))
+ HarnessError::Container(format!("could not read a cursor config: {error}"))
})?
.ok_or(HarnessError::CursorNotConnected)?;
// The decrypt error stays opaque on the way out. It can mean the row
// was written under another user's encryption context, and a caller
// that could tell that apart from "KMS is down" could probe for it.
- self.cipher
+ let key = self
+ .cipher
.decrypt(owner, &stored.encrypted)
.await
.map_err(|error| {
tracing::error!(error = ?error, "could not decrypt a cursor api key");
HarnessError::Container("could not decrypt the cursor api key".to_owned())
- })
+ })?;
+ Ok(ResolvedCursorConfig {
+ key,
+ default_model_id: stored.default_model_id,
+ })
}
}
diff --git a/crates/agent_harness/src/outbound/cursor/manager.rs b/crates/agent_harness/src/outbound/cursor/manager.rs
index 76b37a0087..d7ca271765 100644
--- a/crates/agent_harness/src/outbound/cursor/manager.rs
+++ b/crates/agent_harness/src/outbound/cursor/manager.rs
@@ -159,14 +159,14 @@ where
/// Built per session and dropped with it, rather than held on the manager:
/// the key belongs to one user, and the sessions of two users must not be
/// able to reach each other's Cursor accounts through a shared client.
- async fn client_for(&self, session: &AgentSession) -> Result<CursorClient> {
- let api_key = self.keys.resolve(&session.owner_id).await?;
- CursorClient::new(CursorConfig {
- api_key: ApiKey::new(api_key.expose()),
+ async fn client_for(&self, session: &AgentSession) -> Result<(CursorClient, Option<String>)> {
+ let config = self.keys.resolve(&session.owner_id).await?;
+ let client = CursorClient::new(CursorConfig {
+ api_key: ApiKey::new(config.key.expose()),
base_url: self.base_url.clone(),
- // Whatever the user already chose in their own Cursor settings:
- // Cursor resolves user default -> team default -> system default
- // when the field is absent, which is what "normal" means here.
+ // The client-level model stays absent: the *session* carries the
+ // model now (the user's default, seeded below via
+ // `with_default_model`, or a per-session pick), applied per run.
model: None,
starting_ref: DEFAULT_STARTING_REF.to_owned(),
record_dir: None,
@@ -177,7 +177,8 @@ where
// retyping, and the fix is to register the key again.
tracing::error!(error = %error, session_id = %session.id, "a stored cursor api key is unusable");
HarnessError::Container("the stored cursor api key is unusable".to_owned())
- })
+ })?;
+ Ok((client, config.default_model_id))
}
/// Wire up one session's in-process agent and return our end of its pipe.
@@ -187,6 +188,7 @@ where
fn serve_session(
&self,
client: CursorClient,
+ default_model_id: Option<String>,
session_id: AgentSessionId,
restore: Option<RestoredCursorSession>,
) -> PipeTransport {
@@ -198,11 +200,13 @@ where
sessions: self.sessions.clone(),
};
let notifier = AcpNotifier::new();
- let service = Arc::new(CursorSessionService::new(
- cursor,
- notifier.clone(),
- FixedRepo(self.repo.clone()),
- ));
+ // The user's chosen model seeds the session as its default: a fresh
+ // session starts on it, and a resumed one still prefers whatever it
+ // was actually last using (carried in `restore.model_id`) over this.
+ let service = Arc::new(
+ CursorSessionService::new(cursor, notifier.clone(), FixedRepo(self.repo.clone()))
+ .with_default_model(default_model_id),
+ );
if let Some(restored) = restore {
service.restore_session(
restored.acp_session,
@@ -274,8 +278,8 @@ where
// connected an account, and refusing here is what turns "the bot
// ignored me" into a sentence they can act on.
let session = AgentSessionRepo::get(&self.sessions, command.session_id).await?;
- let client = self.client_for(&session).await?;
- Ok(self.serve_session(client, command.session_id, None))
+ let (client, default_model_id) = self.client_for(&session).await?;
+ Ok(self.serve_session(client, default_model_id, command.session_id, None))
}
async fn resume(&self, session: AgentSessionId) -> Result<PipeTransport> {
@@ -288,7 +292,7 @@ where
// agent yet (the next prompt mints one). No acp id at all means the
// session never opened; serve it fresh, exactly like `spawn`.
let stored = AgentSessionRepo::get(&self.sessions, session).await?;
- let client = self.client_for(&stored).await?;
+ let (client, default_model_id) = self.client_for(&stored).await?;
let restore = match &stored.acp_session_id {
Some(acp) => {
let agent = ExternalSessionRepo::get(&self.sessions, session)
@@ -307,7 +311,7 @@ where
}
None => None,
};
- Ok(self.serve_session(client, session, restore))
+ Ok(self.serve_session(client, default_model_id, session, restore))
}
async fn teardown(&self, session: AgentSessionId) -> Result<()> {
@@ -327,7 +331,7 @@ where
let stored = AgentSessionRepo::get(&self.sessions, session).await?;
let agent = CursorAgentId::new(external.external_id);
match self.client_for(&stored).await {
- Ok(client) => client
+ Ok((client, _default_model_id)) => client
.archive_agent(&agent)
.await
.map_err(|error| HarnessError::Container(error.to_string()))?,
diff --git a/crates/agent_harness/src/outbound/cursor/manager/test.rs b/crates/agent_harness/src/outbound/cursor/manager/test.rs
index 8a16818e8e..2e88dfe561 100644
--- a/crates/agent_harness/src/outbound/cursor/manager/test.rs
+++ b/crates/agent_harness/src/outbound/cursor/manager/test.rs
@@ -1,3 +1,4 @@
+use super::super::keys::ResolvedCursorConfig;
use super::*;
use crate::domain::model::AgentKind;
use agent_client_protocol::schema::v1::SessionId;
@@ -143,24 +144,35 @@ impl AgentSessionRepo for StubSessions {
}
}
-/// A fake Cursor API: create/get/archive/stream, canned. Returns its base url
-/// and the archive-call log.
-async fn fake_cursor_api() -> (String, Arc<Mutex<Vec<String>>>) {
+/// A fake Cursor API: create/get/archive/stream, canned. Returns its base url,
+/// the archive-call log, and the bodies of every `create_agent` POST — the
+/// last being how a test sees which model a spawn asked for.
+async fn fake_cursor_api() -> (
+ String,
+ Arc<Mutex<Vec<String>>>,
+ Arc<Mutex<Vec<serde_json::Value>>>,
+) {
let archived = Arc::new(Mutex::new(Vec::<String>::new()));
let archive_log = archived.clone();
+ let created = Arc::new(Mutex::new(Vec::<serde_json::Value>::new()));
+ let create_log = created.clone();
let app = axum::Router::new()
.route(
"/v1/agents",
- axum::routing::post(|| async {
- axum::Json(serde_json::json!({
- "agent": {
- "id": "bc-test-agent",
- "name": "Add a health check",
- "status": "ACTIVE",
- "url": "https://cursor.com/agents/bc-test-agent",
- },
- "run": { "id": "run-test-1" },
- }))
+ axum::routing::post(move |axum::Json(body): axum::Json<serde_json::Value>| {
+ let created = created.clone();
+ async move {
+ created.lock().expect("create log poisoned").push(body);
+ axum::Json(serde_json::json!({
+ "agent": {
+ "id": "bc-test-agent",
+ "name": "Add a health check",
+ "status": "ACTIVE",
+ "url": "https://cursor.com/agents/bc-test-agent",
+ },
+ "run": { "id": "run-test-1" },
+ }))
+ }
}),
)
.route(
@@ -173,6 +185,23 @@ async fn fake_cursor_api() -> (String, Arc<Mutex<Vec<String>>>) {
}))
}),
)
+ .route(
+ "/v1/models",
+ axum::routing::get(|| async {
+ // Enough of the real shape for the wrapper to resolve an id to
+ // its default variant: grok-4.6's default is high + fast.
+ axum::Json(serde_json::json!({
+ "items": [{
+ "id": "grok-4.6",
+ "displayName": "Cursor Grok 4.6",
+ "variants": [
+ {"params": [{"id":"effort","value":"low"}], "isDefault": false},
+ {"params": [{"id":"effort","value":"high"},{"id":"fast","value":"true"}], "isDefault": true},
+ ],
+ }],
+ }))
+ }),
+ )
.route(
"/v1/agents/{id}/archive",
axum::routing::post(move |axum::extract::Path(id): axum::extract::Path<String>| {
@@ -245,19 +274,46 @@ async fn fake_cursor_api() -> (String, Arc<Mutex<Vec<String>>>) {
tokio::spawn(async move {
axum::serve(listener, app).await.expect("serve");
});
- (base_url, archive_log)
+ (base_url, archive_log, create_log)
}
-/// A key source: `Some` for an owner who has connected Cursor, `None` for one
-/// who has not — the state every user starts in.
+/// A config source: `key` is `Some` for an owner who has connected Cursor,
+/// `None` for one who has not — the state every user starts in. `model` is the
+/// default model that owner chose, if any.
#[derive(Clone, Copy)]
-struct StubKeys(Option<&'static str>);
+struct StubKeys {
+ key: Option<&'static str>,
+ model: Option<&'static str>,
+}
+
+impl StubKeys {
+ /// A connected owner with a well-formed key and no model preference.
+ const fn connected() -> Self {
+ Self {
+ key: Some("crsr_test"),
+ model: None,
+ }
+ }
+
+ /// An owner who has not connected Cursor.
+ const fn absent() -> Self {
+ Self {
+ key: None,
+ model: None,
+ }
+ }
+}
impl CursorApiKeys for StubKeys {
- async fn resolve(&self, _owner: &MacroUserIdStr<'_>) -> Result<CursorApiKey> {
- self.0
+ async fn resolve(&self, _owner: &MacroUserIdStr<'_>) -> Result<ResolvedCursorConfig> {
+ let key = self
+ .key
.map(|key| CursorApiKey::parse(key).expect("a well-formed stub key"))
- .ok_or(HarnessError::CursorNotConnected)
+ .ok_or(HarnessError::CursorNotConnected)?;
+ Ok(ResolvedCursorConfig {
+ key,
+ default_model_id: self.model.map(str::to_owned),
+ })
}
}
@@ -265,7 +321,7 @@ fn manager(
base_url: String,
sessions: StubSessions,
) -> CursorContainerManager<StubSessions, StubKeys> {
- manager_with_keys(base_url, sessions, StubKeys(Some("crsr_test")))
+ manager_with_keys(base_url, sessions, StubKeys::connected())
}
fn manager_with_keys(
@@ -304,7 +360,7 @@ async fn send_acp(sender: &super::super::pipe::PipeSender, frame: serde_json::Va
/// answers.
#[tokio::test]
async fn spawning_and_prompting_records_the_minted_agent() {
- let (base_url, _) = fake_cursor_api().await;
+ let (base_url, _, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
let session_id = AgentSessionId::new();
let manager = manager(base_url, sessions.clone());
@@ -370,12 +426,79 @@ async fn spawning_and_prompting_records_the_minted_agent() {
);
}
+/// A fresh session starts on the owner's configured default model, resolved
+/// to its variant against the live model table — the per-user setting reaching
+/// all the way to the agent Cursor mints.
+#[tokio::test]
+async fn spawn_uses_the_owners_default_model() {
+ let (base_url, _, created) = fake_cursor_api().await;
+ let sessions = StubSessions::default();
+ let session_id = AgentSessionId::new();
+ let manager = manager_with_keys(
+ base_url,
+ sessions,
+ StubKeys {
+ key: Some("crsr_test"),
+ model: Some("grok-4.6"),
+ },
+ );
+
+ let transport = manager
+ .spawn(SpawnContainer {
+ session_id,
+ kind: AgentKind::Cursor,
+ repo_url: "https://github.com/macro-inc/macro".to_owned(),
+ size: SandboxSize::Default,
+ })
+ .await
+ .expect("spawn");
+ let (sender, mut receiver) = transport.split();
+
+ send_acp(
+ &sender,
+ serde_json::json!({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}),
+ )
+ .await;
+ next_acp(&mut receiver).await;
+ send_acp(
+ &sender,
+ serde_json::json!({"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/workspace","mcpServers":[]}}),
+ )
+ .await;
+ let acp_session = next_acp(&mut receiver).await["result"]["sessionId"]
+ .as_str()
+ .expect("a session id")
+ .to_owned();
+ send_acp(
+ &sender,
+ serde_json::json!({"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{
+ "sessionId": acp_session,
+ "prompt": [{"type":"text","text":"go"}],
+ }}),
+ )
+ .await;
+ loop {
+ if next_acp(&mut receiver).await["id"] == 3 {
+ break;
+ }
+ }
+
+ let body = created.lock().expect("create log poisoned")[0].clone();
+ assert_eq!(body["model"]["id"], "grok-4.6");
+ // The default variant's params travel with the id — a bare id is not a
+ // selection Cursor accepts.
+ assert_eq!(
+ body["model"]["params"],
+ serde_json::json!([{"id":"effort","value":"high"},{"id":"fast","value":"true"}])
+ );
+}
+
/// Resume restores the persisted identity: the harness's `session/load` is
/// answered, and the next prompt is a follow-up run on the restored agent —
/// not a fresh agent.
#[tokio::test]
async fn resume_restores_the_persisted_identity() {
- let (base_url, _) = fake_cursor_api().await;
+ let (base_url, _, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
let session_id = AgentSessionId::new();
ExternalSessionRepo::upsert(
@@ -418,7 +541,7 @@ async fn resume_restores_the_persisted_identity() {
/// refusing left a session every follow-up crashed against (seen live).
#[tokio::test]
async fn resume_answers_session_load_even_before_an_agent_was_minted() {
- let (base_url, _) = fake_cursor_api().await;
+ let (base_url, _, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
let session_id = AgentSessionId::new();
*sessions.acp_session_id.lock().expect("stub poisoned") = Some("cursor-acp-1".to_owned());
@@ -502,7 +625,7 @@ async fn an_idle_pipe_is_shut_down() {
/// session that never minted an agent tears down without any API call.
#[tokio::test]
async fn teardown_archives_and_forgets() {
- let (base_url, archived) = fake_cursor_api().await;
+ let (base_url, archived, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
let session_id = AgentSessionId::new();
let manager = manager(base_url, sessions.clone());
@@ -541,9 +664,9 @@ async fn teardown_archives_and_forgets() {
/// everyone, so it is the error most users will ever see.
#[tokio::test]
async fn spawning_without_a_registered_key_says_so() {
- let (base_url, _) = fake_cursor_api().await;
+ let (base_url, _, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
- let manager = manager_with_keys(base_url, sessions, StubKeys(None));
+ let manager = manager_with_keys(base_url, sessions, StubKeys::absent());
let refused = manager
.spawn(SpawnContainer {
@@ -569,10 +692,10 @@ async fn spawning_without_a_registered_key_says_so() {
/// The alternative is a Macro session nothing can ever remove.
#[tokio::test]
async fn teardown_forgets_the_session_even_when_the_key_is_gone() {
- let (base_url, archived) = fake_cursor_api().await;
+ let (base_url, archived, _) = fake_cursor_api().await;
let sessions = StubSessions::default();
let session_id = AgentSessionId::new();
- let manager = manager_with_keys(base_url, sessions.clone(), StubKeys(None));
+ let manager = manager_with_keys(base_url, sessions.clone(), StubKeys::absent());
ExternalSessionRepo::upsert(
&sessions,
diff --git a/crates/agent_runtime_protocol/src/outbound/websocket/test.rs b/crates/agent_runtime_protocol/src/outbound/websocket/test.rs
index 9d5465aead..a82c08eea6 100644
--- a/crates/agent_runtime_protocol/src/outbound/websocket/test.rs
+++ b/crates/agent_runtime_protocol/src/outbound/websocket/test.rs
@@ -7,6 +7,12 @@ use super::*;
use crate::domain::connection::{RuntimeConnection, ServerConnection, SystemEventHandler};
use crate::domain::schema::v0::{AcpMessage, SystemEvent, ToRuntimeMessage, ToServerMessage};
+/// A generous cap on waits that should resolve "promptly": long enough that CI
+/// scheduling jitter under parallel tests never trips it, short enough that a
+/// genuine hang still fails the test rather than stalling the suite. These
+/// tests bind real loopback sockets, so a tight 1s raced the runner under load.
+const PROMPT: Duration = Duration::from_secs(10);
+
fn event() -> ToServerMessage {
ToServerMessage::Event {
event: SystemEvent::Unknown("runtime/ready".to_owned()),
@@ -34,7 +40,7 @@ async fn sent_payload_is_exactly_the_serialized_envelope_with_no_rpc_wrapper() {
.await
.expect("send should succeed");
- let sent = timeout(Duration::from_secs(1), outgoing_rx.recv())
+ let sent = timeout(PROMPT, outgoing_rx.recv())
.await
.expect("outbound payload should not hang")
.expect("outgoing channel should remain open");
@@ -72,19 +78,26 @@ async fn wire_frames_are_bare_json_with_no_outer_envelope() {
.expect("raw client should connect");
let (mut write, mut read) = stream.split();
- let server_channel = timeout(Duration::from_secs(1), transport.accept())
+ let server_channel = timeout(PROMPT, transport.accept())
.await
.expect("server accept should not hang")
.expect("server should accept the connection");
server_channel.tx.send(acp_to_runtime()).unwrap();
- let frame = timeout(Duration::from_secs(1), read.next())
- .await
- .expect("frame should arrive promptly")
- .expect("stream should remain open")
- .expect("frame should not be an error");
- let TungsteniteMessage::Text(text) = frame else {
- panic!("expected a text frame");
+ // Skip keepalive control frames: the server pings connected runtimes, so a
+ // Ping can arrive before (or interleave with) the data frame this asserts
+ // on. Read until the first Text frame rather than assuming it is first.
+ let text = loop {
+ let frame = timeout(PROMPT, read.next())
+ .await
+ .expect("frame should arrive promptly")
+ .expect("stream should remain open")
+ .expect("frame should not be an error");
+ match frame {
+ TungsteniteMessage::Text(text) => break text,
+ TungsteniteMessage::Ping(_) | TungsteniteMessage::Pong(_) => continue,
+ other => panic!("expected a text frame, got {other:?}"),
+ }
};
let received: Value = serde_json::from_str(&text).unwrap();
assert_eq!(
@@ -124,7 +137,7 @@ async fn malformed_frame_is_dropped_without_closing_the_connection() {
.expect("raw client should connect");
let (mut write, _read) = stream.split();
- let mut server_channel = timeout(Duration::from_secs(1), transport.accept())
+ let mut server_channel = timeout(PROMPT, transport.accept())
.await
.expect("server accept should not hang")
.expect("server should accept the connection");
@@ -140,7 +153,7 @@ async fn malformed_frame_is_dropped_without_closing_the_connection() {
.await
.unwrap();
- let delivered = timeout(Duration::from_secs(1), server_channel.rx.recv())
+ let delivered = timeout(PROMPT, server_channel.rx.recv())
.await
.expect("well-formed frame after a malformed one should still arrive")
.expect("channel should remain open");
@@ -169,13 +182,13 @@ async fn runtime_initiates_a_real_websocket_and_exchanges_bare_json_envelopes()
.await
.expect("runtime should connect");
let mut runtime = connect_runtime::<ToServerMessage, ToRuntimeMessage, _>(stream);
- let mut server = timeout(Duration::from_secs(1), transport.accept())
+ let mut server = timeout(PROMPT, transport.accept())
.await
.expect("server accept should not hang")
.expect("server should accept runtime");
runtime.tx.send(event()).unwrap();
- let delivered = timeout(Duration::from_secs(1), server.rx.recv())
+ let delivered = timeout(PROMPT, server.rx.recv())
.await
.expect("runtime-to-server should not hang")
.expect("server logical channel should remain open");
@@ -185,7 +198,7 @@ async fn runtime_initiates_a_real_websocket_and_exchanges_bare_json_envelopes()
);
server.tx.send(acp_to_runtime()).unwrap();
- let delivered = timeout(Duration::from_secs(1), runtime.rx.recv())
+ let delivered = timeout(PROMPT, runtime.rx.recv())
.await
.expect("server-to-runtime should not hang")
.expect("runtime logical channel should remain open");
@@ -233,7 +246,7 @@ async fn role_connections_run_over_a_runtime_initiated_websocket() {
runtime_connection
.system_event(SystemEvent::Unknown("runtime/ready".to_owned()))
.unwrap();
- let received = timeout(Duration::from_secs(1), event_receiver.recv())
+ let received = timeout(PROMPT, event_receiver.recv())
.await
.expect("event should not hang")
.expect("event channel should remain open");
diff --git a/crates/cursor_api_key/src/lib.rs b/crates/cursor_api_key/src/lib.rs
index a3b90f2150..6862f43726 100644
--- a/crates/cursor_api_key/src/lib.rs
+++ b/crates/cursor_api_key/src/lib.rs
@@ -14,7 +14,7 @@
//!
//! # Threat model
//!
-//! The row is not the exposure. A `cursor_api_keys` row is a KMS ciphertext
+//! The row is not the exposure. A `cursor_configs` row is a KMS ciphertext
//! blob, useless without a KMS call that IAM gates and CloudTrail records, and
//! bound by its encryption context to exactly one user — so a row copied into
//! another user's id does not decrypt. What is worth worrying about is
diff --git a/crates/cursor_api_key/src/store.rs b/crates/cursor_api_key/src/store.rs
index fe0aa08353..b5edaf8306 100644
--- a/crates/cursor_api_key/src/store.rs
+++ b/crates/cursor_api_key/src/store.rs
@@ -1,10 +1,11 @@
-//! Reading and writing the `cursor_api_keys` row.
+//! Reading and writing the `cursor_configs` row.
//!
-//! Only ciphertext passes through here — this module cannot decrypt anything
-//! and does not hold a KMS client. That is deliberate: a caller that wants a
-//! usable key has to go through [`crate::cipher`], which means every read of a
-//! plaintext key is an IAM-gated, CloudTrail-recorded KMS call rather than a
-//! plain `SELECT`.
+//! The row is a user's Cursor configuration: their encrypted API key, and the
+//! model their `@cursor` sessions start on. Only ciphertext passes through
+//! here — this module cannot decrypt anything and does not hold a KMS client.
+//! That is deliberate: a caller that wants a usable key has to go through
+//! [`crate::cipher`], which means every read of a plaintext key is an
+//! IAM-gated, CloudTrail-recorded KMS call rather than a plain `SELECT`.
#[cfg(test)]
mod test;
@@ -12,13 +13,16 @@ mod test;
use crate::cipher::EncryptedCursorApiKey;
use chrono::{DateTime, Utc};
-/// A stored key, as the row holds it.
+/// A user's stored Cursor configuration, as the row holds it.
#[derive(Clone, Debug, Eq, PartialEq)]
-pub struct StoredCursorApiKey {
- /// The Macro user the key belongs to.
+pub struct StoredCursorConfig {
+ /// The Macro user the configuration belongs to.
pub user_id: String,
/// The ciphertext and what is needed to decrypt it.
pub encrypted: EncryptedCursorApiKey,
+ /// The Cursor model id this user's sessions start on, when they have
+ /// chosen one. `None` means "use the deployment's built-in default".
+ pub default_model_id: Option<String>,
/// When the key was first registered.
pub created_at: DateTime<Utc>,
/// When it was last replaced.
@@ -30,7 +34,9 @@ pub struct StoredCursorApiKey {
/// Replacing rather than erroring on a second write is the behaviour the
/// settings surface wants: a user pasting a new key after rotating it at Cursor
/// is updating, not conflicting. `created_at` survives the replacement so the
-/// row still records when the user first connected.
+/// row still records when the user first connected, and `default_model_id` is
+/// deliberately left untouched — rotating a key must not silently reset the
+/// model the user chose.
///
/// # Errors
/// If the row cannot be written — including because `user_id` is not a real
@@ -39,10 +45,10 @@ pub async fn upsert_cursor_api_key(
executor: impl sqlx::PgExecutor<'_>,
user_id: &str,
encrypted: &EncryptedCursorApiKey,
-) -> anyhow::Result<StoredCursorApiKey> {
+) -> anyhow::Result<StoredCursorConfig> {
let row = sqlx::query!(
r#"
- INSERT INTO cursor_api_keys (
+ INSERT INTO cursor_configs (
user_id,
key_ciphertext,
encryption_version,
@@ -59,6 +65,7 @@ pub async fn upsert_cursor_api_key(
key_ciphertext,
encryption_version,
kms_key_id,
+ default_model_id,
created_at,
updated_at
"#,
@@ -70,19 +77,20 @@ pub async fn upsert_cursor_api_key(
.fetch_one(executor)
.await?;
- Ok(StoredCursorApiKey {
+ Ok(StoredCursorConfig {
user_id: row.user_id,
encrypted: EncryptedCursorApiKey {
key_ciphertext: row.key_ciphertext,
encryption_version: row.encryption_version,
kms_key_id: row.kms_key_id,
},
+ default_model_id: row.default_model_id,
created_at: row.created_at,
updated_at: row.updated_at,
})
}
-/// The user's key, or `None` if they have not registered one.
+/// The user's configuration, or `None` if they have not registered a key.
///
/// `None` is the ordinary answer, not an error: it is what "this user has not
/// connected Cursor" looks like, and both the settings surface and the harness
@@ -93,7 +101,7 @@ pub async fn upsert_cursor_api_key(
pub async fn get_cursor_api_key(
executor: impl sqlx::PgExecutor<'_>,
user_id: &str,
-) -> anyhow::Result<Option<StoredCursorApiKey>> {
+) -> anyhow::Result<Option<StoredCursorConfig>> {
let row = sqlx::query!(
r#"
SELECT
@@ -101,9 +109,10 @@ pub async fn get_cursor_api_key(
key_ciphertext,
encryption_version,
kms_key_id,
+ default_model_id,
created_at,
updated_at
- FROM cursor_api_keys
+ FROM cursor_configs
WHERE user_id = $1
"#,
user_id,
@@ -111,18 +120,49 @@ pub async fn get_cursor_api_key(
.fetch_optional(executor)
.await?;
- Ok(row.map(|row| StoredCursorApiKey {
+ Ok(row.map(|row| StoredCursorConfig {
user_id: row.user_id,
encrypted: EncryptedCursorApiKey {
key_ciphertext: row.key_ciphertext,
encryption_version: row.encryption_version,
kms_key_id: row.kms_key_id,
},
+ default_model_id: row.default_model_id,
created_at: row.created_at,
updated_at: row.updated_at,
}))
}
+/// Set (or clear, with `None`) the user's default model.
+///
+/// Returns whether a row was updated. `false` means the user has no
+/// configuration row yet — i.e. has not connected Cursor — which the settings
+/// surface treats as "connect first", never as an error: a model choice on a
+/// row that must also hold a `NOT NULL` key is not representable, and would be
+/// moot anyway since a user with no key starts no sessions.
+///
+/// # Errors
+/// If the row cannot be updated.
+pub async fn set_default_model_id(
+ executor: impl sqlx::PgExecutor<'_>,
+ user_id: &str,
+ default_model_id: Option<&str>,
+) -> anyhow::Result<bool> {
+ let result = sqlx::query!(
+ r#"
+ UPDATE cursor_configs
+ SET default_model_id = $2,
+ updated_at = NOW()
+ WHERE user_id = $1
+ "#,
+ user_id,
+ default_model_id,
+ )
+ .execute(executor)
+ .await?;
+ Ok(result.rows_affected() > 0)
+}
+
/// Forget a user's key, reporting whether there was one.
///
/// This does **not** revoke anything at Cursor — the key keeps working
@@ -135,7 +175,7 @@ pub async fn delete_cursor_api_key(
executor: impl sqlx::PgExecutor<'_>,
user_id: &str,
) -> anyhow::Result<bool> {
- let result = sqlx::query!("DELETE FROM cursor_api_keys WHERE user_id = $1", user_id)
+ let result = sqlx::query!("DELETE FROM cursor_configs WHERE user_id = $1", user_id)
.execute(executor)
.await?;
Ok(result.rows_affected() > 0)
diff --git a/crates/cursor_api_key/src/store/test.rs b/crates/cursor_api_key/src/store/test.rs
index e6b5a71acd..b617e0999e 100644
--- a/crates/cursor_api_key/src/store/test.rs
+++ b/crates/cursor_api_key/src/store/test.rs
@@ -16,7 +16,7 @@ fn encrypted(seed: u8) -> EncryptedCursorApiKey {
/// The table's foreign key means a key needs a real user to belong to.
///
/// A Macro user is two rows: `macro_user` holds the identity and `"User"` the
-/// profile that references it. `cursor_api_keys` keys on `"User"."id"`, the
+/// profile that references it. `cursor_configs` keys on `"User"."id"`, the
/// text id that `MacroUserIdStr` carries — not the `macro_user_id` uuid.
async fn insert_user(pool: &Pool<Postgres>, user_id: &str) -> anyhow::Result<()> {
let email = format!("{user_id}@example.com");
@@ -147,3 +147,62 @@ async fn a_key_for_an_unknown_user_is_refused(pool: Pool<Postgres>) -> anyhow::R
);
Ok(())
}
+
+/// A freshly registered key has no default model: the user gets the
+/// deployment's built-in default until they choose one.
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn a_new_key_has_no_default_model(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ insert_user(&pool, USER_ID).await?;
+ let stored = upsert_cursor_api_key(&pool, USER_ID, &encrypted(1)).await?;
+ assert_eq!(stored.default_model_id, None);
+ Ok(())
+}
+
+/// The chosen model round-trips, and clearing it with `None` reverts to the
+/// deployment default.
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn the_default_model_round_trips_and_clears(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ insert_user(&pool, USER_ID).await?;
+ upsert_cursor_api_key(&pool, USER_ID, &encrypted(1)).await?;
+
+ assert!(set_default_model_id(&pool, USER_ID, Some("grok-4.6")).await?);
+ assert_eq!(
+ get_cursor_api_key(&pool, USER_ID)
+ .await?
+ .expect("present")
+ .default_model_id
+ .as_deref(),
+ Some("grok-4.6")
+ );
+
+ assert!(set_default_model_id(&pool, USER_ID, None).await?);
+ assert_eq!(
+ get_cursor_api_key(&pool, USER_ID)
+ .await?
+ .expect("present")
+ .default_model_id,
+ None
+ );
+ Ok(())
+}
+
+/// Rotating the key leaves the chosen model alone — a new paste is not a reset.
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn rotating_the_key_keeps_the_default_model(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ insert_user(&pool, USER_ID).await?;
+ upsert_cursor_api_key(&pool, USER_ID, &encrypted(1)).await?;
+ set_default_model_id(&pool, USER_ID, Some("claude-opus-5")).await?;
+
+ let rotated = upsert_cursor_api_key(&pool, USER_ID, &encrypted(2)).await?;
+ assert_eq!(rotated.default_model_id.as_deref(), Some("claude-opus-5"));
+ Ok(())
+}
+
+/// Choosing a model before connecting is not an error, just a no-op: there is
+/// no row to hold it, and no session would use it.
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn setting_a_model_without_a_key_is_a_noop(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ insert_user(&pool, USER_ID).await?;
+ assert!(!set_default_model_id(&pool, USER_ID, Some("grok-4.6")).await?);
+ Ok(())
+}
diff --git a/crates/macro_db_client/migrations/20260826150909_cursor_configs_rename_and_default_model.sql b/crates/macro_db_client/migrations/20260826150909_cursor_configs_rename_and_default_model.sql
new file mode 100644
index 0000000000..ffe556d7f8
--- /dev/null
+++ b/crates/macro_db_client/migrations/20260826150909_cursor_configs_rename_and_default_model.sql
@@ -0,0 +1,28 @@
+-- `cursor_api_keys` becomes `cursor_configs`.
+--
+-- The table was a key store; it is now a user's whole Cursor configuration,
+-- of which the encrypted key is one field and the chosen default model is the
+-- next. The rename keeps the name honest before more config lands on the row.
+--
+-- `RENAME TO` is metadata-only and atomic — no rewrite, no data lock — and the
+-- primary key follows automatically. The three CHECK constraints carry the old
+-- table name in their own names, so they are renamed too; otherwise a future
+-- constraint violation would report a table that no longer exists.
+ALTER TABLE cursor_api_keys RENAME TO cursor_configs;
+ALTER TABLE cursor_configs RENAME CONSTRAINT cursor_api_keys_ciphertext_not_empty
+ TO cursor_configs_ciphertext_not_empty;
+ALTER TABLE cursor_configs RENAME CONSTRAINT cursor_api_keys_encryption_version_positive
+ TO cursor_configs_encryption_version_positive;
+ALTER TABLE cursor_configs RENAME CONSTRAINT cursor_api_keys_kms_key_id_not_empty
+ TO cursor_configs_kms_key_id_not_empty;
+
+-- The model a user's `@cursor` sessions start on, as a Cursor model id (e.g.
+-- `grok-4.6`). NULL means "use the deployment's built-in default", so every
+-- existing row is valid without a backfill. Only the id is stored: its
+-- parameters are resolved from Cursor's own default variant for that model at
+-- session start, since Cursor rejects an id whose parameters are not a variant
+-- it knows, and that variant table can change between now and then.
+ALTER TABLE cursor_configs ADD COLUMN default_model_id TEXT;
+
+ALTER TABLE cursor_configs ADD CONSTRAINT cursor_configs_default_model_id_not_empty
+ CHECK (default_model_id IS NULL OR default_model_id <> '');
diff --git a/packages/sdk/generated/auth/index.ts b/packages/sdk/generated/auth/index.ts
index c52be48168..e94a27a379 100644
--- a/packages/sdk/generated/auth/index.ts
+++ b/packages/sdk/generated/auth/index.ts
@@ -1,4 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export { type Options, Sdk } from './sdk.gen';
-export type { AbGroup, AppleLoginData, AppleLoginError, AppleLoginErrors, AppleLoginRequest, AppleLoginResponse, AppleLoginResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusError, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponse, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusError, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponse, CheckGmailLinkStatusResponses, CheckoutSessionMetadata, ClientOptions, CreateAccountMergeRequest, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Error, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Request, CreateCheckoutSessionV2Response, CreateCheckoutSessionV2Responses, CreateInProgressLinkData, CreateInProgressLinkError, CreateInProgressLinkErrors, CreateInProgressLinkResponse, CreateInProgressLinkResponse2, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestError, CreateMergeRequestErrors, CreateMergeRequestResponse, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionError, CreatePortalSessionErrors, CreatePortalSessionRequest, CreatePortalSessionResponse, CreatePortalSessionResponses, CreateTeamData, CreateTeamError, CreateTeamErrors, CreateTeamRequest, CreateTeamResponse, CreateTeamResponses, CreateUserData, CreateUserError, CreateUserErrors, CreateUserRequest, CreateUserResponse, CreateUserResponses, CursorApiKeyStatus, DeleteCursorApiKeyData, DeleteCursorApiKeyError, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponse, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkError, DeleteGithubLinkErrors, DeleteGithubLinkResponse, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamError, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerError, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserError, DeleteUserErrors, DeleteUserResponse, DeleteUserResponses, EmptyResponse, EnrichedGithubPullRequest, EnrichGithubPullRequestsData, EnrichGithubPullRequestsError, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsProxyRequest, EnrichGithubPullRequestsResponse, EnrichGithubPullRequestsResponse2, EnrichGithubPullRequestsResponses, ErrorResponse, GenerateEmailLinkData, GenerateEmailLinkError, GenerateEmailLinkErrors, GenerateEmailLinkRequest, GenerateEmailLinkResponse, GenerateEmailLinkResponses, GenericSuccessResponse, GetCursorApiKeyData, GetCursorApiKeyError, GetCursorApiKeyErrors, GetCursorApiKeyResponse, GetCursorApiKeyResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsError, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponse, GetLegacyUserPermissionsResponse2, GetLegacyUserPermissionsResponses, GetNamesWithEmailRequestBody, GetPermissionsData, GetPermissionsError, GetPermissionsErrors, GetPermissionsResponse, GetPermissionsResponses, GetProfilePicturesRequestBody, GetReferralCodeData, GetReferralCodeError, GetReferralCodeErrors, GetReferralCodeResponse, GetReferralCodeResponses, GetTeamData, GetTeamError, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesError, GetTeamInvitesErrors, GetTeamInvitesResponse, GetTeamInvitesResponses, GetTeamResponse, GetTeamResponses, GetUserInfo, GetUserInfoData, GetUserInfoError, GetUserInfoErrors, GetUserInfoResponse, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesError, GetUserInvitesErrors, GetUserInvitesResponse, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsError, GetUserLinkExistsErrors, GetUserLinkExistsResponse, GetUserLinkExistsResponses, GetUserNameData, GetUserNameError, GetUserNameErrors, GetUserNameResponse, GetUserNameResponses, GetUserNamesData, GetUserNamesError, GetUserNamesErrors, GetUserNamesResponse, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailError, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponse, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationError, GetUserOrganizationErrors, GetUserOrganizationResponse, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsError, GetUserPermissionsErrors, GetUserPermissionsResponse, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaError, GetUserQuotaErrors, GetUserQuotaResponse, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsError, GetUserTeamsErrors, GetUserTeamsResponse, GetUserTeamsResponses, GithubLinkStatusResponse, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestRef, GithubPullRequestStatus, GmailLinkStatusResponse, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkError, InitGithubLinkErrors, InitGithubLinkResponse, InitGithubLinkResponse2, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkError, InitGmailLinkErrors, InitGmailLinkResponse, InitGmailLinkResponse2, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkError, InitOutlookLinkErrors, InitOutlookLinkResponse, InitOutlookLinkResponse2, InitOutlookLinkResponses, InviteEntry, InviteToTeamData, InviteToTeamError, InviteToTeamErrors, InviteToTeamRequest, InviteToTeamResponses, JoinTeamData, JoinTeamError, JoinTeamErrors, JoinTeamResponses, LinkShare, LogoutData, LogoutResponse, LogoutResponses, MacroApiTokenData, MacroApiTokenError, MacroApiTokenErrors, MacroApiTokenResponse, MacroApiTokenResponse2, MacroApiTokenResponses, Oauth2CallbackData, Oauth2CallbackError, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectError, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackError, PasswordlessCallbackErrors, PasswordlessCallbackResponse, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginError, PasswordlessLoginErrors, PasswordlessLoginResponse, PasswordlessLoginResponses, PasswordlessRequest, PasswordlessStartedResponse, PasswordLoginData, PasswordLoginError, PasswordLoginErrors, PasswordLoginResponse, PasswordLoginResponses, PasswordRequest, PatchTeamCrmSettingsData, PatchTeamCrmSettingsError, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsRequest, PatchTeamCrmSettingsResponse, PatchTeamCrmSettingsResponse2, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamError, PatchTeamErrors, PatchTeamRequest, PatchTeamResponses, PatchTeamUserRole, PatchUserGroupData, PatchUserGroupError, PatchUserGroupErrors, PatchUserGroupRequest, PatchUserGroupResponse, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingError, PatchUserOnboardingErrors, PatchUserOnboardingRequest, PatchUserOnboardingResponse, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialError, PatchUserTutorialErrors, PatchUserTutorialRequest, PatchUserTutorialResponse, PatchUserTutorialResponses, Permission, PostGetNamesRequestBody, PostProfilePicturesData, PostProfilePicturesError, PostProfilePicturesErrors, PostProfilePicturesResponse, PostProfilePicturesResponses, ProfilePictureQueryParams, ProfilePictures, PutCursorApiKeyData, PutCursorApiKeyError, PutCursorApiKeyErrors, PutCursorApiKeyRequest, PutCursorApiKeyResponse, PutCursorApiKeyResponses, PutProfilePictureData, PutProfilePictureError, PutProfilePictureErrors, PutProfilePictureResponse, PutProfilePictureResponses, PutUserNameData, PutUserNameError, PutUserNameErrors, PutUserNameQueryParams, PutUserNameResponse, PutUserNameResponses, RefreshData, RefreshError, RefreshErrors, RefreshResponse, RefreshResponses, RejectInvitationData, RejectInvitationError, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamError, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailError, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailRequest, ResendFusionauthVerifyUserEmailResponse, ResendFusionauthVerifyUserEmailResponses, SendInviteBody, SendMobileWelcomeEmailData, SendMobileWelcomeEmailError, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailRequest, SendMobileWelcomeEmailResponse, SendMobileWelcomeEmailResponse2, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeError, SendReferralCodeErrors, SendReferralCodeResponse, SendReferralCodeResponses, SessionCreationData, SessionCreationError, SessionCreationErrors, SessionCreationResponse, SessionCreationResponses, SessionLoginData, SessionLoginError, SessionLoginErrors, SessionLoginResponse, SessionLoginResponses, SsoLoginData, SsoLoginError, SsoLoginErrors, SsoLoginResponses, SsoRequiredResponse, StripeSessionResponse, Team, TeamInviteDetails, TeamInvitesResponse, TeamMember, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainResponse, ToggleNonAdminInvitesResponse, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainError, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponse, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesError, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponse, ToggleTeamNonAdminInvitesResponses, UserLinkResponse, UserName, UserNames, UserOrganizationResponse, UserProfilePicture, UserQuota, UserTokensResponse, VerifyEmailLinkData, VerifyEmailLinkError, VerifyEmailLinkErrors, VerifyEmailLinkResponse, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailError, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponse, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestError, VerifyMergeRequestErrors, VerifyMergeRequestResponse, VerifyMergeRequestResponses } from './types.gen';
+export type { AbGroup, AppleLoginData, AppleLoginError, AppleLoginErrors, AppleLoginRequest, AppleLoginResponse, AppleLoginResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusError, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponse, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusError, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponse, CheckGmailLinkStatusResponses, CheckoutSessionMetadata, ClientOptions, CreateAccountMergeRequest, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Error, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Request, CreateCheckoutSessionV2Response, CreateCheckoutSessionV2Responses, CreateInProgressLinkData, CreateInProgressLinkError, CreateInProgressLinkErrors, CreateInProgressLinkResponse, CreateInProgressLinkResponse2, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestError, CreateMergeRequestErrors, CreateMergeRequestResponse, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionError, CreatePortalSessionErrors, CreatePortalSessionRequest, CreatePortalSessionResponse, CreatePortalSessionResponses, CreateTeamData, CreateTeamError, CreateTeamErrors, CreateTeamRequest, CreateTeamResponse, CreateTeamResponses, CreateUserData, CreateUserError, CreateUserErrors, CreateUserRequest, CreateUserResponse, CreateUserResponses, CursorApiKeyStatus, CursorModelOption, CursorModelsResponse, DeleteCursorApiKeyData, DeleteCursorApiKeyError, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponse, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkError, DeleteGithubLinkErrors, DeleteGithubLinkResponse, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamError, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerError, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserError, DeleteUserErrors, DeleteUserResponse, DeleteUserResponses, EmptyResponse, EnrichedGithubPullRequest, EnrichGithubPullRequestsData, EnrichGithubPullRequestsError, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsProxyRequest, EnrichGithubPullRequestsResponse, EnrichGithubPullRequestsResponse2, EnrichGithubPullRequestsResponses, ErrorResponse, GenerateEmailLinkData, GenerateEmailLinkError, GenerateEmailLinkErrors, GenerateEmailLinkRequest, GenerateEmailLinkResponse, GenerateEmailLinkResponses, GenericSuccessResponse, GetCursorApiKeyData, GetCursorApiKeyError, GetCursorApiKeyErrors, GetCursorApiKeyResponse, GetCursorApiKeyResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsError, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponse, GetLegacyUserPermissionsResponse2, GetLegacyUserPermissionsResponses, GetNamesWithEmailRequestBody, GetPermissionsData, GetPermissionsError, GetPermissionsErrors, GetPermissionsResponse, GetPermissionsResponses, GetProfilePicturesRequestBody, GetReferralCodeData, GetReferralCodeError, GetReferralCodeErrors, GetReferralCodeResponse, GetReferralCodeResponses, GetTeamData, GetTeamError, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesError, GetTeamInvitesErrors, GetTeamInvitesResponse, GetTeamInvitesResponses, GetTeamResponse, GetTeamResponses, GetUserInfo, GetUserInfoData, GetUserInfoError, GetUserInfoErrors, GetUserInfoResponse, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesError, GetUserInvitesErrors, GetUserInvitesResponse, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsError, GetUserLinkExistsErrors, GetUserLinkExistsResponse, GetUserLinkExistsResponses, GetUserNameData, GetUserNameError, GetUserNameErrors, GetUserNameResponse, GetUserNameResponses, GetUserNamesData, GetUserNamesError, GetUserNamesErrors, GetUserNamesResponse, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailError, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponse, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationError, GetUserOrganizationErrors, GetUserOrganizationResponse, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsError, GetUserPermissionsErrors, GetUserPermissionsResponse, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaError, GetUserQuotaErrors, GetUserQuotaResponse, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsError, GetUserTeamsErrors, GetUserTeamsResponse, GetUserTeamsResponses, GithubLinkStatusResponse, GithubPullRequestCheckRun, GithubPullRequestComment, GithubPullRequestRef, GithubPullRequestStatus, GmailLinkStatusResponse, HealthHandlerData, HealthHandlerResponse, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkError, InitGithubLinkErrors, InitGithubLinkResponse, InitGithubLinkResponse2, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkError, InitGmailLinkErrors, InitGmailLinkResponse, InitGmailLinkResponse2, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkError, InitOutlookLinkErrors, InitOutlookLinkResponse, InitOutlookLinkResponse2, InitOutlookLinkResponses, InviteEntry, InviteToTeamData, InviteToTeamError, InviteToTeamErrors, InviteToTeamRequest, InviteToTeamResponses, JoinTeamData, JoinTeamError, JoinTeamErrors, JoinTeamResponses, LinkShare, ListCursorModelsData, ListCursorModelsError, ListCursorModelsErrors, ListCursorModelsResponse, ListCursorModelsResponses, LogoutData, LogoutResponse, LogoutResponses, MacroApiTokenData, MacroApiTokenError, MacroApiTokenErrors, MacroApiTokenResponse, MacroApiTokenResponse2, MacroApiTokenResponses, Oauth2CallbackData, Oauth2CallbackError, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectError, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackError, PasswordlessCallbackErrors, PasswordlessCallbackResponse, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginError, PasswordlessLoginErrors, PasswordlessLoginResponse, PasswordlessLoginResponses, PasswordlessRequest, PasswordlessStartedResponse, PasswordLoginData, PasswordLoginError, PasswordLoginErrors, PasswordLoginResponse, PasswordLoginResponses, PasswordRequest, PatchTeamCrmSettingsData, PatchTeamCrmSettingsError, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsRequest, PatchTeamCrmSettingsResponse, PatchTeamCrmSettingsResponse2, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamError, PatchTeamErrors, PatchTeamRequest, PatchTeamResponses, PatchTeamUserRole, PatchUserGroupData, PatchUserGroupError, PatchUserGroupErrors, PatchUserGroupRequest, PatchUserGroupResponse, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingError, PatchUserOnboardingErrors, PatchUserOnboardingRequest, PatchUserOnboardingResponse, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialError, PatchUserTutorialErrors, PatchUserTutorialRequest, PatchUserTutorialResponse, PatchUserTutorialResponses, Permission, PostGetNamesRequestBody, PostProfilePicturesData, PostProfilePicturesError, PostProfilePicturesErrors, PostProfilePicturesResponse, PostProfilePicturesResponses, ProfilePictureQueryParams, ProfilePictures, PutCursorApiKeyData, PutCursorApiKeyError, PutCursorApiKeyErrors, PutCursorApiKeyRequest, PutCursorApiKeyResponse, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelError, PutCursorDefaultModelErrors, PutCursorDefaultModelRequest, PutCursorDefaultModelResponse, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureError, PutProfilePictureErrors, PutProfilePictureResponse, PutProfilePictureResponses, PutUserNameData, PutUserNameError, PutUserNameErrors, PutUserNameQueryParams, PutUserNameResponse, PutUserNameResponses, RefreshData, RefreshError, RefreshErrors, RefreshResponse, RefreshResponses, RejectInvitationData, RejectInvitationError, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamError, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailError, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailRequest, ResendFusionauthVerifyUserEmailResponse, ResendFusionauthVerifyUserEmailResponses, SendInviteBody, SendMobileWelcomeEmailData, SendMobileWelcomeEmailError, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailRequest, SendMobileWelcomeEmailResponse, SendMobileWelcomeEmailResponse2, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeError, SendReferralCodeErrors, SendReferralCodeResponse, SendReferralCodeResponses, SessionCreationData, SessionCreationError, SessionCreationErrors, SessionCreationResponse, SessionCreationResponses, SessionLoginData, SessionLoginError, SessionLoginErrors, SessionLoginResponse, SessionLoginResponses, SsoLoginData, SsoLoginError, SsoLoginErrors, SsoLoginResponses, SsoRequiredResponse, StripeSessionResponse, Team, TeamInviteDetails, TeamInvitesResponse, TeamMember, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainResponse, ToggleNonAdminInvitesResponse, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainError, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponse, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesError, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponse, ToggleTeamNonAdminInvitesResponses, UserLinkResponse, UserName, UserNames, UserOrganizationResponse, UserProfilePicture, UserQuota, UserTokensResponse, VerifyEmailLinkData, VerifyEmailLinkError, VerifyEmailLinkErrors, VerifyEmailLinkResponse, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailError, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponse, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestError, VerifyMergeRequestErrors, VerifyMergeRequestResponse, VerifyMergeRequestResponses } from './types.gen';
diff --git a/packages/sdk/generated/auth/sdk.gen.ts b/packages/sdk/generated/auth/sdk.gen.ts
index a11fc5da70..773b0340ee 100644
--- a/packages/sdk/generated/auth/sdk.gen.ts
+++ b/packages/sdk/generated/auth/sdk.gen.ts
@@ -2,7 +2,7 @@
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
-import type { AppleLoginData, AppleLoginErrors, AppleLoginResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Responses, CreateInProgressLinkData, CreateInProgressLinkErrors, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestErrors, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionErrors, CreatePortalSessionResponses, CreateTeamData, CreateTeamErrors, CreateTeamResponses, CreateUserData, CreateUserErrors, CreateUserResponses, DeleteCursorApiKeyData, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkErrors, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, EnrichGithubPullRequestsData, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsResponses, GenerateEmailLinkData, GenerateEmailLinkErrors, GenerateEmailLinkResponses, GetCursorApiKeyData, GetCursorApiKeyErrors, GetCursorApiKeyResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponses, GetPermissionsData, GetPermissionsErrors, GetPermissionsResponses, GetReferralCodeData, GetReferralCodeErrors, GetReferralCodeResponses, GetTeamData, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesErrors, GetTeamInvitesResponses, GetTeamResponses, GetUserInfoData, GetUserInfoErrors, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesErrors, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsErrors, GetUserLinkExistsResponses, GetUserNameData, GetUserNameErrors, GetUserNameResponses, GetUserNamesData, GetUserNamesErrors, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationErrors, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsErrors, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaErrors, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsErrors, GetUserTeamsResponses, HealthHandlerData, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkErrors, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkErrors, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkErrors, InitOutlookLinkResponses, InviteToTeamData, InviteToTeamErrors, InviteToTeamResponses, JoinTeamData, JoinTeamErrors, JoinTeamResponses, LogoutData, LogoutResponses, MacroApiTokenData, MacroApiTokenErrors, MacroApiTokenResponses, Oauth2CallbackData, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackErrors, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginErrors, PasswordlessLoginResponses, PasswordLoginData, PasswordLoginErrors, PasswordLoginResponses, PatchTeamCrmSettingsData, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamErrors, PatchTeamResponses, PatchUserGroupData, PatchUserGroupErrors, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingErrors, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialErrors, PatchUserTutorialResponses, PostProfilePicturesData, PostProfilePicturesErrors, PostProfilePicturesResponses, PutCursorApiKeyData, PutCursorApiKeyErrors, PutCursorApiKeyResponses, PutProfilePictureData, PutProfilePictureErrors, PutProfilePictureResponses, PutUserNameData, PutUserNameErrors, PutUserNameResponses, RefreshData, RefreshErrors, RefreshResponses, RejectInvitationData, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailResponses, SendMobileWelcomeEmailData, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeErrors, SendReferralCodeResponses, SessionCreationData, SessionCreationErrors, SessionCreationResponses, SessionLoginData, SessionLoginErrors, SessionLoginResponses, SsoLoginData, SsoLoginErrors, SsoLoginResponses, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponses, VerifyEmailLinkData, VerifyEmailLinkErrors, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestErrors, VerifyMergeRequestResponses } from './types.gen';
+import type { AppleLoginData, AppleLoginErrors, AppleLoginResponses, CheckGithubLinkStatusData, CheckGithubLinkStatusErrors, CheckGithubLinkStatusResponses, CheckGmailLinkStatusData, CheckGmailLinkStatusErrors, CheckGmailLinkStatusResponses, CreateCheckoutSessionV2Data, CreateCheckoutSessionV2Errors, CreateCheckoutSessionV2Responses, CreateInProgressLinkData, CreateInProgressLinkErrors, CreateInProgressLinkResponses, CreateMergeRequestData, CreateMergeRequestErrors, CreateMergeRequestResponses, CreatePortalSessionData, CreatePortalSessionErrors, CreatePortalSessionResponses, CreateTeamData, CreateTeamErrors, CreateTeamResponses, CreateUserData, CreateUserErrors, CreateUserResponses, DeleteCursorApiKeyData, DeleteCursorApiKeyErrors, DeleteCursorApiKeyResponses, DeleteGithubLinkData, DeleteGithubLinkErrors, DeleteGithubLinkResponses, DeleteTeamData, DeleteTeamErrors, DeleteTeamInviteHandlerData, DeleteTeamInviteHandlerErrors, DeleteTeamInviteHandlerResponses, DeleteTeamResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, EnrichGithubPullRequestsData, EnrichGithubPullRequestsErrors, EnrichGithubPullRequestsResponses, GenerateEmailLinkData, GenerateEmailLinkErrors, GenerateEmailLinkResponses, GetCursorApiKeyData, GetCursorApiKeyErrors, GetCursorApiKeyResponses, GetLegacyUserPermissionsData, GetLegacyUserPermissionsErrors, GetLegacyUserPermissionsResponses, GetPermissionsData, GetPermissionsErrors, GetPermissionsResponses, GetReferralCodeData, GetReferralCodeErrors, GetReferralCodeResponses, GetTeamData, GetTeamErrors, GetTeamInvitesData, GetTeamInvitesErrors, GetTeamInvitesResponses, GetTeamResponses, GetUserInfoData, GetUserInfoErrors, GetUserInfoResponses, GetUserInvitesData, GetUserInvitesErrors, GetUserInvitesResponses, GetUserLinkExistsData, GetUserLinkExistsErrors, GetUserLinkExistsResponses, GetUserNameData, GetUserNameErrors, GetUserNameResponses, GetUserNamesData, GetUserNamesErrors, GetUserNamesResponses, GetUserNamesWithEmailData, GetUserNamesWithEmailErrors, GetUserNamesWithEmailResponses, GetUserOrganizationData, GetUserOrganizationErrors, GetUserOrganizationResponses, GetUserPermissionsData, GetUserPermissionsErrors, GetUserPermissionsResponses, GetUserQuotaData, GetUserQuotaErrors, GetUserQuotaResponses, GetUserTeamsData, GetUserTeamsErrors, GetUserTeamsResponses, HealthHandlerData, HealthHandlerResponses, InitGithubLinkData, InitGithubLinkErrors, InitGithubLinkResponses, InitGmailLinkData, InitGmailLinkErrors, InitGmailLinkResponses, InitOutlookLinkData, InitOutlookLinkErrors, InitOutlookLinkResponses, InviteToTeamData, InviteToTeamErrors, InviteToTeamResponses, JoinTeamData, JoinTeamErrors, JoinTeamResponses, ListCursorModelsData, ListCursorModelsErrors, ListCursorModelsResponses, LogoutData, LogoutResponses, MacroApiTokenData, MacroApiTokenErrors, MacroApiTokenResponses, Oauth2CallbackData, Oauth2CallbackErrors, Oauth2CallbackResponses, OauthRedirectData, OauthRedirectErrors, OauthRedirectResponses, PasswordlessCallbackData, PasswordlessCallbackErrors, PasswordlessCallbackResponses, PasswordlessLoginData, PasswordlessLoginErrors, PasswordlessLoginResponses, PasswordLoginData, PasswordLoginErrors, PasswordLoginResponses, PatchTeamCrmSettingsData, PatchTeamCrmSettingsErrors, PatchTeamCrmSettingsResponses, PatchTeamData, PatchTeamErrors, PatchTeamResponses, PatchUserGroupData, PatchUserGroupErrors, PatchUserGroupResponses, PatchUserOnboardingData, PatchUserOnboardingErrors, PatchUserOnboardingResponses, PatchUserTutorialData, PatchUserTutorialErrors, PatchUserTutorialResponses, PostProfilePicturesData, PostProfilePicturesErrors, PostProfilePicturesResponses, PutCursorApiKeyData, PutCursorApiKeyErrors, PutCursorApiKeyResponses, PutCursorDefaultModelData, PutCursorDefaultModelErrors, PutCursorDefaultModelResponses, PutProfilePictureData, PutProfilePictureErrors, PutProfilePictureResponses, PutUserNameData, PutUserNameErrors, PutUserNameResponses, RefreshData, RefreshErrors, RefreshResponses, RejectInvitationData, RejectInvitationErrors, RejectInvitationResponses, RemoveUserFromTeamData, RemoveUserFromTeamErrors, RemoveUserFromTeamResponses, ResendFusionauthVerifyUserEmailData, ResendFusionauthVerifyUserEmailErrors, ResendFusionauthVerifyUserEmailResponses, SendMobileWelcomeEmailData, SendMobileWelcomeEmailErrors, SendMobileWelcomeEmailResponses, SendReferralCodeData, SendReferralCodeErrors, SendReferralCodeResponses, SessionCreationData, SessionCreationErrors, SessionCreationResponses, SessionLoginData, SessionLoginErrors, SessionLoginResponses, SsoLoginData, SsoLoginErrors, SsoLoginResponses, ToggleTeamAutoJoinDomainData, ToggleTeamAutoJoinDomainErrors, ToggleTeamAutoJoinDomainResponses, ToggleTeamNonAdminInvitesData, ToggleTeamNonAdminInvitesErrors, ToggleTeamNonAdminInvitesResponses, VerifyEmailLinkData, VerifyEmailLinkErrors, VerifyEmailLinkResponses, VerifyFusionauthUserEmailData, VerifyFusionauthUserEmailErrors, VerifyFusionauthUserEmailResponses, VerifyMergeRequestData, VerifyMergeRequestErrors, VerifyMergeRequestResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/**
@@ -100,6 +100,39 @@ export class Sdk extends HeyApiClient {
});
}
+ /**
+ * Choose the model this user's `@cursor` sessions start on.
+ *
+ * Stores the id only; its parameters are resolved from Cursor's own default
+ * variant at session start. Not validated against the live model list here —
+ * the settings dropdown offers only real ids, and a stale id degrades to the
+ * deployment default at spawn rather than failing, so a round trip to Cursor
+ * on every save would buy nothing.
+ */
+ public putCursorDefaultModel<ThrowOnError extends boolean = false>(options: Options<PutCursorDefaultModelData, ThrowOnError>): RequestResult<PutCursorDefaultModelResponses, PutCursorDefaultModelErrors, ThrowOnError> {
+ return (options.client ?? this.client).put<PutCursorDefaultModelResponses, PutCursorDefaultModelErrors, ThrowOnError>({
+ url: '/cursor-api-key/default-model',
+ ...options,
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers
+ }
+ });
+ }
+
+ /**
+ * List the models the caller's Cursor account offers.
+ *
+ * Reached only from the settings dropdown, so it decrypts the user's own key
+ * and asks Cursor directly — the list is per-account and changes, so there is
+ * nothing to cache statically. Reuses the harness's Cursor client rather than
+ * reimplementing the `/v1/models` parse, keeping one source of truth for what
+ * a model is.
+ */
+ public listCursorModels<ThrowOnError extends boolean = false>(options?: Options<ListCursorModelsData, ThrowOnError>): RequestResult<ListCursorModelsResponses, ListCursorModelsErrors, ThrowOnError> {
+ return (options?.client ?? this.client).get<ListCursorModelsResponses, ListCursorModelsErrors, ThrowOnError>({ url: '/cursor-api-key/models', ...options });
+ }
+
/**
* Verifies the user's primary email for FusionAuth
*/
diff --git a/packages/sdk/generated/auth/types.gen.ts b/packages/sdk/generated/auth/types.gen.ts
index 8298b0af92..58fd1c7c60 100644
--- a/packages/sdk/generated/auth/types.gen.ts
+++ b/packages/sdk/generated/auth/types.gen.ts
@@ -118,6 +118,12 @@ export type CreateUserRequest = {
* that cannot reach KMS does not start.
*/
export type CursorApiKeyStatus = {
+ /**
+ * The Cursor model id this user's sessions start on, when they have
+ * chosen one. `None` means the deployment default is in effect — the
+ * settings dropdown shows that as its resting value.
+ */
+ defaultModelId?: string | null;
/**
* Whether this user has a key stored.
*/
@@ -128,6 +134,34 @@ export type CursorApiKeyStatus = {
updatedAt?: string | null;
};
+/**
+ * One model the settings dropdown can offer.
+ *
+ * Just id and name: the dropdown lists models, not the hundreds of parameter
+ * variants each carries. The chosen id's parameters are resolved to Cursor's
+ * default variant at session start.
+ */
+export type CursorModelOption = {
+ /**
+ * The human-readable name, e.g. `Cursor Grok 4.6`.
+ */
+ displayName: string;
+ /**
+ * The id to store and send, e.g. `grok-4.6`.
+ */
+ id: string;
+};
+
+/**
+ * The models this account may choose from.
+ */
+export type CursorModelsResponse = {
+ /**
+ * The offered models, in the order Cursor returned them.
+ */
+ models: Array<CursorModelOption>;
+};
+
/**
* Empty response is required due to custom fetch forcing `response.json()`
*/
@@ -712,6 +746,17 @@ export type PutCursorApiKeyRequest = {
apiKey: string;
};
+/**
+ * The model the user chose for their sessions.
+ */
+export type PutCursorDefaultModelRequest = {
+ /**
+ * A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and
+ * fall back to the deployment default.
+ */
+ modelId?: string | null;
+};
+
export type PutUserNameQueryParams = {
/**
* First Name of user
@@ -1039,6 +1084,49 @@ export type PutCursorApiKeyResponses = {
export type PutCursorApiKeyResponse = PutCursorApiKeyResponses[keyof PutCursorApiKeyResponses];
+export type PutCursorDefaultModelData = {
+ body: PutCursorDefaultModelRequest;
+ path?: never;
+ query?: never;
+ url: '/cursor-api-key/default-model';
+};
+
+export type PutCursorDefaultModelErrors = {
+ 401: string;
+ 403: ErrorResponse;
+ 409: ErrorResponse;
+};
+
+export type PutCursorDefaultModelError = PutCursorDefaultModelErrors[keyof PutCursorDefaultModelErrors];
+
+export type PutCursorDefaultModelResponses = {
+ 200: CursorApiKeyStatus;
+};
+
+export type PutCursorDefaultModelResponse = PutCursorDefaultModelResponses[keyof PutCursorDefaultModelResponses];
+
+export type ListCursorModelsData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/cursor-api-key/models';
+};
+
+export type ListCursorModelsErrors = {
+ 401: string;
+ 403: ErrorResponse;
+ 409: ErrorResponse;
+ 502: ErrorResponse;
+};
+
+export type ListCursorModelsError = ListCursorModelsErrors[keyof ListCursorModelsErrors];
+
+export type ListCursorModelsResponses = {
+ 200: CursorModelsResponse;
+};
+
+export type ListCursorModelsResponse = ListCursorModelsResponses[keyof ListCursorModelsResponses];
+
export type VerifyFusionauthUserEmailData = {
body?: never;
path: {
diff --git a/packages/sdk/specs/auth.json b/packages/sdk/specs/auth.json
index 3021e2c692..9757c8c8b6 100644
--- a/packages/sdk/specs/auth.json
+++ b/packages/sdk/specs/auth.json
@@ -146,6 +146,126 @@
}
}
},
+ "/cursor-api-key/default-model": {
+ "put": {
+ "tags": ["crate::api::cursor_api_key::put_cursor_default_model"],
+ "summary": "Choose the model this user's `@cursor` sessions start on.",
+ "description": "Stores the id only; its parameters are resolved from Cursor's own default\nvariant at session start. Not validated against the live model list here —\nthe settings dropdown offers only real ids, and a stale id degrades to the\ndeployment default at spawn rather than failing, so a round trip to Cursor\non every save would buy nothing.",
+ "operationId": "put_cursor_default_model",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PutCursorDefaultModelRequest"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CursorApiKeyStatus"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/cursor-api-key/models": {
+ "get": {
+ "tags": ["crate::api::cursor_api_key::list_cursor_models"],
+ "summary": "List the models the caller's Cursor account offers.",
+ "description": "Reached only from the settings dropdown, so it decrypts the user's own key\nand asks Cursor directly — the list is per-account and changes, so there is\nnothing to cache statically. Reuses the harness's Cursor client rather than\nreimplementing the `/v1/models` parse, keeping one source of truth for what\na model is.",
+ "operationId": "list_cursor_models",
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/CursorModelsResponse"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "409": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ },
+ "502": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ErrorResponse"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
"/email/fusionauth/verify/{verification_id}": {
"get": {
"tags": ["email::verify_fusionauth_user_email"],
@@ -3791,6 +3911,10 @@
"description": "What settings needs to render the Cursor connection.\n\nDeliberately thin. `registered` drives the whole UI; `updatedAt` lets it say\nwhen the key was last replaced, which is the only thing a user can check\nagainst their own memory when a session starts failing.\n\nDeliberately *not* reporting anything about the deployment itself. That is\noperator information: a user who sees it cannot act on it, and a service\nthat cannot reach KMS does not start.",
"required": ["registered"],
"properties": {
+ "defaultModelId": {
+ "type": ["string", "null"],
+ "description": "The Cursor model id this user's sessions start on, when they have\nchosen one. `None` means the deployment default is in effect — the\nsettings dropdown shows that as its resting value."
+ },
"registered": {
"type": "boolean",
"description": "Whether this user has a key stored."
@@ -3802,6 +3926,35 @@
}
}
},
+ "CursorModelOption": {
+ "type": "object",
+ "description": "One model the settings dropdown can offer.\n\nJust id and name: the dropdown lists models, not the hundreds of parameter\nvariants each carries. The chosen id's parameters are resolved to Cursor's\ndefault variant at session start.",
+ "required": ["id", "displayName"],
+ "properties": {
+ "displayName": {
+ "type": "string",
+ "description": "The human-readable name, e.g. `Cursor Grok 4.6`."
+ },
+ "id": {
+ "type": "string",
+ "description": "The id to store and send, e.g. `grok-4.6`."
+ }
+ }
+ },
+ "CursorModelsResponse": {
+ "type": "object",
+ "description": "The models this account may choose from.",
+ "required": ["models"],
+ "properties": {
+ "models": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CursorModelOption"
+ },
+ "description": "The offered models, in the order Cursor returned them."
+ }
+ }
+ },
"EmptyResponse": {
"type": "object",
"description": "Empty response is required due to custom fetch forcing `response.json()`"
@@ -4588,6 +4741,16 @@
}
}
},
+ "PutCursorDefaultModelRequest": {
+ "type": "object",
+ "description": "The model the user chose for their sessions.",
+ "properties": {
+ "modelId": {
+ "type": ["string", "null"],
+ "description": "A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and\nfall back to the deployment default."
+ }
+ }
+ },
"PutUserNameQueryParams": {
"type": "object",
"properties": {
diff --git a/packages/sdk/src/coverage/skipped.ts b/packages/sdk/src/coverage/skipped.ts
index 3f3f183182..75dbad1d67 100644
--- a/packages/sdk/src/coverage/skipped.ts
+++ b/packages/sdk/src/coverage/skipped.ts
@@ -64,6 +64,7 @@ export const authExcluded = [
'initOutlookLink',
'inviteToTeam',
'joinTeam',
+ 'listCursorModels',
'logout',
'oauth2Callback',
'oauthRedirect',
@@ -77,6 +78,7 @@ export const authExcluded = [
'patchUserTutorial',
'postProfilePictures',
'putCursorApiKey',
+ 'putCursorDefaultModel',
'putProfilePicture',
'putUserName',
'refresh',
diff --git a/services/authentication_service/Cargo.toml b/services/authentication_service/Cargo.toml
index 2f2bf6124c..a91600777e 100644
--- a/services/authentication_service/Cargo.toml
+++ b/services/authentication_service/Cargo.toml
@@ -29,6 +29,7 @@ return_passwordless_code = []
[dependencies]
cursor_api_key = { path = "../../crates/cursor_api_key" }
+cursor_cloud_agents = { path = "../../crates/cursor_cloud_agents" }
aes-gcm = { workspace = true }
calendar_events = { path = "../../crates/calendar_events" }
analytics_client = { path = "../../crates/analytics_client" }
diff --git a/services/authentication_service/src/api/cursor_api_key.rs b/services/authentication_service/src/api/cursor_api_key.rs
index 59d35225f5..afb4921958 100644
--- a/services/authentication_service/src/api/cursor_api_key.rs
+++ b/services/authentication_service/src/api/cursor_api_key.rs
@@ -23,7 +23,9 @@ mod test;
pub(in crate::api) mod delete_cursor_api_key;
pub(in crate::api) mod get_cursor_api_key;
+pub(in crate::api) mod list_cursor_models;
pub(in crate::api) mod put_cursor_api_key;
+pub(in crate::api) mod put_cursor_default_model;
/// Routes for the settings surface's Cursor connection.
pub fn router() -> Router<ApiContext> {
@@ -31,6 +33,10 @@ pub fn router() -> Router<ApiContext> {
.route("/", get(get_cursor_api_key::handler))
.route("/", put(put_cursor_api_key::handler))
.route("/", delete(delete_cursor_api_key::handler))
+ // The models this account may pick from, for the settings dropdown.
+ .route("/models", get(list_cursor_models::handler))
+ // The model new sessions start on.
+ .route("/default-model", put(put_cursor_default_model::handler))
}
fn require_macro_staff(user_id: &MacroUserIdStr<'_>) -> Result<(), CursorApiKeyError> {
@@ -54,6 +60,10 @@ fn require_macro_staff(user_id: &MacroUserIdStr<'_>) -> Result<(), CursorApiKeyE
pub struct CursorApiKeyStatus {
/// Whether this user has a key stored.
pub registered: bool,
+ /// The Cursor model id this user's sessions start on, when they have
+ /// chosen one. `None` means the deployment default is in effect — the
+ /// settings dropdown shows that as its resting value.
+ pub default_model_id: Option<String>,
/// When the stored key was last replaced, if there is one.
pub updated_at: Option<chrono::DateTime<chrono::Utc>>,
}
@@ -67,6 +77,15 @@ pub enum CursorApiKeyError {
/// Cursor agents are currently restricted to Macro staff.
#[error("Cursor agents are only available to Macro staff")]
NotMacroStaff,
+ /// An operation that needs a connected account was attempted without one —
+ /// e.g. choosing a model before pasting a key.
+ #[error("connect a Cursor API key first")]
+ NotConnected,
+ /// Cursor's own API could not be reached or refused the request — listing
+ /// models, say. Distinct from [`Self::Internal`] so the client can tell
+ /// "Cursor is having a moment" from "we broke".
+ #[error("Cursor's API is unavailable right now")]
+ CursorUnavailable,
/// Encryption or persistence failed.
#[error("internal error")]
Internal,
@@ -79,6 +98,8 @@ impl axum::response::IntoResponse for CursorApiKeyError {
// A shape this service cannot use is the client's mistake.
Self::MalformedKey => StatusCode::BAD_REQUEST,
Self::NotMacroStaff => StatusCode::FORBIDDEN,
+ Self::NotConnected => StatusCode::CONFLICT,
+ Self::CursorUnavailable => StatusCode::BAD_GATEWAY,
Self::Internal => StatusCode::INTERNAL_SERVER_ERROR,
};
// `to_string` and nothing else: every variant's message is written to
diff --git a/services/authentication_service/src/api/cursor_api_key/delete_cursor_api_key.rs b/services/authentication_service/src/api/cursor_api_key/delete_cursor_api_key.rs
index e5b9238bd0..73575528cf 100644
--- a/services/authentication_service/src/api/cursor_api_key/delete_cursor_api_key.rs
+++ b/services/authentication_service/src/api/cursor_api_key/delete_cursor_api_key.rs
@@ -39,6 +39,8 @@ pub async fn handler(
Ok(Json(CursorApiKeyStatus {
registered: false,
+ // The row is gone, model choice with it: disconnecting is a clean slate.
+ default_model_id: None,
updated_at: None,
}))
}
diff --git a/services/authentication_service/src/api/cursor_api_key/get_cursor_api_key.rs b/services/authentication_service/src/api/cursor_api_key/get_cursor_api_key.rs
index c3b8315f15..c1d8d9df65 100644
--- a/services/authentication_service/src/api/cursor_api_key/get_cursor_api_key.rs
+++ b/services/authentication_service/src/api/cursor_api_key/get_cursor_api_key.rs
@@ -38,6 +38,7 @@ pub async fn handler(
Ok(Json(CursorApiKeyStatus {
registered: stored.is_some(),
+ default_model_id: stored.as_ref().and_then(|s| s.default_model_id.clone()),
updated_at: stored.map(|stored| stored.updated_at),
}))
}
diff --git a/services/authentication_service/src/api/cursor_api_key/list_cursor_models.rs b/services/authentication_service/src/api/cursor_api_key/list_cursor_models.rs
new file mode 100644
index 0000000000..047e58d0ee
--- /dev/null
+++ b/services/authentication_service/src/api/cursor_api_key/list_cursor_models.rs
@@ -0,0 +1,105 @@
+use axum::{Json, extract::State};
+use cursor_cloud_agents::api::{ApiKey, CursorClient, CursorConfig};
+use cursor_cloud_agents::domain::ports::CursorAgents;
+use macro_authorization::{MacroAuthorizationExtractor, UserOnly};
+use utoipa::ToSchema;
+
+use super::{CursorApiKeyError, require_macro_staff};
+use crate::api::context::{ApiContext, AuthorizationService};
+
+/// One model the settings dropdown can offer.
+///
+/// Just id and name: the dropdown lists models, not the hundreds of parameter
+/// variants each carries. The chosen id's parameters are resolved to Cursor's
+/// default variant at session start.
+#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct CursorModelOption {
+ /// The id to store and send, e.g. `grok-4.6`.
+ pub id: String,
+ /// The human-readable name, e.g. `Cursor Grok 4.6`.
+ pub display_name: String,
+}
+
+/// The models this account may choose from.
+#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct CursorModelsResponse {
+ /// The offered models, in the order Cursor returned them.
+ pub models: Vec<CursorModelOption>,
+}
+
+/// List the models the caller's Cursor account offers.
+///
+/// Reached only from the settings dropdown, so it decrypts the user's own key
+/// and asks Cursor directly — the list is per-account and changes, so there is
+/// nothing to cache statically. Reuses the harness's Cursor client rather than
+/// reimplementing the `/v1/models` parse, keeping one source of truth for what
+/// a model is.
+#[utoipa::path(
+ get,
+ path = "/cursor-api-key/models",
+ operation_id = "list_cursor_models",
+ responses(
+ (status = 200, body = CursorModelsResponse),
+ (status = 401, body = String),
+ (status = 403, body = model::response::ErrorResponse),
+ (status = 409, body = model::response::ErrorResponse),
+ (status = 502, body = model::response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(ctx, user_context), err, fields(user_id = %user_context.authorization.macro_user_id))]
+pub async fn handler(
+ State(ctx): State<ApiContext>,
+ user_context: MacroAuthorizationExtractor<AuthorizationService, UserOnly>,
+) -> Result<Json<CursorModelsResponse>, CursorApiKeyError> {
+ let user_id = &user_context.authorization.macro_user_id;
+ require_macro_staff(user_id)?;
+
+ let stored = cursor_api_key::store::get_cursor_api_key(&ctx.db, user_id.as_ref())
+ .await
+ .map_err(|error| {
+ tracing::error!(error = ?error, "failed to read cursor config");
+ CursorApiKeyError::Internal
+ })?
+ .ok_or(CursorApiKeyError::NotConnected)?;
+
+ let key = ctx
+ .cursor_api_key_cipher
+ .decrypt(user_id.as_ref(), &stored.encrypted)
+ .await
+ .map_err(|error| {
+ // Opaque on the way out for the same reason the harness keeps it
+ // so: the variants can distinguish a wrong encryption context from
+ // KMS being down, which is a probing signal.
+ tracing::error!(error = ?error, "failed to decrypt cursor api key");
+ CursorApiKeyError::Internal
+ })?;
+
+ let client = CursorClient::new(CursorConfig {
+ api_key: ApiKey::new(key.expose()),
+ base_url: cursor_cloud_agents::api::CURSOR_API_BASE_URL.to_owned(),
+ model: None,
+ starting_ref: "main".to_owned(),
+ record_dir: None,
+ })
+ .map_err(|error| {
+ tracing::error!(error = %error, "a stored cursor api key is unusable");
+ CursorApiKeyError::Internal
+ })?;
+
+ let models = client.list_models().await.map_err(|error| {
+ tracing::warn!(error = %error, "could not list cursor models");
+ CursorApiKeyError::CursorUnavailable
+ })?;
+
+ Ok(Json(CursorModelsResponse {
+ models: models
+ .into_iter()
+ .map(|model| CursorModelOption {
+ id: model.id,
+ display_name: model.display_name,
+ })
+ .collect(),
+ }))
+}
diff --git a/services/authentication_service/src/api/cursor_api_key/put_cursor_api_key.rs b/services/authentication_service/src/api/cursor_api_key/put_cursor_api_key.rs
index dcd5200075..0986ede190 100644
--- a/services/authentication_service/src/api/cursor_api_key/put_cursor_api_key.rs
+++ b/services/authentication_service/src/api/cursor_api_key/put_cursor_api_key.rs
@@ -71,6 +71,9 @@ pub async fn handler(
Ok(Json(CursorApiKeyStatus {
registered: true,
+ // Carried through: pasting a rotated key does not reset the model,
+ // and the store preserves it, so the response reflects that.
+ default_model_id: stored.default_model_id,
updated_at: Some(stored.updated_at),
}))
}
diff --git a/services/authentication_service/src/api/cursor_api_key/put_cursor_default_model.rs b/services/authentication_service/src/api/cursor_api_key/put_cursor_default_model.rs
new file mode 100644
index 0000000000..b4c99b311d
--- /dev/null
+++ b/services/authentication_service/src/api/cursor_api_key/put_cursor_default_model.rs
@@ -0,0 +1,79 @@
+use axum::{
+ Json,
+ extract::{self, State},
+};
+use macro_authorization::{MacroAuthorizationExtractor, UserOnly};
+use utoipa::ToSchema;
+
+use super::{CursorApiKeyError, CursorApiKeyStatus, require_macro_staff};
+use crate::api::context::{ApiContext, AuthorizationService};
+
+/// The model the user chose for their sessions.
+#[derive(Debug, serde::Serialize, serde::Deserialize, ToSchema)]
+#[serde(rename_all = "camelCase")]
+pub struct PutCursorDefaultModelRequest {
+ /// A Cursor model id (e.g. `grok-4.6`), or `null` to clear the choice and
+ /// fall back to the deployment default.
+ pub model_id: Option<String>,
+}
+
+/// Choose the model this user's `@cursor` sessions start on.
+///
+/// Stores the id only; its parameters are resolved from Cursor's own default
+/// variant at session start. Not validated against the live model list here —
+/// the settings dropdown offers only real ids, and a stale id degrades to the
+/// deployment default at spawn rather than failing, so a round trip to Cursor
+/// on every save would buy nothing.
+#[utoipa::path(
+ put,
+ path = "/cursor-api-key/default-model",
+ operation_id = "put_cursor_default_model",
+ request_body = PutCursorDefaultModelRequest,
+ responses(
+ (status = 200, body = CursorApiKeyStatus),
+ (status = 401, body = String),
+ (status = 403, body = model::response::ErrorResponse),
+ (status = 409, body = model::response::ErrorResponse),
+ )
+)]
+#[tracing::instrument(skip(ctx, user_context), err, fields(user_id = %user_context.authorization.macro_user_id))]
+pub async fn handler(
+ State(ctx): State<ApiContext>,
+ user_context: MacroAuthorizationExtractor<AuthorizationService, UserOnly>,
+ extract::Json(req): extract::Json<PutCursorDefaultModelRequest>,
+) -> Result<Json<CursorApiKeyStatus>, CursorApiKeyError> {
+ let user_id = &user_context.authorization.macro_user_id;
+ require_macro_staff(user_id)?;
+
+ let updated = cursor_api_key::store::set_default_model_id(
+ &ctx.db,
+ user_id.as_ref(),
+ req.model_id.as_deref(),
+ )
+ .await
+ .map_err(|error| {
+ tracing::error!(error = ?error, "failed to set cursor default model");
+ CursorApiKeyError::Internal
+ })?;
+ // No row to update means no key: a model choice on a keyless account is
+ // not representable and would be moot, so it is a "connect first", not an
+ // error the user caused by a bad value.
+ if !updated {
+ return Err(CursorApiKeyError::NotConnected);
+ }
+
+ // Re-read rather than echo the request, so the response reflects the
+ // stored truth including the untouched `updated_at`/`registered`.
+ let stored = cursor_api_key::store::get_cursor_api_key(&ctx.db, user_id.as_ref())
+ .await
+ .map_err(|error| {
+ tracing::error!(error = ?error, "failed to read cursor config after setting model");
+ CursorApiKeyError::Internal
+ })?;
+
+ Ok(Json(CursorApiKeyStatus {
+ registered: stored.is_some(),
+ default_model_id: stored.as_ref().and_then(|s| s.default_model_id.clone()),
+ updated_at: stored.map(|stored| stored.updated_at),
+ }))
+}
diff --git a/services/authentication_service/src/api/swagger.rs b/services/authentication_service/src/api/swagger.rs
index f2fd48032b..7843be8c69 100644
--- a/services/authentication_service/src/api/swagger.rs
+++ b/services/authentication_service/src/api/swagger.rs
@@ -90,6 +90,8 @@ use model::user::{
crate::api::cursor_api_key::get_cursor_api_key::handler,
crate::api::cursor_api_key::put_cursor_api_key::handler,
crate::api::cursor_api_key::delete_cursor_api_key::handler,
+ crate::api::cursor_api_key::list_cursor_models::handler,
+ crate::api::cursor_api_key::put_cursor_default_model::handler,
/// /github_pull_requests
github_pull_requests::handler,