/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/server/src/handlers/provider.ts
32 строки
1 KB
Kit Langton
refactor(protocol): extract server contracts (#33708)
25 июн 2026, 05:15
Не верифицирован
25 июн 2026, 05:15
56a37c3
Код
Авторство
О чём код?
import { Catalog } from "@opencode-ai/core/catalog" import { Effect } from "effect" import { HttpApiBuilder } from "effect/unstable/httpapi" import { Api } from "../api" import { ProviderNotFoundError } from "@opencode-ai/protocol/errors" import { response } from "../location" export const ProviderHandler = HttpApiBuilder.group(Api, "server.provider", (handlers) => Effect.gen(function* () { return handlers .handle( "provider.list", Effect.fn(function* () { const catalog = yield* Catalog.Service return yield* response(catalog.provider.available()) }), ) .handle( "provider.get", Effect.fn(function* (ctx) { const catalog = yield* Catalog.Service const provider = yield* catalog.provider.get(ctx.params.providerID) if (!provider) return yield* new ProviderNotFoundError({ providerID: ctx.params.providerID, message: `Provider not found: ${ctx.params.providerID}`, }) return yield* response(Effect.succeed(provider)) }), ) }), )