Repository navigation
Add Windows Claude Desktop credential helper - #6516
aponcedeleonch merged 2 commits into
Conversation
Setup on Windows used to write a POSIX .sh shim and then refuse. Write a .cmd shim and quote the thv path for cmd.exe instead. Signed-off-by: Po-Han Shih <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6516 +/- ##
==========================================
+ Coverage 80.01% 80.04% +0.03%
==========================================
Files 837 837
Lines 85215 85236 +21
==========================================
+ Hits 68182 68228 +46
+ Misses 17028 17003 -25
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aponcedeleonch
left a comment
There was a problem hiding this comment.
Thanks for picking this up, @stantheman0128, and sorry it took so long to get a review. The approach still fits main, and the goto trick to keep a ) in the path from breaking the script is a nice touch. A few things before we can merge:
callre-runs percent expansion (pkg/client/llm_gateway_credential_helper.go:302and:305). The%%fromquoteForCmdcollapses back to a single%and then gets stripped, soC:\100%\thv.exeturns intoC:\100\thv.exe.callalso doubles^inside quotes. Sinceos.Executable()always gives usthv.exe, could we dropcalland run the exe directly?- The Windows execution test uses a path without
%,^or&, which is why this slipped through. Could you add those to the path, and use a real.exeas the fake thv (a tinygo buildin the test works)? Heads up that CI has no Windows runner, so this test only runs locally. - Has anyone confirmed that Claude Desktop actually runs a
.cmdhelper? Node refuses to spawn.cmd/.batfiles withoutshell: true, so this is the part I'm least sure about. A quick end-to-end check on a Windows machine would settle it. - It needs a rebase. The only conflict is
quoteForCmdsitting next to themanagedProfilePresentrewrite from #6883, so keeping main's version and addingquoteForCmdabove it should do it. While you're there, the "POSIX-only" comment nearquoteForPOSIXShellcan go.
Small nit: the comment at :243 says Windows GUI apps don't get thv on PATH. They do get the user's PATH from the registry. Using the absolute path is still the right call, just for a different reason.
call re-expanded percent signs and doubled carets inside the quoted thv.exe path.
|
The Windows shim now runs |
#6516 dropped `call` from the Windows Claude Desktop shim, but TestConfigureCredentialHelper_WritesConfigMetaAndShim still asserted `call "<thv>" llm token` on Windows. That contradicts the NotContains check in TestWriteCredentialHelperShim_UsesAbsolutePath, so the test fails on Windows. CI has no Windows runner, so it went unnoticed. Also correct the shim doc comment: explorer-launched apps on Windows do get the user's PATH. The absolute path is still right because it does not depend on thv being on PATH and pins the thv that ran setup. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
thv llm setup --client claude-desktopdetected Claude Desktop on Windows and then failed withclaude-desktop LLM gateway setup is not supported on Windows yet. The helper it would have written is a POSIX/bin/shscript (claude-desktop-helper.sh).The Windows early return is gone. Setup now writes
claude-desktop-helper.cmd. The shim still execs the absolutethvpath fromos.Executable()(GUI-launched Claude Desktop has no useful PATH). It usesgotoinstead of a parenthesizedifso a)in the path cannot break the block, andcallso a.cmdtoken helper returns.%and"in the path are escaped for cmd.exe.Fixes #6507
Type of change
Test plan
go test ./pkg/client/ -count=1 -timeout 180s -run "CredentialHelper|QuoteFor|WriteCredential")task test-e2e) (suite skips on Windows; POSIX fake-browser)task lint-fix)Isolated
%USERPROFILE%on this Win11 box (real Claude store untouched):Setup exit 0. Wrote
.toolhive\llm\claude-desktop-helper.cmdwithcall "<abs thv.exe>" llm token. Config documentinferenceCredentialHelperpointed at that.cmd.thv llm teardown claude-desktopremoved the shim and the config document.Did not launch Claude Desktop itself, so the GUI helper invoke is untested here.
API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Does this introduce a user-facing change?
Yes.
thv llm setup --client claude-desktopnow configures Claude Desktop on Windows.Special notes for reviewers
Assigned on #6507. Direct-mode clients still use the PATH-resolved
thv llm tokenshell string; only Claude Desktop needs the absolute-path shim.Assisted by Cursor.
Evidence
Live setup/teardown under a temp USERPROFILE: setup exit 0,
.cmdpresent, teardown removed the shim. Real%LOCALAPPDATA%\Claude-3pfile count stayed 0.