
    (Gj                     8	   d Z ddlmZmZmZmZmZ g dZg dZi ddddgg d	d
ddgg d	dddgg d	dddgg d	dddgg d	dddgg d	ddg dg d	dddgg d	ddddgg d	dd g d!g d	d"d#g d$g d	d%d&d%gg d	d'd(g d)g d	d*d+d,gg d	d-d.d-gg d	d/d0d/gg d	d1d2g g d	i d3d4d3gg d	d5d6g d7g d	d8d9d8gg d	d:d;d<gg d	d=d>d?gg d	d@dAg dBg d	dCdDg dEg d	dFdGdFgg d	dHdIdHgg d	dJdKg dLg d	dMdNdOgg d	dPdQg dRg d	dSdTg dUg d	dVdWddgdd'gd	dXdYg g dZd	d[d\g d]g d^d_d`dag dbg d	i dcddg deg d	dfdgeg d	dhdieg d	djdkeg d	dldmedFdHgz   g d	dndoeg d	dpdqeg d	drdseg d	dtdueg d	dvdweg d	dxdyeg d	dzd{eg d	d|d}eg d	d~deg d	ddeg dz   g d	ddeg d	ddeg d	deg d	deg d	deg dLz   dg ddeg d	deg d	dg g dd	dZ	d^dde
dedeee
ef                  fdZde
dee
         fdZdd^dde
dee
         dedee
         fdZdee
         dee
         fdZdee
         fdZdee
e
f         fdZdee
ee
ef         f         fdZdee
         fdZde
defdZ	 	 dde
de
dee
         dee
         ddf
dZde
dee
ef         fdZedk    r ed            ed            ed            ed            e                                            D ]U\  ZZ ee          Zed         rdndZ ede dedded                      ed eed                    d           V ed            ed           dD ]RZ ee          Z ede d            ed ee           dd                      e!e                                S ed            ed            eg d          Z" ed            edd                      e!e"                                 ed            ed            edddgddgĦ            ed¦          Z# edŦ            ede#d                      edd                     e#d                               dS dS )a  
Toolsets Module

This module provides a flexible system for defining and managing tool aliases/toolsets.
Toolsets allow you to group tools together for specific scenarios and can be composed
from individual tools or other toolsets.

Features:
- Define custom toolsets with specific tools
- Compose toolsets from other toolsets
- Built-in common toolsets for typical use cases
- Easy extension for new toolsets
- Support for dynamic toolset resolution

Usage:
    from toolsets import get_toolset, resolve_toolset, get_all_toolsets
    
    # Get tools for a specific toolset
    tools = get_toolset("research")
    
    # Resolve a toolset to get all tool names (including from composed toolsets)
    all_tools = resolve_toolset("full_stack")
    )ListDictAnySetOptional)1
web_searchweb_extractterminalprocessread_terminalclose_terminal	read_file
write_filepatchsearch_filesvision_analyzeimage_generateskills_list
skill_viewskill_managebrowser_navigatebrowser_snapshotbrowser_clickbrowser_typebrowser_scrollbrowser_backbrowser_pressbrowser_get_imagesbrowser_visionbrowser_consolebrowser_cdpbrowser_dialogtext_to_speechtodomemorysession_searchclarifyexecute_codedelegate_taskcronjobha_list_entitiesha_get_stateha_list_servicesha_call_servicekanban_showkanban_listkanban_completekanban_blockkanban_heartbeatkanban_commentkanban_createkanban_linkkanban_unblockcomputer_use)r   r	   r   r'   webz)Web research and content extraction toolsr   r	   descriptiontoolsincludessearchz0Web search only (no content extraction/scraping)x_searchu   Search X (Twitter) posts and threads via xAI's built-in x_search Responses tool. Available when xAI credentials are configured (SuperGrok OAuth or XAI_API_KEY). Off by default; enable in `hermes tools` → X (Twitter) Search.visionzImage analysis and vision toolsr   videozGVideo analysis and understanding tools (opt-in, not in default toolset)video_analyze	image_genz"Creative generation tools (images)r   	video_genu  Video generation tools. Single ``video_generate`` tool covers text-to-video (prompt only) and image-to-video (prompt + image_url), plus reference-to-video. Provider-specific edit/extend workflows may appear as separate tools. Configure via ``hermes tools`` → Video Generation.)video_generatexai_video_editxai_video_extendr8   u   Background desktop control via cua-driver (macOS/Windows/Linux) — screenshots, mouse, keyboard, scroll, drag. Does NOT steal the user's cursor or keyboard focus. Works with any tool-capable model.r
   z7Terminal/command execution and process management toolsr   skillsz\Access, create, edit, and manage skill documents with specialized instructions and knowledge)r   r   r   browserz|Browser automation for web interaction (navigate, click, type, scroll, iframes, hold-click) with web search for finding URLs)r   r   r   r   r   r   r   r   r   r    r!   r"   r   r*   zbCronjob management tool - create, list, update, pause, resume, remove, and trigger scheduled tasksfilez_File manipulation tools: read, write, patch (with fuzzy matching), and search (content + files))r   r   r   r   ttszVText-to-speech: convert text to audio with Edge TTS (free), ElevenLabs, OpenAI, or xAIr#   r$   z.Task planning and tracking for multi-step workr%   zAPersistent memory across sessions (personal notes + user profile)context_enginez2Runtime tools exposed by the active context enginer&   z7Search and recall past conversations with summarizationprojectuG   Desktop Projects — create/switch named workspaces (GUI sessions only))project_listproject_createproject_switchr'   zAAsk the user clarifying questions (multiple-choice or open-ended)code_executionzMRun Python scripts that call tools programmatically (reduces LLM round trips)r(   
