Introducing a new way to review your PRs.

Read the announcement

triliumnext / trilium

Build your personal knowledge base with Trilium Notes

View on GitHub

20 documents · Updated Nov 23, 2026

docs / server-intelligence-and-automation

Server intelligence and automation

Server intelligence and automation helps Trilium turn files into usable knowledge, find that knowledge, and connect approved AI agents to it. It joins search, OCR, imports, model providers, MCP access, and guarded automation behind operational paths that show progress and stop work when its owner disconnects. See Server platform for the server lifecycle, Server storage and note services for the data services these features use, and Server HTTP API and sharing for the wider request surface.

Search and OCR

Server-side search gives the main search surfaces one query model for note text, titles, labels, relations, hierarchy, and note properties. It returns ranked notes with paths, snippets, and highlights so fast lookup and deep content search have the same meaning.

Search separates plain text from structured expressions. Exact, substring, regular-expression, numeric, and fuzzy operators serve different needs. Normal search favors exact results and can use a second fuzzy pass for body content when fuzzy matching is enabled. Explicit operators keep their own matching rules, so a typo fallback does not change a query that asks for exact or substring behavior. Callers can disable regular expressions on open surfaces because a hostile pattern could block the server.

The search context carries scope, hidden and archived-note rules, ordering, limits, fuzzy permission, highlight types, and errors. Content preparation follows what the editor shows, so visible links, icons, and encoded text can match. Protected content remains inside the open protected session boundary. Result surfaces can rank only the leading result window when they do not need the full set.

References: packages/…/search.ts• L287-320 packages/…/search.ts• L334-456 packages/…/search.ts• L459-553 packages/…/search.ts• L855-954 packages/…/search_context.ts• L10-108 packages/…/types.ts• L10-40 packages/…/lex.js• L6-145 packages/…/note_content_fulltext.ts• L290-313 packages/…/note_content_fulltext_preprocessor.ts• L1-49 packages/…/note_content_fulltext_preprocessor.ts• L144-245

OCR text extraction

OCR adds searchable text to images and supported documents. The service chooses a processor from the media type, selects a language from the request or note settings, records confidence and processing data, and stores the result with the source blob.

Image, office, and PDF content follow the same service boundary. Protected sources are skipped when their bytes are not available, and protected OCR text is stored in protected form. A batch run processes supported blobs that have no stored result, reports progress and failures, and can be cancelled. An empty result counts as processed so an unreadable file does not run again on every batch.

PDFs use embedded text where it is sufficient and OCR only for pages that look scanned. Scanned pages are rendered with a bounded pixel budget and processed one at a time. A document can OCR up to 50 scanned pages, while later pages retain any embedded text and the result reports skipped or failed work. Image OCR can filter low-confidence words and keeps one language worker safe across concurrent requests.

References: apps/…/ocr_service.ts• L105-121 apps/…/ocr_service.ts• L185-269 apps/…/ocr_service.ts• L287-370 apps/…/pdf_processor.ts• L31-35 apps/…/pdf_processor.ts• L65-123 apps/…/pdf_processor.spec.ts• L161-204 apps/…/pdf_processor.spec.ts• L230-310 apps/…/pdf_renderer.ts• L30-47 apps/…/pdf_renderer.ts• L49-117 apps/…/pdf_renderer.spec.ts• L112-153 apps/…/tesseract_recognizer.spec.ts• L219-338

OCR-aware search and agent context

The stored text representation connects file understanding to the rest of the system. Full-text search can match OCR text, an OCR expression can inspect a note and its attachments, and note-aware agent tools can read the same extracted text. Search keeps protected OCR text inside the protected-session boundary.

This creates one path from a binary source to search results and chat context:

flowchart LR
    A[Image or document] --> B[Text extraction]
    B --> C[Stored text representation]
    C --> D[Search]
    C --> E[Note and attachment tools]
    D --> F[Ranked result and snippet]
    E --> G[Agent answer or note action]

References: packages/…/ocr_content.ts• L47-143 packages/…/helpers.ts• L89-114 packages/…/attachment_tools.ts• L37-69

Import services

Common import pipeline

The import system changes uploaded files and archives into notes under a selected parent. A shared dispatcher chooses the source format, creates notes and attachments, applies content processing, and reports completion only after pending image writes finish.

