diff --git a/packages/core/src/plugin/provider/cloudflare-workers-ai.ts b/packages/core/src/plugin/provider/cloudflare-workers-ai.ts index c66d0b9270b..668584df7eb 100644 --- a/packages/core/src/plugin/provider/cloudflare-workers-ai.ts +++ b/packages/core/src/plugin/provider/cloudflare-workers-ai.ts @@ -2,7 +2,6 @@ import { Effect } from "effect" import { define } from "@opencode/plugin/effect/plugin" import { Form } from "@opencode/schema/form" import { Provider } from "../../provider.js" -import { iife } from "../../util/iife.js" import { configuredSettings } from "./configured.js" const providerID = Provider.ID.make("cloudflare-workers-ai") @@ -11,18 +10,18 @@ export const CloudflareWorkersAIPlugin = define({ id: "opencode.provider.cloudflare.workers.ai", effect: Effect.fn(function* (ctx) { const configured = yield* configuredSettings(providerID) - const form = iife(() => { - if (typeof configured?.baseURL === "string" || resolveAccountId(configured ?? {})) return - return Form.Fields.make([ - { - type: "string", - key: "accountId", - title: "Enter your Cloudflare Account ID", - placeholder: "e.g. 1234567890abcdef1234567890abcdef", - required: true, - }, - ]) - }) + const form = + typeof configured?.baseURL === "string" || resolveAccountId(configured ?? {}) + ? undefined + : Form.Fields.make([ + { + type: "string", + key: "accountId", + title: "Enter your Cloudflare Account ID", + placeholder: "e.g. 1234567890abcdef1234567890abcdef", + required: true, + }, + ]) yield* ctx.integration.transform((editor) => { editor.method.update({ integrationID: providerID, diff --git a/packages/core/src/util/error.ts b/packages/core/src/util/error.ts deleted file mode 100644 index 574bc82953f..00000000000 --- a/packages/core/src/util/error.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Schema } from "effect" - -export abstract class NamedError extends Error { - abstract schema(): Schema.Top - abstract toObject(): { name: string; data: unknown } - - static hasName(error: unknown, name: string): boolean { - return typeof error === "object" && error !== null && "name" in error && error.name === name - } - - static create( - name: Name, - fields: Fields, - ): ReturnType>> - static create( - name: Name, - data: DataSchema, - ): ReturnType> - static create(name: Name, data: Schema.Top | Schema.Struct.Fields) { - return NamedError.createSchemaClass(name, Schema.isSchema(data) ? data : Schema.Struct(data)) - } - - public static createSchemaClass(name: Name, data: DataSchema) { - const schema = Schema.Struct({ - name: Schema.Literal(name), - data, - }).annotate({ identifier: name }) - type Data = Schema.Schema.Type - - const result = class extends NamedError { - public static readonly Schema = schema - public static readonly EffectSchema = schema - public static readonly tag = name - - public override readonly name = name - - constructor( - public readonly data: Data, - options?: ErrorOptions, - ) { - super(name, options) - this.name = name - } - - static isInstance(input: unknown): input is InstanceType { - return NamedError.hasName(input, name) - } - - schema() { - return schema - } - - toObject() { - return { - name: name, - data: this.data, - } - } - } - Object.defineProperty(result, "name", { value: name }) - return result - } - - public static readonly Unknown = NamedError.create("UnknownError", { - message: Schema.String, - ref: Schema.optional(Schema.String), - }) -} diff --git a/packages/core/src/util/iife.ts b/packages/core/src/util/iife.ts deleted file mode 100644 index ca9ae6c10b4..00000000000 --- a/packages/core/src/util/iife.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function iife(fn: () => T) { - return fn() -} diff --git a/packages/core/src/v1/config/error.ts b/packages/core/src/v1/config/error.ts deleted file mode 100644 index 65c7bd3ae90..00000000000 --- a/packages/core/src/v1/config/error.ts +++ /dev/null @@ -1,18 +0,0 @@ -export * as ConfigErrorV1 from "./error.js" - -import { Schema } from "effect" -import { NamedError } from "../../util/error.js" - -const Issue = Schema.StructWithRest( - Schema.Struct({ - message: Schema.String, - path: Schema.Array(Schema.String), - }), - [Schema.Record(Schema.String, Schema.Unknown)], -) - -export const InvalidError = NamedError.create("ConfigInvalidError", { - path: Schema.String, - issues: Schema.optional(Schema.Array(Issue)), - message: Schema.optional(Schema.String), -})