delegationz:Spawn subagents with isolated context for complex subtasksr)   homeassistantz0Home Assistant smart home control and monitoring)r+   r,   r-   r.   kanbanu  Kanban multi-agent coordination — only active when the agent is spawned by the kanban dispatcher (HERMES_KANBAN_TASK env set). The dispatcher runs inside the gateway by default; see `kanban.dispatch_in_gateway` in config.yaml. Lets workers mark tasks done with structured handoffs, block for human input, heartbeat during long ops, comment on threads, and (for orchestrators) list, unblock, and fan out tasks.)	r/   r0   r1   r2   r3   r4   r5   r6   r7   discordzSDiscord read and participate tools (fetch messages, search members, create threads)discord_adminzKDiscord server management (list channels/roles, pin messages, assign roles)yuanbaozAYuanbao platform tools - group info, member queries, DM, stickers)yb_query_group_infoyb_query_group_members
yb_send_dmyb_search_stickeryb_send_sticker
feishu_docz!Read Feishu/Lark document contentfeishu_doc_readfeishu_drivez:Feishu/Lark document comment operations (list, reply, add))feishu_drive_list_comments!feishu_drive_list_comment_repliesfeishu_drive_reply_commentfeishu_drive_add_commentspotifyzCNative Spotify playback, search, playlist, album, and library tools)spotify_playbackspotify_devicesspotify_queuespotify_searchspotify_playlistsspotify_albumsspotify_library	debuggingz%Debugging and troubleshooting toolkitsafez$Safe toolkit without terminal access)r9   r@   rC   codingzbCoding-focused toolset: files, terminal, search, web docs, skills, todo, delegate, vision, browser) r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r$   r%   r&   r'   r(   r)   T)r;   r<   r=   posturez
hermes-acpum   Editor integration (VS Code, Zed, JetBrains) — coding-focused tools without messaging, audio, or clarify UI)r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r$   r%   r&   r(   r)   zhermes-api-serveru|   OpenAI-compatible API server — full agent tools accessible via HTTP (no interactive UI tools like clarify or send_message))#r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r$   r%   r&   r(   r)   r*   r+   r,   r-   r.   z
hermes-clizHFull interactive CLI toolset - all default tools plus cronjob managementzhermes-cronzMDefault cron toolset - same core tools as hermes-cli; gated by `hermes tools`hermes-telegramzPTelegram bot toolset - full access for personal use (terminal has safety checks)hermes-discordz]Discord bot toolset - full access (terminal has safety checks via dangerous command approval)hermes-whatsappzMWhatsApp bot toolset - similar to Telegram (personal messaging, more trusted)hermes-slackzNSlack bot toolset - full access for workspace use (terminal has safety checks)hermes-signalz?Signal bot toolset - encrypted messaging platform (full access)hermes-bluebubbleszNBlueBubbles iMessage bot toolset - Apple iMessage via local BlueBubbles serverhermes-homeassistantzDHome Assistant bot toolset - smart home event monitoring and controlhermes-emailz>Email bot toolset - interact with Hermes via email (IMAP/SMTP)hermes-mattermostzAMattermost bot toolset - self-hosted team messaging (full access)hermes-matrixzDMatrix bot toolset - decentralized encrypted messaging (full access)hermes-dingtalkzBDingTalk bot toolset - enterprise messaging platform (full access)hermes-feishuzLFeishu/Lark bot toolset - enterprise messaging via Feishu/Lark (full access))r^   r`   ra   rb   rc   hermes-weixinzFWeixin bot toolset - personal WeChat messaging via iLink (full access)hermes-qqbotzBQQBot toolset - QQ messaging via Official Bot API v2 (full access)z=WeCom bot toolset - enterprise WeChat messaging (full access)zJWeCom callback toolset - enterprise self-built app messaging (full access)uZ   Yuanbao Bot 元宝消息平台工具集 - 群信息、成员查询、私聊、贴纸表情ztools.yuanbao_tools)r;   r<   moduler=   z7SMS bot toolset - interact with Hermes via SMS (Twilio)z=Webhook toolset - receive and process external webhook eventsz7Gateway toolset - union of all messaging platform tools)rp   rq   rr   rs   rt   ru   rv   rw   
hermes-smsrx   ry   rz   r{   hermes-wecomhermes-wecom-callbackr|   r}   hermes-webhookhermes-yuanbao)r   r   r   r   r   zhermes-gatewayinclude_registrynamer   returnc                    t                               |           }|sO|sdS i |t          |                    dg                     t          |                    dg                     dS 	 ddlm} n# t
          $ r	 |r|ndcY S w xY w|r[t          t          |                    dg                     t          |                    |                     z            }i |d|iS | }d|  }|	                    |           }| t                      vr|}|sdS d|  d	}nGd
 t                                                      D             }|                    |           }	|	rd|	 d	}||                    |          g dS )a  
    Get a toolset definition by name.

    Args:
        name (str): Name of the toolset
        include_registry (bool): When True (default), merge in tools that
            plugins/overlays registered into this toolset via the registry.
            When False, return only the static ``TOOLSETS`` definition (the
            composite-authored view). Platform reverse-mapping in
            ``_get_platform_tools`` uses False so that a tool registered into a
            toolset but absent from a platform's static composite does not drop
            the whole toolset from inference. See issue #49622.

    Returns:
        Dict: Toolset definition with description, tools, and includes
        None: If toolset not found. With include_registry=False the static
            view only recognizes names literally present in ``TOOLSETS``, so
            registry/MCP-only toolsets AND registry-derived aliases return None
            (they have no static counterpart).
    Nr<   r=   )r<   r=   r   registryzPlugin toolset: zMCP server 'z' toolsc                 ,    i | ]\  }}|t           v||S  TOOLSETS).0alias	canonicals      ./home/rurouni/.hermes/hermes-agent/toolsets.py
<dictcomp>zget_toolset.<locals>.<dictcomp>  s3     
 
 
 yH$$ u$$$    r:   )r   getlisttools.registryr   	Exceptionsortedsetget_tool_names_for_toolsetget_toolset_alias_target_get_plugin_toolset_names_get_registry_toolset_aliasesitems)
r   r   toolsetr   merged_toolsregistry_toolsetr;   alias_targetreverse_aliasesr   s
             r   get_toolsetr   J  s   * ll4  G 

  	4

'++gr2233W[[R8899
 
 
 	
,+++++++ , , ,!+wwt+++,  2GR(())(55d;;<<=
 
 2'17L111+T++K44T::L,....' 	42T222
 
$A$C$C$I$I$K$K
 
 

  ##D)) 	87777K #445EFF  s   -A4 4BBtoolset_namec                 x   t          t                    }t          |           }|rd|v st          t          |                     |z
  S t          |d                   |z
  }|                    dg           D ]B}t          |          }|r/d|v r+|                    t          |d                   |z
             C|S )uj  Return a ``hermes-*`` bundle's platform-specific tools, excluding core.

    Platform bundles are defined as ``_HERMES_CORE_TOOLS + [platform extras]``.
    When a bundle name appears in ``disabled_toolsets``, subtracting the whole
    bundle would strip core tools (terminal, read_file, …) shared by every
    other enabled toolset, emptying the model's tool list (#33924). This
    returns only the bundle's non-core delta (its own extras plus those of any
    one-level ``includes``), so disabling a bundle removes its platform tools
    while leaving core intact.

    Bundle nesting is one level deep in practice (only ``hermes-gateway``
    includes other bundles, and those leaves don't nest further), so a single
    ``includes`` pass is sufficient. Unknown/garbage names fall back to the
    full resolution minus core — never re-introducing the core wipe.
    r<   r=   )r   _HERMES_CORE_TOOLSr   resolve_toolsetr   update)r   corets_def	to_removeincinc_defs         r   bundle_non_core_toolsr     s      !""D&&F 9w&((?<0011D88F7O$$t+Izz*b)) ; ;c"" 	;w'))S!122T9:::r   Nvisitedc                   |t                      }| dv rgt                      }t                      D ];}t          ||                                |          }|                    |           <t          |          S | |v rg S |                    |            t          | |          }|s|r|                     d          r| t          d          d         	 ddl
m} |                              rst          t                    }	 ddlm}	 |                    fd|	j                                        D                        n# t$          $ r Y nw xY wt'          |          S n# t$          $ r Y nw xY wg S t          |                    d	g                     }
|                    d
g           D ])}t          |||          }|
                    |           *t          |
          S )a<  
    Recursively resolve a toolset to get all tool names.

    This function handles toolset composition by recursively resolving
    included toolsets and combining all tools.

    Args:
        name (str): Name of the toolset to resolve
        visited (Set[str]): Set of already visited toolsets (for cycle detection)
        include_registry (bool): When True (default), include tools that
            plugins/overlays registered into a toolset. When False, resolve only
            the static ``TOOLSETS`` definition (includes are still resolved, but
            statically). Platform reverse-mapping uses False so a registry-added
            tool cannot drop the whole toolset from inference (see #49622 and
            ``_get_platform_tools``).

    Returns:
        List[str]: List of all tool names in the toolset
    N>   *allr   zhermes-r   )platform_registryr   c              3   <   K   | ]}|j         k    |j        V  d S N)r   r   )r   eplatform_names     r   	<genexpr>z"resolve_toolset.<locals>.<genexpr>  s>       , ,'( yM99 F9999, ,r   r<   r=   )r   get_toolset_namesr   copyr   r   addr   
startswithlengateway.platform_registryr   is_registeredr   r   r   _toolsvaluesr   r   r   )r   r   r   	all_toolsr   resolvedr   r   plugin_toolsr   r<   included_nameincluded_toolsr   s                @r   r   r     sc   ( %% |!ee	-// 	' 	'L&|W\\^^VfgggHX&&&&i   
 w	KK $1ABBBG   		 : : 	 Y1MGGGGGG$22=AA 
.#&'9#:#:L;;;;;;$++ , , , ,,4O,B,B,D,D, , ,     %   ---
.     	 GR(())E
 !Z44 % %(Rbccc^$$$$%==s6   /E) 
>E	 E) 	
EE) EE) )
E65E6toolset_namesc                     t                      }| D ]&}t          |          }|                    |           't          |          S )z
    Resolve multiple toolsets and combine their tools.
    
    Args:
        toolset_names (List[str]): List of toolset names to resolve
        
    Returns:
        List[str]: Combined list of all tool names (deduplicated)
    )r   r   r   r   )r   r   r   r<   s       r   resolve_multiple_toolsetsr     sN     I    %%)r   c                      	 ddl m}  d |                                 D             S # t          $ r t	                      cY S w xY w)u   Return toolset names registered by plugins (from the tool registry).

    These are toolsets that exist in the registry but not in the static
    ``TOOLSETS`` dict — i.e. they were added by plugins at load time.
    r   r   c                 $    h | ]}|t           v|S r   r   )r   r   s     r   	<setcomp>z,_get_plugin_toolset_names.<locals>.<setcomp>  s-     
 
 
8++ +++r   )r   r   get_registered_toolset_namesr   r   r   s    r   r   r     sp    ++++++
 
 ( E E G G
 
 
 	

    uus   #& A Ac                  \    	 ddl m}  |                                 S # t          $ r i cY S w xY w)z@Return explicit toolset aliases registered in the live registry.r   r   )r   r   get_registered_toolset_aliasesr   r   s    r   r   r   %  sO    ++++++66888   			s    ++c                      t          t                    } t                      }t                      D ]L}|}|                                D ]\  }}||k    r|t          vr|} n|| v r6t          |          }|r|| |<   M| S )z
    Get all available toolsets with their definitions.

    Includes both statically-defined toolsets and plugin-registered ones.
    
    Returns:
        Dict: All toolset definitions
    )dictr   r   r   r   r   )resultaliasests_namedisplay_namer   r   r   s          r   get_all_toolsetsr   .  s     (^^F+--G,.. 
+ 
+ ' 	 	E9G##X(=(=$6!!l++ 	+#*F< Mr   c                  T   t          t                                                    } t                      }t	                      D ]W}|                                D ]+\  }}||k    r |t          vr|                     |            n,|                     |           Xt          |           S )z
    Get names of all available toolsets (excluding aliases).

    Includes plugin-registered toolset names.
    
    Returns:
        List[str]: List of toolset names
    )r   r   keysr   r   r   r   r   )namesr   r   r   r   s        r   r   r   G  s       E+--G,..   ' 	 	E9G##X(=(=		%   IIg%==r   c                 h    | dv rdS | t           v rdS | t                      v rdS | t                      v S )z
    Check if a toolset name is valid.
    
    Args:
        name (str): Toolset name to validate
        
    Returns:
        bool: True if valid, False otherwise
    >   r   r   T)r   r   r   )r   s    r   validate_toolsetr   ^  sM     |txt(****t02222r   r;   r<   r=   c                 *    ||pg |pg dt           | <   dS )a
  
    Create a custom toolset at runtime.
    
    Args:
        name (str): Name for the new toolset
        description (str): Description of the toolset
        tools (List[str]): Direct tools to include
        includes (List[str]): Other toolsets to include
    r:   Nr   r   r;   r<   r=   s       r   create_custom_toolsetr   r  s)      #"N HTNNNr   c           
          t          |           }|sdS t          |           }| |d         |d         |d         |t          |          t          |d                   dS )z
    Get detailed information about a toolset including resolved tools.
    
    Args:
        name (str): Toolset name
        
    Returns:
        Dict: Detailed toolset information
    Nr;   r<   r=   )r   r;   direct_toolsr=   resolved_tools
tool_countis_composite)r   r   r   bool)r   r   r   s      r   get_toolset_infor     su     $G t$T**N }-(J'(.))WZ011  r   __main__zToolsets System Demoz<============================================================z
Available Toolsets:z(----------------------------------------r   z[composite]z[leaf]z   20z - z     Tools: r   z totalz
Toolset Resolution Examples:)r9   r
   rm   rl   z
  :z    Resolved to z tools: z, z
Multiple Toolset Resolution:)r9   r@   r
   z*  Combining ['web', 'vision', 'terminal']:z    Result: z
Custom Toolset Creation:	my_customz$My custom toolset for specific tasksr   z  Created 'my_custom' toolset:z    Description: z    Resolved tools: r   )NN)$__doc__typingr   r   r   r   r   r   _HERMES_WEBHOOK_SAFE_TOOLSr   strr   r   r   r   r   r   r   r   r   r   r   r   __name__printr   r   r   info	compositer   r<   joinr   combinedcustom_infor   r   r   <module>r      s   0 2 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 l   g	B. g I g ?
 	 	g2 8"# 3g> `!" ?gJ ;"# KgV 5 JII
 