The goal is to preserve meaning in the note tree rather than only copy source bytes. Text and Markdown become editor content. CSV and XLSX can become editable spreadsheet notes when that choice is enabled. Other sources keep the note type that supports them. Imports can carry hierarchy, labels, relations, internal links, attachments, and source dates when the source provides them.

Large archive imports use a scan phase and bounded batches. Link and relation writes wait until their targets exist. Markdown front matter becomes labels, and safe HTML and attribute handling prevents imported content from becoming active server behavior.

References: packages/…/dispatch.ts• L26-53 packages/…/single.ts• L23-87 packages/…/zip.ts• L505-537 packages/…/zip.ts• L669-803 packages/…/zip.ts• L818-980 packages/…/import.ts• L19-89

Source format adapters

Source adapters rebuild the useful structure of common knowledge-base exports. They preserve each source's main hierarchy and links while rejecting export shapes that do not contain enough data for a reliable tree.

SourceResulting model
Text, Markdown, HTML, code, image, spreadsheet, or fileOne editable or binary note suited to the source
Trilium ZIP, generic ZIP, OPML, or ENEXA reconstructed tree with links, attributes, and attachments where available
Obsidian vaultFolder notes, Markdown pages, wikilinks, labels, and supported canvas drawings
Notion HTML exportNested pages, attachments, links, and database pages as table-like collections
Google Keep TakeoutText or checklist notes with colors, dates, and media attachments
Anytype JSON exportPages, collections, properties, files, and cross-page links

Markdown front matter becomes labels rather than executable relations. ZIP restore flows remap IDs and rewrite relative links so imported entities do not point at the source tree. The archive reader also detects an Obsidian vault before normal ZIP processing and keeps spreadsheet conversion consistent with single-file import.

References: packages/…/dispatch.ts• L55-91 packages/…/markdown.ts• L21-80 packages/…/markdown.spec.ts• L60-104 packages/…/single.ts• L44-87 packages/…/importer.ts• L1-33 packages/…/importer.ts• L38-65 packages/…/importer.ts• L51-71 packages/…/zip.ts• L30-73 packages/…/zip.ts• L818-859

OneNote import workflow

OneNote import is a network-backed service that uses Microsoft Graph to bring selected notebooks, groups, sections, pages, resources, and handwriting into the note tree. The web client signs in through device authorization, lets the user choose notebooks and sections, and starts the long work in the background.

The importer first fetches the selected source data, then creates the note tree in one creation phase. It preserves notebook, group, section, and subpage structure. It converts OneNote's free-form HTML into editor content, including reading order, task tags, formatting, tables, images, captions, and code blocks. It downloads page resources with bounded concurrency, turns InkML handwriting into an SVG attachment, rewrites internal page links after all targets exist, and preserves the source dates.

The import keeps partial work understandable. A password-protected section becomes a locked placeholder with user guidance. A page or resource failure becomes a visible placeholder or stays as an unresolved source link, while the report records the loss. Six consecutive section-list or page-fetch failures stop the run when they indicate an expired token or Graph outage. Graph throttling follows Retry-After, refreshes the access token before a retry, reports a throttled progress phase, and records the wait in the final report. A transient gateway timeout has a shorter request retry limit than the shared throttle window.

This flow separates external fetch work from note creation so the user can see the source tree and a durable report even when individual pages or resources fail:

flowchart LR
    A[Select OneNote sections] --> B[Graph sign-in and enumeration]
    B --> C[Fetch pages and resources]
    C --> D[Convert HTML and handwriting]
    D --> E[Create notebook and page tree]
    E --> F[Rewrite links and attach media]
    F --> G[Import report and task completion]
    B --> H[Locked or failed placeholder]
    C --> H

References: apps/…/onenote_import.ts• L33-51 apps/…/onenote_import.ts• L161-172 apps/…/graph.spec.ts• L62-263 apps/…/graph.spec.ts• L455-497 apps/…/token_provider.spec.ts• L27-118 apps/…/converter.ts• L114-135 apps/…/converter.spec.ts• L331-355 apps/…/importer.ts• L114-241 apps/…/importer.ts• L269-455 apps/…/importer.spec.ts• L216-365 apps/…/importer.spec.ts• L408-566 apps/…/inkml.ts• L106-133 apps/…/links.ts• L30-68 apps/…/links.spec.ts• L41-165

