import { Effect, Schema } from "effect";import { ExecutionEnvironmentDescriptor } from "./environment.ts";import { ServerAuthDescriptor } from "./auth.ts";import { IsoDateTime, NonNegativeInt, ProjectId, ThreadId, TrimmedNonEmptyString,} from "./baseSchemas.ts";import { KeybindingRule, ResolvedKeybindingsConfig } from "./keybindings.ts";import { EditorId } from "./editor.ts";import { ModelCapabilities } from "./model.ts";import { ProviderKind } from "./orchestration.ts";import { ServerSettings } from "./settings.ts"; const KeybindingsMalformedConfigIssue = Schema.Struct({ kind: Schema.Literal("keybindings.malformed-config"), message: TrimmedNonEmptyString,}); const KeybindingsInvalidEntryIssue = Schema.Struct({ kind: Schema.Literal("keybindings.invalid-entry"), message: TrimmedNonEmptyString, index: Schema.Number,}); export const ServerConfigIssue = Schema.Union([ KeybindingsMalformedConfigIssue, KeybindingsInvalidEntryIssue,]);export type ServerConfigIssue = typeof ServerConfigIssue.Type; const ServerConfigIssues = Schema.Array(ServerConfigIssue); export const ServerProviderState = Schema.Literals(["ready", "warning", "error", "disabled"]);export type ServerProviderState = typeof ServerProviderState.Type; export const ServerProviderAuthStatus = Schema.Literals([ "authenticated", "unauthenticated", "unknown",]);export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type; export const ServerProviderAuth = Schema.Struct({ status: ServerProviderAuthStatus, type: Schema.optional(TrimmedNonEmptyString), label: Schema.optional(TrimmedNonEmptyString),});export type ServerProviderAuth = typeof ServerProviderAuth.Type; export const ServerProviderModel = Schema.Struct({ slug: TrimmedNonEmptyString, name: TrimmedNonEmptyString, shortName: Schema.optional(TrimmedNonEmptyString), subProvider: Schema.optional(TrimmedNonEmptyString), isCustom: Schema.Boolean, capabilities: Schema.NullOr(ModelCapabilities),});export type ServerProviderModel = typeof ServerProviderModel.Type; export const ServerProviderSlashCommandInput = Schema.Struct({ hint: TrimmedNonEmptyString,});export type ServerProviderSlashCommandInput = typeof ServerProviderSlashCommandInput.Type; export const ServerProviderSlashCommand = Schema.Struct({ name: TrimmedNonEmptyString, description: Schema.optional(TrimmedNonEmptyString), input: Schema.optional(ServerProviderSlashCommandInput),});export type ServerProviderSlashCommand = typeof ServerProviderSlashCommand.Type; export const ServerProviderSkill = Schema.Struct({ name: TrimmedNonEmptyString, description: Schema.optional(TrimmedNonEmptyString), path: TrimmedNonEmptyString, scope: Schema.optional(TrimmedNonEmptyString), enabled: Schema.Boolean, displayName: Schema.optional(TrimmedNonEmptyString), shortDescription: Schema.optional(TrimmedNonEmptyString),});export type ServerProviderSkill = typeof ServerProviderSkill.Type; export const ServerProvider = Schema.Struct({ provider: ProviderKind, displayName: Schema.optional(TrimmedNonEmptyString), badgeLabel: Schema.optional(TrimmedNonEmptyString), showInteractionModeToggle: Schema.optional(Schema.Boolean), enabled: Schema.Boolean, installed: Schema.Boolean, version: Schema.NullOr(TrimmedNonEmptyString), status: ServerProviderState, auth: ServerProviderAuth, checkedAt: IsoDateTime, message: Schema.optional(TrimmedNonEmptyString), models: Schema.Array(ServerProviderModel), slashCommands: Schema.Array(ServerProviderSlashCommand).pipe( Schema.withDecodingDefault(Effect.succeed([])), ), skills: Schema.Array(ServerProviderSkill).pipe(Schema.withDecodingDefault(Effect.succeed([]))),});export type ServerProvider = typeof ServerProvider.Type; export const ServerProviders = Schema.Array(ServerProvider);export type ServerProviders = typeof ServerProviders.Type; export const ServerObservability = Schema.Struct({ logsDirectoryPath: TrimmedNonEmptyString, localTracingEnabled: Schema.Boolean, otlpTracesUrl: Schema.optional(TrimmedNonEmptyString), otlpTracesEnabled: Schema.Boolean, otlpMetricsUrl: Schema.optional(TrimmedNonEmptyString), otlpMetricsEnabled: Schema.Boolean,});export type ServerObservability = typeof ServerObservability.Type; export const ServerConfig = Schema.Struct({ environment: ExecutionEnvironmentDescriptor, auth: ServerAuthDescriptor, cwd: TrimmedNonEmptyString, keybindingsConfigPath: TrimmedNonEmptyString, keybindings: ResolvedKeybindingsConfig, issues: ServerConfigIssues, providers: ServerProviders, availableEditors: Schema.Array(EditorId), observability: ServerObservability, settings: ServerSettings,});export type ServerConfig = typeof ServerConfig.Type; export const ServerUpsertKeybindingInput = KeybindingRule;export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type; export const ServerUpsertKeybindingResult = Schema.Struct({ keybindings: ResolvedKeybindingsConfig, issues: ServerConfigIssues,});export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.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({ 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; export const ServerLifecycleReadyPayload = Schema.Struct({ at: IsoDateTime, environment: ExecutionEnvironmentDescriptor,});export type ServerLifecycleReadyPayload = typeof ServerLifecycleReadyPayload.Type; export const ServerLifecycleWelcomePayload = Schema.Struct({ environment: ExecutionEnvironmentDescriptor, cwd: TrimmedNonEmptyString, projectName: TrimmedNonEmptyString, bootstrapProjectId: Schema.optional(ProjectId), bootstrapThreadId: Schema.optional(ThreadId),});export type ServerLifecycleWelcomePayload = typeof ServerLifecycleWelcomePayload.Type; export const ServerLifecycleStreamWelcomeEvent = Schema.Struct({ version: Schema.Literal(1), sequence: NonNegativeInt, type: Schema.Literal("welcome"), payload: ServerLifecycleWelcomePayload,});export type ServerLifecycleStreamWelcomeEvent = typeof ServerLifecycleStreamWelcomeEvent.Type; export const ServerLifecycleStreamReadyEvent = Schema.Struct({ version: Schema.Literal(1), sequence: NonNegativeInt, type: Schema.Literal("ready"), payload: ServerLifecycleReadyPayload,});export type ServerLifecycleStreamReadyEvent = typeof ServerLifecycleStreamReadyEvent.Type; export const ServerLifecycleStreamEvent = Schema.Union([ ServerLifecycleStreamWelcomeEvent, ServerLifecycleStreamReadyEvent,]);export type ServerLifecycleStreamEvent = typeof ServerLifecycleStreamEvent.Type; export const ServerProviderUpdatedPayload = Schema.Struct({ providers: ServerProviders,});export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.Type;
import { Effect, Schema } from "effect";
import { ExecutionEnvironmentDescriptor } from "./environment.ts";
import { ServerAuthDescriptor } from "./auth.ts";
import {
IsoDateTime,
NonNegativeInt,
ProjectId,
ThreadId,
TrimmedNonEmptyString,
} from "./baseSchemas.ts";
import { KeybindingRule, ResolvedKeybindingsConfig } from "./keybindings.ts";
import { EditorId } from "./editor.ts";
import { ModelCapabilities } from "./model.ts";
import { ProviderKind } from "./orchestration.ts";
import { ServerSettings } from "./settings.ts";
const KeybindingsMalformedConfigIssue = Schema.Struct({
kind: Schema.Literal("keybindings.malformed-config"),
message: TrimmedNonEmptyString,
});
const KeybindingsInvalidEntryIssue = Schema.Struct({
kind: Schema.Literal("keybindings.invalid-entry"),
message: TrimmedNonEmptyString,
index: Schema.Number,
});
export const ServerConfigIssue = Schema.Union([
KeybindingsMalformedConfigIssue,
KeybindingsInvalidEntryIssue,
]);
export type ServerConfigIssue = typeof ServerConfigIssue.Type;
const ServerConfigIssues = Schema.Array(ServerConfigIssue);
export const ServerProviderState = Schema.Literals(["ready", "warning", "error", "disabled"]);
export type ServerProviderState = typeof ServerProviderState.Type;
export const ServerProviderAuthStatus = Schema.Literals([
"authenticated",
"unauthenticated",
"unknown",
]);
export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type;
export const ServerProviderAuth = Schema.Struct({
status: ServerProviderAuthStatus,
type: Schema.optional(TrimmedNonEmptyString),
label: Schema.optional(TrimmedNonEmptyString),
});
export type ServerProviderAuth = typeof ServerProviderAuth.Type;
export const ServerProviderModel = Schema.Struct({
slug: TrimmedNonEmptyString,
name: TrimmedNonEmptyString,
shortName: Schema.optional(TrimmedNonEmptyString),
subProvider: Schema.optional(TrimmedNonEmptyString),
isCustom: Schema.Boolean,
capabilities: Schema.NullOr(ModelCapabilities),
});
export type ServerProviderModel = typeof ServerProviderModel.Type;
export const ServerProviderSlashCommandInput = Schema.Struct({
hint: TrimmedNonEmptyString,
});
export type ServerProviderSlashCommandInput = typeof ServerProviderSlashCommandInput.Type;
export const ServerProviderSlashCommand = Schema.Struct({
name: TrimmedNonEmptyString,
description: Schema.optional(TrimmedNonEmptyString),
input: Schema.optional(ServerProviderSlashCommandInput),
});
export type ServerProviderSlashCommand = typeof ServerProviderSlashCommand.Type;
export const ServerProviderSkill = Schema.Struct({
name: TrimmedNonEmptyString,
description: Schema.optional(TrimmedNonEmptyString),
path: TrimmedNonEmptyString,
scope: Schema.optional(TrimmedNonEmptyString),
enabled: Schema.Boolean,
displayName: Schema.optional(TrimmedNonEmptyString),
shortDescription: Schema.optional(TrimmedNonEmptyString),
});
export type ServerProviderSkill = typeof ServerProviderSkill.Type;
export const ServerProvider = Schema.Struct({
provider: ProviderKind,
displayName: Schema.optional(TrimmedNonEmptyString),
badgeLabel: Schema.optional(TrimmedNonEmptyString),
showInteractionModeToggle: Schema.optional(Schema.Boolean),
enabled: Schema.Boolean,
installed: Schema.Boolean,
version: Schema.NullOr(TrimmedNonEmptyString),
status: ServerProviderState,
auth: ServerProviderAuth,
checkedAt: IsoDateTime,
message: Schema.optional(TrimmedNonEmptyString),
models: Schema.Array(ServerProviderModel),
slashCommands: Schema.Array(ServerProviderSlashCommand).pipe(
Schema.withDecodingDefault(Effect.succeed([])),
),
skills: Schema.Array(ServerProviderSkill).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
});
export type ServerProvider = typeof ServerProvider.Type;
export const ServerProviders = Schema.Array(ServerProvider);
export type ServerProviders = typeof ServerProviders.Type;
export const ServerObservability = Schema.Struct({
logsDirectoryPath: TrimmedNonEmptyString,
localTracingEnabled: Schema.Boolean,
otlpTracesUrl: Schema.optional(TrimmedNonEmptyString),
otlpTracesEnabled: Schema.Boolean,
otlpMetricsUrl: Schema.optional(TrimmedNonEmptyString),
otlpMetricsEnabled: Schema.Boolean,
});
export type ServerObservability = typeof ServerObservability.Type;
export const ServerConfig = Schema.Struct({
environment: ExecutionEnvironmentDescriptor,
auth: ServerAuthDescriptor,
cwd: TrimmedNonEmptyString,
keybindingsConfigPath: TrimmedNonEmptyString,
keybindings: ResolvedKeybindingsConfig,
issues: ServerConfigIssues,
providers: ServerProviders,
availableEditors: Schema.Array(EditorId),
observability: ServerObservability,
settings: ServerSettings,
});
export type ServerConfig = typeof ServerConfig.Type;
export const ServerUpsertKeybindingInput = KeybindingRule;
export type ServerUpsertKeybindingInput = typeof ServerUpsertKeybindingInput.Type;
export const ServerUpsertKeybindingResult = Schema.Struct({
keybindings: ResolvedKeybindingsConfig,
issues: ServerConfigIssues,
});
export type ServerUpsertKeybindingResult = typeof ServerUpsertKeybindingResult.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({
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;
export const ServerLifecycleReadyPayload = Schema.Struct({
at: IsoDateTime,
environment: ExecutionEnvironmentDescriptor,
});
export type ServerLifecycleReadyPayload = typeof ServerLifecycleReadyPayload.Type;
export const ServerLifecycleWelcomePayload = Schema.Struct({
environment: ExecutionEnvironmentDescriptor,
cwd: TrimmedNonEmptyString,
projectName: TrimmedNonEmptyString,
bootstrapProjectId: Schema.optional(ProjectId),
bootstrapThreadId: Schema.optional(ThreadId),
});
export type ServerLifecycleWelcomePayload = typeof ServerLifecycleWelcomePayload.Type;
export const ServerLifecycleStreamWelcomeEvent = Schema.Struct({
version: Schema.Literal(1),
sequence: NonNegativeInt,
type: Schema.Literal("welcome"),
payload: ServerLifecycleWelcomePayload,
});
export type ServerLifecycleStreamWelcomeEvent = typeof ServerLifecycleStreamWelcomeEvent.Type;
export const ServerLifecycleStreamReadyEvent = Schema.Struct({
version: Schema.Literal(1),
sequence: NonNegativeInt,
type: Schema.Literal("ready"),
payload: ServerLifecycleReadyPayload,
});
export type ServerLifecycleStreamReadyEvent = typeof ServerLifecycleStreamReadyEvent.Type;
export const ServerLifecycleStreamEvent = Schema.Union([
ServerLifecycleStreamWelcomeEvent,
ServerLifecycleStreamReadyEvent,
]);
export type ServerLifecycleStreamEvent = typeof ServerLifecycleStreamEvent.Type;
export const ServerProviderUpdatedPayload = Schema.Struct({
providers: ServerProviders,
});
export type ServerProviderUpdatedPayload = typeof ServerProviderUpdatedPayload.Type;