§
    ÷žyj“
  ã                  óJ   — d Z ddlmZ ddlmZmZ h d£ZdddœZddd	œZdd„Z	dS )aß  LM Studio reasoning-effort resolution shared by the chat-completions
transport and run_agent's iteration-limit summary path.

LM Studio publishes per-model ``capabilities.reasoning.allowed_options`` (e.g.
``["off","on"]`` for toggle-style models, ``["off","minimal","low"]`` for
graduated models). We map the user's ``reasoning_config`` onto LM Studio's
OpenAI-compatible vocabulary, then clamp against the model's allowed set so
the server doesn't 400 on an unsupported effort.
é    )Úannotations)ÚListÚOptional>   ÚlowÚhighÚnoneÚxhighÚmediumÚminimalr   r
   )ÚoffÚonr	   )ÚmaxÚultraÚreasoning_configúOptional[dict]Úallowed_optionsúOptional[List[str]]ÚreturnúOptional[str]c                óŒ  — d}| r«t          | t          ¦  «        r–|                      d¦  «        du rd}n||                      d¦  «        pd                     ¦   «                              ¦   «         }t
                               ||¦  «        }t                               ||¦  «        }|t          v r|}|rd„ |D ¦   «         }||vrdS |S )	a…  Return the ``reasoning_effort`` string to send to LM Studio, or ``None``.

    ``None`` means "omit the field": the user picked a level the model can't
    honor, so let LM Studio fall back to the model's declared default rather
    than silently substituting a different effort. When ``allowed_options`` is
    falsy (probe failed), skip clamping and send the resolved effort anyway.
    r
   ÚenabledFr   ÚeffortÚ c                óD   — h | ]}t                                ||¦  «        ’ŒS © )Ú_LM_EFFORT_ALIASESÚget)Ú.0Úopts     ú>/home/ragecks/.hermes/hermes-agent/agent/lmstudio_reasoning.pyú	<setcomp>z*resolve_lmstudio_effort.<locals>.<setcomp>9   s)   € ÐOÐOÐO¸Õ%×)Ò)¨#¨sÑ3Ô3ÐOÐOÐOó    N)Ú
isinstanceÚdictr   ÚstripÚlowerr   Ú_LM_EFFORT_CLAMPÚ_LM_VALID_EFFORTS)r   r   r   ÚrawÚalloweds        r    Úresolve_lmstudio_effortr+   #   sÞ   € ð €FØð �JÐ'7½Ñ>Ô>ð Ø×Ò 	Ñ*Ô*¨eÐ3Ð3ØˆFˆFà#×'Ò'¨Ñ1Ô1Ð7°R×>Ò>Ñ@Ô@×FÒFÑHÔHˆCÝ$×(Ò(¨¨cÑ2Ô2ˆCÝ"×&Ò& s¨CÑ0Ô0ˆCØÕ'Ð'Ð'Ø�Øð ØOÐO¸ÐOÑOÔOˆØ˜Ð Ð Ø�4Ø€Mr"   N)r   r   r   r   r   r   )
Ú__doc__Ú
__future__r   Útypingr   r   r(   r   r'   r+   r   r"   r    ú<module>r/      sˆ   ððð ð #Ð "Ð "Ð "Ð "Ð "à !Ð !Ð !Ð !Ð !Ð !Ð !Ð !ð JÐIÐIÐ ð $¨8Ð4Ð4Ð ð #¨WÐ5Ð5Ð ðð ð ð ð ð r"   