1use aios_core::governance::{ActionAdapter, AuthorizedAction};
19use aios_spec::governance::{ActionOutcome, AdapterError};
20use aios_spec::intent::ActionType;
21
22pub mod android_adapter;
23pub mod offline_adapter;
24pub use android_adapter::{AndroidAdapter, AndroidBridgeConfig};
25pub use offline_adapter::OfflineAdapter;
26
27pub struct DefaultActionExecutor;
34
35impl DefaultActionExecutor {
36 pub fn new() -> Self {
37 Self
38 }
39}
40
41impl Default for DefaultActionExecutor {
42 fn default() -> Self {
43 Self::new()
44 }
45}
46
47impl ActionAdapter for DefaultActionExecutor {
48 fn name(&self) -> &'static str {
49 "default"
50 }
51
52 fn execute(&self, authorized: &AuthorizedAction) -> Result<ActionOutcome, AdapterError> {
53 let action = authorized.action();
54 let action_name = format!("{:?}", action.action_type);
55
56 let summary = match action.action_type {
57 ActionType::PreWarmProcess => match action.target.as_deref() {
58 Some(target) => {
59 tracing::info!(
60 target = %target,
61 urgency = ?action.urgency,
62 "PreWarmProcess: stub (third-party prewarm is not implemented)"
63 );
64 "stub_prewarm".to_string()
65 },
66 None => {
67 return Err(AdapterError::ExecutionError(
68 "PreWarmProcess requires a target app".into(),
69 ));
70 },
71 },
72 ActionType::PrefetchFile => {
73 tracing::info!(
74 target = ?action.target,
75 urgency = ?action.urgency,
76 "PrefetchFile: stub (local desktop fallback)"
77 );
78 "stub_prefetch".to_string()
79 },
80 ActionType::KeepAlive => {
81 if let Some(ref target) = action.target {
82 tracing::info!(
83 target = %target,
84 urgency = ?action.urgency,
85 "KeepAlive: stub (Android-safe keepalive not wired here)"
86 );
87 format!("stub_keepalive:{target}")
88 } else {
89 tracing::info!("KeepAlive: no target specified, skipping");
90 "stub_keepalive:system".to_string()
91 }
92 },
93 ActionType::ReleaseMemory => {
94 tracing::info!(
95 target = ?action.target,
96 urgency = ?action.urgency,
97 "ReleaseMemory: stub (Android-safe release not wired here)"
98 );
99 "stub_release_memory".to_string()
100 },
101 ActionType::NoOp => {
102 tracing::debug!("NoOp executed");
103 "noop".to_string()
104 },
105 };
106
107 Ok(ActionOutcome {
108 action_type: action_name,
109 target: action.target.clone(),
110 summary,
111 latency_us: 0,
112 })
113 }
114}