import { z } from "zod"; export const profileRoleSchema = z.enum(["companion", "operations", "general"]); export const authenticationTypeSchema = z.enum(["device-token", "api-key"]); export const transportKindSchema = z.enum(["desktop-v1", "astrbot-openapi"]); export const activeSlotKindSchema = z.enum(["companion", "operations"]); const optionalIdentifier = z.string().min(1).optional(); export const connectionProfileSchema = z .object({ id: z.uuid(), displayName: z.string().min(1).max(80), role: profileRoleSchema, baseUrl: z.url(), eventStreamUrl: z.url().optional(), authenticationType: authenticationTypeSchema, transportKind: transportKindSchema.default("desktop-v1"), credentialReference: optionalIdentifier, allowInsecureHttp: z.boolean(), pinnedCertificateFingerprint: z .string() .regex(/^[A-F0-9]{64}$/) .optional(), autoConnectSlot: activeSlotKindSchema.optional(), autoConnect: z.boolean(), serverInstanceId: optionalIdentifier, serverVersion: optionalIdentifier, protocolVersion: optionalIdentifier, localToolPolicyId: optionalIdentifier, lastConnectedAt: optionalIdentifier, remoteUsername: optionalIdentifier, stickySessionId: optionalIdentifier, createdAt: z.string().min(1), updatedAt: z.string().min(1), }) .strict(); export const connectionProfileListSchema = z.array(connectionProfileSchema); export type ProfileRole = z.infer; export type AuthenticationType = z.infer; export type TransportKind = z.infer; export type ConnectionProfile = z.infer; export type ActiveSlotKind = z.infer; export interface ConnectionProfileInput { displayName: string; role: ProfileRole; baseUrl: string; eventStreamUrl?: string; authenticationType: AuthenticationType; transportKind?: TransportKind; allowInsecureHttp: boolean; remoteUsername?: string; pinnedCertificateFingerprint?: string; autoConnect: boolean; autoConnectSlot?: ActiveSlotKind; } export interface UpdateConnectionProfileRequest { id: string; profile: ConnectionProfileInput; }