# Copilot Personal v1.4.5 โ€” Obsidian AI Agent Plugin AI assistant for Obsidian. Multimodal chat with real streaming, RAG semantic search, autonomous agent (17 tools), 11 LLM providers, multi-provider fallback, PDF processing with `unpdf`, Free/Pro licensing with cloud validation + grace period, CircuitBreaker on all providers, dual-build (store/obfuscated). 151 tests. TypeScript strict mode. > ๐Ÿ“– [Spanish documentation](DOCUMENTATION_ES.md) > โš ๏ธ **Commercial Disclosure:** This plugin offers a Free tier (unlimited basic chat, 50 messages/day, 3 tools) and a **Pro tier** ($4.99/mo via Lemon Squeezy) that unlocks Agent Mode, web search, semantic RAG, PDF image extraction, and multi-provider fallback. The Pro tier requires a paid license key validated against a Cloudflare Worker (`copilot-personal-worker.copilot-personal.workers.dev`). No account or payment is required for the Free tier. No telemetry or analytics are collected. --- ## Key Features | Feature | Description | |---------|-------------| | **Multimodal Chat** | Real streaming chat (fetch + ReadableStream) with file drag & drop | | **Agent Mode** | Autonomous tool-calling loop with 17 tools, LLM-based classification, anti-loop, plan tracker | | **Semantic RAG** | Vault indexing with embeddings, cosine similarity search, JSON persistence | | **Advanced PDF** | Text extraction, page rendering to PNG, embedded image extraction with `unpdf` | | **11 LLM Providers** | DeepSeek, OpenAI, Anthropic, Gemini, LM Studio, OpenRouter, Mistral, Groq, Perplexity, xAI | | **Per-Provider API Keys** | Each provider stores its own key โ€” switching from DeepSeek to Gemini won't mix keys | | **Multi-Provider Fallback** | Automatic capability compensation (Pro) โ€” e.g., DeepSeek for chat + LM Studio for embeddings | | **Free/Pro Licensing** | Cloud-based validation via Cloudflare Worker, device binding, grace period, rate limiting | | **CircuitBreaker** | 3 failures โ†’ 30s open + exponential backoff on all providers | | **Intelligent Auto-Save** | Multi-note detection, invented wiki-link validation, automatic save | | **Slash Commands** | `/summarize`, `/translate`, `/explain`, `/toc`, `/flashcards`, `/rewrite`, `/expand` | | **Chat Export** | Markdown + JSON via commands (Ctrl+P) | | **Model-Specific Adapters** | Optimized system prompts per model family (anti-verbose, anti-hallucination) | | **Context Management** | Map-Reduce compaction, L1-L5 layers, auto-trim, CURRENT TASK reminders | | **Real-Time UI Updates** | Header badges (Local/Cloud, Free/Pro) and model selector refresh instantly on settings change | --- ## Architecture ``` src/ โ”œโ”€โ”€ main.ts # Plugin entry point โ”œโ”€โ”€ settings.ts # Settings interface & defaults โ”œโ”€โ”€ settingsTab.ts # Settings UI tab โ”œโ”€โ”€ chatView.ts # Chat ItemView (main orchestrator) โ”œโ”€โ”€ constants.ts # Centralized constants โ”œโ”€โ”€ LLMProviders/ # 11 providers with native tool calling โ”‚ โ”œโ”€โ”€ providerTypes.ts # LLMProvider interface, capabilities โ”‚ โ”œโ”€โ”€ providerManager.ts # Factory: auto-detect & multi-provider routing โ”‚ โ”œโ”€โ”€ deepseekProvider.ts # DeepSeek (OpenAI-compatible + thinking mode) โ”‚ โ”œโ”€โ”€ openaiProvider.ts # OpenAI / OpenAI-compatible APIs โ”‚ โ”œโ”€โ”€ anthropicProvider.ts # Anthropic Messages API (native input_schema) โ”‚ โ”œโ”€โ”€ geminiProvider.ts # Gemini API (native functionDeclarations) โ”‚ โ””โ”€โ”€ baseOpenAIProvider.ts # Shared logic for OpenAI-compatible providers โ”œโ”€โ”€ agent/ # Autonomous agent system โ”‚ โ”œโ”€โ”€ ToolRegistry.ts # Singleton: register, get, execute tools โ”‚ โ”œโ”€โ”€ AgentModeRunner.ts # Main tool-calling loop โ”‚ โ”œโ”€โ”€ ToolRouter.ts # LLM-based task classification โ†’ tool selection โ”‚ โ”œโ”€โ”€ PlanTracker.ts # Execution plan state tracking โ”‚ โ”œโ”€โ”€ ContextCompactor.ts # Map-Reduce context summarization โ”‚ โ””โ”€โ”€ ContextLayers.ts # L1-L5 context layer system โ”œโ”€โ”€ tools/ # 17 agent tools โ”‚ โ”œโ”€โ”€ FileParserManager.ts # PDF, image, text file parsers โ”‚ โ”œโ”€โ”€ readNoteTool.ts # read_note (4 search strategies + path traversal protection) โ”‚ โ”œโ”€โ”€ readPdfTool.ts # read_pdf (TOC + pages + auto-find) โ”‚ โ”œโ”€โ”€ createNoteTool.ts # create_note โ”‚ โ”œโ”€โ”€ updateNoteTool.ts # update_note (post-write verification) โ”‚ โ”œโ”€โ”€ renderPdfPagesTool.ts # render_pdf_pages (pages to PNG, 144 DPI) โ”‚ โ”œโ”€โ”€ extractPdfImagesTool.ts # extract_pdf_images (embedded images + fallback) โ”‚ โ”œโ”€โ”€ imageAnalysisTool.ts # analyze_image (vision model) โ”‚ โ”œโ”€โ”€ semanticSearchTool.ts # search_vault_semantic โ”‚ โ”œโ”€โ”€ webSearchTool.ts # search_web (browser-use microservice) โ”‚ โ””โ”€โ”€ additionalTools.ts # list_notes, fulltext_search, vault_stats, etc. โ”œโ”€โ”€ search/ # RAG semantic search โ”‚ โ”œโ”€โ”€ vectorStoreManager.ts # In-memory cosine similarity + JSON persistence โ”‚ โ”œโ”€โ”€ indexOperations.ts # Chunking, embedding, batch indexing โ”‚ โ”œโ”€โ”€ indexEventHandler.ts # Auto-reindex on create/modify/delete โ”‚ โ”œโ”€โ”€ hybridRetriever.ts # Hybrid search (vector + fulltext) โ”‚ โ””โ”€โ”€ reranker.ts # Result re-ranking โ”œโ”€โ”€ services/ โ”‚ โ”œโ”€โ”€ LicenseManager.ts # Cloud-first license validation + rate limiting โ”‚ โ”œโ”€โ”€ webSearchClient.ts # HTTP client for Python microservice โ”‚ โ””โ”€โ”€ lmStudioService.ts # LM Studio model detection (/v1/models) โ”œโ”€โ”€ memory/ โ”‚ โ””โ”€โ”€ MemoryManager.ts # Persistent conversation summaries โ”œโ”€โ”€ components/ โ”‚ โ”œโ”€โ”€ ChatHistoryBrowser.ts # Chat history navigator โ”‚ โ””โ”€โ”€ ApplyView.ts # Diff view for โ””โ”€โ”€ utils/ โ””โ”€โ”€ pathUtils.ts # Path normalization, fetch fallback, timeouts ``` --- ## Installation ### Quick Install ```bash cd "YourVault/.obsidian/plugins" git clone https://github.com/JosefBelzer/Copilot-Personal.git cd copilot-personal npm install npm run build ``` ### Build Modes ```bash npm run build # Obfuscated main.js (external distribution: ZIP, Gumroad, BRAT) npm run build:store # Clean main.js (PR to Obsidian Community Plugins) npm run dev # Dev mode with sourcemaps and watch ``` > โš ๏ธ **For Obsidian Community Plugin submission:** use ONLY `npm run build:store`. > Obfuscated builds (`npm run build`) will be REJECTED by reviewers. Obfuscation is for external distribution only. ### Manual Install 1. Download ZIP from [Releases](https://github.com/JosefBelzer/Copilot-Personal/releases) 2. Extract to `YourVault/.obsidian/plugins/copilot-personal/` 3. Enable in Settings โ†’ Community plugins โ†’ Copilot Personal ### Web Search Server (optional) ```bash cd web_search_server pip install -r requirements.txt set COPILOT_WEB_TOKEN=your-secure-token uvicorn main:app --host 127.0.0.1 --port 8000 ``` --- ## Free vs Pro Licensing ### ๐Ÿ†“ Free (default) - Unlimited basic chat - 50 messages/day (persistent across restarts) - 3 tools: `read_note`, `read_pdf`, `find_files` - Pro options appear **disabled** (๐Ÿ”’) in settings UI ### โญ Pro ($4.99/mo via Lemon Squeezy) - **Unlimited messages** ยท **Agent mode** (17 tools) - **Web search** ยท **PDF with images** ยท **Semantic RAG** - **Chat export** (MD/JSON) ยท **Slash commands** ยท Priority support - **Multi-provider fallback** ยท **Per-provider API keys** ### Activating Pro 1. Purchase a Pro subscription at [belzersoftware.lemonsqueezy.com](https://belzersoftware.lemonsqueezy.com/checkout/buy/85655f95-93f7-4649-954a-8bc62472f302) 2. Receive your **License Key** via email (Lemon Squeezy UUID format, e.g., `056b9494-...`) 3. Settings โ†’ Copilot Personal โ†’ License Key โ†’ paste the key 4. You'll see `โœ… Pro license activated successfully.` 5. Chat badge changes to `โญ Pro` ### License Security | Mechanism | Description | |-----------|-------------| | **Cloud validation** | Every activation is verified against the Cloudflare Worker | | **Device binding** | License tied to your device via fingerprint. Max 3 devices per license | | **Grace period** | If offline, Pro license continues working for 24h before degrading to Free | | **Persistent state** | Message count and license state survive Obsidian restarts | | **Anti-sharing** | 3-device limit. Frequent device switching triggers protections | --- ## Privacy & Security - **API keys:** Stored locally in `data.json`. Each provider has its own field โ€” switching providers won't leak keys. Masked (`type="password"`) in settings UI. Never sent to plugin author's servers. - **Vault data:** Sent only to your configured LLM provider. No telemetry or analytics. - **Vault enumeration:** This plugin calls `vault.getFiles()` and `vault.getMarkdownFiles()` to enable semantic search (RAG), file lookup tools (`find_files`, `read_note`), and auto-save post-processing. File contents are only read when explicitly requested by the user or the agent. - **Web search:** Requires a local Python microservice (`web_search_server/`). Authentication token is configurable in settings. - **License validation:** Pro keys are validated against the Cloudflare Worker. Free tier requires no internet connection. - **Path traversal:** Multi-layer protection against directory escape attacks in `read_note`. - **Timing-safe auth:** Admin endpoint uses constant-time comparison for secret tokens. - **sessionStorage:** Used only for temporary chat session crash recovery (auto-saved every 30s, cleared on new chat). All persistent data uses Obsidian's `loadData()/saveData()` API. - **No telemetry, no analytics, no tracking.** --- ## Development ```bash npm install # Install dependencies npm run build # Obfuscated build (external distribution) npm run build:store # Clean build (Obsidian store submission) npm run typecheck # TypeScript check only npm run dev # Watch mode npx jest --verbose # Run 151 tests across 16 suites ``` ### Testing 16 test suites covering: license management, circuit breaker, provider auto-detection, tool registry, agent detection, read/write tools, PDF tools, vector store CRUD, index operations, LM Studio service, settings, singleton reset, chat flow. Run with `npx jest --verbose`. ### Notes - **Legacy API key migration:** If you previously stored your API key in the old single-key field, it is automatically migrated to the per-provider key on first load after upgrading to v1.4.4. --- ## License MIT License โ€” see [LICENSE](LICENSE) file for details.