Skip to content

fix: resolve zai key from omp credential store first - #5

Merged
rz1989s merged 1 commit into
mainfrom
fix/zai-key-omp-credential-store
Sep 7, 2026
Merged

rz1989s merged 1 commit into
mainfrom
fix/zai-key-omp-credential-store

Conversation

@rz1989s

@rz1989s rz1989s commented Sep 7, 2026

Copy link
Copy Markdown
Member

Problem

zai.authJsonPath defaulted 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():

  1. explicit zai.authJsonPath config → that file is the sole source (two-account setups)
  2. ctx.modelRegistry.getApiKeyForProvider("zai") — omp's own credential ladder (models.yml → OAuth → /login key → env → auth broker); also correct in broker mode where agent.db is bypassed
  3. ~/.pi/agent/auth.json fallback (pi-coexisting setups)
  • /sl reports the winning key source (zai key omp credentials · … / no key); 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
  • README + dataflow.svg updated ("omp has no auth store of its own" was factually wrong)

Verification

  • pnpm typecheck clean
  • 19/19 tests — 4 new in test/zai-key.test.ts (store-wins-unconfigured, fallback on miss/reject/absent-ctx, explicit-pin-bypasses-store, no-key → null)
  • dataflow.svg re-rendered + visually verified

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.
@rz1989s
rz1989s merged commit 2e3dced into main Sep 7, 2026
@rz1989s
rz1989s deleted the fix/zai-key-omp-credential-store branch September 7, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant