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_CREATED: &str = "soothe.card.created";
62pub const EVENT_CARD_UPDATED: &str = "soothe.card.updated";
64pub const EVENT_CARD_FINALIZED: &str = "soothe.card.finalized";
66pub const EVENT_CARD_REPLAY_BEGIN: &str = "soothe.card.replay.begin";
68pub const EVENT_CARD_REPLAY_END: &str = "soothe.card.replay.end";
70
71pub const EVENT_TOOL_STARTED: &str = "soothe.tool.execution.started";
73pub const EVENT_TOOL_COMPLETED: &str = "soothe.tool.execution.completed";
75pub const EVENT_TOOL_ERROR: &str = "soothe.tool.execution.error";
77
78pub const EVENT_STREAM_TOOL_CALL_UPDATE: &str = "soothe.stream.tool_call.update";
80pub const EVENT_TOOL_CALL_UPDATES_BATCH: &str = "tool_call_updates_batch";
82
83pub const EVENT_STRANGE_LOOP_STARTED: &str = "soothe.cognition.strange_loop.started";
89pub const EVENT_STRANGE_LOOP_COMPLETED: &str = "soothe.cognition.strange_loop.completed";
91pub const EVENT_STRANGE_LOOP_PLAN_DECISION: &str = "soothe.cognition.strange_loop.plan.decision";
93pub const EVENT_STRANGE_LOOP_REASONED: &str = "soothe.cognition.strange_loop.reasoned";
95pub const EVENT_STRANGE_LOOP_STEP_STARTED: &str = "soothe.cognition.strange_loop.step.started";
97pub const EVENT_STRANGE_LOOP_STEP_QUEUED: &str = "soothe.cognition.strange_loop.step.queued";
99pub const EVENT_STRANGE_LOOP_STEP_COMPLETED: &str = "soothe.cognition.strange_loop.step.completed";
101pub const EVENT_STRANGE_LOOP_CONTEXT_COMPACTED: &str =
103 "soothe.cognition.strange_loop.context.compacted";
104
105pub const EVENT_BRANCH_CREATED: &str = "soothe.cognition.branch.created";
107pub const EVENT_BRANCH_RETRY_STARTED: &str = "soothe.cognition.branch.retry.started";
109
110pub const EVENT_MESSAGE_RECEIVED: &str = "soothe.protocol.message.received";
112pub const EVENT_MESSAGE_SENT: &str = "soothe.protocol.message.sent";
114
115pub const EVENT_FINAL_REPORT: &str = "soothe.output.autonomous.final_report.reported";
117
118pub const EVENT_AUTOPILOT_STATUS_CHANGED: &str = "soothe.system.autopilot.status.changed";
120pub const EVENT_AUTOPILOT_GOAL_CREATED: &str = "soothe.system.autopilot.goal.created";
122pub const EVENT_AUTOPILOT_GOAL_PROGRESS: &str = "soothe.system.autopilot.goal.reported";
124pub const EVENT_AUTOPILOT_GOAL_COMPLETED: &str = "soothe.system.autopilot.goal.completed";
126pub const EVENT_AUTOPILOT_GOAL_SUSPENDED: &str = "soothe.system.autopilot.goal.suspended";
128pub const EVENT_AUTOPILOT_GOAL_BLOCKED: &str = "soothe.system.autopilot.goal.blocked";
130pub const EVENT_AUTOPILOT_DREAMING_ENTERED: &str = "soothe.system.autopilot.dreaming.started";
132pub const EVENT_AUTOPILOT_DREAMING_EXITED: &str = "soothe.system.autopilot.dreaming.completed";
134
135pub const EVENT_GENERAL_FAILED: &str = "soothe.error.general.failed";
137
138#[derive(Debug, Clone, PartialEq, Eq)]
140pub struct ParsedNamespace {
141 pub domain: String,
143 pub component: String,
145 pub action: String,
147}
148
149pub fn parse_namespace(ns: &str) -> Option<ParsedNamespace> {
153 let parts: Vec<&str> = ns.split('.').collect();
154 if parts.len() < 4 || parts[0] != "soothe" {
155 return None;
156 }
157 if parts[1] == "internal" {
158 return None;
159 }
160 Some(ParsedNamespace {
161 domain: parts[1].to_string(),
162 component: parts[2].to_string(),
163 action: parts[3].to_string(),
164 })
165}
166
167pub fn classify_event_verbosity(event_type_or_namespace: &str) -> VerbosityTier {
169 if let Some(parsed) = parse_namespace(event_type_or_namespace) {
170 return classify_by_domain(&parsed.domain, event_type_or_namespace);
171 }
172 classify_by_event_type_string(event_type_or_namespace)
173}
174
175fn classify_by_domain(domain: &str, full: &str) -> VerbosityTier {
176 match domain {
177 "cognition" => VerbosityTier::Normal,
178 "protocol" => VerbosityTier::Detailed,
179 "tool" => VerbosityTier::Internal,
180 "subagent" => classify_subagent_event(full),
181 "autopilot" | "system" => VerbosityTier::Normal,
182 "output" | "error" => VerbosityTier::Quiet,
183 _ => VerbosityTier::Normal,
184 }
185}
186
187fn classify_subagent_event(full: &str) -> VerbosityTier {
188 let Some(parsed) = parse_namespace(full) else {
189 return VerbosityTier::Normal;
190 };
191 match parsed.action.as_str() {
192 "started" | "completed" => VerbosityTier::Normal,
193 _ => VerbosityTier::Detailed,
194 }
195}
196
197fn classify_by_event_type_string(event_type: &str) -> VerbosityTier {
198 if event_type == EVENT_FINAL_REPORT || event_type == EVENT_GENERAL_FAILED {
199 return VerbosityTier::Quiet;
200 }
201 if event_type == EVENT_TOOL_STARTED {
202 return VerbosityTier::Internal;
203 }
204 VerbosityTier::Normal
205}
206
207pub fn is_completion_event(event_type: &str) -> bool {
209 event_type.ends_with(".completed")
210 || event_type.ends_with(".failed")
211 || event_type == EVENT_GENERAL_FAILED
212}
213
214pub fn is_subagent_progress_event(event_type: &str) -> bool {
216 let Some(parsed) = parse_namespace(event_type) else {
217 return false;
218 };
219 parsed.domain == "subagent" && matches!(parsed.action.as_str(), "started" | "completed")
220}
221
222#[cfg(test)]
223mod tests {
224 use super::*;
225
226 #[test]
227 fn parse_valid() {
228 let p = parse_namespace("soothe.cognition.plan.created").unwrap();
229 assert_eq!(p.domain, "cognition");
230 assert_eq!(p.component, "plan");
231 assert_eq!(p.action, "created");
232 }
233
234 #[test]
235 fn reject_internal() {
236 assert!(parse_namespace("soothe.internal.loop.completed").is_none());
237 }
238
239 #[test]
240 fn classify_quiet() {
241 assert_eq!(
242 classify_event_verbosity(EVENT_FINAL_REPORT),
243 VerbosityTier::Quiet
244 );
245 }
246}