Fix account session protocol layering

This commit is contained in:
Dhruv
2026-06-01 07:43:39 +05:30
parent b7bce9beb7
commit 5ae17fb80f
21 changed files with 71 additions and 987 deletions

View File

@@ -5,48 +5,6 @@
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AccountSessionsAddParams": {
"properties": {
"switchToAddedAccount": {
"type": "boolean"
}
},
"type": "object"
},
"AccountSessionsListParams": {
"properties": {
"refreshWorkspaceMetadata": {
"type": "boolean"
}
},
"type": "object"
},
"AccountSessionsLogoutParams": {
"properties": {
"sessionId": {
"type": "string"
}
},
"required": [
"sessionId"
],
"type": "object"
},
"AccountSessionsSwitchParams": {
"properties": {
"accountId": {
"type": "string"
},
"sessionId": {
"type": "string"
}
},
"required": [
"accountId",
"sessionId"
],
"type": "object"
},
"AddCreditsNudgeCreditType": {
"enum": [
"credits",
@@ -5917,102 +5875,6 @@
"title": "Account/login/cancelRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/add"
],
"title": "AccountSession/addRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsAddParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/addRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/list"
],
"title": "AccountSession/listRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsListParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/listRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/logout"
],
"title": "AccountSession/logoutRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsLogoutParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/logoutRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/switch"
],
"title": "AccountSession/switchRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsSwitchParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/switchRequest",
"type": "object"
},
{
"properties": {
"id": {

View File

@@ -1787,102 +1787,6 @@
"title": "Account/login/cancelRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/v2/RequestId"
},
"method": {
"enum": [
"accountSession/add"
],
"title": "AccountSession/addRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/v2/AccountSessionsAddParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/addRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/v2/RequestId"
},
"method": {
"enum": [
"accountSession/list"
],
"title": "AccountSession/listRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/v2/AccountSessionsListParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/listRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/v2/RequestId"
},
"method": {
"enum": [
"accountSession/logout"
],
"title": "AccountSession/logoutRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/v2/AccountSessionsLogoutParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/logoutRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/v2/RequestId"
},
"method": {
"enum": [
"accountSession/switch"
],
"title": "AccountSession/switchRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/v2/AccountSessionsSwitchParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/switchRequest",
"type": "object"
},
{
"properties": {
"id": {
@@ -5827,193 +5731,6 @@
"title": "AccountRateLimitsUpdatedNotification",
"type": "object"
},
"AccountSession": {
"properties": {
"displayName": {
"type": [
"string",
"null"
]
},
"email": {
"type": [
"string",
"null"
]
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"isActive": {
"type": "boolean"
},
"lastUsedAt": {
"format": "int64",
"type": "integer"
},
"plan": {
"type": [
"string",
"null"
]
},
"selectedWorkspaceAccountId": {
"type": [
"string",
"null"
]
},
"sessionId": {
"type": "string"
},
"userId": {
"type": [
"string",
"null"
]
},
"workspaces": {
"items": {
"$ref": "#/definitions/v2/AccountSessionWorkspace"
},
"type": "array"
}
},
"required": [
"isActive",
"lastUsedAt",
"sessionId",
"workspaces"
],
"type": "object"
},
"AccountSessionWorkspace": {
"properties": {
"accountId": {
"type": "string"
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"kind": {
"anyOf": [
{
"$ref": "#/definitions/v2/AccountSessionWorkspaceKind"
},
{
"type": "null"
}
]
},
"name": {
"type": [
"string",
"null"
]
},
"status": {
"$ref": "#/definitions/v2/AccountSessionWorkspaceStatus"
}
},
"required": [
"accountId",
"status"
],
"type": "object"
},
"AccountSessionWorkspaceKind": {
"enum": [
"personal",
"workspace"
],
"type": "string"
},
"AccountSessionWorkspaceStatus": {
"enum": [
"active",
"disabled",
"deactivated"
],
"type": "string"
},
"AccountSessionsAddParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"switchToAddedAccount": {
"type": "boolean"
}
},
"title": "AccountSessionsAddParams",
"type": "object"
},
"AccountSessionsListParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"refreshWorkspaceMetadata": {
"type": "boolean"
}
},
"title": "AccountSessionsListParams",
"type": "object"
},
"AccountSessionsLogoutParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"sessionId": {
"type": "string"
}
},
"required": [
"sessionId"
],
"title": "AccountSessionsLogoutParams",
"type": "object"
},
"AccountSessionsResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"activeSessionId": {
"type": [
"string",
"null"
]
},
"sessions": {
"items": {
"$ref": "#/definitions/v2/AccountSession"
},
"type": "array"
}
},
"required": [
"sessions"
],
"title": "AccountSessionsResponse",
"type": "object"
},
"AccountSessionsSwitchParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"accountId": {
"type": "string"
},
"sessionId": {
"type": "string"
}
},
"required": [
"accountId",
"sessionId"
],
"title": "AccountSessionsSwitchParams",
"type": "object"
},
"AccountUpdatedNotification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {

View File

@@ -103,193 +103,6 @@
"title": "AccountRateLimitsUpdatedNotification",
"type": "object"
},
"AccountSession": {
"properties": {
"displayName": {
"type": [
"string",
"null"
]
},
"email": {
"type": [
"string",
"null"
]
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"isActive": {
"type": "boolean"
},
"lastUsedAt": {
"format": "int64",
"type": "integer"
},
"plan": {
"type": [
"string",
"null"
]
},
"selectedWorkspaceAccountId": {
"type": [
"string",
"null"
]
},
"sessionId": {
"type": "string"
},
"userId": {
"type": [
"string",
"null"
]
},
"workspaces": {
"items": {
"$ref": "#/definitions/AccountSessionWorkspace"
},
"type": "array"
}
},
"required": [
"isActive",
"lastUsedAt",
"sessionId",
"workspaces"
],
"type": "object"
},
"AccountSessionWorkspace": {
"properties": {
"accountId": {
"type": "string"
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"kind": {
"anyOf": [
{
"$ref": "#/definitions/AccountSessionWorkspaceKind"
},
{
"type": "null"
}
]
},
"name": {
"type": [
"string",
"null"
]
},
"status": {
"$ref": "#/definitions/AccountSessionWorkspaceStatus"
}
},
"required": [
"accountId",
"status"
],
"type": "object"
},
"AccountSessionWorkspaceKind": {
"enum": [
"personal",
"workspace"
],
"type": "string"
},
"AccountSessionWorkspaceStatus": {
"enum": [
"active",
"disabled",
"deactivated"
],
"type": "string"
},
"AccountSessionsAddParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"switchToAddedAccount": {
"type": "boolean"
}
},
"title": "AccountSessionsAddParams",
"type": "object"
},
"AccountSessionsListParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"refreshWorkspaceMetadata": {
"type": "boolean"
}
},
"title": "AccountSessionsListParams",
"type": "object"
},
"AccountSessionsLogoutParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"sessionId": {
"type": "string"
}
},
"required": [
"sessionId"
],
"title": "AccountSessionsLogoutParams",
"type": "object"
},
"AccountSessionsResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"activeSessionId": {
"type": [
"string",
"null"
]
},
"sessions": {
"items": {
"$ref": "#/definitions/AccountSession"
},
"type": "array"
}
},
"required": [
"sessions"
],
"title": "AccountSessionsResponse",
"type": "object"
},
"AccountSessionsSwitchParams": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"accountId": {
"type": "string"
},
"sessionId": {
"type": "string"
}
},
"required": [
"accountId",
"sessionId"
],
"title": "AccountSessionsSwitchParams",
"type": "object"
},
"AccountUpdatedNotification": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
@@ -2722,102 +2535,6 @@
"title": "Account/login/cancelRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/add"
],
"title": "AccountSession/addRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsAddParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/addRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/list"
],
"title": "AccountSession/listRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsListParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/listRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/logout"
],
"title": "AccountSession/logoutRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsLogoutParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/logoutRequest",
"type": "object"
},
{
"properties": {
"id": {
"$ref": "#/definitions/RequestId"
},
"method": {
"enum": [
"accountSession/switch"
],
"title": "AccountSession/switchRequestMethod",
"type": "string"
},
"params": {
"$ref": "#/definitions/AccountSessionsSwitchParams"
}
},
"required": [
"id",
"method",
"params"
],
"title": "AccountSession/switchRequest",
"type": "object"
},
{
"properties": {
"id": {

View File

@@ -1,10 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"switchToAddedAccount": {
"type": "boolean"
}
},
"title": "AccountSessionsAddParams",
"type": "object"
}

View File

@@ -1,10 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"refreshWorkspaceMetadata": {
"type": "boolean"
}
},
"title": "AccountSessionsListParams",
"type": "object"
}

