Skip to content

AI integration using freellmapi - #3084

Open
abdelrahmanelnabawy wants to merge 5 commits into
standardnotes:mainfrom
abdelrahmanelnabawy:main
Open

abdelrahmanelnabawy wants to merge 5 commits into
standardnotes:mainfrom
abdelrahmanelnabawy:main

Conversation

@abdelrahmanelnabawy

Copy link
Copy Markdown

feat(desktop): Add Local AI Notes Assistant (FreeLLM API)

Summary

Introduces a Desktop-only Local AI Notes Assistant (packages/web/src/freellmapi) that connects to any locally hosted, OpenAI-compatible Responses API (POST <baseURL>/responses), including FreeLLM API, Ollama, and LM Studio.

The assistant enables users to interact with their decrypted notes through natural language, including browsing, searching, reading, editing, creating, and recovering notes — all locally.

Key Features

1. Multi-Step AI Agent for Note Browsing & Editing

  • Implements an autonomous tool-calling loop supporting:
    • list_notes
    • search_notes
    • read_note
    • open_note
    • edit_note
    • create_note
  • Supports the following note types:
    • NoteType.Super (through HeadlessSuperConverter)
    • RichText
    • Markdown
    • Plain
    • Code
    • Task
    • Spreadsheet
  • Provides a safe, review-first editing workflow with before/after diff cards:
    • Approve & Apply
    • Dismiss
  • Includes an optional Auto-edit toggle.
  • Adds convenient actions:
    • + Create Note
    • + Add Notation
    • Save File (.md)

2. Lost Information Detection & Recovery

Introduces dedicated tools and a built-in Recovery interface to help users locate and restore missing information.

  • find_lost_info — Performs multi-keyword fuzzy searches across:
    • Active notes
    • Archived notes
    • Trash
    • Local Session History
    • AI Pre-Edit Snapshots
    • Loaded Local Backup files (.json, .md, .txt)
  • get_note_history — Inspects AI snapshots, local session history, and remote revision history.
  • audit_missing_info — Identifies:
    • Untitled notes
    • Empty note stubs
    • Unfinished placeholders (TODO, TBD, FIXME, ???, [ ])
  • restore_note — Supports note restoration through the built-in Recovery drawer.

The Recovery drawer includes:

  • Undo Snapshots
  • Local Backup file loader
  • Trash restoration
  • Archive restoration

3. GUI Configuration & Preferences

Adds a Desktop-only configuration experience through:

  • Preferences → AI / FreeLLM API
  • An inline Settings drawer inside the AI panel.

Available configuration options:

  • Base URL
  • API Key (with show/hide functionality)
  • Model
  • Quick connection presets:
    • FreeLLM Local
    • Ollama
    • LM Studio
  • Custom Instructions
  • Max Agent Steps
  • Auto-edit

Also includes a live Test Connection feature with latency reporting.

Changes Overview

New Module — packages/web/src/freellmapi/

Introduces 12 new files:

File | Purpose -- | -- config.ts | Configuration management client.ts | API client noteConverter.ts | Note format conversion noteOperations.ts | Note operations noteTools.ts | AI agent tool definitions recoveryStore.ts | Recovery and snapshot storage FreeLlmApiController.ts | Main controller FreeLlmApiPanel.tsx | AI assistant interface FreeLlmApiFooterButton.tsx | Footer integration FreeLlmApiPreferencesPane.tsx | Preferences UI index.ts | Module exports freellmapi.spec.ts | Unit tests

Desktop Integration

Updates 13 existing files, with +45 / -11 lines, covering:

  • Dependency injection and Desktop-only gating (isDesktopDevice):
    • Types.ts
    • WebDependencies.ts
    • WebApplication.ts
  • UI integration:
    • ApplicationView.tsx
    • Footer.tsx
  • Preferences registration:
    • PreferenceId.ts
    • StatusService.ts
    • PreferencesSessionController.ts
    • PaneSelector.tsx
  • Build, lint, and styling configuration:
    • tsconfig.json
    • web.webpack.config.js
    • tailwind.config.js
    • packages/web/package.json

Documentation

Updated README.md with:

  • Build instructions
  • GUI configuration and setup
  • CORS configuration
  • Security and privacy details

Security & Privacy

The implementation includes several security and privacy safeguards:

  • Desktop-only availability: The assistant is disabled on Web and Mobile. freeLlmApiController is undefined outside the Desktop environment.
  • No hardcoded API credentials: The apiKey defaults to an empty string ('') and must be configured through the GUI.
  • Sensitive note exclusion: Protected, locked, and 2FA (NoteType.Authentication) notes are always excluded from read and write operations.
  • No plaintext snapshot persistence: Pre-edit undo snapshots are stored exclusively in workspace-scoped RAM and automatically wiped on:
    • App lock
    • Sign-out
    • deinit()
  • XSS and input protection:
    • Escapes RichText HTML headings and content.
    • Limits backup imports to 25 MB per file.
    • Limits backup imports to 5,000 records.
    • Enforces a 90-second request timeout.

Verification & Testing

All checks completed successfully:

  • yarn workspace @standardnotes/web lint — ESLint and TypeScript checks passed (0 errors).
  • yarn workspace @standardnotes/services lint — Passed (0 errors).
  • yarn workspace @standardnotes/web test src/freellmapi/freellmapi.spec.ts — 10/10 tests passing.
  • yarn build:desktop — Full @standardnotes/web and @standardnotes/desktop production build completed successfully (exit code 0).

Related Commits

  • b3fcc1630
  • 3d3bd1624
  • 22c4d44b0

Result: A fully integrated, Desktop-only local AI notes assistant with multi-step agentic capabilities, safe note editing, lost-information recovery, and configurable local LLM connectivity.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant