ó
    À‘´jÙ  ã                  ó*   • S r SSKJr  SrSrSrSS jrg)	u9	  
Workaround module â€” call it only along an OAuth code path.

This module exists solely to satisfy Anthropic's Claude Code OAuth
subscription gate, which requires the system prompt to be sent in
array format with a specific identity string as the first text block.
pydantic-ai's `AnthropicModel` joins all `system_prompt=` parts into a
single string before sending, so an agent built with `system_prompt=`
alone cannot reach the gate through the library. It sends a list of
text blocks instead whenever a request carries instruction parts or the
`anthropic_cache_instructions` setting. Instruction parts come from
`instructions=`, from toolset or capability instructions, and from
prompted output mode.

Upstream issue draft: `issues/pydantic-ai-multi-block-system-prompt.md`
(not yet filed against pydantic/pydantic-ai).

When the upstream fix ships and pydantic-ai supports array system
prompts natively:
  1. Delete this module.
  2. Replace every `make_oauth_anthropic_model` call with a stock
     `AnthropicModel`, and give every agent built on it
     `CLAUDE_CODE_IDENTITY` as its first system block, ahead of its own
     prompt.
  3. Delete `issues/pydantic-ai-multi-block-system-prompt.md`.

Scope guarantees (the ring-fence):

- Every caller of `make_oauth_anthropic_model`, in `quber/agents/` and
  in `quber/playground/agent.py`, calls it only along the OAuth code
  path, when an OAuth token resolves. The API-key path
  (`ANTHROPIC_API_KEY`) constructs a stock `AnthropicModel` and never
  calls into this module.
- The wrapped `AsyncAnthropic` client is constructed *inside* this
  module and returned only via `make_oauth_anthropic_model`. Nothing
  else in quber holds a reference to that client. The wrapped
  `messages.create` cannot leak into other usages.
- The wrapper rewrites only the `system` field, only when it is a
  plain string. List-shaped `system` and `None` are pass-through. A
  list goes out without the identity block, so an agent whose requests
  carry instruction parts or `anthropic_cache_instructions` gets no
  identity block from this wrapper.
- The wrapper applies to **all** model IDs invoked through this
  client. That is intentional: the gate is a property of the
  subscription endpoint, not of any specific model. Haiku passes
  the gate too â€” sending the identity block does not change Haiku's
  behavior.
é    )Úannotationsz9You are Claude Code, Anthropic's official CLI for Claude.z>claude-cli/2.1.119 (external, claude-vscode, agent-sdk/0.1.75)z%oauth-2025-04-20,claude-code-20250219c                óà   ^• SSK Jn  SSKJn  SSKJn  U" U[        [        S.S9nUR                  R                  R                  mU4S jnXeR                  R                  l
        U" X" US9S	9$ )
uf  Construct an `AnthropicModel` whose underlying SDK client has its
`beta.messages.create` wrapped to rewrite the `system` field into
the 2-block array format the OAuth gate requires.

Returned model is safe to hand to pydantic-ai's `Agent` â€” it
behaves like any other `AnthropicModel` from the library's
perspective. The rewrite is invisible to the caller.
r   )ÚAsyncAnthropic)ÚAnthropicModel)ÚAnthropicProvider)zanthropic-betaz
User-Agent)Ú
auth_tokenÚdefault_headersc               Ÿ  óž   >#   • UR                  S5      n[        U[        5      (       a  S[        S.SUS./US'   T" U 0 UD6I S h  v•N $  N7f)NÚsystemÚtext)Útyper   )ÚgetÚ
isinstanceÚstrÚCLAUDE_CODE_IDENTITY)ÚargsÚkwargsr   Úorig_creates      €Ú6/home/mande/repo/quber/src/quber/agents/_oauth_gate.pyÚcreate_with_identity_blockÚ>make_oauth_anthropic_model.<locals>.create_with_identity_block^   sX   øé € ð —‘˜HÓ%ˆÜ�fœc×"Ñ"àÔ)=Ñ>Ø¨Ñ0ð ˆF�8Ññ ! $Ð1¨&Ñ1×1Ð1Ñ1ùs   ƒAAÁAÁA)Úanthropic_client)Úprovider)Ú	anthropicr   Úpydantic_ai.models.anthropicr   Úpydantic_ai.providers.anthropicr   ÚCLAUDE_CODE_BETAÚCLAUDE_CODE_USER_AGENTÚbetaÚmessagesÚcreate)Ú
model_namer   r   r   r   Úclientr   r   s          @r   Úmake_oauth_anthropic_modelr$   G   sh   ø€ õ )Ý;ÝAáØä.Ü0ñ
ñ€Fð —+‘+×&Ñ&×-Ñ-€Kõ2ð #=‡K�K×ÑÔá˜*Ð/@ÐRXÑ/YÑZÐZó    N)r"   r   r   r   )Ú__doc__Ú
__future__r   r   r   r   r$   © r%   r   Ú<module>r)      s0   ðñ/õb #ð SÐ ð ZÐ ð
 ;Ð õ'[r%   