@@ -468,55 +468,12 @@ pub mod client {
468468 self . config . api_key . is_empty ( )
469469 }
470470
471- /// Returns `true` when this client is configured to use a Claude Code
472- /// OAuth Bearer token (Claude.ai Pro/Max). The query path and the
473- /// request builders check this to enable stealth-impersonation.
471+ /// Returns `true` when this client is configured to use Bearer-token
472+ /// authorization instead of an Anthropic API key.
474473 pub fn is_oauth ( & self ) -> bool {
475474 self . config . use_bearer_auth
476475 }
477476
478- /// Mutate the outgoing request so it looks like Claude Code when the
479- /// client is authenticated with an OAuth Bearer token:
480- ///
481- /// 1. Prepend the required `"You are Claude Code, …"` system block.
482- /// Existing system content is preserved as a second block so the
483- /// rest of Coven Code's prompt assembly still reaches the model.
484- ///
485- /// No-op when `use_bearer_auth` is false (API-key flow).
486- fn apply_oauth_stealth ( & self , request : & mut CreateMessageRequest ) {
487- if !self . config . use_bearer_auth {
488- return ;
489- }
490-
491- let identity_block = SystemBlock {
492- block_type : "text" . to_string ( ) ,
493- text : claurst_core:: oauth_config:: CLAUDE_CODE_SYSTEM_PROMPT_PREFIX . to_string ( ) ,
494- cache_control : None ,
495- } ;
496-
497- request. system = match request. system . take ( ) {
498- None => Some ( SystemPrompt :: Blocks ( vec ! [ identity_block] ) ) ,
499- Some ( SystemPrompt :: Text ( existing) ) => {
500- let existing_block = SystemBlock {
501- block_type : "text" . to_string ( ) ,
502- text : existing,
503- cache_control : None ,
504- } ;
505- Some ( SystemPrompt :: Blocks ( vec ! [ identity_block, existing_block] ) )
506- }
507- Some ( SystemPrompt :: Blocks ( mut blocks) ) => {
508- // Avoid duplicating the identity block on retries / re-sends.
509- let already_first = blocks. first ( ) . is_some_and ( |b| {
510- b. text == claurst_core:: oauth_config:: CLAUDE_CODE_SYSTEM_PROMPT_PREFIX
511- } ) ;
512- if !already_first {
513- blocks. insert ( 0 , identity_block) ;
514- }
515- Some ( SystemPrompt :: Blocks ( blocks) )
516- }
517- } ;
518- }
519-
520477 /// Build a new client. Panics if `config.api_key` is empty.
521478 pub fn new ( config : ClientConfig ) -> anyhow:: Result < Self > {
522479 // Allow empty key at construction — validation is deferred to
@@ -592,8 +549,9 @@ pub mod client {
592549 model
593550 )
594551 } else {
595- "Set ANTHROPIC_API_KEY, run `coven-code auth login`, \
596- or use --provider to select a different provider (e.g. --provider openai).". to_string ( )
552+ "Set ANTHROPIC_API_KEY, or use --provider to select a different provider \
553+ (e.g. --provider openai). Anthropic OAuth login is disabled until Coven Code \
554+ has its own OAuth client.". to_string ( )
597555 } ;
598556 return Err ( ClaudeError :: Auth (
599557 format ! ( "No API key for the selected model. {}" , hint)
@@ -605,7 +563,6 @@ pub mod client {
605563 }
606564
607565 request. stream = false ;
608- self . apply_oauth_stealth ( & mut request) ;
609566 let body = serde_json:: to_value ( & request) . map_err ( ClaudeError :: Json ) ?;
610567
611568 let resp = self . send_with_retry ( & body) . await ?;
@@ -696,8 +653,9 @@ pub mod client {
696653 } else if model. starts_with ( "llama" ) {
697654 format ! ( "Model '{}' looks like a Llama model. Use `--provider groq` or `--provider ollama` for local." , model)
698655 } else {
699- "Set ANTHROPIC_API_KEY, run `coven-code auth login`, \
700- or use --provider to select a different provider (e.g. --provider openai).". to_string ( )
656+ "Set ANTHROPIC_API_KEY, or use --provider to select a different provider \
657+ (e.g. --provider openai). Anthropic OAuth login is disabled until Coven Code \
658+ has its own OAuth client.". to_string ( )
701659 } ;
702660 return Err ( ClaudeError :: Auth (
703661 format ! ( "No API key for the selected model. {}" , hint)
@@ -711,7 +669,6 @@ pub mod client {
711669 }
712670
713671 request. stream = true ;
714- self . apply_oauth_stealth ( & mut request) ;
715672 let body = serde_json:: to_value ( & request) . map_err ( ClaudeError :: Json ) ?;
716673
717674 let resp = self . send_with_retry ( & body) . await ?;
@@ -756,15 +713,7 @@ pub mod client {
756713 . header ( "anthropic-version" , & self . config . api_version )
757714 . header ( "content-type" , "application/json" ) ;
758715 if self . config . use_bearer_auth {
759- let ua = format ! (
760- "claude-cli/{}" ,
761- claurst_core:: oauth_config:: CLAUDE_CODE_VERSION_FOR_OAUTH
762- ) ;
763- req = req
764- . header ( "anthropic-beta" , claurst_core:: oauth_config:: OAUTH_BETA_FLAGS . join ( "," ) )
765- . header ( "user-agent" , ua)
766- . header ( "x-app" , "cli" )
767- . header ( "Authorization" , format ! ( "Bearer {}" , & self . config. api_key) ) ;
716+ req = req. header ( "Authorization" , format ! ( "Bearer {}" , & self . config. api_key) ) ;
768717 } else {
769718 req = req. header ( "x-api-key" , & self . config . api_key ) ;
770719 }
@@ -803,25 +752,10 @@ pub mod client {
803752 loop {
804753 attempts += 1 ;
805754
806- // Use Bearer auth for Claude.ai OAuth tokens; x-api-key for regular keys .
755+ // Use Bearer auth when explicitly configured; otherwise use x-api-key.
807756 let use_oauth = self . config . use_bearer_auth ;
808757
809- // On the OAuth path we impersonate Claude Code: prepend the
810- // required beta flags, advertise `claude-cli/<ver>` as the
811- // user-agent, and drop the CCH billing header (the real
812- // Claude Code client sends it but the API does not require
813- // it for OAuth tokens, and emitting it would fingerprint
814- // mismatch against the impersonated UA).
815- let anthropic_beta = if use_oauth {
816- let mut flags: Vec < & str > =
817- claurst_core:: oauth_config:: OAUTH_BETA_FLAGS . to_vec ( ) ;
818- if !self . config . beta_features . is_empty ( ) {
819- flags. push ( & self . config . beta_features ) ;
820- }
821- flags. join ( "," )
822- } else {
823- self . config . beta_features . clone ( )
824- } ;
758+ let anthropic_beta = self . config . beta_features . clone ( ) ;
825759
826760 let mut req = self
827761 . http
@@ -832,14 +766,7 @@ pub mod client {
832766 . header ( "accept" , "text/event-stream" ) ;
833767
834768 if use_oauth {
835- let ua = format ! (
836- "claude-cli/{}" ,
837- claurst_core:: oauth_config:: CLAUDE_CODE_VERSION_FOR_OAUTH
838- ) ;
839- req = req
840- . header ( "user-agent" , ua)
841- . header ( "x-app" , "cli" )
842- . header ( "Authorization" , format ! ( "Bearer {}" , & self . config. api_key) ) ;
769+ req = req. header ( "Authorization" , format ! ( "Bearer {}" , & self . config. api_key) ) ;
843770 } else {
844771 // Compute CCH billing hash and attach on the API-key path
845772 // only — this is the codepath the official client uses
0 commit comments