MCPcopy Index your code
hub / github.com/anomalyco/opencode / statusWithFetch

Function statusWithFetch

packages/opencode/src/session/llm/native-runtime.ts:50–72  ·  view source on GitHub ↗
(
  input: Pick<StreamInput, "model" | "provider" | "auth">,
  fetch: typeof globalThis.fetch | undefined,
)

Source from the content-addressed store, hash-verified

48}
49
50function statusWithFetch(
51 input: Pick<StreamInput, "model" | "provider" | "auth">,
52 fetch: typeof globalThis.fetch | undefined,
53): RuntimeStatus {
54 const providerID = input.model.providerID
55 if (providerID !== "openai" && providerID !== "anthropic" && !providerID.startsWith("opencode"))
56 return { type: "unsupported", reason: "provider is not openai, opencode, or anthropic" }
57 const npm = input.model.api.npm
58 if (npm !== "@ai-sdk/openai" && npm !== "@ai-sdk/openai-compatible" && npm !== "@ai-sdk/anthropic")
59 return { type: "unsupported", reason: "provider package is not OpenAI, OpenAI-compatible, or Anthropic" }
60 if (input.auth?.type === "oauth" && !(input.provider.id === "openai" && fetch)) {
61 return { type: "unsupported", reason: "OAuth auth requires a provider fetch override" }
62 }
63
64 const apiKey = typeof input.provider.options.apiKey === "string" ? input.provider.options.apiKey : input.provider.key
65 if (!apiKey) return { type: "unsupported", reason: "API key is not configured" }
66
67 return {
68 type: "supported",
69 apiKey,
70 baseURL: typeof input.provider.options.baseURL === "string" ? input.provider.options.baseURL : undefined,
71 }
72}
73
74export function stream(input: StreamInput): StreamResult {
75 const fetch = providerFetch(input)

Callers 2

statusFunction · 0.85
streamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected