MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / add_hook_to_groups

Function add_hook_to_groups

atomic-agent/src/hooks/codex.rs:480–510  ·  view source on GitHub ↗
(
    groups: &mut Vec<Value>,
    command: &str,
    status_message: Option<&str>,
    timeout_sec: Option<u64>,
)

Source from the content-addressed store, hash-verified

478}
479
480fn add_hook_to_groups(
481 groups: &mut Vec<Value>,
482 command: &str,
483 status_message: Option<&str>,
484 timeout_sec: Option<u64>,
485) -> bool {
486 if groups.iter().any(|group| group_has_command(group, command)) {
487 return false;
488 }
489
490 let mut entry = Map::new();
491 entry.insert("type".to_string(), Value::String("command".to_string()));
492 entry.insert("command".to_string(), Value::String(command.to_string()));
493 if let Some(message) = status_message {
494 entry.insert(
495 "statusMessage".to_string(),
496 Value::String(message.to_string()),
497 );
498 }
499 if let Some(timeout) = timeout_sec {
500 entry.insert("timeout".to_string(), Value::Number(timeout.into()));
501 }
502
503 let mut group = Map::new();
504 group.insert(
505 "hooks".to_string(),
506 Value::Array(vec![Value::Object(entry)]),
507 );
508 groups.push(Value::Object(group));
509 true
510}
511
512fn group_has_command(group: &Value, command: &str) -> bool {
513 group

Callers 2

add_hookFunction · 0.85

Calls 4

group_has_commandFunction · 0.85
iterMethod · 0.45
insertMethod · 0.45
pushMethod · 0.45

Tested by 1