fix: added Cursor OAuth provider and fixed authentication flow race conditions

- Added Cursor OAuth provider support to CLI authentication flow.
- Fixed race conditions in OAuth callback handling and session picker cleanup.
- Improved JWT token parsing and error handling across OAuth providers.
- Replaced Bun.sleep() with abortable sleep for proper cancellation support.
- Enhanced process execution with concurrent stream reading and better timeout handling.
- Added cache cleanup mechanism for auth storage with 5-minute intervals.
This commit is contained in:
can1357
2026-01-20 19:50:50 +01:00
parent 94f406d4f0
commit 21af96d890
35 changed files with 468 additions and 287 deletions
@@ -4,7 +4,7 @@
* Provides unified bash execution for AgentSession.executeBash() and direct calls.
*/
import { cspawn, Exception } from "@oh-my-pi/pi-utils";
import { cspawn, Exception, ptree } from "@oh-my-pi/pi-utils";
import { getShellConfig } from "../utils/shell";
import { getOrCreateSnapshot, getSnapshotSourceCommand } from "../utils/shell-snapshot";
import { OutputSink } from "./streaming-output";
@@ -63,7 +63,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
// Exception covers NonZeroExitError, AbortError, TimeoutError
if (err instanceof Exception) {
if (err.aborted) {
const isTimeout = err.message.includes("timed out");
const isTimeout = err instanceof ptree.TimeoutError || err.message.toLowerCase().includes("timed out");
const annotation = isTimeout
? `Command timed out after ${Math.round((options?.timeout ?? 0) / 1000)} seconds`
: undefined;