1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// @generated from the MSP stable schema and protocol sources; do not edit by hand.
use serde::Deserialize;
use serde::Serialize;
mod catch_all;
/// `hook/list` params. Per-session because hook scope follows the session's
/// workspace and plugin state.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HookListParams {
/// The target session.
pub session_id: String,
}
/// `hook/list` result: one row per installed handler per event — a
/// `ResolvedHookHandler` carries one event, and grouping would lose
/// matcher/command identity.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct HookListResult {
/// The session's installed hook rows.
pub hooks: Vec<HookCatalogEntry>,
}
/// One installed handler.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct HookCatalogEntry {
/// The handler key (config key or plugin hook id).
pub key: String,
/// The event the handler runs on.
pub event: HookEventName,
/// Where the handler comes from.
pub handler_kind: HookHandlerKind,
/// The row's own switch. Non-enabled rows are included as `false`, never
/// dropped.
pub enabled: bool,
}
/// A hook row's origin: the config `HookSourceKind` values plus
/// plugin-contributed. Open: a future origin is additive.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum HookHandlerKind {
/// A managed (fleet-composed) config hook.
Managed,
/// A user-settings config hook.
User,
/// A workspace-project config hook.
Project,
/// Contributed by an installed plugin.
Plugin,
/// A value from a newer host, kept verbatim so an older client decodes the
/// rest of the message. Never construct it with a known word.
Unknown(String),
}
/// Hook event names: the lowercase-first-letter spelling of every
/// `HookEventKind::all()` variant. Open: a future event value is additive.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum HookEventName {
/// `sessionStart`: a session starts, resumes, is cleared, is forked, or
/// continues after compaction.
SessionStart,
/// `userPromptSubmit`: the user submits a prompt, before the model sees it.
UserPromptSubmit,
/// `preToolUse`: a tool call has been validated and is about to run.
PreToolUse,
/// `permissionRequest`: a tool call is waiting for approval.
PermissionRequest,
/// `postToolUse`: a tool call finished successfully.
PostToolUse,
/// `preLLMCall`: a model request is about to be sent.
PreLLMCall,
/// `postLLMCall`: a model response was received.
PostLLMCall,
/// `preCompact`: context compaction is about to run.
PreCompact,
/// `postCompact`: context compaction finished.
PostCompact,
/// `subagentStart`: a child agent session starts during a turn.
SubagentStart,
/// `subagentStop`: a child agent session is about to stop.
SubagentStop,
/// `stop`: the model is about to end the turn.
Stop,
/// `sessionEnd`: the session shuts down. Observation only.
SessionEnd,
/// `notification`: the session is waiting on the user, for example on a
/// pending approval or a new question. Observation only.
Notification,
/// `postToolUseFailure`: a tool call failed.
PostToolUseFailure,
/// `stopFailure`: the turn ended because the model call failed. Observation
/// only.
StopFailure,
/// `postToolBatch`: one batch of tool results was committed.
PostToolBatch,
/// `interrupt`: a top-level turn was cancelled. Observation only, and never
/// sent for a child agent's turn.
Interrupt,
/// `sessionFork`: a fork of the session has completed. The host waits for
/// the handler's verdict, which decides how the fork is presented (such
/// as its tab label) but cannot block the fork.
SessionFork,
/// `toolUseStart`: an approved tool call is about to start running.
/// Observation only.
ToolUseStart,
/// A value from a newer host, kept verbatim so an older client decodes the
/// rest of the message. Never construct it with a known word.
Unknown(String),
}