singularity-forge/packages/pi-ai
Jeremy McSpadden f8814f5a15 refactor(pi-ai): replace model-ID pattern matching with capability metadata (#2548)
* refactor(pi-ai): replace model-ID pattern matching with capability metadata

Add ModelCapabilities to Model<TApi> and a CAPABILITY_PATCHES mechanism
so call sites read model.capabilities fields instead of parsing model IDs
or hardcoding provider names.

- types.ts: add ModelCapabilities interface (supportsXhigh, requiresToolCallId,
  supportsServiceTier, charsPerToken) and capabilities?: ModelCapabilities to
  Model<TApi>
- models.ts: add CAPABILITY_PATCHES table applied at registry init; patches
  declare GPT-5.x and Opus 4.6 capabilities once instead of repeating ID
  checks at every call site; supportsXhigh() now reads capabilities only
- service-tier.ts: extract SERVICE_TIER_MODEL_PREFIXES constant so the gating
  list has a single named home; add path comment pointing to issue #2546 for
  the full capability-driven follow-up

No behaviour change. New models and providers can declare capabilities in
their model definitions without touching function logic.

Closes #2546

* fix(pi-ai): apply capability patches to custom/discovered/extension models

Models constructed outside the static pi-ai registry (custom models
from models.json, extension-registered models, discovered models)
bypassed CAPABILITY_PATCHES — causing supportsXhigh() to silently
return false for GPT-5.x or Opus 4.6 variants registered through
those paths.

Export applyCapabilityPatches() from pi-ai and call it in ModelRegistry
after model assembly in all three construction paths: loadModels(),
applyProviderConfig(), and discoverModels().

Add regression tests covering patching, precedence, idempotency,
and synthetic models that mimic the custom/extension path.

Closes #2546
2026-03-26 16:38:29 -06:00
..
scripts fix(pi-ai): correct Copilot context window and output token limits (#2118) 2026-03-22 17:04:16 -06:00
src refactor(pi-ai): replace model-ID pattern matching with capability metadata (#2548) 2026-03-26 16:38:29 -06:00
bedrock-provider.d.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
bedrock-provider.js feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
oauth.d.ts fix: add missing package.json subpath exports and oauth stubs (#1014) 2026-03-17 18:01:56 -06:00
oauth.js fix: add missing package.json subpath exports and oauth stubs (#1014) 2026-03-17 18:01:56 -06:00
package.json feat: add anthropic-vertex provider for Claude on Vertex AI (#1533) 2026-03-19 23:14:13 -06:00
tsconfig.json feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00