1use schemars::JsonSchema;
4use serde::Deserialize;
5use wcore::{
6 agent::{AsTool, ToolDescription},
7 protocol::ext::ToolDef,
8};
9
10#[derive(Deserialize, JsonSchema)]
11pub struct Recall {
12 pub queries: Vec<String>,
14 pub limit: Option<u32>,
16}
17
18impl ToolDescription for Recall {
19 const DESCRIPTION: &'static str =
20 "Search memory by one or more queries. Returns relevant entities and graph connections.";
21}
22
23#[derive(Deserialize, JsonSchema)]
24pub struct Extract {
25 pub entities: Vec<ExtractEntity>,
27 pub relations: Vec<ExtractRelation>,
29}
30
31#[derive(Deserialize, JsonSchema)]
32pub struct ExtractEntity {
33 pub key: String,
35 pub value: String,
37 pub entity_type: Option<String>,
39}
40
41#[derive(Deserialize, JsonSchema)]
42pub struct ExtractRelation {
43 pub source: String,
45 pub relation: String,
47 pub target: String,
49}
50
51impl ToolDescription for Extract {
52 const DESCRIPTION: &'static str =
53 "Batch upsert entities and relations into memory. Internal tool for extraction.";
54}
55
56pub fn tool_defs() -> Vec<ToolDef> {
58 let t = Recall::as_tool();
59 vec![ToolDef {
60 name: t.name.to_string(),
61 description: t.description.to_string(),
62 parameters: serde_json::to_vec(&t.parameters).expect("schema serialization"),
63 strict: t.strict,
64 }]
65}
66
67pub fn all_tool_defs() -> Vec<ToolDef> {
72 [Recall::as_tool(), Extract::as_tool()]
73 .into_iter()
74 .map(|t| ToolDef {
75 name: t.name.to_string(),
76 description: t.description.to_string(),
77 parameters: serde_json::to_vec(&t.parameters).expect("schema serialization"),
78 strict: t.strict,
79 })
80 .collect()
81}