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): run subscription CLIs from the Flatpak on the host
Elian Doran5d3df049bd6b
diff --git a/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.css b/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.cssindex 4450fa3995..7b2a2a28ef 100644--- a/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.css+++ b/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.css@@ -69,3 +69,8 @@margin-bottom: 0.25em;}}++.no-items.model-selection-error {+ white-space: pre-wrap;+ overflow-wrap: anywhere;+}diff --git a/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.tsx b/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.tsxindex cb68ee7445..435063e5a1 100644--- a/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm/ModelSelection.tsx@@ -92,7 +92,11 @@ export default function ModelSelection({ query, timeoutMs, selected, onChange, aif (error) {return (// JSX escapes the text itself, so i18next must not escape the message as well.- <NoItems icon="bx bx-error-circle" text={t("llm.models_load_failed", { error, interpolation: { escapeValue: false } })}>+ <NoItems+ icon="bx bx-error-circle"+ className="model-selection-error"+ text={t("llm.models_load_failed", { error, interpolation: { escapeValue: false } })}+ >{troubleshooting}</NoItems>);diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex f2f952f46f..70c4d8e108 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -1,6 +1,6 @@{"_help_BOCnjTMBCoxW": "<p>This section presents the most important changes by version. For a full set of changes, please consult the change log of each release. For purposes of brevity, beta versions are skipped and the features gathered to the nearest stable version.</p><ul><li>v0.105.0:<ul><li>Text notes now have a <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> for quick proof-reading and other text-based operations that don't require a full chat.</li></ul></li><li>v0.101.0:<ul><li>A new layout has been introduced, making significant modifications to the UI/UX such as integrating the ribbon and the floating buttons into other UI elements and introducing new functionality such as the <a class=\"reference-link\" href=\"#root/_help_I6p2a06hdnL6\">Breadcrumb</a>.</li></ul></li><li>v0.97.0:<ul><li>Books are now <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>.</li><li><a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a> is a new collection type displaying notes and attributes in an editable grid.</li><li><a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a> is introduced, adding a new way to edit notes in a popup instead of opening a new tab. It also integrates well with <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>.</li></ul></li><li>v0.96.0:<ul><li><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> gain premium features thanks to a collaboration with the CKEditor team:<ul><li><a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a></li><li><a class=\"reference-link\" href=\"#root/_help_pwc194wlRzcH\">Text Snippets</a></li></ul></li></ul></li><li>v0.95.0:<ul><li>A more friendly theme was introduced for <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, with search, expandable tree, night mode and more.</li></ul></li><li>v0.94.0:<ul><li>Added integration with <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a> (using self-hosted LLMs such as Ollama or industry standards such as ChatGPT).</li></ul></li><li>v0.92.5:<ul><li>Windows binaries are now signed.</li><li><a class=\"reference-link\" href=\"#root/_help_7DAiwaf8Z7Rz\">Multi-factor authentication with TOTP</a> was introduced.</li></ul></li><li>v0.92.4:<ul><li>macOS binaries are now signed.</li><li><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes can now have adjustable <a class=\"reference-link\" href=\"#root/_help_veGu4faJErEM\">Content language & Right-to-left support</a>.</li><li><a class=\"reference-link\" href=\"#root/_help_NRnIZmSMc5sj\">Printing & Exporting as PDF</a></li><li><a class=\"reference-link\" href=\"#root/_help_rC3pL2aptaRE\">Zen mode</a></li><li><a class=\"reference-link\" href=\"#root/_help_xWbu3jpNWapp\">Calendar</a>, allowing notes to be displayed in a monthly grid based on start and end dates.</li></ul></li><li>v0.91.5:<ul><li>Significant improvements for mobile.</li><li><a class=\"reference-link\" href=\"#root/_help_AgjCISero73a\">Footnotes</a> are now supported in <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes.</li><li>Mermaid diagrams can now be inserted inline within <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes.</li><li>The TriliumNext theme is introduced, bringing a more modern design to the application.</li><li><a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>, displaying notes as markers on a geographical map for easy trip planning.</li></ul></li><li>v0.90.8:<ul><li>A new note type was introduced: <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a></li></ul></li></ul>",- "_help_poXkQfguuA0U": "<p>To install Trilium on your desktop, follow these steps:</p><ol><li><strong>Download the Latest Release</strong>: Obtain the appropriate binary release for your operating system from the <a href=\"https://github.com/TriliumNext/Trilium/releases/latest\">latest release page</a> on GitHub.</li><li><strong>Extract the Package</strong>: Unzip the downloaded package to a location of your choice.</li><li><strong>Run the Application</strong>: Launch Trilium by executing the <code>trilium</code> executable found within the unzipped folder.</li></ol><h2>Installing from Flathub</h2><p>On Linux, Trilium is also available on <a href=\"https://flathub.org/en/apps/org.triliumnotes.Trilium\">Flathub</a>, for both x86_64 and ARM (aarch64). Install it from your software center (e.g. GNOME Software or KDE Discover), or from a terminal:</p><pre><code class=\"language-text-x-sh\">flatpak install flathub org.triliumnotes.Trilium</code></pre><p>Updates arrive through the software center or <code>flatpak update</code>, like any other Flatpak.</p><p>The Flathub version runs in a sandbox and keeps its <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> in <code>~/.var/app/org.triliumnotes.Trilium/data/trilium-data</code>. It cannot see the data directory of a <code>.deb</code>, <code>.rpm</code>, AppImage or <code>.zip</code> installation (<code>~/.local/share/trilium-data</code>), so it starts with an empty database. To bring existing notes over:</p><ol><li><p>Close Trilium, in both the old installation and the Flatpak.</p></li><li><p>Copy the old data directory into the sandbox:</p><pre><code class=\"language-text-x-sh\">mkdir -p ~/.var/app/org.triliumnotes.Trilium/data\ncp -a ~/.local/share/trilium-data ~/.var/app/org.triliumnotes.Trilium/data/</code></pre></li><li><p>Start the Flatpak version.</p></li></ol><p>If <code>~/.var/app/org.triliumnotes.Trilium/data/trilium-data</code> already exists because the Flatpak version was started before, remove or rename it first.</p><h2>Startup Scripts</h2><p>Trilium offers various startup scripts to customize your experience:</p><ul><li><code>trilium-no-cert-check</code>: Starts Trilium without validating <a href=\"#root/_help_l2VkvOwUNfZj\">TLS certificates</a>, useful if connecting to a server with a self-signed certificate.<ul><li>Alternatively, set the <code>NODE_TLS_REJECT_UNAUTHORIZED=0</code> environment variable before starting Trilium.</li></ul></li><li><code>trilium-portable</code>: Launches Trilium in portable mode, where the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> is created within the application's directory, making it easy to move the entire setup. Electron's internal data (caches, dictionaries, etc.) is also stored within the data directory, so no files are written to the system's roaming profile.</li><li><code>trilium-safe-mode</code>: Boots Trilium in \"safe mode,\" disabling any startup scripts that might cause the application to crash.</li></ul><h2>Synchronization</h2><p>For Trilium desktop users who wish to synchronize their data with a server instance, refer to the <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> guide for detailed instructions.</p>",+ "_help_poXkQfguuA0U": "<p>To install Trilium on your desktop, follow these steps:</p><ol><li><strong>Download the Latest Release</strong>: Obtain the appropriate binary release for your operating system from the <a href=\"https://github.com/TriliumNext/Trilium/releases/latest\">latest release page</a> on GitHub.</li><li><strong>Extract the Package</strong>: Unzip the downloaded package to a location of your choice.</li><li><strong>Run the Application</strong>: Launch Trilium by executing the <code>trilium</code> executable found within the unzipped folder.</li></ol><h2>Installing from Flathub</h2><p>On Linux, Trilium is also available on <a href=\"https://flathub.org/en/apps/org.triliumnotes.Trilium\">Flathub</a>, for both x86_64 and ARM (aarch64). Install it from your software center (e.g. GNOME Software or KDE Discover), or from a terminal:</p><pre><code class=\"language-text-x-sh\">flatpak install flathub org.triliumnotes.Trilium</code></pre><p>Updates arrive through the software center or <code>flatpak update</code>, like any other Flatpak.</p><p>The Flathub version runs in a sandbox and keeps its <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> in <code>~/.var/app/org.triliumnotes.Trilium/data/trilium-data</code>. It cannot see the data directory of a <code>.deb</code>, <code>.rpm</code>, AppImage or <code>.zip</code> installation (<code>~/.local/share/trilium-data</code>), so it starts with an empty database. To bring existing notes over:</p><ol><li><p>Close Trilium, in both the old installation and the Flatpak.</p></li><li><p>Copy the old data directory into the sandbox:</p><pre><code class=\"language-text-x-sh\">mkdir -p ~/.var/app/org.triliumnotes.Trilium/data\ncp -a ~/.local/share/trilium-data ~/.var/app/org.triliumnotes.Trilium/data/</code></pre></li><li><p>Start the Flatpak version.</p></li></ol><p>If <code>~/.var/app/org.triliumnotes.Trilium/data/trilium-data</code> already exists because the Flatpak version was started before, remove or rename it first.</p><p>The sandbox also hides the command-line tools that the <a href=\"#root/_help_eFhxp9laTW1S\">subscription-based AI providers</a> run (Claude Code, GitHub Copilot, OpenAI Codex, Google Antigravity); that page describes the permission that lets the Flatpak start them.</p><h2>Startup Scripts</h2><p>Trilium offers various startup scripts to customize your experience:</p><ul><li><code>trilium-no-cert-check</code>: Starts Trilium without validating <a href=\"#root/_help_l2VkvOwUNfZj\">TLS certificates</a>, useful if connecting to a server with a self-signed certificate.<ul><li>Alternatively, set the <code>NODE_TLS_REJECT_UNAUTHORIZED=0</code> environment variable before starting Trilium.</li></ul></li><li><code>trilium-portable</code>: Launches Trilium in portable mode, where the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> is created within the application's directory, making it easy to move the entire setup. Electron's internal data (caches, dictionaries, etc.) is also stored within the data directory, so no files are written to the system's roaming profile.</li><li><code>trilium-safe-mode</code>: Boots Trilium in \"safe mode,\" disabling any startup scripts that might cause the application to crash.</li></ul><h2>Synchronization</h2><p>For Trilium desktop users who wish to synchronize their data with a server instance, refer to the <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> guide for detailed instructions.</p>","_help_nRqcgfTb97uV": "<p>Sometimes, setting up a <a href=\"#root/_help_WOcw2SLH6tbX\">dedicated server installation</a> is not feasible. The desktop application ships with a fully functional server instance by default.</p><p>For security reasons, this feature is <strong>not enabled</strong> by default. To enable it, enable <em>Network access</em> in <a class=\"reference-link\" href=\"#root/_help_fiHicjpHjIRJ\">Security</a>.</p><p>After enabling network access and restarting the application, you can access this web interface locally by navigating to <a href=\"http://localhost:37840/login\">http://localhost:37840/login</a>.</p><aside class=\"admonition note\"><p>The server embedded in the desktop application will only run as long as the desktop application itself is running. So closing the application will also close the server. To overcome this, you can try hiding the application in the system tray.</p></aside><h2>Mobile interface</h2><p>By default, this will display the desktop user interface, even on mobile. To switch to the mobile version, simply go to the <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> and select “Switch to the mobile version”.</p><h2>Allowing the port externally on Windows with Windows Defender Firewall</h2><p>First, find out the IP of your desktop server by running <code>ipconfig</code> in your local terminal. Then try accessing <code>http://<ip>:37840/login</code> on another device. If it doesn't work, then most likely the port is blocked by your operating system's firewall.</p><p>If you use Windows Defender Firewall:</p><ol><li>Go to Windows's start menu and look for “Windows Defender Firewall with Advanced Security”.</li><li>Go to “Inbound Rules” on the left tree, and select “New Rule” in the “Actions” sidebar on the right.</li><li>Select “Port” and press “Next”.</li><li>Type in <code>37840</code> in the “Specific local ports” section and then press “Next”.</li><li>Leave “Allow the connection” checked and press “Next”.</li><li>Configure the networks to apply to (check all if unsure) and then press “Next”.</li><li>Add an appropriate name to the rule (e.g. “Trilium Notes”) and press “Finish”.</li></ol><aside class=\"admonition warning\"><p>Since v0.104.0, the port used by Trilium is accessible only on <code>localhost</code>. To enable across the local network, see <a class=\"reference-link\" href=\"#root/_help_swSFivWk6KkA\">Network Access</a>.</p></aside>","_help_Rp0q8bSP6Ayl": "<p>The desktop version of Trilium supports all three main operating systems:</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span> Windows</p><div class=\"trilium-tab-panel\"><ul><li>Windows 11 is officially supported.</li><li>Windows on ARM is also supported</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span> Linux</p><div class=\"trilium-tab-panel\"><ul><li>Most modern distributions are supported, including NixOS.</li><li>ARM is supported in <code>aarch64</code> (no ARM v7 support).</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-apple\"></span> macOS</p><div class=\"trilium-tab-panel\"><ul><li>Minimum supported operating system: macOS Ventura</li><li>Both Intel and Apple Silicon devices are supported.</li></ul></div></section></div>","_help_Un4wj2Mak2Ky": "<p>Since TriliumNext 0.94.1, the desktop and server applications can be built using <a href=\"https://nixos.org/\">Nix</a>.</p><h2>System requirements</h2><p>Installation of Nix on Mac or Linux (<a href=\"https://nixos.org/download/\">download page</a>). About 3-4 gigabytes of additional storage space, for build artifacts.</p><h2>Run directly</h2><p>Using <a href=\"https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-run.html\">nix run</a>, the desktop app can be started as: <code>nix run github:TriliumNext/Trilium/v0.95.0</code></p><p>Running the server requires explicitly specifying the desired package: <code>nix run github:TriliumNext/Trilium/v0.95.0#server</code></p><p>Instead of a version (<code>v0.95.0</code> above), you can also specify a commit hash (or a branch name). This makes it easy to test development builds.</p><h2>Install on NixOS</h2><p>Add to your <code>flake.nix</code>:</p><pre><code class=\"language-text-x-trilium-auto\">{\n inputs = {\n nixpkgs.url = # ...;\n trilium-notes = {\n url = \"github:TriliumNext/Trilium/v0.95.0\";\n inputs.nixpkgs.follows = \"nixpkgs\";\n };\n };\n\n outputs =\n {\n self,\n # ...\n trilium-notes,\n ...\n }:\n {\n nixosConfigurations = {\n \"nixos\" = nixpkgs.lib.nixosSystem {\n system = \"x86_64-linux\";\n modules = [\n ./configuration.nix\n ];\n specialArgs = {\n inherit\n trilium-notes\n ;\n };\n };\n };\n };\n}\n</code></pre><p>Add to your <code>configuration.nix</code>:</p><pre><code class=\"language-text-x-trilium-auto\">{\n # ...\n trilium-notes,\n ...\n}:\n\n{\n # ...\n\n services.trilium-server.package = trilium-notes.packages.x86_64-linux.server;\n\n environment.systemPackages = [\n trilium-notes.packages.x86_64-linux.desktop\n ];\n}</code></pre><p>The flake aims to be compatible with the latest NixOS stable and unstable.</p>",@@ -244,7 +244,7 @@"_help_TiQbQDgP8L5t": "<p>Optical Character Recognition is the process in which the text from images or PDFs is extracted.</p><h2>Built-in support</h2><p>Since v0.103.0, Trilium has built-in support for OCR. The extracted text can be:</p><ul><li>Integrated with <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, to quickly find the image or file based on snippets of text.</li><li>Integrated with the <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a> feature, which allows the agent to access the content of a non-text note.</li><li>Manually accessed for other purposes (e.g. copying into a note or sending it somewhere else).</li></ul><h2>Supported formats</h2><p>OCR in Trilium supports the following formats:</p><h3>Images</h3><ul><li>Both <a href=\"#root/_help_W8vYD3Q1zjCR\">individual image notes</a> and <a href=\"#root/_help_mT0HEkOsz6i1\">attachments in text files</a> are supported.</li><li>Supported formats:<ul><li>JPEG</li><li>PNG</li><li>GIF (only non-animated)</li><li>BMP</li><li>WebP</li></ul></li><li>Note that this feature works best for computer-rendered text rather than handwriting.</li><li>The underlying technology is Tesseract.js.</li></ul><h3>PDFs</h3><p>The PDF extraction supports:</p><ul><li>PDFs with text information (e.g. a PDF created by a browser or a word processing application), in which the text is extracted.</li><li>Scanned PDFs, and other PDFs whose text cannot be selected (such as documents whose text was converted to outlines), in which the text is extracted through an OCR process.</li><li>Mixed PDFs, containing both text and images with text content.</li></ul><p>Note that OCR extraction is limited to 50 pages per PDF, pages containing text information (not as an image) are not subject to this limitation.</p><aside class=\"admonition note\"><p>Text extraction for scanned PDFs using OCR was introduced in v0.106.0. If a scanned PDF was already processed by an earlier version, reprocess it individually via <em>Process OCR</em>; batch processing only handles files that haven't been OCR'd yet.</p></aside><h3>Office documents</h3><p>The text will be extracted from the following file formats:</p><ul><li>Microsoft Word documents</li><li>Microsoft Excel documents<ul><li>Only the raw text information, the cell structure is not maintained.</li><li>Values are extracted raw, so searching for dates will not work. The OpenDocument alternative will actually extract the properly formatted value.</li></ul></li><li>Microsoft PowerPoint documents</li><li>The OpenDocument alternatives to the previous formats (Text, Spreadsheet, Presentation), created by editors such as LibreOffice and OpenOffice.</li><li><a href=\"https://en.wikipedia.org/wiki/Rich_Text_Format\">Rich Text Format (RTF)</a>, since v0.104.0.</li><li><a href=\"https://en.wikipedia.org/wiki/EPUB\">EPUB</a>, since v0.104.1.</li></ul><h2>Configuring and triggering OCR</h2><p>The OCR can be configured by going to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsMedia\">Media</a> and looking for the <em>Text Extraction (OCR)</em> section.</p><p>There are three ways to trigger the OCR:</p><ul><li>By enabling <em>Auto-process new files</em> which will process only the notes or attachments created after enabling the option, existing files will remain unprocessed.</li><li>By pressing <em>Start Batch Processing</em> which will process all the existing notes.</li><li>By manually requesting for an image or file to have its text extracted, regardless of whether the automatic processing is enabled or not.</li></ul><h3>Minimum confidence</h3><p>When extracting text from an image, there is a certain level of confidence which indicates whether the extracted text appears relevant.</p><p>When the minimum confidence is set to a low percentage, the text extraction can interpret symbols and drawings incorrectly resulting in garbled text.</p><p>If the extracted text for a note or an attachment quality is lower than the minimum confidence, the OCR is disregarded.</p><h2>Language management</h2><p>OCR needs to be aware of the language of the content in order for it to work correctly. The reason is that each language has its own data which needs to be downloaded, and accents or other symbols will not be supported by the default language.</p><p>To configure the languages that are supported by the OCR, simply go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsLocalization\">Language & Region</a> and adjust the <em>Content languages</em>.</p><p>When there are no content languages defined, the user interface <em>Language</em> is used instead.</p><p>After making this change, the automatic processing or manual reprocessing will take into consideration the new languages.</p><p>To enforce the detection in a particular language for a given note, use the <code>language</code> <a href=\"#root/_help_zEY4DaJG4YT5\">attribute</a>, similar to <a href=\"#root/_help_veGu4faJErEM\">text content language</a>. For <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>, it's not possible to manually adjust the language.</p><aside class=\"admonition note\"><p>The trained data for each language is not packaged with Trilium, as that would require a significant amount of space that might not be otherwise needed. As such, when the trained data will be downloaded automatically via <a href=\"https://github.com/naptha/tesseract.js/\">Tesseract.js</a>.</p><p>The downloaded trained data is located in the <a class=\"reference-link\" href=\"#root/_help_tAassRL4RSQL\">Data directory</a>, in the <code>ocr-cache</code> directory.</p></aside><h2>Viewing extracted content for a single note</h2><p>To access the extracted content of a note:</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes, go to the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Advanced</em> → <em>View OCR Text</em>.</li><li>For <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> (e.g. <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a> in <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes), double-click the attachment to view the details, press the […] button at the left and select <em>View extracted text (OCR)</em>.</li></ul><p>This section allows:</p><ul><li>Viewing the extracted text, which can be copied elsewhere if needed or just to check the quality of the extraction.</li><li>If the note has not been extracted yet, pressing <em>Process OCR</em> will process it in the background. If the extraction confidence is lower than the minimum confidence, there will be a notification.</li><li>Similarly, if the minimum confidence was changed in settings, it is possible to press the <em>Process OCR</em> button again to extract the text again.</li></ul>","_help_GBBMSlVSOIGP": "<p>Trilium can connect to a large language model and use it as an assistant that works directly on your notes: ask questions about the note you're reading, have it draft or restructure content, or get it to write scripts and widgets for you.</p><p>The integration is off by default and does nothing until you enable it and configure a provider; Trilium ships no model of its own. The provider you pick decides how your notes travel: a cloud API billed per use, a subscription you already pay for, or a model running on your own hardware, in which case nothing leaves the machine. See <a class=\"reference-link\" href=\"#root/_help_bkPZAMT7d2sR\">Providers</a> for what each involves, and <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> for exactly what gets sent.</p><p>Once enabled, the assistant is available as:</p><ul><li>As a dedicated note type, it can read and modify notes through tools, which you can switch off per conversation if you would rather it only saw what you type.</li><li>A panel in the right sidebar, which acts similarly to the dedicated note type but it also has optional access to the current note.</li><li>An <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> which comes with builtin actions that operate over selected text (such as proof-reading, summarizing), as well as <a class=\"reference-link\" href=\"#root/_help_mVEYwt20exhO\">Custom AI quick actions</a>.</li></ul><h2>Feature highlights</h2><ul><li>Chat-based interface with live streaming of the messages.</li><li>Provides the AI context with the note currently being looked at.</li><li>Tools to alter note content, create new notes, etc.</li><li>Statistics regarding context window use and pricing per message.</li><li>Attachments for multi-modal chat (images, text files, PDFs).</li><li>Optional MCP to allow external chat tools (e.g. Claude Code) to operate on notes within Trilium.</li></ul><h2>Sample use-cases</h2><ul><li>Create any type of <a class=\"reference-link\" href=\"#root/_help_MgibgPcfeuGz\">Custom Widgets</a>.</li><li>Easily create a <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>, e.g. <em>Create for me a render note which allows me to play tic-tac-toe. Make sure to use Preact instead of the legacy jQuery.</em></li><li>Create widgets for a <a class=\"reference-link\" href=\"#root/_help_IF7Q6I9x7zuw\">Dashboard</a>, such as a calculator, a stopwatch, a pomodoro timer.</li></ul><aside class=\"admonition note\"><p>Claude Sonnet is known to produce very good frontend or backend scripts with little guidance, as the AI has been instructed in how to produce them.</p></aside><h2>LLM Providers</h2><p>Trilium supports four different types of providers:</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-cloud\"></span> Cloud</p><div class=\"trilium-tab-panel\"><p>Pay-per use with an API key which is billed separately from any subscription you might already have.</p><ul><li><span class=\"tn-icon tn-brand tn-brand-anthropic\"></span> Anthropic Claude</li><li><span class=\"tn-icon tn-brand tn-brand-openai\"></span> OpenAI GPT</li><li><span class=\"tn-icon tn-brand tn-brand-gemini\"></span> Google Gemini</li><li><span class=\"tn-icon tn-brand tn-brand-deepseek\"></span> DeepSeek</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-coin\"></span> Subscription-based</p><div class=\"trilium-tab-panel\"><p>Reuses an existing subscription instead of paying per use.</p><ul><li><span class=\"tn-icon tn-brand tn-brand-claude\"></span> <a href=\"#root/_help_eFhxp9laTW1S\">Claude Code</a></li><li><span class=\"tn-icon tn-brand tn-brand-github-copilot\"></span> <a href=\"#root/_help_eFhxp9laTW1S\">GitHub Copilot</a></li><li><span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <a href=\"#root/_help_eFhxp9laTW1S\">Google Antigravity</a></li><li><span class=\"tn-icon tn-brand tn-brand-codex\"></span> <a href=\"#root/_help_eFhxp9laTW1S\">OpenAI Codex</a></li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-network-chart\"></span> Local/self-hosted</p><div class=\"trilium-tab-panel\"><ul><li><span class=\"tn-icon tn-brand tn-brand-ollama\"></span> Ollama</li><li><span class=\"tn-icon tn-brand tn-brand-lmstudio\"></span> LM Studio</li></ul></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-code-curly\"></span> Custom endpoints</p><div class=\"trilium-tab-panel\"><p>For other providers that are not directly supported by Trilium, either local or hosted (e.g. OpenRouter, Groq, Mistral).</p></div></section></div><aside class=\"admonition tip\"><p>For more information about each provider, see <a class=\"reference-link\" href=\"#root/_help_bkPZAMT7d2sR\">Providers</a>. See the dedicated <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> to better understand what data is sent to providers.</p></aside><h2>Enabling the AI integration</h2><p>To enable the AI integration, simply go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and press the toggle in the top-right of the dialog and configure a provider.</p><h2>Creating a new chat</h2><p>There are two different chat interfaces:</p><ul><li>One in the sidebar.</li><li>A dedicated note type.</li></ul><h3>The sidebar interface</h3><h3>The dedicated note type</h3><p>The dedicated chat note is similar to the sidebar interface, but it makes longer conversations more comfortable to read.</p><p>Unlike the sidebar, the AI will not be aware of the current note it's in.</p><h3>Templates</h3><p>Chat notes can be set as <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> to make them easily reusable. The entire conversation history is kept, allowing a basic form of specialization for the LLM with the existing chat acting like a system prompt. </p><h3>Model selection</h3><p>When a provider is configured in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>, the next step is to select the models that will be available for the chat.</p><p>The models are retrieved dynamically from the provider, only when the model selection list is visible. To alter the list of models, simply press the Edit button in the model selection box.</p><p>Pricing information is displayed for known models. The pricing information (price per million tokens) is embedded in the application (using a subset of LiteLLM's data) and is updated with new versions of Trilium. Local providers are considered free, whereas custom endpoint providers don't offer any pricing information.</p><h2>Features</h2><h3>Web search</h3><p>The AI can optionally search the web to find more information about a specific topic. </p><p>Where the search comes from is chosen in the <em>Web search</em> submenu of the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> menu next to the model selector at the bottom of the chat, whose row shows the source in use:</p><ul><li><em>Disabled</em> turns web search off for this chat.</li><li><em>Use the model's built-in search</em>, the default, lets the model search with its provider's own search. Anthropic, OpenAI, Google Gemini and DeepSeek models have one, as do Claude Code, Google Antigravity and OpenAI Codex. Ollama, LM Studio and custom endpoints don't, so this choice is disabled for their models. DeepSeek's search is billed per search on your DeepSeek account and works only with DeepSeek's own endpoint, not with a custom base URL.</li><li>A search provider (Brave Search, Tavily, Exa, Serper, Perplexity or SearXNG) searches through that service instead, whichever model is answering. Search providers are added in the <em>Search Providers</em> section of the AI settings, which <em>Manage search providers</em> at the bottom of the submenu opens. The browser version can't use Brave Search, Exa or Perplexity, whose services refuse requests made from a web page, so they're shown disabled there.</li></ul><p>To use SearXNG, enable its JSON output by adding <code>json</code> to the search formats in the instance's <code>settings.yml</code>. SearXNG turns JSON off by default, and without it every search fails.</p><pre><code class=\"language-text-x-yaml\">search:\n formats:\n - html\n - json</code></pre><p>SearXNG doesn't use API keys, so leave the API key empty. Fill it in only if your instance sits behind a proxy that requires a token; Trilium sends it as a bearer token in the <code>Authorization</code> header.</p><p>Whether web search is on is kept per chat; the search source is shared by all chats. A choice the current model can't use stays in the menu, disabled; hover the <span class=\"tn-icon bx bx-info-circle\"></span>icon next to it to see why. Claude Code, GitHub Copilot, Google Antigravity and OpenAI Codex run their own tools, so they can't use a search provider.</p><p>In the chat, a search run through a search provider shows that provider's logo at the start of its line instead of the <span class=\"tn-icon bx bx-search\"></span>magnifier; hover the logo to see the provider's name.</p><p>With a search provider, the model can also read the pages it finds, or a link you give it, as text: Trilium fetches the page itself and hands the model up to its first 20,000 characters. Addresses on your own machine or network are refused. In the browser version most sites don't allow being read this way, so reading a page there usually fails.</p><h3>Thinking</h3><p>Some models reason before they answer. While the model is thinking, its reasoning is shown in full under a spinner; once it is done, it folds into a collapsible <em>Thought process</em> line above the reply.</p><p>How much a model thinks is set per chat, in one of two ways depending on the model:</p><ul><li>Most models have an <span class=\"tn-icon bx bx-brain\"></span><em>Extended thinking</em> button, next to the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> button.</li><li>Models that offer several levels of reasoning (DeepSeek V4, OpenAI Codex, Antigravity) have a <span class=\"tn-icon bx bx-brain\"></span>reasoning effort dropdown next to the model selector instead. <em>None</em>, where offered, turns thinking off; higher levels give better answers to hard questions, but take longer and cost more.</li></ul><aside class=\"admonition note\"><p>The effort dropdown only appears once Trilium knows the model's levels. For a DeepSeek provider set up with an earlier version of Trilium, edit the provider in the model selection box and press <em>Save</em> once.</p></aside><h3>Note access (tools)</h3><p>Tools allow the agentic AI to understand and operate on notes directly within your Trilium instance.</p><p>This feature is on by default. To turn it off, press the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> button next to the model selector at the bottom of the chat and switch off <em>Note access</em>. The <em>Tools</em> button is highlighted while note access or web search is on.</p><p>Here are a few tools that Trilium provides for the LLM:</p><ul><li>At note level:<ul><li>Search for notes</li><li>Get the metadata or content of a note.</li><li>Edit a note<ul><li>There are multiple mechanism for the LLM to edit a note: completely by re-writing it, find/replace of a text sequence or append.</li><li>When re-writing a note, the LLM can also change its type (for example from a text note to a code note) or the language of a code note, rewriting the content to match.</li><li>Whenever the AI makes a change, a <a href=\"#root/_help_vZWERwf8U3nx\">revision</a> is saved to be able to revert any unwanted changes.</li></ul></li><li>Create a new note<ul><li>Asked for a drawing, the LLM can create an SVG image note, or turn an existing note into one. It can write only SVG images, not other formats such as PNG.</li></ul></li><li>Rename or delete a note.</li></ul></li><li>At attribute level:<ul><li>Get the full list of attributes, or a specific attribute.</li><li>Set the value of an attribute.<ul><li>An attribute that runs code, such as <code>#run</code>, <code>#widget</code> or <code>~renderNote</code>, is saved with a <code>disabled:</code> prefix (for example <code>#disabled:widget</code>), the same way a safe import disables it (see <a class=\"reference-link\" href=\"#root/_help_YzMcWlCVeW09\">Active content</a>). If the note already had that attribute enabled, the AI removes it, so none of it runs until you enable the new value. The AI tells you which note it is on; review the code, then enable it with the toggle next to the active content badge beside the note's title or, for a <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>, the <em>Enable render note</em> button in the note.</li></ul></li><li>Delete an attribute.</li></ul></li><li>At tree level:<ul><li>Get the direct children of a note.</li><li>Get the entire subtree of a note.</li><li>Move or clone a note somewhere else.</li></ul></li><li>For <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>:<ul><li>Get metadata for an attachment.</li><li>Get the content of an attachment.</li></ul></li><li>Skills (see the dedicated section).</li></ul><p>Each tool the AI uses appears in the chat as a single line naming the tool and the note or query it worked on; a renamed note shows its previous title struck through, a deleted note its title struck through, a moved note where it was moved from and to, an attribute the AI read, set or deleted as a pill (struck through once deleted), an attachment by its title, note and size, and a web page the AI read as a link. A line folds open only when there is something to read inline: the notes a search found, the pages a web search found, the icons an icon search found, the type, attributes or start of the content of a note the AI read, all the attributes of a note, the text of an attachment or of a web page, the User Guide pages the AI looked up or its table of contents (both open in the help panel), the children or the whole subtree of a note, what the AI wrote into a note it created, rewrote or added to, the changes of an edit, or the reason a tool failed. A search names on its line the part of the tree it is confined to, if any, and also shows how many notes it found and how many of the matches the AI asked for; each note it lists opens with a click. To see exactly what the AI sent to a tool and what it got back, hover the line and press the <span class=\"tn-icon bx bx-code-alt\"></span>button next to it; on touch screens the button is always shown.</p><p>When the reply stops moving for a couple of seconds while the AI is still at work, for example while it reads what a tool returned, a <em>Still working…</em> line appears under it until the next part of the reply arrives.</p><h4>Approving tool calls</h4><p>Before the AI runs a tool, the chat asks whether to allow it. The tool's line is marked with a <span class=\"tn-icon bx bxs-hand\"></span>icon and has <em>Allow</em> and <em>Deny</em> buttons below it. When the call would write to a note, the line opens on the text it would write or the changes of an edit. The reply waits until you answer.</p><ul><li>To let the call run, press <em>Allow</em>.</li><li>To stop asking about a tool for the rest of the chat, open the menu next to <em>Allow</em> and choose to always allow that tool for this chat. The call runs, and so do the other calls of that tool still waiting and every later one in this chat. Other tools keep asking, and a new chat asks again.</li><li>To refuse it, press <em>Deny</em>. The AI is told that you declined, and its reply carries on without the call, which is marked <em>denied</em>.</li><li>Stopping the reply denies every call that is still waiting.</li></ul><p>To make a chat ask about a tool again, open the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> menu at the bottom of the chat and, under <em>Allowed in this chat</em>, press the tool. The submenu is shown once the chat has allowed a tool.</p><p>Which calls ask depends on the chat's permission mode, chosen in the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> menu under <em>Permissions</em>:</p><ul><li><em>Always ask</em>: every call asks, including the ones that only read (searching notes, or reading a note or an attachment).</li><li><em>Ask before changes</em>: the calls that only read run on their own, and the ones that change your notes (creating, editing, renaming, moving or deleting a note, and setting or deleting an attribute) ask.</li><li><em>Don't ask</em>: every call runs without asking, changes included.</li></ul><p>A new chat starts in the mode you picked last, in any chat, or in <em>Ask before changes</em> until you pick one. Picking <em>Don't ask</em> therefore carries over to the next chat too.</p><p>A tool allowed for the chat runs without asking in every mode. So does looking something up in what ships with Trilium (its User Guide, the skill sheets that teach the AI Trilium's search syntax and note types, and the icons), since it reads none of your notes. Searching the web and reading a web page never ask either: turning on web search in the <em>Tools</em> menu is what allows them, whether the model searches on its own or through a search provider.</p><aside class=\"admonition note\"><p>The <a class=\"reference-link\" href=\"#root/_help_eFhxp9laTW1S\">Subscription-based providers</a> (Claude Code, GitHub Copilot, Google Antigravity and OpenAI Codex) ask like any other provider.</p></aside><aside class=\"admonition note\"><p>Most changes you allow can be undone: a deleted note can be restored, and an edit reverted from its revision. Setting an attribute is harder to undo, since attributes have no history.</p></aside><aside class=\"admonition note\"><p>Gemini can't use its built-in search while note access is on. While it is, the built-in search choice in the <em>Tools</em> menu is disabled and says why; a search provider works with note access on.</p></aside><h3>Attachments</h3><p>Since Trilium v0.140.0, <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> allow for multi-modal chat:</p><ul><li>Raster image (sent as vision input, except for SVGs) with the following supported formats: PNG, JPEG, GIF, WebP.</li><li>PDFs, sent natively to the provider (supported by Anthropic, OpenAI and Google).</li><li>SVG images (sent as raw HTML).</li><li>Text files.</li></ul><p>Not every model reads every kind of attachment: DeepSeek reads no PDFs, and images only with its vision models; OpenAI Codex, GitHub Copilot and Google Antigravity read images but no PDFs. For such a model:</p><ul><li>The attach button offers only the kinds the model reads, and a pasted or dropped file it can't read is not attached.</li><li>After switching to such a model, an attachment it can't read is marked with a <span class=\"tn-icon bx bx-error\"></span>warning, and the message can't be sent until the attachment is removed or another model is selected.</li><li>An attachment sent in an earlier message reaches the model as its name only, such as <code>[attached file: report.pdf]</code>, so it can tell you it doesn't see the content.</li></ul><p>To upload an attachment:</p><ul><li>Press the dedicated <em>Attach</em> button (paperclip icon) underneath the text box.</li><li>Paste an image directly from clipboard using Ctrl+V.</li></ul><p>Once one or more attachments are uploaded, they will appear directly above the text box:</p><ul><li>Images have a small thumbnail for easy identifications.</li><li>Every attachment can be deleted by pressing their corresponding X button.</li></ul><p>Clicking an image or a PDF, either its chip above the text box or where it appears in a sent message, opens it in a viewer: an image can be zoomed and panned there, a PDF read page by page. The button next to the viewer's close button opens the original file in a new browser tab. <kbd>Ctrl</kbd>-clicking instead opens an image in a new browser tab, and a PDF as an attachment in a new Trilium tab.</p><p>When an attachment is present, the LLM is instructed to consider the attachment with priority, even if it has access to the current note.</p><aside class=\"admonition note\"><p>Currently Trilium doesn't pre-process the attachments (e.g. via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a>) before sending them to the LLM provider.</p></aside><h3>Mentions</h3><p>Mentions are a way to insert references to notes other than the current note, using the same mechanism as <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>. To refer to another note, simply type @ followed by the name of the note to reference.</p><p>This feature is mostly helpful when note tools are enabled, otherwise the LLM will have no way to access the given note.</p><h3>Skills</h3><p>Skills in Trilium are specialized instruction sets that help the AI be more productive by understanding how Trilium.</p><p>These skills are not loaded by default to avoid an increased consumption of tokens, but the AI can load them on-demand if <em>Note tools</em> are enabled.</p><p>The following skills are built-in:</p><ul><li>Search syntax: understands the full syntax of <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>.</li><li>Backend scripting: to be able to write proper <a class=\"reference-link\" href=\"#root/_help_SPirpZypehBG\">Backend scripts</a>.</li><li>Frontend scripting: to be able to write proper <a href=\"#root/_help_yIhgI5H7A2Sm\">front-end scripts</a> (basic scripts, widgets, <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>).</li><li>Dashboards: to build a <a class=\"reference-link\" href=\"#root/_help_IF7Q6I9x7zuw\">Dashboard</a> and its widgets, including interactive ones made with a <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>.</li></ul><p>When <em>Note tools</em> are enabled the skills will automatically be made available to the AI, so no user interaction is required.</p><aside class=\"admonition note\"><p>Custom skills are currently not supported but they are planned.</p></aside><h3>MCP</h3><p>Trilium comes with a built-in MCP server which allows you to use an external agent such as Claude Code have access to your database. See the dedicated <a class=\"reference-link\" href=\"#root/_help_KOWBFgsZXJAD\">MCP</a> page for more details.</p><h2>History</h2><h3>Removal in v0.102.0</h3><p>Starting with version v0.102.0, AI/LLM integration has been removed from the Trilium Notes core.</p><p>While a significant amount of effort went into developing this feature, maintaining and supporting it long-term proved to be unsustainable.</p><p>When upgrading to v0.102.0, your Chat notes will be preserved, but instead of the dedicated chat window they will be turned to a normal <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note, revealing the underlying JSON of the conversation.</p><h3>Reintroduction in v0.103.0</h3><p>Given the recent advancements of the AI scene, we decided to give the LLM integration another try. v0.103.0 introduces a completely new chat system.</p><p>One of the key changes that lead to the reimplementation is that now we are using a library (<a href=\"https://github.com/vercel/ai\">Vercel AI</a>) to manage the inner mechanism and the differences between LLM providers instead of having to implement it on our own.</p>","_help_bkPZAMT7d2sR": "<p>Providers are added in the <em>Model Providers</em> section of the AI settings, with <em>Add Model Provider</em>. Each one lists the models selected for it, which are the ones the chat offers; a provider with no models selected is not offered in the chat.</p><h2>Cloud providers using API keys</h2><p>Currently, the following cloud providers are supported:</p><ul><li><span class=\"tn-icon tn-brand tn-brand-anthropic\"></span> <a href=\"https://platform.claude.com/settings/workspaces/default/keys\">Anthropic</a></li><li><span class=\"tn-icon tn-brand tn-brand-openai\"></span> OpenAI</li><li><span class=\"tn-icon tn-brand tn-brand-gemini\"></span> Gemini</li><li><span class=\"tn-icon tn-brand tn-brand-deepseek\"></span> DeepSeek</li></ul><p>For all the providers, an API key is needed. Note that this is charged separately from the subscription you might already have (e.g. Claude Pro). If that might be a problem, consider using either a subscription provider (see below) or using it externally via MCP.</p><p>Do note that most other LLM providers (e.g. OpenRouter, Groq, Mistral) can still be used in Trilium via the OpenAI-compatible custom endpoint (see below).</p><p>If you are using a proxy or gateway, you can also configure the base URL, otherwise the default will be used.</p><p>For Gemini, a chat that doesn't specify a model uses <code>gemini-3.8-flash</code>, and the automatically generated chat titles use <code>gemini-3.5-flash-lite</code>. A model you select explicitly is used as is and isn't affected by these defaults.</p><aside class=\"admonition note\"><p>We don't plan to support all cloud providers, even if the library we are using would theoretically support them. Before opening a PR adding support for a different cloud provider, make sure to discuss it over <a href=\"https://github.com/orgs/TriliumNext/discussions\">GitHub Discussions</a>.</p></aside><aside class=\"admonition important\"><p>See also the dedicated <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> section to better understand what data is being sent to a cloud provider.</p></aside><h2>Subscription-based providers</h2><p>Trilium integrates multiple <a class=\"reference-link\" href=\"#root/_help_eFhxp9laTW1S\">Subscription-based providers</a>:</p><ul><li><span class=\"tn-icon tn-brand tn-brand-claude\"></span> Claude Code by reusing your CLI.</li><li><span class=\"tn-icon tn-brand tn-brand-github-copilot\"></span> GitHub Copilot by reusing your CLI's ACP.</li><li><span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> Google Antigravity by downloading and setting up an ACP for Trilium.</li><li><span class=\"tn-icon tn-brand tn-brand-codex\"></span> OpenAI Codex by reusing your CLI through an ACP adapter shipped with Trilium.</li></ul><h2>Local/self-hosted providers</h2><p>Local or self-hosted providers are a free alternative which respects your privacy but requires specific hardware.</p><p>Trilium directly supports the following local providers:</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon tn-brand tn-brand-ollama\"></span> Ollama</p><div class=\"trilium-tab-panel\"><p>Generally Ollama runs in the background so it should be directly usable in Trilium as long as the models are downloaded (e.g. <code>ollama pull llama3.2</code>).</p></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon tn-brand tn-brand-lmstudio\"></span> LM Studio</p><div class=\"trilium-tab-panel\"><p>The OpenAI-compatible server is <strong>disabled</strong> by default in LM Studio installations. First download your desired models through the graphical interface, then go to <em>Settings</em> → <em>Developer</em> and toggle <em>Developer mode</em>. On the left there will be a new <em>Developer</em> tab, with a toggle to start it up.</p></div></section></div><p>Even for local providers that are not directly supported by Trilium, you can still use a custom endpoint (see below).</p><aside class=\"admonition warning\"><p>When dealing with self-hosted LLM models, depending on the training and the size of the model, the quality of the output may vary. Before <a href=\"#root/_help_wy8So3yZZlH9\">reporting issues</a> regarding the quality of the output (e.g. hallucinating tool calls), consider benchmarking the response against a cloud provider (Claude Sonnet is recommended).</p></aside><h2>Custom endpoints</h2><p>If your desired hosted (e.g. OpenRouter, Groq, Mistral) or local LLM provider is not listed in Trilium, you can use the dedicated <em>OpenAI-compatible</em> provider from the <em>Custom endpoint</em> section.</p><p>This allows you to set the base URL to an OpenAI-compatible API, with an optional API key if required by the service.</p><p>Enter the base URL exactly as the service documents it, including its version path, such as <code>https://api.groq.com/openai/v1</code> or <code>https://open.bigmodel.cn/api/paas/v4</code>. Only a bare host such as <code>http://localhost:8080</code> is completed with <code>/v1</code>.</p><p>The endpoint can run on the same machine as Trilium, elsewhere on your local network or on a Tailscale tailnet. Trilium refuses link-local addresses (<code>169.254.0.0/16</code>) and cloud metadata endpoints, which no model server is served on.</p><p>For custom endpoints, the pricing of the models is not known so the cost of a conversation will not be displayed; this is especially relevant for hosted providers.</p>",- "_help_eFhxp9laTW1S": "<p>Some cloud providers offer a subscription, which has a fixed monthly fee instead of pay-per-use (unlike the API keys).</p><p>In a nutshell, subscription-based providers work by either reusing your existing CLI tools (e.g. Claude Code, GitHub Copilot and OpenAI Codex via ACP) whereas some require installing the ACP server manually (e.g. Google Antigravity). Because they require something to be installed on your device, these providers are not available on Mobile (Android or iOS) or standalone mode.</p><p>See also the dedicated <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> section to better understand what data is being sent to a cloud provider.</p><h2><span class=\"tn-icon tn-brand tn-brand-claude\"></span> Claude Code</h2><p>To use a subscription:</p><ol><li>First, Claude Code needs to be installed on the machine that runs Trilium. So for a <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>, Claude needs to be installed locally and for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> accessed via a browser, Claude needs to be installed on the server.</li><li>Claude Code must already be authenticated. To do so, run <code>claude</code> in a terminal once, type <code>/login</code> and follow the instructions.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the Claude Code provider.</li></ol><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Claude Code binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_CLAUDE_CODE_PATH</code> environment variable pointing to the Claude binary. This allows overriding the path if needed.</li><li>By looking for <code>claude</code> in your PATH, generally works in most circumstances.</li><li>By asking your login shell for its <code>PATH</code> which lets a desktop install find a CLI installed through <code>nvm</code>, <code>fnm</code>, <code>asdf</code> or Homebrew, since a GUI-launched app doesn't inherit your terminal's environment.</li></ul></details><p>After your provider is set up, you'll benefit from the same features as an API key (note tools, web search, extended thinking, image/PDF attachments, streaming).</p><aside class=\"admonition note\"><p>Trilium intentionally uses your Claude Code binary in order not to have to package a ~250 MB client with it, but this comes at a cost: there is a small risk for a version incompatibility, if the version installed locally doesn't match the one expected by Trilium. Generally it's best to keep both Claude Code and Trilium updated to the latest version.</p></aside><h2><span class=\"tn-icon tn-brand tn-brand-github-copilot\"></span> GitHub Copilot</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>GitHub Copilot gives access to the models of your GitHub Copilot subscription (Pro, Pro+, Business or Enterprise), without an API key. Usage counts against your Copilot plan.</p><ol><li>Install the GitHub Copilot CLI on the machine that runs Trilium, for example with <code>npm install -g @github/copilot</code>. As with Claude Code, for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> it needs to be installed on the server.</li><li>Sign in by running <code>copilot login</code> in a terminal once. If you already use GitHub Copilot in another editor on the same machine, that login is reused.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the GitHub Copilot provider.</li></ol><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Copilot CLI binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_COPILOT_PATH</code> environment variable pointing to the Copilot binary.</li><li>By looking for <code>copilot</code> in your PATH.</li><li>By asking your login shell for its <code>PATH</code>, the same as for Claude Code.</li></ul></details><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools; its own file, shell and web tools are blocked for security reasons.</li><li>Images can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li></ul><h2><span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> Google Antigravity</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>Google Antigravity gives access to Gemini models using a Google account (free, Google AI Pro or Google AI Ultra), without an API key. At the time of writing, a free Google account is enough to use it.</p><p>Unlike Claude Code or GitHub Copilot, Google's Antigravity ACP server is not part of the CLI so it needs to be installed manually just for Trilium. The downloaded archive is around 112-334 MB and the extracted size is around 230 MB-2 GB based on the platform.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span> Windows</p><div class=\"trilium-tab-panel\"><ol><li>Download Google's Antigravity ACP server for your platform. The link is shown when adding the provider in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>. Unpack it on the device that runs Trilium.</li><li>Make it findable by Trilium, either:<ol><li>by adding the unpacked folder to your PATH, or</li><li>by setting a <code>TRILIUM_ANTIGRAVITY_ACP_PATH</code> environment variable pointing to <code>agy_acp_server.exe</code>.</li></ol></li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span> Linux & <span class=\"tn-icon bx bxl-apple\"></span> macOS</p><div class=\"trilium-tab-panel\"><ol><li>Download Google's Antigravity ACP server for your platform. The link is shown when adding the provider in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>. Unpack it on the device that runs Trilium.</li><li>Make it findable by Trilium, either:<ol><li>by adding the unpacked folder to your PATH, or</li><li>by setting a <code>TRILIUM_ANTIGRAVITY_ACP_PATH</code> environment variable pointing to <code>agy_acp_server.par</code>.</li></ol></li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">NixOS</p><div class=\"trilium-tab-panel\"><ol><li><p>On NixOS, <code>antigravity-acp</code> package is already available but only in <code>nixos-unstable</code> at the time of writing. The easiest method to test it out is to use the <code>nix shell</code> with flakes:</p><pre><code class=\"language-text-x-trilium-auto\">NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:nixos/nixpkgs/nixos-unstable#antigravity-acp\ntrilium</code></pre></li><li><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</p></li></ol></div></section></div><aside class=\"admonition note\"><p>Trilium needs <code>curl</code> to use Google Antigravity. It comes with Windows 10 and later, macOS and most Linux distributions.</p></aside><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools; its own file and shell tools are blocked for security reasons.</li><li>The Antigravity ACP server requires authentication via a login link. The login link needs to be run on the same device, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a> should work fine.</li><li>Images can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li><li>The results of tool calls (e.g. reading a note, writing attributes) are not properly displayed because they are not exposed by the ACP server.</li></ul><h2><span class=\"tn-icon tn-brand tn-brand-codex\"></span> OpenAI Codex</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>OpenAI Codex gives access to the Codex models of your ChatGPT plan (Free, Go, Plus, Pro or Business), without an API key. At the time of writing, a free ChatGPT account is enough to use it. Usage counts against your plan's Codex limits, which are small on the Free plan.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span><span class=\"tn-icon bx bxl-tux\"></span><span class=\"tn-icon bx bxl-apple\"></span> Most platforms</p><div class=\"trilium-tab-panel\"><ol><li>Install the Codex CLI on the machine that runs Trilium, for example with <code>npm install -g @openai/codex</code>. As with Claude Code, for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> it needs to be installed on the server. Trilium ships the ACP adapter that connects to it, so nothing else is needed.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the <span class=\"tn-icon tn-brand tn-brand-codex\"></span> <em>OpenAI Codex</em> provider. When the list of models is loaded for the first time, the ChatGPT sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">NixOS</p><div class=\"trilium-tab-panel\"><ol><li><p>On NixOS, Codex is available as the <code>codex</code> package in nixpkgs. The stable channel can lag behind Codex's releases, so a newer version can be taken from <code>nixos-unstable</code>:</p><pre><code class=\"language-text-x-sh\">nix shell github:nixos/nixpkgs/nixos-unstable#codex\ntrilium</code></pre></li><li><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the <span class=\"tn-icon tn-brand tn-brand-codex\"></span> <em>OpenAI Codex</em> provider. When the list of models is loaded for the first time, the ChatGPT sign-in page opens in a browser on the machine running Trilium; finish signing in there.</p></li></ol></div></section></div><p>Trilium keeps its own Codex sign-in and settings, separate from any Codex CLI you use in a terminal, so an existing <code>codex login</code> is not reused.</p><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Codex CLI binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_CODEX_PATH</code> environment variable pointing to the Codex binary.</li><li>By looking for <code>codex</code> in your PATH.</li><li>By asking your login shell for its <code>PATH</code>, the same as for Claude Code.</li></ul></details><aside class=\"admonition note\"><p>Trilium needs <code>curl</code> to use OpenAI Codex, the same as for Google Antigravity: Trilium checks every tool call Codex makes through it. It comes with Windows 10 and later, macOS and most Linux distributions.</p></aside><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools, and search the web when the chat allows it; its own file, shell and other tools are blocked for security reasons.</li><li>The ChatGPT sign-in opens in a browser on the device running Trilium, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a> should work fine.</li><li>Images and SVGs can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li></ul>",+ "_help_eFhxp9laTW1S": "<p>Some cloud providers offer a subscription, which has a fixed monthly fee instead of pay-per-use (unlike the API keys).</p><p>In a nutshell, subscription-based providers work by either reusing your existing CLI tools (e.g. Claude Code, GitHub Copilot and OpenAI Codex via ACP) whereas some require installing the ACP server manually (e.g. Google Antigravity). Because they require something to be installed on your device, these providers are not available on Mobile (Android or iOS) or standalone mode.</p><p>See also the dedicated <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> section to better understand what data is being sent to a cloud provider.</p><h2>Using the Flatpak</h2><p>The Flatpak version of Trilium (see <a href=\"#root/_help_poXkQfguuA0U\">Installing from Flathub</a>) runs in a sandbox that hides the programs installed on your computer, so on its own it cannot find Claude Code, the GitHub Copilot CLI, the Codex CLI or Google's Antigravity ACP server. Trilium can start them outside the sandbox once you allow it to:</p><ol><li><p>Install the CLI on your computer and sign in to it, as described below for each provider.</p></li><li><p>Allow Trilium to start programs outside its sandbox by running this in a terminal:</p><pre><code class=\"language-text-x-sh\">flatpak override --user --talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium</code></pre></li><li><p>Restart Trilium, then go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the provider.</p></li></ol><p>Trilium then looks the CLI up in your computer's <code>PATH</code> and in your login shell's, and starts it there through <code>flatpak-spawn --host</code>. Until the permission is granted, adding one of these providers fails with a message that repeats these steps.</p><aside class=\"admonition warning\"><p>This permission lets Trilium run any program on your computer outside the sandbox, which is the same access an installation outside Flatpak has. To take it back, run <code>flatpak override --user --no-talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium</code> and restart Trilium.</p></aside><p>The environment variables that point Trilium at a CLI (such as <code>TRILIUM_CLAUDE_CODE_PATH</code>) name a file inside the sandbox, so with the Flatpak, leave them unset and let Trilium find the CLI on your computer.</p><h2><span class=\"tn-icon tn-brand tn-brand-claude\"></span> Claude Code</h2><p>To use a subscription:</p><ol><li>First, Claude Code needs to be installed on the machine that runs Trilium. So for a <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>, Claude needs to be installed locally and for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> accessed via a browser, Claude needs to be installed on the server.</li><li>Claude Code must already be authenticated. To do so, run <code>claude</code> in a terminal once, type <code>/login</code> and follow the instructions.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the Claude Code provider.</li></ol><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Claude Code binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_CLAUDE_CODE_PATH</code> environment variable pointing to the Claude binary. This allows overriding the path if needed.</li><li>By looking for <code>claude</code> in your PATH, generally works in most circumstances.</li><li>By asking your login shell for its <code>PATH</code> which lets a desktop install find a CLI installed through <code>nvm</code>, <code>fnm</code>, <code>asdf</code> or Homebrew, since a GUI-launched app doesn't inherit your terminal's environment.</li></ul></details><p>After your provider is set up, you'll benefit from the same features as an API key (note tools, web search, extended thinking, image/PDF attachments, streaming).</p><aside class=\"admonition note\"><p>Trilium intentionally uses your Claude Code binary in order not to have to package a ~250 MB client with it, but this comes at a cost: there is a small risk for a version incompatibility, if the version installed locally doesn't match the one expected by Trilium. Generally it's best to keep both Claude Code and Trilium updated to the latest version.</p></aside><h2><span class=\"tn-icon tn-brand tn-brand-github-copilot\"></span> GitHub Copilot</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>GitHub Copilot gives access to the models of your GitHub Copilot subscription (Pro, Pro+, Business or Enterprise), without an API key. Usage counts against your Copilot plan.</p><ol><li>Install the GitHub Copilot CLI on the machine that runs Trilium, for example with <code>npm install -g @github/copilot</code>. As with Claude Code, for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> it needs to be installed on the server.</li><li>Sign in by running <code>copilot login</code> in a terminal once. If you already use GitHub Copilot in another editor on the same machine, that login is reused.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the GitHub Copilot provider.</li></ol><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Copilot CLI binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_COPILOT_PATH</code> environment variable pointing to the Copilot binary.</li><li>By looking for <code>copilot</code> in your PATH.</li><li>By asking your login shell for its <code>PATH</code>, the same as for Claude Code.</li></ul></details><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools; its own file, shell and web tools are blocked for security reasons.</li><li>Images can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li></ul><h2><span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> Google Antigravity</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>Google Antigravity gives access to Gemini models using a Google account (free, Google AI Pro or Google AI Ultra), without an API key. At the time of writing, a free Google account is enough to use it.</p><p>Unlike Claude Code or GitHub Copilot, Google's Antigravity ACP server is not part of the CLI so it needs to be installed manually just for Trilium. The downloaded archive is around 112-334 MB and the extracted size is around 230 MB-2 GB based on the platform.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span> Windows</p><div class=\"trilium-tab-panel\"><ol><li>Download Google's Antigravity ACP server for your platform. The link is shown when adding the provider in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>. Unpack it on the device that runs Trilium.</li><li>Make it findable by Trilium, either:<ol><li>by adding the unpacked folder to your PATH, or</li><li>by setting a <code>TRILIUM_ANTIGRAVITY_ACP_PATH</code> environment variable pointing to <code>agy_acp_server.exe</code>.</li></ol></li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span> Linux & <span class=\"tn-icon bx bxl-apple\"></span> macOS</p><div class=\"trilium-tab-panel\"><ol><li>Download Google's Antigravity ACP server for your platform. The link is shown when adding the provider in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>. Unpack it on the device that runs Trilium.</li><li>Make it findable by Trilium, either:<ol><li>by adding the unpacked folder to your PATH, or</li><li>by setting a <code>TRILIUM_ANTIGRAVITY_ACP_PATH</code> environment variable pointing to <code>agy_acp_server.par</code>.</li></ol></li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">NixOS</p><div class=\"trilium-tab-panel\"><ol><li><p>On NixOS, <code>antigravity-acp</code> package is already available but only in <code>nixos-unstable</code> at the time of writing. The easiest method to test it out is to use the <code>nix shell</code> with flakes:</p><pre><code class=\"language-text-x-trilium-auto\">NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:nixos/nixpkgs/nixos-unstable#antigravity-acp\ntrilium</code></pre></li><li><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI / LLM and add the <span class=\"tn-icon tn-brand tn-brand-antigravity\"></span> <em>Google Antigravity</em> provider. When the list of models is loaded for the first time, the Google sign-in page opens in a browser on the machine running Trilium; finish signing in there.</p></li></ol></div></section></div><aside class=\"admonition note\"><p>Trilium needs <code>curl</code> to use Google Antigravity. It comes with Windows 10 and later, macOS and most Linux distributions.</p></aside><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools; its own file and shell tools are blocked for security reasons.</li><li>The Antigravity ACP server requires authentication via a login link. The login link needs to be run on the same device, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a> should work fine.</li><li>Images can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li><li>The results of tool calls (e.g. reading a note, writing attributes) are not properly displayed because they are not exposed by the ACP server.</li></ul><h2><span class=\"tn-icon tn-brand tn-brand-codex\"></span> OpenAI Codex</h2><aside class=\"admonition note\"><p>This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class=\"reference-link\" href=\"#root/_help_wy8So3yZZlH9\">Reporting issues</a>.</p></aside><p>OpenAI Codex gives access to the Codex models of your ChatGPT plan (Free, Go, Plus, Pro or Business), without an API key. At the time of writing, a free ChatGPT account is enough to use it. Usage counts against your plan's Codex limits, which are small on the Free plan.</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span><span class=\"tn-icon bx bxl-tux\"></span><span class=\"tn-icon bx bxl-apple\"></span> Most platforms</p><div class=\"trilium-tab-panel\"><ol><li>Install the Codex CLI on the machine that runs Trilium, for example with <code>npm install -g @openai/codex</code>. As with Claude Code, for a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> it needs to be installed on the server. Trilium ships the ACP adapter that connects to it, so nothing else is needed.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the <span class=\"tn-icon tn-brand tn-brand-codex\"></span> <em>OpenAI Codex</em> provider. When the list of models is loaded for the first time, the ChatGPT sign-in page opens in a browser on the machine running Trilium; finish signing in there.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\">NixOS</p><div class=\"trilium-tab-panel\"><ol><li><p>On NixOS, Codex is available as the <code>codex</code> package in nixpkgs. The stable channel can lag behind Codex's releases, so a newer version can be taken from <code>nixos-unstable</code>:</p><pre><code class=\"language-text-x-sh\">nix shell github:nixos/nixpkgs/nixos-unstable#codex\ntrilium</code></pre></li><li><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em> and add the <span class=\"tn-icon tn-brand tn-brand-codex\"></span> <em>OpenAI Codex</em> provider. When the list of models is loaded for the first time, the ChatGPT sign-in page opens in a browser on the machine running Trilium; finish signing in there.</p></li></ol></div></section></div><p>Trilium keeps its own Codex sign-in and settings, separate from any Codex CLI you use in a terminal, so an existing <code>codex login</code> is not reused.</p><details class=\"trilium-collapsible\"><summary>How Trilium identifies your Codex CLI binary</summary><p>In this order:</p><ul><li>By looking for a <code>TRILIUM_CODEX_PATH</code> environment variable pointing to the Codex binary.</li><li>By looking for <code>codex</code> in your PATH.</li><li>By asking your login shell for its <code>PATH</code>, the same as for Claude Code.</li></ul></details><aside class=\"admonition note\"><p>Trilium needs <code>curl</code> to use OpenAI Codex, the same as for Google Antigravity: Trilium checks every tool call Codex makes through it. It comes with Windows 10 and later, macOS and most Linux distributions.</p></aside><h3>Known limitations</h3><ul><li>The agent can only work with your notes through Trilium's note tools, and search the web when the chat allows it; its own file, shell and other tools are blocked for security reasons.</li><li>The ChatGPT sign-in opens in a browser on the device running Trilium, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a> should work fine.</li><li>Images and SVGs can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a> when the note tools are enabled.</li></ul>","_help_cRRrdZjgyhNc": "<p>Trilium sends nothing to an AI provider until you send a message. Enabling the integration, adding a provider or opening a chat transmits nothing on its own, the one exception is that listing a provider's models sends your API key to that provider, so the list can be fetched.</p><p>Once you send a message or run the <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a>, what leaves your machine depends on the provider you chose and on which context options are enabled.</p><h2>Where your notes go</h2><figure class=\"table\"><table><thead><tr><th>Provider type</th><th>Destination</th></tr></thead><tbody><tr><td>Cloud providers</td><td>The provider's servers (Anthropic, OpenAI, Google, DeepSeek)</td></tr><tr><td>Subscription-based</td><td>The provider's servers, via Claude Code running locally</td></tr><tr><td>Local / self-hosted</td><td>Nothing leaves the machine running the model</td></tr><tr><td>Custom endpoint</td><td>Wherever it was pointed, which may be your own hardware or a hosted service</td></tr></tbody></table></figure><p>This is the reason the provider list is grouped this way, and why Trilium pre-selects nothing: the choice of where your note content is sent is made explicitly by you, before anything is sent.</p><aside class=\"admonition note\"><p>The <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> has a model selection of its own, so it may be answered by a different provider than the one in the chat. The row at the bottom of the assistant's menu always names the one being used.</p></aside><h2>What is actually sent</h2><ul><li><strong>Always, with every message</strong><ul><li>The conversation itself: your messages and the assistant's replies, including earlier turns</li><li>Trilium's system prompt describing how to format answers and use tools.</li></ul></li><li><strong>The current note, only when note context is enabled.</strong><ul><li>In the sidebar chat this is the file icon at the bottom; the dedicated chat note type never sends a current note.</li><li>What travels is a metadata block: the note's ID, title, type, creation and modification dates, its parent IDs, the titles of up to 20 children, up to 20 attributes, and a preview of the content.</li><li>Notes above a size threshold send a size hint instead of the text, and the model must call a tool to read further.</li></ul></li><li><strong>Any note the model asks for, when note access is enabled.</strong><ul><li>Tools let the model search your tree and read notes, attributes and attachments beyond the current one.</li><li>It decides what to fetch, and each call waits for you to allow it, unless the chat's permission mode lets reads or every call run on their own, or you allowed that tool for the chat. The reachable scope is your whole tree, except for notes you exclude (see <em>Excluding notes</em> below).</li></ul></li><li><strong>Attachments and mentions</strong>, when you add them: images, PDFs and text files are sent to the provider, and an <code>@</code> mention makes that note fetchable.</li><li><strong>Your search query</strong>, when web search is enabled, the model's search terms reach the provider's own search infrastructure, or the search provider chosen in the <em>Tools</em> menu (Brave Search, Tavily, Exa, Serper, Perplexity or your SearXNG instance).</li><li><strong>The pages the model reads</strong>, when web search goes through a search provider or a DeepSeek model's built-in search: Trilium fetches each page the model asks for from the site itself, so the site sees a request from the machine running Trilium. The page's text is then sent to the model's provider.</li></ul><h2>The in-editor AI assistant</h2><p>A run of the <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> sends a different set than a chat message. For quick actions, it sends it the moment you pick an action, there is no send button to reconsider at. For the free-form <em>Ask AI</em>, there is a dedicated send button and model selector.</p><ul><li><strong>The passage you selected</strong>, or the paragraph the cursor is in when you pick a quick action without selecting anything.</li><li><strong>Up to 1500 characters of the note on each side of that passage</strong>, as plain text. The assistant is told this is context only and must not be rewritten, but it is sent regardless of whether you selected it: a run on a single sentence still transmits the paragraphs around it.</li><li><strong>Where the note sits</strong>: its title and the titles of its parents, as a breadcrumb.</li><li><strong>Trilium's writing-assistant instructions</strong>, which describe the formatting it may produce.</li><li><strong>Earlier turns of the same exchange</strong>, once you follow up on a response.</li></ul><p>No note metadata block is sent, web search is never enabled, and the assistant has no note tools so it can read nothing beyond the text listed above.</p><h2>Protected notes</h2><p>While your <a href=\"#root/_help_bwg0e8ewQMak\">protected session</a> is locked, protected notes send neither title nor content. <strong>While it is unlocked they are treated like any other note,</strong> a note the model reads through a tool is sent to the provider in full. If you keep sensitive material in protected notes, be aware that unlocking them removes that boundary for the duration of the session.</p><p>The same applies to the <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a>: it works on whatever is open in the editor, so running it inside an unlocked protected note sends that note's text like any other.</p><h2>Excluding notes</h2><p>Add the <code>#excludeFromLlm</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a> to a note to hide it from the AI chat and the <a href=\"#root/_help_KOWBFgsZXJAD\">MCP server</a>. The label covers only that note: the notes below it stay visible unless you make the label <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable</a>, and a child can opt back in with <code>#excludeFromLlm=false</code>.</p><p>A note created from a template inherits all of the template's labels (see <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>), so adding <code>#excludeFromLlm</code> to a template hides every note that uses it, not just the template.</p><p>For an excluded note:</p><ul><li>The note tools report it as not found: it is left out of search results, child lists and subtrees, and relations that point to it are not shown.</li><li>The model cannot read, edit, move, clone or rename it, create notes under it, or remove the label. It also cannot delete a note that has an excluded note below it.</li><li>Its metadata is not sent as the current note, even when note context is enabled.</li><li>A visible child does not show it as a parent, and the model cannot move the child out of it.</li></ul><p>Unlike a protected note, an excluded note stays hidden while your protected session is unlocked. The exclusion applies to the note tools only. It is not encryption, and it does not cover:</p><ul><li>Files you attach to a message yourself.</li><li>The <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> when you run it inside the note.</li><li>Text from the note that appears in other notes, such as a link with the note's title.</li><li>What a search query can test. Search never returns an excluded note, but a query can still match a visible note through an excluded one: by its title in the note path, through a relation (<code>~link.title</code>), a parent or child (<code>note.parents.content</code>), or a label the visible note inherits from it. A model that guesses can learn whether an excluded note contains a given word.</li></ul><h2>What you control</h2><ul><li><strong>Which provider</strong>: the single decision that determines whether anything leaves your machine at all.</li><li><strong>Note access</strong>: turn it off in the <span class=\"tn-icon bx bx-shield-quarter\"></span><em>Tools</em> menu at the bottom of the chat, and the model can read nothing beyond what you type.</li><li><strong>The current note:</strong> the file icon in the sidebar chat.</li><li><strong>Notes the AI cannot reach:</strong> the <code>#excludeFromLlm</code> label, see <em>Excluding notes</em> above.</li><li><strong>Web search:</strong> also in the <em>Tools</em> menu.</li><li><strong>Which tool calls ask first:</strong> the <em>Permissions</em> submenu of the <em>Tools</em> menu. <em>Always ask</em> has every call wait for you, reads included. A new chat starts in the mode you picked last, so a chat after one set to <em>Don't ask</em> asks about nothing either. Until you pick a mode, chats start in <em>Ask before changes</em>, where the AI reads and searches your notes without asking.</li><li><strong>The editor assistant</strong>: it has no per-run toggles. What you control is whether you run it, what you select before you do and which model answers.</li></ul><p>With note access and note context both off, the provider receives only the words you typed.</p><h2>Keeping everything local</h2><p>Adding an Ollama or LM Studio provider keeps every message on the machine running the model, and Trilium marks their models as free because no metered API is involved. The trade-off is quality and hardware: a small local model may fail at tool calls that a cloud model handles, so a local setup that misbehaves is worth benchmarking against a cloud provider before reporting it as a bug.</p><h2>Telemetry & security</h2><p>Trilium itself collects no telemetry from the AI integration.</p><p>Your API key is stored in your database, sent only to the provider it belongs to, and is write-only through the options API so that a malevolent <a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a> cannot access it. If you have backend or SQL console access enabled, a malevolent script <strong>could potentially exfiltrate your API keys</strong>.</p><p>The built-in MCP server is off by default. When enabled, every request must carry an ETAPI token, which grants the same full read and write access to your notes as the REST API; treat one like a password. On desktop it is reachable only from <code>localhost</code> unless you turn on <a class=\"reference-link\" href=\"#root/_help_swSFivWk6KkA\">Network Access</a>.</p>","_help_KOWBFgsZXJAD": "<p><a href=\"https://en.wikipedia.org/wiki/Model_Context_Protocol\">Model Context Protocol</a> allows external chat applications such as Claude Code to have access to the Trilium database.</p><h2>Built-in MCP</h2><p>v0.103.0 comes with a built-in MCP server that is not active by default. To activate it, go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → AI/LLM and toggle the <em>MCP server</em> option.</p><p>Once the MCP is active, simply add the MCP server to your AI assistant. The URL to use is displayed in the <em>Endpoint</em> <em>URL</em> information underneath the MCP toggle.</p><p>Only the HTTP transport is supported, the <code>stdio</code> method is not supported. If that is a blocker, consider using a third-party alternative listed below.</p><p>The tools exposed to the MCP are the same tools that are supported by the internal chat (see the <em>Note access</em> section). Notes with the <code>#excludeFromLlm</code> label are hidden from both, see <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a>.</p><h3>Approving tool calls</h3><p>Trilium does not ask for approval of the calls an external assistant makes; that is left to the assistant's own permission settings. To help it decide, each tool tells the assistant whether it only reads your notes, only adds to them (creating a note, cloning it or appending to it), or can overwrite or remove something (editing, renaming, moving or deleting). An assistant that supports these hints can then run reads on their own and ask before changes, the way <em>Ask before changes</em> does in Trilium's chat.</p><h3>Authentication</h3><p>To protect your notes from unauthorized access, the MCP server requires authentication. Generally MCP servers need to support OAuth for authentication, but Trilium uses a simpler mechanism using Bearer tokens.</p><p>To configure authentication, first create an <a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a> token by going to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>ETAPI</em>. Then follow the instructions in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>, by looking at the <em>How to connect an assistant</em> section under MCP.</p><h2>Third-party alternatives</h2><p>The following are alternatives to Trilium's built-in MCP feature. Since Trilium's AI implementation is still experimental, its tooling might not be as mature as external tools.</p><ul><li><a href=\"https://github.com/perfectra1n/triliumnext-mcp\">perfectra1n/triliumnext-mcp</a></li><li><a href=\"https://github.com/tan-yong-sheng/triliumnext-mcp\">tan-yong-sheng/triliumnext-mcp</a></li><li><a href=\"https://github.com/eliassoares/trilium-fastmcp\">eliassoares/trilium-fastmcp</a></li></ul><aside class=\"admonition important\"><p>These solutions are third-party and thus not endorsed or supported directly by the Trilium Notes team. Please address questions and issues on their corresponding repository instead.</p></aside>","_help_Y84QCbArmK3z": "<aside class=\"admonition important\"><p><strong>Meeting transcription is in beta</strong></p><p>Meeting transcription is a new feature and is still in beta. It has not been tested on every operating system, audio setup and meeting application, so it might fail to capture the audio, miss part of a meeting or behave differently from what this page describes. Before relying on it for an important meeting, try it on a short call first.</p><p>If something does not work, please <a href=\"#root/_help_wy8So3yZZlH9\">report the issue</a>, mentioning your operating system and the meeting application you used. The <em>Keep recordings for troubleshooting</em> option described below keeps what is needed to reproduce a problem.</p></aside><p>Meeting transcription turns a meeting into text while it happens: Trilium listens to your microphone and to what the other participants say through your speakers, and writes down who said what in a new note. Recognition runs entirely on your device, so no audio leaves it (see <em>Privacy</em> below).</p><p>Meeting transcription is available only in the desktop application. It is not available when Trilium is accessed through a browser, nor in the mobile application.</p><h2>Enabling meeting transcription</h2><p>Meeting transcription is off by default. To turn it on, go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Transcription</em> and turn on <em>Meeting transcription</em>. This adds the <span class=\"tn-icon bx bx-microphone\"></span> <em>Transcribe meeting</em> button to the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, marked with a <em>Beta</em> badge.</p><p>The speech recognition models are not part of Trilium. The first time you transcribe a meeting, Trilium asks to download them; see <a class=\"reference-link\" href=\"#root/_help_ebyr7ES2SwOW\">Downloaded resources</a> for the sizes and how to manage them. Each device downloads its own copy.</p><h2>Transcribing a meeting</h2><ol><li>Press the <span class=\"tn-icon bx bx-microphone\"></span> <em>Transcribe meeting</em> button in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li><li>If the models are not downloaded yet, confirm the download and wait for it to finish.</li><li>Trilium creates a text note titled with the current date and time (for example <em>Meeting 2026-10-15 14:30</em>) in the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>, opens it and starts transcribing. While it transcribes, the button turns into a <span class=\"tn-icon bx bx-stop-circle\"></span> <em>Stop transcribing</em> button and shows the time elapsed. Beside it, a reminder asks you to let everyone in the meeting know that it is being transcribed and to ask for their consent; it closes by itself after 10 seconds, or when you click it.</li><li>To end the transcription, press the <span class=\"tn-icon bx bx-stop-circle\"></span> <em>Stop transcribing</em> button. Trilium finishes transcribing what was already said before it stops.</li></ol><p>Only one meeting can be transcribed at a time. The note itself is an ordinary text note: you can take notes in it during the meeting, rename it or move it anywhere in the tree. It carries the <code>#meetingRecording</code> label.</p><p>Trilium tells you when your microphone or the meeting's audio is not being transcribed. It shows a message saying which one and why, the time on the button turns red and the button's tooltip says that some audio is not being transcribed:</p><ul><li><strong>Not captured</strong>: the transcription started without that audio, for example because there is no microphone or because Trilium was not allowed to record the screen and its audio. Connect the microphone or allow the recording, then stop the transcription and start it again.</li><li><strong>No audio</strong>: nothing has arrived from it for 10 seconds, as when its capture hangs. Stop the transcription and start it again; what was transcribed until then is kept.</li><li><strong>Only silence</strong>: it has delivered nothing but silence, for 15 seconds from your microphone or for a minute from the meeting. A microphone muted in your system's settings, or with a mute button of its own, does this. A meeting nobody speaks in for a minute does it too, so this message can be ignored when the others are just quiet.</li></ul><p>Each message shows once. <em>No audio</em> and <em>Only silence</em> clear by themselves once sound arrives again.</p><p>If the transcription stops on its own, for example because the audio could no longer be captured, Trilium shows a message and keeps everything transcribed until then. Closing Trilium during a meeting waits for the transcription to finish first.</p><h2>The transcript</h2><p>The transcript is stored as an <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> of the meeting note and is shown in a collapsible <em>Transcript</em> section above the note's content. It updates as the meeting goes on, one paragraph per speaker turn, each with the time it started. While the meeting is being transcribed, the header of the <em>Transcript</em> section shows the level of your microphone (<em>Me</em>) and of the meeting's audio (<em>Others</em>), so you can tell that both are being heard, even while the section is collapsed; a source that is not being transcribed is marked <em>Not captured</em>, <em>No audio</em> or <em>Only silence</em>. While someone is talking, <em>Speaking…</em> shows under their name until their words are transcribed. If you are reading the end of the transcript, it scrolls to follow new text.</p><p>The <em>Transcript</em> section is expanded each time the note is opened. To collapse it, click its header; it stays collapsed only until the note is opened again.</p><p>The transcript is also listed among the note's attachments, under <em>Generated by Trilium</em>. Opening it from there shows the same view of the transcript. Deleting the attachment deletes the transcript, and the section disappears from the note.</p><ul><li>What you say into your microphone is labeled <em>Me</em>.</li><li>What the other participants say is labeled <em>Speaker 1</em>, <em>Speaker 2</em> and so on, while <em>Identify speakers</em> is on; otherwise it is labeled <em>Others</em>.</li><li>To name a speaker, click their name, type the new name and press <kbd>Enter</kbd>. The name changes on every turn of that speaker. Press <kbd>Esc</kbd> to cancel, or clear the name to restore the default one.</li><li>To show the transcript with or without hesitations such as \"uh\", \"um\" and stuttered words, press the <span class=\"tn-icon bx bx-eraser\"></span> <em>Hide filler words</em> button above it, which shows as pressed while they are hidden. While they are shown, they are grayed out, so you can see what hiding them would remove. This affects only what is shown; the stored transcript keeps every word.</li><li>To copy the transcript as plain text, press the <span class=\"tn-icon bx bx-copy\"></span> <em>Copy transcript</em> button above it. Each turn is copied with the speaker's name and the time it started, as shown, so the copy leaves out filler words while they are hidden.</li></ul><p>If the meeting note is <a href=\"#root/_help_bwg0e8ewQMak\">protected</a> and the protected session is locked during the meeting, the transcript cannot be saved. Trilium keeps it in memory and saves it once you enter the protected session again, as long as Trilium stays open.</p><h2>Configuration</h2><p>The settings are in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Transcription</em>, and are shown once <em>Meeting transcription</em> is on.</p><figure class=\"table\"><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><em>European languages</em></td><td>The speech recognition model. Both are versions of NVIDIA's Parakeet TDT 0.6B v3 model and recognize 25 European languages and work out which one is spoken. <em>Standard</em> is a smaller download and runs well on most computers. <em>High accuracy</em> makes fewer mistakes, but is a larger download and needs about 1.6 GB more memory while transcribing. A model is downloaded the first time you transcribe with it.</td></tr><tr><td><em>Identify speakers</em></td><td>Tells the other participants apart and labels each of them separately, using the TitaNet model. Voices are compared only during the meeting: nothing about a voice is stored, and no one is recognized from one meeting to the next. Turn it off if it mixes up voices. The change applies from the next meeting.</td></tr><tr><td><em>Keep recordings for troubleshooting</em></td><td>Keeps the audio of the meeting, the settings used and the transcript as it was produced, so that a problem can be reported and reproduced. It takes about 230 MB per hour of meeting and is never deleted automatically. The folder where they are kept is shown below the option.</td></tr></tbody></table></figure><aside class=\"admonition warning\"><p>Before turning on <em>Keep recordings for troubleshooting</em>, ask everyone in the meeting to agree to being recorded. In several countries and US states, recording a conversation without everyone's consent is a criminal offense. The audio is stored unencrypted, even for protected notes. While the option is on, the tooltip of the <em>Transcribe meeting</em> button says so, and the reminder shown when the transcription starts mentions that the audio is kept.</p></aside><p>The sizes and licenses of the models are listed in <a class=\"reference-link\" href=\"#root/_help_ebyr7ES2SwOW\">Downloaded resources</a>.</p><h2>Privacy</h2><p>Meeting transcription does not use any online service:</p><ul><li>The audio is recognized on your device by the open-source sherpa-onnx engine. Trilium does not send the audio or the transcript to any online service, and no account or API key is needed.</li><li>An Internet connection is needed only to download the models, from Hugging Face and from the sherpa-onnx project on GitHub. Once they are downloaded, meeting transcription works offline.</li><li>Speaker identification compares voices only during the meeting. Nothing about a voice is stored.</li><li>The audio is not kept, unless <em>Keep recordings for troubleshooting</em> is on. Those recordings stay in a folder on your device and are never synchronized.</li></ul><p>The transcript itself is an attachment of the meeting note, so it is handled like the rest of your notes. If you use <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>, it is synchronized to your sync server and your other devices. To keep it encrypted, transcribe into a <a href=\"#root/_help_bwg0e8ewQMak\">protected</a> note: the transcript of a protected note is protected too.</p><h2>Limitations</h2><ul><li>Meeting transcription needs a speech recognition engine that does not load on every computer, for example on Linux distributions older than Ubuntu 22.04 or Debian 12. Where it does not load, the <em>Transcribe meeting</em> button does not appear, the <em>Transcription</em> options say so, and the log records why.</li><li>The transcript is made from the audio played by your device. A participant whose voice does not come out of your speakers or headphones, for example someone in the same room, is transcribed only as far as your microphone picks them up, and is labeled <em>Me</em>.</li><li>Speaker identification works best with a few clearly distinct voices. Similar voices, many participants or poor call quality can lead to speakers being merged or split.</li><li>Accuracy is lower for languages other than English, and the model can switch to the wrong language for short passages.</li><li>Transcribing uses a noticeable amount of processor time and memory, especially with the <em>High accuracy</em> model.</li></ul>",diff --git a/apps/server/src/assets/translations/en/server.json b/apps/server/src/assets/translations/en/server.jsonindex 248a53e450..1276de8dd8 100644--- a/apps/server/src/assets/translations/en/server.json+++ b/apps/server/src/assets/translations/en/server.json@@ -601,5 +601,8 @@"nothing-to-share": "Nothing to share: no text, link or files were received.","rejected": "Share rejected: {{- reason}}","other-page": "Only the system share menu can send content to this address."+ },+ "llm_providers": {+ "flatpak_sandbox": "Trilium runs as a Flatpak, so it cannot start programs installed outside its sandbox, such as {{- cli}}. To use {{- cli}}:\n\n1. Install it on this computer and sign in to it from a terminal.\n2. Allow Trilium to start programs outside its sandbox by running this in a terminal:\n\n{{- grantCommand}}\n\n3. Restart Trilium.\n\nThis gives Trilium the same access to your computer as an installation outside Flatpak. To take it back, run:\n\n{{- revokeCommand}}"}}diff --git a/apps/server/src/services/llm/providers/antigravity_binary.ts b/apps/server/src/services/llm/providers/antigravity_binary.tsindex e6c2fc9747..13c66eb8e3 100644--- a/apps/server/src/services/llm/providers/antigravity_binary.ts+++ b/apps/server/src/services/llm/providers/antigravity_binary.ts@@ -20,7 +20,7 @@ import { execFile } from "child_process";import { existsSync } from "fs";import { promisify } from "util";-import { cachedProbe, findOnPath } from "./binary_lookup.js";+import { cachedProbe, describeFlatpakSandbox, findOnPath } from "./binary_lookup.js";const execFileAsync = promisify(execFile);@@ -92,5 +92,5 @@ async function locateBinary(): Promise<string> {return onPath;}- throw new Error(`Google's Antigravity ACP server (agy_acp_server) was not found. Put the folder it was unpacked into on PATH, or set the TRILIUM_ANTIGRAVITY_ACP_PATH environment variable to the executable. ${SETUP_HINT}`);+ throw new Error(await describeFlatpakSandbox("Google Antigravity ACP server") ?? `Google's Antigravity ACP server (agy_acp_server) was not found. Put the folder it was unpacked into on PATH, or set the TRILIUM_ANTIGRAVITY_ACP_PATH environment variable to the executable. ${SETUP_HINT}`);}diff --git a/apps/server/src/services/llm/providers/binary_lookup.spec.ts b/apps/server/src/services/llm/providers/binary_lookup.spec.tsindex 688fe5bc95..6a263aef34 100644--- a/apps/server/src/services/llm/providers/binary_lookup.spec.ts+++ b/apps/server/src/services/llm/providers/binary_lookup.spec.ts@@ -8,11 +8,14 @@ const execFileMock = vi.hoisted(() => vi.fn<(binary: string, args: string[], optvi.mock("child_process", () => ({ execFile: execFileMock }));const existsSyncMock = vi.hoisted(() => vi.fn((_path: string) => true));-vi.mock("fs", () => ({ existsSync: existsSyncMock }));+const writeFileSyncMock = vi.hoisted(() => vi.fn<(file: string, content: string) => void>());+vi.mock("fs", () => ({ existsSync: existsSyncMock, mkdirSync: vi.fn(), writeFileSync: writeFileSyncMock, chmodSync: vi.fn() }));+vi.mock("../../data_dir.js", () => ({ default: { TRILIUM_DATA_DIR: "/data" } }));vi.mock("@triliumnext/core", () => ({ getLog: () => ({ info: vi.fn(), error: vi.fn() }) }));+vi.mock("i18next", () => ({ t: (key: string, options: object) => `${key} ${JSON.stringify(options)}` }));-const { extractPathFromShellEnv, findOnPath, needsShell, resetLoginShellPathCache } = await import("./binary_lookup.js");+const { buildHostLauncher, describeFlatpakSandbox, extractPathFromShellEnv, findOnPath, needsShell, resetLoginShellPathCache } = await import("./binary_lookup.js");const NVM_BIN = path.join("/home/user", ".nvm", "versions", "node", "v24.19.0", "bin");const CLAUDE = path.join(NVM_BIN, "claude");@@ -158,3 +161,130 @@ describe("needsShell", () => {expect(needsShell("C:\\npm\\copilot.exe")).toBe(false);});});++describe("inside a Flatpak", () => {+ const LAUNCHER = path.resolve("/data", "flatpak-host", "claude");++ beforeEach(() => {+ resetLoginShellPathCache();+ execFileMock.mockReset();+ writeFileSyncMock.mockReset();+ process.env.FLATPAK_ID = "org.triliumnotes.Trilium";+ });++ afterEach(() => {+ delete process.env.FLATPAK_ID;+ });++ /** Answers each `flatpak-spawn` call by the host command it runs. */+ function hostAnswers(answer: (hostArgs: string[]) => string | Error) {+ execFileMock.mockImplementation((binary, args, _options, cb) => {+ expect(binary).toBe("flatpak-spawn");+ const result = answer(args);+ if (result instanceof Error) {+ cb(result);+ } else {+ cb(null, { stdout: result, stderr: "" });+ }+ });+ }++ it("finds the CLI on the host's PATH and returns a launcher for it", async () => {+ hostAnswers((args) => (args.includes("command -v \"$1\"") ? "/usr/bin/claude\n" : ""));++ await expect(findOnPath("claude")).resolves.toBe(LAUNCHER);+ expect(execFileMock.mock.calls.map(([ , args ]) => args)).toEqual([+ [ "--host", "true" ],+ [ "--host", "sh", "-c", "command -v \"$1\"", "sh", "claude" ]+ ]);+ expect(writeFileSyncMock).toHaveBeenCalledWith(LAUNCHER, buildHostLauncher("/usr/bin/claude"));+ });++ it("falls back to the host's login shell, whose PATH the launcher then carries", async () => {+ const loginPath = "/home/user/.nvm/bin:/usr/bin";+ hostAnswers((args) => {+ if (args.includes("--env=TERM=dumb")) {+ return `__TRILIUM_SHELL_ENV__PATH=${loginPath}\n__TRILIUM_SHELL_ENV__`;+ }+ if (args.includes("command -v \"$1\"")) {+ return args.includes(`--env=PATH=${loginPath}`) ? "/home/user/.nvm/bin/claude\n" : "";+ }+ return "";+ });++ await expect(findOnPath("claude")).resolves.toBe(LAUNCHER);+ expect(writeFileSyncMock).toHaveBeenCalledWith(+ LAUNCHER, buildHostLauncher("/home/user/.nvm/bin/claude", loginPath));+ });++ it("reports no CLI when the host has none, or `command -v` names a builtin or alias", async () => {+ hostAnswers((args) => (args.includes("command -v \"$1\"") ? "claude\n" : ""));+ await expect(findOnPath("claude")).resolves.toBeUndefined();+ expect(writeFileSyncMock).not.toHaveBeenCalled();+ // Asked on the session's PATH, then on the login shell's, which reported none.+ expect(execFileMock.mock.calls.filter(([ , args ]) => args.includes("command -v \"$1\""))).toHaveLength(1);+ expect(execFileMock.mock.calls.some(([ , args ]) => args.includes("--env=TERM=dumb"))).toBe(true);+ });++ it("explains the override only when the sandbox blocks the host", async () => {+ hostAnswers(() => new Error("Portal call failed: org.freedesktop.DBus.Error.ServiceUnknown"));+ const message = await describeFlatpakSandbox("Claude Code");+ expect(message).toBe(`llm_providers.flatpak_sandbox ${JSON.stringify({+ cli: "Claude Code",+ grantCommand: "flatpak override --user --talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium",+ revokeCommand: "flatpak override --user --no-talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium"+ })}`);+ // The lookup stays on the sandbox's own PATH, where a CLI could still be.+ expect(execFileMock.mock.calls.filter(([ , args ]) => args.includes("command -v \"$1\""))).toEqual([]);++ resetLoginShellPathCache();+ hostAnswers(() => "");+ await expect(describeFlatpakSandbox("Claude Code")).resolves.toBeUndefined();++ delete process.env.FLATPAK_ID;+ await expect(describeFlatpakSandbox("Claude Code")).resolves.toBeUndefined();+ });+});++describe.skipIf(process.platform === "win32")("buildHostLauncher", () => {+ it("runs the CLI through flatpak-spawn with the CLI's variables and a host directory", async () => {+ const realFs = await vi.importActual<typeof import("fs")>("fs");+ const { execFileSync } = await vi.importActual<typeof import("child_process")>("child_process");+ const os = await vi.importActual<typeof import("os")>("os");+ const dir = realFs.mkdtempSync(path.join(os.tmpdir(), "trilium-launcher-"));+ try {+ // A stand-in for flatpak-spawn that prints its directory and arguments.+ const fakeSpawn = path.join(dir, "flatpak-spawn");+ realFs.writeFileSync(fakeSpawn, "#!/bin/sh\npwd\nfor arg in \"$@\"; do printf '%s\\n' \"$arg\"; done\n");+ realFs.chmodSync(fakeSpawn, 0o755);+ const launcher = path.join(dir, "claude");+ realFs.writeFileSync(launcher, buildHostLauncher("/opt/it's/claude", "/host/bin:/usr/bin"));+ realFs.chmodSync(launcher, 0o755);++ const home = realFs.mkdtempSync(path.join(dir, "home-"));+ const output = execFileSync(launcher, [ "--print", "two words", "$HOME" ], {+ cwd: dir,+ encoding: "utf8",+ env: {+ PATH: `${dir}:${process.env.PATH}`,+ HOME: home,+ CLAUDE_CODE_ENTRYPOINT: "sdk-ts \"quoted\" $(not run)",+ CODEX_HOME: "/data/codex-agent",+ UNRELATED: "left out"+ }+ });++ const [ cwd, ...args ] = output.trimEnd().split("\n");+ // `dir` is outside HOME, so the launcher moved to HOME first.+ expect(cwd).toBe(home);+ expect(args.slice(0, 3)).toEqual([ "--host", "--watch-bus", "--env=PATH=/host/bin:/usr/bin" ]);+ expect(args.slice(-4)).toEqual([ "/opt/it's/claude", "--print", "two words", "$HOME" ]);+ expect(args.slice(3, -4).sort()).toEqual([+ "--env=CLAUDE_CODE_ENTRYPOINT=sdk-ts \"quoted\" $(not run)",+ "--env=CODEX_HOME=/data/codex-agent"+ ]);+ } finally {+ realFs.rmSync(dir, { recursive: true, force: true });+ }+ });+});diff --git a/apps/server/src/services/llm/providers/binary_lookup.ts b/apps/server/src/services/llm/providers/binary_lookup.tsindex 1495ca5956..7f6f42daa2 100644--- a/apps/server/src/services/llm/providers/binary_lookup.ts+++ b/apps/server/src/services/llm/providers/binary_lookup.ts@@ -12,11 +12,17 @@* user's login shell get asked for its own PATH. A hit there is adopted into* `process.env.PATH`, because the CLI subprocess needs it too — an npm shim* resolves its `node` through PATH.+ *+ * Inside a Flatpak, no CLI installed on the computer is visible. When the user+ * allows the app to talk to `org.freedesktop.Flatpak`, the CLI is looked up on+ * the host instead and started there through `flatpak-spawn --host`, by a+ * launcher script written into the data directory (see {@link buildHostLauncher}).*/import { getLog } from "@triliumnext/core";import { execFile } from "child_process";-import { existsSync } from "fs";+import { chmodSync, existsSync, mkdirSync, writeFileSync } from "fs";+import { t } from "i18next";import path from "path";import { promisify } from "util";@@ -28,12 +34,30 @@ const DELIMITER = "__TRILIUM_SHELL_ENV__";/** Upper bound on the login shell's startup: rc files can source a lot. */const LOGIN_SHELL_TIMEOUT_MS = 10000;+/** Upper bound on a `flatpak-spawn --host` call that only checks or looks something up. */+const HOST_LOOKUP_TIMEOUT_MS = 5000;++/** The `env` dump a login shell prints, delimited so rc-file chatter can be discarded. */+const ENV_DUMP_SCRIPT = `printf %s ${DELIMITER}; env; printf %s ${DELIMITER}`;++/**+ * The variables a host launcher passes from Trilium to the CLI. `flatpak-spawn --host` starts+ * the CLI with the session's environment, not Trilium's, so the variables the SDK and the+ * providers set (`CLAUDE_CODE_ENTRYPOINT`, `CODEX_HOME`, `GEMINI_HOME`) are passed explicitly.+ */+const HOST_ENV_PREFIXES = [ "ANTHROPIC_", "CLAUDE_", "CODEX_", "COPILOT_", "GEMINI_", "GH_", "GITHUB_" ];+/*** Finds `binary` on PATH, falling back to the login shell's PATH. Returns the* full path to the executable, or `undefined` if it is installed nowhere the- * user's shell could reach it either.+ * user's shell could reach it either. Inside a Flatpak that may start programs+ * on the host, returns a launcher for the host's `binary` instead.*/export async function findOnPath(binary: string): Promise<string | undefined> {+ if (process.env.FLATPAK_ID && await canReachFlatpakHost()) {+ return findOnFlatpakHost(binary);+ }+const inherited = searchPath(process.env.PATH, binary);if (inherited) {return inherited;@@ -52,6 +76,48 @@ export async function findOnPath(binary: string): Promise<string | undefined> {return found;}+/**+ * Why `cli` cannot be found when Trilium runs as a Flatpak that may not start programs on the+ * host, with the steps that allow it. `undefined` outside a Flatpak, or once the host is+ * reachable and the CLI is simply not installed there.+ */+export async function describeFlatpakSandbox(cli: string): Promise<string | undefined> {+ const appId = process.env.FLATPAK_ID;+ if (!appId || await canReachFlatpakHost()) {+ return undefined;+ }+ return t("llm_providers.flatpak_sandbox", {+ cli,+ grantCommand: `flatpak override --user --talk-name=org.freedesktop.Flatpak ${appId}`,+ revokeCommand: `flatpak override --user --no-talk-name=org.freedesktop.Flatpak ${appId}`+ });+}++/**+ * The script that starts `hostBinary` on the host from inside the Flatpak. It passes the+ * variables named by {@link HOST_ENV_PREFIXES}, and moves to the home directory when the+ * current one exists only in the sandbox, which `flatpak-spawn` would refuse to start in.+ * `hostPath` is the login shell's PATH, set when that is where the CLI was found.+ */+export function buildHostLauncher(hostBinary: string, hostPath?: string): string {+ const pathFlag = hostPath ? ` ${shellQuote(`--env=PATH=${hostPath}`)}` : "";+ const prefixes = HOST_ENV_PREFIXES.map((prefix) => `${prefix}*`).join("|");+ return `#!/bin/sh+# Written by Trilium: runs ${hostBinary} outside the Flatpak sandbox.+set -- ${shellQuote(hostBinary)} "$@"+for var in $(env | sed -n 's/^\\([A-Za-z_][A-Za-z0-9_]*\\)=.*/\\1/p'); do+ case "$var" in+ ${prefixes}) eval "set -- \\"--env=$var=\\\${$var}\\" \\"\\$@\\"" ;;+ esac+done+case "$PWD" in+ "$HOME" | "$HOME"/*) ;;+ *) cd "$HOME" || exit 1 ;;+esac+exec flatpak-spawn --host --watch-bus${pathFlag} "$@"+`;+}+/*** Memoize a binary probe: concurrent first calls share one run, and a failed* one is forgotten so a later install is picked up without a restart.@@ -113,6 +179,8 @@ export function needsShell(binary: string): boolean {/** For tests: forget the login shell's PATH so the next call re-reads it. */export function resetLoginShellPathCache(): void {cachedLoginShellPath = undefined;+ cachedHostReachable = undefined;+ cachedHostLoginShellPath = undefined;}/**@@ -176,7 +244,7 @@ async function readLoginShellPath(): Promise<string | undefined> {// `printf` and `env` are external commands, so the dump reads the same under// bash, zsh, fish and dash. `-i` matters: nvm and fnm are commonly set up in// an interactive-only rc file (.zshrc, .bashrc).- const args = ["-ilc", `printf %s ${DELIMITER}; env; printf %s ${DELIMITER}`];+ const args = ["-ilc", ENV_DUMP_SCRIPT];try {const { stdout } = await execFileAsync(shell, args, {timeout: LOGIN_SHELL_TIMEOUT_MS,@@ -202,3 +270,91 @@ function mergePaths(inherited: string | undefined, loginShell: string): string {];return [...new Set(entries.filter((entry) => entry))].join(path.delimiter);}++/** Whether `flatpak-spawn --host` works, which takes the user's `--talk-name` override. */+let cachedHostReachable: Promise<boolean> | undefined;++function canReachFlatpakHost(): Promise<boolean> {+ if (!cachedHostReachable) {+ cachedHostReachable = execFileAsync("flatpak-spawn", [ "--host", "true" ], { timeout: HOST_LOOKUP_TIMEOUT_MS })+ .then(() => true, (err: unknown) => {+ const detail = err instanceof Error ? err.message : String(err);+ getLog().info(`Running as a Flatpak that cannot start programs on the host (${detail})`);+ return false;+ });+ }+ return cachedHostReachable;+}++/**+ * Looks `binary` up on the host's PATH, then on its login shell's, and writes a launcher for it.+ * The lookup runs `command -v` in the host's `sh`, since no host path can be tested from inside+ * the sandbox.+ */+async function findOnFlatpakHost(binary: string): Promise<string | undefined> {+ const onSessionPath = await commandOnHost(binary);+ if (onSessionPath) {+ return writeHostLauncher(binary, onSessionPath);+ }++ const loginShellPath = await resolveHostLoginShellPath();+ const onLoginShellPath = loginShellPath ? await commandOnHost(binary, loginShellPath) : undefined;+ if (!onLoginShellPath) {+ return undefined;+ }+ getLog().info(`Found ${binary} at ${onLoginShellPath} on the PATH of the host's login shell`);+ return writeHostLauncher(binary, onLoginShellPath, loginShellPath);+}++async function commandOnHost(binary: string, hostPath?: string): Promise<string | undefined> {+ const pathFlag = hostPath ? [ `--env=PATH=${hostPath}` ] : [];+ try {+ const { stdout } = await execFileAsync("flatpak-spawn", [+ "--host", ...pathFlag, "sh", "-c", "command -v \"$1\"", "sh", binary+ ], { timeout: HOST_LOOKUP_TIMEOUT_MS, encoding: "utf8" });+ const found = stdout.trim();+ // `command -v` prints a bare name for a builtin, function or alias.+ return path.posix.isAbsolute(found) ? found : undefined;+ } catch {+ return undefined;+ }+}++/** The host login shell's PATH; a failed read is cached too, as for {@link resolveLoginShellPath}. */+let cachedHostLoginShellPath: Promise<string | undefined> | undefined;++function resolveHostLoginShellPath(): Promise<string | undefined> {+ if (!cachedHostLoginShellPath) {+ cachedHostLoginShellPath = readHostLoginShellPath();+ }+ return cachedHostLoginShellPath;+}++async function readHostLoginShellPath(): Promise<string | undefined> {+ // The sandbox sets SHELL to its own /bin/sh, so the host's `sh` reads the session's SHELL.+ try {+ const { stdout } = await execFileAsync("flatpak-spawn", [+ "--host", "--env=TERM=dumb", "sh", "-c", "exec \"${SHELL:-/bin/sh}\" -ilc \"$1\"", "sh", ENV_DUMP_SCRIPT+ ], { timeout: LOGIN_SHELL_TIMEOUT_MS, encoding: "utf8", maxBuffer: 1024 * 1024 });+ return extractPathFromShellEnv(stdout);+ } catch (err) {+ const detail = err instanceof Error ? err.message : String(err);+ getLog().info(`Could not read PATH from the host's login shell (${detail})`);+ return undefined;+ }+}++async function writeHostLauncher(binary: string, hostBinary: string, hostPath?: string): Promise<string> {+ // Imported here: data_dir resolves the data directory as soon as it loads.+ const { default: dataDirs } = await import("../../data_dir.js");+ const dir = path.resolve(dataDirs.TRILIUM_DATA_DIR, "flatpak-host");+ mkdirSync(dir, { recursive: true });+ const launcher = path.join(dir, binary);+ writeFileSync(launcher, buildHostLauncher(hostBinary, hostPath));+ chmodSync(launcher, 0o755);+ return launcher;+}++function shellQuote(value: string): string {+ return `'${value.replaceAll("'", `'\\''`)}'`;+}diff --git a/apps/server/src/services/llm/providers/claude_binary.ts b/apps/server/src/services/llm/providers/claude_binary.tsindex 8255606cf2..add8a1626c 100644--- a/apps/server/src/services/llm/providers/claude_binary.ts+++ b/apps/server/src/services/llm/providers/claude_binary.ts@@ -20,7 +20,7 @@ import { execFile } from "child_process";import { existsSync } from "fs";import { promisify } from "util";-import { cachedProbe, findOnPath } from "./binary_lookup.js";+import { cachedProbe, describeFlatpakSandbox, findOnPath } from "./binary_lookup.js";const execFileAsync = promisify(execFile);@@ -76,5 +76,5 @@ async function locateBinary(): Promise<string> {return onPath;}- throw new Error("Claude Code CLI not found. Install it (`npm install -g @anthropic-ai/claude-code`) and run `claude /login` on the machine running the Trilium server, or set the TRILIUM_CLAUDE_CODE_PATH environment variable to its location.");+ throw new Error(await describeFlatpakSandbox("Claude Code") ?? "Claude Code CLI not found. Install it (`npm install -g @anthropic-ai/claude-code`) and run `claude /login` on the machine running the Trilium server, or set the TRILIUM_CLAUDE_CODE_PATH environment variable to its location.");}diff --git a/apps/server/src/services/llm/providers/codex_binary.ts b/apps/server/src/services/llm/providers/codex_binary.tsindex bfefa2c74d..782030e9ab 100644--- a/apps/server/src/services/llm/providers/codex_binary.ts+++ b/apps/server/src/services/llm/providers/codex_binary.ts@@ -19,7 +19,7 @@ import { existsSync } from "fs";import path from "path";import { RESOURCE_DIR } from "../../resource_dir.js";-import { cachedProbe, findOnPath, runVersionProbe } from "./binary_lookup.js";+import { cachedProbe, describeFlatpakSandbox, findOnPath, runVersionProbe } from "./binary_lookup.js";const PROBE_TIMEOUT_MS = 15000;@@ -79,5 +79,5 @@ async function locateBinary(): Promise<string> {return onPath;}- throw new Error(`The Codex CLI (codex) was not found. ${INSTALL_HINT}`);+ throw new Error(await describeFlatpakSandbox("Codex CLI") ?? `The Codex CLI (codex) was not found. ${INSTALL_HINT}`);}diff --git a/apps/server/src/services/llm/providers/copilot_binary.ts b/apps/server/src/services/llm/providers/copilot_binary.tsindex 778aff9b4e..ddfe195fd3 100644--- a/apps/server/src/services/llm/providers/copilot_binary.ts+++ b/apps/server/src/services/llm/providers/copilot_binary.ts@@ -23,7 +23,7 @@import { getLog } from "@triliumnext/core";import { existsSync } from "fs";-import { cachedProbe, findOnPath, runVersionProbe } from "./binary_lookup.js";+import { cachedProbe, describeFlatpakSandbox, findOnPath, runVersionProbe } from "./binary_lookup.js";const PROBE_TIMEOUT_MS = 15000;@@ -77,5 +77,5 @@ async function locateBinary(): Promise<string> {return onPath;}- throw new Error("GitHub Copilot CLI not found. Install it (`npm install -g @github/copilot`) and run `copilot login` on the machine running the Trilium server, or set the TRILIUM_COPILOT_PATH environment variable to its location.");+ throw new Error(await describeFlatpakSandbox("GitHub Copilot CLI") ?? "GitHub Copilot CLI not found. Install it (`npm install -g @github/copilot`) and run `copilot login` on the machine running the Trilium server, or set the TRILIUM_COPILOT_PATH environment variable to its location.");}diff --git a/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md b/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.mdindex e1004ff581..742ea7afff 100644--- a/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md+++ b/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md@@ -5,6 +5,25 @@ In a nutshell, subscription-based providers work by either reusing your existingSee also the dedicated <a class="reference-link" href="../Privacy.md">Privacy</a> section to better understand what data is being sent to a cloud provider.+## Using the Flatpak++The Flatpak version of Trilium (see [Installing from Flathub](../../Installation%20%26%20Setup/Desktop%20Installation.md)) runs in a sandbox that hides the programs installed on your computer, so on its own it cannot find Claude Code, the GitHub Copilot CLI, the Codex CLI or Google's Antigravity ACP server. Trilium can start them outside the sandbox once you allow it to:++1. Install the CLI on your computer and sign in to it, as described below for each provider.+2. Allow Trilium to start programs outside its sandbox by running this in a terminal:++ ```sh+ flatpak override --user --talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium+ ```+3. Restart Trilium, then go to <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _AI / LLM_ and add the provider.++Trilium then looks the CLI up in your computer's `PATH` and in your login shell's, and starts it there through `flatpak-spawn --host`. Until the permission is granted, adding one of these providers fails with a message that repeats these steps.++> [!WARNING]+> This permission lets Trilium run any program on your computer outside the sandbox, which is the same access an installation outside Flatpak has. To take it back, run `flatpak override --user --no-talk-name=org.freedesktop.Flatpak org.triliumnotes.Trilium` and restart Trilium.++The environment variables that point Trilium at a CLI (such as `TRILIUM_CLAUDE_CODE_PATH`) name a file inside the sandbox, so with the Flatpak, leave them unset and let Trilium find the CLI on your computer.+## <span class="tn-icon tn-brand tn-brand-claude"></span> Claude CodeTo use a subscription:diff --git a/docs/User Guide/User Guide/Installation & Setup/Desktop Installation.md b/docs/User Guide/User Guide/Installation & Setup/Desktop Installation.mdindex 40b14051ce..dd2c20ac07 100644--- a/docs/User Guide/User Guide/Installation & Setup/Desktop Installation.md+++ b/docs/User Guide/User Guide/Installation & Setup/Desktop Installation.md@@ -28,6 +28,8 @@ The Flathub version runs in a sandbox and keeps its [data directory](Data%20direIf `~/.var/app/org.triliumnotes.Trilium/data/trilium-data` already exists because the Flatpak version was started before, remove or rename it first.+The sandbox also hides the command-line tools that the [subscription-based AI providers](../AI/Providers/Subscription-based%20providers.md) run (Claude Code, GitHub Copilot, OpenAI Codex, Google Antigravity); that page describes the permission that lets the Flatpak start them.+## Startup ScriptsTrilium offers various startup scripts to customize your experience: