
    `gj                    `    d Z ddlmZ ddlZddlZddlZddlmZ 	 	 d	 	 	 	 	 	 	 	 	 ddZd	dZ	y)
ul  ``hermes slack ...`` CLI subcommands.

Today only ``hermes slack manifest`` is implemented — it generates the
Slack app manifest JSON for registering every gateway command as a native
Slack slash (``/btw``, ``/stop``, ``/model``, …) so users get the same
first-class slash UX Discord and Telegram already have.

Typical workflow::

    $ hermes slack manifest > slack-manifest.json
    # or:
    $ hermes slack manifest --write

Then paste the printed JSON into the Slack app config (Features → App
Manifest → Edit) and click Save. Slack diffs the manifest and prompts
for reinstall when scopes/commands change.
    )annotationsN)Pathc           
     (   ddl m} ||rdnd}t        |      j                         j	                         }|dvrt        d       |       }|d   d	   }d
dd
d| dd dd|d}g d}g d}	|dk(  r,ddi|d<   |j                  d       |	j                  ddg       n0|dk(  r+ddi|d<   |j                  d       |	j                  ddg       |j                          |	j                          ddd| dd  |xs d!dd" d#d$|d%d&|iid'|	id(did
dd
d)d*S )+ui  Build a full Slack manifest merging display info + our slash list.

    The slash-command list is always generated from ``COMMAND_REGISTRY`` so
    it stays in sync with the rest of Hermes. Other manifest sections
    (display info, OAuth scopes, socket mode) are set to sensible defaults
    for a Hermes deployment — users can tweak them in the Slack UI after
    pasting.

    By default, this keeps Hermes on Slack's older Assistant messaging
    experience (``assistant_view``) for backward compatibility. Pass
    ``messaging_experience="agent"`` (``--agent-view``) to emit Slack's Agent
    messaging experience (``agent_view`` + ``app_home_opened``). Pass
    ``include_assistant=False`` or ``messaging_experience="none"``
    (``--no-assistant``) to omit Slack AI messaging features and get a flat DM
    surface where ``/help``, ``/new``, etc. work inline.
    r   slack_app_manifestN	assistantnone>   r	   agentr   z;messaging_experience must be one of: assistant, agent, nonefeaturesslash_commandsFT)home_tab_enabledmessages_tab_enabledmessages_tab_read_only_enabledP   )display_namealways_online)app_homebot_userr   )zapp_mentions:readzchannels:historyzchannels:readz
chat:writecommandsz
files:readzfiles:writezgroups:historyzgroups:readz
im:historyzim:readzim:writezmpim:historyz	mpim:readz
users:read)app_mentionzmessage.channelszmessage.groupsz
message.imzmessage.mpimassistant_descriptionz$Chat with Hermes in threads and DMs.assistant_viewzassistant:write assistant_thread_context_changedassistant_thread_startedr
   agent_descriptionz#Chat with Hermes in Slack Messages.
agent_viewapp_context_changedapp_home_opened   )major_versionminor_version#   Your Hermes agent on Slack   z#1a1a2e)namedescriptionbackground_colorscopesbot
bot_events
is_enabled)event_subscriptionsinteractivityorg_deploy_enabledsocket_mode_enabledtoken_rotation_enabled)	_metadatadisplay_informationr   oauth_configsettings)	hermes_cli.commandsr   strstriplower
ValueErrorappendextendsort)
bot_namebot_descriptioninclude_assistantmessaging_experiencer   partialslashesr   
bot_scopesr*   s
             G/root/.hermes/venv/lib/python3.12/site-packages/hermes_cli/slack_cli.py_build_full_manifestrE      s   , 7#.?{V34::<BBD#AAI
 	
 !"Gj!"23G !&$(.3
 %SbM!
 "HJ$J {*#%K&
!" 	+,2*	
 
	(!F"
 	+, 	02CDEOOOO 

 SbM+K/KTcR ) 

 z
 j$ d #(#'&+

!     c                   t        | dd      xs d}t        | dd      xs d}t        | dd      rd}nt        | d	d      rd
}nd}t        | dd      rddlm}  |       d   d   }nt        |||      }t	        j
                  |dd      dz   }t        | dd      }|t        |t              r|r	 ddlm	} t         |             dz  }	nt        |      j#                         }	|	j$                  j'                  dd       |	j)                  |d       t+        d|	 t,        j.                         t+        d |	 d!t,        j.                         yt,        j0                  j3                  |       y# t        $ rP t        t        j                  j                  d      xs  t        t        j                          dz              dz  }	Y w xY w)"a  Print or write a Slack app manifest JSON.

    Flags (all parsed in ``hermes_cli/main.py``):
      --write [PATH]  Write to file instead of stdout (default path:
                      ``$HERMES_HOME/slack-manifest.json``)
      --name NAME     Override the bot display name (default: "Hermes")
      --description DESC  Override the bot description
      --slashes-only  Emit only the ``features.slash_commands`` array (for
                      merging into an existing manifest manually)
      --no-assistant  Omit Slack AI Assistant mode (assistant_view feature,
                      assistant:write scope, assistant_thread_* events) so
                      DMs render as a flat chat where bare slash commands
                      work inline instead of the Assistant thread pane.
      --agent-view    Use Slack's Agent messaging experience (agent_view,
                      app_home_opened + message.im) instead of the legacy
                      Assistant messaging experience.
    r%   NHermesr&   r#   r   Fr
   no_assistantr	   r   slashes_onlyr   r   r   r   )r@      )indentensure_ascii
write)get_hermes_homezslack-manifest.jsonHERMES_HOMEz.hermesT)parentsexist_okzutf-8)encodingzSlack manifest written to: )fileu   
Next steps:
  1. Open https://api.slack.com/apps and pick your Hermes app
     (or create a new one: Create New App → From an app manifest).
  2. Features → App Manifest → paste the contents of
     z
  3. Save; Slack will prompt to reinstall the app if scopes or
     slash commands changed.
  4. Make sure Socket Mode is enabled and you have a bot token
     (xoxb-...) and app token (xapp-...) configured via
     `hermes setup`.
)getattrr5   r   rE   jsondumps
isinstanceboolhermes_constantsrP   r   	Exceptionosenvirongetr6   home
expanduserparentmkdir
write_textprintsysstderrstdoutrO   )
argsr%   r&   r@   r   manifestpayloadwrite_targetrP   targets
             rD   slack_manifest_commandrn      s   $ 4&2(D$t4T8TKt\5)&	~u	-%*t^U+:%'
34DE'!5
 jj!%@4GG4$/LlD)lu<o/03HH ,'224FD48'G4+F843::F 8 %		% 	
  	

!-  ubjjnn];[s499;QZCZ?[\_ttus   1E2 2AG
G)TN)
r=   r6   r>   r6   r?   rZ   r@   z
str | Nonereturndict)ro   int)
__doc__
__future__r   rW   r]   rf   pathlibr   rE   rn    rF   rD   <module>rv      sc   " #  	 
  #'+	}}} } %	}
 
}@FrF   