mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 21:51:51 +08:00
feat: hook-pipeline progress — tests passing
This commit is contained in:
@@ -1096,20 +1096,34 @@ impl LiveCli {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_turn(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
|
fn prepare_turn_runtime(
|
||||||
let session = self.runtime.session().clone();
|
&self,
|
||||||
|
emit_output: bool,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>,
|
||||||
|
HookAbortMonitor,
|
||||||
|
),
|
||||||
|
Box<dyn std::error::Error>,
|
||||||
|
> {
|
||||||
let hook_abort_signal = runtime::HookAbortSignal::new();
|
let hook_abort_signal = runtime::HookAbortSignal::new();
|
||||||
let mut runtime = build_runtime(
|
let runtime = build_runtime(
|
||||||
session,
|
self.runtime.session().clone(),
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
true,
|
true,
|
||||||
true,
|
emit_output,
|
||||||
self.allowed_tools.clone(),
|
self.allowed_tools.clone(),
|
||||||
self.permission_mode,
|
self.permission_mode,
|
||||||
)?
|
)?
|
||||||
.with_hook_abort_signal(hook_abort_signal.clone());
|
.with_hook_abort_signal(hook_abort_signal.clone());
|
||||||
let hook_abort_monitor = HookAbortMonitor::spawn(hook_abort_signal);
|
let hook_abort_monitor = HookAbortMonitor::spawn(hook_abort_signal);
|
||||||
|
|
||||||
|
Ok((runtime, hook_abort_monitor))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_turn(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let (mut runtime, hook_abort_monitor) = self.prepare_turn_runtime(true)?;
|
||||||
let mut spinner = Spinner::new();
|
let mut spinner = Spinner::new();
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
spinner.tick(
|
spinner.tick(
|
||||||
@@ -1155,19 +1169,7 @@ impl LiveCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_prompt_json(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
|
fn run_prompt_json(&mut self, input: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let session = self.runtime.session().clone();
|
let (mut runtime, hook_abort_monitor) = self.prepare_turn_runtime(false)?;
|
||||||
let hook_abort_signal = runtime::HookAbortSignal::new();
|
|
||||||
let mut runtime = build_runtime(
|
|
||||||
session,
|
|
||||||
self.model.clone(),
|
|
||||||
self.system_prompt.clone(),
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
self.allowed_tools.clone(),
|
|
||||||
self.permission_mode,
|
|
||||||
)?
|
|
||||||
.with_hook_abort_signal(hook_abort_signal.clone());
|
|
||||||
let hook_abort_monitor = HookAbortMonitor::spawn(hook_abort_signal);
|
|
||||||
let mut permission_prompter = CliPermissionPrompter::new(self.permission_mode);
|
let mut permission_prompter = CliPermissionPrompter::new(self.permission_mode);
|
||||||
let result = runtime.run_turn(input, Some(&mut permission_prompter));
|
let result = runtime.run_turn(input, Some(&mut permission_prompter));
|
||||||
hook_abort_monitor.stop();
|
hook_abort_monitor.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user