Skip to main content

muse_code_sdk/msp/method/
hook.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6mod catch_all;
7
8/// `hook/list` params. Per-session because hook scope follows the session's
9/// workspace and plugin state.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct HookListParams {
13    /// The target session.
14    pub session_id: String,
15}
16
17/// `hook/list` result: one row per installed handler per event — a
18/// `ResolvedHookHandler` carries one event, and grouping would lose
19/// matcher/command identity.
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "camelCase")]
22#[non_exhaustive]
23pub struct HookListResult {
24    /// The session's installed hook rows.
25    pub hooks: Vec<HookCatalogEntry>,
26}
27
28/// One installed handler.
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
30#[serde(rename_all = "camelCase")]
31#[non_exhaustive]
32pub struct HookCatalogEntry {
33    /// The handler key (config key or plugin hook id).
34    pub key: String,
35    /// The event the handler runs on.
36    pub event: HookEventName,
37    /// Where the handler comes from.
38    pub handler_kind: HookHandlerKind,
39    /// The row's own switch. Non-enabled rows are included as `false`, never
40    /// dropped.
41    pub enabled: bool,
42}
43
44/// A hook row's origin: the config `HookSourceKind` values plus
45/// plugin-contributed. Open: a future origin is additive.
46#[derive(Debug, Clone, PartialEq, Eq)]
47#[non_exhaustive]
48pub enum HookHandlerKind {
49    /// A managed (fleet-composed) config hook.
50    Managed,
51    /// A user-settings config hook.
52    User,
53    /// A workspace-project config hook.
54    Project,
55    /// Contributed by an installed plugin.
56    Plugin,
57    /// A value from a newer host, kept verbatim so an older client decodes the
58    /// rest of the message. Never construct it with a known word.
59    Unknown(String),
60}
61
62/// Hook event names: the lowercase-first-letter spelling of every
63/// `HookEventKind::all()` variant. Open: a future event value is additive.
64#[derive(Debug, Clone, PartialEq, Eq)]
65#[non_exhaustive]
66pub enum HookEventName {
67    SessionStart,
68    UserPromptSubmit,
69    PreToolUse,
70    PermissionRequest,
71    PostToolUse,
72    /// Explicit rename: the governing rules rules lowercase-first-letter
73    /// (`preLLMCall`), preserving the acronym.
74    PreLLMCall,
75    /// Explicit rename: the governing rules rules `postLLMCall`.
76    PostLLMCall,
77    PreCompact,
78    PostCompact,
79    SubagentStart,
80    SubagentStop,
81    Stop,
82    SessionEnd,
83    Notification,
84    PostToolUseFailure,
85    StopFailure,
86    PostToolBatch,
87    Interrupt,
88    SessionFork,
89    ToolUseStart,
90    /// A value from a newer host, kept verbatim so an older client decodes the
91    /// rest of the message. Never construct it with a known word.
92    Unknown(String),
93}