pub struct Interpreter { /* private fields */ }Expand description
The Patchwork interpreter.
Executes Patchwork code synchronously. Think blocks block on channel operations waiting for LLM responses from the agent.
Implementations§
Source§impl Interpreter
impl Interpreter
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new interpreter without an agent.
Think blocks will return placeholder values instead of blocking on LLM.
Sourcepub fn with_agent(agent: AgentHandle) -> Self
pub fn with_agent(agent: AgentHandle) -> Self
Create a new interpreter with an agent handle.
Think blocks will block on the agent channel waiting for LLM responses.
Sourcepub fn with_working_dir_and_agent(
working_dir: PathBuf,
agent: AgentHandle,
) -> Self
pub fn with_working_dir_and_agent( working_dir: PathBuf, agent: AgentHandle, ) -> Self
Create a new interpreter with a specific working directory and agent.
Sourcepub fn with_working_dir(working_dir: PathBuf) -> Self
pub fn with_working_dir(working_dir: PathBuf) -> Self
Create a new interpreter with a specific working directory.
Sourcepub fn runtime_mut(&mut self) -> &mut Runtime
pub fn runtime_mut(&mut self) -> &mut Runtime
Get a mutable reference to the runtime.
Sourcepub fn agent(&self) -> Option<&AgentHandle>
pub fn agent(&self) -> Option<&AgentHandle>
Get a reference to the agent handle, if present.
Sourcepub fn set_print_sink(&mut self, sink: PrintSink)
pub fn set_print_sink(&mut self, sink: PrintSink)
Set a print sink for redirecting print() output.
When set, all print() calls will send to this channel instead of stdout.
Sourcepub fn eval(&mut self, code: &str) -> Result<Value>
pub fn eval(&mut self, code: &str) -> Result<Value>
Evaluate Patchwork code.
Parses and executes the code, returning the final value or an error.
For ACP usage, code starting with { is wrapped in a skill for execution.