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
2.9 KiB
2.9 KiB
AGENTS.md
Project
nous-portal: a 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 --noEmitthennode --test tests/*.test.mjs.- Install dev deps with
npm install --legacy-peer-deps --no-package-lock. Plainnpm installignores the"*"peer ranges and pulls a full duplicate copy of@earendil-works/pi-aiintonode_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 legacyProviderConfig+oauthblock. The legacygetApiKeycontract pushes an extension toward minting an agent key; Nous retired that endpoint (410 session_key_minting_retired). HereOAuthAuth.toAuthreturns the access token itself, and pi owns the locked refresh pattern. Seedocs/adr/0001-stack.md. - Streaming is delegated to pi's built-in
openai-completionsAPI. 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.withoutTierHeaderstrips 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. ImportopenAICompletionsApifrom@earendil-works/pi-ai/compat; the./api/*subpath typechecks but fails at load. ctxvspi:setModel,registerCommand,registerProviderare onpi;ui.notify,model,modelRegistryare on the handler'sctx. Check withtscrather than guessing.pi -pand--list-modelsnever fetch live catalogs (allowModelNetworkis hard-codedfalse). That is why the provider shipsBASELINE; interactive startup overlays the live list.- Tests load
index.tsthrough jiti with the host packages aliased totests/stubs/pi-ai.mjs. Alias keys are longest-prefix first, sopi-ai/compatmust precedepi-aior the bare key swallows the subpath. - Never blanket-inject
tags.userinto request bodies. As of 2026-11-25 Nous free and discounted models return 500 when that field is present, and onlyupstage/solar-mini4:freerequires it.solar-mini4:freeis therefore left out ofBASELINEon purpose.
Catalog tiers
Live catalog signals, classified in tierOf:
- free:
synthesizedFreeVariant: true(also suffixed:free) - promo:
pricing.original.promptgreater than the currentpricing.prompt
billing_mode: "subscription" is a separate axis (batch models billed to the plan), not a promo marker.