desktopHostProtocol.ts 1.0 KB

123456789101112131415161718
  1. import { z } from 'zod'
  2. const text = z.string().min(1).max(4096).regex(/^[^\u0000-\u001f\u007f]*$/)
  3. export const desktopHostEnvironmentSchema = z.object({
  4. version: z.literal(1), osRelease: text, arch: text, shell: text,
  5. homeDirectory: text, defaultCwd: text, fileRoots: z.array(text).min(1).max(8),
  6. shellScope: z.literal('user'), timezone: text,
  7. }).strict()
  8. export const desktopHostInfoSchema = z.object({
  9. id: z.string().uuid(), name: z.string().max(128), platform: z.string().max(16),
  10. screen: z.boolean(), accessibility: z.boolean(), approved: z.array(z.string().regex(/^[a-f0-9]{64}$/)).max(100),
  11. full: z.array(z.string().regex(/^[a-f0-9]{64}$/)).max(100).optional(),
  12. fileTransferVersion: z.literal(1).optional(), environment: desktopHostEnvironmentSchema.optional(),
  13. }).strict()
  14. export const desktopHostExchangeSchema = z.object({
  15. host: desktopHostInfoSchema,
  16. results: z.array(z.object({ id: z.string().uuid(), value: z.unknown().optional(), error: z.string().max(500).optional() }).strict()).max(20),
  17. }).strict()