summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-04-08 15:55:14 -0500
committerGitHub <[email protected]>2026-04-08 15:55:14 -0500
commit4961d72c0fa23ee23bca9ea59b86a2b13bcf4427 (patch)
tree8cdab62ea19223c38a62981450eb77a089436717 /packages
parent00cb8839ae71a1aae0a9bac92a1f53c61ef70bf9 (diff)
downloadopencode-4961d72c0fa23ee23bca9ea59b86a2b13bcf4427.tar.gz
opencode-4961d72c0fa23ee23bca9ea59b86a2b13bcf4427.zip
tweak: separate ModelsDev.Model and Config model schemas (#21561)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/config/config.ts94
-rw-r--r--packages/opencode/src/provider/models.ts3
-rw-r--r--packages/opencode/src/provider/provider.ts4
-rw-r--r--packages/sdk/js/src/v2/gen/types.gen.ts54
-rw-r--r--packages/sdk/openapi.json130
5 files changed, 169 insertions, 116 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index efae2ca55..1952e3b57 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -786,28 +786,81 @@ export namespace Config {
})
export type Layout = z.infer<typeof Layout>
- export const Provider = ModelsDev.Provider.partial()
- .extend({
- whitelist: z.array(z.string()).optional(),
- blacklist: z.array(z.string()).optional(),
- models: z
+ export const Model = z
+ .object({
+ id: z.string(),
+ name: z.string(),
+ family: z.string().optional(),
+ release_date: z.string(),
+ attachment: z.boolean(),
+ reasoning: z.boolean(),
+ temperature: z.boolean(),
+ tool_call: z.boolean(),
+ interleaved: z
+ .union([
+ z.literal(true),
+ z
+ .object({
+ field: z.enum(["reasoning_content", "reasoning_details"]),
+ })
+ .strict(),
+ ])
+ .optional(),
+ cost: z
+ .object({
+ input: z.number(),
+ output: z.number(),
+ cache_read: z.number().optional(),
+ cache_write: z.number().optional(),
+ context_over_200k: z
+ .object({
+ input: z.number(),
+ output: z.number(),
+ cache_read: z.number().optional(),
+ cache_write: z.number().optional(),
+ })
+ .optional(),
+ })
+ .optional(),
+ limit: z.object({
+ context: z.number(),
+ input: z.number().optional(),
+ output: z.number(),
+ }),
+ modalities: z
+ .object({
+ input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
+ output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
+ })
+ .optional(),
+ experimental: z.boolean().optional(),
+ status: z.enum(["alpha", "beta", "deprecated"]).optional(),
+ provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
+ options: z.record(z.string(), z.any()),
+ headers: z.record(z.string(), z.string()).optional(),
+ variants: z
.record(
z.string(),
- ModelsDev.Model.partial().extend({
- variants: z
- .record(
- z.string(),
- z
- .object({
- disabled: z.boolean().optional().describe("Disable this variant for the model"),
- })
- .catchall(z.any()),
- )
- .optional()
- .describe("Variant-specific configuration"),
- }),
+ z
+ .object({
+ disabled: z.boolean().optional().describe("Disable this variant for the model"),
+ })
+ .catchall(z.any()),
)
- .optional(),
+ .optional()
+ .describe("Variant-specific configuration"),
+ })
+ .partial()
+
+ export const Provider = z
+ .object({
+ api: z.string().optional(),
+ name: z.string(),
+ env: z.array(z.string()),
+ id: z.string(),
+ npm: z.string().optional(),
+ whitelist: z.array(z.string()).optional(),
+ blacklist: z.array(z.string()).optional(),
options: z
.object({
apiKey: z.string().optional(),
@@ -840,11 +893,14 @@ export namespace Config {
})
.catchall(z.any())
.optional(),
+ models: z.record(z.string(), Model).optional(),
})
+ .partial()
.strict()
.meta({
ref: "ProviderConfig",
})
+
export type Provider = z.infer<typeof Provider>
export const Info = z
diff --git a/packages/opencode/src/provider/models.ts b/packages/opencode/src/provider/models.ts
index c6ab5d836..23f61d804 100644
--- a/packages/opencode/src/provider/models.ts
+++ b/packages/opencode/src/provider/models.ts
@@ -70,10 +70,7 @@ export namespace ModelsDev {
.optional(),
experimental: z.boolean().optional(),
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
- options: z.record(z.string(), z.any()),
- headers: z.record(z.string(), z.string()).optional(),
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
- variants: z.record(z.string(), z.record(z.string(), z.any())).optional(),
})
export type Model = z.infer<typeof Model>
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts
index 9ca49bf8f..9febf634f 100644
--- a/packages/opencode/src/provider/provider.ts
+++ b/packages/opencode/src/provider/provider.ts
@@ -937,8 +937,8 @@ export namespace Provider {
npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible",
},
status: model.status ?? "active",
- headers: model.headers ?? {},
- options: model.options ?? {},
+ headers: {},
+ options: {},
cost: {
input: model.cost?.input ?? 0,
output: model.cost?.output ?? 0,
diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts
index e21e093c6..4f226e60c 100644
--- a/packages/sdk/js/src/v2/gen/types.gen.ts
+++ b/packages/sdk/js/src/v2/gen/types.gen.ts
@@ -1250,6 +1250,29 @@ export type ProviderConfig = {
env?: Array<string>
id?: string
npm?: string
+ whitelist?: Array<string>
+ blacklist?: Array<string>
+ options?: {
+ apiKey?: string
+ baseURL?: string
+ /**
+ * GitHub Enterprise URL for copilot authentication
+ */
+ enterpriseUrl?: string
+ /**
+ * Enable promptCacheKey for this provider (default false)
+ */
+ setCacheKey?: boolean
+ /**
+ * Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
+ */
+ timeout?: number | false
+ /**
+ * Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.
+ */
+ chunkTimeout?: number
+ [key: string]: unknown | string | boolean | number | false | number | undefined
+ }
models?: {
[key: string]: {
id?: string
@@ -1288,16 +1311,16 @@ export type ProviderConfig = {
}
experimental?: boolean
status?: "alpha" | "beta" | "deprecated"
+ provider?: {
+ npm?: string
+ api?: string
+ }
options?: {
[key: string]: unknown
}
headers?: {
[key: string]: string
}
- provider?: {
- npm?: string
- api?: string
- }
/**
* Variant-specific configuration
*/
@@ -1312,29 +1335,6 @@ export type ProviderConfig = {
}
}
}
- whitelist?: Array<string>
- blacklist?: Array<string>
- options?: {
- apiKey?: string
- baseURL?: string
- /**
- * GitHub Enterprise URL for copilot authentication
- */
- enterpriseUrl?: string
- /**
- * Enable promptCacheKey for this provider (default false)
- */
- setCacheKey?: boolean
- /**
- * Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
- */
- timeout?: number | false
- /**
- * Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.
- */
- chunkTimeout?: number
- [key: string]: unknown | string | boolean | number | false | number | undefined
- }
}
export type McpLocalConfig = {
diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json
index 0f3b2c397..a0672df2d 100644
--- a/packages/sdk/openapi.json
+++ b/packages/sdk/openapi.json
@@ -10596,6 +10596,60 @@
"npm": {
"type": "string"
},
+ "whitelist": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "blacklist": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "options": {
+ "type": "object",
+ "properties": {
+ "apiKey": {
+ "type": "string"
+ },
+ "baseURL": {
+ "type": "string"
+ },
+ "enterpriseUrl": {
+ "description": "GitHub Enterprise URL for copilot authentication",
+ "type": "string"
+ },
+ "setCacheKey": {
+ "description": "Enable promptCacheKey for this provider (default false)",
+ "type": "boolean"
+ },
+ "timeout": {
+ "description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
+ "anyOf": [
+ {
+ "description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
+ "type": "integer",
+ "exclusiveMinimum": 0,
+ "maximum": 9007199254740991
+ },
+ {
+ "description": "Disable timeout for this provider entirely.",
+ "type": "boolean",
+ "const": false
+ }
+ ]
+ },
+ "chunkTimeout": {
+ "description": "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
+ "type": "integer",
+ "exclusiveMinimum": 0,
+ "maximum": 9007199254740991
+ }
+ },
+ "additionalProperties": {}
+ },
"models": {
"type": "object",
"propertyNames": {
@@ -10725,6 +10779,17 @@
"type": "string",
"enum": ["alpha", "beta", "deprecated"]
},
+ "provider": {
+ "type": "object",
+ "properties": {
+ "npm": {
+ "type": "string"
+ },
+ "api": {
+ "type": "string"
+ }
+ }
+ },
"options": {
"type": "object",
"propertyNames": {
@@ -10741,17 +10806,6 @@
"type": "string"
}
},
- "provider": {
- "type": "object",
- "properties": {
- "npm": {
- "type": "string"
- },
- "api": {
- "type": "string"
- }
- }
- },
"variants": {
"description": "Variant-specific configuration",
"type": "object",
@@ -10771,60 +10825,6 @@
}
}
}
- },
- "whitelist": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "blacklist": {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "options": {
- "type": "object",
- "properties": {
- "apiKey": {
- "type": "string"
- },
- "baseURL": {
- "type": "string"
- },
- "enterpriseUrl": {
- "description": "GitHub Enterprise URL for copilot authentication",
- "type": "string"
- },
- "setCacheKey": {
- "description": "Enable promptCacheKey for this provider (default false)",
- "type": "boolean"
- },
- "timeout": {
- "description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
- "anyOf": [
- {
- "description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
- "type": "integer",
- "exclusiveMinimum": 0,
- "maximum": 9007199254740991
- },
- {
- "description": "Disable timeout for this provider entirely.",
- "type": "boolean",
- "const": false
- }
- ]
- },
- "chunkTimeout": {
- "description": "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
- "type": "integer",
- "exclusiveMinimum": 0,
- "maximum": 9007199254740991
- }
- },
- "additionalProperties": {}
}
},
"additionalProperties": false