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_selection(
provider: Box<dyn Provider>,
model: String,
config: OpiConfig,
workspace_root: PathBuf,
tool_selection: ToolSelection,
) -> Self
pub fn new_with_selection( provider: Box<dyn Provider>, model: String, config: OpiConfig, workspace_root: PathBuf, tool_selection: ToolSelection, ) -> Self
Create a new harness with an explicit tool selection.
Sourcepub fn new_with_tool_config(
provider: Box<dyn Provider>,
model: String,
config: OpiConfig,
workspace_root: PathBuf,
tool_config: ToolRuntimeConfig,
) -> Self
pub fn new_with_tool_config( provider: Box<dyn Provider>, model: String, config: OpiConfig, workspace_root: PathBuf, tool_config: ToolRuntimeConfig, ) -> Self
Create a new harness with already resolved tool runtime config.
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>,
tool_selection: ToolSelection,
) -> 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>, tool_selection: ToolSelection, ) -> 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>,
tool_selection: ToolSelection,
) -> 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>, tool_selection: ToolSelection, ) -> Self
Create a new harness, optionally adopting an existing session (resume).
Sourcepub fn new_with_hooks_and_resume_tool_config(
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>,
tool_config: ToolRuntimeConfig,
) -> Self
pub fn new_with_hooks_and_resume_tool_config( 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>, tool_config: ToolRuntimeConfig, ) -> Self
Create a new harness, optionally adopting an existing session (resume), with already resolved tool runtime config.
Sourcepub fn new_with_global_config_dir(
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>,
tool_selection: ToolSelection,
global_config_dir: Option<PathBuf>,
) -> Self
pub fn new_with_global_config_dir( 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>, tool_selection: ToolSelection, global_config_dir: Option<PathBuf>, ) -> Self
Create a new harness with an explicit global config directory override.
When global_config_dir is None, uses the platform default from
crate::config::user_config_dir. Pass Some(path) in tests to
isolate global context file discovery from the real user config dir.
Sourcepub fn new_with_global_config_dir_tool_config(
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>,
tool_config: ToolRuntimeConfig,
global_config_dir: Option<PathBuf>,
) -> Self
pub fn new_with_global_config_dir_tool_config( 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>, tool_config: ToolRuntimeConfig, global_config_dir: Option<PathBuf>, ) -> Self
Create a new harness with an explicit global config directory override and already resolved tool runtime config.
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 fn queue_images(&mut self, images: Vec<InputContent>)
pub fn queue_images(&mut self, images: Vec<InputContent>)
Queue images to be injected into the next prompt.
Sourcepub fn take_pending_images(&mut self) -> Vec<InputContent>
pub fn take_pending_images(&mut self) -> Vec<InputContent>
Take and clear queued images.
Sourcepub fn model_picker_items(&self) -> Vec<SelectItem>
pub fn model_picker_items(&self) -> Vec<SelectItem>
Return model picker items from the active provider.
Sourcepub fn resume_session_id(&mut self, session_id: &str) -> Result<usize, String>
pub fn resume_session_id(&mut self, session_id: &str) -> Result<usize, String>
Resume an existing session by ID into this harness.
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 prompt_with_content(
&mut self,
content: Vec<InputContent>,
) -> Result<Vec<AgentMessage>, AgentError>
pub async fn prompt_with_content( &mut self, content: Vec<InputContent>, ) -> Result<Vec<AgentMessage>, AgentError>
Send a user message with arbitrary content (text + images) 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
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>
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>
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