No description
Find a file
Logan Yang a78b38c8c2
feat(entitlement): gate multi-agent to Plus tier via signed entitlement token (#2644)
* feat(entitlement): gate multi-agent to Plus tier via signed entitlement token

Multi-agent fan-out was gated on the binary isPlusUser flag, which any valid
license flips true, so a future Lite tier would wrongly pass. Introduce a
server-signed entitlement token (ES256, verified offline via WebCrypto) as the
single entitlement primitive.

- Rename the broad flag isPlusUser to isPaidUser (any paid license, incl. Lite);
  all existing Plus-feature gates move to it, preserving current behavior.
- Add a new strict isPlusUser (tier >= Plus) derived from the token's
  multi_agent feature. The multi-agent UI gate and the authoritative
  send-boundary check (ensureMultiAgentEntitlement) now key on it.
- No-token fallback (isPlusUser = isPaidUser) preserves today's behavior until
  the server ships tokens alongside Lite/Pro, so there is no plan-name list in
  the public client to patch out.
- Settings sanitize migration backfills isPaidUser from the legacy isPlusUser.
- src/entitlement/ verifies the JWS signature with an embedded public key (no
  key can mint tokens client-side); forged data.json / faked responses fail.

Tests cover tier gating across Free/Lite/Plus/Pro plus the crypto layer
(valid, expired, wrong-user, tampered, unknown-kid, malformed).

Self-host migration to the token is deferred to logancyang/obsidian-copilot-preview#201.
Closes logancyang/obsidian-copilot-preview#200.
Design: "Copilot Entitlement Token Design".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(test): swap in Node WebCrypto when jsdom's subtle lacks generateKey

CI (Node 22) ships a jsdom whose window.crypto.subtle exists but is partial
(no generateKey), so the previous `!subtle` guard skipped the polyfill and the
entitlement crypto tests failed. Probe for the actual method and install Node's
complete WebCrypto when it's missing. Runtime is unaffected (test-only setup).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(entitlement): never downgrade on an unverifiable token (Codex P1/P2)

Addresses two Codex findings:

- P1: when /license starts returning a token but the client's public keys are
  not shipped yet (or during kid rotation), every token verified as null and
  applyEntitlement cleared the flags, dropping paying users to free. Now
  applyEntitlement never clears: it returns false when it cannot verify, and
  validateLicenseKey falls back to turnOnPaid() for a license the server already
  confirmed valid. Only an authoritative negative (invalid license / no key)
  downgrades, via turnOffPaid.
- P2: removed refreshEntitlementFromCache() and its concurrent startup call,
  which could clear flags after checkIsPaidUser() restored them. The persisted
  flags already hold the last verdict and the online check is authoritative;
  offline expiry enforcement belongs to the deferred self-host migration (#201).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(test): run entitlement crypto test in node env, not flaky jsdom subtle

jsdom ships only a partial SubtleCrypto (no generateKey), and patching it in
jest.setup was nondeterministic across CI Node builds (passed on one commit,
failed on the next with no setup change). Run verify.test under the node
environment, where crypto.subtle is Node's complete WebCrypto — the verification
logic is WebCrypto-spec behavior, identical between Node and the webview.

Also drop verify.ts's @/logger import so the entitlement module is a pure leaf
(no settings/obsidian graph), which keeps the node-env test import-safe and
matches the module's intended dependency-light design. jest.setup now guards its
window usage so it is a no-op under the node environment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(test): force WebCrypto onto globalThis, not just window

The prior fix patched window.crypto, but a bare `crypto` reference in a module
resolves to globalThis.crypto, and jest's jsdom environment installs a partial
SubtleCrypto (no generateKey) on globalThis that the window-only patch missed —
so CI kept failing in jsdom while local (clean jsdom) passed. Patch globalThis
(and window) with Node's complete WebCrypto, with a fallback to replacing
`.subtle` if `crypto` is a locked accessor. Reverts the node-env docblock on the
crypto test; the global patch covers the standard jsdom env.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(test): inject Node WebCrypto into entitlement verify instead of patching globals

Root cause of the repeated CI failures: jest's jsdom environment exposes a
partial, locked SubtleCrypto (no generateKey/ECDSA) on the global the module
resolves `crypto` from, and neither replacing window/globalThis.crypto nor the
@jest-environment node docblock reliably overrode it on CI (local jsdom resolves
clean, so it couldn't be reproduced locally).

Fix: give verifyEntitlement an injectable `subtle` option (default
`crypto.subtle`, as used at runtime on desktop + mobile), and have the test pass
Node's webcrypto.subtle explicitly. The test no longer depends on the
environment's global WebCrypto at all, so it's deterministic in any jest env.
jest.setup reverted to its original form (no crypto hacks).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(entitlement): close 3 Codex findings (Lite bypass, log leak, offline expiry)

- P1 (Lite bypass): an unverifiable entitlement token no longer grants the strict
  gate. validateLicenseKey now calls markPaidPendingEntitlement() — paid so general
  Plus features work, but isPlusUser stays false so an unverifiable Lite token
  can't pass the multi-agent gate before the verifying key ships (fails closed).
  Tokenless (old server) still grants paid + Plus.
- P2 (log leak): parseBrevilabsResponse redacts the `entitlement` JWS before
  logInfo, so it never lands in the shared copilot-log.md.
- P2 (offline expiry): persist the token's exp as entitlementExpiresAt and have
  the strict gate (isPlusEnabled / useIsPlusUser) honor it, so multi-agent locks
  at expiry even while /license is unavailable. The broad paid gate keeps legacy
  behavior. ensureMultiAgentEntitlement's slow path re-reads it, so an expired
  token offline is blocked.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* feat(entitlement): embed prod ES256 public key (kid ent-2026-06)

Populate ENTITLEMENT_PUBLIC_KEYS with the production verify-only public
JWK so verifyEntitlement can validate server-signed tokens offline. The
matching private key signs tokens in brevilabs-api.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

* fix(entitlement): require in-session signature proof for strict Plus

Address Codex P1: isPlusEnabled() trusted the persisted isPlusUser
boolean + entitlementExpiresAt without re-verifying the JWS, so an
edited data.json (isPlusUser: true + future expiry) bypassed the
multi-agent gate offline and in the startup window. The signed token was
not actually the gate on cached state.

Gate token-derived strict Plus on an in-memory, non-persisted proof that
a signed entitlement granting multi_agent was cryptographically verified
in THIS process — set by applyEntitlement (server response) or the new
verifyCachedEntitlement (cached token re-checked at startup, offline via
WebCrypto). A persisted boolean alone never sets it, so it fails closed.

The tokenless fallback (pre-token server, entitlementExpiresAt === 0) is
unchanged: no signed artifact exists to verify, so it honors the
license-confirmed flag as today and preserves new-plugin/old-server
compatibility.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T4qVU9iszFGZ1q5ro8m2X

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 19:56:00 -07:00
.claude introduce model migration script 2026-05-28 16:03:46 -07:00
.cursor/rules Improve the regex for composer codeblock (#1778) 2025-09-03 13:51:34 -07:00
.github fix(mobile): guard Agent Mode off the mobile load path (#2577) 2026-06-06 21:56:58 -07:00
.husky chore(deps): swap unmaintained/legacy deps per e18e module-replacements (#2447) 2026-05-14 01:12:52 -07:00
__mocks__ feat(agent-projects): project-scoped Agent Mode — Agent Home PR2 (#2604) 2026-06-28 00:33:22 -07:00
designdocs feat(agent-projects): project-scoped Agent Mode — Agent Home PR2 (#2604) 2026-06-28 00:33:22 -07:00
docs fix(agent-mode): copy/insert the full agent response, not just trailing prose (#166) (#2616) 2026-06-29 19:44:04 -07:00
images Reduce images size in half in README without losing quality (#1966) 2025-10-30 16:58:32 -07:00
scripts feat(agent-projects): project-scoped Agent Mode — Agent Home PR2 (#2604) 2026-06-28 00:33:22 -07:00
src feat(entitlement): gate multi-agent to Plus tier via signed entitlement token (#2644) 2026-06-29 19:56:00 -07:00
typings feat(agent-mode): introduce Agent Mode feature 2026-05-20 19:05:41 -07:00
.editorconfig Create vector store per vault (#348) 2024-03-08 21:50:45 -08:00
.gitignore fix(agent-mode): copy/insert the full agent response, not just trailing prose (#166) (#2616) 2026-06-29 19:44:04 -07:00
.npmrc Initial commit 2023-03-30 17:15:32 -07:00
.prettierrc Refactor Settings, add formatting (#518) 2024-08-20 21:53:09 -07:00
AGENTS.md Add BYOK settings - agent enablement 2026-05-28 16:02:47 -07:00
CLAUDE.md fix(agent-mode): surface missing provider credentials (#2529) 2026-05-29 23:39:18 -07:00
components.json Add tw prefix to tailwind (#1497) 2025-05-31 22:30:54 -07:00
CONTRIBUTING.md Add npm run test:vault for fast worktree-to-vault plugin reload (#2477) 2026-05-19 12:05:49 -07:00
esbuild.config.mjs fix(mobile): guard Agent Mode off the mobile load path (#2577) 2026-06-06 21:56:58 -07:00
eslint.config.mjs feat(agent-mode): one-click "Report an Issue" flow with screenshot + frame log (#2614) 2026-06-15 16:43:26 -07:00
jest.config.js feat(agent-projects): project-scoped Agent Mode — Agent Home PR2 (#2604) 2026-06-28 00:33:22 -07:00
jest.setup.js feat(models): flag non-vision models, guard image sends (#2627) 2026-06-29 00:02:47 -07:00
knip.json chore(deps): remove unused deps and dead code to shrink bundle (#2460) 2026-05-14 22:25:59 -07:00
LICENSE Add license 2023-03-30 23:52:55 -07:00
local_copilot.md docs: update local copilot instructions for macOS (#1077) 2025-01-22 14:51:34 -08:00
manifest.json release: v3.3.3 (#2494) 2026-05-20 18:27:22 -07:00
nodeModuleShim.mjs feat(agent-mode): introduce Agent Mode feature 2026-05-20 19:05:41 -07:00
package-lock.json feat(agent-mode): show recent chats from native harness history regardless of markdown autosave (#2591) 2026-06-10 21:35:46 -07:00
package.json fix(mobile): guard Agent Mode off the mobile load path (#2577) 2026-06-06 21:56:58 -07:00
README.md feat(relevant-notes): dedicated pane with redesigned populated view (#2559) 2026-06-05 06:54:12 +08:00
RELEASES.md release: v3.3.3 (#2494) 2026-05-20 18:27:22 -07:00
tailwind.config.js feat(agent-projects): project-scoped Agent Mode — Agent Home PR2 (#2604) 2026-06-28 00:33:22 -07:00
tsconfig.json Merge 3.1.0 preview (#1906) 2025-10-10 21:38:50 -07:00
version-bump.mjs chore(release): make prerelease tooling stop poisoning master's manifest.json (#2429) 2026-05-13 15:53:48 -07:00
versions.json release: v3.3.3 (#2494) 2026-05-20 18:27:22 -07:00
wasmPlugin.mjs Format code (#521) 2024-08-21 15:16:22 -07:00

Copilot for Obsidian

The Ultimate AI Assistant for Your Second Brain

GitHub release (latest SemVer) Obsidian Downloads

Documentation | Youtube | Report Bug | Request Feature

Reward Banner

The What

Copilot for Obsidian is your invault AI assistant with chat-based vault search, web and YouTube support, powerful context processing, and ever-expanding agentic capabilities within Obsidian's highly customizable workspace - all while keeping your data under your control.

The Why

Today's AI giants want you trapped: your data on their servers, prompts locked to their models, and switching costs that keep you paying. When they change pricing, shut down features, or terminate your account, you lose everything you built.

We are building the opposite. Our goal is to create a portable agentic experience with no provider lock-in. Data is always yours. Use whatever LLM you like. Imagine that a brand new model drops, you run it on your own hardware, and it already knows about you (long-term memory), knows how to run the same commands and tools you have defined over time (as just markdown files), and becomes the thought partner and assistant that you own. This is AI that grows with you, not a subscription you're hostage to.

This is the future we believe in. If you share this vision, please support this project!

Key Features

  • 🔒 Your data is 100% yours: Local search and storage, and full control of your data if you use self-hosted models.
  • 🧠 Bring Your Own Model: Tap any OpenAI-compatible or local model to uncover insights, spark connections, and create content.
  • 🖼️ Multimedia understanding: Drop in webpages, YouTube videos, images, PDFs, EPUBS, or real-time web search for quick insights.
  • 🔍 Smart Vault Search: Search your vault with chat, no setup required. Embeddings are optional. Copilot delivers results right away.
  • ✍️ Composer and Quick Commands: Interact with your writing with chat, apply changes with 1 click.
  • 🗂️ Project Mode: Create AI-ready context based on folders and tags. Think NotebookLM but inside your vault!
  • 🤖 Agent Mode (Plus): Unlock an autonomous agent with built-in tool calling. No commands needed. Copilot automatically triggers vault, web searches or any other relevant tool when relevant.

Copilot's Agent can call the proper tools on its own upon your request.

Product UI screenshot

Table of Contents

Copilot V3 is a New Era 🔥

After months of hard work, we have revamped the codebase and adopted a new paradigm for our agentic infrastructure. It opens the door for easier addition of agentic tools (MCP support coming). We will provide a new version of the documentation soon. Here is a couple of new things that you cannot miss!

  • FOR ALL USERS: You can do vault search out-of-the-box without building an index first (Indexing is still available but optional behind the "Semantic Search" toggle in QA settings).
  • FOR FREE USERS: Image support and chat context menu are available to all users starting from v3.0.0!
  • FOR PLUS USERS: Autonomous agent is available with vault search, web search, youtube, composer and soon a lot other tools! Long-term memory is also a tool the agent can use by itself starting from 3.1.0!

Read the Changelog.

Why People Love It ❤️

  • "Copilot is the missing link that turns Obsidian into a true second brain. I use it to draft investment memos with text, code, and visuals—all in one place. Its the first tool that truly unifies how I search, process, organize, and retrieve knowledge without ever leaving Obsidian. With AI-powered search, organization, and reasoning built into my notes, it unlocks insights Id otherwise miss. My workflow is faster, deeper, and more connected than ever—I cant imagine working without it." - @jasonzhangb, Investor & Research Analyst
  • "Since discovering Copilot, my writing process has been completely transformed. Conversing with my own articles and thoughts is the most refreshing experience Ive had in decades.” - Mat QV, Writer
  • "Copilot has transformed our family—not just as a productivity assistant, but as a therapist. I introduced it to my nontechnical wife, Mania, who was stressed about our daughters upcoming exam; within an hour, she gained clarity on her mindset and next steps, finding calm and confidence." - @screenfluent, A Loving Husband

Get Started

Install Obsidian Copilot

  1. Open Obsidian → Settings → Community plugins.
  2. Turn off Safe mode (if enabled).
  3. Click Browse, search for “Copilot for Obsidian”.
  4. Click Install, then Enable.

Set API Keys

Free User

  1. Go to Obsidian → Settings → Copilot → Basic and click Set Keys.
  2. Choose your AI provider(s) (e.g., OpenRouter, Gemini, OpenAI, Anthropic, Cohere) and paste your API key(s). OpenRouter is recommended.

Copilot Plus/Believer

  1. Copy your license key at your dashboard. Dont forget to join our wonderful Discord community!
  2. Go to Obsidian → Settings → Copilot → Basic and paste the key into in the Copilot Plus card.

Usage

Free User

Chat Mode: reference notes and discuss ideas with Copilot

Use @ to add context and chat with your note.

Chat Mode

Ask Copilot:

Summarize Q3 Retrospective and identify the top 3 action items for Q4 based on the notes in {01-Projects}.

Chat Mode

Vault QA Mode: chat with your entire vault

Ask Copilot:

What are the recurring themes in my research regarding the intersection of AI and SaaS?

Vault Mode

Copilot's Command Palette

Copilot's Command Palette puts powerful AI capabilities at your fingertips. Access all commands in chat window via / or via right-click menu on selected text.

Add selection to chat context

Select text and add it to context. Recommend shortcut: ctrl/cmd + L

Add Selection to Context

Quick Command

Select text and apply action without opening chat. Recommend shortcut: ctrl/cmd + K

Quick Command

Edit and Apply with One Click

Select text and edit with one RIGHT click.

One-Click Commands

Create your Command

Create commands and workflows in Settings → Copilot → Command → Add Cmd.

Create Command

Command Palette in Chat

Type / to use Command Palette in chat window.

Prompt Palette

Open it from the command palette (Open Relevant Notes) to get its own pane that surfaces related content and links for whatever note you're viewing.

Use it to quickly reference past research, ideas, or decisions—no need to search or switch tabs.

Relevant Notes

Copilot Plus/Believer

Copilot Plus brings powerful AI agentic capabilities, context-aware actions and seamless tool integration—built to elevate your knowledge work in Obsidian.

Get Precision Insights From a Specific Time Window

In agent mode, ask copilot:

What did I do last week?

Time-Based Queries

Agent Mode: Autonomous Tool Calling

Copilot's agent automatically calls the right tools—no manual commands needed. Just ask, and it searches the web, queries your vault, and combines insights seamlessly.

Ask Copilot in agent mode:

Research web and my vault and draft a note on AI SaaS onboarding best practices.

Agent Mode

Understand Images in Your Notes

Copilot can analyze images embedded in your notes—from wireframes and diagrams to screenshots and photos. Get detailed feedback, suggestions, and insights based on visual content.

Ask Copilot to analyze your wireframes:

Analyze the wireframe in UX Design - Mobile App Wireframes and suggest improvements for the navigation flow.

Image Understanding

One Prompt, Every Source—Instant Summaries from PDFs, Videos, and Web

In agent mode, ask Copilot

*Compare the information about [Agent Memory] from this youtube video: [URL], this PDF [file], and @web[search results]. Start with your

 conclusion in bullet points in your response*

One Prompt, Every Source

Need Help?

  • Check the documentation for setup guides, how-tos, and advanced features.
  • Watch Youtube for walkthroughs.
  • If you're experiencing a bug or have a feature idea, please follow the steps below to help us help you faster:
    • 🐛 Bug Report Checklist
      • ☑️Use the bug report template when reporting an issue
      • ☑️Enable Debug Mode in Copilot Settings → Advanced for more detailed logs
      • ☑️Open the dev console to collect error messages:
        • Mac: Cmd + Option + I
        • Windows: Ctrl + Shift + I
      • ☑️Turn off all other plugins, keeping only Copilot enabled
      • ☑️Attach relevant console logs to your report
      • ☑️Submit your bug report here
    • 💡 Feature Request Checklist
      • ☑️Use the feature request template for requesting a new feature
      • ☑️Clearly describe the feature, why it matters, and how it would help
      • ☑️Submit your feature request here

FAQ

Why isnt Vault search finding my notes?

If you're using the Vault QA mode (or the tool @vault in Plus), try the following:

  • Ensure you have a working embedding model from your AI model's provider (e.g. OpenAI). Watch this video: AI Model Setup (API Key)
  • Ensure your Copilot indexing is up-to-date. Watch this video: Vault Mode
  • If issues persist, run Force Re-Index or use List Indexed Files from the Command Palette to inspect what's included in the index.
  • ⚠️ Dont switch embedding models after indexing—it can break the results.
Why is my AI model returning error code429: Insufficient Quota?

Most likely this is happening because you havent configured billing with your chosen model provider—or youve hit your monthly quota. For example, OpenAI typically caps individual accounts at $120/month. To resolve:

  • ▶️ Watch the “AI Model Setup” video: AI Model Setup (API Key)
  • 🔍 Verify your billing settings in your OpenAI dashboard
  • 💳 Add a payment method if one isnt already on file
  • 📊 Check your usage dashboard for any quota or limit warnings

If youre using a different provider, please refer to their documentation and billing policies for the equivalent steps.

Why am I getting a token limit error?

Please refer to your model providers documentation for the context window size.

⚠️ If you set a large max token limit in your Copilot settings, you may encounter this error.

  • Max tokens refers to completion tokens, not input tokens.
  • A higher output token limit means less room for input!

🧠 Behind-the-scenes prompts for Copilot commands also consume tokens, so:

  • Keep your message length short
  • Set a reasonable max token value to avoid hitting the cap

💡 For QA with unlimited context, switch to the Vault QA mode in the dropdown (Copilot v2.1.0+ required).

🙏 Thank You

If you share the vision of building the most powerful AI agent for our second brain, consider sponsoring this project or buying me a coffee. Help spread the word by sharing Copilot for Obsidian on Twitter/X, Reddit, or your favorite platform!

BuyMeACoffee

Acknowledgments

Special thanks to our top sponsors: @mikelaaron, @pedramamini, @Arlorean, @dashinja, @azagore, @MTGMAD, @gpythomas, @emaynard, @scmarinelli, @borthwick, @adamhill, @gluecode, @rusi, @timgrote, @JiaruiYu-Consilium, @ddocta, @AMOz1, @chchwy, @pborenstein, @GitTom, @kazukgw, @mjluser1, @joesfer, @rwaal, @turnoutnow-harpreet, @dreznicek, @xrise-informatik, @jeremygentles, @ZhengRui, @bfoujols, @jsmith0475, @pagiaddlemon, @sebbyyyywebbyyy, @royschwartz2, @vikram11, @amiable-dev, @khalidhalim, @DrJsPBs, @chishaku, @Andrea18500, @shayonpal, @rhm2k, @snorcup, @JohnBub, @obstinatelark, @jonashaefele, @vishnu2kmohan

Copilot Plus Disclosure

Copilot Plus is a premium product of Brevilabs LLC and it is not affiliated with Obsidian. It offers a powerful agentic AI integration into Obsidian. Please check out our website obsidiancopilot.com for more details!

  • An account and payment are required for full access.
  • Copilot Plus requires network use to facilitate the AI agent.
  • Privacy & Data Handling:
    • Free tier: Your messages and notes are sent only to your configured LLM provider (OpenAI, Anthropic, Google, etc.). Nothing goes to Brevilabs servers.
    • Plus tier: Messages go to your configured LLM provider. File conversions (PDF, DOCX, EPUB, images, etc.) are processed by Brevilabs servers only when you explicitly trigger these features via @ commands.
    • Processing vs. Retention: We process your data to deliver the feature you requested, then discard it. No message content, file uploads, or documents are retained on our servers after processing.
    • User ID: A randomly generated UUID is sent with Plus API requests for service delivery (license abuse prevention, rate limiting) but is not used for user tracking, profiling, or analytics.
  • Please see the privacy policy on the website for more details.
  • The frontend code of Copilot plugin is fully open-source. However, the backend code facilitating the AI agents is close-sourced and proprietary.
  • We offer a full refund if you are not satisfied with the product within 14 days of your purchase, no questions asked.

Authors

Brevilabs Team | Email: logan@brevilabs.com | X/Twitter: @logancyang