Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import * as Schema from "effect/Schema";
import { ExecutionEnvironmentDescriptor } from "../environment.ts";
import { ServerAuthDescriptor } from "../auth.ts";
import { ForwardCompatibleArray, TrimmedNonEmptyString } from "../baseSchemas.ts";
import {
KeybindingCommand,
KeybindingValue,
KeybindingWhen,
ResolvedKeybindingsConfig,
} from "../keybindings.ts";
import { EditorId, FileManagerRevealKind, RemoteOpenTarget } from "../editor.ts";
import { ServerSettings } from "../settings/server.ts";
import { ServerConfigIssues, ServerProviders, ServerObservability } from "./providers.ts";
export const ServerConfig = Schema.Struct({
environment: ExecutionEnvironmentDescriptor,
auth: ServerAuthDescriptor,
cwd: TrimmedNonEmptyString,
keybindingsConfigPath: TrimmedNonEmptyString,
keybindings: ResolvedKeybindingsConfig,
issues: ServerConfigIssues,
providers: ServerProviders,
// Editor ids grow over time; drop ones this build does not know rather than
// failing the whole config decode.
availableEditors: ForwardCompatibleArray(EditorId),
/**
* SSH hosts this environment advertises for remote open-in-editor links.
* Absent on servers that predate the feature; empty when the machine has no
* sshd or no advertisable name.
*/
remoteOpenTargets: Schema.optionalKey(ForwardCompatibleArray(RemoteOpenTarget)),
observability: ServerObservability,
settings: ServerSettings,
/** Whether shell subscriptions can emit an opt-in catch-up completion marker. */
shellResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
/** Whether shell.openInEditor honors `LaunchEditorInput.reveal` for the
file-manager editor. */
shellRevealInFileManager: Schema.optionalKey(Schema.Boolean),
/** File-manager wording clients should use for reveal actions. */
shellRevealInFileManagerKind: Schema.optionalKey(FileManagerRevealKind),
/** Whether thread subscriptions can emit an opt-in catch-up completion marker. */
threadResumeCompletionMarker: Schema.optionalKey(Schema.Boolean),
/**
* Whether thread detail reads accept a turn window (`turnLimit`/
* `beforeCursor`) and return `page` metadata. Clients must not send window
* fields to servers that don't advertise this.
*/
threadSnapshotPagination: Schema.optionalKey(Schema.Boolean),
});
export type ServerConfig = typeof ServerConfig.Type;
const ServerUpsertKeybindingReplaceTarget = Schema.Struct({
key: KeybindingValue,
command: KeybindingCommand,
when: Schema.optional(KeybindingWhen),
});
export const ServerUpsertKeybindingInput = Schema.Struct({
key: KeybindingValue,
command: KeybindingCommand,
when: Schema.optional(KeybindingWhen),
replace: Schema.optional(ServerUpsertKeybindingReplaceTarget),
});
export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
export const ServerRemoveKeybindingInput = ServerUpsertKeybindingReplaceTarget;
export type ServerRemoveKeybindingInput = typeof ServerRemoveKeybindingInput.Type;
export const ServerUpsertKeybindingResult = Schema.Struct({
keybindings: ResolvedKeybindingsConfig,
issues: ServerConfigIssues,
});
export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.Type;
export const ServerRemoveKeybindingResult = ServerUpsertKeybindingResult;
export type ServerRemoveKeybindingResult = typeof ServerRemoveKeybindingResult.Type;
export const ServerConfigUpdatedPayload = Schema.Struct({
issues: ServerConfigIssues,
providers: ServerProviders,
settings: Schema.optional(ServerSettings),
});
export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;
export const ServerConfigKeybindingsUpdatedPayload = Schema.Struct({
keybindings: ResolvedKeybindingsConfig,
issues: ServerConfigIssues,
});
export type ServerConfigKeybindingsUpdatedPayload =
typeof ServerConfigKeybindingsUpdatedPayload.Type;
export const ServerConfigProviderStatusesPayload = Schema.Struct({
providers: ServerProviders,
});
export type ServerConfigProviderStatusesPayload = typeof ServerConfigProviderStatusesPayload.Type;
export const ServerConfigSettingsUpdatedPayload = Schema.Struct({
settings: ServerSettings,
});
export type ServerConfigSettingsUpdatedPayload = typeof ServerConfigSettingsUpdatedPayload.Type;
export const ServerConfigStreamSnapshotEvent = Schema.Struct({
version: Schema.Literal(1),
type: Schema.Literal("snapshot"),
config: ServerConfig,
});
export type ServerConfigStreamSnapshotEvent = typeof ServerConfigStreamSnapshotEvent.Type;
export const ServerConfigStreamKeybindingsUpdatedEvent = Schema.Struct({
version: Schema.Literal(1),
type: Schema.Literal("keybindingsUpdated"),
payload: ServerConfigKeybindingsUpdatedPayload,
});
export type ServerConfigStreamKeybindingsUpdatedEvent =
typeof ServerConfigStreamKeybindingsUpdatedEvent.Type;
export const ServerConfigStreamProviderStatusesEvent = Schema.Struct({
version: Schema.Literal(1),
type: Schema.Literal("providerStatuses"),
payload: ServerConfigProviderStatusesPayload,
});
export type ServerConfigStreamProviderStatusesEvent =
typeof ServerConfigStreamProviderStatusesEvent.Type;
export const ServerConfigStreamSettingsUpdatedEvent = Schema.Struct({
version: Schema.Literal(1),
type: Schema.Literal("settingsUpdated"),
payload: ServerConfigSettingsUpdatedPayload,
});
export type ServerConfigStreamSettingsUpdatedEvent =
typeof ServerConfigStreamSettingsUpdatedEvent.Type;
export const ServerConfigStreamEvent = Schema.Union([
ServerConfigStreamSnapshotEvent,
ServerConfigStreamKeybindingsUpdatedEvent,
ServerConfigStreamProviderStatusesEvent,
ServerConfigStreamSettingsUpdatedEvent,
]);
export type ServerConfigStreamEvent = typeof ServerConfigStreamEvent.Type;