feat(id): brand ProviderID and ModelID (#17110)

This commit is contained in:
Kit Langton
2026-03-12 09:27:52 -04:00
committed by GitHub
parent 2eeba53b07
commit c45467964c
23 changed files with 157 additions and 107 deletions

View File

@@ -6,6 +6,7 @@ import { fn } from "@/util/fn"
import type { AuthOuathResult, Hooks } from "@opencode-ai/plugin"
import { NamedError } from "@opencode-ai/util/error"
import { Auth } from "@/auth"
import { ProviderID } from "./schema"
export namespace ProviderAuth {
const state = Instance.state(async () => {
@@ -53,7 +54,7 @@ export namespace ProviderAuth {
export const authorize = fn(
z.object({
providerID: z.string(),
providerID: ProviderID.zod,
method: z.number(),
}),
async (input): Promise<Authorization | undefined> => {
@@ -73,7 +74,7 @@ export namespace ProviderAuth {
export const callback = fn(
z.object({
providerID: z.string(),
providerID: ProviderID.zod,
method: z.number(),
code: z.string().optional(),
}),
@@ -119,7 +120,7 @@ export namespace ProviderAuth {
export const api = fn(
z.object({
providerID: z.string(),
providerID: ProviderID.zod,
key: z.string(),
}),
async (input) => {
@@ -133,13 +134,13 @@ export namespace ProviderAuth {
export const OauthMissing = NamedError.create(
"ProviderAuthOauthMissing",
z.object({
providerID: z.string(),
providerID: ProviderID.zod,
}),
)
export const OauthCodeMissing = NamedError.create(
"ProviderAuthOauthCodeMissing",
z.object({
providerID: z.string(),
providerID: ProviderID.zod,
}),
)