mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 23:01:52 +08:00
fix: resolve thinking/streaming/update merge conflicts
This commit is contained in:
@@ -1271,6 +1271,7 @@ fn run_resume_command(
|
|||||||
| SlashCommand::Model { .. }
|
| SlashCommand::Model { .. }
|
||||||
| SlashCommand::Permissions { .. }
|
| SlashCommand::Permissions { .. }
|
||||||
| SlashCommand::Session { .. }
|
| SlashCommand::Session { .. }
|
||||||
|
| SlashCommand::Thinking { .. }
|
||||||
| SlashCommand::Unknown(_) => Err("unsupported resumed slash command".into()),
|
| SlashCommand::Unknown(_) => Err("unsupported resumed slash command".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1438,6 +1439,7 @@ impl LiveCli {
|
|||||||
tools: None,
|
tools: None,
|
||||||
tool_choice: None,
|
tool_choice: None,
|
||||||
stream: false,
|
stream: false,
|
||||||
|
thinking: None,
|
||||||
};
|
};
|
||||||
let runtime = tokio::runtime::Runtime::new()?;
|
let runtime = tokio::runtime::Runtime::new()?;
|
||||||
let response = runtime.block_on(client.send_message(&request))?;
|
let response = runtime.block_on(client.send_message(&request))?;
|
||||||
@@ -1446,7 +1448,7 @@ impl LiveCli {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter_map(|block| match block {
|
.filter_map(|block| match block {
|
||||||
OutputContentBlock::Text { text } => Some(text.as_str()),
|
OutputContentBlock::Text { text } => Some(text.as_str()),
|
||||||
OutputContentBlock::ToolUse { .. } => None,
|
OutputContentBlock::ToolUse { .. } | OutputContentBlock::Thinking { .. } => None,
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("");
|
.join("");
|
||||||
@@ -1518,6 +1520,10 @@ impl LiveCli {
|
|||||||
SlashCommand::Session { action, target } => {
|
SlashCommand::Session { action, target } => {
|
||||||
self.handle_session_command(action.as_deref(), target.as_deref())?
|
self.handle_session_command(action.as_deref(), target.as_deref())?
|
||||||
}
|
}
|
||||||
|
SlashCommand::Thinking { .. } => {
|
||||||
|
println!("Thinking mode toggled.");
|
||||||
|
false
|
||||||
|
}
|
||||||
SlashCommand::Unknown(name) => {
|
SlashCommand::Unknown(name) => {
|
||||||
eprintln!("unknown slash command: /{name}");
|
eprintln!("unknown slash command: /{name}");
|
||||||
false
|
false
|
||||||
@@ -2235,6 +2241,11 @@ fn render_export_text(session: &Session) -> String {
|
|||||||
"[tool_result id={tool_use_id} name={tool_name} error={is_error}] {output}"
|
"[tool_result id={tool_use_id} name={tool_name} error={is_error}] {output}"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
ContentBlock::Thinking { text: thinking, .. } => {
|
||||||
|
if !thinking.is_empty() {
|
||||||
|
lines.push(format!("[thinking] {thinking}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lines.push(String::new());
|
lines.push(String::new());
|
||||||
@@ -2423,6 +2434,7 @@ impl ApiClient for AnthropicRuntimeClient {
|
|||||||
}),
|
}),
|
||||||
tool_choice: self.enable_tools.then_some(ToolChoice::Auto),
|
tool_choice: self.enable_tools.then_some(ToolChoice::Auto),
|
||||||
stream: true,
|
stream: true,
|
||||||
|
thinking: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.runtime.block_on(async {
|
self.runtime.block_on(async {
|
||||||
@@ -2469,6 +2481,8 @@ impl ApiClient for AnthropicRuntimeClient {
|
|||||||
input.push_str(&partial_json);
|
input.push_str(&partial_json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ContentBlockDelta::ThinkingDelta { .. }
|
||||||
|
| ContentBlockDelta::SignatureDelta { .. } => {}
|
||||||
},
|
},
|
||||||
ApiStreamEvent::ContentBlockStop(_) => {
|
ApiStreamEvent::ContentBlockStop(_) => {
|
||||||
if let Some((id, name, input)) = pending_tool.take() {
|
if let Some((id, name, input)) = pending_tool.take() {
|
||||||
@@ -2602,6 +2616,7 @@ fn push_output_block(
|
|||||||
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
||||||
*pending_tool = Some((id, name, input.to_string()));
|
*pending_tool = Some((id, name, input.to_string()));
|
||||||
}
|
}
|
||||||
|
OutputContentBlock::Thinking { .. } => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -2719,6 +2734,7 @@ fn convert_messages(messages: &[ConversationMessage]) -> Vec<InputMessage> {
|
|||||||
}],
|
}],
|
||||||
is_error: *is_error,
|
is_error: *is_error,
|
||||||
},
|
},
|
||||||
|
ContentBlock::Thinking { .. } => InputContentBlock::Text { text: String::new() },
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
(!content.is_empty()).then(|| InputMessage {
|
(!content.is_empty()).then(|| InputMessage {
|
||||||
|
|||||||
@@ -1666,6 +1666,7 @@ impl ApiClient for AnthropicAgentApiClient {
|
|||||||
tools: Some(agent_tool_definitions()),
|
tools: Some(agent_tool_definitions()),
|
||||||
tool_choice: Some(ToolChoice::Auto),
|
tool_choice: Some(ToolChoice::Auto),
|
||||||
stream: true,
|
stream: true,
|
||||||
|
thinking: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.runtime.block_on(async {
|
self.runtime.block_on(async {
|
||||||
@@ -1709,6 +1710,8 @@ impl ApiClient for AnthropicAgentApiClient {
|
|||||||
input.push_str(&partial_json);
|
input.push_str(&partial_json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ContentBlockDelta::ThinkingDelta { .. }
|
||||||
|
| ContentBlockDelta::SignatureDelta { .. } => {}
|
||||||
},
|
},
|
||||||
ApiStreamEvent::ContentBlockStop(_) => {
|
ApiStreamEvent::ContentBlockStop(_) => {
|
||||||
if let Some((id, name, input)) = pending_tool.take() {
|
if let Some((id, name, input)) = pending_tool.take() {
|
||||||
@@ -1792,6 +1795,7 @@ fn convert_agent_messages(messages: &[ConversationMessage]) -> Vec<InputMessage>
|
|||||||
}],
|
}],
|
||||||
is_error: *is_error,
|
is_error: *is_error,
|
||||||
},
|
},
|
||||||
|
ContentBlock::Thinking { .. } => InputContentBlock::Text { text: String::new() },
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
(!content.is_empty()).then(|| InputMessage {
|
(!content.is_empty()).then(|| InputMessage {
|
||||||
@@ -1829,6 +1833,7 @@ fn push_agent_output_block(
|
|||||||
OutputContentBlock::ToolUse { id, name, input } => {
|
OutputContentBlock::ToolUse { id, name, input } => {
|
||||||
*pending_tool = Some((id, name, input.to_string()));
|
*pending_tool = Some((id, name, input.to_string()));
|
||||||
}
|
}
|
||||||
|
OutputContentBlock::Thinking { .. } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user