
    i                       U d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZ  ej        e          Zd	Z ej        d
ej                  ZdddZ dedZ! G d de	          Z"i d e"dd          d e"dd          d e"dd          d e"dd          d e"dd          d e"dd          d e"dd          d  e"dd           d! e"dd!          d" e"d#d"          d$ e"d$d%          d& e"d'd&          d( e"d)d(          d* e"d*d*          d+ e"d+d+          d, e"d-d,          d. e"d/d.           e"d0d1           e"d2d3           e"d4d5           e"d6d7          d8Z#d9e$d:<    G d; d<e	          Z%i Z&d=e$d><   i a'd=e$d?<   dfd@Z(dgdBZ)e G dC dD                      Z*e G dE dF                      Z+dhdIZ,didMZ-	 	 	 djdkdTZ.	 dldmdWZ/	 	 	 	 	 	 dndod^Z0	 	 	 	 dpdqdcZ1dS )ru  Shared model-switching logic for CLI and gateway /model commands.

Both the CLI (cli.py) and gateway (gateway/run.py) /model handlers
share the same core pipeline:

  parse flags -> alias resolution -> provider resolution ->
  credential resolution -> normalize model name ->
  metadata lookup -> build result

This module ties together the foundation layers:

- ``agent.models_dev``            -- models.dev catalog, ModelInfo, ProviderInfo
- ``hermes_cli.providers``        -- canonical provider identity + overlays
- ``hermes_cli.model_normalize``  -- per-provider name formatting

Provider switching uses the ``--provider`` flag exclusively.
No colon-based ``provider:model`` syntax — colons are reserved for
OpenRouter variant suffixes (``:free``, ``:extended``, ``:fast``).
    )annotationsN)	dataclass)List
NamedTupleOptional)custom_provider_slugdetermine_api_mode	get_labelis_aggregatorresolve_provider_full)normalize_model_for_provider)ModelCapabilities	ModelInfoget_model_capabilitiesget_model_infolist_provider_modelszNous Research Hermes 3 & 4 models are NOT agentic and are not designed for use with Hermes Agent. They lack the tool-calling capabilities required for agent workflows. Consider using an agentic model instead (Claude, GPT, Gemini, DeepSeek, etc.).z&(?:^|[/:])hermes[-_ ]?[34](?:[-_.:]|$)
model_namestrreturnboolc                X    | sdS t          t                              |                     S )zReturn True if *model_name* is a real Nous Hermes 3/4 chat model.

    Used to decide whether to surface the non-agentic warning at startup.
    Callers in :mod:`cli.py` and here should go through this single helper
    so the two sites don't drift.
    F)r   _NOUS_HERMES_NON_AGENTIC_REsearchr   s    5/root/.hermes/hermes-agent/hermes_cli/model_switch.pyis_nous_hermes_non_agenticr   K   s.      u+22:>>???    c                2    t          |           rt          S dS )zHReturn a warning string if *model_name* is a Nous Hermes 3/4 chat model. )r   _HERMES_MODEL_WARNINGr   s    r   _check_hermes_model_warningr!   W   s    !*-- %$$2r   c                  (    e Zd ZU dZded<   ded<   dS )ModelIdentityz:Vendor slug and family prefix used for catalog resolution.r   vendorfamilyN__name__
