1
>
/*---------------------------------------------------------------------------------------------
codexAccountState.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type { ProtectedResourceMetadata } from '../../common/state/protocol/common/state.js';
7
>
import type { CodexUsageSource } from '../../common/agentHostCustomizationConfig.js';
8
>
import type { GetAccountResponse } from './protocol/generated/v2/GetAccountResponse.js';
9
>
10
>
export interface ICodexAccountState {
11
>
readonly usageSource: 'openai' | 'copilot';
12
>
readonly status: 'signedIn' | 'signedOut' | 'error';
13
>
readonly authType?: 'chatgpt' | 'apiKey' | 'other';
14
>
readonly planType?: string;
15
>
readonly error?: string;
16
>
}
17
>
18
>
export function codexAccountStateFromResponse(response: GetAccountResponse): ICodexAccountState {
19
if (response.account?.type === 'chatgpt') {
20
return { usageSource: 'openai', status: 'signedIn', authType: 'chatgpt', planType: response.account.planType };