19 lines
806 B
TypeScript
19 lines
806 B
TypeScript
import { Effect } from "effect"
|
|
import { define } from "@opencode-ai/plugin/v2/effect/plugin"
|
|
import { ProviderV2 } from "../../provider"
|
|
|
|
export const KiloPlugin = define({
|
|
id: "opencode.provider.kilo",
|
|
effect: Effect.fn(function* (ctx) {
|
|
yield* ctx.catalog.transform((evt) => {
|
|
for (const item of evt.provider.list()) {
|
|
if (!ProviderV2.isAISDK(item.provider.package)) continue
|
|
if (ProviderV2.packageName(item.provider.package) !== "@ai-sdk/openai-compatible") continue
|
|
if (item.provider.settings?.baseURL !== "https://api.kilo.ai/api/gateway") continue
|
|
evt.provider.update(item.provider.id, (provider) => {
|
|
provider.headers = { ...provider.headers, "HTTP-Referer": "https://opencode.ai/", "X-Title": "opencode" }
|
|
})
|
|
}
|
|
})
|
|
}),
|
|
})
|