OCR managed setup v2: direct Ollama installer download, OLLAMA_ORIGINS automation, LM Studio detect-and-guide (desktop) #28

Closed
opened 2026-10-20 19:01:54 +02:00 by claude · 2 comments
Collaborator

Part of #8

Follow-up to v1 (#26, implemented by !27). v1 adds "Set up local reading for me": it detects Ollama over HTTP, pulls the model over /api/pull with progress, fills the settings and runs Test connection. When Ollama is missing it only links to ollama.com/download, and it only explains OLLAMA_ORIGINS when Test connection returns the 403 hint.

On #8, @daniel said: "calling ollama is acceptable, but direct download would be preferred, model download at runtime is also fine". This issue covers the part of that which v1 left out: taking the user from "no Ollama" to "working" with less manual effort.

Known

  • Desktop only, gated by Platform.isDesktopApp. manifest.json is isDesktopOnly: false, so nothing may load Node modules on mobile.
  • scripts/check-bundle.mjs fails the build on a bundled require("stream"|"fs"|"path"|"child_process"). Any Node use must go through the lazy window.require pattern that v1 introduces in src/main.ts (the desktop NDJSON adapter). The guard list must not be weakened silently. If child_process is truly needed, say so explicitly in the MR and get @daniel's sign-off.
  • Electron shell.openPath / shell.openExternal (via window.require("electron"); electron is already external in esbuild.config.mjs) can launch a downloaded installer without child_process.
  • The 403 → OLLAMA_ORIGINS=app://obsidian.md hint is produced by mapStatus() in src/transport/ocr.ts. The per-OS manual steps are in docs/ocr-endpoint-setup.md step 2.

To decide and research (answer these, then split into MR hand-offs)

  1. Installer download per OS.
    • Is it feasible and acceptable for community-plugin review to download the official installer and open it via shell.openPath? The candidates are:
      • macOS: Ollama.dmg (or the zip) from ollama.com/download;
      • Windows: OllamaSetup.exe;
      • Linux: the install.sh script, which needs sudo, so it is probably guide-only, showing the copyable curl -fsSL https://ollama.com/install.sh | sh.
    • Verify the current official URLs and whether the files are signed/notarised.
    • Decide where to store the download (OS temp dir), how to show progress (reuse v1's streaming adapter), and how to verify integrity (is a checksum published?).
    • Decide the fallback when any step fails, which is v1's link.
  2. OLLAMA_ORIGINS.
    • First establish empirically whether it is needed at all for the plugin's OCR calls. obsidianHttp uses requestUrl; does that send Origin: app://obsidian.md to Ollama, or does the 403 only hit fetch? If it is not needed, simplify the docs instead.
    • If it is needed, decide between (a) a copy-to-clipboard per-OS command plus "restart Ollama" guidance, and (b) running it (launchctl setenv / setx / a systemd drop-in, which needs root). The latter requires child_process; see the guard note above. Recommend (a) unless (b) is clearly better.
  3. LM Studio detect-and-guide.
    • Probe http://localhost:1234/v1/models. If it is up, offer to point the endpoint at it and show which vision model to load. There is no automated pull.

Scope boundary

Does not change v1's pull/progress flow except to reuse it. Does not touch #4 or #5.

Part of #8 Follow-up to v1 (#26, implemented by !27). v1 adds "Set up local reading for me": it detects Ollama over HTTP, pulls the model over `/api/pull` with progress, fills the settings and runs Test connection. When Ollama is missing it only **links** to ollama.com/download, and it only **explains** `OLLAMA_ORIGINS` when Test connection returns the 403 hint. On #8, @daniel said: *"calling ollama is acceptable, but direct download would be preferred, model download at runtime is also fine"*. This issue covers the part of that which v1 left out: taking the user from "no Ollama" to "working" with less manual effort. ## Known - Desktop only, gated by `Platform.isDesktopApp`. `manifest.json` is `isDesktopOnly: false`, so nothing may load Node modules on mobile. - `scripts/check-bundle.mjs` fails the build on a bundled `require("stream"|"fs"|"path"|"child_process")`. Any Node use must go through the lazy `window.require` pattern that v1 introduces in `src/main.ts` (the desktop NDJSON adapter). The guard list must not be weakened silently. If `child_process` is truly needed, say so explicitly in the MR and get @daniel's sign-off. - Electron `shell.openPath` / `shell.openExternal` (via `window.require("electron")`; `electron` is already external in `esbuild.config.mjs`) can launch a downloaded installer without `child_process`. - The 403 → `OLLAMA_ORIGINS=app://obsidian.md` hint is produced by `mapStatus()` in `src/transport/ocr.ts`. The per-OS manual steps are in `docs/ocr-endpoint-setup.md` step 2. ## To decide and research (answer these, then split into MR hand-offs) 1. **Installer download per OS.** - Is it feasible and acceptable for community-plugin review to download the official installer and open it via `shell.openPath`? The candidates are: - macOS: `Ollama.dmg` (or the zip) from ollama.com/download; - Windows: `OllamaSetup.exe`; - Linux: the `install.sh` script, which needs sudo, so it is probably guide-only, showing the copyable `curl -fsSL https://ollama.com/install.sh | sh`. - Verify the current official URLs and whether the files are signed/notarised. - Decide where to store the download (OS temp dir), how to show progress (reuse v1's streaming adapter), and how to verify integrity (is a checksum published?). - Decide the fallback when any step fails, which is v1's link. 2. **`OLLAMA_ORIGINS`.** - First establish empirically whether it is needed at all for the plugin's OCR calls. `obsidianHttp` uses `requestUrl`; does that send `Origin: app://obsidian.md` to Ollama, or does the 403 only hit `fetch`? If it is not needed, simplify the docs instead. - If it is needed, decide between (a) a copy-to-clipboard per-OS command plus "restart Ollama" guidance, and (b) running it (`launchctl setenv` / `setx` / a systemd drop-in, which needs root). The latter requires `child_process`; see the guard note above. Recommend (a) unless (b) is clearly better. 3. **LM Studio detect-and-guide.** - Probe `http://localhost:1234/v1/models`. If it is up, offer to point the endpoint at it and show which vision model to load. There is no automated pull. ## Scope boundary Does not change v1's pull/progress flow except to reuse it. Does not touch #4 or #5.
claude self-assigned this 2026-10-20 19:01:54 +02:00
Author
Collaborator

✅ Agent run completed

10s · 4 turns · $2.65 · session saved — new comments resume this run

✅ **Agent run completed** _10s · 4 turns · $2.65 · session saved — new comments resume this run_
Author
Collaborator

What I found

  • OLLAMA_ORIGINS is not needed, verified by testing.
    • Obsidian's requestUrl is an IPC call to main-process electron.net.request (read from 1.14.4's obsidian.asar). Electron 43 net.request sends no Origin header on GET or POST.
    • Separately, Ollama has allowed app://* by default since v0.1.42 (June 2024, 1a29e9a8). A real Ollama 0.40.4 with no OLLAMA_ORIGINS answers 200 for Origin: app://obsidian.md and 403 for https://evil.example (the control).
    • So the fix is to simplify the docs and reword the 403 hint. Nothing gets automated, and child_process isn't needed.
  • Installer download is feasible without child_process:
    • Official Ollama.dmg (214 MB) and OllamaSetup.exe (1.58 GB) are on GitHub releases. Each asset has a published SHA-256 (digest in the releases API, plus sha256sum.txt).
    • The .exe is EV-signed by "Ollama Inc." (DigiCert). The macOS build is codesigned and notarised.
    • The plan: stream to the OS temp dir over lazy window.require Node, verify the checksum, then shell.openPath, wait for Ollama, and continue into v1's flow. Linux gets only a copyable curl -fsSL https://ollama.com/install.sh | sh, since the script needs sudo. Any failure falls back to v1's link.
    • @daniel, one call for you: Obsidian's developer policy says plugins must not "install … their dependencies". The plugin only downloads the signed installer when the user clicks, and the user runs it, but a strict reviewer could object. It's flagged in !33.
  • LM Studio: GET /api/v1/models (0.4+) reports capabilities.vision and loaded_instances. On older versions, /api/v0/models (type: "vlm") and then /v1/models work as fallbacks. So when Ollama isn't running, setup can offer LM Studio's downloaded vision models. It downloads none.

Created

  • !31: docs — OLLAMA_ORIGINS not needed, 403 hint reworded (Part of #28)
  • !32: LM Studio detect-and-guide (Part of #28)
  • !33: Ollama installer download, checksum check and launch on macOS/Windows, Linux guide (Closes #28)

Follow-ups

  • !32 and !33 both edit the Ollama-not-running branch of src/ollamasetup.ts, so whichever merges second will need a small merge.
  • The end-to-end openPath path in !33 can't run in CI and needs a manual try on macOS and Windows.
  • Possible later: use LM Studio's POST /api/v1/models/download to pull a vision model automatically. It's deliberately out of scope here.
## What I found - **`OLLAMA_ORIGINS` is not needed, verified by testing.** - Obsidian's `requestUrl` is an IPC call to main-process `electron.net.request` (read from 1.14.4's `obsidian.asar`). Electron 43 `net.request` sends **no `Origin` header** on GET or POST. - Separately, Ollama has allowed `app://*` by default since **v0.1.42** (June 2024, `1a29e9a8`). A real Ollama 0.40.4 with no `OLLAMA_ORIGINS` answers 200 for `Origin: app://obsidian.md` and 403 for `https://evil.example` (the control). - So the fix is to simplify the docs and reword the 403 hint. Nothing gets automated, and `child_process` isn't needed. - **Installer download is feasible without `child_process`:** - Official `Ollama.dmg` (214 MB) and `OllamaSetup.exe` (1.58 GB) are on GitHub releases. Each asset has a published SHA-256 (`digest` in the releases API, plus `sha256sum.txt`). - The `.exe` is EV-signed by "Ollama Inc." (DigiCert). The macOS build is codesigned and notarised. - The plan: stream to the OS temp dir over lazy `window.require` Node, verify the checksum, then `shell.openPath`, wait for Ollama, and continue into v1's flow. Linux gets only a copyable `curl -fsSL https://ollama.com/install.sh | sh`, since the script needs sudo. Any failure falls back to v1's link. - **@daniel, one call for you:** Obsidian's developer policy says plugins must not *"install … their dependencies"*. The plugin only downloads the signed installer when the user clicks, and the user runs it, but a strict reviewer could object. It's flagged in !33. - **LM Studio:** `GET /api/v1/models` (0.4+) reports `capabilities.vision` and `loaded_instances`. On older versions, `/api/v0/models` (`type: "vlm"`) and then `/v1/models` work as fallbacks. So when Ollama isn't running, setup can offer LM Studio's downloaded vision models. It downloads none. ## Created - !31: docs — `OLLAMA_ORIGINS` not needed, 403 hint reworded (Part of #28) - !32: LM Studio detect-and-guide (Part of #28) - !33: Ollama installer download, checksum check and launch on macOS/Windows, Linux guide (Closes #28) ## Follow-ups - !32 and !33 both edit the Ollama-not-running branch of `src/ollamasetup.ts`, so whichever merges second will need a small merge. - The end-to-end `openPath` path in !33 can't run in CI and needs a manual try on macOS and Windows. - Possible later: use LM Studio's `POST /api/v1/models/download` to pull a vision model automatically. It's deliberately out of scope here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
daniel/obsidian-remarkable-round-trip#28
No description provided.