Skip to content

feat: fully dynamic model catalog - no hardcoded models - #224

Open
KpihX wants to merge 3 commits into
anthonyhaussman:mainfrom
kpihx-labs:main
Open

KpihX wants to merge 3 commits into
anthonyhaussman:mainfrom
kpihx-labs:main

Conversation

@KpihX

@KpihX KpihX commented Nov 15, 2026

Copy link
Copy Markdown

This PR makes the opencode-agy-auth plugin fully dynamic by removing all hardcoded model lists.

Changes

  • Removed STATIC_MODELS_SIMPLE and TIER_MAPPING hardcoded constants from tier.ts
  • Added dynamic model discovery via AGY quota API (retrieveUserQuota)
  • New exports in tier.ts:
    • inferModelMetadata() - infers model metadata from model ID patterns
    • extractBaseModelId() - extracts base model ID from tiered variants
    • buildTierMapping() - builds tier mapping from quota response
    • fetchAvailableModelIds() - fetches available model IDs from AGY
    • resolveModelTier() - now accepts dynamic tier mapping
  • Updated plugin.ts:
    • buildModelFromBase() - builds ProviderModel from dynamic data
    • buildDynamicModelCatalog() - creates catalog from quota response
    • getDynamicModels() - merges dynamic models with user config
    • Provider models hook now calls dynamic catalog
  • Updated v2.ts to use dynamic catalog at startup

How it works

  1. When authenticated, the plugin calls AGY's retrieveUserQuota API
  2. Extracts modelId from each bucket in the response
  3. Groups tiered variants by base model (e.g., gemini-3.8-flash-low -> gemini-3.8-flash)
  4. Infers metadata (name, capabilities, limits) from base model ID patterns
  5. Builds full ProviderModel catalog dynamically
  6. Merges with any user-defined model overrides

Verification

  • npm run build passes TypeScript
  • Manual test with opencode models shows only models from user's actual AGY quota

This ensures the plugin always shows exactly the models the user has access to in their AGY account, not a stale hardcoded list.

- Removed STATIC_MODELS_SIMPLE and TIER_MAPPING hardcoded lists
- Added dynamic model inference from AGY quota API (retrieveUserQuota)
- Models are now discovered at runtime based on user's actual AGY access
- Updated tier.ts with inferModelMetadata, extractBaseModelId, buildTierMapping, fetchAvailableModelIds
- Updated plugin.ts to use dynamic catalog via buildDynamicModelCatalog
- Updated v2.ts to use dynamic catalog at startup
- Tests updated to verify dynamic behavior instead of hardcoded models
- Remove STATIC_MODELS_SIMPLE and TIER_MAPPING hardcoded lists
- Discover models live from AGY quota API (retrieveUserQuota)
- Infer model metadata (name, limits, capabilities) from model ID patterns
- Config hook populates models at startup without touching client
  (avoids re-entrant config.get deadlock); NOOP auth client + 25s cap
  so a stalled network can never hang server startup
- Resolve projectId via refresh-token parts, config, env, then AGY API
  (resolveProjectContextFromAccessToken) as last resort
- v2 setup registers dynamic models via provider/model/catalog transforms
  using the connection API
- provider.models hook merges dynamic catalog with user overrides,
  applies models.dev pricing, normalizes costs; login-required fallback
- Verified: opencode models lists live AGY inventory (4.6, gemini-3.8,
  gpt-oss-120b, etc.), zero 5.5 entries; nvidia-labs unaffected
- Remove accidentally committed npm tarball
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