Repository navigation
Conversation
Adds the `explabs` entry to pi's credential store (~/.pi/agent/auth.json) as an API key source, resolving literals, $ENV_VAR references and `!command` secret lookups. EXPLABS_API_KEY stays as the fallback, and auth.json wins when both are set. Fixes joeljuca#1
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.
Summary
Solves issue #1
Adds the
explabsentry in pi's credential store (~/.pi/agent/auth.json) as an API key source, withEXPLABS_API_KEYas the fallback.Credential values support the same syntax as
models.json//loginvalues: a literal key, a$ENV_VAR/${ENV_VAR}reference, or a leading!commandfor secret managers (e.g."key": "!secret-tool lookup service explabs"). A!commandis handed to pi unresolved, so pi expands it per request and caches the result; the extension resolves it itself only for its own/modelsfetch.Resolution order: explicit extension config
apiKey→auth.json→ environment variable, soauth.jsonwins when both are set (matching pi's documented "auth file credentials take priority over environment variables").Why
auth.jsonwas being ignored: the extension always passes its own defaultapiKeyEnv, andresolveApiKey()treated any explicitapiKeyEnvas an opt-out of the credential store, making theauth.jsonbranch unreachable. #1apiKeyEnvnow only names the fallback variable — it no longer disablesauth.json.What changed
src/api-key.ts— new: reads theexplabsentry via pi'sreadStoredCredential(), resolves literals /$VAR/!command(with$$and$!escapes), and reports which source wonsrc/index.ts— passes the unresolved value to pi and uses the resolved one for the model fetch;/login explabsnow points atauth.jsonandEXPLABS_API_KEYREADME.md,CHANGELOG.md— documented both setup options and the precedenceTesting
npm run typecheck,npm test(61 tests) andnpm run prettier:checkpass.Also verified end-to-end against a local stub of the
/v1/modelsendpoint, checking theAuthorizationheader pi actually sends:auth.jsonwith!commandEXPLABS_API_KEYonlyauth.jsonwinsauth.jsonwith$VAR/ literal