use polyc_llm::ToolSpec;
use serde_json::json;
pub const LINK_EMAIL: &str = "link_email";
pub const ALL: &[&str] = &[LINK_EMAIL];
#[must_use]
pub fn all_specs() -> Vec<ToolSpec> {
vec![link_email_spec()]
}
#[must_use]
pub fn link_email_spec() -> ToolSpec {
ToolSpec::new(
LINK_EMAIL,
"Verify an email address by sending a one-click confirmation link. Use it when \
the person gives you an address to verify, or when another tool needs a \
verified email on file before it can proceed. Takes the address, sends a mail \
with a link, and confirms the mail went out — nothing is linked until the \
person clicks the link on their own device. It only ever verifies THIS \
person's own address.",
json!({
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "The email address to verify."
}
},
"required": ["email"],
"additionalProperties": false
}),
)
.titled("Verify an email address")
}
#[cfg(test)]
mod tests {
#![allow(clippy::pedantic, clippy::nursery, missing_docs)]
use super::*;
#[test]
fn all_specs_match_all_names() {
let specs = all_specs();
assert_eq!(specs.len(), ALL.len());
for name in ALL {
assert!(specs.iter().any(|s| s.name == *name), "{name} has no spec");
}
}
#[test]
fn link_email_spec_requires_the_email_argument_and_is_ungated() {
let spec = link_email_spec();
assert_eq!(spec.name, LINK_EMAIL);
assert!(!spec.destructive, "moves no money, is not destructive");
let props = spec.schema_json["properties"].as_object().unwrap();
assert!(props.contains_key("email"));
let required = spec.schema_json["required"].as_array().unwrap();
assert_eq!(required, &[json!("email")]);
}
}