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

settings.ts

64 lines1.9 KB

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