1use crate::verbosity::VerbosityTier;
7
8pub const EVENT_PLAN_CREATED: &str = "soothe.cognition.plan.created";
14pub const EVENT_PLAN_BATCH_STARTED: &str = "soothe.cognition.plan.batch.started";
16pub const EVENT_PLAN_REFLECTED: &str = "soothe.cognition.plan.reflected";
18
19pub const EVENT_GOAL_CREATED: &str = "soothe.cognition.goal.created";
21pub const EVENT_GOAL_COMPLETED: &str = "soothe.cognition.goal.completed";
23pub const EVENT_GOAL_FAILED: &str = "soothe.cognition.goal.failed";
25pub const EVENT_GOAL_DEFERRED: &str = "soothe.cognition.goal.deferred";
27pub const EVENT_GOAL_BATCH_STARTED: &str = "soothe.cognition.goal.batch.started";
29pub const EVENT_GOAL_REPORTED: &str = "soothe.cognition.goal.reported";
31pub const EVENT_GOAL_DIRECTIVES_APPLIED: &str = "soothe.cognition.goal.directives.applied";
33
34pub const EVENT_DEEP_RESEARCH_STARTED: &str = "soothe.subagent.deep_research.started";
40pub const EVENT_DEEP_RESEARCH_PROGRESS: &str = "soothe.subagent.deep_research.progress";
42pub const EVENT_DEEP_RESEARCH_STEP_COMPLETED: &str = "soothe.subagent.deep_research.step.completed";
44pub const EVENT_DEEP_RESEARCH_GATHER_SUMMARY: &str = "soothe.subagent.deep_research.gather.summary";
46pub const EVENT_DEEP_RESEARCH_CRAWL_SUMMARY: &str = "soothe.subagent.deep_research.crawl.summary";
48pub const EVENT_DEEP_RESEARCH_COMPLETED: &str = "soothe.subagent.deep_research.completed";
50
51pub const EVENT_REPLAY_COMPLETE: &str = "replay_complete";
57pub const EVENT_LOOP_REATTACHED_WIRE: &str = "loop_reattached";
59
60pub const EVENT_CARD_REPLAY_BEGIN: &str = "card.replay_begin";
62pub const EVENT_CARD_CREATED: &str = "card.created";
64pub const EVENT_CARD_REPLAY_END: &str = "card.replay_end";
66
67pub const EVENT_TOOL_STARTED: &str = "soothe.tool.execution.started";
69pub const EVENT_TOOL_COMPLETED: &str = "soothe.tool.execution.completed";
71pub const EVENT_TOOL_ERROR: &str = "soothe.tool.execution.error";
73
74pub const EVENT_STREAM_TOOL_CALL_UPDATE: &str = "soothe.stream.tool_call.update";
76pub const EVENT_TOOL_CALL_UPDATES_BATCH: &str = "tool_call_updates_batch";
78
79pub const EVENT_STRANGE_LOOP_STARTED: &str = "soothe.cognition.strange_loop.started";
85pub const EVENT_STRANGE_LOOP_COMPLETED: &str = "soothe.cognition.strange_loop.completed";
87pub const EVENT_STRANGE_LOOP_PLAN_DECISION: &str = "soothe.cognition.strange_loop.plan.decision";
89pub const EVENT_STRANGE_LOOP_REASONED: &str = "soothe.cognition.strange_loop.reasoned";
91pub const EVENT_STRANGE_LOOP_STEP_STARTED: &str = "soothe.cognition.strange_loop.step.started";
93pub const EVENT_STRANGE_LOOP_STEP_QUEUED: &str = "soothe.cognition.strange_loop.step.queued";
95pub const EVENT_STRANGE_LOOP_STEP_COMPLETED: &str = "soothe.cognition.strange_loop.step.completed";
97pub const EVENT_STRANGE_LOOP_CONTEXT_COMPACTED: &str =
99 "soothe.cognition.strange_loop.context.compacted";
100
101pub const EVENT_BRANCH_CREATED: &str = "soothe.cognition.branch.created";
103pub const EVENT_BRANCH_RETRY_STARTED: &str = "soothe.cognition.branch.retry.started";
105
106pub const EVENT_MESSAGE_RECEIVED: &str = "soothe.protocol.message.received";
108pub const EVENT_MESSAGE_SENT: &str = "soothe.protocol.message.sent";
110
111pub const EVENT_FINAL_REPORT: &str = "soothe.output.autonomous.final_report.reported";
113
114pub const EVENT_AUTOPILOT_STATUS_CHANGED: &str = "soothe.system.autopilot.status.changed";
116pub const EVENT_AUTOPILOT_GOAL_CREATED: &str = "soothe.system.autopilot.goal.created";
118pub const EVENT_AUTOPILOT_GOAL_PROGRESS: &str = "soothe.system.autopilot.goal.reported";
120pub const EVENT_AUTOPILOT_GOAL_COMPLETED: &str = "soothe.system.autopilot.goal.completed";
122pub const EVENT_AUTOPILOT_GOAL_SUSPENDED: &str = "soothe.system.autopilot.goal.suspended";
124pub const EVENT_AUTOPILOT_GOAL_BLOCKED: &str = "soothe.system.autopilot.goal.blocked";
126pub const EVENT_AUTOPILOT_DREAMING_ENTERED: &str = "soothe.system.autopilot.dreaming.started";
128pub const EVENT_AUTOPILOT_DREAMING_EXITED: &str = "soothe.system.autopilot.dreaming.completed";
130
131pub const EVENT_GENERAL_FAILED: &str = "soothe.error.general.failed";
133
134#[derive(Debug, Clone, PartialEq, Eq)]
136pub struct ParsedNamespace {
137 pub domain: String,
139 pub component: String,
141 pub action: String,
143}
144
145pub fn parse_namespace(ns: &str) -> Option<ParsedNamespace> {
149 let parts: Vec<&str> = ns.split('.').collect();
150 if parts.len() < 4 || parts[0] != "soothe" {
151 return None;
152 }
153 if parts[1] == "internal" {
154 return None;
155 }
156 Some(ParsedNamespace {
157 domain: parts[1].to_string(),
158 component: parts[2].to_string(),
159 action: parts[3].to_string(),
160 })
161}
162
163pub fn classify_event_verbosity(event_type_or_namespace: &str) -> VerbosityTier {
165 if let Some(parsed) = parse_namespace(event_type_or_namespace) {
166 return classify_by_domain(&parsed.domain, event_type_or_namespace);
167 }
168 classify_by_event_type_string(event_type_or_namespace)
169}
170
171fn classify_by_domain(domain: &str, full: &str) -> VerbosityTier {
172 match domain {
173 "cognition" => VerbosityTier::Normal,
174 "protocol" => VerbosityTier::Detailed,
175 "tool" => VerbosityTier::Internal,
176 "subagent" => classify_subagent_event(full),
177 "autopilot" | "system" => VerbosityTier::Normal,
178 "output" | "error" => VerbosityTier::Quiet,
179 _ => VerbosityTier::Normal,
180 }
181}
182
183fn classify_subagent_event(full: &str) -> VerbosityTier {
184 let Some(parsed) = parse_namespace(full) else {
185 return VerbosityTier::Normal;
186 };
187 match parsed.action.as_str() {
188 "started" | "completed" => VerbosityTier::Normal,
189 _ => VerbosityTier::Detailed,
190 }
191}
192
193fn classify_by_event_type_string(event_type: &str) -> VerbosityTier {
194 if event_type == EVENT_FINAL_REPORT || event_type == EVENT_GENERAL_FAILED {
195 return VerbosityTier::Quiet;
196 }
197 if event_type == EVENT_TOOL_STARTED {
198 return VerbosityTier::Internal;
199 }
200 VerbosityTier::Normal
201}
202
203pub fn is_completion_event(event_type: &str) -> bool {
205 event_type.ends_with(".completed")
206 || event_type.ends_with(".failed")
207 || event_type == EVENT_GENERAL_FAILED
208}
209
210pub fn is_subagent_progress_event(event_type: &str) -> bool {
212 let Some(parsed) = parse_namespace(event_type) else {
213 return false;
214 };
215 parsed.domain == "subagent" && matches!(parsed.action.as_str(), "started" | "completed")
216}
217
218#[cfg(test)]
219mod tests {
220 use super::*;
221
222 #[test]
223 fn parse_valid() {
224 let p = parse_namespace("soothe.cognition.plan.created").unwrap();
225 assert_eq!(p.domain, "cognition");
226 assert_eq!(p.component, "plan");
227 assert_eq!(p.action, "created");
228 }
229
230 #[test]
231 fn reject_internal() {
232 assert!(parse_namespace("soothe.internal.loop.completed").is_none());
233 }
234
235 #[test]
236 fn classify_quiet() {
237 assert_eq!(
238 classify_event_verbosity(EVENT_FINAL_REPORT),
239 VerbosityTier::Quiet
240 );
241 }
242}