Download packages/server/src/handlers/provider.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/server/src/handlers/provider.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/server/src/handlers/provider.ts
-
curl -L -o provider.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/server/src/handlers/provider.ts
1.13 kB
| 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)) | |
| }), | |
| ) | |
| }), | |
| ) | |