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`: a session starts, resumes, is cleared, is forked, or
68 /// continues after compaction.
69 SessionStart,
70 /// `userPromptSubmit`: the user submits a prompt, before the model sees it.
71 UserPromptSubmit,
72 /// `preToolUse`: a tool call has been validated and is about to run.
73 PreToolUse,
74 /// `permissionRequest`: a tool call is waiting for approval.
75 PermissionRequest,
76 /// `postToolUse`: a tool call finished successfully.
77 PostToolUse,
78 /// `preLLMCall`: a model request is about to be sent.
79 PreLLMCall,
80 /// `postLLMCall`: a model response was received.
81 PostLLMCall,
82 /// `preCompact`: context compaction is about to run.
83 PreCompact,
84 /// `postCompact`: context compaction finished.
85 PostCompact,
86 /// `subagentStart`: a child agent session starts during a turn.
87 SubagentStart,
88 /// `subagentStop`: a child agent session is about to stop.
89 SubagentStop,
90 /// `stop`: the model is about to end the turn.
91 Stop,
92 /// `sessionEnd`: the session shuts down. Observation only.
93 SessionEnd,
94 /// `notification`: the session is waiting on the user, for example on a
95 /// pending approval or a new question. Observation only.
96 Notification,
97 /// `postToolUseFailure`: a tool call failed.
98 PostToolUseFailure,
99 /// `stopFailure`: the turn ended because the model call failed. Observation
100 /// only.
101 StopFailure,
102 /// `postToolBatch`: one batch of tool results was committed.
103 PostToolBatch,
104 /// `interrupt`: a top-level turn was cancelled. Observation only, and never
105 /// sent for a child agent's turn.
106 Interrupt,
107 /// `sessionFork`: a fork of the session has completed. The host waits for
108 /// the handler's verdict, which decides how the fork is presented (such
109 /// as its tab label) but cannot block the fork.
110 SessionFork,
111 /// `toolUseStart`: an approved tool call is about to start running.
112 /// Observation only.
113 ToolUseStart,
114 /// A value from a newer host, kept verbatim so an older client decodes the
115 /// rest of the message. Never construct it with a known word.
116 Unknown(String),
117}