Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2b391e9
feat: enrich model capabilities via models.dev and fix provider alias…
abien May 15, 2026
254201f
fix: address model metadata review feedback
abien May 15, 2026
0103477
fix: preserve combo attachment metadata
abien May 15, 2026
5df51f9
fix: respect explicit attachment false
abien May 15, 2026
9ca663b
fix: address code review issues from PR #18
Alph4d0g May 16, 2026
c8fa121
fix: use nullish coalescing for API key fallback
Alph4d0g May 16, 2026
c20ec3b
fix: add runtime validation for modelMetadata merge
Alph4d0g May 16, 2026
44944ff
fix: improve modelMetadata validation coverage
Alph4d0g May 16, 2026
b694043
fix: include modelsDev config in cache key
Alph4d0g May 16, 2026
95cdf39
refactor: extract splitModelId to eliminate DRY violation
Alph4d0g May 16, 2026
1b2718a
docs: document supportsTools default rationale
Alph4d0g May 16, 2026
78dae51
fix: avoid logging sensitive response data in models fetch error
Alph4d0g May 16, 2026
30fb321
style: add trailing newline to models-dev.ts
Alph4d0g May 16, 2026
0b1519c
fix: sanitize model IDs in log messages to prevent injection
Alph4d0g May 16, 2026
02d79b8
perf: use async file I/O for logger to prevent event loop blocking
Alph4d0g May 16, 2026
0b049a6
fix: strengthen log sanitization and cover missed interpolation sites
Alph4d0g May 16, 2026
f08a553
perf: avoid duplicate lookup candidates when alias resolves to same key
Alph4d0g May 16, 2026
2816f4c
types: tighten variants type to prevent invalid reasoning effort values
Alph4d0g May 16, 2026
be56ca4
refactor: extract magic constant 4096 to named defaults
Alph4d0g May 16, 2026
b3226b2
style: remove redundant as const assertions
Alph4d0g May 16, 2026
c92d7a1
test(tasks 15,17,18,19): Add model metadata, temperature/reasoning, v…
Alph4d0g May 16, 2026
114969f
test(task 20): Replace hardcoded ports with getDummyBaseUrl() helper
Alph4d0g May 16, 2026
3255e63
fix: align provider model fields with OpenCode plugin types
Alph4d0g May 16, 2026
8d32ebe
types: add OmniRoute native fields (snake_case, capabilities) to Omni…
Alph4d0g May 17, 2026
138c841
feat: normalize all OmniRoute field variants (snake_case, capabilities)
Alph4d0g May 17, 2026
1ab5139
feat: add provider alias-to-canonical mapping for deduplication
Alph4d0g May 17, 2026
b65a789
test: verify normalization of snake_case and capabilities fields
Alph4d0g May 17, 2026
c175d4c
fix: preserve user metadata by only deduplicating known aliases and c…
Alph4d0g May 17, 2026
725964e
fix: address gemini-code-assist review feedback on PR #20
Alph4d0g May 17, 2026
2aeacc3
chore: bump version to 1.2.0, update CHANGELOG and README
Alph4d0g May 17, 2026
36a2658
Merge branch 'main' into feat/model-enrichment-capabilities
Alph4d0g May 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .opencode/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
{
"name": "opencode-omniroute-auth",
"path": "/Users/alpha/git/opencode-omniroute-auth"
}
]
}
6 changes: 6 additions & 0 deletions .opencode/opencode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"list"
]
}
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

All notable changes to this project are documented in this file.

## [1.2.0] - 2026-05-17

### Added

- **Comprehensive Model Metadata Normalization** — `normalizeModel()` now reads all OmniRoute field variants with proper precedence:
- camelCase fields (e.g., `contextWindow`, `supportsVision`)
- snake_case fields (e.g., `context_length`, `max_output_tokens`)
- capabilities object (e.g., `capabilities.vision`, `capabilities.tool_calling`)
- Precedence: camelCase > snake_case > capabilities object
- **Provider Alias Deduplication** — Generic deduplication system that groups alias and canonical model entries:
- Added `PROVIDER_ALIAS_TO_CANONICAL` mapping for known aliases (`cx` → `codex`, `ollamacloud` → `ollama-cloud`, etc.)
- Added `deduplicateModels()` function that prefers canonical IDs and merges alias metadata
- Added `resolveProviderAliasForMetadata()` and `isProviderAlias()` helpers
- Only deduplicates known aliases; unknown provider prefixes are preserved as-is
- **Model Capability Enrichment** — Extended `OmniRouteModel` interface with native OmniRoute fields:
- snake_case context limits: `context_length`, `max_input_tokens`, `max_output_tokens`
- Top-level capability flags: `vision`, `tool_calling`
- capabilities object: `vision`, `tool_calling`, `reasoning`, `thinking`, `attachment`, `temperature`
- **Array-based Metadata Validation** — User-provided `modelMetadata` array blocks are now validated with warning logs for invalid entries
- **4 New Test Cases** covering normalization precedence, snake_case field reading, and deduplication behavior