LLM providers and tools

Provider catalog

The LLM layer gives chat one provider-neutral way to choose a model, stream a reply, report usage, and name a new chat. It supports hosted APIs, OpenAI-compatible endpoints, the OpenRouter model gateway, and host-authenticated agent providers. Model lists can come from a live endpoint and are merged with local price and context metadata, so availability follows the account while known cost data stays consistent.

The catalog reports authentication and endpoint failures during setup instead of silently showing models that cannot run. OpenRouter can report the model that actually answered when its router or an alias selects a different model, along with the cost for the turn. Provider model selections also carry attachment support and reasoning options when the provider supplies them.

The server adds providers that need Node and a host program. Claude Code, GitHub Copilot, Google Antigravity, and OpenAI Codex use the account and login state of their installed tools, so a subscription path can work without a Trilium API key. Provider modules load on first use so every server start does not load every agent stack.

Host providers locate a user-supplied binary through an explicit path or the normal and login-shell paths. They probe it before chat and keep concurrent first probes to one operation. In a Flatpak, the same boundary can find and launch the tool on the host when the sandbox has permission. Setup errors stay visible when a binary is missing, an account is not signed in, or a probe fails. Subscription models are treated as plan-covered rather than as metered token prices.

References: packages/…/base_provider.ts• L53-93 packages/…/base_provider.ts• L155-203 packages/…/base_provider.ts• L261-299 packages/…/google.ts• L43-85 packages/…/openrouter.ts• L42-195 packages/…/index.ts• L15-86 packages/…/index.ts• L101-207 apps/…/binary_lookup.ts• L1-20 apps/…/binary_lookup.ts• L51-77 apps/…/binary_lookup.ts• L121-169 apps/…/binary_lookup.spec.ts• L70-164 apps/…/claude_binary.ts• L1-79 apps/…/copilot_binary.ts• L1-80 apps/…/antigravity_binary.ts• L1-95 apps/…/codex_binary.ts• L1-82 apps/…/codex_binary.spec.ts• L19-98

Agent chat sessions

Agent providers run their own loops and keep host-side conversation sessions. The server maps a chat note to an agent session and resumes it only when the transcript, process generation, model context, and note-tool setting still match.

When a session is lost or the conversation changes, the server replays the retained transcript into a fresh session. Claude keeps warm sessions per chat and reaps idle processes. ACP providers share a warm process across turns and chats, then remove a failed process so the next turn starts from a clean generation. A client abort cancels only that turn.

The shared stream can show text, thinking, tool calls, tool results, usage, citations, approval requests, and errors. Usage covers the complete tool loop rather than only its last model call. Provider-specific reports can replace the requested model and estimated cost when a router selects the actual model and billing data.

The current note is supplied as a small metadata hint in the user turn. It gives the model useful context without moving changing note data into the cached system prompt. If the user attaches files, the hint tells the model to treat those files as the main subject. Chat resolves the provider and attachment capabilities from stored configuration rather than trusting those values from the request.

Note tools are opt-in for agent chats. Claude uses an in-process MCP bridge when the chat enables them, while its host tools remain disabled. ACP agents use the same note contract through their controlled bridge or hooks. A host agent that is not configured for note access receives neither the note tools nor their guidance.

References: packages/…/note_hint.ts• L14-36 packages/…/chat.ts• L36-135 packages/…/base_provider.ts• L317-475 packages/…/base_provider.ts• L501-600 packages/…/stream.ts• L119-263 apps/…/acp_agent.ts• L448-660 apps/…/acp_agent.spec.ts• L67-145 apps/…/acp_client.ts• L183-244 apps/…/acp_client.spec.ts• L133-284 apps/…/claude_agent.ts• L282-409 apps/…/claude_agent.ts• L681-749 apps/…/claude_agent.spec.ts• L552-722 apps/…/claude_agent.spec.ts• L779-805 apps/…/codex_agent.spec.ts• L173-264 apps/…/transcript.ts• L14-67

Web search tools

Web search gives an agent current public information without tying chat to one model vendor. A configured search provider returns a bounded set of sources, and a separate page reader fetches a selected HTTP or HTTPS page as Markdown for closer review.

