Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: add note management tools (get, create, update) to agent mode

Gabriel Steinecda3049b434
diff --git a/src/config/prompts.ts b/src/config/prompts.ts
index ab1b37b86..1a5cbc9d9 100644
--- a/src/config/prompts.ts
+++ b/src/config/prompts.ts
@@ -147,6 +147,11 @@ const DEFAULT_AGENT_SYSTEM_PROMPT =
const TOOL_INSTRUCTIONS: Record<string, string> = {
search_notes:
"Use search_notes to find information from the user's past meetings, discussions, or personal notes before answering from memory.",
+ get_note:
+ "Use get_note to fetch the full content of a specific note by ID. Use search_notes first to find the note ID.",
+ create_note: "Use create_note when the user asks you to create, write, or draft a new note.",
+ update_note:
+ "Use update_note to modify an existing note's title, content, or move it to a different folder. Use search_notes first to find the note ID.",
web_search:
"Use web_search for questions about current events, facts you're unsure about, or anything requiring up-to-date information.",
copy_to_clipboard:
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index 6802ee828..973ef066f 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Websuche...",
"copy_to_clipboardStatus": "In Zwischenablage kopieren...",
"get_calendar_eventsStatus": "Kalender wird geprüft...",
+ "get_noteStatus": "Notiz wird gelesen...",
+ "create_noteStatus": "Notiz wird erstellt...",
+ "update_noteStatus": "Notiz wird aktualisiert...",
"foundNotes": "{{count}} Notiz gefunden",
"foundNotes_plural": "{{count}} Notizen gefunden",
"searchResults": "{{count}} Ergebnis gefunden",
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 6f151f837..71d1b7b84 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1891,6 +1891,9 @@
"web_searchStatus": "Searching the web...",
"copy_to_clipboardStatus": "Copying to clipboard...",
"get_calendar_eventsStatus": "Checking calendar...",
+ "get_noteStatus": "Reading note...",
+ "create_noteStatus": "Creating note...",
+ "update_noteStatus": "Updating note...",
"foundNotes": "Found {{count}} note",
"foundNotes_plural": "Found {{count}} notes",
"searchResults": "Found {{count}} result",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index b49d92978..8067bf17a 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Buscando en la web...",
"copy_to_clipboardStatus": "Copiando al portapapeles...",
"get_calendar_eventsStatus": "Consultando calendario...",
+ "get_noteStatus": "Leyendo nota...",
+ "create_noteStatus": "Creando nota...",
+ "update_noteStatus": "Actualizando nota...",
"foundNotes": "{{count}} nota encontrada",
"foundNotes_plural": "{{count}} notas encontradas",
"searchResults": "{{count}} resultado encontrado",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index f50dac182..77c00d367 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Recherche sur le web...",
"copy_to_clipboardStatus": "Copie dans le presse-papiers...",
"get_calendar_eventsStatus": "Vérification du calendrier...",
+ "get_noteStatus": "Lecture de la note...",
+ "create_noteStatus": "Création de la note...",
+ "update_noteStatus": "Mise à jour de la note...",
"foundNotes": "{{count}} note trouvée",
"foundNotes_plural": "{{count}} notes trouvées",
"searchResults": "{{count}} résultat trouvé",
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index 835c5e5a1..0698edb09 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Ricerca sul web...",
"copy_to_clipboardStatus": "Copia negli appunti...",
"get_calendar_eventsStatus": "Controllo del calendario...",
+ "get_noteStatus": "Lettura della nota...",
+ "create_noteStatus": "Creazione della nota...",
+ "update_noteStatus": "Aggiornamento della nota...",
"foundNotes": "{{count}} nota trovata",
"foundNotes_plural": "{{count}} note trovate",
"searchResults": "{{count}} risultato trovato",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 4250f34f7..81acc6304 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "ウェブを検索中...",
"copy_to_clipboardStatus": "クリップボードにコピー中...",
"get_calendar_eventsStatus": "カレンダーを確認中...",
+ "get_noteStatus": "ノートを読み込み中...",
+ "create_noteStatus": "ノートを作成中...",
+ "update_noteStatus": "ノートを更新中...",
"foundNotes": "{{count}}件のノートが見つかりました",
"foundNotes_plural": "{{count}}件のノートが見つかりました",
"searchResults": "{{count}}件の結果が見つかりました",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 9cd5a679c..025eb77ed 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Pesquisando na web...",
"copy_to_clipboardStatus": "Copiando para a área de transferência...",
"get_calendar_eventsStatus": "Verificando calendário...",
+ "get_noteStatus": "Lendo nota...",
+ "create_noteStatus": "Criando nota...",
+ "update_noteStatus": "Atualizando nota...",
"foundNotes": "{{count}} nota encontrada",
"foundNotes_plural": "{{count}} notas encontradas",
"searchResults": "{{count}} resultado encontrado",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 88fa191d1..c431d0d38 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "Поиск в интернете...",
"copy_to_clipboardStatus": "Копирование в буфер обмена...",
"get_calendar_eventsStatus": "Проверка календаря...",
+ "get_noteStatus": "Чтение заметки...",
+ "create_noteStatus": "Создание заметки...",
+ "update_noteStatus": "Обновление заметки...",
"foundNotes": "Найдена {{count}} заметка",
"foundNotes_plural": "Найдено {{count}} заметок",
"searchResults": "Найден {{count}} результат",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index bb8c79b3e..2c223a3d1 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "正在搜索网页...",
"copy_to_clipboardStatus": "正在复制到剪贴板...",
"get_calendar_eventsStatus": "正在查看日历...",
+ "get_noteStatus": "正在读取笔记...",
+ "create_noteStatus": "正在创建笔记...",
+ "update_noteStatus": "正在更新笔记...",
"foundNotes": "找到 {{count}} 条笔记",
"foundNotes_plural": "找到 {{count}} 条笔记",
"searchResults": "找到 {{count}} 条结果",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index 7631b3517..777093828 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1821,6 +1821,9 @@
"web_searchStatus": "正在搜尋網頁...",
"copy_to_clipboardStatus": "正在複製到剪貼簿...",
"get_calendar_eventsStatus": "正在查看行事曆...",
+ "get_noteStatus": "正在讀取筆記...",
+ "create_noteStatus": "正在建立筆記...",
+ "update_noteStatus": "正在更新筆記...",
"foundNotes": "找到 {{count}} 則筆記",
"foundNotes_plural": "找到 {{count}} 則筆記",
"searchResults": "找到 {{count}} 項結果",
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 804afa1e6..1704dc0c2 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -1338,12 +1338,13 @@ class ReasoningService extends BaseReasoningService {
} else if (chunk.type === "tool-result") {
const output = chunk.output;
const displayText =
- typeof output === "string"
- ? output
- : output?.error
- ? String(output.error)
- : "Done";
- yield { type: "tool_result", callId: chunk.toolCallId, toolName: chunk.toolName, displayText };
+ typeof output === "string" ? output : output?.error ? String(output.error) : "Done";
+ yield {
+ type: "tool_result",
+ callId: chunk.toolCallId,
+ toolName: chunk.toolName,
+ displayText,
+ };
} else if (chunk.type === "finish") {
yield { type: "done", finishReason: chunk.finishReason };
}
diff --git a/src/services/tools/createNoteTool.ts b/src/services/tools/createNoteTool.ts
new file mode 100644
index 000000000..003a594b9
--- /dev/null
+++ b/src/services/tools/createNoteTool.ts
@@ -0,0 +1,73 @@
+import type { ToolDefinition, ToolResult } from "./ToolRegistry";
+import { resolveFolderId } from "./utils";
+import { syncNoteToCloud } from "../../stores/noteStore";
+
+export const createNoteTool: ToolDefinition = {
+ name: "create_note",
+ description: "Create a new note with a title and content, optionally in a specific folder.",
+ parameters: {
+ type: "object",
+ properties: {
+ title: {
+ type: "string",
+ description: "The title of the note",
+ },
+ content: {
+ type: "string",
+ description: "The content of the note",
+ },
+ folder: {
+ type: "string",
+ description: "The folder name to create the note in (optional)",
+ },
+ },
+ required: ["title", "content"],
+ additionalProperties: false,
+ },
+ readOnly: false,
+
+ async execute(args: Record<string, unknown>): Promise<ToolResult> {
+ const title = args.title as string;
+ const content = args.content as string;
+ const folderName = args.folder as string | undefined;
+
+ try {
+ let folderId: number | null = null;
+
+ if (folderName) {
+ const resolved = await resolveFolderId(folderName);
+ if (resolved.error) {
+ return { success: false, data: null, displayText: resolved.error };
+ }
+ folderId = resolved.folderId;
+ }
+
+ const result = await window.electronAPI.saveNote(
+ title,
+ content,
+ "personal",
+ null,
+ null,
+ folderId
+ );
+
+ if (!result.success || !result.note) {
+ return { success: false, data: null, displayText: "Failed to create note" };
+ }
+
+ syncNoteToCloud(result.note).catch(() => {});
+
+ return {
+ success: true,
+ data: { id: result.note.id, title: result.note.title },
+ displayText: `Created note: "${title}"`,
+ };
+ } catch (error) {
+ return {
+ success: false,
+ data: null,
+ displayText: `Failed to create note: ${(error as Error).message}`,
+ };
+ }
+ },
+};
diff --git a/src/services/tools/getNoteTool.ts b/src/services/tools/getNoteTool.ts
new file mode 100644
index 000000000..1219759fc
--- /dev/null
+++ b/src/services/tools/getNoteTool.ts
@@ -0,0 +1,55 @@
+import type { ToolDefinition, ToolResult } from "./ToolRegistry";
+
+export const getNoteTool: ToolDefinition = {
+ name: "get_note",
+ description:
+ "Get the full content of a specific note by ID. Use search_notes first to find the note ID.",
+ parameters: {
+ type: "object",
+ properties: {
+ id: {
+ type: "number",
+ description: "The note ID to retrieve",
+ },
+ },
+ required: ["id"],
+ additionalProperties: false,
+ },
+ readOnly: true,
+
+ async execute(args: Record<string, unknown>): Promise<ToolResult> {
+ const id = args.id as number;
+
+ try {
+ const note = await window.electronAPI.getNote(id);
+
+ if (!note) {
+ return {
+ success: false,
+ data: null,
+ displayText: `Note with ID ${id} not found`,
+ };
+ }
+
+ return {
+ success: true,
+ data: {
+ id: note.id,
+ title: note.title,
+ content: note.enhanced_content || note.content,
+ type: note.note_type,
+ folder_id: note.folder_id,
+ created_at: note.created_at,
+ updated_at: note.updated_at,
+ },
+ displayText: `Retrieved note: "${note.title}"`,
+ };
+ } catch (error) {
+ return {
+ success: false,
+ data: null,
+ displayText: `Failed to get note: ${(error as Error).message}`,
+ };
+ }
+ },
+};
diff --git a/src/services/tools/index.ts b/src/services/tools/index.ts
index ea782ed7b..d45d10f35 100644
--- a/src/services/tools/index.ts
+++ b/src/services/tools/index.ts
@@ -1,5 +1,8 @@
import { ToolRegistry } from "./ToolRegistry";
import { searchNotesTool } from "./searchNotesTool";
+import { getNoteTool } from "./getNoteTool";
+import { createNoteTool } from "./createNoteTool";
+import { updateNoteTool } from "./updateNoteTool";
import { clipboardTool } from "./clipboardTool";
import { webSearchTool } from "./webSearchTool";
import { calendarTool } from "./calendarTool";
@@ -16,6 +19,9 @@ export function createToolRegistry(settings: ToolRegistrySettings): ToolRegistry
const registry = new ToolRegistry();
registry.register(searchNotesTool);
+ registry.register(getNoteTool);
+ registry.register(createNoteTool);
+ registry.register(updateNoteTool);
registry.register(clipboardTool);
if (settings.isSignedIn) {
diff --git a/src/services/tools/searchNotesTool.ts b/src/services/tools/searchNotesTool.ts
index fd4cd59be..2e8f1bae4 100644
--- a/src/services/tools/searchNotesTool.ts
+++ b/src/services/tools/searchNotesTool.ts
@@ -39,6 +39,7 @@ export const searchNotesTool: ToolDefinition = {
}
const results = notes.map((note) => ({
+ id: note.id,
title: note.title,
date: note.created_at,
type: note.note_type,
diff --git a/src/services/tools/updateNoteTool.ts b/src/services/tools/updateNoteTool.ts
new file mode 100644
index 000000000..e41b8a266
--- /dev/null
+++ b/src/services/tools/updateNoteTool.ts
@@ -0,0 +1,87 @@
+import type { ToolDefinition, ToolResult } from "./ToolRegistry";
+import { resolveFolderId } from "./utils";
+import { syncNoteUpdateToCloud } from "../../stores/noteStore";
+
+export const updateNoteTool: ToolDefinition = {
+ name: "update_note",
+ description:
+ "Update an existing note's title, content, or move it to a different folder. Use search_notes first to find the note ID.",
+ parameters: {
+ type: "object",
+ properties: {
+ id: {
+ type: "number",
+ description: "The note ID to update",
+ },
+ title: {
+ type: "string",
+ description: "New title for the note (optional)",
+ },
+ content: {
+ type: "string",
+ description: "New content for the note (optional)",
+ },
+ folder: {
+ type: "string",
+ description: "Folder name to move the note to (optional)",
+ },
+ },
+ required: ["id"],
+ additionalProperties: false,
+ },
+ readOnly: false,
+
+ async execute(args: Record<string, unknown>): Promise<ToolResult> {
+ const id = args.id as number;
+ const title = args.title as string | undefined;
+ const content = args.content as string | undefined;
+ const folderName = args.folder as string | undefined;
+
+ if (!title && !content && !folderName) {
+ return {
+ success: false,
+ data: null,
+ displayText: "At least one of title, content, or folder must be provided",
+ };
+ }
+
+ try {
+ const note = await window.electronAPI.getNote(id);
+ if (!note) {
+ return { success: false, data: null, displayText: `Note with ID ${id} not found` };
+ }
+
+ const updates: Record<string, string | number | null> = {};
+ if (title) updates.title = title;
+ if (content) updates.content = content;
+
+ if (folderName) {
+ const resolved = await resolveFolderId(folderName);
+ if (resolved.error) {
+ return { success: false, data: null, displayText: resolved.error };
+ }
+ updates.folder_id = resolved.folderId;
+ }
+
+ const result = await window.electronAPI.updateNote(id, updates);
+
+ if (!result.success) {
+ return { success: false, data: null, displayText: "Failed to update note" };
+ }
+
+ syncNoteUpdateToCloud(note, updates).catch(() => {});
+
+ return {
+ success: true,
+ data: { id, title: title || note.title },
+ displayText: `Updated note: "${title || note.title}"`,
+ };
+ } catch (error) {
+ return {
+ success: false,
+ data: null,
+ displayText: `Failed to update note: ${(error as Error).message}`,
+ };
+ }
+ },
+};
diff --git a/src/services/tools/utils.ts b/src/services/tools/utils.ts
new file mode 100644
index 000000000..ea4917971
--- /dev/null
+++ b/src/services/tools/utils.ts
@@ -0,0 +1,11 @@
+export async function resolveFolderId(
+ folderName: string
+): Promise<{ folderId: number; error?: undefined } | { folderId?: undefined; error: string }> {
+ const folders = await window.electronAPI.getFolders();
+
+ const match = folders.find((f) => f.name.toLowerCase() === folderName.toLowerCase());
+ if (match) return { folderId: match.id };
+
+ const available = folders.map((f) => f.name).join(", ");
+ return { error: `Folder "${folderName}" not found. Available folders: ${available}` };
+}