e0a5f57793
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as a monorepo subdirectory under desktop/. Source only — node_modules, dist, Cargo target and the upstream .git history are excluded. desktop/ keeps its own independent Cargo workspace (desktop/src-tauri with crates/*); it is not part of the backend boosapi crate, so a `cargo check` at the metapi root still compiles only the backend. Build the desktop app from desktop/src-tauri per desktop/README.md. Note: app icons are still placeholder assets pending the final BoosAPI logo. The updater signing keys live outside the repo and are not included.
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
// Example 10: Permissions
|
|
//
|
|
// Read-only agent with AllowedTools restriction.
|
|
// Can only use Read, Glob, Grep — no write or execute.
|
|
//
|
|
// Run: cargo run --example 10-permissions
|
|
|
|
use open_agent_sdk::{Agent, AgentOptions, SDKMessage};
|
|
use open_agent_sdk::types;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
println!("--- Example 10: Permissions ---");
|
|
|
|
let mut agent = Agent::new(AgentOptions {
|
|
max_turns: Some(10),
|
|
allowed_tools: Some(vec![
|
|
"Read".to_string(),
|
|
"Glob".to_string(),
|
|
"Grep".to_string(),
|
|
]),
|
|
..Default::default()
|
|
})
|
|
.await
|
|
.unwrap();
|
|
|
|
let (mut rx, handle) = agent
|
|
.query("Review the code in src/lib.rs for best practices and potential improvements.")
|
|
.await;
|
|
|
|
while let Some(event) = rx.recv().await {
|
|
match event {
|
|
SDKMessage::Assistant { message, .. } => {
|
|
let text = types::extract_text(&message);
|
|
if !text.is_empty() {
|
|
print!("{}", text);
|
|
}
|
|
}
|
|
SDKMessage::Result { cost_usd, .. } => {
|
|
println!("\n\n--- Done (${:.4}) ---", cost_usd);
|
|
}
|
|
SDKMessage::Error { message } => {
|
|
eprintln!("Error: {}", message);
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
handle.await.unwrap();
|
|
agent.close().await;
|
|
}
|