Wgn R !! ogB Pi( CgN u>>> OgZ  V
 
 
 
 
[gr { sg@ xEEE AgL 
o"# MgX G Ygd Z egp K qg g| P"# }gH `EEE IgT Z Ug` f ! agl S!" mg~ I\\\ gJ ?
 
 
 ! Kgp l qg| d!" }gH Z
 
 
 
 
Ig` :#$ agl S
 
 
  mg~ \
 
 
  gV >i(FO Wgb =222 cgv {
 
 
  ) wgv  G
 
 
 ! wg g g\	  V
 
 
8 = ]	g^
 a# _
gj
  g#	 	k
g@ i# AgL v#'
 
  Mg^ f# _gj g# kgv X# wgB g# CgN ]# OgZ W# [gf Z# ggr ]# sg~ [# gJ e# '
 '
 '
 
 
 
Kgb _# cgn [# og g| W#  d#  t# '
 '
 '
 
 (  Q#  W+  Q r  r  r Eg g gV 8< F F Fc F FcSVh@X F F F FR C    8OUY O O O# OC Od O^bcf^g O O O OdT#Y 49    &3s8    "tCH~    $sDcN23    249    .33 34 3 3 3 3. 	 
 9 3i	
 
   03 4S>    : z	E
 !!!	E(OOO	E
!"""	E(OOO))++1133 B Bg%%%).%9GMMx	C9CCtCCC7=+ACCDDD@SS&6!788@@@AAAA	E
*+++	E(OOO8 Q Q%%nTnnnOUOOTYYvve}}5M5MOOPPPP	E
*+++	E(OOO(()F)F)FGGH	E
6777	E
666(#3#344
6
6777	E
&'''	E(OOO:nh'	    #";//K	E
*+++	E
:k-8
:
:;;;	E
K;7G+H!I!I
K
KLLLLLI r   