Open History to see the last commit
1/**
2 * Shared by the server driver and the client settings form, so it holds only
3 * browser-safe schema code.
4 */
5import {
6 CustomModelSetting,
7 makeBinaryPathSetting,
8 makeProviderSettingsSchema,
9 TrimmedString,
10} from "@t3tools/contracts";
11import * as Effect from "effect/Effect";
12import * as Schema from "effect/Schema";
13
14export const OpenCodeSettings = makeProviderSettingsSchema(
15 {
16 enabled: Schema.Boolean.pipe(
17 Schema.withDecodingDefault(Effect.succeed(false)),
18 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
19 ),
20 binaryPath: makeBinaryPathSetting("opencode").pipe(
21 Schema.annotateKey({
22 title: "Binary path",
23 description: "Path to the OpenCode binary.",
24 providerSettingsForm: {
25 placeholder: "opencode",
26 clearWhenEmpty: "omit",
27 },
28 }),
29 ),
30 serverUrl: TrimmedString.pipe(
31 Schema.withDecodingDefault(Effect.succeed("")),
32 Schema.annotateKey({
33 title: "Server URL",
34 description: "Leave blank to let T3 Code spawn the server when needed.",
35 providerSettingsForm: {
36 placeholder: "http://127.0.0.1:4096",
37 clearWhenEmpty: "omit",
38 },
39 }),
40 ),
41 serverPassword: TrimmedString.pipe(
42 Schema.withDecodingDefault(Effect.succeed("")),
43 Schema.annotateKey({
44 title: "Server password",
45 description: "Stored in plain text on disk.",
46 providerSettingsForm: {
47 control: "password",
48 placeholder: "Optional",
49 clearWhenEmpty: "omit",
50 },
51 }),
52 ),
53 customModels: Schema.Array(CustomModelSetting).pipe(
54 Schema.withDecodingDefault(Effect.succeed([])),
55 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
56 ),
57 },
58 {
59 order: ["binaryPath", "serverUrl", "serverPassword"],
60 },
61);
62export type OpenCodeSettings = typeof OpenCodeSettings.Type;