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

server.ts

93 lines3.3 KB

1import { Schema } from "effect";
2import { IsoDateTime, TrimmedNonEmptyString } from "./baseSchemas";
3import { KeybindingRule, ResolvedKeybindingsConfig } from "./keybindings";
4import { EditorId } from "./editor";
5import { ProviderKind } from "./orchestration";
6​
7const KeybindingsMalformedConfigIssue = Schema.Struct({
8 kind: Schema.Literal("keybindings.malformed-config"),
9 message: TrimmedNonEmptyString,
10});
11​
12const KeybindingsInvalidEntryIssue = Schema.Struct({
13 kind: Schema.Literal("keybindings.invalid-entry"),
14 message: TrimmedNonEmptyString,
15 index: Schema.Number,
16});
17​
18export const ServerConfigIssue = Schema.Union([
19 KeybindingsMalformedConfigIssue,
20 KeybindingsInvalidEntryIssue,
21]);
22export type ServerConfigIssue = typeof ServerConfigIssue.Type;
23​
24const ServerConfigIssues = Schema.Array(ServerConfigIssue);
25​
26export const ServerProviderStatusState = Schema.Literals(["ready", "warning", "error"]);
27export type ServerProviderStatusState = typeof ServerProviderStatusState.Type;
28​
29export const ServerProviderAuthStatus = Schema.Literals([
30 "authenticated",
31 "unauthenticated",
32 "unknown",
33]);
34export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type;
35​
36const ServerProviderCapabilityState = Schema.Literals([
37 "available",
38 "unsupported",
39 "misconfigured",
40]);
41export type ServerProviderCapabilityState = typeof ServerProviderCapabilityState.Type;
42​
43const ServerProviderCapability = Schema.Struct({
44 state: ServerProviderCapabilityState,
45 minimumVersion: Schema.optional(TrimmedNonEmptyString),
46 requiresExperimentalFlag: Schema.optional(Schema.Boolean),
47 message: Schema.optional(TrimmedNonEmptyString),
48});
49export type ServerProviderCapability = typeof ServerProviderCapability.Type;
50​
51const ServerProviderCapabilities = Schema.Struct({
52 agentTeams: Schema.optional(ServerProviderCapability),
53});
54export type ServerProviderCapabilities = typeof ServerProviderCapabilities.Type;
55​
56export const ServerProviderStatus = Schema.Struct({
57 provider: ProviderKind,
58 status: ServerProviderStatusState,
59 available: Schema.Boolean,
60 authStatus: ServerProviderAuthStatus,
61 checkedAt: IsoDateTime,
62 version: Schema.optional(TrimmedNonEmptyString),
63 message: Schema.optional(TrimmedNonEmptyString),
64 capabilities: Schema.optional(ServerProviderCapabilities),
65});
66export type ServerProviderStatus = typeof ServerProviderStatus.Type;
67​
68const ServerProviderStatuses = Schema.Array(ServerProviderStatus);
69​
70export const ServerConfig = Schema.Struct({
71 cwd: TrimmedNonEmptyString,
72 keybindingsConfigPath: TrimmedNonEmptyString,
73 keybindings: ResolvedKeybindingsConfig,
74 issues: ServerConfigIssues,
75 providers: ServerProviderStatuses,
76 availableEditors: Schema.Array(EditorId),
77});
78export type ServerConfig = typeof ServerConfig.Type;
79​
80export const ServerUpsertKeybindingInput = KeybindingRule;
81export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
82​
83export const ServerUpsertKeybindingResult = Schema.Struct({
84 keybindings: ResolvedKeybindingsConfig,
85 issues: ServerConfigIssues,
86});
87export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.Type;
88​
89export const ServerConfigUpdatedPayload = Schema.Struct({
90 issues: ServerConfigIssues,
91 providers: ServerProviderStatuses,
92});
93export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;