Something went wrong. Try again.
opencode v2 mirror
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import os from "os"import { App } from "../../app.js"import { Effect } from "effect"import { define } from "@opencode/plugin/effect/plugin"import { Provider } from "../../provider.js"
export const GitLabPlugin = define({ id: "opencode.provider.gitlab", effect: Effect.fn(function* (ctx) { yield* ctx.aisdk.hook( "sdk", Effect.fn(function* (evt) { if (evt.package !== "gitlab-ai-provider") return const mod = yield* Effect.promise(() => import("gitlab-ai-provider")) evt.sdk = mod.createGitLab({ ...evt.options, instanceUrl: typeof evt.options.instanceUrl === "string" ? evt.options.instanceUrl : (process.env.GITLAB_INSTANCE_URL ?? "https://gitlab.com"), apiKey: typeof evt.options.apiKey === "string" ? evt.options.apiKey : process.env.GITLAB_TOKEN, aiGatewayHeaders: { "User-Agent": `${App.useragent(ctx.app)} gitlab-ai-provider/${mod.VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`, "anthropic-beta": "context-1m-2025-08-07", ...evt.options.aiGatewayHeaders, }, featureFlags: { duo_agent_platform_agentic_chat: true, duo_agent_platform: true, ...evt.options.featureFlags, }, }) }), ) yield* ctx.aisdk.hook( "language", Effect.fn(function* (evt) { if (evt.model.providerID !== Provider.ID.gitlab) return const featureFlags = typeof evt.options.featureFlags === "object" && evt.options.featureFlags ? evt.options.featureFlags : {} const id = evt.model.modelID ?? evt.model.id if (id.startsWith("duo-workflow-")) { const gitlab = yield* Effect.promise(() => import("gitlab-ai-provider")) const workflowRef = typeof evt.model.settings?.workflowRef === "string" ? evt.model.settings.workflowRef : undefined const workflowDefinition = typeof evt.model.settings?.workflowDefinition === "string" ? evt.model.settings.workflowDefinition : undefined const language = evt.sdk.workflowChat(gitlab.isWorkflowModel(id) ? id : "duo-workflow", { featureFlags, workflowDefinition, }) if (workflowRef) language.selectedModelRef = workflowRef evt.language = language return } evt.language = evt.sdk.agenticChat(id, { aiGatewayHeaders: evt.options.aiGatewayHeaders, featureFlags, }) }), ) }),})