feat(gateway): add Claude Code Desktop support#784
Open
BYK wants to merge 1 commit into
Open
Conversation
Add a `claude-code-desktop` agent and `lore setup claude-code-desktop` command so the Anthropic Claude Code Desktop app (macOS + Windows) can route through the Lore gateway. The Desktop spawns the same `claude` CLI as a child and reads `ANTHROPIC_BASE_URL` from `~/.claude/settings.json` (not the parent env), so: - New `lib/desktop-detect.ts` `isClaudeDesktopInstalled()` detects the app (macOS `/Applications/Claude.app`, Windows `%LOCALAPPDATA%\Programs\ Claude`, null on Linux/other). - The agent's `envVars` deliberately omits `ANTHROPIC_BASE_URL` / `DISABLE_AUTO_COMPACT` (the child won't inherit them) and only injects the `X-Lore-*` headers. `binary` is a stable placeholder; the real launcher path is resolved at runtime via `detect()`. - `main.ts` / `run.ts` match the shorthand by agent name OR binary so `lore claude-code-desktop` works whether or not the app is installed, while existing binary-matched agents (`lore run codex`, etc.) keep spawning the literal token unchanged. - `setupClaudeCodeDesktop` writes `~/.claude/settings.json` (primary, documented path), runs `setx ANTHROPIC_BASE_URL` on Windows for dev/preview servers, and prints in-app Local env editor values as a fallback for builds hitting anthropics/claude-code#67619. The in-app editor store is Electron `safeStorage`-encrypted and is never written. Docs and help text updated; deterministic tests added for detection, envVars, the setup branches, and the Windows `setx` path.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 87.50%. Project has 5698 uncovered lines. Files with missing lines (4)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 65.81% 65.95% +0.14%
==========================================
Files 106 107 +1
Lines 16666 16736 +70
Branches 11670 11692 +22
==========================================
+ Hits 10969 11038 +69
- Misses 5697 5698 +1
- Partials 1333 1336 +3Generated by Codecov Action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
claude-code-desktopagent andlore setup claude-code-desktopcommand so the Anthropic Claude Code Desktop app (macOS + Windows) can route through the Lore gateway.Why / key fact
The Desktop app spawns the same
claudeCLI as a child process for local Code sessions and readsANTHROPIC_BASE_URLfrom~/.claude/settings.json— not from the parent process env. So the integration surface differs from the CLI'slore runenv-injection path.Changes
lib/desktop-detect.ts(new):isClaudeDesktopInstalled()— macOS/Applications/Claude.app/Contents/MacOS/Claude, Windows%LOCALAPPDATA%\Programs\Claude\*,nullon Linux/other.agents.ts: newclaude-code-desktopagent.envVarsdeliberately omitsANTHROPIC_BASE_URL/DISABLE_AUTO_COMPACT(the spawned child won't inherit them) and only injects theX-Lore-*headers.binaryis a stable placeholder; the real launcher path is resolved at runtime viadetect().main.ts/run.ts: the shorthand and explicit-command paths now match by agent name OR binary, solore claude-code-desktopworks whether or not the app is installed. Existing binary-matched agents (lore run codex,lore run claude, …) keep spawning the literal token unchanged.setup.tssetupClaudeCodeDesktop: writes~/.claude/settings.json(primary, documented path), runssetx ANTHROPIC_BASE_URLon Windows so dev/preview servers inherit it, and prints in-app Local env editor values as a fallback for builds hitting anthropics/claude-code#67619. 🔴 The in-app editor store is ElectronsafeStorage-encrypted and is never written by Lore.with-claude-code.mdgains a Desktop section;setup.mdandhelp.tslist the new app.Integration approach (researched)
The in-app Local env editor is
safeStorage-encrypted (macOS Keychain / Windows DPAPI) and cannot be written by an external tool. Lore therefore automates the documented plaintext path (settings.json+ Windowssetx) and surfaces the in-app editor only as a manual fallback.Tests
Deterministic tests added (mocking
node:fsexistsSync,node:child_processexecFileSync, and the detector) for: detection on each platform, the agent'senvVarsomissions, the linux/mac-detected/mac-missing/windows-setx setup branches, andsettings.jsonwrite. All discrimination-checked.Verification
pnpm test— 3174 passed / 6 skippedpnpm run typecheck— cleanpnpm run lint— cleanpnpm run build— all packages + website buildlore setup claude-code-desktopandlore claude-code-desktopdispatch on LinuxNote
An adversarial review was run pre-PR; it caught a BLOCKER (the shorthand failing when the app is installed, due to a module-load-resolved
binary) and several MAJOR/MINOR items — all fixed in this branch (stable placeholderbinary, name-or-binary matching inmain.ts, precise spawn-target resolution, broadened non-desktop-platform guard, and deterministic/discriminating tests).