@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
23 lines • 1.03 kB
JavaScript
/**
* "This server needs OAuth" classification, shared by the connect path
* (`connection.ts`) and the tool-call health path (`health.ts`).
*
* Lives in its own module so neither of those files has to import the MCP SDK
* for the `UnauthorizedError` identity check; `sdk.lazy.ts` owns that identity
* and answers synchronously from the module the auth/HTTP paths already loaded.
*/
import { OAuthFlowError } from "./auth/oauth-errors.js";
import { isMcpSdkUnauthorizedError } from "./sdk.lazy.js";
const MAX_CAUSE_DEPTH = 5;
export function isMcpNeedsAuthError(error, depth = 0) {
if (isMcpSdkUnauthorizedError(error))
return true;
if (error instanceof OAuthFlowError)
return error.terminal;
// connectMcpTransport wraps the SDK error in a ConnectError; unwrap the cause.
if (depth < MAX_CAUSE_DEPTH && error !== null && typeof error === "object" && "cause" in error) {
return isMcpNeedsAuthError(error.cause, depth + 1);
}
return false;
}
//# sourceMappingURL=needs-auth.js.map