| 1027 | } |
| 1028 | |
| 1029 | function normalizeCodexIntegrationState(rawOutput: string): CodexIntegrationState { |
| 1030 | const normalizedOutput = rawOutput.toLowerCase() |
| 1031 | |
| 1032 | if (normalizedOutput.includes("logged in using chatgpt")) { |
| 1033 | return "connected_chatgpt" |
| 1034 | } |
| 1035 | |
| 1036 | if ( |
| 1037 | normalizedOutput.includes("logged in using an api key") || |
| 1038 | normalizedOutput.includes("logged in using api key") |
| 1039 | ) { |
| 1040 | return "connected_api_key" |
| 1041 | } |
| 1042 | |
| 1043 | if (normalizedOutput.includes("not logged in")) { |
| 1044 | return "not_logged_in" |
| 1045 | } |
| 1046 | |
| 1047 | return "unknown" |
| 1048 | } |
| 1049 | |
| 1050 | function parseStoredMessages(raw: string | null | undefined): any[] { |
| 1051 | if (!raw) return [] |