§
    øžyj´#  ã                  ó~   — d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 dZ
dZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS )u  ``hermes portal`` â€” the human-readable entry point for Nous Portal.

Running ``hermes portal`` with no subcommand performs the one-shot Portal
onboarding: OAuth login, pick a Nous model, switch the inference provider to
Nous, and offer to enable the Tool Gateway. It is the friendly alias for
``hermes auth add nous --type oauth`` (which still works), is identical to
``hermes setup --portal``, and runs the same Nous flow as the first-time quick
setup.

Subcommands:
  (none)   Log in to Nous Portal + set it up (one-shot onboarding).
  login    Explicit alias for the default one-shot onboarding.
  info     Show Portal auth state + which Tool Gateway tools are routed.
  open     Open the Portal subscription page in the user's default browser.
  tools    List Tool Gateway tools and which are active in the current config.

This command is intentionally minimal â€” it does not duplicate functionality
already in ``hermes auth`` or ``hermes tools``. It's the onboarding + discovery
surface for the Portal subscription itself.
é    )ÚannotationsN)ÚColorsÚcolor)Úload_configzhttps://portal.nousresearch.comz3https://portal.nousresearch.com/manage-subscriptionzKhttps://hermes-agent.nousresearch.com/docs/user-guide/features/tool-gatewayÚreturnÚintc                óð  — ddl m} ddlm} t	          ¦   «         pi }	  |¦   «         pi }n# t
          $ r i }Y nw xY wt          |                     d¦  «        ¦  «        }t          ¦   «          t          t          dt          j        ¦  «        ¦  «         t          t          dt          j        ¦  «        ¦  «         |r‚|                     d¦  «        pt          }t          dt          d	t          j        ¦  «        › �¦  «         t          d
|› �¦  «         |                     d¦  «        }|rt          d|› �¦  «         nPt          dt          dt          j        ¦  «        › �¦  «         t          dt          › �¦  «         t          d¦  «         t!          |                     d¦  «        t"          ¦  «        r|                     d¦  «        ni }t%          |                     d¦  «        pd¦  «                             ¦   «                              ¦   «         }	|	dk    r+t          dt          dt          j        ¦  «        › �¦  «         n|	rt          d|	› d�¦  «         t          ¦   «          t          t          dt          j        ¦  «        ¦  «         t          t          dt          j        ¦  «        ¦  «         	  ||¦  «        }
n# t
          $ r d}
Y nw xY w|
€t          d¦  «         dS g }|
                     ¦   «         D ]z}|j        rt          dt          j        ¦  «        }n:|j        r|j        r|j        }n$|j        rd}nt          dt          j        ¦  «        }|                     |j        |f¦  «         Œ{t9          d„ |D ¦   «         d¬ ¦  «        }|D ]\  }}t          d!|d"|› �›d#|› �¦  «         Œ|s=t          ¦   «          t          t          d$t:          › �t          j        ¦  «        ¦  «         dS )%z0Show Portal auth + Tool Gateway routing summary.r   )Úget_nous_auth_status_local©Úget_nous_subscription_featuresÚ	logged_inz  Nous Portalu#     â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€Úportal_base_urlz  Auth:    u   âœ“ logged inz  Portal:  Úinference_base_urlz  API:     znot logged inz  Sign up: z  Login:   hermes portalÚmodelÚproviderÚ Únousz  Model:   u$   âœ“ using Nous as inference providerz  Model:   currently z (switch with `hermes model`)z  Tool Gatewayu&     â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€Nz(  (could not resolve subscription state)zvia Nous PortalÚactiveúnot configuredc              3  ó@   K  — | ]}t          |d          ¦  «        V — ŒdS )r   N©Úlen)Ú.0Úrs     ú;/home/ragecks/.hermes/hermes-agent/hermes_cli/portal_cli.pyú	<genexpr>z_cmd_status.<locals>.<genexpr>a   s,   è è € Ð)Ð)˜q•�Q�q”T‘”Ð)Ð)Ð)Ð)Ð)Ð)ó    )Údefaultú  ú<z   ú  Docs: )Úhermes_cli.authr
   Úhermes_cli.nous_subscriptionr   r   Ú	ExceptionÚboolÚgetÚprintr   r   ÚMAGENTAÚDEFAULT_PORTAL_URLÚGREENÚYELLOWÚSUBSCRIPTION_URLÚ