__module____qualname____doc____annotations__ r   r   r#   r#   c   s(         DDKKKKKKKKr   r#   sonnet	anthropiczclaude-sonnetopuszclaude-opushaikuzclaude-haikuclaudegpt5openaizgpt-5gptcodexo3o4geminigoogledeepseekzdeepseek-chatgrokzx-aillamaz
meta-llamaqwenminimaxnemotronnvidiakimi
moonshotaizz-aiglmstepfunstepxiaomimimozarcee-aitrinity)rC   rE   rG   rH   zdict[str, ModelIdentity]MODEL_ALIASESc                  2    e Zd ZU dZded<   ded<   ded<   dS )DirectAliasz5Exact model mapping that bypasses catalog resolution.r   modelproviderbase_urlNr&   r,   r   r   rK   rK      s1         ??JJJMMMMMMMMr   rK   dict[str, DirectAlias]_BUILTIN_DIRECT_ALIASESDIRECT_ALIASESc                     t          t                    } 	 ddlm}  |            }|                    d          }t          |t                     r|                                D ]\  }}t          |t                     s|                    dd          }|                    dd          }|                    dd          }|r9t          |||	          | |                                	                                <   n# t          $ r Y nw xY w| S )
ao  Load direct aliases from config.yaml ``model_aliases:`` section.

    Config format::

        model_aliases:
          qwen:
            model: "qwen3.5:397b"
            provider: custom
            base_url: "https://ollama.com/v1"
          minimax:
            model: "minimax-m2.7"
            provider: custom
            base_url: "https://ollama.com/v1"
    r   )load_configmodel_aliasesrL   r   rM   customrN   )rL   rM   rN   )dictrP   hermes_cli.configrS   get
isinstanceitemsrK   striplower	Exception)	mergedrS   cfguser_aliasesnameentryrL   rM   rN   s	            r   _load_direct_aliasesrc      s)    )**F111111kmmww//lD)) 
	+1133 	 	e!%.. 		'2.. 99Z:: 99Z44 3>#h4 4 4F4::<<--//0    Ms   C'C> >
D
DNonec                 4    t           st                      a dS dS )z&Lazy-load direct aliases on first use.N)rQ   rc   r,   r   r   _ensure_direct_aliasesrf      s%      0-//0 0r   c                      e Zd ZU dZded<   dZded<   dZded<   dZded	<   dZded
<   dZ	ded<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dS )ModelSwitchResultz!Result of a model switch attempt.r   successr   r   	new_modeltarget_providerFprovider_changedapi_keyrN   api_modeerror_messagewarning_messageprovider_labelresolved_via_aliasNzOptional[ModelCapabilities]capabilitieszOptional[ModelInfo]
model_info	is_global)r'   r(   r)   r*   r+   rj   rk   rl   rm   rN   rn   ro   rp   rq   rr   rs   rt   ru   r,   r   r   rh   rh      s         ++MMMIO"""""GHHMON     04L4444&*J****Ir   rh   c                  V    e Zd ZU dZded<   dZded<   dZded<   dZded<   dZded	<   d
S )CustomAutoResultz?Result of switching to bare 'custom' provider with auto-detect.r   ri   r   r   rL   rN   rm   ro   N)	r'   r(   r)   r*   r+   rL   rN   rm   ro   r,   r   r   rw   rw      sa         IIMMMEOOOOHGMr   rw   raw_argstuple[str, str, bool]c                   d}d}d| v r*d}|                      dd                                          } |                                 }d}g }|t          |          k     rf||         dk    r'|dz   t          |          k     r||dz            }|dz  }n |                    ||                    |dz  }|t          |          k     fd	                    |                                          }|||fS )
a  Parse --provider and --global flags from /model command args.

    Returns (model_input, explicit_provider, is_global).

    Examples::

        "sonnet"                         -> ("sonnet", "", False)
        "sonnet --global"                -> ("sonnet", "", True)
        "sonnet --provider anthropic"    -> ("sonnet", "anthropic", False)
        "--provider my-ollama"           -> ("", "my-ollama", False)
        "sonnet --provider anthropic --global" -> ("sonnet", "anthropic", True)
    Fr   z--globalTr   z
--provider       )replacer[   splitlenappendjoin)rx   ru   explicit_providerpartsifilteredmodel_inputs          r   parse_model_flagsr     s    I X	##J3399;; NNE	AH
c%jj..8|##AE

