Replace openrouter-rs with in-tree client and require sandbox
Remove the openrouter-rs dependency in favor of a minimal in-tree OpenRouter chat-completions client, and drop the BOT_NAME and SANDBOX_ENABLED config options. Reviews now always run inside the sandbox, and the review prompt asks the model to read files with the available tools instead of embedding the diff.
This commit is contained in:
@@ -6,15 +6,11 @@
|
||||
//! exhausted.
|
||||
|
||||
use anyhow::Context;
|
||||
use openrouter_rs::{
|
||||
Message,
|
||||
types::{Role, Tool, ToolCall},
|
||||
};
|
||||
use serde_json::Value;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::{
|
||||
open_router::OpenRouterClient,
|
||||
open_router::{Message, OpenRouterClient, Role, Tool, ToolCall},
|
||||
sandbox::{Sandbox, tools},
|
||||
};
|
||||
|
||||
@@ -105,10 +101,22 @@ fn parse_args(call: &ToolCall) -> anyhow::Result<Value> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
/// Builds a tool call the way the API returns one, so the fixture also
|
||||
/// covers deserialization.
|
||||
fn tool_call(name: &str, arguments: &str) -> ToolCall {
|
||||
serde_json::from_value(json!({
|
||||
"id": "call_1",
|
||||
"type": "function",
|
||||
"function": { "name": name, "arguments": arguments }
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_args_accepts_empty_arguments() {
|
||||
let call = ToolCall::new("id", "ls", "");
|
||||
let call = tool_call("ls", "");
|
||||
assert_eq!(
|
||||
parse_args(&call).unwrap(),
|
||||
Value::Object(serde_json::Map::new())
|
||||
@@ -117,13 +125,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_args_parses_json_object() {
|
||||
let call = ToolCall::new("id", "ls", r#"{"path":"src"}"#);
|
||||
let call = tool_call("ls", r#"{"path":"src"}"#);
|
||||
assert_eq!(parse_args(&call).unwrap()["path"], "src");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_args_rejects_invalid_json() {
|
||||
let call = ToolCall::new("id", "ls", "not json");
|
||||
let call = tool_call("ls", "not json");
|
||||
assert!(parse_args(&call).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user