The chat turn names a stored search-provider configuration. Request data cannot replace its credentials or endpoint. The page reader removes page furniture and limits both response size and returned text. Search and page reads follow the chat turn's cancellation signal. Provider errors tell the agent when the user must fix a key, endpoint, account balance, or search service rather than retrying the same request.

References: packages/…/web_search.ts• L26-75 packages/…/web_search.ts• L81-150 packages/…/web_search.ts• L159-211 packages/…/web_search.ts• L253-311 packages/…/chat.ts• L42-62 packages/…/index.ts• L101-115

Note-aware tools

Note access is an explicit chat capability. When enabled, an agent can search and read notes, inspect attachments, navigate the tree, inspect or change labels and relations, and create or edit notes. When it is not enabled, the agent does not receive the note tool surface. Notes marked with the excludeFromLlm label, including inherited exclusions, appear as missing to these tools and disappear from visible search, hierarchy, relation, and attachment results.

The tools use the same note services as the rest of the server. Read results are bounded. Mutating calls use the server request context and a transaction. Content edits can replace a note, append to it, or apply unique exact replacements. Attribute changes can replace one value, add another value, or target a specific attribute. They preserve revision and protection rules, reject system-note changes, and ask for user approval when the provider requires it. Attributes that could run code are saved in a disabled form until the user enables them.

References: packages/…/helpers.ts• L32-77 packages/…/index.ts• L23-50 packages/…/tool_registry.ts• L49-75 packages/…/note_tools.ts• L17-63 packages/…/note_tools.ts• L101-270 packages/…/attribute_tools.ts• L58-129 packages/…/hierarchy_tools.ts• L59-195 packages/…/attachment_tools.ts• L13-69 packages/…/exclude_from_llm.spec.ts• L59-132 packages/…/system_prompt.ts• L36-60 apps/…/mcp_server.ts• L20-47

Skill sheets

Skill sheets give an agent detailed guidance only when a task needs it. The catalog covers search syntax, backend and frontend scripting, and dashboards; a host supplies the matching Markdown and can add an API reference for scripting skills. This keeps the base prompt short while giving the agent a controlled source for product-specific instructions.

References: packages/…/skills.ts• L15-27 packages/…/skills.ts• L30-57 packages/…/skills.ts• L59-97

Agent boundaries

Each host agent has a narrow boundary because it runs near the server's files and credentials. Claude and Copilot deny built-in file, shell, and network tools. Antigravity and Codex use hooks and permission callbacks to allow Trilium note tools while denying other host access. Web access is opt-in and limited to public HTTP or HTTPS addresses.

The Agent Client Protocol (ACP) carries JSON-RPC messages between the server and Copilot, Antigravity, or OpenAI Codex. Its client handles framing, request replies, agent requests, cancellation, and process failure. It can host an external process or a worker, and it ends child process trees when the server exits. Permission requests fail closed when they do not identify an approved Trilium tool or when the bridge cannot answer.

References: apps/…/acp_agent.ts• L764-839 apps/…/acp_agent.spec.ts• L17-77 apps/…/acp_client.ts• L86-180 apps/…/acp_client.spec.ts• L201-348 apps/…/claude_agent.ts• L681-749 apps/…/claude_agent.spec.ts• L641-733 apps/…/copilot_agent.ts• L51-65 apps/…/antigravity_agent.ts• L208-240 apps/…/codex_agent.ts• L122-161 apps/…/codex_agent.spec.ts• L173-209 apps/…/codex_hook.spec.ts• L22-88 apps/…/binary_lookup.ts• L121-169 apps/…/binary_lookup.ts• L274-355

MCP integration

Shared MCP tool surface

The Model Context Protocol (MCP) exposes the same note-aware tools to external agents and in-app agents. A shared MCP server registers note, attribute, attachment, hierarchy, icon, skill, and help tools so both paths act on the same product contract.

Read calls run in the request context. Mutating calls also use a database transaction. Results are returned as text containing the structured tool result, and error results are marked as errors so an agent cannot mistake failure for success.

References: apps/…/mcp_server.ts• L20-70 packages/…/index.ts• L23-50

Public MCP endpoint

