- add startup ProviderHealth service/layer to probe Codex install and auth state - extend server contracts and WS payloads to include provider statuses - show non-ready provider warnings in ChatView and cover with server/web tests
76 lines
2.8 KiB
TypeScript
76 lines
2.8 KiB
TypeScript
import { Schema } from "effect";
|
|
import { IsoDateTime, TrimmedNonEmptyString } from "./baseSchemas";
|
|
import { KeybindingRule, ResolvedKeybindingsConfig } from "./keybindings";
|
|
import { EditorId } from "./editor";
|
|
import { ProviderKind } from "./orchestration";
|
|
|
|
export const KeybindingsMalformedConfigIssue = Schema.Struct({
|
|
kind: Schema.Literal("keybindings.malformed-config"),
|
|
message: TrimmedNonEmptyString,
|
|
});
|
|
export type KeybindingsMalformedConfigIssue = typeof KeybindingsMalformedConfigIssue.Type;
|
|
|
|
export const KeybindingsInvalidEntryIssue = Schema.Struct({
|
|
kind: Schema.Literal("keybindings.invalid-entry"),
|
|
message: TrimmedNonEmptyString,
|
|
index: Schema.Number,
|
|
});
|
|
export type KeybindingsInvalidEntryIssue = typeof KeybindingsInvalidEntryIssue.Type;
|
|
|
|
export const ServerConfigIssue = Schema.Union([
|
|
KeybindingsMalformedConfigIssue,
|
|
KeybindingsInvalidEntryIssue,
|
|
]);
|
|
export type ServerConfigIssue = typeof ServerConfigIssue.Type;
|
|
|
|
export const ServerConfigIssues = Schema.Array(ServerConfigIssue);
|
|
export type ServerConfigIssues = typeof ServerConfigIssues.Type;
|
|
|
|
export const ServerProviderStatusState = Schema.Literals(["ready", "warning", "error"]);
|
|
export type ServerProviderStatusState = typeof ServerProviderStatusState.Type;
|
|
|
|
export const ServerProviderAuthStatus = Schema.Literals([
|
|
"authenticated",
|
|
"unauthenticated",
|
|
"unknown",
|
|
]);
|
|
export type ServerProviderAuthStatus = typeof ServerProviderAuthStatus.Type;
|
|
|
|
export const ServerProviderStatus = Schema.Struct({
|
|
provider: ProviderKind,
|
|
status: ServerProviderStatusState,
|
|
available: Schema.Boolean,
|
|
authStatus: ServerProviderAuthStatus,
|
|
checkedAt: IsoDateTime,
|
|
message: Schema.optional(TrimmedNonEmptyString),
|
|
});
|
|
export type ServerProviderStatus = typeof ServerProviderStatus.Type;
|
|
|
|
export const ServerProviderStatuses = Schema.Array(ServerProviderStatus);
|
|
export type ServerProviderStatuses = typeof ServerProviderStatuses.Type;
|
|
|
|
export const ServerConfig = Schema.Struct({
|
|
cwd: TrimmedNonEmptyString,
|
|
keybindingsConfigPath: TrimmedNonEmptyString,
|
|
keybindings: ResolvedKeybindingsConfig,
|
|
issues: ServerConfigIssues,
|
|
providers: ServerProviderStatuses,
|
|
availableEditors: Schema.Array(EditorId),
|
|
});
|
|
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: ServerProviderStatuses,
|
|
});
|
|
export type ServerConfigUpdatedPayload = typeof ServerConfigUpdatedPayload.Type;
|