()
| 174 | } |
| 175 | |
| 176 | export async function ensureAuthenticated(): Promise<void> { |
| 177 | // Check if API key is set via environment variable |
| 178 | if (process.env.MXBAI_API_KEY) { |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | // Check for stored OAuth token |
| 183 | const token = await getStoredToken(); |
| 184 | if (token) { |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | const shouldLogin = await confirm({ |
| 189 | message: "You are not logged in. Would you like to login now?", |
| 190 | initialValue: true, |
| 191 | }); |
| 192 | |
| 193 | if (isCancel(shouldLogin) || !shouldLogin) { |
| 194 | cancel("Operation cancelled"); |
| 195 | process.exit(0); |
| 196 | } |
| 197 | |
| 198 | await loginAction(); |
| 199 | } |
| 200 | |
| 201 | export async function deleteFile( |
| 202 | store: Store, |
no test coverage detected