### Changed

- **Array Metadata Merge Precedence** — In array-based `modelMetadata`, user config now comes before generated blocks to ensure user overrides take precedence in first-match-wins systems
- **Metadata Key Canonicalization** — User metadata with alias keys (e.g., `cx/gpt-5.5`) is merged into canonical keys (e.g., `codex/gpt-5.5`) to match deduplicated model IDs
- **Unknown Prefix Handling** — Unknown provider prefixes now merge metadata instead of overwriting, preserving all available metadata

### Fixed

- **Dead Code Removal** — Eliminated unreachable `isAlias` check in deduplication logic
- **Alias Metadata Loss** — Alias metadata is now merged into canonical entries instead of being dropped
- **Review Feedback** — Addressed all gemini-code-assist review comments from PR #20:
- Fixed array-based metadata merge precedence (userConfig first)
- Added validation for array-based user metadata blocks
- Fixed metadata merging for unknown provider prefixes
- Simplified deduplication logic and merged alias metadata into canonical

## [1.1.4] - 2026-05-15

### Added
Expand Down
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@
- ✅ **Provider Auto-Registration** - Registers an `omniroute` provider via plugin hooks
- ✅ **Model Caching** - Intelligent caching with TTL for better performance
- ✅ **Fallback Models** - Default models when API is unavailable
- ✅ **Model Metadata Normalization** - Reads all OmniRoute field variants (camelCase, snake_case, capabilities object) with proper precedence
- ✅ **Provider Alias Deduplication** - Automatically deduplicates alias/canonical model entries (e.g., `cx/gpt-5.5` → `codex/gpt-5.5`)
- ✅ **Combo Model Capability Enrichment** - Automatically calculates lowest common capabilities for OmniRoute combo models
- ✅ **models.dev Enrichment** - Enriches model metadata from models.dev API with provider alias resolution
- ✅ **Subscription Provider Fallback** - Falls back to public providers for subscription-based models
- ✅ **Model Variant Support** - Automatically strips reasoning effort suffixes (e.g., `gpt-5.5-xhigh` → `gpt-5.5`) for lookup
- ✅ **Secure Logging** - Sanitized log output with async file I/O to prevent event loop blocking

## Installation

```bash
npm install opencode-omniroute-auth
```

## Quick Start

### 1. Add plugin to opencode config
Expand Down Expand Up @@ -276,6 +286,21 @@ interface OmniRouteModel {
supportsStreaming?: boolean;
supportsVision?: boolean;
supportsTools?: boolean;
supportsTemperature?: boolean;
supportsReasoning?: boolean;
supportsAttachment?: boolean;
// OmniRoute native fields (normalized automatically)
context_length?: number;
max_input_tokens?: number;
max_output_tokens?: number;
capabilities?: {
vision?: boolean;
tool_calling?: boolean;
reasoning?: boolean;
thinking?: boolean;
attachment?: boolean;
temperature?: boolean;
};
pricing?: {
input?: number;
output?: number;
Expand All @@ -290,14 +315,14 @@ import {
fetchModels,
clearModelCache,
refreshModels,
// New: Combo model utilities
// Combo model utilities
clearComboCache,
fetchComboData,
resolveUnderlyingModels,
calculateModelCapabilities,
} from 'opencode-omniroute-auth/runtime';

// Fetch models manually (with automatic enrichment)
// Fetch models manually (with automatic normalization and enrichment)
const models = await fetchModels(config, apiKey);

// Clear model cache (also clears combo cache)
Expand All @@ -311,21 +336,6 @@ const combos = await fetchComboData(config);
const underlyingModels = await resolveUnderlyingModels('Designer', config);
const capabilities = await calculateModelCapabilities(model, config, modelsDevIndex);
```
import {
fetchModels,
clearModelCache,
refreshModels,
} from 'opencode-omniroute-auth/runtime';

// Fetch models manually
const models = await fetchModels(config, apiKey);

// Clear model cache
clearModelCache();

// Force refresh models
const freshModels = await refreshModels(config, apiKey);
```

## Development

Expand Down Expand Up @@ -385,3 +395,7 @@ Contributions are welcome! Please feel free to submit a Pull Request.
## Support

For support, please open an issue on GitHub or contact OmniRoute support.

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=Alph4d0g/opencode-omniroute-auth&type=Date)](https://star-history.com/#Alph4d0g/opencode-omniroute-auth&Date)
Loading
Loading