(:(: %a!eFAAOOE!H%%%FA c%jj.. ((8$$**,,K*I66r   	raw_inputcurrent_providerOptional[tuple[str, str, str]]c                   |                                                                  }t                       t                              |          }||j        |j        |fS t                                          D ]3\  }}|j                                        |k    r|j        |j        |fc S 4t                              |          }|dS |\  }}t          |          }	|	sdS t          |          }
|	D ]~}|                                }|
r6| d|                                 }|                    |          r|||fc S N|                                }|                    |          r|||fc S dS )a  Resolve a short alias against the current provider's catalog.

    Looks up *raw_input* in :data:`MODEL_ALIASES`, then searches the
    current provider's models.dev catalog for the first model whose ID
    starts with ``vendor/family`` (or just ``family`` for non-aggregator
    providers).

    Returns:
        ``(provider, resolved_model_id, alias_name)`` if a match is
        found on the current provider, or ``None`` if the alias doesn't
        exist or no matching model is available.
    N/)r[   r\   rf   rQ   rX   rM   rL   rZ   rI   r   r   
startswith)r   r   keydirect
alias_namedaidentityr$   r%   catalog
aggregatormodel_id	mid_lowerprefixfamily_lowers                  r   resolve_aliasr   .  s     //


!
!
#
#C $$Fs33
 )..00 7 7
B8>>s""K:6666 #   %%HtNFF ##344G t /00J 9 9NN$$	 		9))))//11F##F++ 9((C88889 "<<>>L##L11 9((C88889 4r   r   user_providersrV   custom_providerslist | None	list[str]c                f    	 t          | ||d          }d |D             S # t          $ r g cY S w xY w)u   Return slugs of providers that have credentials.

    Uses ``list_authenticated_providers()`` which is backed by the models.dev
    in-memory cache (1 hr TTL) — no extra network cost.
    r   )r   r   r   
max_modelsc                    g | ]
}|d          S )slugr,   ).0ps     r   
<listcomp>z4get_authenticated_provider_slugs.<locals>.<listcomp>|  s    ---a&	---r   )list_authenticated_providersr]   )r   r   r   	providerss       r    get_authenticated_provider_slugsr   k  sa    	0-)-	
 
 
	 .-9----   			s   ! 00r,   authenticated_providersc                D    |pd}|D ]}t          | |          }||c S dS )zTry to resolve an alias on the user's authenticated providers.

    Falls back to ``("openrouter", "nous")`` only when no authenticated
    providers are supplied (backwards compat for non-interactive callers).
    )
openrouternousN)r   )r   r   r   rM   results        r   _resolve_alias_fallbackr     sF     (A+AI  y(33MMM 4r   Fcurrent_modelcurrent_base_urlcurrent_api_keyru   r   c	                   ddl m}	m}
m} ddlm} d}|                                 }|}|rt          |||          }|[d| d}	 ddlm	}  |            }|r|d	z  }|dd
         D ]}|d|j
         z  }n# t          $ r Y nw xY wt          d||          S |j        }|sr|j        rGddlm}  ||j                  }|r|}nPt          d||j        |d|j         d|j         d|           S t          d||j        |d|j         d|           S t#          ||          }||\  }}}nEt#          | |          }|%|\  }}}t$                              d|||           nL|                                                                 }|t*          v r{t-          |||          }t/          | |          }|$|\  }}}t$                              d|||           nt*          |         }t          d|d| d|j         d|j         d          S |                     d          }|dk    rd| vrt7          |          rt| d|                                                                         }| |dz   d                                         }|r%|r#| d| }t$                              d| |           t7          |          r|st9          |          } | rs|                                }!| D ]}"|"                                |!k    r|"} n?| D ];}"d|"v r5|"                    dd          \  }}#|#                                |!k    r|"} n<|pd}$|dv pd |$v pd!|$v }%||k    r|%s|s |	||          }|r|\  }}||k    }&t=          |          }'|                    d"          rt          |||          }(|(|(j        }'|})|}*d}+|&s|r	  ||#          },|,                     d$d          })|,                     d%d          }*|,                     d&d          }+n# t          $ r$}-t          d||'|d'|' d(|-           cY d}-~-S d}-~-ww xY w	  ||#          },|,                     d$d          })|,                     d%d          }*|,                     d&d          }+n# t          $ r Y nw xY w|r<tC                       tD                               |          }.|.|.j        r|.j        }*|)sd)})tG          ||          }	  |
