import { t } from 'elysia'

const activitySegment = t.Object({
  id: t.String(),
  sessionId: t.String(),
  startedAt: t.String(),
  startedAtUnix: t.Number(),
  endedAt: t.String(),
  endedAtUnix: t.Number(),
  durationSeconds: t.Number(),
  segmentType: t.Union([
    t.Literal('work'),
    t.Literal('meeting'),
    t.Literal('browsing'),
    t.Literal('chat'),
    t.Literal('audio'),
    t.Literal('idle'),
    t.Literal('unknown'),
  ]),
  frontApp: t.Nullable(t.String()),
  title: t.Nullable(t.String()),
  summary: t.Nullable(t.String()),
  sourceCounts: t.Record(t.String(), t.Number()),
  sourceRefs: t.Record(t.String(), t.Array(t.String())),
  pipelineStatus: t.Union([
    t.Literal('collecting'),
    t.Literal('triaged'),
    t.Literal('summarized'),
    t.Literal('crystallized'),
    t.Literal('error'),
  ]),
  isCrystallized: t.Boolean(),
  metadata: t.Record(t.String(), t.Any()),
})

export const ChronicleModel = {
  config: t.Object({
    profileId: t.String(),
    modelId: t.String(),
    workspaceId: t.String(),
    enabled: t.Boolean(),
    activityPipelineEnabled: t.Boolean(),
    activityPipelineIntervalMs: t.Number(),
    activityPipelineBatchSize: t.Number(),
    dreamSchedulerEnabled: t.Optional(t.Boolean({ default: false })),
    dreamSchedulerIntervalMs: t.Optional(t.Number({ default: 86_400_000 })),
    dreamSchedulerApplyMerge: t.Optional(t.Boolean({ default: false })),
    audioCaptureEnabled: t.Boolean(),
    audioSource: t.Optional(t.Union([
      t.Literal('microphone'),
      t.Literal('system'),
      t.Literal('mixed'),
    ], { default: 'microphone' })),
    audioSegmentMs: t.Number(),
    audioSegmentIntervalMs: t.Number(),
    audioRmsThreshold: t.Number(),
    storageRoot: t.String(),
    privacySensitiveAppBundleIds: t.Optional(t.Array(t.String(), { default: [] })),
    privacySensitiveTitlePatterns: t.Optional(t.Array(t.String(), { default: [] })),
    privacySensitiveUrlPatterns: t.Optional(t.Array(t.String(), { default: [] })),
    closedEyesDiscardEnabled: t.Optional(t.Boolean({ default: false })),
    closedEyesMode: t.Optional(t.Union([
      t.Literal('auto'),
      t.Literal('always-record'),
      t.Literal('always-pause'),
    ], { default: 'auto' })),
  }),

  timelineEntry: t.Object({
    id: t.String(),
    sourceType: t.Optional(t.Union([t.Literal('snapshot'), t.Literal('message'), t.Literal('audio')])),
    capturedAt: t.String(),
    capturedAtUnix: t.Number(),
    displayId: t.Number(),
    segmentDir: t.String(),
    framePath: t.String(),
    ocrText: t.Nullable(t.String()),
    appBundleId: t.Nullable(t.String()),
    windowTitle: t.Nullable(t.String()),
    platform: t.Optional(t.Nullable(t.String())),
    channelId: t.Optional(t.Nullable(t.String())),
    channelName: t.Optional(t.Nullable(t.String())),
    userName: t.Optional(t.Nullable(t.String())),
  }),

  memoryEntry: t.Object({
    id: t.String(),
    type: t.Union([t.Literal('10min'), t.Literal('6h')]),
    source: t.Union([t.Literal('llm'), t.Literal('local'), t.Literal('imported')]),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
    content: t.String(),
    modelId: t.Nullable(t.String()),
    matchKind: t.Nullable(t.Union([t.Literal('keyword'), t.Literal('semantic'), t.Literal('hybrid')])),
    keywordScore: t.Nullable(t.Number()),
    semanticScore: t.Nullable(t.Number()),
  }),

  memoryUpdateBody: t.Object({
    content: t.Optional(t.String({ minLength: 1 })),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
    sourceSnapshotPaths: t.Optional(t.Array(t.String())),
    sourceFramePaths: t.Optional(t.Array(t.String())),
  }, { additionalProperties: false }),

  privacyEntity: t.Object({
    type: t.String(),
    start: t.Number(),
    end: t.Number(),
    text: t.String(),
  }),

  privacyRedactBody: t.Object({
    text: t.String(),
  }, { additionalProperties: false }),

  privacyRedactResponse: t.Object({
    text: t.String(),
    redactedText: t.String(),
    entityCount: t.Number(),
    entities: t.Array(t.Object({
      type: t.String(),
      start: t.Number(),
      end: t.Number(),
      text: t.String(),
    })),
  }),

  privacyExportBody: t.Object({
    workspaceId: t.Optional(t.Nullable(t.String())),
    limit: t.Optional(t.Number({ minimum: 1 })),
    includeMemories: t.Optional(t.Boolean()),
    includeMessages: t.Optional(t.Boolean()),
    includeAudioTranscripts: t.Optional(t.Boolean()),
    includeSnapshots: t.Optional(t.Boolean()),
    outputFormat: t.Optional(t.Union([t.Literal('markdown'), t.Literal('json')])),
  }, { additionalProperties: false }),

  privacyExportResponse: t.Object({
    format: t.Union([t.Literal('markdown'), t.Literal('json')]),
    content: t.String(),
    entityCount: t.Number(),
    sources: t.Array(t.Object({
      type: t.String(),
      id: t.String(),
      title: t.String(),
      redactedEntityCount: t.Number(),
    })),
  }),

  privacyFrameMaskBody: t.Object({
    mode: t.Optional(t.Union([t.Literal('blur')])),
    fullFrame: t.Optional(t.Boolean()),
    blurSigma: t.Optional(t.Number({ minimum: 1, maximum: 100 })),
    regions: t.Optional(t.Array(t.Object({
      x: t.Number({ minimum: 0 }),
      y: t.Number({ minimum: 0 }),
      width: t.Number({ minimum: 1 }),
      height: t.Number({ minimum: 1 }),
    }))),
  }, { additionalProperties: false }),

  privacyBreadcrumb: t.Object({
    id: t.String(),
    kind: t.String(),
    status: t.Union([t.Literal('info'), t.Literal('success'), t.Literal('warning'), t.Literal('error')]),
    message: t.String(),
    snapshotId: t.Nullable(t.String()),
    memoryId: t.Nullable(t.String()),
    attrs: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
  }),

  realtimeEvent: t.Object({
    id: t.String(),
    channel: t.Union([
      t.Literal('activity'),
      t.Literal('cron'),
      t.Literal('meeting'),
      t.Literal('memory'),
      t.Literal('notification'),
      t.Literal('error'),
      t.Literal('message'),
      t.Literal('audio'),
      t.Literal('snapshot'),
      t.Literal('model'),
    ]),
    event: t.String(),
    type: t.Union([
      t.Literal('config'),
      t.Literal('daemon'),
      t.Literal('snapshot'),
      t.Literal('memory'),
      t.Literal('summarize'),
      t.Literal('model-resource'),
      t.Literal('message'),
      t.Literal('audio'),
      t.Literal('activity'),
    ]),
    status: t.Union([t.Literal('info'), t.Literal('success'), t.Literal('warning'), t.Literal('error')]),
    message: t.String(),
    snapshotId: t.Nullable(t.String()),
    memoryId: t.Nullable(t.String()),
    attrs: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
  }),

  realtimeEventsQuery: t.Object({
    limit: t.Optional(t.Number({ default: 50, minimum: 1, maximum: 500 })),
    after: t.Optional(t.Number({ minimum: 0 })),
  }),

  realtimeEventsStreamQuery: t.Object({
    limit: t.Optional(t.Number({ default: 50, minimum: 1, maximum: 500 })),
    after: t.Optional(t.Number({ minimum: 0 })),
    intervalMs: t.Optional(t.Number({ default: 1000, minimum: 250, maximum: 30000 })),
    once: t.Optional(t.Boolean({ default: false })),
  }),

  embeddingRequestBody: t.Object({
    texts: t.Array(t.String({ minLength: 1 }), { minItems: 1, maxItems: 64 }),
  }),

  embeddingResponse: t.Object({
    modelId: t.String(),
    modelVersion: t.String(),
    dimensions: t.Number(),
    embeddings: t.Array(t.Array(t.Number())),
  }),

  modelResource: t.Object({
    id: t.String(),
    category: t.Union([
      t.Literal('ocr'),
      t.Literal('audio-vad'),
      t.Literal('audio-asr'),
      t.Literal('speaker'),
      t.Literal('embedding'),
      t.Literal('pii'),
    ]),
    status: t.Union([
      t.Literal('available'),
      t.Literal('missing'),
      t.Literal('installing'),
      t.Literal('installed'),
      t.Literal('error'),
    ]),
    displayName: t.String(),
    path: t.Nullable(t.String()),
    version: t.Nullable(t.String()),
    message: t.Nullable(t.String()),
    sizeBytes: t.Nullable(t.Number()),
    metadata: t.Record(t.String(), t.Any()),
    updatedAt: t.Number(),
  }),

  daemonResources: t.Object({
    running: t.Boolean(),
    pid: t.Nullable(t.Number()),
    rssMB: t.Nullable(t.Number()),
    cpuPercent: t.Nullable(t.Number()),
  }),

  modelResourceCategoryParams: t.Object({
    category: t.Union([
      t.Literal('ocr'),
      t.Literal('audio-vad'),
      t.Literal('audio-asr'),
      t.Literal('speaker'),
      t.Literal('embedding'),
      t.Literal('pii'),
    ]),
  }),

  modelResourceInstallBody: t.Object({
    source: t.Optional(t.Union([t.Literal('manifest'), t.Literal('local-files')])),
    sourceRoot: t.Optional(t.Nullable(t.String())),
    files: t.Optional(t.Array(t.Object({
      relativePath: t.String({ minLength: 1 }),
      sourcePath: t.String({ minLength: 1 }),
    }))),
  }),

  messageSource: t.Object({
    id: t.String(),
    platform: t.Literal('slack'),
    label: t.String(),
    enabled: t.Boolean(),
    workspaceId: t.Nullable(t.String()),
    teamId: t.Nullable(t.String()),
    botTokenRef: t.Nullable(t.String()),
    channelIds: t.Array(t.String()),
    realtimeMode: t.Union([
      t.Literal('polling'),
      t.Literal('events-api'),
      t.Literal('socket-mode'),
    ]),
    signingSecretRef: t.Nullable(t.String()),
    status: t.Union([
      t.Literal('idle'),
      t.Literal('syncing'),
      t.Literal('ready'),
      t.Literal('error'),
      t.Literal('disabled'),
    ]),
    lastSyncAt: t.Nullable(t.Number()),
    lastMessageAt: t.Nullable(t.Number()),
    lastError: t.Nullable(t.String()),
    createdAt: t.Number(),
    updatedAt: t.Number(),
  }),

  messageSourceBody: t.Object({
    platform: t.Literal('slack'),
    label: t.String({ minLength: 1 }),
    enabled: t.Boolean(),
    workspaceId: t.Optional(t.Nullable(t.String())),
    teamId: t.Optional(t.Nullable(t.String())),
    botTokenRef: t.Optional(t.Nullable(t.String())),
    channelIds: t.Array(t.String()),
    realtimeMode: t.Optional(t.Union([
      t.Literal('polling'),
      t.Literal('events-api'),
    ])),
    signingSecretRef: t.Optional(t.Nullable(t.String())),
  }),

  messageSourcePatchBody: t.Object({
    label: t.Optional(t.String({ minLength: 1 })),
    enabled: t.Optional(t.Boolean()),
    workspaceId: t.Optional(t.Nullable(t.String())),
    teamId: t.Optional(t.Nullable(t.String())),
    botTokenRef: t.Optional(t.Nullable(t.String())),
    channelIds: t.Optional(t.Array(t.String())),
    realtimeMode: t.Optional(t.Union([
      t.Literal('polling'),
      t.Literal('events-api'),
    ])),
    signingSecretRef: t.Optional(t.Nullable(t.String())),
  }),

  messageEntry: t.Object({
    id: t.String(),
    sourceId: t.String(),
    platform: t.Literal('slack'),
    channelId: t.String(),
    channelName: t.Nullable(t.String()),
    userName: t.Nullable(t.String()),
    text: t.String(),
    messageTs: t.String(),
    messageAt: t.String(),
    messageAtUnix: t.Number(),
    permalink: t.Nullable(t.String()),
  }),

  audioSegment: t.Object({
    id: t.String(),
    segmentIndex: t.Number(),
    startMs: t.Number(),
    endMs: t.Nullable(t.Number()),
    speakerLabel: t.Nullable(t.String()),
    text: t.String(),
    confidence: t.Nullable(t.Number()),
    language: t.Nullable(t.String()),
  }),

  audioTranscript: t.Object({
    id: t.String(),
    sourceId: t.String(),
    memoryId: t.Nullable(t.String()),
    title: t.Nullable(t.String()),
    source: t.Union([t.Literal('asr'), t.Literal('manual'), t.Literal('imported')]),
    status: t.Union([t.Literal('recording'), t.Literal('completed'), t.Literal('imported'), t.Literal('error')]),
    startedAt: t.String(),
    startedAtUnix: t.Number(),
    endedAt: t.Nullable(t.String()),
    endedAtUnix: t.Nullable(t.Number()),
    language: t.Nullable(t.String()),
    appBundleId: t.Nullable(t.String()),
    windowTitle: t.Nullable(t.String()),
    segmentCount: t.Number(),
    previewText: t.String(),
    segments: t.Array(t.Object({
      id: t.String(),
      segmentIndex: t.Number(),
      startMs: t.Number(),
      endMs: t.Nullable(t.Number()),
      speakerLabel: t.Nullable(t.String()),
      text: t.String(),
      confidence: t.Nullable(t.Number()),
      language: t.Nullable(t.String()),
    })),
  }),

  audioTranscriptSegmentBody: t.Object({
    startMs: t.Number({ minimum: 0 }),
    endMs: t.Optional(t.Nullable(t.Number({ minimum: 0 }))),
    speakerLabel: t.Optional(t.Nullable(t.String())),
    text: t.String({ minLength: 1 }),
    confidence: t.Optional(t.Nullable(t.Number({ minimum: 0, maximum: 1 }))),
    language: t.Optional(t.Nullable(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  audioTranscriptReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    title: t.Optional(t.Nullable(t.String())),
    source: t.Optional(t.Union([t.Literal('asr'), t.Literal('manual'), t.Literal('imported')])),
    status: t.Optional(t.Union([t.Literal('recording'), t.Literal('completed'), t.Literal('imported'), t.Literal('error')])),
    startedAt: t.String({ minLength: 1 }),
    endedAt: t.Optional(t.Nullable(t.String())),
    language: t.Optional(t.Nullable(t.String())),
    appBundleId: t.Optional(t.Nullable(t.String())),
    windowTitle: t.Optional(t.Nullable(t.String())),
    audioPath: t.Optional(t.Nullable(t.String())),
    transcriptPath: t.Optional(t.Nullable(t.String())),
    segments: t.Array(t.Object({
      startMs: t.Number({ minimum: 0 }),
      endMs: t.Optional(t.Nullable(t.Number({ minimum: 0 }))),
      speakerLabel: t.Optional(t.Nullable(t.String())),
      text: t.String({ minLength: 1 }),
      confidence: t.Optional(t.Nullable(t.Number({ minimum: 0, maximum: 1 }))),
      language: t.Optional(t.Nullable(t.String())),
      metadata: t.Optional(t.Record(t.String(), t.Any())),
    })),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  speakerProfile: t.Object({
    id: t.String(),
    workspaceId: t.Nullable(t.String()),
    displayName: t.String(),
    normalizedLabel: t.String(),
    aliases: t.Array(t.String()),
    embedding: t.Nullable(t.Array(t.Number())),
    embeddingDimensions: t.Nullable(t.Number()),
    embeddingModelId: t.Nullable(t.String()),
    sampleCount: t.Number(),
    lastSeenAt: t.Nullable(t.String()),
    lastSeenAtUnix: t.Nullable(t.Number()),
    sourceTranscriptId: t.Nullable(t.String()),
    sourceSegmentId: t.Nullable(t.String()),
    metadata: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
    updatedAt: t.String(),
    updatedAtUnix: t.Number(),
  }),

  speakerProfileBody: t.Object({
    displayName: t.String({ minLength: 1 }),
    aliases: t.Optional(t.Array(t.String())),
    embedding: t.Optional(t.Nullable(t.Array(t.Number()))),
    embeddingModelId: t.Optional(t.Nullable(t.String())),
    sampleCount: t.Optional(t.Number({ minimum: 0 })),
    lastSeenAt: t.Optional(t.Nullable(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  audioRawSegment: t.Object({
    id: t.String(),
    sourceId: t.String(),
    recordedAt: t.String(),
    recordedAtUnix: t.Number(),
    source: t.Union([t.Literal('microphone'), t.Literal('system'), t.Literal('mixed')]),
    status: t.Union([
      t.Literal('captured'),
      t.Literal('queued'),
      t.Literal('processed'),
      t.Literal('ignored'),
      t.Literal('error'),
    ]),
    audioPath: t.String(),
    metadataPath: t.String(),
    sampleRate: t.Number(),
    channels: t.Number(),
    sampleCount: t.Number(),
    droppedSamples: t.Number(),
    durationMs: t.Number(),
    rms: t.Number(),
    peak: t.Number(),
    active: t.Boolean(),
    vadStatus: t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')]),
    asrStatus: t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')]),
    speakerStatus: t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')]),
    metadata: t.Record(t.String(), t.Any()),
  }),

  audioRawSegmentProcessingResultBody: t.Object({
    status: t.Optional(t.Union([
      t.Literal('captured'),
      t.Literal('queued'),
      t.Literal('processed'),
      t.Literal('ignored'),
      t.Literal('error'),
    ])),
    vadStatus: t.Optional(t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')])),
    asrStatus: t.Optional(t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')])),
    speakerStatus: t.Optional(t.Union([t.Literal('not-implemented'), t.Literal('pending'), t.Literal('ready'), t.Literal('error')])),
    transcriptSourceId: t.Optional(t.Nullable(t.String())),
    speakerProfileIds: t.Optional(t.Array(t.String())),
    errorMessage: t.Optional(t.Nullable(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  activitySegment,

  activitySession: t.Object({
    id: t.String(),
    workspaceId: t.Nullable(t.String()),
    startedAt: t.String(),
    startedAtUnix: t.Number(),
    endedAt: t.Nullable(t.String()),
    endedAtUnix: t.Nullable(t.Number()),
    durationSeconds: t.Nullable(t.Number()),
    frontApp: t.Nullable(t.String()),
    title: t.Nullable(t.String()),
    segmentCount: t.Number(),
    snapshotCount: t.Number(),
    messageCount: t.Number(),
    audioTranscriptCount: t.Number(),
    audioRawSegmentCount: t.Number(),
    accessibilitySnapshotCount: t.Number(),
    isMeeting: t.Boolean(),
    meetingTitle: t.Nullable(t.String()),
    metadata: t.Record(t.String(), t.Any()),
  }),

  activitySessionDetail: t.Object({
    id: t.String(),
    workspaceId: t.Nullable(t.String()),
    startedAt: t.String(),
    startedAtUnix: t.Number(),
    endedAt: t.Nullable(t.String()),
    endedAtUnix: t.Nullable(t.Number()),
    durationSeconds: t.Nullable(t.Number()),
    frontApp: t.Nullable(t.String()),
    title: t.Nullable(t.String()),
    segmentCount: t.Number(),
    snapshotCount: t.Number(),
    messageCount: t.Number(),
    audioTranscriptCount: t.Number(),
    audioRawSegmentCount: t.Number(),
    accessibilitySnapshotCount: t.Number(),
    isMeeting: t.Boolean(),
    meetingTitle: t.Nullable(t.String()),
    metadata: t.Record(t.String(), t.Any()),
    segments: t.Array(activitySegment),
  }),

  activitySnapshot: t.Object({
    id: t.String(),
    sourceId: t.String(),
    workspaceId: t.Nullable(t.String()),
    capturedAt: t.String(),
    capturedAtUnix: t.Number(),
    displayId: t.Number(),
    segmentDir: t.String(),
    framePath: t.String(),
    artifactPath: t.Nullable(t.String()),
    ocrText: t.Nullable(t.String()),
    appBundleId: t.Nullable(t.String()),
    windowTitle: t.Nullable(t.String()),
    metadata: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
    updatedAt: t.String(),
    updatedAtUnix: t.Number(),
  }),

  activitySnapshotOcr: t.Object({
    snapshotId: t.String(),
    sourceId: t.String(),
    ocrText: t.Nullable(t.String()),
    ocrPath: t.Nullable(t.String()),
    capturedAt: t.String(),
    capturedAtUnix: t.Number(),
  }),

  activityMonitorStatus: t.Object({
    enabled: t.Boolean(),
    available: t.Boolean(),
    running: t.Boolean(),
    pid: t.Nullable(t.Number()),
    monitorStatus: t.Union([t.Literal('disabled'), t.Literal('running'), t.Literal('unavailable')]),
    captureStatus: t.Union([t.Literal('idle'), t.Literal('capturing'), t.Literal('error')]),
    pipelineStatus: t.Union([t.Literal('disabled'), t.Literal('running'), t.Literal('idle')]),
    audioStatus: t.Union([t.Literal('disabled'), t.Literal('armed'), t.Literal('unavailable')]),
    lastCaptureAt: t.Nullable(t.String()),
    lastCaptureAtUnix: t.Nullable(t.Number()),
    lastActivityAt: t.Nullable(t.String()),
    lastActivityAtUnix: t.Nullable(t.Number()),
    lastPipelineRunAt: t.Nullable(t.String()),
    lastPipelineRunAtUnix: t.Nullable(t.Number()),
    lastErrorAt: t.Nullable(t.String()),
    lastErrorAtUnix: t.Nullable(t.Number()),
    lastError: t.Nullable(t.String()),
    totals: t.Object({
      snapshots: t.Number(),
      activitySessions: t.Number(),
      activitySegments: t.Number(),
      pipelineRuns: t.Number(),
      accessibilitySnapshots: t.Number(),
      accessibilityEvents: t.Number(),
      audioTranscripts: t.Number(),
      audioRawSegments: t.Number(),
      memories: t.Number(),
      messages: t.Number(),
    }),
    config: t.Object({
      activityPipelineEnabled: t.Boolean(),
      activityPipelineIntervalMs: t.Number(),
      activityPipelineBatchSize: t.Number(),
      audioCaptureEnabled: t.Boolean(),
      audioSource: t.Union([t.Literal('microphone'), t.Literal('system'), t.Literal('mixed')]),
      closedEyesDiscardEnabled: t.Boolean(),
      closedEyesMode: t.Union([t.Literal('auto'), t.Literal('always-record'), t.Literal('always-pause')]),
    }),
  }),

  activityStorageStats: t.Object({
    storageRoot: t.String(),
    modelsRoot: t.String(),
    storage: t.Object({
      exists: t.Boolean(),
      fileCount: t.Number(),
      directoryCount: t.Number(),
      totalBytes: t.Number(),
    }),
    models: t.Object({
      exists: t.Boolean(),
      fileCount: t.Number(),
      directoryCount: t.Number(),
      totalBytes: t.Number(),
    }),
    database: t.Object({
      snapshots: t.Number(),
      activitySessions: t.Number(),
      activitySegments: t.Number(),
      memories: t.Number(),
      memoryChunks: t.Number(),
      knowledgeCards: t.Number(),
      pipelineRuns: t.Number(),
      dreamRuns: t.Number(),
      accessibilitySnapshots: t.Number(),
      accessibilityEvents: t.Number(),
      audioTranscripts: t.Number(),
      audioRawSegments: t.Number(),
      messages: t.Number(),
      modelResources: t.Number(),
    }),
  }),

  memoryStatus: t.Object({
    available: t.Boolean(),
    totalMemories: t.Number(),
    totalChunks: t.Number(),
    totalKeywords: t.Number(),
    totalEmbeddings: t.Number(),
    totalKnowledgeCards: t.Number(),
    totalKnowledgeVersions: t.Number(),
    totalActivitySegments: t.Number(),
    pendingActivitySegments: t.Number(),
    crystallizedActivitySegments: t.Number(),
    totalPipelineRuns: t.Number(),
    lastMemoryAt: t.Nullable(t.String()),
    lastMemoryAtUnix: t.Nullable(t.Number()),
    lastKnowledgeCardAt: t.Nullable(t.String()),
    lastKnowledgeCardAtUnix: t.Nullable(t.Number()),
    lastPipelineRunAt: t.Nullable(t.String()),
    lastPipelineRunAtUnix: t.Nullable(t.Number()),
    searchIndex: t.Object({
      chunkCount: t.Number(),
      keywordCount: t.Number(),
      embeddingCount: t.Number(),
      embeddingReadyCount: t.Number(),
      embeddingPendingCount: t.Number(),
      embeddingErrorCount: t.Number(),
    }),
    pipeline: t.Object({
      activityPipelineEnabled: t.Boolean(),
      activityPipelineRunning: t.Boolean(),
      dreamSchedulerEnabled: t.Boolean(),
      dreamSchedulerRunning: t.Boolean(),
    }),
  }),

  memoryCrystallizeBody: t.Object({
    segmentId: t.Optional(t.String({ minLength: 1 })),
  }, { additionalProperties: false }),

  memoryCrystallizeResponse: t.Object({
    status: t.Union([
      t.Literal('success'),
      t.Literal('error'),
      t.Literal('skipped'),
    ]),
    message: t.String(),
    segmentId: t.Nullable(t.String()),
    result: t.Nullable(t.Any()),
  }),

  pipelineRun: t.Object({
    id: t.String(),
    sessionId: t.Nullable(t.String()),
    segmentId: t.Nullable(t.String()),
    trigger: t.Union([
      t.Literal('snapshot'),
      t.Literal('message'),
      t.Literal('audio-raw'),
      t.Literal('audio-transcript'),
      t.Literal('memory'),
      t.Literal('manual'),
      t.Literal('summarize'),
    ]),
    stage: t.Union([
      t.Literal('collection'),
      t.Literal('segmentation'),
      t.Literal('triage'),
      t.Literal('summarization'),
      t.Literal('crystallization'),
    ]),
    status: t.Union([
      t.Literal('queued'),
      t.Literal('running'),
      t.Literal('success'),
      t.Literal('error'),
      t.Literal('skipped'),
    ]),
    startedAt: t.String(),
    startedAtUnix: t.Number(),
    endedAt: t.Nullable(t.String()),
    endedAtUnix: t.Nullable(t.Number()),
    errorMessage: t.Nullable(t.String()),
    snapshotsCount: t.Number(),
    messagesCount: t.Number(),
    audioTranscriptsCount: t.Number(),
    audioRawSegmentsCount: t.Number(),
    memoriesCount: t.Number(),
    segmentsCount: t.Number(),
    segmentIds: t.Array(t.String()),
    metadata: t.Record(t.String(), t.Any()),
  }),

  knowledgeCard: t.Object({
    id: t.String(),
    title: t.String(),
    content: t.String(),
    cardType: t.Union([
      t.Literal('fact'),
      t.Literal('insight'),
      t.Literal('decision'),
      t.Literal('task'),
      t.Literal('pattern'),
    ]),
    dimension: t.Union([
      t.Literal('technical'),
      t.Literal('business'),
      t.Literal('personal'),
      t.Literal('project'),
      t.Literal('general'),
    ]),
    confidence: t.Number(),
    sourceMemoryIds: t.Array(t.String()),
    sourceSegmentIds: t.Array(t.String()),
    sourceChunkIds: t.Array(t.String()),
    tags: t.Array(t.String()),
    contentHash: t.String(),
    version: t.Number(),
    status: t.Union([
      t.Literal('active'),
      t.Literal('merged'),
      t.Literal('archived'),
      t.Literal('deleted'),
    ]),
    mergedIntoId: t.Nullable(t.String()),
    pinned: t.Boolean(),
    metadata: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
    updatedAt: t.String(),
    updatedAtUnix: t.Number(),
  }),

  knowledgeVersion: t.Object({
    id: t.String(),
    knowledgeId: t.String(),
    version: t.Number(),
    title: t.String(),
    content: t.String(),
    cardType: t.Union([
      t.Literal('fact'),
      t.Literal('insight'),
      t.Literal('decision'),
      t.Literal('task'),
      t.Literal('pattern'),
    ]),
    dimension: t.Union([
      t.Literal('technical'),
      t.Literal('business'),
      t.Literal('personal'),
      t.Literal('project'),
      t.Literal('general'),
    ]),
    confidence: t.Number(),
    sourceMemoryIds: t.Array(t.String()),
    sourceSegmentIds: t.Array(t.String()),
    sourceChunkIds: t.Array(t.String()),
    tags: t.Array(t.String()),
    metadata: t.Record(t.String(), t.Any()),
    createdAt: t.String(),
    createdAtUnix: t.Number(),
  }),

  knowledgeFile: t.Object({
    id: t.String(),
    knowledgeId: t.String(),
    source: t.Union([
      t.Literal('attached'),
      t.Literal('memory'),
      t.Literal('snapshot'),
      t.Literal('activity'),
    ]),
    filename: t.String(),
    contentType: t.Nullable(t.String()),
    sizeBytes: t.Nullable(t.Number()),
    filePath: t.Nullable(t.String()),
    embedded: t.Boolean(),
    evidenceType: t.Nullable(t.String()),
    evidenceId: t.Nullable(t.String()),
    metadata: t.Record(t.String(), t.Any()),
    createdAt: t.Nullable(t.String()),
    createdAtUnix: t.Nullable(t.Number()),
    updatedAt: t.Nullable(t.String()),
    updatedAtUnix: t.Nullable(t.Number()),
  }),

  dreamRun: t.Object({
    id: t.String(),
    workspaceId: t.Nullable(t.String()),
    runType: t.Union([
      t.Literal('archive'),
      t.Literal('merge'),
      t.Literal('prune'),
      t.Literal('restore'),
      t.Literal('dry-run'),
    ]),
    status: t.Union([
      t.Literal('running'),
      t.Literal('completed'),
      t.Literal('failed'),
    ]),
    startedAt: t.String(),
    startedAtUnix: t.Number(),
    endedAt: t.Nullable(t.String()),
    endedAtUnix: t.Nullable(t.Number()),
    inputCount: t.Number(),
    outputCount: t.Number(),
    mergedCount: t.Number(),
    deletedCount: t.Number(),
    sourceKnowledgeIds: t.Array(t.String()),
    outputKnowledgeIds: t.Array(t.String()),
    config: t.Record(t.String(), t.Any()),
    result: t.Record(t.String(), t.Any()),
    errorMessage: t.Nullable(t.String()),
  }),

  knowledgeCardsQuery: t.Object({
    limit: t.Optional(t.Number({ default: 50 })),
    dimension: t.Optional(t.Union([
      t.Literal('technical'),
      t.Literal('business'),
      t.Literal('personal'),
      t.Literal('project'),
      t.Literal('general'),
    ])),
    type: t.Optional(t.Union([
      t.Literal('fact'),
      t.Literal('insight'),
      t.Literal('decision'),
      t.Literal('task'),
      t.Literal('pattern'),
    ])),
    includeDeleted: t.Optional(t.Boolean({ default: false })),
  }),

  knowledgeCardMutationBody: t.Object({
    title: t.String({ minLength: 1 }),
    content: t.String({ minLength: 1 }),
    cardType: t.Optional(t.Union([
      t.Literal('fact'),
      t.Literal('insight'),
      t.Literal('decision'),
      t.Literal('task'),
      t.Literal('pattern'),
    ])),
    dimension: t.Optional(t.Union([
      t.Literal('technical'),
      t.Literal('business'),
      t.Literal('personal'),
      t.Literal('project'),
      t.Literal('general'),
    ])),
    confidence: t.Optional(t.Number({ minimum: 0, maximum: 1 })),
    sourceMemoryIds: t.Optional(t.Array(t.String())),
    sourceSegmentIds: t.Optional(t.Array(t.String())),
    sourceChunkIds: t.Optional(t.Array(t.String())),
    tags: t.Optional(t.Array(t.String())),
    stableKey: t.Optional(t.String()),
    pinned: t.Optional(t.Boolean()),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }, { additionalProperties: false }),

  knowledgeCardPatchBody: t.Object({
    title: t.Optional(t.String({ minLength: 1 })),
    content: t.Optional(t.String({ minLength: 1 })),
    cardType: t.Optional(t.Union([
      t.Literal('fact'),
      t.Literal('insight'),
      t.Literal('decision'),
      t.Literal('task'),
      t.Literal('pattern'),
    ])),
    dimension: t.Optional(t.Union([
      t.Literal('technical'),
      t.Literal('business'),
      t.Literal('personal'),
      t.Literal('project'),
      t.Literal('general'),
    ])),
    confidence: t.Optional(t.Number({ minimum: 0, maximum: 1 })),
    sourceMemoryIds: t.Optional(t.Array(t.String())),
    sourceSegmentIds: t.Optional(t.Array(t.String())),
    sourceChunkIds: t.Optional(t.Array(t.String())),
    tags: t.Optional(t.Array(t.String())),
    pinned: t.Optional(t.Boolean()),
    status: t.Optional(t.Union([
      t.Literal('active'),
      t.Literal('merged'),
      t.Literal('archived'),
      t.Literal('deleted'),
    ])),
    mergedIntoId: t.Optional(t.Nullable(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }, { additionalProperties: false }),

  knowledgeVersionRestoreBody: t.Object({
    version: t.Number({ minimum: 1 }),
  }, { additionalProperties: false }),

  dreamStartBody: t.Object({
    runType: t.Optional(t.Union([
      t.Literal('archive'),
      t.Literal('merge'),
      t.Literal('prune'),
      t.Literal('restore'),
      t.Literal('dry-run'),
    ])),
    dryRun: t.Optional(t.Boolean()),
    limit: t.Optional(t.Number({ minimum: 2 })),
    similarityThreshold: t.Optional(t.Number({ minimum: 0.1, maximum: 1 })),
    applyMerge: t.Optional(t.Boolean()),
    olderThanDays: t.Optional(t.Number({ minimum: 0 })),
    knowledgeIds: t.Optional(t.Array(t.String())),
  }),

  activityPipelineTickResponse: t.Object({
    checked: t.Number(),
    triaged: t.Number(),
    summarized: t.Number(),
    crystallized: t.Number(),
    skipped: t.Number(),
    errors: t.Number(),
  }),

  activityPipelineAction: t.Object({
    segment: t.Object({
      id: t.String(),
      sessionId: t.String(),
      startedAt: t.String(),
      startedAtUnix: t.Number(),
      endedAt: t.String(),
      endedAtUnix: t.Number(),
      durationSeconds: t.Number(),
      segmentType: t.Union([
        t.Literal('work'),
        t.Literal('meeting'),
        t.Literal('browsing'),
        t.Literal('chat'),
        t.Literal('audio'),
        t.Literal('idle'),
        t.Literal('unknown'),
      ]),
      frontApp: t.Nullable(t.String()),
      title: t.Nullable(t.String()),
      summary: t.Nullable(t.String()),
      sourceCounts: t.Record(t.String(), t.Number()),
      sourceRefs: t.Record(t.String(), t.Array(t.String())),
      pipelineStatus: t.Union([
        t.Literal('collecting'),
        t.Literal('triaged'),
        t.Literal('summarized'),
        t.Literal('crystallized'),
        t.Literal('error'),
      ]),
      isCrystallized: t.Boolean(),
      metadata: t.Record(t.String(), t.Any()),
    }),
    run: t.Object({
      id: t.String(),
      sessionId: t.Nullable(t.String()),
      segmentId: t.Nullable(t.String()),
      trigger: t.Union([
        t.Literal('snapshot'),
        t.Literal('message'),
        t.Literal('audio-raw'),
        t.Literal('audio-transcript'),
        t.Literal('memory'),
        t.Literal('manual'),
        t.Literal('summarize'),
      ]),
      stage: t.Union([
        t.Literal('collection'),
        t.Literal('segmentation'),
        t.Literal('triage'),
        t.Literal('summarization'),
        t.Literal('crystallization'),
      ]),
      status: t.Union([
        t.Literal('queued'),
        t.Literal('running'),
        t.Literal('success'),
        t.Literal('error'),
        t.Literal('skipped'),
      ]),
      startedAt: t.String(),
      startedAtUnix: t.Number(),
      endedAt: t.Nullable(t.String()),
      endedAtUnix: t.Nullable(t.Number()),
      errorMessage: t.Nullable(t.String()),
      snapshotsCount: t.Number(),
      messagesCount: t.Number(),
      audioTranscriptsCount: t.Number(),
      audioRawSegmentsCount: t.Number(),
      memoriesCount: t.Number(),
      segmentsCount: t.Number(),
      segmentIds: t.Array(t.String()),
      metadata: t.Record(t.String(), t.Any()),
    }),
    memoryId: t.Nullable(t.String()),
    knowledgeCards: t.Optional(t.Array(t.Object({
      id: t.String(),
      title: t.String(),
      content: t.String(),
      cardType: t.Union([
        t.Literal('fact'),
        t.Literal('insight'),
        t.Literal('decision'),
        t.Literal('task'),
        t.Literal('pattern'),
      ]),
      dimension: t.Union([
        t.Literal('technical'),
        t.Literal('business'),
        t.Literal('personal'),
        t.Literal('project'),
        t.Literal('general'),
      ]),
      confidence: t.Number(),
      sourceMemoryIds: t.Array(t.String()),
      sourceSegmentIds: t.Array(t.String()),
      sourceChunkIds: t.Array(t.String()),
      tags: t.Array(t.String()),
      contentHash: t.String(),
      version: t.Number(),
      status: t.Union([
        t.Literal('active'),
        t.Literal('merged'),
        t.Literal('archived'),
        t.Literal('deleted'),
      ]),
      mergedIntoId: t.Nullable(t.String()),
      pinned: t.Boolean(),
      metadata: t.Record(t.String(), t.Any()),
      createdAt: t.String(),
      createdAtUnix: t.Number(),
      updatedAt: t.String(),
      updatedAtUnix: t.Number(),
    }))),
    status: t.Union([
      t.Literal('success'),
      t.Literal('error'),
      t.Literal('skipped'),
    ]),
    message: t.String(),
  }),

  audioRawSegmentReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    recordedAt: t.String({ minLength: 1 }),
    source: t.Optional(t.Union([t.Literal('microphone'), t.Literal('system'), t.Literal('mixed')])),
    status: t.Optional(t.Union([
      t.Literal('captured'),
      t.Literal('queued'),
      t.Literal('processed'),
      t.Literal('ignored'),
      t.Literal('error'),
    ])),
    audioPath: t.String({ minLength: 1 }),
    metadataPath: t.String({ minLength: 1 }),
    sampleRate: t.Number({ minimum: 1 }),
    channels: t.Number({ minimum: 1 }),
    sampleCount: t.Number({ minimum: 0 }),
    droppedSamples: t.Optional(t.Number({ minimum: 0 })),
    durationMs: t.Optional(t.Number({ minimum: 0 })),
    rms: t.Number({ minimum: 0, maximum: 1 }),
    peak: t.Number({ minimum: 0, maximum: 1 }),
    active: t.Boolean(),
    vadImplemented: t.Optional(t.Boolean()),
    asrImplemented: t.Optional(t.Boolean()),
    speakerLabelingImplemented: t.Optional(t.Boolean()),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  accessibilitySnapshot: t.Object({
    id: t.String(),
    sourceId: t.String(),
    snapshotId: t.Nullable(t.String()),
    capturedAt: t.String(),
    capturedAtUnix: t.Number(),
    status: t.Union([
      t.Literal('ready'),
      t.Literal('permission-denied'),
      t.Literal('unavailable'),
      t.Literal('error'),
    ]),
    provider: t.String(),
    appBundleId: t.Nullable(t.String()),
    windowTitle: t.Nullable(t.String()),
    elementCount: t.Number(),
    text: t.Nullable(t.String()),
    tree: t.Array(t.Any()),
    metadata: t.Record(t.String(), t.Any()),
  }),

  accessibilitySnapshotReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    status: t.Optional(t.Union([
      t.Literal('ready'),
      t.Literal('permission-denied'),
      t.Literal('unavailable'),
      t.Literal('error'),
    ])),
    provider: t.Optional(t.String()),
    accessibilityPath: t.Optional(t.Nullable(t.String())),
    text: t.Optional(t.Nullable(t.String())),
    elementCount: t.Optional(t.Number({ minimum: 0 })),
    appBundleId: t.Optional(t.Nullable(t.String())),
    windowTitle: t.Optional(t.Nullable(t.String())),
    tree: t.Optional(t.Array(t.Any())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  accessibilityEvent: t.Object({
    id: t.String(),
    sourceId: t.String(),
    snapshotId: t.Nullable(t.String()),
    accessibilitySnapshotId: t.Nullable(t.String()),
    capturedAt: t.String(),
    capturedAtUnix: t.Number(),
    provider: t.String(),
    appBundleId: t.Nullable(t.String()),
    pid: t.Nullable(t.Number()),
    notification: t.String(),
    droppedBefore: t.Number(),
    metadata: t.Record(t.String(), t.Any()),
  }),

  accessibilityEventReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    capturedAt: t.String({ minLength: 1 }),
    provider: t.Optional(t.String()),
    appBundleId: t.Optional(t.Nullable(t.String())),
    pid: t.Optional(t.Nullable(t.Number())),
    notification: t.String({ minLength: 1 }),
    droppedBefore: t.Optional(t.Number({ minimum: 0 })),
    snapshotId: t.Optional(t.Nullable(t.String())),
    accessibilitySnapshotId: t.Optional(t.Nullable(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  slackSyncResponse: t.Object({
    sourceId: t.String(),
    status: t.Union([t.Literal('success'), t.Literal('error')]),
    ingested: t.Number(),
    message: t.String(),
  }),

  slackEventsResponse: t.Object({
    sourceId: t.String(),
    status: t.Union([t.Literal('ok'), t.Literal('ignored')]),
    ingested: t.Number(),
    message: t.String(),
    challenge: t.Optional(t.String()),
  }),

  summarizeBody: t.Object({
    prompt: t.String({ minLength: 1 }),
    windowType: t.Union([t.Literal('10min'), t.Literal('6h')]),
    sourceSnapshotIds: t.Optional(t.Array(t.String())),
    sourceArtifactPaths: t.Optional(t.Array(t.String())),
  }),

  summarizeResponse: t.Object({
    summary: t.String(),
    memoryId: t.Nullable(t.String()),
    status: t.Union([t.Literal('success'), t.Literal('error')]),
  }),

  snapshotReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    displayId: t.Number(),
    frameIndex: t.Optional(t.Number()),
    capturedAt: t.String({ minLength: 1 }),
    segmentDir: t.String(),
    framePath: t.String(),
    capturePath: t.Optional(t.String()),
    ocrPath: t.Optional(t.String()),
    snapshotPath: t.Optional(t.String()),
    ocrText: t.Optional(t.String()),
    appBundleId: t.Optional(t.String()),
    windowTitle: t.Optional(t.String()),
    closedEyes: t.Optional(t.Object({
      status: t.Optional(t.Union([
        t.Literal('open'),
        t.Literal('closed'),
        t.Literal('absent'),
        t.Literal('unknown'),
      ])),
      confidence: t.Optional(t.Nullable(t.Number({ minimum: 0, maximum: 1 }))),
      detector: t.Optional(t.Nullable(t.String())),
      discard: t.Optional(t.Boolean()),
      reason: t.Optional(t.Nullable(t.String())),
      metadata: t.Optional(t.Record(t.String(), t.Any())),
    })),
    accessibility: t.Optional(t.Object({
      sourceId: t.String({ minLength: 1 }),
      status: t.Optional(t.Union([
        t.Literal('ready'),
        t.Literal('permission-denied'),
        t.Literal('unavailable'),
        t.Literal('error'),
      ])),
      provider: t.Optional(t.String()),
      accessibilityPath: t.Optional(t.Nullable(t.String())),
      text: t.Optional(t.Nullable(t.String())),
      elementCount: t.Optional(t.Number({ minimum: 0 })),
      appBundleId: t.Optional(t.Nullable(t.String())),
      windowTitle: t.Optional(t.Nullable(t.String())),
      tree: t.Optional(t.Array(t.Any())),
      metadata: t.Optional(t.Record(t.String(), t.Any())),
    })),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  snapshotIngestResponse: t.Union([
    t.Object({
      id: t.String(),
      sourceId: t.String(),
      workspaceId: t.Nullable(t.String()),
      capturedAt: t.Number(),
      displayId: t.Number(),
      segmentDir: t.String(),
      framePath: t.String(),
      artifactPath: t.Nullable(t.String()),
      ocrText: t.Nullable(t.String()),
      appBundleId: t.Nullable(t.String()),
      windowTitle: t.Nullable(t.String()),
      metadataJson: t.String(),
      createdAt: t.Number(),
      updatedAt: t.Number(),
    }),
    t.Object({
      status: t.Literal('ignored'),
      reason: t.String(),
      sourceId: t.String(),
      capturedAt: t.String(),
      capturedAtUnix: t.Number(),
    }),
  ]),

  memoryReportBody: t.Object({
    sourceId: t.String({ minLength: 1 }),
    windowType: t.Union([t.Literal('10min'), t.Literal('6h')]),
    createdAt: t.String({ minLength: 1 }),
    memoryPath: t.Optional(t.String()),
    content: t.String(),
    summaryKind: t.Union([t.Literal('llm'), t.Literal('local'), t.Literal('imported')]),
    sourceSnapshotPaths: t.Optional(t.Array(t.String())),
    sourceFramePaths: t.Optional(t.Array(t.String())),
    metadata: t.Optional(t.Record(t.String(), t.Any())),
  }),

  status: t.Object({
    available: t.Boolean(),
    running: t.Boolean(),
    pid: t.Nullable(t.Number()),
    lastCaptureAt: t.Nullable(t.Number()),
    lastSummaryAt: t.Nullable(t.Number()),
    lastErrorAt: t.Nullable(t.Number()),
    lastError: t.Nullable(t.String()),
    lastExitCode: t.Nullable(t.Number()),
    lastExitAt: t.Nullable(t.Number()),
    totalSnapshots: t.Number(),
    totalSummaries: t.Number(),
    totalMessages: t.Number(),
    lastMessageAt: t.Nullable(t.Number()),
    totalAccessibilitySnapshots: t.Number(),
    lastAccessibilitySnapshotAt: t.Nullable(t.Number()),
    totalAccessibilityEvents: t.Number(),
    lastAccessibilityEventAt: t.Nullable(t.Number()),
    totalAudioTranscripts: t.Number(),
    lastAudioTranscriptAt: t.Nullable(t.Number()),
    totalAudioRawSegments: t.Number(),
    lastAudioRawSegmentAt: t.Nullable(t.Number()),
    totalActivitySegments: t.Number(),
    lastActivitySegmentAt: t.Nullable(t.Number()),
    totalPipelineRuns: t.Number(),
    lastPipelineRunAt: t.Nullable(t.Number()),
    totalKnowledgeCards: t.Number(),
    lastKnowledgeCardAt: t.Nullable(t.Number()),
    totalDreamRuns: t.Number(),
    lastDreamRunAt: t.Nullable(t.Number()),
    dreamSchedulerEnabled: t.Boolean(),
    dreamSchedulerRunning: t.Boolean(),
    dreamSchedulerIntervalMs: t.Number(),
    dreamSchedulerApplyMerge: t.Boolean(),
    activityPipelineEnabled: t.Boolean(),
    activityPipelineRunning: t.Boolean(),
    activityPipelineIntervalMs: t.Number(),
    activityPipelineBatchSize: t.Number(),
    audioCaptureEnabled: t.Boolean(),
    audioRuntimeStatus: t.Union([
      t.Literal('disabled'),
      t.Literal('armed'),
      t.Literal('unavailable'),
    ]),
    closedEyesDiscardEnabled: t.Boolean(),
    closedEyesMode: t.Union([
      t.Literal('auto'),
      t.Literal('always-record'),
      t.Literal('always-pause'),
    ]),
    audioSource: t.Union([
      t.Literal('microphone'),
      t.Literal('system'),
      t.Literal('mixed'),
    ]),
    configuredModel: t.Nullable(t.String()),
  }),
}
