feat(llm): get_attachment + get_note_attachments

This commit is contained in:
Elian Doran
2026-04-03 19:09:43 +03:00
parent f47ec21aa8
commit 4a0d45ad7d
3 changed files with 26 additions and 20 deletions

View File

@@ -2355,7 +2355,8 @@
"load_skill": "Load skill",
"web_search": "Web search",
"note_in_parent": "<Note/> in <Parent/>",
"get_attachments": "Get attachments"
"get_note_attachments": "Get note attachments",
"get_attachment": "Get attachment"
}
}
}

View File

@@ -5,32 +5,22 @@
import { z } from "zod";
import becca from "../../../becca/becca.js";
import mappers from "../../../etapi/mappers.js";
import { defineTools } from "./tool_registry.js";
export const attachmentTools = defineTools({
get_attachments: {
description: "List all attachments of a note. Returns metadata such as title, MIME type, role, size, and attachment ID for each attachment.",
get_attachment: {
description: "Get metadata for a single attachment by its ID.",
inputSchema: z.object({
noteId: z.string().describe("The ID of the note whose attachments to list")
attachmentId: z.string().describe("The ID of the attachment to retrieve")
}),
execute: async ({ noteId }) => {
const note = becca.getNote(noteId);
if (!note) {
return { error: "Note not found" };
execute: async ({ attachmentId }) => {
const attachment = becca.getAttachment(attachmentId);
if (!attachment) {
return { error: "Attachment not found" };
}
const attachments = note.getAttachments();
return attachments.map((att) => ({
attachmentId: att.attachmentId,
title: att.title,
role: att.role,
mime: att.mime,
contentLength: att.contentLength,
position: att.position,
isProtected: !!att.isProtected,
utcDateModified: att.utcDateModified
}));
return mappers.mapAttachmentToPojo(attachment);
}
}
});

View File

@@ -273,5 +273,20 @@ export const noteTools = defineTools({
return { error: err instanceof Error ? err.message : "Failed to create note" };
}
}
},
get_note_attachments: {
description: "List all attachments of a note by its ID. Returns metadata for each attachment.",
inputSchema: z.object({
noteId: z.string().describe("The ID of the note whose attachments to list")
}),
execute: async ({ noteId }) => {
const note = becca.getNote(noteId);
if (!note) {
return { error: "Note not found" };
}
return note.getAttachments().map((att) => mappers.mapAttachmentToPojo(att));
}
}
});