diff --git a/src/lib.rs b/src/lib.rs index 1f79bb0..fe21fe4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, diff --git a/src/task.rs b/src/task.rs index b445dcd..8dc470a 100644 --- a/src/task.rs +++ b/src/task.rs @@ -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, + pub temperature: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct AgentTaskSpec { pub task_id: Uuid, @@ -196,6 +205,10 @@ pub struct AgentTaskSpec { pub suggested_test_files: Vec, #[serde(default)] pub project_id: Option, + #[serde(default)] + pub connector_config: Option, + #[serde(default)] + pub tools_json: Option, } 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, } } } diff --git a/src/tools.rs b/src/tools.rs index a414d09..9997078 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -1534,6 +1534,58 @@ pub fn tool_definitions() -> Vec { ] } +/// 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> { + 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 { + let formatted: Vec = 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::*;