pub struct CodingHarness { /* private fields */ }Expand description
Harness wiring config, tools, system prompt, hooks, and Agent.
Implementations§
Source§impl CodingHarness
impl CodingHarness
Sourcepub fn new(
provider: Box<dyn Provider>,
model: String,
config: OpiConfig,
workspace_root: PathBuf,
) -> Self
pub fn new( provider: Box<dyn Provider>, model: String, config: OpiConfig, workspace_root: PathBuf, ) -> Self
Create a new harness with the given provider, model, config, and workspace root.
Sourcepub fn new_with_hooks(
provider: Box<dyn Provider>,
model: String,
config: OpiConfig,
workspace_root: PathBuf,
hooks: Box<dyn AgentHooks>,
user_system_prompt: Option<String>,
initial_messages: Vec<AgentMessage>,
) -> Self
pub fn new_with_hooks( provider: Box<dyn Provider>, model: String, config: OpiConfig, workspace_root: PathBuf, hooks: Box<dyn AgentHooks>, user_system_prompt: Option<String>, initial_messages: Vec<AgentMessage>, ) -> Self
Create a new harness with custom hooks.
Sourcepub fn new_with_hooks_and_resume(
provider: Box<dyn Provider>,
model: String,
config: OpiConfig,
workspace_root: PathBuf,
hooks: Box<dyn AgentHooks>,
user_system_prompt: Option<String>,
initial_messages: Vec<AgentMessage>,
resume: Option<ResumeInfo>,
) -> Self
pub fn new_with_hooks_and_resume( provider: Box<dyn Provider>, model: String, config: OpiConfig, workspace_root: PathBuf, hooks: Box<dyn AgentHooks>, user_system_prompt: Option<String>, initial_messages: Vec<AgentMessage>, resume: Option<ResumeInfo>, ) -> Self
Create a new harness, optionally adopting an existing session (resume).
Sourcepub fn add_tool(&mut self, tool: Box<dyn Tool>)
pub fn add_tool(&mut self, tool: Box<dyn Tool>)
Add an extra tool to the harness (for testing with mock tools).
Sourcepub async fn prompt(
&mut self,
text: &str,
) -> Result<Vec<AgentMessage>, AgentError>
pub async fn prompt( &mut self, text: &str, ) -> Result<Vec<AgentMessage>, AgentError>
Send a user prompt and run the agent loop.
Sourcepub async fn continue_(
&mut self,
text: &str,
) -> Result<Vec<AgentMessage>, AgentError>
pub async fn continue_( &mut self, text: &str, ) -> Result<Vec<AgentMessage>, AgentError>
Continue the conversation with an additional message.
Sourcepub fn subscribe(&mut self, callback: Box<dyn Fn(&AgentEvent) + Send + Sync>)
pub fn subscribe(&mut self, callback: Box<dyn Fn(&AgentEvent) + Send + Sync>)
Register an event subscriber.
Sourcepub fn system_prompt(&self) -> &str
pub fn system_prompt(&self) -> &str
Return the assembled system prompt (for testing).
Sourcepub fn cancel_token(&self) -> CancellationToken
pub fn cancel_token(&self) -> CancellationToken
Return a clonable cancellation token for external cancellation.
Sourcepub fn session(&self) -> Option<&SessionCoordinator>
pub fn session(&self) -> Option<&SessionCoordinator>
Return the session coordinator, if active.
Auto Trait Implementations§
impl Freeze for CodingHarness
impl !RefUnwindSafe for CodingHarness
impl Send for CodingHarness
impl Sync for CodingHarness
impl Unpin for CodingHarness
impl UnsafeUnpin for CodingHarness
impl !UnwindSafe for CodingHarness
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more