|||)|**          }/n# t          $ r
 d+d+ddd,}/Y nw xY w|/                     d-          s+|/                     d.d/          }0t          d|||'||00          S |/                     d1          r|/d1         }|d2v r |||          }+|+stI          ||*          }+tK          ||          }1tM          ||          }2g }3|/                     d.          r|3'                    |/d.                    tQ          |          }4|4r|3'                    |4           t          d+|||&|)|*|+|3rd3)                    |3          nd|'||1|2|4          S )5a  Core model-switching pipeline shared between CLI and gateway.

    Resolution chain:

      If --provider given:
        a. Resolve provider via resolve_provider_full()
        b. Resolve credentials
        c. If model given, resolve alias on target provider or use as-is
        d. If no model, auto-detect from endpoint

      If no --provider:
        a. Try alias resolution on current provider
        b. If alias exists but not on current provider -> fallback
        c. On aggregator, try vendor/model slug conversion
        d. Aggregator catalog search
        e. detect_provider_for_model() as last resort
        f. Resolve credentials
        g. Normalize model name for target provider

      Finally:
        h. Get full model metadata from models.dev
        i. Build result

    Args:
        raw_input: The model name (after flag parsing).
        current_provider: The currently active provider.
        current_model: The currently active model name.
        current_base_url: The currently active base URL.
        current_api_key: The currently active API key.
        is_global: Whether to persist the switch.
        explicit_provider: From --provider flag (empty = no explicit provider).
        user_providers: The ``providers:`` dict from config.yaml (for user endpoints).
        custom_providers: The ``custom_providers:`` list from config.yaml.

    Returns:
        ModelSwitchResult with all information the caller needs.
    r   )detect_provider_for_modelvalidate_requested_modelopencode_model_api_mode)resolve_runtime_providerr   NzUnknown provider 'z`'. Check 'hermes model' for available providers, or define it in config.yaml under 'providers:'.)validate_config_structureu1   

Run 'hermes doctor' — config issues detected:   u   
  • F)ri   ru   ro   )_auto_detect_local_modelzNo model detected on z (z@). Specify the model explicitly: /model <model-name> --provider )ri   rk   rq   ru   ro   z
Provider 'zN' has no base URL configured. Specify a model: /model <model-name> --provider zAlias '%s' resolved to %s on %s)r   r   r   z,Alias '%s' resolved via fallback to %s on %szAlias 'z
' maps to r   z] but no matching model was found in any provider catalog. Try specifying the full model name.:r{   z3Converted vendor:model '%s' to aggregator slug '%s')rU   local	localhostz	127.0.0.1zcustom:)	requestedrm   rN   rn   z,Could not resolve credentials for provider 'z': zno-key-required)rm   rN   T)acceptedpersist
recognizedmessager   r   zInvalid model)ri   rj   rk   rq   ru   ro   corrected_model>   opencode-goopencode-zenopencodez | )ri   rj   rk   rl   rm   rN   rn   rp   rq   rr   rs   rt   ru   )*hermes_cli.modelsr   r   r   hermes_cli.runtime_providerr   r[   r   rW   r   r   r]   rh   idrN   r   ra   r   loggerdebugr\   rI   r   r   r$   r%   findr   r   r   r
   r   rX   rf   rQ   r   r	   r   r   r   r!   r   )5r   r   r   r   r   ru   r   r   r   r   r   r   r   resolved_aliasrj   rk   pdef_switch_errr   _cfg_issues_cir   detectedalias_result_r   authedfallback_resultr   	colon_posleftrightr   new_model_lowermidbare_base	is_customrl   rq   custom_pdefrm   rN   rn   runtimee_da
