Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

settings.ts

61 lines1.9 KB

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