The public MCP surface is a stateless Streamable HTTP endpoint at /mcp. It is available only when the mcpEnabled option is on, and every request must carry a valid ETAPI bearer token. Cookie access is not accepted because a browser page must not be able to trigger note operations through a session cookie.

Failed token checks are rate-limited per IP. Valid clients are not blocked by the failed-auth budget, which supports clients that share a proxy address.

References: apps/…/mcp.ts• L19-27 apps/…/mcp.ts• L29-61 apps/…/mcp.ts• L64-111 apps/…/mcp.ts• L125-148

Private agent MCP bridge

In-app agents use a separate MCP path. Claude receives an in-process server through its agent SDK. ACP agents receive a short-lived HTTP server on loopback because ACP accepts MCP servers by URL.

The private bridge uses a random secret path, a pinned local host, a request-size limit, and per-request cleanup. It follows the chat's Note access setting and does not depend on the public mcpEnabled option. Antigravity and Codex also use private hook paths for tool decisions.

References: apps/…/claude_agent.ts• L725-745 apps/…/claude_agent.spec.ts• L552-569 apps/…/acp_mcp_endpoint.ts• L1-21 apps/…/acp_mcp_endpoint.ts• L35-55 apps/…/acp_mcp_endpoint.ts• L85-124 apps/…/acp_mcp_endpoint.ts• L154-213

Scripting and automation safeguards

Backend script execution

Backend scripting is a high-power automation feature that can access the server. It is disabled by default behind backendScriptingEnabled, and every execution path uses the same central guard.

The guarded paths include submitted script code, backend JavaScript notes, script-based search results, scheduled jobs, and event handlers. Script notes must use the backend JavaScript environment. Protected script notes also need an available protected session. Scheduled and event work stops when scripting is disabled or the server is in safe mode.

References: packages/…/scripting_guard.ts• L1-27 packages/…/script.ts• L24-79 packages/…/script.ts• L23-89 packages/…/scheduler.ts• L26-70

SQL console

The SQL console is a separate administrative capability for inspecting the schema and running SQL stored in a note. It is disabled by default behind sqlConsoleEnabled, runs statements separately, and returns rows for read statements or execution results for other statements.

SQL access remains separate from backend scripting. This gives operators an explicit database-control boundary instead of treating SQL as an automatic side effect of script access.

References: packages/…/sql.ts• L14-75 packages/…/scripting_guard.ts• L16-23

Outbound request safety

Intelligence features that contact a URL use a shared outbound request boundary. It checks the URL, resolves every address, rejects unsafe address ranges by default, and pins the connection to the checked addresses.

The policy is strict because URLs can come from note content. Redirects are bounded and credentialed callers must revalidate each hop. An operator-configured local model endpoint may use private addresses, but note-derived URLs and agent web tools remain restricted to their own safe policies.

References: apps/…/safe_fetch.ts• L14-48 apps/…/safe_fetch.ts• L67-100 apps/…/safe_fetch.ts• L204-268 apps/…/antigravity_agent.ts• L403-413 apps/…/codex_hook.ts• L74-99

Operational interfaces

HTTP and task interfaces

These services use short HTTP calls for commands and streams or background tasks for work that can outlive a request. The interface determines how a caller observes progress and how the server stops work when the caller leaves.

