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

Function add_hook_to_groups

atomic-agent/src/hooks/codex.rs:494–524  ·  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

492}
493
494fn add_hook_to_groups(
495 groups: &mut Vec<Value>,
496 command: &str,
497 status_message: Option<&str>,
498 timeout_sec: Option<u64>,
499) -> bool {
500 if groups.iter().any(|group| group_has_command(group, command)) {
501 return false;
502 }
503
504 let mut entry = Map::new();
505 entry.insert("type".to_string(), Value::String("command".to_string()));
506 entry.insert("command".to_string(), Value::String(command.to_string()));
507 if let Some(message) = status_message {
508 entry.insert(
509 "statusMessage".to_string(),
510 Value::String(message.to_string()),
511 );
512 }
513 if let Some(timeout) = timeout_sec {
514 entry.insert("timeout".to_string(), Value::Number(timeout.into()));
515 }
516
517 let mut group = Map::new();
518 group.insert(
519 "hooks".to_string(),
520 Value::Array(vec![Value::Object(entry)]),
521 );
522 groups.push(Value::Object(group));
523 true
524}
525
526fn group_has_command(group: &Value, command: &str) -> bool {
527 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