Skip to content

Commit 8369dec

Browse files
committed
refactor(types): use canonical provider category identifiers
1 parent c24a8c5 commit 8369dec

2 files changed

Lines changed: 73 additions & 15 deletions

File tree

‎packages/types/src/__tests__/provider-identifiers.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import {
2+
customProviders,
3+
dynamicProviders,
4+
fauxProviders,
5+
internalProviders,
6+
isCustomProvider,
7+
isDynamicProvider,
8+
isFauxProvider,
9+
isInternalProvider,
10+
isLocalProvider,
211
isProviderName,
312
isRetiredProvider,
13+
localProviders,
414
providerIdentifiers,
515
providerNames,
616
providerNamesSchema,
@@ -81,6 +91,54 @@ describe("provider identifiers", () => {
8191
expect(retiredProviderNames).toEqual(retiredIdentifiers)
8292
})
8393

94+
it("derives provider category collections from canonical identifiers", () => {
95+
expect(dynamicProviders).toEqual([
96+
providerIdentifiers.openrouter,
97+
providerIdentifiers.vercelAiGateway,
98+
providerIdentifiers.zooGateway,
99+
providerIdentifiers.litellm,
100+
providerIdentifiers.requesty,
101+
providerIdentifiers.unbound,
102+
providerIdentifiers.poe,
103+
providerIdentifiers.deepseek,
104+
providerIdentifiers.moonshot,
105+
providerIdentifiers.opencodeGo,
106+
providerIdentifiers.kenari,
107+
])
108+
expect(localProviders).toEqual([providerIdentifiers.ollama, providerIdentifiers.lmstudio])
109+
expect(internalProviders).toEqual([providerIdentifiers.vscodeLm])
110+
expect(customProviders).toEqual([providerIdentifiers.openai])
111+
expect(fauxProviders).toEqual([providerIdentifiers.fakeAi])
112+
})
113+
114+
it("preserves provider category type guards", () => {
115+
for (const identifier of dynamicProviders) {
116+
expect(isDynamicProvider(identifier)).toBe(true)
117+
}
118+
119+
for (const identifier of localProviders) {
120+
expect(isLocalProvider(identifier)).toBe(true)
121+
}
122+
123+
for (const identifier of internalProviders) {
124+
expect(isInternalProvider(identifier)).toBe(true)
125+
}
126+
127+
for (const identifier of customProviders) {
128+
expect(isCustomProvider(identifier)).toBe(true)
129+
}
130+
131+
for (const identifier of fauxProviders) {
132+
expect(isFauxProvider(identifier)).toBe(true)
133+
}
134+
135+
expect(isDynamicProvider("unknown-provider")).toBe(false)
136+
expect(isLocalProvider("unknown-provider")).toBe(false)
137+
expect(isInternalProvider("unknown-provider")).toBe(false)
138+
expect(isCustomProvider("unknown-provider")).toBe(false)
139+
expect(isFauxProvider("unknown-provider")).toBe(false)
140+
})
141+
84142
it("keeps active and retired providers separate", () => {
85143
const activeIdentifiers = new Set<string>(Object.values(providerIdentifiers))
86144
const retiredIdentifiers = Object.values(retiredProviderIdentifiers)

‎packages/types/src/provider-settings.ts‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ export const DEFAULT_CONSECUTIVE_MISTAKE_LIMIT = 3
4444
*/
4545

4646
export const dynamicProviders = [
47-
"openrouter",
48-
"vercel-ai-gateway",
49-
"zoo-gateway",
50-
"litellm",
51-
"requesty",
52-
"unbound",
53-
"poe",
54-
"deepseek",
55-
"moonshot",
56-
"opencode-go",
57-
"kenari",
47+
providerIdentifiers.openrouter,
48+
providerIdentifiers.vercelAiGateway,
49+
providerIdentifiers.zooGateway,
50+
providerIdentifiers.litellm,
51+
providerIdentifiers.requesty,
52+
providerIdentifiers.unbound,
53+
providerIdentifiers.poe,
54+
providerIdentifiers.deepseek,
55+
providerIdentifiers.moonshot,
56+
providerIdentifiers.opencodeGo,
57+
providerIdentifiers.kenari,
5858
] as const
5959

6060
export type DynamicProvider = (typeof dynamicProviders)[number]
@@ -68,7 +68,7 @@ export const isDynamicProvider = (key: string): key is DynamicProvider =>
6868
* Local providers require localhost API calls in order to get the model list.
6969
*/
7070

71-
export const localProviders = ["ollama", "lmstudio"] as const
71+
export const localProviders = [providerIdentifiers.ollama, providerIdentifiers.lmstudio] as const
7272

7373
export type LocalProvider = (typeof localProviders)[number]
7474

@@ -81,7 +81,7 @@ export const isLocalProvider = (key: string): key is LocalProvider => localProvi
8181
* model list.
8282
*/
8383

84-
export const internalProviders = ["vscode-lm"] as const
84+
export const internalProviders = [providerIdentifiers.vscodeLm] as const
8585

8686
export type InternalProvider = (typeof internalProviders)[number]
8787

@@ -94,7 +94,7 @@ export const isInternalProvider = (key: string): key is InternalProvider =>
9494
* Custom providers are completely configurable within Roo Code settings.
9595
*/
9696

97-
export const customProviders = ["openai"] as const
97+
export const customProviders = [providerIdentifiers.openai] as const
9898

9999
export type CustomProvider = (typeof customProviders)[number]
100100

@@ -107,7 +107,7 @@ export const isCustomProvider = (key: string): key is CustomProvider => customPr
107107
* model lists.
108108
*/
109109

110-
export const fauxProviders = ["fake-ai"] as const
110+
export const fauxProviders = [providerIdentifiers.fakeAi] as const
111111

112112
export type FauxProvider = (typeof fauxProviders)[number]
113113

0 commit comments

Comments
 (0)