isinstanceÚdictÚstrÚstripÚlowerÚitemsÚmanaged_by_nousr   Úcurrent_providerÚDIMÚappendÚlabelÚmaxÚDOCS_URL)Úargsr
   r   ÚconfigÚauthr   ÚportalÚ	inferenceÚ	model_cfgr   ÚfeaturesÚrowsÚfeatÚstateÚwidthr7   s                   r   Ú_cmd_statusrE   "   s,  € à:Ð:Ð:Ð:Ð:Ð:ØKÐKÐKÐKÐKÐKå‰]Œ]Ð ˜b€Fðà)Ð)Ñ+Ô+Ð1¨rˆˆøÝð ð ð Øˆˆˆðøøøõ �T—X’X˜kÑ*Ô*Ñ+Ô+€Iå	�G„G€GÝ	�%�¥¤Ñ
0Ô
0Ñ1Ô1Ð1Ý	�%Ð5µv´~Ñ
FÔ
FÑGÔGÐGØð 
*Ø—’Ð+Ñ,Ô,ÐBÕ0BˆÝÐB�E /µ6´<Ñ@Ô@ÐBÐBÑCÔCÐCÝÐ$˜FÐ$Ð$Ñ%Ô%Ð%Ø—H’HÐ1Ñ2Ô2ˆ	Øð 	-ÝÐ+ 	Ð+Ð+Ñ,Ô,Ð,øåÐC�E /µ6´=ÑAÔAÐCÐCÑDÔDÐDÝÐ.Õ,Ð.Ð.Ñ/Ô/Ð/ÝÐ(Ñ)Ô)Ð)õ (2°&·*²*¸WÑ2EÔ2EÅtÑ'LÔ'LÐT�—
’
˜7Ñ#Ô#Ð#ÐRT€IÝ�9—=’= Ñ,Ô,Ð2°Ñ3Ô3×9Ò9Ñ;Ô;×AÒAÑCÔC€HØ�6ÒÐÝÐY�EÐ"HÍ&Ì,ÑWÔWÐYÐYÑZÔZÐZÐZØ	ð OÝÐM hÐMÐMÐMÑNÔNÐNõ 
�G„G€GÝ	�%Ð ¥&¤.Ñ
1Ô
1Ñ2Ô2Ð2Ý	�%Ð8½&¼.Ñ
IÔ
IÑJÔJÐJðØ1Ð1°&Ñ9Ô9ˆˆøÝð ð ð Øˆˆˆðøøøð ÐÝÐ8Ñ9Ô9Ð9Øˆqà€DØ—’Ñ Ô ð 	)ð 	)ˆØÔð 	8ÝÐ+­V¬\Ñ:Ô:ˆEˆEØŒ[ð 	8˜TÔ2ð 	8ØÔ)ˆEˆEØŒ[ð 	8ØˆEˆEåÐ*­F¬JÑ7Ô7ˆEØ�Š�T”Z Ð'Ñ(Ô(Ð(Ð(åÐ)Ð) DÐ)Ñ)Ô)°1Ð5Ñ5Ô5€EØð /ð /‰ˆˆuÝÐ-�5Ð-˜5Ð-Ð-Ð-Ð- eÐ-Ð-Ñ.Ô.Ð.Ð.àð 8Ý‰ŒˆÝ�eÐ)�xÐ)Ð)­6¬:Ñ6Ô6Ñ7Ô7Ð7Øˆ1s   ž+ «:¹:Ê9K ËKËKc                óÊ   — t           }t          d|› �¦  «         	 t          j        |¦  «        }n# t          $ r d}Y nw xY w|st          ¦   «          t          d¦  «         dS dS )z9Open the Portal subscription page in the default browser.zOpening Fz9Could not launch a browser. Visit the URL above manually.é   r   )r,   r'   Ú
webbrowserÚopenr$   )r:   ÚtargetÚopeneds      r   Ú	_cmd_openrL   k   s‚   € å€FÝ	Ð
�VÐ
Ð
ÑÔÐðÝ” Ñ(Ô(ˆˆøÝð ð ð Øˆˆˆðøøøàð Ý‰ŒˆÝÐIÑJÔJÐJØˆqØˆ1s   ›0 °?¾?c           	     óX  — ddl m} t          ¦   «         pi }	  ||¦  «        }n,# t          $ r t	          dt
          j        ¬¦  «         Y dS w xY wg d¢}t	          ¦   «          t	          t          dt          j	        ¦  «        ¦  «         t	          t          dt          j	        ¦  «        ¦  «         |j
        s5t	          t          d	t          j        ¦  «        ¦  «         t	          ¦   «          t          d
