// letta's tools — letta's own code (novox/hq ADR 0039). They import letta's own client (../client) // and plug into the mesh through the sdk's tool harness. Editing them rebuilds letta and nothing // else. Absent a password they yield no tools rather than a failure. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { LettaClient } from "../client.js"; export function getLettaTools(letta: LettaClient): ToolDefinition[] { return [ { name: "letta_list_agents", description: "List the Letta agents on the server.", input: {}, run: async () => ({ agents: await letta.listAgents() }), }, { name: "letta_get_messages", description: "Fetch recent messages from a Letta agent's conversation.", input: { agent_id: { type: "string", description: "the agent id" }, limit: { type: "number", description: "max messages to return (default 20)" }, }, run: async (args) => { const agentId = String(args.agent_id); const limit = args.limit ? Number(args.limit) : 20; return { messages: await letta.getMessages(agentId, limit) }; }, }, { name: "letta_send_message", description: "Send a user message to a Letta agent and return its reply.", input: { agent_id: { type: "string", description: "the agent id" }, text: { type: "string", description: "the message to send" }, }, run: async (args) => { const agentId = String(args.agent_id); const text = String(args.text); return { reply: await letta.sendMessage(agentId, text) }; }, }, ]; } registerModuleTools("letta", (env) => { try { return getLettaTools(LettaClient.fromEnv(env)); } catch { return []; } });