Files
t3code/packages/provider-opencode/src/settings.ts
T

67 lines
2.1 KiB
TypeScript

/**
* OpenCode instance settings. Shared by the server driver and the client
* settings form, so it holds only browser-safe schema code.
*
* @module provider-opencode/settings
*/
import {
CustomModelSetting,
makeBinaryPathSetting,
makeProviderSettingsSchema,
TrimmedString,
} from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
export const OpenCodeSettings = makeProviderSettingsSchema(
{
// Off by default (like Cursor and Grok): the binding is not yet stable
// enough to probe on every install. Users opt in from Settings.
enabled: Schema.Boolean.pipe(
Schema.withDecodingDefault(Effect.succeed(false)),
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
),
binaryPath: makeBinaryPathSetting("opencode").pipe(
Schema.annotateKey({
title: "Binary path",
description: "Path to the OpenCode binary.",
providerSettingsForm: {
placeholder: "opencode",
clearWhenEmpty: "omit",
},
}),
),
serverUrl: TrimmedString.pipe(
Schema.withDecodingDefault(Effect.succeed("")),
Schema.annotateKey({
title: "Server URL",
description: "Leave blank to let T3 Code spawn the server when needed.",
providerSettingsForm: {
placeholder: "http://127.0.0.1:4096",
clearWhenEmpty: "omit",
},
}),
),
serverPassword: TrimmedString.pipe(
Schema.withDecodingDefault(Effect.succeed("")),
Schema.annotateKey({
title: "Server password",
description: "Stored in plain text on disk.",
providerSettingsForm: {
control: "password",
placeholder: "Optional",
clearWhenEmpty: "omit",
},
}),
),
customModels: Schema.Array(CustomModelSetting).pipe(
Schema.withDecodingDefault(Effect.succeed([])),
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
),
},
{
order: ["binaryPath", "serverUrl", "serverPassword"],
},
);
export type OpenCodeSettings = typeof OpenCodeSettings.Type;