„ |D ¦   «         ¦  «        }|D ]¶\  }}}|j                             |¦  «        }	|	€t          dt          j        ¦  «        }
n\|	j        rt          dt          j        ¦  «        }
n:|	j        r|	j        r|	j        }
n$|	j        rd}
nt          dt          j        ¦  «        }
t	          d|d|› �›d|d›d|
› �¦  «         Œ·t	          ¦   «          t	          t          dt(          › �t          j        ¦  «        ¦  «         t	          t          dt*          › �t          j        ¦  «        ¦  «         dS )z0List the Tool Gateway catalog + current routing.r   r   z%Could not resolve Tool Gateway state.©ÚfilerG   ))ÚwebzWeb search & extractÚ	Firecrawl)Ú	image_genzImage generationÚFAL)ÚttszText-to-speechz
OpenAI TTS)ÚbrowserzBrowser automationzBrowser Use)ÚmodalzCloud terminalÚModalz  Tool Gateway catalogu>     â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€u?     Not logged into Nous Portal â€” sign in with `hermes portal`.c              3  ó<   K  — | ]\  }}}t          |¦  «        V — Œd S )Nr   )r   Ú_r7   s      r   r   z_cmd_tools.<locals>.<genexpr>–   s.   è è € Ð<Ð<¡[ Q¨¨q•c˜%‘j”jÐ<Ð<Ð<Ð<Ð<Ð<r   NÚunknownu   âœ“ via Nous Portalr   r   r   r    z  partner: z<14Ú z  Manage your subscription: r!   )r#   r   r   r$   r'   ÚsysÚstderrr   r   r(   Únous_auth_presentr+   r8   r@   r&   r5   r3   r*   r   r4   r,   r9   )r:   r   r;   r@   ÚcatalogÚlabel_widthÚkeyr7   ÚpartnerrB   rC   s              r   Ú
_cmd_toolsrc   z   sE  € àKÐKÐKÐKÐKÐKå‰]Œ]Ð ˜b€FðØ1Ð1°&Ñ9Ô9ˆˆøÝð ð ð ÝÐ5½C¼JÐGÑGÔGÐGØˆqˆqðøøøð
ð ð €Gõ 
�G„G€GÝ	�%Ð(­&¬.Ñ
9Ô
9Ñ:Ô:Ð:Ý	�%ÐPÕRXÔR`Ñ
aÔ
aÑbÔbÐbàÔ%ð Ý�eÐUÕW]ÔWdÑeÔeÑfÔfÐfÝ‰ŒˆåÐ<Ð<°GÐ<Ñ<Ô<Ñ<Ô<€KØ&ð Kð KÑˆˆU�GØÔ ×$Ò$ SÑ)Ô)ˆØˆ<Ý˜)¥V¤ZÑ0Ô0ˆEˆEØÔ!ð 	8ÝÐ/µ´Ñ>Ô>ˆEˆEØŒ[ð 	8˜TÔ2ð 	8ØÔ)ˆEˆEØŒ[ð 	8ØˆEˆEåÐ*­F¬JÑ7Ô7ˆEÝÐI�5ÐI˜;ÐIÐIÐIÐI°GÐIÐIÐIÀ%ÐIÐIÑJÔJÐJÐJå	�G„G€GÝ	�%ÐAÕ/?ÐAÐAÅ6Ä:Ñ
NÔ
NÑOÔOÐOÝ	�%Ð%�8Ð%Ð%¥v¤zÑ
2Ô
2Ñ3Ô3Ð3Øˆ1s   ˜$ ¤%AÁAc                ó¶   — ddl m} t          ¦   «         pi }	  ||¦  «         n5# t          t          f$ r! t          ¦   «          t          d¦  «         Y dS w xY wdS )aÈ  Run the one-shot Nous Portal onboarding (login + model + provider + tools).

    This is the human-readable front door for `hermes auth add nous --type
    oauth`. It reuses the exact wiring behind `hermes setup --portal` (which in
    turn runs the same Nous flow as the first-time quick setup), so the
    commands stay in lockstep: device-code login, pick a Nous model, switch the
    inference provider to Nous, then offer the Tool Gateway opt-in.
    r   )Ú_run_portal_one_shotzPortal setup cancelled.rG   )Úhermes_cli.setupre   r   ÚKeyboardInterruptÚEOFErrorr'   )r:   re   r;   s      r   Ú
_cmd_loginri   «   sƒ   € ð 6Ð5Ð5Ð5Ð5Ð5å‰]Œ]Ð ˜b€FðØÐ˜VÑ$Ô$Ð$Ð$øÝ�xÐ(ð ð ð Ý‰ŒˆÝÐ'Ñ(Ô(Ð(Øˆqˆqðøøøð ˆ1s   ˜$ ¤.AÁAc                ó:  — t          | dd¦  «        }|dv rt          | ¦  «        S |dv rt          | ¦  «        S |dk    rt          | ¦  «        S |dk    rt	          | ¦  «        S t          d|› �t          j        ¬¦  «         t          d	t          j        ¬¦  «         d
S )z4Top-level dispatch for `hermes portal <subcommand>`.Úportal_commandN>   Nr   Úlogin>   ÚinfoÚstatusrI   ÚtoolszUnknown portal subcommand: rN   z!Run `hermes portal -h` for usage.rG   )Úgetattrri   rE   rL   rc   r'   r\   r]   )r:   Úsubs     r   rk   rk   À   s¯   € å
�$Ð(¨$Ñ
/Ô
/€CØ
Ð!Ð!Ð!õ ˜$ÑÔÐØ
Ð Ð Ð å˜4Ñ Ô Ð Ø
ˆf‚}€}Ý˜‰ŒÐØ
ˆg‚~€~Ý˜$ÑÔÐÝ	Ð
-¨Ð
-Ð
-µC´JÐ?Ñ?Ô?Ð?Ý	Ð
-µC´JÐ?Ñ?Ô?Ð?Øˆ1r   ÚNonec                óz  — |                       ddd¬¦  «        }|                     d¬¦  «        }|                      dd¬	¦  «         |                      d
d¬	¦  «         |                      d¦  «         |                      dd¬	¦  «         |                      dd¬	¦  «         |                     t          ¬¦  «         dS )zARegister `hermes portal` on the given argparse subparsers object.r=   zLSet up Nous Portal (login, model pick, Tool Gateway); see also `portal info`u0  Run `hermes portal` with no subcommand to log in to Nous Portal and set it up â€” pick a model, set Nous as your provider, and offer the Tool Gateway (the human-readable alias for `hermes auth add nous --type oauth`, identical to `hermes setup --portal`). Subcommands: login (default), info, open, tools.)ÚhelpÚdescriptionrk   )Údestrl   z@Log in to Nous Portal + set it up (default; one-shot onboarding))rt   rm   z/Show Portal auth + Tool Gateway routing summaryrn   rI   z9Open the Portal subscription page in your default browserro   z5List Tool Gateway tools and which are routed via Nous)ÚfuncN)Ú
add_parserÚadd_subparsersÚset_defaultsrk   )Ú
subparsersÚportal_parserÚ
portal_subs      r   rx   rx   Ô   s  € à×)Ò)ØØ[ð?ð	 *ñ 
ô 
€Mð ×-Ò-Ð3CÐ-ÑDÔD€Jà×ÒØØOð ñ ô ð ð ×ÒØØ>ð ñ ô ð ð
 ×Ò˜(Ñ#Ô#Ð#Ø×ÒØØHð ñ ô ð ð ×ÒØØDð ñ ô ð ð
 ×Ò¥NÐÑ3Ô3Ð3Ð3Ð3r   )r   r   )r   rr   )Ú__doc__Ú
__future__r   r\   rH   Úhermes_cli.colorsr   r   Úhermes_cli.configr   r)   r,   r9   rE   rL   rc   ri   rk   rx   © r   r   ú<module>rƒ      sû   ððð ð( #Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø Ð Ð Ð à +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø )Ð )Ð )Ð )Ð )Ð )à6Ð ØHÐ ØX€ðFð Fð Fð FðRð ð ð ð.ð .ð .ð .ðbð ð ð ð*ð ð ð ð("4ð "4ð "4ð "4ð "4ð "4r   