(&self)
| 54 | } |
| 55 | |
| 56 | pub async fn list_schemas(&self) -> Vec<ToolSchema> { |
| 57 | let tools = self.tools.read().await; |
| 58 | let mut schemas: Vec<ToolSchema> = tools |
| 59 | .values() |
| 60 | .map(|t| ToolSchema { |
| 61 | name: t.id().to_string(), |
| 62 | description: t.description().to_string(), |
| 63 | parameters: t.parameters(), |
| 64 | }) |
| 65 | .collect(); |
| 66 | |
| 67 | // Trigger tool.definition hook for each schema so plugins can transform them |
| 68 | for schema in &mut schemas { |
| 69 | let hook_outputs = opencode_plugin::trigger_collect( |
| 70 | HookContext::new(HookEvent::ToolDefinition) |
| 71 | .with_data("tool_id", serde_json::json!(&schema.name)) |
| 72 | .with_data("description", serde_json::json!(&schema.description)) |
| 73 | .with_data("parameters", schema.parameters.clone()), |
| 74 | ) |
| 75 | .await; |
| 76 | for output in hook_outputs { |
| 77 | if let Some(payload) = output.payload.as_ref() { |
| 78 | apply_tool_definition_payload(schema, payload); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | schemas |
| 84 | } |
| 85 | |
| 86 | pub async fn execute( |
| 87 | &self, |
no test coverage detected