validationmsgrs   rt   warningshermes_warns5                                                        r   switch_modelr     s	   `         
 EDDDDDN!!I&O
  Y6$
 

 <6%6 6 6 6 GGGGGG7799 @#XXK*2A2 @ @#'?#+'?'??   $#)    '  	} PPPPPP33DMBB  (II, %(7'+y"+pDI p p p p\mp p	 	 	 	 )!$3#'9'_TY _ _K\_ _	 	 	 	 %Y@@#+7(Ay. %Y0@AA#9E6OYLL1	?    //##))++Cm##9%5#1%5  
 #:)V"L"L".AP>OYLLF&	?   
  -S1H, %"+Cc C CX_ C Cx C C C	    &NN3//	q==S	%9%9mL\>]>]%9$ZiZ06688>>@@D%i!mnn5;;==E  '+$5$5e$5$5	Q%y   )) 	&. 	&*?;;G &"+//"3"3" 
& 
&Cyy{{o55$'	 6  ' & &#::&)iiQ&7&7GAt#zz||>>,/	 % !&B$(;; 
5 8K5$8 	
 /// 0" 0 10<LMMH 6-5* '*:://N!!),, .+
 

 "(-N GHH , 	..IIIGkk)R00G{{:r22H{{:r22HH 
	 
	 
	$ /-#/&/ /+,/ /	 	 	 	 	 	 	 	 	
		..9IJJJGkk)R00G{{:r22H{{:r22HH 	 	 	D	  ,     00?s|?|H ,+ -YHHI
--	
 
 


  
 
 
	
 




 >>*%% 	
nnY88 +)
 
 
 	
 ~~'(( 201	 TTT**?IFF  A%ox@@ */9EEL  ;;J H~~i   /
9-...-i88K %$$$ ')08@

8,,,b%)!   sV   1A8 8
BBAP 
Q P;5Q ;Q AR 
R R 2T TT   r   int
List[dict]c                  C ddl Cddlm}m}m} ddlm} ddlm}m	}	 g }
t                      } |            }t          |	          }d |D             |d<   d|vr|d         |d<   |                                D ]1\  }}|                    |          }t          |t                    s1|                    |          }|r|j        rt!          |j                  }n,|                    d	g           }t          |t                     st#          Cfd
|D                       }|s|                    |g           }t%          |          }|d|         }|} ||          }|r|j        n|}|
                    |||| k    p|| k    d||dd           |                    |           3ddlm} ddlm} d |                                D             }|                                D ]\  }}||v r|                    ||          }||v r&d}|j        r t#          Cfd|j        D                       }|sT|j        dk    rI||fD ]D} |                    |           }!|!r+|!j        r$t#          Cfd|!j        D                       rd} nE|s	 ddlm}"  |"            }#|#                    di           }$|#                    di           }%|#r||$v s||$v s||%v s||%v rd}n3# t6          $ r&}&t8                              d||&           Y d}&~&nd}&~&ww xY w|s\	 ddlm}'  |'|          }(|(                                 rd}n3# t6          $ r&}&t8                              d||&           Y d}&~&nd}&~&ww xY w|s|dk    r	 ddl!m"})m#}*  |*            }+ |)            },|+r|+                    d          s|,r|,                    d          rd}n2# t6          $ r%}&t8                              d|&           Y d}&~&nd}&~&ww xY w|s|                    |g           p|                    |g           }t%          |          }|d|         }|
                    |tI          |          || k    p|| k    d||dd           |                    |           |                    |           	 ddlm%}- n# tL          $ r g }-Y nw xY w|-D ]y}.|.j'        |v r|                    |.j'                  }/d}0|/r'|/j        r t#          Cfd |/j        D                       }0|0sd	 ddlm}"  |"            }1|1                    di           }2|1                    di           }3|1r|.j'        |2v s	|.j'        |3v rd}0n# t6          $ r Y nw xY w|0s>	 ddlm}'  |'|.j'                  }4|4                                 rd}0n# t6          $ r Y nw xY w|0s|                    |.j'        g           }5t%          |5          }6|5d|         }7|
                    |.j'        |.j(        |.j'        | k    d|7|6d!d           |                    |.j'                   {|r;t          |t                    r%|                                D ]\  }8}9t          |9t                    s|9                    d"d#          p|8}|9                    d$d#          p|9                    d%d#          pd#}:|9                    d&d#          };g }<|;r|<                    |;           |9                    d'g           }=t          |=t                     r |=D ]}>|>r|>|<vr|<                    |>           |
                    |8||8| k    d|<|<rt%          |<          ndd(|:d)           |rt          |t                     rdd*l)m*}?  |?            }@|D ]}At          |At                    s|A                    d"          pd#+                                }|A                    d+d#          p-|A                    d%d#          p|A                    d$d#          pd#+                                }:|r|:stY          |          }||@vr	||:g d,|@|<   |A                    d-          pd#+                                };|;r1|;|@|         d'         vr!|@|         d'                             |;           |@                                D ]f\  }}B||v r
|
                    ||Bd"         || k    d|Bd'         t%          |Bd'                   d(|Bd.         d)           |                    |           g|
-                    d/ 0           |
S )1u  Detect which providers have credentials and list their curated models.

    Uses the curated model lists from hermes_cli/models.py (OPENROUTER_MODELS,
    _PROVIDER_MODELS) — NOT the full models.dev catalog.  These are hand-picked
    agentic models that work well as agent backends.

    Returns a list of dicts, each with:
      - slug: str — the --provider value to use
      - name: str — display name
      - is_current: bool
      - is_user_defined: bool
      - models: list[str] — curated model IDs (up to max_models)
      - total_models: int — total curated count
      - source: str — "built-in", "models.dev", "user-config"

    Only includes providers that have API keys set or are user-defined endpoints.
    r   N)PROVIDER_TO_MODELS_DEVfetch_models_devget_provider_info)PROVIDER_REGISTRY)OPENROUTER_MODELS_PROVIDER_MODELSc                    g | ]\  }}|S r,   r,   )r   r   r   s      r   r   z0list_authenticated_providers.<locals>.<listcomp>  s    AAAVS!SAAAr   r   r   envc              3  L   K   | ]}j                             |          V  d S NenvironrX   r   evoss     r   	<genexpr>z/list_authenticated_providers.<locals>.<genexpr>2  s1      >>r
r**>>>>>>r   Fzbuilt-in)r   ra   
is_currentis_user_definedmodelstotal_modelssource)HERMES_OVERLAYSc                    i | ]\  }}||	S r,   r,   )r   kvs      r   
<dictcomp>z0list_authenticated_providers.<locals>.<dictcomp>Q  s    GGG1q!GGGr   c              3  L   K   | ]}j                             |          V  d S r   r   r   s     r   r   z/list_authenticated_providers.<locals>.<genexpr>_  s1      PP2BJNN2..PPPPPPr   rm   c              3  L   K   | ]}j                             |          V  d S r   r   r   s     r   r   z/list_authenticated_providers.<locals>.<genexpr>e  s1      NN"2:>>"--NNNNNNr   T)_load_auth_storer   credential_poolz"Auth store check failed for %s: %s)	load_poolz'Credential pool check failed for %s: %sr.   )read_claude_code_credentialsread_hermes_oauth_credentialsaccessTokenz)Anthropic external creds check failed: %shermes)CANONICAL_PROVIDERSc              3  L   K   | ]}j                             |          V  d S r   r   r   s     r   r   z/list_authenticated_providers.<locals>.<genexpr>  s1      YYr
r 2 2YYYYYYr   	canonicalra   r   apiurldefault_modelr   zuser-config)r   ra   r   r   r   r   r   api_url)OrderedDictrN   )ra   r  r   rL   r  c                &    | d          | d          fS )Nr   r   r,   )rs    r   <lambda>z.list_authenticated_providers.<locals>.<lambda>>  s    AlO 3a6G5GH r   )r   ).r   agent.models_devr   r   r   hermes_cli.authr   r   r   r   setrV   rZ   rX   rY   api_key_env_varslistanyr   ra   r   addhermes_cli.providersr   extra_env_vars	auth_typer  r]   r   r   agent.credential_poolr	  has_credentialsagent.anthropic_adapterr
  r  r
   r  ImportErrorr   labelcollectionsr  r[   r   sort)Dr   r   r   r   r   r   _mdev_pinfor   r   r   results
seen_slugsdatacurated	hermes_idmdev_idpdatapconfigenv_vars	has_creds	model_idstotaltopr   pinfodisplay_namer   _auth_registry_mdev_to_hermespidoverlayhermes_slug_keypcfgr  storeproviders_store
pool_storeexcr	  poolr
  r  hermes_credscc_creds_canon_provs_cp
_cp_config_cp_has_creds	_cp_store_cp_providers_store_cp_pool_store_cp_pool_cp_model_ids	_cp_total_cp_topep_nameep_cfgr  r  models_list
cfg_modelsmr  groupsrb   grpr   sD                                                                      @r   r   r     s   . III         
 211111EEEEEEEEGeeJD %))9$:$:GAA/@AAAGLW!,/ 5::<< ' '	7!!%&& 	
 $''	22 	w/ 	G455HHyy++Hh--  >>>>X>>>>>	 	 KK	2..	I$G$$%*7uzz "22QgAQ6Q$! 
 
 	 	 	 	t 544444CCCCCC
 HG(>(D(D(F(FGGGO'--// X$ X$W* &))#s33*$$ 	! 	QPPPP9OPPPPPI 	W.);;k*  %))$// D1 NNNN8MNNNNN $(	
  	MM<<<<<<((**"'))K"<"<"YY'8"==
 %?**k_.L.Lj((K:,E,E $I M M MA3LLLLLLLLM  	ZZ;;;;;; y--'')) % $I Z Z ZFUXYYYYYYYYZ  	O[K77O         =<>>7799  %\%5%5m%D%D %%!)m!<!<% $I O O OH#NNNNNNNNO 	 KKR00HGKKR4H4H	I$k**%)99TSDT=T$!
 
 	 	 	 	s{####IIIIIII     0! 0!8z!! $''11
 	Z*5 	ZYYYYZ=XYYYYYM 	<<<<<<,,..	&/mmK&D&D#!*/@"!E!E )H 333x>11$(M    	;;;;;;$9SX..++-- )$(M     	CHb11&&	,HI(&66$%!
 
 	 	 	 	sx      *^T:: -3355 	 	OGVfd++ !::fb11<WLjj++Jvzz%/D/DJG"JJ;;M K 2""=111Hb11J*d++ .# . .A .Qk11#**1--- NN$%)99#'%4? FK 0 0 0Q'"	 	 	 	 	 	&  *!J'7>> *!+++++++6;==% 	= 	=EeT** !IIf--3::<<L		*b)) 99UB''99UB'' egg    w '55D6!!(&    t
 #YYw//52<<>>M =fTl86L!L!LtX&--m<<< 	! 	!ID#z!!NNF"&66#'h- #CM 2 2'y>	 	 	 	 	 NN4     LLHHLIIINs   AK##
L-LL'M
M1M,,M1=AO


O9O44O9&R- -R<;R<AU))
U65U6<,V))
V65V6)r   r   r   r   )r   r   r   r   )r   rO   )r   rd   )rx   r   r   ry   )r   r   r   r   r   r   )r   NN)r   r   r   rV   r   r   r   r   )r,   )r   r   r   r   r   r   )r   r   Fr   NN)r   r   r   r   r   r   r   r   r   r   ru   r   r   r   r   rV   r   r   r   rh   )r   NNr   )
r   r   r   rV   r   r   r   r   r   r   )2r*   
__future__r   loggingredataclassesr   typingr   r   r   r   r   r	   r
   r   r   hermes_cli.model_normalizer   r  r   r   r   r   r   	getLoggerr'   r   r    compile
IGNORECASEr   r   r!   r#   rI   r+   rK   rP   rQ   rc   rf   rh   rw   r   r   r   r   r   r   r,   r   r   <module>rc     sj    ( # " " " " "  				 ! ! ! ! ! ! - - - - - - - - - -                                
	8	$	$-   )bj-M  	@ 	@ 	@ 	@       J   1+{O<<1+ {M::1+ {N;;	1+
 {H551+ x111+ 
x//1+ x111+ 	x..1+ 	x..1+ x221+$ z?;;%1+* vv..+1+0 |W5511+6 vv..71+< y)44=1+B x44C1+H |V44I1+N vu-- y&11 x00 z955a1+ 1+ 1+ 1 1 1 1x    *    35  4 4 4 4 *, + + + +! ! ! !H0 0 0 0        &        "7 "7 "7 "7R: : : :| $(    0 *,    2 $(W W W W W~
 $(	L L L L L L Lr   