diff --git a/packages/core/src/plugin/provider/azure.ts b/packages/core/src/plugin/provider/azure.ts
index 989689f13ca..a80500beee9 100644
--- a/packages/core/src/plugin/provider/azure.ts
+++ b/packages/core/src/plugin/provider/azure.ts
@@ -1,6 +1,9 @@
import { Effect } from "effect"
import { define } from "@opencode-ai/plugin/effect/plugin"
+import type { Form } from "@opencode-ai/schema/form"
import { Provider } from "../../provider"
+import type { DeepMutable } from "../../schema"
+import { iife } from "../../util/iife"
import { configuredSettings } from "./configured"
function selectLanguage(sdk: any, modelID: string, useChat: boolean) {
@@ -15,24 +18,25 @@ export const AzurePlugin = define({
id: "opencode.provider.azure",
effect: Effect.fn(function* (ctx) {
const configured = yield* configuredSettings(Provider.ID.azure)
+ const forms = iife((): DeepMutable
| undefined => {
+ if (resolveResourceName(configured) || typeof configured?.baseURL === "string") return
+ return [
+ {
+ type: "string",
+ key: "resourceName",
+ title: "Enter Azure Resource Name",
+ placeholder: "e.g. my-models",
+ required: true,
+ },
+ ]
+ })
yield* ctx.integration.transform((draft) => {
draft.method.update({
integrationID: Provider.ID.azure,
method: {
type: "key",
label: "API key",
- forms:
- resolveResourceName(configured) || typeof configured?.baseURL === "string"
- ? undefined
- : [
- {
- type: "string",
- key: "resourceName",
- title: "Enter Azure Resource Name",
- placeholder: "e.g. my-models",
- required: true,
- },
- ],
+ forms,
},
})
})
diff --git a/packages/core/src/plugin/provider/cloudflare-ai-gateway.ts b/packages/core/src/plugin/provider/cloudflare-ai-gateway.ts
index 63fef1a1795..daa1a46589e 100644
--- a/packages/core/src/plugin/provider/cloudflare-ai-gateway.ts
+++ b/packages/core/src/plugin/provider/cloudflare-ai-gateway.ts
@@ -2,7 +2,10 @@ import os from "os"
import { App } from "../../app"
import { Effect, Option, Schema } from "effect"
import { define } from "@opencode-ai/plugin/effect/plugin"
+import type { Form } from "@opencode-ai/schema/form"
import { Provider } from "../../provider"
+import type { DeepMutable } from "../../schema"
+import { iife } from "../../util/iife"
import { configuredSettings } from "./configured"
const providerID = Provider.ID.make("cloudflare-ai-gateway")
@@ -11,44 +14,39 @@ export const CloudflareAIGatewayPlugin = define({
id: "opencode.provider.cloudflare-ai-gateway",
effect: Effect.fn(function* (ctx) {
const configured = yield* configuredSettings(providerID)
- const hasBaseURL = typeof configured?.baseURL === "string"
- yield* ctx.integration.transform((draft) => {
- const hasAccountId =
- hasBaseURL || Boolean(process.env.CLOUDFLARE_ACCOUNT_ID || stringOption(configured ?? {}, "accountId"))
- const hasGatewayId =
- hasBaseURL ||
- Boolean(
- process.env.CLOUDFLARE_GATEWAY_ID ||
- stringOption(configured ?? {}, "gatewayId") ||
- stringOption(configured ?? {}, "gateway"),
- )
+ const forms = iife((): DeepMutable | undefined => {
+ if (typeof configured?.baseURL === "string") return
+ const accountId = process.env.CLOUDFLARE_ACCOUNT_ID || stringOption(configured ?? {}, "accountId")
+ const gatewayId =
+ process.env.CLOUDFLARE_GATEWAY_ID ||
+ stringOption(configured ?? {}, "gatewayId") ||
+ stringOption(configured ?? {}, "gateway")
+ if (accountId && gatewayId) return
const accountIdForm = {
- type: "string" as const,
+ type: "string",
key: "accountId",
title: "Enter your Cloudflare Account ID",
placeholder: "e.g. 1234567890abcdef1234567890abcdef",
required: true,
- }
+ } satisfies DeepMutable
const gatewayIdForm = {
- type: "string" as const,
+ type: "string",
key: "gatewayId",
title: "Enter your Cloudflare AI Gateway ID",
placeholder: "e.g. my-gateway",
required: true,
- }
+ } satisfies DeepMutable
+ if (accountId) return [gatewayIdForm]
+ if (gatewayId) return [accountIdForm]
+ return [accountIdForm, gatewayIdForm]
+ })
+ yield* ctx.integration.transform((draft) => {
draft.method.update({
integrationID: providerID,
method: {
type: "key",
label: "Gateway API token",
- forms:
- !hasAccountId && !hasGatewayId
- ? [accountIdForm, gatewayIdForm]
- : !hasAccountId
- ? [accountIdForm]
- : !hasGatewayId
- ? [gatewayIdForm]
- : undefined,
+ forms,
},
})
})
diff --git a/packages/core/src/plugin/provider/cloudflare-workers-ai.ts b/packages/core/src/plugin/provider/cloudflare-workers-ai.ts
index d12768cf3ef..78b54a5ba11 100644
--- a/packages/core/src/plugin/provider/cloudflare-workers-ai.ts
+++ b/packages/core/src/plugin/provider/cloudflare-workers-ai.ts
@@ -2,7 +2,10 @@ import os from "os"
import { App } from "../../app"
import { Effect } from "effect"
import { define } from "@opencode-ai/plugin/effect/plugin"
+import type { Form } from "@opencode-ai/schema/form"
import { Provider } from "../../provider"
+import type { DeepMutable } from "../../schema"
+import { iife } from "../../util/iife"
import { configuredSettings } from "./configured"
const providerID = Provider.ID.make("cloudflare-workers-ai")
@@ -11,24 +14,25 @@ export const CloudflareWorkersAIPlugin = define({
id: "opencode.provider.cloudflare-workers-ai",
effect: Effect.fn(function* (ctx) {
const configured = yield* configuredSettings(providerID)
+ const forms = iife((): DeepMutable | undefined => {
+ if (typeof configured?.baseURL === "string" || resolveAccountId(configured ?? {})) return
+ return [
+ {
+ type: "string",
+ key: "accountId",
+ title: "Enter your Cloudflare Account ID",
+ placeholder: "e.g. 1234567890abcdef1234567890abcdef",
+ required: true,
+ },
+ ]
+ })
yield* ctx.integration.transform((draft) => {
draft.method.update({
integrationID: providerID,
method: {
type: "key",
label: "API key",
- forms:
- typeof configured?.baseURL === "string" || resolveAccountId(configured ?? {})
- ? undefined
- : [
- {
- type: "string",
- key: "accountId",
- title: "Enter your Cloudflare Account ID",
- placeholder: "e.g. 1234567890abcdef1234567890abcdef",
- required: true,
- },
- ],
+ forms,
},
})
})