+
    Q(i                    P   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
t
^ RIHt ^ RIHtHtHt ^ RIHt ]! R4      t]! 4       t]
P*                  ! R	R
R7      t]P/                  RR7      RRRRRRRRRRRR/R R ll4       t]P/                  RR7      RR/R R ll4       tR# )z0CIMD (Client ID Metadata Document) CLI commands.)annotationsN)Path)	Annotated)Console)CIMDFetcherCIMDFetchErrorCIMDValidationError)
get_loggerzcli.cimdcimdzFCIMD (Client ID Metadata Document) utilities for OAuth authentication.)namehelpcreate)r   	client_id
client_urilogo_uriscopeoutputprettyTc               <    V ^8  d   QhRRRRRRRRR	R
RRRRRRRR/	# )   r   zXAnnotated[str, cyclopts.Parameter(help='Human-readable name of the client application')]redirect_uriz|Annotated[list[str], cyclopts.Parameter(name=['--redirect-uri', '-r'], help='Allowed redirect URIs (can specify multiple)')]r   zAnnotated[str | None, cyclopts.Parameter(name='--client-id', help='The URL where this document will be hosted (sets client_id directly)')]r   zdAnnotated[str | None, cyclopts.Parameter(name='--client-uri', help="URL of the client's home page")]r   zcAnnotated[str | None, cyclopts.Parameter(name='--logo-uri', help="URL of the client's logo image")]r   zwAnnotated[str | None, cyclopts.Parameter(name='--scope', help='Space-separated list of scopes the client may request')]r   zmAnnotated[str | None, cyclopts.Parameter(name=['--output', '-o'], help='Output file path (default: stdout)')]r   zDAnnotated[bool, cyclopts.Parameter(help='Pretty-print JSON output')]returnNone )formats   "V/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/cli/cimd.py__annotate__r       sy     l llll()l67lDElRSl`all 
ml    c                    RT;'       g    RRV RVRRRR.R	R
./pV'       d   W8R&   V'       d   WHR&   V'       d   WXR&   V'       d   \         P                  ! V^R7      M\         P                  ! V4      p	V'       d   \        V4      P                  4       P	                  4       p
V
P
                  P                  RRR7       \        V
R4      ;_uu_ 4       pVP                  V	4       VP                  R4       RRR4       \        P                  RV 24       V'       g   \        P                  R4       R# R# \        V	4       V'       g    \        RR7      pVP                  R4       R# R#   + '       g   i     L}; i)a  Generate a CIMD document for hosting.

Create a Client ID Metadata Document that you can host at an HTTPS URL.
The URL where you host this document becomes your client_id.

Example:
    fastmcp cimd create --name "My App" -r "http://localhost:*/callback"

After creating the document, host it at an HTTPS URL with a non-root path,
for example: https://myapp.example.com/oauth/client.json
r   z+https://YOUR-DOMAIN.com/path/to/client.jsonclient_nameredirect_uristoken_endpoint_auth_methodnonegrant_typesauthorization_coderesponse_typescoder   r   r   )indentT)parentsexist_okw
Nu,   [green]✓[/green] CIMD document written to z
[yellow]Important:[/yellow] client_id is a placeholder. Update it to the URL where you will host this document, or re-run with --client-id.)stderr)jsondumpsr   
expanduserresolveparentmkdiropenwriteconsoleprintr   )r   r   r   r   r   r   r   r   docjson_outputoutput_pathfstderr_consoles   $$$$$$$$     r   create_commandr<      sD   J 	YOO"Ot$f,-6(C &L"JG 06$**S+4::c?K 6l--/779   =+s##qGGK GGDM $ 	DVHMNMM ` 
 	k$D1N  /  $#s   #E--E=	validatetimeoutg      $@c               $    V ^8  d   QhRRRRRR/# )r   urlzOAnnotated[str, cyclopts.Parameter(help='URL of the CIMD document to validate')]r>   zfAnnotated[float, cyclopts.Parameter(name=['--timeout', '-t'], help='HTTP request timeout in seconds')]r   r   r   )r   s   "r   r   r      s/     J J
JJ 
Jr   c                  a a R VV 3R llp\         P                  ! V! 4       4      pV'       g   \        P                  ! ^4       R# R# )a<  Validate a hosted CIMD document.

Fetches the document from the given URL and validates:
- URL is valid CIMD URL (HTTPS, non-root path)
- Document is valid JSON
- Document conforms to CIMD schema
- client_id in document matches the URL

Example:
    fastmcp cimd validate https://myapp.example.com/oauth/client.json
c                   V ^8  d   QhRR/# )r   r   boolr   )r   s   "r   r   &validate_command.<locals>.__annotate__   s     , ,T ,r   c                 R  <"   \        SR 7      p V P                  S4      '       gn   \        P                  RS 24       \        P                  4        \        P                  R4       \        P                  R4       \        P                  R4       R# \        P                  RS R24        V P	                  S4      G Rj  xL
 p\        P                  R4       \        P                  4        \        P                  R4       \        P                  RTP                   24       \        P                  RTP                  ;'       g    R 24       \        P                  RTP                   24       TP                  '       dB   \        P                  R4       TP                   F  p\        P                  RT 24       K  	  M\        P                  R4       TP                  '       d#   \        P                  RTP                   24       TP                  '       d#   \        P                  RTP                   24       R#  EL  \
         d$   p\        P                  R	T 24        Rp?R# Rp?i\         d$   p\        P                  R
T 24        Rp?R# Rp?ii ; i5i))r>   u!   [red]✗[/red] Invalid CIMD URL: zCIMD URLs must:u     • Use HTTPS (not HTTP)u;     • Have a non-root path (e.g., /client.json, not just /)Fu   [blue]→[/blue] Fetching z...Nu)   [red]✗[/red] Failed to fetch document: u!   [red]✗[/red] Validation error: u&   [green]✓[/green] Valid CIMD documentz[bold]Document details:[/bold]z  client_id: z  client_name: z	(not set)z  token_endpoint_auth_method: z  redirect_uris:u       • z  redirect_uris: (none)z	  scope: z  client_uri: T)r   is_cimd_client_idr5   r6   fetchr   r   r   r   r!   r    r   r   )fetcherr7   eurir>   r@   s       r   	_validate#validate_command.<locals>._validate   s    g. ((--MM=cUCDMMOMM+,MM67MMWX23%s;<	c**C 	>?67cmm_56(F(F;'GHI6s7U7U6VWXMM,-((./ ) MM34999MMIcii[12>>>MMN3>>*:;<; + 	MMEaSIJ" 	MM=aSAB	st   B*J'.I
 II
 BJ'
<J'A'J'/3J'#$J'I
 
J$I3-J'3J$ J$JJ'J$$J'N)asynciorunsysexit)r@   r>   rK   successs   fd  r   validate_commandrR      s3    6, ,\ kk)+&G r   )__doc__
__future__r   rM   r-   rO   pathlibr   typingr   cycloptsrich.consoler   fastmcp.server.auth.cimdr   r   r   fastmcp.utilities.loggingr	   loggerr5   Appcimd_appcommandr<   rR   r   r   r   <module>r_      s    6 "   
      
 1	J	
) <<		Q 
x l& 	'l4 	5lB 	ClP 	Ql^ 	_lj 	kl !l^ 
z"J 	J #Jr   