use super::*;
impl SessionRegistry {
#[allow(clippy::too_many_arguments)]
pub fn record_permission_requested(
&self,
id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
tool: &str,
subject: &str,
rule: &str,
) -> Result<(), RpcError> {
self.ensure_exists(id)?;
self.record(
id,
Event::PermissionRequested {
session_id: id.to_string(),
request_id: request_id.to_string(),
agent: agent.to_string(),
agent_id: agent_id.to_string(),
tool: tool.to_string(),
subject: subject.to_string(),
rule: rule.to_string(),
},
);
Ok(())
}
pub fn record_permission_resolved(
&self,
id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
decision: &str,
source: &str,
) -> Result<(), RpcError> {
self.ensure_exists(id)?;
self.record(
id,
Event::PermissionResolved {
session_id: id.to_string(),
request_id: request_id.to_string(),
agent: agent.to_string(),
agent_id: agent_id.to_string(),
decision: decision.to_string(),
source: source.to_string(),
},
);
Ok(())
}
}
impl crate::permissions::PermissionEvents for SessionRegistry {
fn permission_requested(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
tool: &str,
subject: &str,
rule: &str,
) {
if let Err(e) = self.record_permission_requested(
session_id, request_id, agent, agent_id, tool, subject, rule,
) {
tracing::debug!(session_id = %session_id, "record_permission_requested skipped: {e}");
}
}
fn permission_resolved(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
decision: &str,
source: &str,
) {
if let Err(e) = self
.record_permission_resolved(session_id, request_id, agent, agent_id, decision, source)
{
tracing::debug!(session_id = %session_id, "record_permission_resolved skipped: {e}");
}
}
fn prompter_attached(&self, session_id: &str) -> bool {
self.prompter_count(session_id) > 0
}
}