View File

@@ -1,13 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"sessionId": {
"type": "string"
}
},
"required": [
"sessionId"
],
"title": "AccountSessionsLogoutParams",
"type": "object"
}

View File

@@ -1,139 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AccountSession": {
"properties": {
"displayName": {
"type": [
"string",
"null"
]
},
"email": {
"type": [
"string",
"null"
]
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"isActive": {
"type": "boolean"
},
"lastUsedAt": {
"format": "int64",
"type": "integer"
},
"plan": {
"type": [
"string",
"null"
]
},
"selectedWorkspaceAccountId": {
"type": [
"string",
"null"
]
},
"sessionId": {
"type": "string"
},
"userId": {
"type": [
"string",
"null"
]
},
"workspaces": {
"items": {
"$ref": "#/definitions/AccountSessionWorkspace"
},
"type": "array"
}
},
"required": [
"isActive",
"lastUsedAt",
"sessionId",
"workspaces"
],
"type": "object"
},
"AccountSessionWorkspace": {
"properties": {
"accountId": {
"type": "string"
},
"imageUrl": {
"type": [
"string",
"null"
]
},
"kind": {
"anyOf": [
{
"$ref": "#/definitions/AccountSessionWorkspaceKind"
},
{
"type": "null"
}
]
},
"name": {
"type": [
"string",
"null"
]
},
"status": {
"$ref": "#/definitions/AccountSessionWorkspaceStatus"
}
},
"required": [
"accountId",
"status"
],
"type": "object"
},
"AccountSessionWorkspaceKind": {
"enum": [
"personal",
"workspace"
],
"type": "string"
},
"AccountSessionWorkspaceStatus": {
"enum": [
"active",
"disabled",
"deactivated"
],
"type": "string"
}
},
"properties": {
"activeSessionId": {
"type": [
"string",
"null"
]
},
"sessions": {
"items": {
"$ref": "#/definitions/AccountSession"
},
"type": "array"
}
},
"required": [
"sessions"
],
"title": "AccountSessionsResponse",
"type": "object"
}

View File

@@ -1,17 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"accountId": {
"type": "string"
},
"sessionId": {
"type": "string"
}
},
"required": [
"accountId",
"sessionId"
],
"title": "AccountSessionsSwitchParams",
"type": "object"
}

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AccountSessionWorkspace } from "./AccountSessionWorkspace";
export type AccountSession = { sessionId: string, email: string | null, userId: string | null, displayName: string | null, imageUrl: string | null, plan: string | null, lastUsedAt: bigint, isActive: boolean, selectedWorkspaceAccountId: string | null, workspaces: Array<AccountSessionWorkspace>, };

View File

@@ -1,7 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AccountSessionWorkspaceKind } from "./AccountSessionWorkspaceKind";
import type { AccountSessionWorkspaceStatus } from "./AccountSessionWorkspaceStatus";
export type AccountSessionWorkspace = { accountId: string, name: string | null, imageUrl: string | null, kind: AccountSessionWorkspaceKind | null, status: AccountSessionWorkspaceStatus, };

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionWorkspaceKind = "personal" | "workspace";

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionWorkspaceStatus = "active" | "disabled" | "deactivated";

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionsAddParams = { switchToAddedAccount?: boolean, };

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionsListParams = { refreshWorkspaceMetadata?: boolean, };

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionsLogoutParams = { sessionId: string, };

View File

@@ -1,6 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AccountSession } from "./AccountSession";
export type AccountSessionsResponse = { activeSessionId: string | null, sessions: Array<AccountSession>, };

View File

@@ -1,5 +0,0 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AccountSessionsSwitchParams = { sessionId: string, accountId: string, };

View File

