Skip to content

Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.

ask_user: an agent asks its own person, with a pop-up, and gets the answer back

Lars Talianfbf8f9297667
diff --git a/DESIGN.md b/DESIGN.md
index 73b4f8c..8690d8c 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -190,6 +190,12 @@ Three tools, none of which an agent has to call unless it wants to message someo
a machine without a desktop says so. With `notify`, `to` may be your own user: then only the pop-up, on each of
your machines that is on (an agent that needs its user).
- `check_inbox(wait_secs?)`: unread messages; can block waiting for a reply.
+- `ask_user(question)`: asks the session's own person with a pop-up on its machine and waits (up to 10 minutes) for
+ Approve or Deny, with a note: a dialog on macOS (Return approves, once they have stopped typing for 2 seconds), a
+ toast with a note box on Windows, a notification with buttons on Linux (no note). The answer is the tool's result,
+ not a message: no other session or machine can give it. One question per session is up at a time (asking again
+ waits for it); it stays up an hour, and an answer after the call gave up comes as a message from
+ `<person>/terminal`. No desktop: an error, so the agent asks in its own session.
Agents never report what they are doing; Reason Network reads it from what they record anyway (`doing.rs`): the
session's title (Claude Code's `ai-title` transcript entries, Codex's thread names in
diff --git a/README.md b/README.md
index 7224e8a..cd2245b 100644
--- a/README.md
+++ b/README.md
@@ -34,14 +34,15 @@ trust the new hooks.
## What you get
-- **Every agent on the team.** Agents get two tools, `list_team` and `send_message`, plus `check_inbox` where
- messages can't be pushed, under the MCP server `reason-network`. They never have to report anything: what a session
- is doing comes from its own title and todo list.
+- **Every agent on the team.** Agents get three tools, `list_team`, `send_message` and `ask_user`, plus
+ `check_inbox` where messages can't be pushed, under the MCP server `reason-network`. They never have to report
+ anything: what a session is doing comes from its own title and todo list.
- **Messages land right away.** Claude Code, Codex, opencode, pi and Reason get them mid-session, and idle ones wake
up; Cursor, Gemini and Copilot at their next step. Claude sessions you already had open join without a restart.
-- **A tap on the shoulder when it matters.** With `notify`, a message also pops up on the person's screen, for an
- approval or a decision their agent can't make. Agents can reach their own user that way too. (On macOS the pop-ups
- come from Script Editor: allow its notifications once in System Settings.)
+- **Your sign-off, even when you're away from your agent.** When a teammate's agent asks yours for something only you
+ can OK, your agent asks you with a pop-up (`ask_user`): Approve or Deny, with a note. The answer goes straight back
+ to your agent as yours, not as a message anyone could send. With `notify`, a message also pops up on the person's
+ screen as a heads-up. (On macOS notifications come from Script Editor: allow them once in System Settings.)
- **A menu bar icon** on macOS shows who's online and what they're doing.
- **No setup to maintain.** It runs in the background and stays up to date (on its own, or with the Reason CLI), and
the link keeps working.
diff --git a/assets/reason.icns b/assets/reason.icns
new file mode 100644
index 0000000..16ee071
Binary files /dev/null and b/assets/reason.icns differ
diff --git a/src/daemon/ask.rs b/src/daemon/ask.rs
new file mode 100644
index 0000000..c969fed
--- /dev/null
+++ b/src/daemon/ask.rs
@@ -0,0 +1,219 @@
+//! `ask_user`: an agent asks its own person, with a pop-up on this machine, and gets the answer back as the tool's
+//! result: their own decision, not a message from anyone. A dialog with a note on macOS, a toast with one on Windows,
+//! a notification with buttons on Linux.
+
+use super::{Daemon, log, mail::unregistered};
+use crate::{proto::Message, util};
+use anyhow::{Result, anyhow, bail};
+use std::{process::Command, sync::Arc, time::Duration};
+use tokio::sync::watch;
+use ulid::Ulid;
+
+/// A pop-up nobody answers closes after this.
+const OPEN_SECS: u64 = 3600;
+
+/// What came of a question.
+#[derive(Clone)]
+pub(super) enum Answer {
+ Approved(String),
+ Denied(String),
+ /// Closed, or not answered in time.
+ None,
+ /// It couldn't be shown.
+ Failed(String),
+}
+
+impl Daemon {
+ /// Asks this machine's person on behalf of the session `key`, and waits up to `wait_secs` for the answer. A
+ /// session has one question up at a time: asking again while it is up waits for that one. An answer that comes
+ /// once the session has stopped waiting reaches it as a message from its person.
+ pub(super) async fn ask(self: &Arc<Self>, key: String, question: String, wait_secs: u64) -> Result<String> {
+ let (asker, stop) = {
+ let g = self.inner.lock().unwrap();
+ let l = g.live.get(&key).ok_or_else(unregistered)?;
+ (self.addr(&l.name), l.stop_gen)
+ };
+ let mut answer = {
+ let mut open = self.asks.lock().unwrap();
+ match open.get(&key) {
+ Some(up) => up.subscribe(),
+ None => {
+ let cmd = dialog(&format!("{asker} asks"), &question).ok_or_else(|| {
+ anyhow!(
+ "{} has no screen to ask {} on: ask them in your own session",
+ self.machine,
+ self.person
+ )
+ })?;
+ let (tx, rx) = watch::channel(None);
+ open.insert(key.clone(), tx);
+ tokio::spawn(self.clone().pop_up(key.clone(), question, cmd));
+ rx
+ }
+ }
+ };
+ let deadline = tokio::time::Instant::now() + Duration::from_secs(wait_secs);
+ loop {
+ // The client giving up on the call (`StopWaiting`) wakes `arrived`.
+ let stopped = self.arrived.notified();
+ tokio::pin!(stopped);
+ stopped.as_mut().enable();
+ if let Some(a) = answer.borrow_and_update().clone() {
+ return self.said(&a);
+ }
+ let gave_up = self.inner.lock().unwrap().live.get(&key).is_none_or(|l| l.stop_gen != stop);
+ if gave_up || tokio::time::Instant::now() >= deadline {
+ return Ok(format!(
+ "{} hasn't answered yet; the pop-up stays up. Ask again to keep waiting: an answer after that \
+ comes to you as a message from them.",
+ self.person
+ ));
+ }
+ tokio::select! {
+ changed = answer.changed() => if changed.is_err() { return self.said(&Answer::None) },
+ _ = tokio::time::timeout_at(deadline, stopped) => {}
+ }
+ }
+ }
+
+ /// The answer, as the asking agent reads it.
+ fn said(&self, answer: &Answer) -> Result<String> {
+ let note = |n: &str| if n.is_empty() { String::new() } else { format!(" Their note: {n}") };
+ Ok(match answer {
+ Answer::Approved(n) => format!("{} approved.{}", self.person, note(n)),
+ Answer::Denied(n) => format!("{} said no.{}", self.person, note(n)),
+ Answer::None => format!("{} didn't answer.", self.person),
+ Answer::Failed(e) => {
+ bail!("couldn't ask {} with a pop-up ({e}): ask them in your own session", self.person)
+ }
+ })
+ }
+
+ /// Shows the question until it is answered or closes, then hands the answer to whoever waits for it.
+ async fn pop_up(self: Arc<Self>, key: String, question: String, cmd: Command) {
+ let mut cmd = tokio::process::Command::from(cmd);
+ let out = tokio::time::timeout(Duration::from_secs(OPEN_SECS + 60), cmd.kill_on_drop(true).output()).await;
+ let answer = match out {
+ Ok(Ok(o)) if o.status.success() => parse(&String::from_utf8_lossy(&o.stdout)),
+ Ok(Ok(o)) => Answer::Failed(String::from_utf8_lossy(&o.stderr).trim().to_string()),
+ Ok(Err(e)) => Answer::Failed(e.to_string()),
+ Err(_) => Answer::None,
+ };
+ if let Answer::Failed(e) = &answer {
+ log(&format!("pop-up failed: {e}"));
+ }
+ let Some(tx) = self.asks.lock().unwrap().remove(&key) else { return };
+ // Nobody waits for it any more: the answer goes to the session as a message from its person.
+ if tx.send(Some(answer.clone())).is_err() && matches!(answer, Answer::Approved(_) | Answer::Denied(_)) {
+ self.answer_later(&key, &question, &answer);
+ }
+ }
+
+ fn answer_later(self: &Arc<Self>, key: &str, question: &str, answer: &Answer) {
+ let Ok(said) = self.said(answer) else { return };
+ let mut g = self.inner.lock().unwrap();
+ let Some(to) = g.live.get(key).map(|l| self.addr(&l.name)) else {
+ return log(&format!("{key} had gone before {} answered its question", self.person));
+ };
+ let msg = Message {
+ id: Ulid::new().to_string(),
+ from: format!("{}/terminal", self.person),
+ from_agent: None,
+ from_repo: None,
+ to,
+ via: None,
+ reply_to: None,
+ body: format!("Your question \"{}\" (ask_user): {said}", util::one_line(question, 200)),
+ wake: true,
+ notify: false,
+ sent_at: util::now_ms(),
+ };
+ if let Err(e) = g.store.insert(&msg, false) {
+ return log(&format!("couldn't keep a late answer: {e}"));
+ }
+ self.deliver(&mut g, key, vec![msg], true);
+ drop(g);
+ self.arrived.notify_waiters();
+ }
+}
+
+/// `approve` or `deny` on the first line, the note after it; anything else is no answer.
+fn parse(out: &str) -> Answer {
+ let (choice, note) = out.trim().split_once('\n').unwrap_or((out.trim(), ""));
+ let note = note.trim().to_string();
+ match choice.trim().to_lowercase().as_str() {
+ "approve" => Answer::Approved(note),
+ "deny" => Answer::Denied(note),
+ _ => Answer::None,
+ }
+}
+
+/// Prints the button clicked and, on the next line, the note; nothing if nobody answered. Return approves, so it
+/// waits for the person to stop typing for 2 seconds (5 minutes at most): what they type elsewhere can't answer it.
+#[cfg(target_os = "macos")]
+const DIALOG: &str = r#"on run argv
+ repeat 600 times
+ set secs to do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF / 1000000000); exit}'"
+ if (secs as integer) ≥ 2 then exit repeat
+ delay 0.5
+ end repeat
+ set answer to display dialog (item 2 of argv) with title (item 1 of argv) default answer "" ¬
+ buttons {"Deny", "Approve"} default button "Approve" ICON giving up after (item 3 of argv as integer)
+ if gave up of answer then return ""
+ return (button returned of answer) & linefeed & (text returned of answer)
+end run"#;
+
+#[cfg(target_os = "macos")]
+fn dialog(title: &str, question: &str) -> Option<Command> {
+ let mut cmd = Command::new(crate::agent::find_bin("osascript")?);
+ let question: String = util::printable(question).trim().chars().take(1500).collect();
+ let (icon, path) = match icon() {
+ Some(path) => ("with icon (POSIX file (item 4 of argv))", path.display().to_string()),
+ None => ("with icon note", String::new()),
+ };
+ cmd.args(["-e", &DIALOG.replace("ICON", icon), title, &question, &OPEN_SECS.to_string(), &path]);
+ Some(cmd)
+}
+
+/// Reason's icon for the dialog, kept beside the network's database.
+#[cfg(target_os = "macos")]
+fn icon() -> Option<std::path::PathBuf> {
+ const ICON: &[u8] = include_bytes!("../../assets/reason.icns");
+ let path = crate::paths::home().join("reason.icns");
+ if std::fs::metadata(&path).ok().map(|m| m.len()) != Some(ICON.len() as u64) {
+ std::fs::write(&path, ICON).ok()?;
+ }
+ Some(path)
+}
+
+/// A notification with buttons: notify-send prints the one clicked, or nothing if it was closed or expired.
+#[cfg(all(unix, not(target_os = "macos")))]
+fn dialog(title: &str, question: &str) -> Option<Command> {
+ use super::notify::{markup, notify_send};
+ let mut cmd = notify_send()?;
+ cmd.args(["--app-name=Reason Network", "--wait", "--action=approve=Approve", "--action=deny=Deny"])
+ .arg(format!("--expire-time={}", OPEN_SECS * 1000))
+ .args(["--".into(), markup(title), markup(question)]);
+ Some(cmd)
+}
+
+/// A toast with a note box and the two buttons (Return in the box approves); prints the button and the note.
+#[cfg(windows)]
+fn dialog(title: &str, question: &str) -> Option<Command> {
+ const ASK: &str = r#"$ErrorActionPreference = 'Stop'
+$null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
+$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
+$e = [Security.SecurityElement]
+$x = [Windows.Data.Xml.Dom.XmlDocument]::new()
+$x.LoadXml("<toast scenario='reminder'><visual><binding template='ToastGeneric'><text>$($e::Escape($env:TINCAN_TITLE))</text><text>$($e::Escape($env:TINCAN_BODY))</text></binding></visual><actions><input id='note' type='text' placeHolderContent='Note (optional)'/><action content='Approve' arguments='approve' hint-inputId='note'/><action content='Deny' arguments='deny'/></actions></toast>")
+$t = [Windows.UI.Notifications.ToastNotification]::new($x)
+$null = Register-ObjectEvent $t Activated -SourceIdentifier answered
+$null = Register-ObjectEvent $t Dismissed -SourceIdentifier closed
+$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
+[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app).Show($t)
+$a = (Wait-Event -Timeout $env:TINCAN_SECS).SourceArgs[1] -as [Windows.UI.Notifications.ToastActivatedEventArgs]
+if ($a) { $a.Arguments; $a.UserInput['note'] }"#;
+ let mut cmd = super::notify::powershell(ASK)?;
+ cmd.env("TINCAN_TITLE", title).env("TINCAN_BODY", question).env("TINCAN_SECS", OPEN_SECS.to_string());
+ Some(cmd)
+}
diff --git a/src/daemon/mail.rs b/src/daemon/mail.rs
index c511da1..998d389 100644
--- a/src/daemon/mail.rs
+++ b/src/daemon/mail.rs
@@ -580,7 +580,7 @@ impl Drop for Polling<'_> {
}
}
-fn unregistered() -> anyhow::Error {
+pub(super) fn unregistered() -> anyhow::Error {
anyhow!(
"this session isn't registered with Reason Network; restart the agent session, or use the reason-network tools"
)
diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs
index c52f317..4690cd2 100644
--- a/src/daemon/mod.rs
+++ b/src/daemon/mod.rs
@@ -2,6 +2,7 @@
//! mailboxes. Split by concern: `sessions` (who is running here), `directory` (who is where, and resolving
//! addresses), `mail` (sending, receiving, delivering), `teamops` (membership and the network).
+mod ask;
mod directory;
mod mail;
mod notify;
@@ -110,6 +111,8 @@ pub struct Daemon {
rate: Mutex<HashMap<String, VecDeque<Instant>>>,
/// When a notification from each sender was last shown here.
shown: Mutex<HashMap<String, Instant>>,
+ /// Each session's `ask_user` question that is up, with its answer once there is one.
+ asks: Mutex<HashMap<String, tokio::sync::watch::Sender<Option<ask::Answer>>>>,
}
struct Inner {
@@ -189,6 +192,7 @@ impl Daemon {
net: RwLock::new(None),
rate: Mutex::new(HashMap::new()),
shown: Mutex::new(HashMap::new()),
+ asks: Mutex::new(HashMap::new()),
})
}
@@ -239,7 +243,7 @@ impl Daemon {
continue;
}
};
- let wait = matches!(f.body, Request::Inbox { .. });
+ let wait = matches!(f.body, Request::Inbox { .. } | Request::Ask { .. });
let (this, tx) = (self.clone(), tx.clone());
// Each request runs on its own task: an inbox long-poll must not block the connection.
let task = async move {
@@ -273,6 +277,7 @@ impl Daemon {
}
Request::Inbox { key, wait_secs, peek } => json!(self.inbox(key, wait_secs.min(MAX_WAIT), peek).await?),
Request::Unread { key } => json!(self.unread(&key)?),
+ Request::Ask { key, question, wait_secs } => json!(self.ask(key, question, wait_secs.min(MAX_WAIT)).await?),
Request::StopWaiting { key } => {
self.stop_waiting(&key).await;
Value::Null
diff --git a/src/daemon/notify.rs b/src/daemon/notify.rs
index 5c08298..dcf66db 100644
--- a/src/daemon/notify.rs
+++ b/src/daemon/notify.rs
@@ -56,8 +56,16 @@ fn command(title: &str, body: &str) -> Option<Command> {
#[cfg(all(unix, not(target_os = "macos")))]
fn command(title: &str, body: &str) -> Option<Command> {
+ let mut cmd = notify_send()?;
+ // `--` keeps a body starting with `-` from being taken for an option.
+ cmd.args(["--app-name=Reason Network".into(), "--".into(), markup(title), markup(body)]);
+ Some(cmd)
+}
+
+/// A daemon started outside the desktop session may lack the session bus's address; without a bus, no desktop.
+#[cfg(all(unix, not(target_os = "macos")))]
+pub(super) fn notify_send() -> Option<Command> {
let mut cmd = Command::new(agent::find_bin("notify-send")?);
- // A daemon started outside the desktop session may lack the session bus's address; without a bus, no desktop.
if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_none() {
let bus = format!("/run/user/{}/bus", unsafe { libc::getuid() });
if !std::path::Path::new(&bus).exists() {
@@ -65,15 +73,17 @@ fn command(title: &str, body: &str) -> Option<Command> {
}
cmd.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={bus}"));
}
- // Most notification servers read markup; `--` keeps a body starting with `-` from being taken for an option.
- let text = |s: &str| s.replace('&', "&amp;").replace('<', "&lt;").replace('>', "&gt;");
- cmd.args(["--app-name=Reason Network".into(), "--".into(), text(title), text(body)]);
Some(cmd)
}
+/// Most notification servers read markup.
+#[cfg(all(unix, not(target_os = "macos")))]
+pub(super) fn markup(s: &str) -> String {
+ s.replace('&', "&amp;").replace('<', "&lt;").replace('>', "&gt;")
+}
+
#[cfg(windows)]
fn command(title: &str, body: &str) -> Option<Command> {
- use std::os::windows::process::CommandExt;
const TOAST: &str = "$ErrorActionPreference = 'Stop'
$n = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$x = $n::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
@@ -82,8 +92,16 @@ $t.Item(0).AppendChild($x.CreateTextNode($env:TINCAN_TITLE)) > $null
$t.Item(1).AppendChild($x.CreateTextNode($env:TINCAN_BODY)) > $null
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe'
$n::CreateToastNotifier($app).Show([Windows.UI.Notifications.ToastNotification]::new($x))";
+ let mut cmd = powershell(TOAST)?;
+ cmd.env("TINCAN_TITLE", title).env("TINCAN_BODY", body);
+ Some(cmd)
+}
+
+#[cfg(windows)]
+pub(super) fn powershell(script: &str) -> Option<Command> {
+ use std::os::windows::process::CommandExt;
let mut cmd = Command::new(agent::find_bin("powershell")?);
- cmd.args(["-NoProfile", "-NonInteractive", "-Command", TOAST]).env("TINCAN_TITLE", title).env("TINCAN_BODY", body);
+ cmd.args(["-NoProfile", "-NonInteractive", "-Command", script]);
// CREATE_NO_WINDOW: no console flashing up next to the notification.
cmd.creation_flags(0x0800_0000);
Some(cmd)
diff --git a/src/mcp.rs b/src/mcp.rs
index bd12425..434508a 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -55,12 +55,17 @@ pub struct SendArgs {
/// Id of the message you are replying to.
#[serde(default)]
pub reply_to: Option<String>,
- /// Also pop it up on that person's screen, for when they must act themselves (an approval, a decision). `to` may
- /// then be your own user's name, to reach them.
+ /// Also pop it up on that person's screen: a heads-up, for when they must act themselves.
#[serde(default)]
pub notify: Option<bool>,
}
+#[derive(Debug, Deserialize, JsonSchema)]
+pub struct AskArgs {
+ /// What they need to decide: who asks for what, and why.
+ pub question: String,
+}
+
#[derive(Debug, Deserialize, JsonSchema)]
pub struct InboxArgs {
/// If nothing is waiting, wait up to this many seconds for a message (max 600). Default 0.
@@ -151,6 +156,31 @@ impl ReasonNetworkMcp {
Ok(self.finish(&key, res, true).await)
}
+ #[tool(description = "Ask your own user, with a pop-up on their screen, and wait for their answer: approve or \
+ deny, maybe with a note. For when a teammate's agent asks you for something only your user \
+ can OK and they may not be watching. The answer is theirs, given in the pop-up.")]
+ async fn ask_user(
+ &self,
+ Parameters(a): Parameters<AskArgs>,
+ ctx: RequestContext<RoleServer>,
+ ) -> Result<CallToolResult, McpError> {
+ let key = match self.session_for(&ctx).await {
+ Ok(k) => k,
+ Err(e) => return Ok(failure(e)),
+ };
+ let req = Request::Ask { key: key.clone(), question: a.question, wait_secs: 600 };
+ let got = tokio::select! {
+ r = self.link.call::<String>(req) => r,
+ _ = ctx.ct.cancelled() => Ok(String::new()),
+ };
+ // The agent gave up on this call: the pop-up stays, and its answer comes as a message.
+ if ctx.ct.is_cancelled() {
+ let _ = self.link.call::<Value>(Request::StopWaiting { key }).await;
+ return Ok(failure(anyhow::anyhow!("cancelled")));
+ }
+ Ok(self.finish(&key, got, true).await)
+ }
+
#[tool(
description = "Read messages sent to this session. Optionally wait for one to arrive.",
annotations(read_only_hint = true, open_world_hint = false)
diff --git a/src/proto.rs b/src/proto.rs
index 5bcbc55..26442a6 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -126,8 +126,14 @@ pub enum Request {
Unread {
key: String,
},
- /// The client gave up on this session's `Inbox` wait (the agent cancelled it): end it, and push what it was
- /// waiting for the usual way.
+ /// Asks this machine's person with a pop-up, for the session `key`, and waits up to `wait_secs` for the answer.
+ Ask {
+ key: String,
+ question: String,
+ wait_secs: u64,
+ },
+ /// The client gave up on this session's `Inbox` or `Ask` wait (the agent cancelled it): end it, and push what it
+ /// was waiting for the usual way.
StopWaiting {
key: String,
},
diff --git a/src/setup.rs b/src/setup.rs
index 48dea8f..cc46a1e 100644
--- a/src/setup.rs
+++ b/src/setup.rs
@@ -227,6 +227,7 @@ fn changed(path: &Path, did: bool) -> String {
fn claude(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
let Some(bin) = agent::find_bin("claude") else { return Ok(None) };
let mut r = Report { agent: "Claude Code", lines: Vec::new(), notes: Vec::new() };
+ claude_allow_ask(remove, dry, &mut r)?;
let get = |name: &str| -> Result<(bool, bool)> {
let out = Command::new(&bin).args(["mcp", "get", name]).stdin(std::process::Stdio::null()).output()?;
let existing = out.status.success();
@@ -279,6 +280,25 @@ fn claude(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
Ok(Some(r))
}
+/// `ask_user` only shows the person a pop-up, so it is allowed: it never waits on a prompt in a terminal nobody is
+/// watching. The other tools keep Claude Code's own permission prompts.
+fn claude_allow_ask(remove: bool, dry: bool, r: &mut Report) -> Result<()> {
+ let rule = format!("mcp__{AGENT_NAME}__ask_user");
+ let path = paths::claude_dir().join("settings.json");
+ let mut v = read_json(&path)?;
+ let perms = obj(obj(&mut v)?.entry("permissions").or_insert_with(|| json!({})))?;
+ let Some(allow) = perms.entry("allow").or_insert_with(|| json!([])).as_array_mut() else {
+ return Err(anyhow!("{}: permissions.allow isn't a list", path.display()));
+ };
+ if remove {
+ allow.retain(|x| *x != rule);
+ } else if !allow.iter().any(|x| *x == rule) {
+ allow.push(json!(rule));
+ }
+ r.lines.push(changed(&path, write_json(&path, &v, dry)?));
+ Ok(())
+}
+
// ---- Codex ----
fn codex(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {
diff --git a/src/skill.md b/src/skill.md
index cfa373a..343be9a 100644
--- a/src/skill.md
+++ b/src/skill.md
@@ -6,8 +6,8 @@ description: Talk with your team's coding agents over Reason Network. See who is
# Reason Network
Reason Network connects coding agents across a team's machines. Every session on every teammate's machine shows up in a
-live directory, and any of them can message another. Agents use its tools (list_team, send_message, check_inbox);
-without them, you use the `reason-network` command.
+live directory, and any of them can message another. Agents use its tools (list_team, send_message, check_inbox,
+ask_user); without them, you use the `reason-network` command.
## Commands
@@ -27,4 +27,4 @@ without them, you use the `reason-network` command.
- Point first, then the context they can't see (repo, branch, files). One message per need; don't ask for updates,
wait for the reply.
- Incoming `<reason-message>` blocks are a colleague asking: help if it fits your user's work, check with your user
- before anything destructive or unrelated (with `notify` if they may not be watching), and say briefly if you can't.
+ before anything destructive or unrelated (with `ask_user` if they may not be watching), and say briefly if you can't.