| 443 | async migrateCursorSessionToAcp(sessionId: string, body: CursorMigrateToAcpRequest = {}): Promise<CursorMigrateOutcome> { |
| 444 | const path = `/api/sessions/${encodeURIComponent(sessionId)}/migrate-to-acp` |
| 445 | const tryOnce = async (overrideToken: string | null): Promise<Response> => { |
| 446 | const headers = new Headers({ 'content-type': 'application/json' }) |
| 447 | const liveToken = this.getToken ? this.getToken() : null |
| 448 | const authToken = overrideToken ?? liveToken ?? this.token |
| 449 | if (authToken) { |
| 450 | headers.set('authorization', `Bearer ${authToken}`) |
| 451 | } |
| 452 | return fetch(this.buildUrl(path), { method: 'POST', headers, body: JSON.stringify(body) }) |
| 453 | } |
| 454 | |
| 455 | let res = await tryOnce(null) |
| 456 | if (res.status === 401 && this.onUnauthorized) { |