0.48.0 — carry over PR #136: key from a file, and Retry-After on 429 - #139
Merged
Merged
Conversation
Both carried over from @KillerQueen-Z's PR #136, which implemented account-key support in parallel and had these two details the shipped version did not. ~/.blockrun/.api-key is read when BLOCKRUN_API_KEY is unset. A stdio MCP server is launched by its client, and several clients make setting an environment variable awkward or impossible — which is why the wallet has always had ~/.blockrun/.session. The key needs the same escape hatch. Precedence is env then file, mirroring BLOCKRUN_WALLET_KEY over .session: an explicitly exported key is a deliberate override and must not be shadowed by whatever is left on disk from an earlier account. An empty or unreadable file falls through to wallet mode rather than taking the server down. A malformed one still fails loudly, and the message now names which source it came from, so "invalid key" does not send someone to check an env var they never set. A 429 from the account API now surfaces Retry-After instead of burying it in the body. It is the one part of a rate-limit response a caller can act on; an agent told only "rate limited" retries immediately and is refused again. Verified with no environment variable set at all, against a temp HOME holding only the key file: the server reports account mode and reads the live balance. Tests 458 -> 462. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116SvLAGyzJ4SYKBvAE2DTc
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.
Salvages the two good ideas from @KillerQueen-Z's #136 that the shipped implementation did not have, and closes that PR as superseded.
What happened
#136 implemented account-API-key support in parallel, opened 2026-09-04 and gated on
@blockrun/llm#36 being published. That gate lifted this morning, and 0.46.0 / 0.47.0 shipped the same feature before #136 could be rebased — so it is now unmergeable against main and its CI is red on a typecheck error plus the stale^3.8.4pin it was explicitly waiting to replace.Rather than close it and lose the work, this carries over the parts it got right.
~/.blockrun/.api-keyThe shipped implementation read
BLOCKRUN_API_KEYand nothing else. #136 also read a file, and that is the better call: a stdio MCP server is launched by its client, and several clients make setting an environment variable awkward or impossible — which is exactly why the wallet has always had~/.blockrun/.session. The key needs the same escape hatch.Precedence is env, then file, mirroring
BLOCKRUN_WALLET_KEYover.session: an explicitly exported key is a deliberate override and must not be shadowed by whatever is left on disk from an earlier account.Retry-Afteron 429Surfaced instead of buried in the response body. It is the one part of a rate-limit response a caller can act on; an agent told only "rate limited" retries immediately and is refused again.
Verification
Ran the built server against a temp
HOMEholding only the key file, with no environment variable set anywhere:Four new tests cover the file path, env-outranks-file, a malformed file naming itself, and an empty file falling through. Tests 458 → 462.
Not carried over
#136's
accountJsonhelper duplicates polling and origin-pinning thatutils/api-key-call.tsandutils/wallet.ts:resolveGatewayUrlalready do, with tests. Itsrequirements-api-preview.txtwas a temporary note for the unpublished SDK and is obsolete.🤖 Generated with Claude Code
https://claude.ai/code/session_0116SvLAGyzJ4SYKBvAE2DTc