fix: resolve zai key from omp credential store first - #5
Merged
Merged
Conversation
omp keeps provider credentials in ~/.omp/agent/agent.db (auth_credentials),
not a pi-style auth.json — omp-only users got a silently inert zai row
because the vendored pi-statusline key path defaulted to ~/.pi/agent/auth.json.
Resolution order (v0.4.0):
1. explicit zai.authJsonPath config pins that file (two-account setups)
2. ctx.modelRegistry.getApiKeyForProvider("zai") — omp's own ladder
(models.yml / OAuth / /login key / env / auth broker; correct in
broker mode where agent.db is bypassed)
3. ~/.pi/agent/auth.json fallback (pi-coexisting setups)
/sl now reports the winning key source; no-key warning names both sources.
modelRegistry is optional on the ctx struct — absent host wiring degrades
to v0.3.0 behavior (file), never crashes.
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.
Problem
zai.authJsonPathdefaulted to~/.pi/agent/auth.json— omp-only users (no pi installed) got a silently inert zai row, because omp stores credentials in~/.omp/agent/agent.db(auth_credentials), not a JSON file.Fix (v0.4.0)
Key resolution order in
resolveZaiKey():zai.authJsonPathconfig → that file is the sole source (two-account setups)ctx.modelRegistry.getApiKeyForProvider("zai")— omp's own credential ladder (models.yml → OAuth → /login key → env → auth broker); also correct in broker mode whereagent.dbis bypassed~/.pi/agent/auth.jsonfallback (pi-coexisting setups)/slreports the winning key source (zai key omp credentials · …/no key); no-key warning names both sourcesmodelRegistryis optional on the ctx struct — absent host wiring degrades to v0.3.0 behavior (file), never crashesVerification
pnpm typecheckcleantest/zai-key.test.ts(store-wins-unconfigured, fallback on miss/reject/absent-ctx, explicit-pin-bypasses-store, no-key → null)