Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm): provide attachments list directly in note meta
Elian Doran1a64e7ba631b
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 5797d8516f..081ec1349b 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2355,7 +2355,6 @@"load_skill": "Load skill","web_search": "Web search","note_in_parent": "<Note/> in <Parent/>",- "get_note_attachments": "Get note attachments","get_attachment": "Get attachment","get_attachment_content": "Read attachment content"}diff --git a/apps/server/src/services/llm/tools/note_tools.ts b/apps/server/src/services/llm/tools/note_tools.tsindex bdb9b0c563..a2321f1772 100644--- a/apps/server/src/services/llm/tools/note_tools.ts+++ b/apps/server/src/services/llm/tools/note_tools.ts@@ -68,7 +68,21 @@ export function getNoteMeta(note: BNote) {isInheritable: attr.isInheritable,utcDateModified: attr.utcDateModified})),- contentPreview: getContentPreview(note)+ contentPreview: getContentPreview(note),+ attachments: note.getAttachments().map((att) => ({+ attachmentId: att.attachmentId,+ ownerId: att.ownerId,+ role: att.role,+ mime: att.mime,+ title: att.title,+ position: att.position,+ blobId: att.blobId,+ dateModified: att.dateModified,+ utcDateModified: att.utcDateModified,+ utcDateScheduledForErasureSince: att.utcDateScheduledForErasureSince,+ contentLength: att.contentLength,+ contentPreview: getAttachmentContentPreview(att)+ }))};}@@ -334,33 +348,5 @@ 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 and a short content preview for each attachment. Use get_attachment_content for the full content.",- 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) => ({- attachmentId: att.attachmentId,- ownerId: att.ownerId,- role: att.role,- mime: att.mime,- title: att.title,- position: att.position,- blobId: att.blobId,- dateModified: att.dateModified,- utcDateModified: att.utcDateModified,- utcDateScheduledForErasureSince: att.utcDateScheduledForErasureSince,- contentLength: att.contentLength,- contentPreview: getAttachmentContentPreview(att)- }));- }}});