Repository navigation
fix: route keys by their variable, never by their shape - #13
Merged
Merged
Conversation
TypeSafe issues apikey_ keys as well as ts_ ones, and key shapes can change, so a key's prefix no longer decides where it is sent. The variable a key sits in decides its host; a key that looks like another host's only earns a hint in doctor. TYPESAFE_API_KEY keeps following TYPESAFE_BASE_URL and JEV_CODE_PROVIDER to OpenRouter and Vercel the way the TypeSafe SDK does; host-specific variables never travel, and the generic key never follows to OpenAI or Ollama. setup now asks which host a pasted key is for, defaulting to the JEV_CODE_PROVIDER host, else the prefix hint, else TypeSafe. The prompts settle when input ends and hand text after a newline to the next prompt. With JEV_CODE_PROVIDER=ollama, a stale TYPESAFE_BASE_URL on another known host is refused instead of carrying Ollama's key there.
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.
Why
TypeSafe issues
apikey_...keys as well asts_...ones, and key shapes can change at any time. Until now jev-code routed a key to a host by its prefix, whichever variable held it, so anapikey_key inTYPESAFE_API_KEYwas treated as "unknown prefix" and a key shaped like another host's was silently rerouted. Routing by shape is a guess, and guesses about credentials are the wrong default.What changes
TYPESAFE_API_KEYgoes to TypeSafe,OPENROUTER_API_KEYto OpenRouter,AI_GATEWAY_API_KEYto Vercel AI Gateway,OPENAI_API_KEYto OpenAI (still opt-in), whatever the key looks like.doctorsays "TYPESAFE_API_KEYlooks like an OpenRouter key (sk-or-…) but is sent to TypeSafe, as set" and tells you where to move it.apikey_is now a recognised TypeSafe shape.TYPESAFE_API_KEYis the generic variable the official SDK reads, so it followsTYPESAFE_BASE_URLandJEV_CODE_PROVIDERto OpenRouter or Vercel the way the SDK does (their setup guides set exactly that pair). It never follows to OpenAI (different wire) or Ollama.OPENROUTER_API_KEYwithJEV_CODE_PROVIDER=typesafeor a base URL on another known host is refused before any request, with the fix named. A proxy base URL still needsJEV_CODE_PROVIDERfor a host-specific key.JEV_CODE_PROVIDER=ollama, a staleTYPESAFE_BASE_URLon another known host is now refused (found by the security review; before, it carried Ollama's key and the payload there).setupasks which host a pasted key is for ([1] TypeSafe [2] OpenRouter [3] Vercel AI Gateway [4] OpenAI Decisions API, number or name, Enter for the default). The default is theJEV_CODE_PROVIDERhost, else the prefix hint, else TypeSafe. NewreadLinehelper next toreadSecret.Behaviour changes to note
TYPESAFE_API_KEY=apikey_…TYPESAFE_API_KEY=sk-or-…TYPESAFE_API_KEY=ts_…+TYPESAFE_BASE_URL=https://openrouter.ai/apiTYPESAFE_API_KEY=sk-proj-…+JEV_CODE_PROVIDER=openaiOPENAI_API_KEYOPENROUTER_API_KEY=…+JEV_CODE_PROVIDER=typesafeTest plan
npm run check(lint, typecheck, skill validation, 145 tests at 96% lines, build, MCP smoke)doctorrun against nine env combinations; messages reviewed by handsetup opencodedriven through a pseudo-terminal: hidden key prompt, visible host question answered with2, key written toOPENROUTER_API_KEY.env.example, harness guides, CLI help, and skill reference updated; no prefix routing claims remain