@@ -3,15 +3,6 @@
export type { Account } from "./Account";
export type { AccountLoginCompletedNotification } from "./AccountLoginCompletedNotification";
export type { AccountRateLimitsUpdatedNotification } from "./AccountRateLimitsUpdatedNotification";
export type { AccountSession } from "./AccountSession";
export type { AccountSessionWorkspace } from "./AccountSessionWorkspace";
export type { AccountSessionWorkspaceKind } from "./AccountSessionWorkspaceKind";
export type { AccountSessionWorkspaceStatus } from "./AccountSessionWorkspaceStatus";
export type { AccountSessionsAddParams } from "./AccountSessionsAddParams";
export type { AccountSessionsListParams } from "./AccountSessionsListParams";
export type { AccountSessionsLogoutParams } from "./AccountSessionsLogoutParams";
export type { AccountSessionsResponse } from "./AccountSessionsResponse";
export type { AccountSessionsSwitchParams } from "./AccountSessionsSwitchParams";
export type { AccountUpdatedNotification } from "./AccountUpdatedNotification";
export type { ActivePermissionProfile } from "./ActivePermissionProfile";
export type { AddCreditsNudgeCreditType } from "./AddCreditsNudgeCreditType";

View File

@@ -919,33 +919,6 @@ client_request_definitions! {
response: v2::CancelLoginAccountResponse,
},
AccountSessionsAdd => "accountSession/add" {
params: v2::AccountSessionsAddParams,
serialization: global("account-auth"),
response: v2::AccountSessionsResponse,
},
AccountSessionsList => "accountSession/list" {
params: v2::AccountSessionsListParams,
serialization: global("account-auth"),
manual_payload_conversion: manual,
response: v2::AccountSessionsResponse,
},
AccountSessionsLogout => "accountSession/logout" {
params: v2::AccountSessionsLogoutParams,
serialization: global("account-auth"),
manual_payload_conversion: manual,
response: v2::AccountSessionsResponse,
},
AccountSessionsSwitch => "accountSession/switch" {
params: v2::AccountSessionsSwitchParams,
serialization: global("account-auth"),
manual_payload_conversion: manual,
response: v2::AccountSessionsResponse,
},
LogoutAccount => "account/logout" {
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
serialization: global("account-auth"),

View File

@@ -13,13 +13,10 @@ use serde::de::Deserializer;
use serde_json::Value;
use std::collections::HashMap;
#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug)]
pub struct AccountsCheckResponse {
#[serde(default)]
pub accounts: Vec<AccountEntry>,
#[serde(default)]
pub account_ordering: Vec<String>,
#[serde(default)]
pub default_account_id: Option<String>,
}
@@ -34,6 +31,75 @@ pub struct AccountEntry {
pub structure: String,
}
#[derive(Deserialize)]
struct RawAccountsCheckResponse {
#[serde(default)]
accounts: RawAccounts,
#[serde(default)]
account_ordering: Vec<String>,
#[serde(default)]
default_account_id: Option<String>,
}
#[derive(Deserialize)]
#[serde(untagged)]
enum RawAccounts {
List(Vec<AccountEntry>),
Map(HashMap<String, ChatGptAccountEntry>),
}
impl Default for RawAccounts {
fn default() -> Self {
Self::List(Vec::new())
}
}
#[derive(Deserialize)]
struct ChatGptAccountEntry {
account: ChatGptAccountInfo,
}
#[derive(Deserialize)]
struct ChatGptAccountInfo {
account_id: Option<String>,
#[serde(default)]
name: Option<String>,
#[serde(default)]
profile_picture_url: Option<String>,
#[serde(default)]
structure: String,
}
impl<'de> Deserialize<'de> for AccountsCheckResponse {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let raw = RawAccountsCheckResponse::deserialize(deserializer)?;
let accounts = match raw.accounts {
RawAccounts::List(accounts) => accounts,
RawAccounts::Map(mut accounts) => raw
.account_ordering
.iter()
.filter_map(|account_id| {
let account = accounts.remove(account_id)?.account;
Some(AccountEntry {
id: account.account_id?,
name: account.name,
profile_picture_url: account.profile_picture_url,
structure: account.structure,
})
})
.collect(),
};
Ok(Self {
accounts,
account_ordering: raw.account_ordering,
default_account_id: raw.default_account_id,
})
}
}
/// Hand-rolled models for the Cloud Tasks task-details response.
/// The generated OpenAPI models are pretty bad. This is a half-step
/// towards hand-rolling them.