Registers the native nous-portal provider for pi. Nous retired agent-key minting (410 session_key_minting_retired), which is where both existing community extensions end their login. The inference API accepts the OAuth access token directly, so toAuth hands it over and no agent key is ever minted or stored. - Device-code OAuth (subscription) and API-key login - Live model discovery delegated to openai-completions streaming - Offline baseline so pi -p and --list-models stay usable - /nous-catalog cycles full, free and promo; /nous-free jumps to free
35 lines
2.9 KiB
Markdown
35 lines
2.9 KiB
Markdown
# AGENTS.md
|
|
|
|
## Project
|
|
|
|
`nous-portal`: a [pi](https://github.com/earendil-works/pi) provider extension (single `index.ts`, no build step). Registers the `nous-portal` provider with device-code OAuth and API-key auth against Nous inference, plus `/model` catalog filters.
|
|
|
|
## Commands
|
|
|
|
- `npm run check`: `tsc --noEmit` then `node --test tests/*.test.mjs`.
|
|
- Install dev deps with `npm install --legacy-peer-deps --no-package-lock`. Plain `npm install` ignores the `"*"` peer ranges and pulls a full duplicate copy of `@earendil-works/pi-ai` into `node_modules`, which pi's loader explicitly warns against.
|
|
- Local install for pi: `ln -s "$PWD" ~/.pi/agent/extensions/nous-portal` (sibling convention in `~/Projects/scripting/pi-extensions`).
|
|
|
|
## Architecture
|
|
|
|
- Uses the **native** pi-ai `Provider` (`createProvider`) rather than the legacy `ProviderConfig` + `oauth` block. The legacy `getApiKey` contract pushes an extension toward minting an agent key; Nous retired that endpoint (`410 session_key_minting_retired`). Here `OAuthAuth.toAuth` returns the access token itself, and pi owns the locked refresh pattern. See `docs/adr/0001-stack.md`.
|
|
- Streaming is delegated to pi's built-in `openai-completions` API. No custom wire protocol.
|
|
- `Model.headers["x-nous-catalog-tier"]` carries the catalog tier **on the model**, because pi persists and restores model objects across runs and a side table would miss restored entries. `withoutTierHeader` strips it before every request.
|
|
|
|
## Conventions and gotchas
|
|
|
|
- **Host imports are allowlisted.** pi's extension loader aliases only `@earendil-works/pi-ai`, `/models`, `/oauth`, `/compat`, `/providers/all`. Import `openAICompletionsApi` from `@earendil-works/pi-ai/compat`; the `./api/*` subpath typechecks but fails at load.
|
|
- **`ctx` vs `pi`:** `setModel`, `registerCommand`, `registerProvider` are on `pi`; `ui.notify`, `model`, `modelRegistry` are on the handler's `ctx`. Check with `tsc` rather than guessing.
|
|
- **`pi -p` and `--list-models` never fetch live catalogs** (`allowModelNetwork` is hard-coded `false`). That is why the provider ships `BASELINE`; interactive startup overlays the live list.
|
|
- **Tests load `index.ts` through jiti with the host packages aliased to `tests/stubs/pi-ai.mjs`.** Alias keys are longest-prefix first, so `pi-ai/compat` must precede `pi-ai` or the bare key swallows the subpath.
|
|
- **Never blanket-inject `tags.user` into request bodies.** As of 2026-11-25 Nous free and discounted models return 500 when that field is present, and only `upstage/solar-mini4:free` requires it. `solar-mini4:free` is therefore left out of `BASELINE` on purpose.
|
|
|
|
## Catalog tiers
|
|
|
|
Live catalog signals, classified in `tierOf`:
|
|
|
|
- free: `synthesizedFreeVariant: true` (also suffixed `:free`)
|
|
- promo: `pricing.original.prompt` greater than the current `pricing.prompt`
|
|
|
|
`billing_mode: "subscription"` is a separate axis (batch models billed to the plan), not a promo marker.
|