ó
    ù!‡jÏ  ã                  ó  • S r SSKJr  SSKrSSKJrJrJrJrJ	r	J
r
  SSKJrJr  SSKJrJr  SSKJrJr   " S S	\5      rS
\R*                  " \R-                  5       SS9 S3r\
 " S S\	5      5       r " S S5      r " S S5      rSS jrg)u  
CoverAttributor Protocol â€” decides scan breadth for a document nobody typed.

One narrow question, answered from the cover page and the page count: is this
a presentation-style document or a prose-and-table filing? The answer selects
how many pages the figure scan reads â€” a presentation scans every page, a
filing scans only the pages the parse nominates. Nothing else hangs off it:
the attributor never writes the document's filing type, which is identity
metadata the user owns, and it never runs when a filing type was supplied.

The caller owns the failure policy. An attribution that raises must fall back
to the cheap path and say so where the run is recorded, because the point of
this agent is that a missing type can never buy the expensive path by
accident.
é    )ÚannotationsN)ÚAnyÚDictÚLiteralÚOptionalÚProtocolÚruntime_checkable)Ú	BaseModelÚField)ÚLangSmithTracerÚusage_metadata_from)ÚDEFAULT_LLM_MODELÚget_settingsc                  óD   • \ rS rSr% \" SS9rS\S'   \" SSS9rS	\S
'   Srg)ÚCoverAttributioné   a  'presentation' for a slide-deck-style document: an earnings deck, supplemental package, or investor presentation, where content is laid out visually page by page. 'filing' for a prose-and-table document: a 10-Q, 10-K, prospectus, or agreement, read as continuous text.)Údescriptionz!Literal['presentation', 'filing']ÚkindÚ z7One short sentence naming what on the cover decided it.)Údefaultr   ÚstrÚreason© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   Ú__annotations__r   Ú__static_attributes__r   ó    Ú</home/mande/repo/quber/src/quber/agents/cover_attribution.pyr   r      s2   ‡ Ù.3ðñ/€DÐ
+ó ñ ØØMñ€FˆCö r    r   u  You are shown the first page of a financial document and told its page count.

Decide which of two kinds the document is:

- *presentation*: a slide-deck-style document â€” an earnings presentation,
  quarterly supplemental package, or investor deck. Typical covers carry a
  company name and quarter as a designed title page, often landscape, often
  image-heavy, with little continuous prose.
- *filing*: a prose-and-table document â€” a Form 10-Q or 10-K, prospectus, or
  agreement. Typical covers carry an SEC form header, registrant details, and
  dense typeset text, and the document runs long.

Answer from what the cover shows. The page count is context, not the answer:
long presentations and short filings both exist.

Return a JSON object conforming exactly to this schema:

é   )ÚindentuE   

Return only the JSON object â€” no prose, no markdown code fences.
c                  ó   • \ rS rSrSS jrSrg)ÚCoverAttributoréD   c              ƒ  ó   #   • g 7f©Nr   )ÚselfÚ	cover_pngÚ
page_counts      r!   Ú	attributeÚCoverAttributor.attributeF   s   é € ÐVYùs   ‚r   N©r*   Úbytesr+   ÚintÚreturnr   )r   r   r   r   r,   r   r   r    r!   r%   r%   D   s   † çYr    r%   c                  óN   • \ rS rSrSr   S       S	S jjrS
S jrSS jrSrg)ÚPydanticAICoverAttributoréI   ub  CoverAttributor backed by pydantic-ai with an Anthropic model.

Auth resolution mirrors the other agents: `ANTHROPIC_AUTH_TOKEN` preferred
over `ANTHROPIC_API_KEY`. A failure raises to the caller â€” this agent's
contract is that the caller falls back to the cheap path and records why,
so a silent default here would hide exactly what must be surfaced.
Nc                ó¤  • SSK Jn  SSKJn  SSKJn  [        5       R                  nU=(       d    UR                  =(       d    [        nU=(       d    UR                  nU=(       d    UR                  n	U(       a  SSKJn
  U
" X5      nOU	(       a  U" U	S9nU" XS9nO[        S5      eXl        U" U[        [         S	9U l        [%        S
S9U l        g )Nr   )ÚAgent)ÚAnthropicModel)ÚAnthropicProvider)Úmake_oauth_anthropic_model)Úapi_key)ÚproviderzyPydanticAICoverAttributor: neither ANTHROPIC_AUTH_TOKEN nor ANTHROPIC_API_KEY is set. Provide one via env or constructor.)Úoutput_typeÚsystem_promptzquber-cover-attribution)Úrun_name)Úpydantic_air6   Úpydantic_ai.models.anthropicr7   Úpydantic_ai.providers.anthropicr8   r   ÚllmÚmodelr   Úanthropic_auth_tokenÚanthropic_api_keyÚquber.agents._oauth_gater9   ÚRuntimeErrorr   ÚATTRIBUTE_COVER_PROMPTÚagentr   Útracer)r)   rC   Ú
auth_tokenr:   r6   r7   r8   Úllm_settingsÚresolved_authÚresolved_keyr9   Ú
anth_modelr;   s                r!   Ú__init__Ú"PydanticAICoverAttributor.__init__R   sµ   € õ 	&Ý?ÝEä#“~×)Ñ)ˆØ×@˜×+Ñ+×@Ô/@ˆØ"×G l×&GÑ&GˆØ×@ ,×"@Ñ"@ˆæÝKá3°EÓI‰JÞÙ(°Ñ>ˆHÙ'¨ÑA‰JäðPóð ð
 Œ
ÙØÜ(Ü0ñ
ˆŒ
ô
 &Ð/HÑIˆ�r    c                ó:   • SS[         S.SSSU S3S.SS	S./S./0$ )
NÚmessagesÚsystem©ÚroleÚcontentÚuserÚtextúThe document is ú pages long.)ÚtyperY   z<cover page image>)rH   )r)   r+   s     r!   Útrace_inputsÚ&PydanticAICoverAttributor.trace_inputsv   sE   € àØ!Ô.DÑEà"à!'Ð3CÀJÀ<È|Ð1\Ñ]Ø!'Ð1EÑFð ñð	ð
ð 	
r    c              ƒ  óú  #   • SSK Jn  U" USS9nU R                  U5      nU R                  R	                  SXPR
                  S9 IS h  v•N nU R                  R                  SU S3U/5      I S h  v•N nUR                  nS	UR                  5       S
./UR                  UR                  [        UR                  5      S.Ul        S S S 5      IS h  v•N   U$  N� Ni N
! , IS h  v•N  (       d  f       W$ = f7f)Nr   )ÚBinaryContentz	image/png)ÚdataÚ
media_typeÚattribute_cover)rC   rZ   r[   Ú	assistantrU   )rS   r   r   Úusage_metadata)r?   r`   r]   rJ   Úllm_runrC   rI   ÚrunÚoutputÚmodel_dump_jsonr   r   r   ÚusageÚoutputs)	r)   r*   r+   r`   ÚimageÚinputsrg   Úresultrh   s	            r!   r,   Ú#PydanticAICoverAttributor.attribute„   s×   é € Ý-á 9¸ÑEˆØ×"Ñ" :Ó.ˆØ—;‘;×&Ñ&Ð'8¸&Ï
É
Ð&×SÑSÐWZØŸ:™:Ÿ>™>Ð-=¸j¸\ÈÐ+VÐX]Ð*^Ó_×_ˆFØ—]‘]ˆFà&1¸f×>TÑ>TÓ>VÑWÐXØŸ™Ø Ÿ-™-Ü"5°f·l±lÓ"Cñ	ˆCŒK÷ T×Sð ˆñ TÙ_÷ T×S×Sð ˆüs[   ‚AC;Á	CÁ
C;Á%C Á2CÁ3AC ÃC;ÃCÃC;ÃC ÃC;Ã C8Ã&C)Ã'C8Ã3C;)rI   rC   rJ   )NNN)rC   úOptional[str]rK   rp   r:   rp   r1   ÚNone)r+   r0   r1   zDict[str, Any]r.   )	r   r   r   r   Ú__doc__rP   r]   r,   r   r   r    r!   r3   r3   I   sM   † ñð  $Ø$(Ø!%ð	"Jàð"Jð "ð"Jð ð	"Jð
 
õ"JôH
÷r    r3   c                  ó0   • \ rS rSrSrSSS jjrS	S jrSrg)
ÚMockCoverAttributoré•   z-Returns a canned CoverAttribution. For tests.Nc                ó4   • U=(       d
    [        SSS9U l        g )NÚpresentationÚmock)r   r   )r   rn   )r)   rn   s     r!   rP   ÚMockCoverAttributor.__init__˜   s   € Ø×TÔ 0°nÈVÑ Tˆ�r    c              ƒ  ó(   #   • X4nU R                   $ 7fr(   ©rn   )r)   r*   r+   Ú_s       r!   r,   ÚMockCoverAttributor.attribute›   s   é € ØÐ!ˆØ�{‰{Ðùs   ‚r{   r(   )rn   zOptional[CoverAttribution]r1   rq   r.   )r   r   r   r   rr   rP   r,   r   r   r    r!   rt   rt   •   s   † Ù7öU÷r    rt   c                 ó   • [        5       $ r(   )r3   r   r    r!   Úget_cover_attributorr       s   € Ü$Ó&Ð&r    )r1   r%   )rr   Ú
__future__r   ÚjsonÚtypingr   r   r   r   r   r	   Úpydanticr
   r   Úquber.agents.langsmith_tracerr   r   Úquber.settingsr   r   r   ÚdumpsÚmodel_json_schemarH   r%   r3   rt   r   r   r    r!   Ú<module>rˆ      s–   ðñõ  #ã ß L× Lç %ç Nß :ô�yô ð ð$ ‡‚Ð×.Ñ.Ó0¸Ñ;Ð <ð =ð%Ð ð0 ôZ�hó Zó ðZ÷Iñ I÷Xñ õ'r    