
    sj                     	   U d Z ddlmZ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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	d0d1d0gg d	d2d3d2gg d	i d4d5g g d	d6d7d6gg d	d8d9g d:g d	d;d<g d=g d	d>d?d>gg d	d@dAdBgg d	dCdDdEgg d	dFdGg dHg d	dIdJg dKg d	dLdMdLgg d	dNdOdNgg d	dPdQg dRg d	dSdTdUgg d	dVdWg dXg d	dYdZg d[g d	d\d]dd!gdd*gd	d^d_g g d`d	i dadbg dcg dddedfdgg dhg d	didjg dkg d	dldmeg d	dndoeg d	dpdqeg d	drdsedLdNgz   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	ddeg d	ddeg d	ddeg dz   g d	deg d	deg d	deg d	deg d	deg dRz   dg ddeg d	de	g d	dg g dd	dZ
ddddededeeeef                  fdZdedee         fdZi Zeeeeeef         ee         f         ed<   dddd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")
    )DictListAnySetOptionalTuple);
web_searchweb_extractterminalprocess	read_file
write_filepatchsearch_filesvision_analyzeimage_generatebfl_flux3_text_to_videobfl_flux3_image_to_videobfl_flux3_keyframes_to_videobfl_flux3_video_continuationbfl_flux3_get_resultbfl_flux3_prompting_guide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browser_exec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_request_reviewkanban_request_changeskanban_heartbeatkanban_commentkanban_createkanban_linkkanban_unblockkanban_attachkanban_attach_urlkanban_attachments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_searchuE  Search X (Twitter) posts and threads via xAI's built-in x_search Responses tool. Read-only public X discovery; use the xurl skill for authenticated X API reads and account actions. 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_extendbfla  Black Forest Labs FLUX 3 video generation through the Nous tool gateway: per-mode submit tools (text, image, keyframes, continuation), a poll tool, and a prompting guide. Generations take minutes, so submit returns a job id and the model polls for the result.)r   r   r   r   r   r   rC   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	   r0   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_switch
desktop_uiud   Desktop GUI affordances — in-app terminal/browser panes, pane focus, reactions (GUI sessions only))read_terminalclose_terminalopen_previewclose_previewread_previewdrive_previewannotate_previewread_window_below
focus_panereact_to_message	setup_mcptourr-   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)r1   r2   r3   r4   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, enter first-class review (request_review — not a block), return review changes, block for human input, heartbeat during long ops, comment on threads, attach files, and (for orchestrators) list, unblock, and fan out tasks.)r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   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)rD   rK   rN   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/   T)rF   rG   rH   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.   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,   r.   r/   r0   r1   r2   r3   r4   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))rw   ry   rz   r{   r|   zFWeixin bot toolset - personal WeChat messaging via iLink (full access)zBQQBot 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)rF   rG   modulerH   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)r   r   r   r   r   r   r   r   
hermes-smsr   r   r   r   hermes-wecomhermes-wecom-callbackhermes-weixinhermes-qqbothermes-webhookhermes-yuanbao)r   r   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).
    NrG   rH   )rG   rH   r   registryzPlugin toolset: zMCP server 'z' toolsc                 ,    i | ]\  }}|t           v||S  TOOLSETS).0alias	canonicals      ,/home/agent/.hermes/hermes-agent/toolsets.py
<dictcomp>zget_toolset.<locals>.<dictcomp>  s3     
 
 
 yH$$ u$$$    rE   )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_toolsetrF   alias_targetreverse_aliasesr   s
             r   get_toolsetr     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.
    rG   rH   )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   _resolve_toolset_memoNvisitedc                   |du }|rm	 ddl m} t          |          }t          |dd          }n# t          $ r d}d}Y nw xY w| |||f}t
                              |          }|t          |          S |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} |                              rnt          t*                    }	 ddl m} |                    fd	|                                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          |          }|r	 ddl m} t          |          }t          |dd          }n# t          $ r d}d}Y nw xY wt#          t
                    dk    rt
                                           t          |          t
          | |||f<   |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
    Nr   r   _generation>   *allr   zhermes-)platform_registryc              3   <   K   | ]}|j         k    |j        V  d S N)r   r   )r   eplatform_names     r   	<genexpr>z"resolve_toolset.<locals>.<genexpr>I  s>       , ,'( yM99 F9999, ,r   rG   rH      )r   r   idgetattrr   r   r   r   r   get_toolset_namesr   copyr   r   addr   
startswithlengateway.platform_registryr   is_registeredr   get_all_entriesclear)r   r   r   external_callr   registry_id
generationmemo_keycached	all_toolsr   resolvedr   r   plugin_toolsrG   included_nameincluded_toolsresultr   s                      @r   r   r     s   ( tOM  	//////X,,K =!<<JJ 	 	 	KJJJ	 *KD&**844<<%% |!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;;;;;;$++ , , , ,,4,D,D,F,F, , ,     %   ---
.     	 GR(())E
 !Z44 % %(Rbccc^$$$$E]]F `	//////X,,K =!<<JJ 	 	 	KJJJ	
 $%%,,!'')))SWX^S_S_t%5{JOPMsW   &0 A A/G =9F7 6G 7
GG GG 
G$#G$&J JJ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   rG   s       r   resolve_multiple_toolsetsr   q  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   )r   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     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   rF   rG   rH   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
    rE   Nr   r   rF   rG   rH   s       r   create_custom_toolsetr    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
    NrF   rG   rH   )r   rF   direct_toolsrH   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:)rD   r   r   r   z
  :z    Resolved to z tools: z, z
Multiple Toolset Resolution:)rD   rK   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   r   _HERMES_WEBHOOK_SAFE_TOOLSr   strr	  r   r   r   int__annotations__r   r   r   r   r   r   r   r  r
  __name__printr   r   r   info	compositer   rG   joinr   combinedcustom_infor   r   r   <module>r     s.    0 9 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
= = = D   `	B. ` I ` "  `6 8"# 7`B `!" C`N ;"# O`Z 5 JII
 
[`r 

 
 
 ! s`X R !! Y`l Pi( m`x u>>> y`D  V
 
 
 
 
E`\ { ]`j xEEE k`v 
o"# w`B G C`N Z O` `Z K [`f P"# g`r `EEE s`P }
 
 
 
 
Q`h Z i`t f ! u`@ S!" A`R I\\\ S`^ D
 
 
 ' _`J l K`V d!" W`b Z
 
 
 
 
c`z :#$ {`F S
 
 
  G`X \
 
 
  Y`p >i(FO q`| =222 }` ` `Z	 {
 
 
  + [	`\
  G
 
 
 # ]
`D  V 
  
  
B G$ $E`P a# Q`\  g#	 	]`r i# s`~ v#'
 
  `P f# Q`\ g# ]`h X# i`t g# u`@ ]# A`L W# M`X Z# Y`d ]# e`p [# q`| e# '
 '
 '
 
 
 
}` `V `#  \#  W#  d#  t# '
 '
 '
 
 (  Q#  W+  Q r  r  r w` ` `H 8< F F Fc F FcSVh@X F F F FR C    L FH tE#tS#"56S	AB G G GmUY m m m# mC md m^bcf^g m m m m`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   