aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
48
akode-rs/ext/guardian-reviewer/src/planned_action.rs
Normal file
48
akode-rs/ext/guardian-reviewer/src/planned_action.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
//! Assembles the existing planned-action evidence for synchronous Guardian prompts.
|
||||
//! The host supplies the resolved reason; action kinds and description bounds stay unchanged.
|
||||
|
||||
use crate::GuardianApprovalRequest;
|
||||
use crate::format_guardian_action_pretty;
|
||||
use akode_guardian_context::GuardianToolDescriptions;
|
||||
use akode_guardian_context::PlannedAction;
|
||||
use akode_guardian_context::PlannedActionKind;
|
||||
|
||||
pub fn build_guardian_planned_action(
|
||||
request: &GuardianApprovalRequest,
|
||||
reason: Option<String>,
|
||||
) -> serde_json::Result<PlannedAction> {
|
||||
Ok(PlannedAction {
|
||||
tool_descriptions: if let GuardianApprovalRequest::McpToolCall {
|
||||
tool_description,
|
||||
connector_description,
|
||||
..
|
||||
} = request
|
||||
{
|
||||
GuardianToolDescriptions::new(
|
||||
tool_description.as_deref(),
|
||||
connector_description.as_deref(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
kind: match request {
|
||||
GuardianApprovalRequest::NativeToolCall { call, .. } => {
|
||||
PlannedActionKind::ToolCall(call.clone())
|
||||
}
|
||||
GuardianApprovalRequest::NetworkAccess { trigger, .. } => PlannedActionKind::Network {
|
||||
json: format_guardian_action_pretty(request)?,
|
||||
has_trigger: trigger.is_some(),
|
||||
},
|
||||
GuardianApprovalRequest::WriteStdin { .. } => PlannedActionKind::TerminalInput {
|
||||
json: format_guardian_action_pretty(request)?,
|
||||
},
|
||||
GuardianApprovalRequest::ExecCommand { .. }
|
||||
| GuardianApprovalRequest::ApplyPatch { .. }
|
||||
| GuardianApprovalRequest::McpToolCall { .. }
|
||||
| GuardianApprovalRequest::RequestPermissions { .. } => PlannedActionKind::Command {
|
||||
json: format_guardian_action_pretty(request)?,
|
||||
},
|
||||
},
|
||||
reason,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user