This commit is contained in:
Alex Emmet 2026-06-17 22:18:37 +02:00
commit c325a7bc4f
3 changed files with 70 additions and 2 deletions

View file

@ -28,8 +28,9 @@ pub use project::{Project, ProjectFile, ProjectId, ProjectSettings};
pub use task::{Task, TaskResult};
pub use todo::{Dependency, ToDo};
pub use tools::{
format_tool_error, format_tool_result, parse_tool_call_blocks, parse_tool_call_stream,
tool_definitions, CompositionStep, ExecutionContext, MarketplaceSearchResults, ParsedToolCall,
format_tool_error, format_tools_json, format_tool_result, parse_tool_call_blocks,
parse_tool_call_stream, tool_definitions, tool_ids_for_agent_type, CompositionStep,
ExecutionContext, MarketplaceSearchResults, ParsedToolCall,
TestAction, ToolComposition, ToolDefinition, ToolDependency, ToolDocumentation, ToolExample,
ToolListing, ToolParser, ToolPlugin, ToolTest, ToolTestResult, ToolTestSuite,
ToolTestSuiteResult, ToolVersion,

View file

@ -174,6 +174,15 @@ pub struct FileRange {
pub line_end: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectorConfig {
pub api_key: String,
pub base_url: String,
pub model: String,
pub max_tokens: Option<i32>,
pub temperature: Option<f32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentTaskSpec {
pub task_id: Uuid,
@ -196,6 +205,10 @@ pub struct AgentTaskSpec {
pub suggested_test_files: Vec<String>,
#[serde(default)]
pub project_id: Option<Uuid>,
#[serde(default)]
pub connector_config: Option<ConnectorConfig>,
#[serde(default)]
pub tools_json: Option<String>,
}
impl AgentTaskSpec {
@ -224,6 +237,8 @@ impl AgentTaskSpec {
agent_type: None,
suggested_test_files: Vec::new(),
project_id: None,
connector_config: None,
tools_json: None,
}
}
}

View file

@ -1534,6 +1534,58 @@ pub fn tool_definitions() -> Vec<ToolDefinition> {
]
}
/// Returns the tool IDs appropriate for a given agent type.
/// Used by the dispatcher to embed tool definitions in task specs.
pub fn tool_ids_for_agent_type(agent_type: &crate::agents::AgentType) -> Option<Vec<&'static str>> {
Some(match agent_type {
crate::agents::AgentType::BuildAgent => vec![
"read_file", "write_file", "edit_file", "list_directory", "search_files",
"bash", "cargo_check", "npm_build", "python_check", "test_runner",
"create_workspace", "kanban_create_todo", "kanban_update_todo",
"kanban_create_task", "list_files", "submit_batch_plan", "report_completion",
],
crate::agents::AgentType::DocAgent => vec![
"read_file", "search_files", "list_files", "list_directory",
"find_references", "file_dependencies", "get_documentation_context",
"documentation_tree", "store_file_doc",
],
crate::agents::AgentType::TestJudge => vec![
"read_file", "search_files", "list_files", "list_directory",
"bash", "kanban_create_todo", "kanban_update_todo", "report_completion",
],
crate::agents::AgentType::Planner => vec![
"kanban_list_board", "kanban_create_todo", "kanban_update_todo",
"kanban_delete_todo", "kanban_move_todo", "kanban_create_task",
"kanban_update_task", "kanban_add_tag", "document_file", "document_project",
"find_references", "file_dependencies", "documentation_tree",
"verify_documentation", "document_folder", "get_documentation_context",
"list_files", "propose_strategic_item", "change_planner_mode",
"audit_assumptions", "identify_blind_spots", "check_dependencies",
"evaluate_plan_risk", "compare_project_patterns", "find_similar_risks",
"store_file_doc", "read_file",
],
crate::agents::AgentType::ChatAgent => return None,
})
}
/// Formats tool definitions as OpenAI-compatible tools JSON.
pub fn format_tools_json(tools: &[ToolDefinition]) -> Option<String> {
let formatted: Vec<serde_json::Value> = tools
.iter()
.map(|t| {
serde_json::json!({
"type": "function",
"function": {
"name": t.name,
"description": t.description,
"parameters": t.parameters,
}
})
})
.collect();
serde_json::to_string(&formatted).ok()
}
#[cfg(test)]
mod tests {
use super::*;