mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-23 18:55:37 -04:00
9e0d3976e1
Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: starptech <starptech@starptechs-MBP.fritz.box> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <little-frank@opencord.local> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: runvip <164729189+runvip@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Julian Coy <julian@ex-machina.co> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Jay <air@live.ca> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com>
76 lines
3.2 KiB
TypeScript
76 lines
3.2 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { LLM, LLMClient, Provider } from "@opencode-ai/llm"
|
|
import { Route, Protocol } from "@opencode-ai/llm/route"
|
|
import { Provider as ProviderSubpath } from "@opencode-ai/llm/provider"
|
|
import {
|
|
CloudflareAIGateway,
|
|
CloudflareWorkersAI,
|
|
OpenAI,
|
|
OpenAICompatible,
|
|
OpenRouter,
|
|
XAI,
|
|
} from "@opencode-ai/llm/providers"
|
|
import * as GitHubCopilot from "@opencode-ai/llm/providers/github-copilot"
|
|
import { OpenAIChat, OpenAICompatibleChat, OpenAIResponses } from "@opencode-ai/llm/protocols"
|
|
import * as AnthropicMessages from "@opencode-ai/llm/protocols/anthropic-messages"
|
|
|
|
describe("public exports", () => {
|
|
test("root exposes app-facing runtime APIs", () => {
|
|
expect(LLM.request).toBeFunction()
|
|
expect(LLMClient.Service).toBeFunction()
|
|
expect(LLMClient.layer).toBeDefined()
|
|
expect(Provider.make).toBeFunction()
|
|
expect(ProviderSubpath.make).toBe(Provider.make)
|
|
})
|
|
|
|
test("route barrel exposes route-authoring APIs", () => {
|
|
expect(Route.make).toBeFunction()
|
|
expect(Protocol.make).toBeFunction()
|
|
})
|
|
|
|
test("provider barrels expose user-facing facades", () => {
|
|
expect(OpenAI.model).toBeFunction()
|
|
expect(OpenAI.provider.responses).toBe(OpenAI.responses)
|
|
expect(OpenAI.provider.responsesWebSocket).toBe(OpenAI.responsesWebSocket)
|
|
expect(OpenAI.configure({ apiKey: "fixture" }).responses).toBeFunction()
|
|
expect(OpenAICompatible.deepseek.model).toBeFunction()
|
|
expect(CloudflareAIGateway.configure).toBeFunction()
|
|
expect(CloudflareAIGateway.configure({ accountId: "fixture", gatewayApiKey: "fixture" }).model).toBeFunction()
|
|
expect(CloudflareWorkersAI.configure).toBeFunction()
|
|
expect(CloudflareWorkersAI.configure({ accountId: "fixture", apiKey: "fixture" }).model).toBeFunction()
|
|
expect(OpenRouter.model).toBeFunction()
|
|
expect(OpenRouter.provider.model).toBe(OpenRouter.model)
|
|
expect(XAI.model).toBeFunction()
|
|
expect(XAI.provider.model).toBe(XAI.model)
|
|
expect(XAI.provider.responses).toBe(XAI.responses)
|
|
expect(XAI.provider.chat).toBe(XAI.chat)
|
|
expect(XAI.configure({ apiKey: "fixture" }).responses("grok-4.3").route.id).toBe("openai-responses")
|
|
expect(XAI.configure({ apiKey: "fixture" }).chat("grok-4.3").route.id).toBe("openai-compatible-chat")
|
|
expect(
|
|
GitHubCopilot.configure({ baseURL: "https://api.githubcopilot.test", apiKey: "fixture" }).model,
|
|
).toBeFunction()
|
|
expect(
|
|
GitHubCopilot.configure({
|
|
baseURL: "https://api.githubcopilot.test",
|
|
apiKey: "fixture",
|
|
endpoint: "responses",
|
|
}).model("mai-code-1-flash-picker").route.id,
|
|
).toBe("openai-responses")
|
|
expect(
|
|
GitHubCopilot.configure({
|
|
baseURL: "https://api.githubcopilot.test",
|
|
apiKey: "fixture",
|
|
endpoint: "chat",
|
|
}).model("gpt-5").route.id,
|
|
).toBe("openai-chat")
|
|
})
|
|
|
|
test("protocol barrels expose supported low-level routes", () => {
|
|
expect(OpenAIChat.route.id).toBe("openai-chat")
|
|
expect(OpenAICompatibleChat.route.id).toBe("openai-compatible-chat")
|
|
expect(OpenAIResponses.route.id).toBe("openai-responses")
|
|
expect(OpenAIResponses.webSocketRoute.id).toBe("openai-responses-websocket")
|
|
expect(AnthropicMessages.route.id).toBe("anthropic-messages")
|
|
})
|
|
})
|