feat(agentcompany-rust): scaffold native shell and runtime bridge
This commit is contained in:
1 parent
34814b4dfd
commit
2cddf89717
40 files changed
+11300
-3
No files matched your search
@@ -0,0 +1,3 @@
|
||||
pub mod service;
|
||||
|
||||
pub use service::{RuntimeConfig, RuntimeService};
|
||||
@@ -0,0 +1,51 @@
|
||||
use anyhow::Result;
|
||||
use pi_bridge::{
|
||||
ClientRequest, FollowUpRequest, PiBridgeClient, RunRequest, RuntimeEvent, RuntimeHandshake,
|
||||
SteerRequest, ToolApprovalDecision,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct RuntimeConfig {
|
||||
pub command: PathBuf,
|
||||
pub args: Vec<String>,
|
||||
pub working_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub struct RuntimeService {
|
||||
client: PiBridgeClient,
|
||||
}
|
||||
|
||||
impl RuntimeService {
|
||||
pub fn connect(config: RuntimeConfig) -> Result<Self> {
|
||||
Ok(Self {
|
||||
client: PiBridgeClient::spawn(config.command, &config.args, config.working_dir)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn handshake(&mut self, message: RuntimeHandshake) -> Result<RuntimeEvent> {
|
||||
self.client.send(&ClientRequest::Handshake(message))?;
|
||||
self.client.read_event()
|
||||
}
|
||||
|
||||
pub fn start_run(&mut self, request: RunRequest) -> Result<()> {
|
||||
self.client
|
||||
.send(&ClientRequest::StartRun(Box::new(request)))
|
||||
}
|
||||
|
||||
pub fn decide_tool_call(&mut self, decision: ToolApprovalDecision) -> Result<()> {
|
||||
self.client.send(&ClientRequest::ToolApproval(decision))
|
||||
}
|
||||
|
||||
pub fn steer(&mut self, request: SteerRequest) -> Result<()> {
|
||||
self.client.send(&ClientRequest::Steer(request))
|
||||
}
|
||||
|
||||
pub fn follow_up(&mut self, request: FollowUpRequest) -> Result<()> {
|
||||
self.client.send(&ClientRequest::FollowUp(request))
|
||||
}
|
||||
|
||||
pub fn next_event(&mut self) -> Result<RuntimeEvent> {
|
||||
self.client.read_event()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user