Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
use ai_toolset::{AsyncTool, RequestContext, ServiceContext, ToolCallError, ToolResult};
use ai_toolset::{ToolAnnotated, ToolAnnotations};
use async_trait::async_trait;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::SkillToolContext;
use super::search_skills::SkillSearchResult;
use crate::domain::ports::SkillService;
/// AI tool input for listing the user's skills.
#[derive(Debug, JsonSchema, Deserialize, Clone, Default)]
#[serde(rename_all = "camelCase")]
#[schemars(
title = "ListSkills",
description = "List up to 100 of the most recently updated skills the user can access, plus built-in skills. Skills are markdown documents containing instructions for AI to read and follow; after finding a relevant skill, read its instructions with ReadSkill using the returned document id. Use this to discover what skills exist; when looking for a specific skill by name or an older skill not in this list, use SearchSkills."
)]
pub struct ListSkills {}
/// Response for a skill listing.
#[derive(Debug, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ListSkillsResponse {
/// The user's skills, most recently updated first.
pub results: Vec<SkillSearchResult>,
}
impl ToolAnnotated for ListSkills {
const ANNOTATIONS: ToolAnnotations = ToolAnnotations::read_only("List skills");
}
#[async_trait]
impl<Svc: SkillService> AsyncTool<SkillToolContext<Svc>> for ListSkills {
type Output = ListSkillsResponse;
#[tracing::instrument(skip_all, fields(user_id=?request_context.user_id), err)]
async fn call(
&self,
service_context: ServiceContext<SkillToolContext<Svc>>,
request_context: RequestContext,
) -> ToolResult<Self::Output> {
let skills = service_context
.service
.list_skills(&request_context.user_id)
.await
.map_err(|error| ToolCallError {
description: "failed to list skills".to_string(),
internal_error: error.into(),
})?;
Ok(ListSkillsResponse {
results: skills
.into_iter()
.map(|skill| SkillSearchResult {
document_id: skill.document_id,
name: skill.name,
description: skill.description,
updated_at: skill.updated_at,
})
.collect(),
})
}
}