CapabilityInterfaceOperational behavior
SearchSearch API handlers and saved search notesReturns ranked note IDs, paths, snippets, highlights, and query errors
OCR/api/ocr/process-note/{noteId}, /api/ocr/process-attachment/{attachmentId}, /api/ocr/batch-process, /api/ocr/batch-progressProcesses one source or reports a cancellable batch
File importImport API under a parent noteReports staged progress and waits for content work before completion
OneNote import/api/onenote-import/*Uses device login, selection, and background progress
LLM chat/api/llm-chat/streamStreams JSON events as SSE and cancels on client close
Model setupProvider model-listing handlerProbes live catalogs and reports credential or endpoint errors during setup
External agent access/mcpUses stateless MCP over HTTP with the public security setting and ETAPI tokens
Backend scripts and SQLScript and SQL API handlersRequire separate security settings before execution

The shared operational pattern is visible in the flow below.

flowchart LR
    A[HTTP command] --> B{Work duration}
    B -->|Short| C[HTTP result]
    B -->|Long| D[Task or stream]
    D --> E[Progress or events]
    D --> F[Cancel on owner disconnect]

References: packages/…/search.ts• L55-115 apps/…/ocr.ts• L13-191 packages/…/import.ts• L19-139 apps/…/onenote_import.ts• L126-157 apps/…/llm_chat.ts• L22-59 packages/…/chat.ts• L22-135 apps/…/mcp.ts• L19-27

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep OCR processor support aligned with batch discovery, protected storage, search, attachment reads, and agent attachment handling.
  • Keep PDF extraction aligned across embedded-text detection, page rendering, the 50-page scan cap, confidence reporting, and packaged PDFium assets.
  • Keep the import dispatcher aligned with source validation, safe HTML and attributes, spreadsheet choices, Markdown front matter, attachment handling, link rewriting, and task completion.
  • Keep OneNote conversion aligned with Graph HTML shapes, resource markers, InkML rendering, internal link identity, source dates, and the final import report.
  • Keep OneNote Graph retry behavior aligned across Retry-After, token refresh, throttled progress, gateway timeout limits, and the section/page failure breakers.
  • Keep search query permissions aligned with regex exposure, fuzzy matching settings, structured highlights, snippets, and autocomplete result limits.
  • Keep host provider identifiers aligned across registration, binary lookup, version probing, model selection, subscription metadata, streaming, and setup errors.
  • Keep live provider catalogs aligned with price-table metadata, model defaults, recommendation rules, attachment support, reasoning options, routed-model reporting, and cached setup results.
  • Keep ACP session reuse aligned with transcript hashes, process generations, model context, note access, warm-process cleanup, and cancellation.
  • Keep provider hooks aligned with note-tool approval, MCP identity, web access, public-address checks, and fail-closed behavior.
  • Keep public MCP authentication separate from private loopback agent MCP access. Changes to one must not widen the other.
  • Keep agent file and shell boundaries aligned with the host process, private agent home, hook paths, binary probes, Flatpak launcher, and server shutdown cleanup.
  • Keep every backend script entry point behind the central scripting guard, including search, scheduled, event-driven, and API-triggered paths.
  • Keep LLM exclusion filtering aligned across note hints, search results, hierarchy, attributes, relations, attachments, and destructive actions.
  • Keep task progress and stream cancellation aligned with client disconnects so long imports, OCR runs, and agent turns do not continue without an owner.

Important failure modes

TriggerConsequenceGuard
A protected source has no open protected sessionOCR cannot read the bytes and search must not see a stored clear-text copySkip OCR until the source is available and store protected OCR text in protected form
A PDF has too many scanned pages or an oversized pageOCR can consume excessive time or memory, or later pages can lack textCap scanned pages at 50 and keep rendering within the pixel budget
A ZIP contains a malformed link, dangerous attribute, or unsafe HTMLImported notes can point outside the new tree or activate imported behaviorRemap IDs, delay relations until targets exist, and sanitize content and dangerous attributes when safe import is enabled
OneNote Graph throttles or returns repeated page or section failuresA long import can appear stuck or create a misleading placeholder-only resultHonor Retry-After, refresh tokens before retries, show the throttled phase, and stop after the systemic-failure threshold
A OneNote page has unsupported HTML, a missing resource, or unreadable InkMLThe page can lose layout or media while the rest of the notebook remains usableNormalize supported editor shapes, download resources with a bounded pool, keep failed references visible, and report the loss
A host agent is missing, signed out, or cannot return its catalogProvider setup can show models that will fail at first useProbe the live host catalog or binary and surface an actionable setup error
A provider model list is stale or does not match its price metadataA user can select an unavailable model or see incomplete cost informationTreat the live endpoint as the availability source and merge it with the local metadata table
An OpenRouter router or alias answers with a different modelThe usage display can name the requested model instead of the model that ranUse the completed turn report and provider billing metadata when available
A transcript or capability setting differs from a warm agent sessionThe reply can use the wrong history or note accessCompare transcript, generation, model context, and note-tool state before resume
A client disconnects during an agent turnA subprocess or agent loop can continue without a readerCancel the turn and dispose or evict the affected session
An agent requests host file, shell, or network accessChat can read or change server-host dataDeny built-in tools and allow only the intended note tools or opt-in public web path
A note excluded from LLM access is passed to a tool or note hintThe agent can see or change data the user marked privateTreat excluded notes, related attributes, attachments, and hidden parents as unavailable
A public MCP request lacks a valid ETAPI tokenAn external caller could read or change notesRequire bearer-token authentication and rate-limit failed checks
A private ACP request uses the wrong host or secret pathNote tools can fail or a local caller can reach the bridgeBind to loopback, use random paths, pin the host, and bound request bodies
A backend script or SQL call bypasses its settingA client can gain server or database controlKeep central scripting and separate SQL guards at the execution boundary

Key files

FileWhy to read it
apps/…/ocr_service.tsCoordinates OCR processors, language selection, protected storage, batches, and progress.
apps/…/pdf_processor.tsShows how embedded PDF text and scanned pages become one bounded result.
apps/…/pdf_renderer.tsDefines the safe rendering boundary for scanned PDF pages.
apps/…/tesseract_recognizer.tsDefines image recognition, confidence filtering, and language worker reuse.
packages/…/search.tsDefines query execution, fuzzy fallback, ranking, snippets, and highlights.
packages/…/search_context.tsDefines search scope, matching permissions, and result state.
packages/…/ocr_content.tsConnects OCR text on notes and attachments to scoped search results.
packages/…/dispatch.tsDefines source selection and the common import completion boundary.
packages/…/single.tsShows single-file note type selection and content handling.
packages/…/zip.tsShows staged archive import, Markdown and spreadsheet handling, link rewriting, attachments, and progress.
apps/…/graph.tsDefines the Graph view of OneNote trees, page content, resources, retries, and error classes.
apps/…/converter.tsDefines how OneNote page content becomes safe editor content.
apps/…/importer.tsCoordinates OneNote fetch, tree creation, media, links, placeholders, and reporting.
apps/…/inkml.tsConverts OneNote handwriting into a bounded theme-aware image.
apps/…/links.tsResolves OneNote page links against the imported note tree.
packages/…/index.tsResolves stored chat and search providers and their selected model metadata.
packages/…/base_provider.tsDefines shared model catalogs, attachment handling, note context, tools, streams, and titles.
packages/…/google.tsShows live Gemini model filtering and the boundary between web search and note tools.
packages/…/openrouter.tsShows routed model discovery, reasoning choices, attachment limits, and turn billing.
packages/…/chat.tsCoordinates provider resolution, tool approval, cancellation, streaming, and chat titles.
packages/…/stream.tsConverts provider output into text, tool, citation, usage, and error events.
packages/…/skills.tsDefines the on-demand product guidance available to agents.
packages/…/helpers.tsDefines LLM visibility, content conversion, previews, and bounded metadata.
packages/…/note_tools.tsDefines note search, reading, editing, creation, and deletion through the agent tool surface.
packages/…/attribute_tools.tsDefines label and relation access, including disabled code-running attributes.
packages/…/hierarchy_tools.tsDefines tree navigation, moves, and clones for agents.
packages/…/attachment_tools.tsDefines attachment metadata and OCR or text reads.
apps/…/binary_lookup.tsDefines host PATH lookup, version probes, and Flatpak host launch.
apps/…/acp_agent.tsDefines shared ACP sessions, streams, permissions, attachments, and model probes.
apps/…/acp_client.tsDefines ACP transport and agent process lifecycle.
apps/…/transcript.tsDefines session matching and transcript replay.
apps/…/claude_agent.tsShows Claude's host-agent boundary, opt-in note tools, live catalog, and warm chat behavior.
apps/…/copilot_agent.tsShows Copilot model discovery and tool denial.
apps/…/antigravity_agent.tsShows Google sign-in, model variants, hooks, and public web checks.
apps/…/codex_agent.tsShows Codex sessions, model variants, web citations, and permission checks.
apps/…/mcp_server.tsBuilds the shared MCP tool surface with transaction handling.
apps/…/acp_mcp_endpoint.tsDefines the private loopback MCP and hook bridge.
apps/…/mcp.tsDefines public MCP authentication and HTTP access.
packages/…/scripting_guard.tsDefines the scripting and SQL security boundary.
packages/…/script.tsShows the common backend script execution path.
packages/…/sql.tsDefines the SQL console interface.
apps/…/safe_fetch.tsDefines outbound URL checks, address pinning, and redirect policy.