openapi: 3.1.0
info:
  title: DeskBot API
  description: REST API for monitoring and controlling DeskBot.
  version: 1.0.0b0
paths:
  /api/v1/health:
    get:
      tags:
      - health
      summary: Health check
      description: 'Return overall health status including component degradation info.


        The response includes the overall status (``"ok"`` or ``"degraded"``)

        and per-component details when a :class:`DegradationRegistry` is

        available on the app state bridge.'
      operationId: health_check_api_v1_health_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
  /api/v1/version:
    get:
      tags:
      - health
      summary: Version info
      description: Return the API version.
      operationId: version_info_api_v1_version_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VersionResponse'
  /api/v1/state:
    get:
      tags:
      - state
      summary: Current robot state
      description: 'Return the current robot state (IDLE, CURIOUS, LISTENING, etc.).


        Returns a placeholder if the state machine hasn''t been started yet.'
      operationId: get_state_api_v1_state_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StateResponse'
    post:
      tags:
      - commands
      summary: Transition state
      description: Transition the robot to a new state.
      operationId: set_state_api_v1_state_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommandResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/config:
    get:
      tags:
      - state
      summary: Current configuration
      description: 'Return the current configuration as a JSON dict.


        Sensitive fields (API keys) are masked.'
      operationId: get_config_api_v1_config_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfigResponse'
  /api/v1/perception:
    get:
      tags:
      - state
      summary: Perception status
      description: Return the current perception status (face detection, scan interval).
      operationId: get_perception_api_v1_perception_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerceptionResponse'
  /api/v1/audio:
    get:
      tags:
      - state
      summary: Audio output status
      description: Return the current audio output status.
      operationId: get_audio_api_v1_audio_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioStatusResponse'
  /api/v1/conversation:
    get:
      tags:
      - state
      summary: Conversation status
      description: Return the current conversation service status.
      operationId: get_conversation_api_v1_conversation_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationStatusResponse'
  /api/v1/speak:
    post:
      tags:
      - commands
      summary: Speak text
      description: 'Send text through the conversation pipeline (LLM -> TTS).


        Uses :meth:`ConversationService.handle_user_text` so typed input

        enters the same canonical path as speech recognition.'
      operationId: speak_api_v1_speak_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeakRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommandResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/speak-direct:
    post:
      tags:
      - commands
      summary: Speak text directly via TTS
      description: 'Speak text directly through TTS without going through the LLM pipeline.


        This bypasses STT and LLM entirely - just synthesizes the given text.'
      operationId: speak_direct_api_v1_speak_direct_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeakRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommandResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/emotion:
    post:
      tags:
      - commands
      summary: Set emotion
      description: Set the robot's current emotion.
      operationId: set_emotion_api_v1_emotion_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmotionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommandResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/conversations:
    get:
      tags:
      - conversations
      summary: List conversations
      description: 'List durable conversations, newest first.


        With the default in-memory configuration, the active conversation is

        returned as a single ephemeral entry.'
      operationId: list_conversations_api_v1_conversations_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/ConversationSummary'
                type: array
                title: Response List Conversations Api V1 Conversations Get
  /api/v1/conversations/{conversation_id}:
    get:
      tags:
      - conversations
      summary: Get conversation
      description: Get a conversation, including ordered messages.
      operationId: get_conversation_api_v1_conversations__conversation_id__get
      parameters:
      - name: conversation_id
        in: path
        required: true
        schema:
          type: string
          title: Conversation Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationDetail'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      tags:
      - conversations
      summary: Delete conversation
      description: Delete a saved conversation; deleting the active one resets it.
      operationId: delete_conversation_api_v1_conversations__conversation_id__delete
      parameters:
      - name: conversation_id
        in: path
        required: true
        schema:
          type: string
          title: Conversation Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OkResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/calibration/servos:
    get:
      tags:
      - calibration
      - calibration
      summary: List all servos
      operationId: list_servos_api_v1_calibration_servos_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServoListResponse'
  /api/v1/calibration/servos/{name}/move:
    post:
      tags:
      - calibration
      - calibration
      summary: Move a servo to an angle
      operationId: move_servo_api_v1_calibration_servos__name__move_post
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          title: Name
      - name: angle
        in: query
        required: true
        schema:
          type: number
          title: Angle
      - name: duration_s
        in: query
        required: false
        schema:
          type: number
          default: 0.4
          title: Duration S
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServoMoveResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/calibration/servos/{name}/release:
    post:
      tags:
      - calibration
      - calibration
      summary: Release a servo
      operationId: release_servo_api_v1_calibration_servos__name__release_post
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          title: Name
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServoReleaseResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/calibration/servos/release_all:
    post:
      tags:
      - calibration
      - calibration
      summary: Release all servos
      operationId: release_all_servos_api_v1_calibration_servos_release_all_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReleaseAllResponse'
  /api/v1/calibration/servos/calibrate/{name}:
    post:
      tags:
      - calibration
      - calibration
      summary: Run servo calibration sequence
      description: Centre a servo safely, optionally testing configured endpoints.
      operationId: calibrate_servo_api_v1_calibration_servos_calibrate__name__post
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          title: Name
      - name: include_limits
        in: query
        required: false
        schema:
          type: boolean
          description: Also visit configured endpoints
          default: false
          title: Include Limits
        description: Also visit configured endpoints
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalibrateServoResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/calibration/display:
    get:
      tags:
      - calibration
      - calibration
      summary: Get display configuration
      operationId: get_display_config_api_v1_calibration_display_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DisplayConfigResponse'
  /api/v1/calibration/display/test_pattern:
    post:
      tags:
      - calibration
      - calibration
      summary: Show a test pattern
      operationId: show_test_pattern_api_v1_calibration_display_test_pattern_post
      parameters:
      - name: pattern
        in: query
        required: false
        schema:
          type: string
          default: gradient
          title: Pattern
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestPatternResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/calibration/display/clear:
    post:
      tags:
      - calibration
      - calibration
      summary: Clear the display
      operationId: clear_display_api_v1_calibration_display_clear_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClearDisplayResponse'
  /api/v1/preferences:
    get:
      tags:
      - preferences
      summary: List all preferences
      description: Return all learned user preferences.
      operationId: list_preferences_api_v1_preferences_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreferenceListResponse'
  /api/v1/preferences/{key}:
    get:
      tags:
      - preferences
      summary: Get a specific preference
      description: Return a single preference by key.
      operationId: get_preference_api_v1_preferences__key__get
      parameters:
      - name: key
        in: path
        required: true
        schema:
          type: string
          title: Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreferenceItem'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      tags:
      - preferences
      summary: Delete a preference
      description: Delete a preference by key.
      operationId: delete_preference_api_v1_preferences__key__delete
      parameters:
      - name: key
        in: path
        required: true
        schema:
          type: string
          title: Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreferenceDeleteResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/learning/status:
    get:
      tags:
      - learning
      - learning
      summary: Learning service status
      description: Return the current learning service status.
      operationId: learning_status_api_v1_learning_status_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LearningStatusResponse'
  /api/v1/learning/preferences:
    get:
      tags:
      - learning
      - learning
      summary: Learned preferences
      description: Return all learned preferences.
      operationId: learning_preferences_api_v1_learning_preferences_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LearningPreferencesResponse'
  /api/v1/learning/config:
    get:
      tags:
      - learning
      - learning
      summary: Learning configuration
      description: Return the current learning configuration.
      operationId: learning_config_api_v1_learning_config_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LearningConfigResponse'
  /api/v1/learning/train:
    post:
      tags:
      - learning
      - learning
      summary: Force a training cycle
      description: Force an immediate training cycle regardless of schedule.
      operationId: force_train_api_v1_learning_train_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForceTrainResponse'
  /api/v1/teaching/status:
    get:
      tags:
      - teaching
      summary: Teaching loop status
      description: Snapshot of the teaching controller and learning service.
      operationId: teaching_status_api_v1_teaching_status_get
      responses:
        '200':
          description: Teaching-loop snapshot
          content:
            application/json:
              schema:
                type: object
                properties:
                  enabled: {type: boolean}
                  in_teaching_mode: {type: boolean, default: false}
                  session_id: {type: string, nullable: true}
                  mode: {type: string, nullable: true}
                  trigger_gesture: {type: string, nullable: true}
                  desired_action: {type: string, nullable: true}
                  total_experiences: {type: integer, default: 0}
                  min_experiences_for_practice: {type: integer, default: 0}
  /api/v1/teaching/transitions:
    get:
      tags:
      - teaching
      summary: Recent teaching transitions
      description: Recent real transitions with a conversation-free state summary. Filters apply against a 256-entry working-memory pool before `limit`, so narrowing does not empty the result window. `total` is the count after filtering, before `limit`.
      operationId: teaching_transitions_api_v1_teaching_transitions_get
      parameters:
      - name: limit
        in: query
        required: false
        schema: {type: integer, minimum: 1, maximum: 256, default: 20}
      - name: action
        in: query
        required: false
        description: Case-insensitive substring filter on action name.
        schema: {type: string}
      - name: success
        in: query
        required: false
        description: Filter on execution_success.
        schema: {type: boolean}
      - name: feedback
        in: query
        required: false
        description: "true = only transitions with attributed feedback; false = none."
        schema: {type: boolean}
      - name: interaction_id
        in: query
        required: false
        description: Exact interaction_id filter.
        schema: {type: string}
      responses:
        '200':
          description: Recent transitions
          content:
            application/json:
              schema:
                type: object
                properties:
                  total: {type: integer}
                  limit: {type: integer}
                  transitions:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp: {type: string, format: date-time}
                        transition_id: {type: string, nullable: true}
                        action_name: {type: string}
                        action_index: {type: integer}
                        execution_success: {type: boolean, default: true}
                        reward: {type: number, default: 0.0}
                        feedback_source: {type: string, nullable: true}
                        interaction_id: {type: string, nullable: true}
                        teaching_session_id: {type: string, nullable: true}
                        state_summary:
                          type: object
                          properties:
                            teaching_context: {type: boolean}
                            interaction_active: {type: boolean}
                            person_present: {type: boolean}
                            gesture: {type: string}
        '404':
          description: Learning service not available
  /api/v1/teaching/feedback:
    post:
      tags:
      - teaching
      summary: Submit explicit human feedback
      description: Attribute praise/correction to the most-recent eligible real transition. Requires an API key.
      operationId: teaching_feedback_api_v1_teaching_feedback_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                polarity: {type: integer, minimum: -1, maximum: 1}
                magnitude: {type: number, exclusiveMinimum: 0, maximum: 2, default: 1.0}
                source: {type: string, default: api}
                text: {type: string, default: ""}
      responses:
        '200':
          description: Acknowledgement
          content:
            application/json:
              schema:
                type: object
                properties:
                  attributed: {type: boolean}
                  transition_id: {type: string, nullable: true}
                  delta: {type: number, default: 0.0}
        '401':
          description: API key required
        '404':
          description: Feedback service not available
  /api/v1/teaching/demonstration:
    post:
      tags:
      - teaching
      summary: Arm a teaching session and/or inject a gesture
      description: Arm a session from a constrained instruction, or trigger a gesture against the live encoder state. Requires an API key.
      operationId: teaching_demonstration_api_v1_teaching_demonstration_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instruction: {type: string, nullable: true}
                gesture: {type: string, nullable: true}
                mode: {type: string, enum: [demonstrate, practice], default: demonstrate}
      responses:
        '200':
          description: Result of arming / triggering
          content:
            application/json:
              schema:
                type: object
                properties:
                  session_id: {type: string, nullable: true}
                  trigger_gesture: {type: string, nullable: true}
                  desired_action: {type: string, nullable: true}
                  executed_action: {type: string, nullable: true}
                  executed_action_index: {type: integer, nullable: true}
        '401':
          description: API key required
        '404':
          description: Teaching controller / learning service not available
        '422':
          description: Unknown mode or unparseable instruction
  /api/v1/teaching/qvalues:
    get:
      tags:
      - teaching
      summary: Current Q-values for the encoder state
      description: Map of action name to Q-value for the current encoded state.
      operationId: teaching_qvalues_api_v1_teaching_qvalues_get
      responses:
        '200':
          description: Q-value map
          content:
            application/json:
              schema:
                type: object
                properties:
                  q_values:
                    type: object
                    additionalProperties: {type: number}
        '404':
          description: Learning service / action learner not available
  /api/v1/config/validate:
    post:
      tags:
      - config
      summary: Validate proposed configuration
      description: 'Validate a proposed configuration without applying it.


        Accepts a JSON body with partial or full config overrides. The

        proposed values are merged with the current defaults and validated

        against the :class:`AppSettings` Pydantic model.


        Returns ``{valid: true}`` on success, or ``{valid: false, errors: [...]}``

        with field-level error messages on failure.


        This endpoint **never** modifies the running configuration.'
      operationId: validate_config_api_v1_config_validate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConfigValidateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfigValidateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/config/schema:
    get:
      tags:
      - config
      summary: Configuration JSON Schema
      description: 'Return the full JSON Schema for :class:`AppSettings`.


        This enables the config validator UI to build dynamic form inputs,

        show field descriptions, types, defaults, and validation constraints.'
      operationId: get_config_schema_api_v1_config_schema_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConfigSchemaResponse'
  /api/v1/performance:
    get:
      tags:
      - performance
      summary: Combined performance summary
      description: Return a combined summary of all profiler data.
      operationId: get_performance_summary_api_v1_performance_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerformanceSummaryResponse'
  /api/v1/performance/frames:
    get:
      tags:
      - performance
      summary: Frame budget stats
      description: Return frame budget performance statistics.
      operationId: get_frame_stats_api_v1_performance_frames_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameStatsResponse'
  /api/v1/performance/servos:
    get:
      tags:
      - performance
      summary: Servo latency stats
      description: Return per-servo latency statistics.
      operationId: get_servo_stats_api_v1_performance_servos_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServoProfilerStatsResponse'
  /api/v1/performance/bus:
    get:
      tags:
      - performance
      summary: Event bus throughput
      description: Return event bus throughput and latency statistics.
      operationId: get_bus_stats_api_v1_performance_bus_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BusProfilerStatsResponse'
  /api/v1/settings/info:
    get:
      tags:
      - settings
      - settings
      summary: Hardware & subsystem overview
      description: Return a comprehensive overview of all testable subsystems.
      operationId: settings_info_api_v1_settings_info_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SettingsInfoResponse'
  /api/v1/settings/camera/info:
    get:
      tags:
      - settings
      - settings
      summary: Camera info
      description: Return camera type and resolution.
      operationId: camera_info_api_v1_settings_camera_info_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CameraInfoResponse'
  /api/v1/settings/camera/frame:
    get:
      tags:
      - settings
      - settings
      summary: Capture a single frame
      description: Capture a single frame and return it as a JPEG (or BMP fallback).
      operationId: camera_frame_api_v1_settings_camera_frame_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /api/v1/settings/camera/stream:
    get:
      tags:
      - settings
      - settings
      summary: Live MJPEG camera preview
      description: "Stream a live MJPEG feed from the camera.\n\nThe browser can display this directly in an ``<img>`` tag::\n\n    <img src=\"/api/v1/settings/camera/stream\" />"
      operationId: camera_stream_api_v1_settings_camera_stream_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /api/v1/settings/mic/info:
    get:
      tags:
      - settings
      - settings
      summary: Microphone info
      description: Return microphone type and sample rate.
      operationId: mic_info_api_v1_settings_mic_info_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MicrophoneInfoResponse'
  /api/v1/settings/mic/level:
    get:
      tags:
      - settings
      - settings
      summary: Current microphone input level
      description: 'Return the current microphone RMS level (0..1).


        For :class:`UsbMicrophone` this reads the continuously-updated

        ``_last_rms_value`` from the background capture thread (zero

        conflict with the conversation audio loop). For other microphones

        a best-effort value is returned.'
      operationId: mic_level_api_v1_settings_mic_level_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MicLevelResponse'
  /api/v1/settings/mic/test:
    post:
      tags:
      - settings
      - settings
      summary: Record and play back a mic test
      description: 'Record *duration* seconds from a temporary microphone and return WAV.


        A **temporary** microphone instance is created with the same settings

        as the active one so the conversation audio loop is not disturbed.

        The recorded audio is returned as a WAV file for the browser to play.'
      operationId: mic_test_api_v1_settings_mic_test_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MicTestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/audio/info:
    get:
      tags:
      - settings
      - settings
      summary: Audio output info
      description: Return audio output type, sample rate, and channels.
      operationId: audio_info_api_v1_settings_audio_info_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioInfoResponse'
  /api/v1/settings/audio/devices:
    get:
      tags:
      - settings
      - settings
      summary: List available audio output devices
      description: 'List available audio output devices via ``sounddevice``.


        Returns an empty list when ``sounddevice`` is not installed or when

        no audio subsystem is available.  The PortAudio query runs in a

        thread with a 3-second timeout so it can never block the API.'
      operationId: audio_devices_api_v1_settings_audio_devices_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioDevicesResponse'
  /api/v1/settings/audio/input-devices:
    get:
      tags:
      - settings
      - settings
      summary: List available audio input devices
      description: List available audio input devices via ``sounddevice``.
      operationId: audio_input_devices_api_v1_settings_audio_input_devices_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioDevicesResponse'
  /api/v1/settings/audio/tone:
    post:
      tags:
      - settings
      - settings
      summary: Play a test tone
      description: Play a sine-wave test tone through the current audio output.
      operationId: audio_tone_api_v1_settings_audio_tone_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToneRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToneResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/audio/test-device:
    post:
      tags:
      - settings
      - settings
      summary: Play a test tone through a specific device
      description: 'Play a test tone through a specific output device (temporary).


        This creates a temporary :class:`UsbSpeaker` for the given device,

        plays the tone, and closes it. Useful for testing different outputs

        before committing to a config change.'
      operationId: audio_test_device_api_v1_settings_audio_test_device_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudioDeviceTestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioTestDeviceResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/audio/switch:
    post:
      tags:
      - settings
      - settings
      summary: Switch the active audio output device
      description: 'Switch the active audio output to a different device at runtime.


        Creates a new :class:`UsbSpeaker` for the requested device and swaps

        it into the bridge, TTS engine, and sound-effects player. The old

        output is closed.'
      operationId: audio_switch_api_v1_settings_audio_switch_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudioSwitchRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudioSwitchResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/audio/stop:
    post:
      tags:
      - settings
      - settings
      summary: Stop audio playback
      description: Stop whatever is currently playing on the audio output.
      operationId: audio_stop_api_v1_settings_audio_stop_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToneResponse'
  /api/v1/settings/tts/test:
    post:
      tags:
      - settings
      - settings
      summary: Speak a test phrase
      description: Speak a test phrase through the configured TTS engine.
      operationId: tts_test_api_v1_settings_tts_test_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TTSTestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TTSTestResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/llm/test:
    post:
      tags:
      - settings
      - settings
      summary: Send a test prompt to the LLM
      description: Send a test prompt to the LLM and return the response text.
      operationId: llm_test_api_v1_settings_llm_test_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LLMTestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LLMTestResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/sound-effect/{name}:
    post:
      tags:
      - settings
      - settings
      summary: Play a sound effect
      description: Play a named sound effect (e.g. ``talk``, ``thinking``, ``cute``).
      operationId: play_sound_effect_api_v1_settings_sound_effect__name__post
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          title: Name
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoundEffectResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/v1/settings/sound-effects:
    get:
      tags:
      - settings
      - settings
      summary: List available sound effects
      description: List all available sound effect names.
      operationId: list_sound_effects_api_v1_settings_sound_effects_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoundEffectsListResponse'
  /api/v1/system/info:
    get:
      tags:
      - system
      - system
      summary: System information
      description: Return system information for the dashboard.
      operationId: system_info_api_v1_system_info_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SystemInfoResponse'
  /api/v1/system/logs:
    get:
      tags:
      - system
      - system
      summary: Recent log entries
      description: Return recent log entries from the in-memory ring buffer, filtered server-side.
      operationId: system_logs_api_v1_system_logs_get
      parameters:
      - name: level
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: 'Filter by level (DEBUG, INFO, WARNING, ERROR); "ALL" = no filter'
          title: Level
        description: 'Filter by level (DEBUG, INFO, WARNING, ERROR); "ALL" = no filter'
      - name: search
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Case-insensitive text search across event/logger/data
          title: Search
        description: Case-insensitive text search across event/logger/data
      - name: logger
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Case-insensitive substring filter on logger name
          title: Logger
        description: Case-insensitive substring filter on logger name
      - name: event
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Case-insensitive substring filter on event name
          title: Event
        description: Case-insensitive substring filter on event name
      - name: exclude
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Comma-separated event names to omit (e.g. 'DisplayUpdated,LookRequested')
          title: Exclude
        description: Comma-separated event names to omit (e.g. 'DisplayUpdated,LookRequested')
      - name: since
        in: query
        required: false
        schema:
          anyOf:
          - type: number
          - type: 'null'
          minimum: 0
          description: Only entries with created_epoch >= this POSIX timestamp (live tailing)
          title: Since
        description: Only entries with created_epoch >= this POSIX timestamp (live tailing)
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          maximum: 500
          minimum: 1
          default: 200
          title: Limit
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      tags:
      - system
      - system
      summary: Clear log buffer
      description: Clear the in-memory log ring buffer.
      operationId: clear_logs_api_v1_system_logs_delete
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OkResponse'
  /api/v1/system/logs/filters:
    get:
      tags:
      - system
      summary: Distinct log filter values
      description: Return the distinct levels, logger names, and event names currently in the ring buffer (for dashboard dropdowns), plus the server-configured noisy_events hide list.
      operationId: system_logs_filters_api_v1_system_logs_filters_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogsFiltersResponse'
  /api/v1/system/bluetooth:
    get:
      tags:
      - system
      - system
      summary: Bluetooth status
      description: Return Bluetooth speaker status if available.
      operationId: bluetooth_status_api_v1_system_bluetooth_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BluetoothResponse'
components:
  schemas:
    AudioDevice:
      properties:
        name:
          anyOf:
          - type: string
          - type: 'null'
          title: Name
        index:
          anyOf:
          - type: integer
          - type: 'null'
          title: Index
        channels:
          anyOf:
          - type: integer
          - type: 'null'
          title: Channels
        default:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Default
      additionalProperties: true
      type: object
      title: AudioDevice
      description: A single sounddevice entry.
      examples:
      - channels: 2
        default: true
        index: 2
        name: hw:1,0
    AudioDeviceTestRequest:
      properties:
        device:
          anyOf:
          - type: string
          - type: integer
          title: Device
          default: default
        frequency_hz:
          type: number
          maximum: 20000.0
          minimum: 20.0
          title: Frequency Hz
          default: 440.0
        duration_s:
          type: number
          maximum: 10.0
          minimum: 0.1
          title: Duration S
          default: 1.0
        volume:
          type: number
          maximum: 1.0
          minimum: 0.0
          title: Volume
          default: 0.5
      additionalProperties: true
      type: object
      title: AudioDeviceTestRequest
      description: Play a test tone through a specific output device (runtime test).
      examples:
      - device: default
        duration_s: 1.0
        frequency_hz: 440.0
        volume: 0.5
    AudioDevicesResponse:
      properties:
        devices:
          items:
            $ref: '#/components/schemas/AudioDevice'
          type: array
          title: Devices
          default: []
        available:
          type: boolean
          title: Available
          default: true
        error:
          anyOf:
          - type: string
          - type: 'null'
          title: Error
      additionalProperties: true
      type: object
      title: AudioDevicesResponse
      description: List of available audio devices.
      examples:
      - available: true
        devices:
        - channels: 2
          default: true
          index: 2
          name: hw:1,0
      - available: false
        devices: []
        error: sounddevice not installed
    AudioInfoResponse:
      properties:
        type:
          type: string
          title: Type
        sample_rate:
          anyOf:
          - type: integer
          - type: 'null'
          title: Sample Rate
        channels:
          anyOf:
          - type: integer
          - type: 'null'
          title: Channels
        is_mock:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Is Mock
        output_device:
          anyOf:
          - type: string
          - type: 'null'
          title: Output Device
      additionalProperties: true
      type: object
      required:
      - type
      title: AudioInfoResponse
      description: Audio output type, sample rate, and channels.
      examples:
      - channels: 2
        is_mock: false
        output_device: default
        sample_rate: 48000
        type: UsbSpeaker
    AudioStatusResponse:
      properties:
        enabled:
          type: boolean
          title: Enabled
        talking:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Talking
        detail:
          anyOf:
          - type: string
          - type: 'null'
          title: Detail
      additionalProperties: true
      type: object
      required:
      - enabled
      title: AudioStatusResponse
      description: Audio output status.
      examples:
      - enabled: true
        talking: false
      - detail: DeskBot app not attached
        enabled: false
    AudioSwitchRequest:
      properties:
        device:
          anyOf:
          - type: string
          - type: integer
          title: Device
          default: default
      additionalProperties: true
      type: object
      title: AudioSwitchRequest
      description: Switch the active audio output device at runtime.
      examples:
      - device: usb_headset
    AudioSwitchResponse:
      properties:
        status:
          type: string
          title: Status
        device:
          anyOf:
          - type: string
          - type: integer
          - type: 'null'
          title: Device
        type:
          anyOf:
          - type: string
          - type: 'null'
          title: Type
      additionalProperties: true
      type: object
      required:
      - status
      title: AudioSwitchResponse
      description: Acknowledgement of an audio device switch.
      examples:
      - device: usb_headset
        status: ok
        type: UsbSpeaker
    AudioTestDeviceResponse:
      properties:
        status:
          type: string
          title: Status
        device:
          anyOf:
          - type: string
          - type: integer
          - type: 'null'
          title: Device
        frequency_hz:
          anyOf:
          - type: number
          - type: 'null'
          title: Frequency Hz
        duration_s:
          anyOf:
          - type: number
          - type: 'null'
          title: Duration S
      additionalProperties: true
      type: object
      required:
      - status
      title: AudioTestDeviceResponse
      description: Acknowledgement of a device test tone.
      examples:
      - device: default
        duration_s: 1.0
        frequency_hz: 440.0
        status: ok
    BluetoothResponse:
      properties:
        available:
          type: boolean
          title: Available
        type:
          anyOf:
          - type: string
          - type: 'null'
          title: Type
        is_bluetooth:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Is Bluetooth
        connected:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Connected
        sink_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Sink Name
        device_mac:
          anyOf:
          - type: string
          - type: 'null'
          title: Device Mac
        device_name:
          anyOf:
          - type: string
          - type: 'null'
          title: Device Name
        auto_connect:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Auto Connect
        playing:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Playing
        sample_rate:
          anyOf:
          - type: integer
          - type: 'null'
          title: Sample Rate
        channels:
          anyOf:
          - type: integer
          - type: 'null'
          title: Channels
      additionalProperties: true
      type: object
      required:
      - available
      title: BluetoothResponse
      description: Bluetooth speaker status.
      examples:
      - available: true
        connected: true
        device_name: DeskBot BT
        is_bluetooth: true
        type: BluetoothSpeaker
      - available: false
    BusProfilerStatsResponse:
      properties:
        enabled:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Enabled
      additionalProperties: true
      type: object
      title: BusProfilerStatsResponse
      description: Event bus throughput and latency statistics.
      examples:
      - avg_latency_ms: 0.4
        events_per_s: 120.0
        subscribers: 12
        total_events: 5400
      - enabled: false
    CalibrateServoResponse:
      properties:
        servo:
          type: string
          title: Servo
        sequence:
          items:
            $ref: '#/components/schemas/CalibrationStep'
          type: array
          title: Sequence
      additionalProperties: true
      type: object
      required:
      - servo
      - sequence
      title: CalibrateServoResponse
      description: Result of a servo calibration sequence.
      examples:
      - sequence:
        - actual_angle: 0.0
          angle: 0.0
          position: min
        - actual_angle: 90.0
          angle: 90.0
          position: centre
        servo: pan
    CalibrationStep:
      properties:
        position:
          type: string
          title: Position
        angle:
          type: number
          title: Angle
        actual_angle:
          type: number
          title: Actual Angle
      additionalProperties: true
      type: object
      required:
      - position
      - angle
      - actual_angle
      title: CalibrationStep
      description: One step of a calibration sequence.
      examples:
      - actual_angle: 0.0
        angle: 0.0
        position: min
    CameraInfoResponse:
      properties:
        type:
          type: string
          title: Type
        width:
          anyOf:
          - type: integer
          - type: 'null'
          title: Width
        height:
          anyOf:
          - type: integer
          - type: 'null'
          title: Height
        is_mock:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Is Mock
        captured:
          anyOf:
          - type: integer
          - type: 'null'
          title: Captured
      additionalProperties: true
      type: object
      required:
      - type
      title: CameraInfoResponse
      description: Camera type and resolution.
      examples:
      - captured: 1024
        height: 480
        is_mock: false
        type: UsbCamera
        width: 640
    ClearDisplayResponse:
      properties:
        cleared:
          type: boolean
          title: Cleared
      additionalProperties: true
      type: object
      required:
      - cleared
      title: ClearDisplayResponse
      description: Acknowledgement of display clear.
      examples:
      - cleared: true
    CommandResponse:
      properties:
        status:
          type: string
          title: Status
          description: '"ok" or "error".'
        detail:
          anyOf:
          - type: string
          - type: 'null'
          title: Detail
      additionalProperties: true
      type: object
      required:
      - status
      title: CommandResponse
      description: Generic command acknowledgement with the echoed payload.
      examples:
      - status: ok
        text: Hello!
      - emotion: happy
        status: ok
      - state: curious
        status: ok
      - detail: DeskBot app not attached
        status: error
    ConfigResponse:
      properties: {}
      additionalProperties: true
      type: object
      title: ConfigResponse
      description: Current (masked) configuration. Free-form nested object.
      examples:
      - displays:
          backend: gc9a01
          height: 240
          rotation: 0
          width: 240
        env: development
        hardware: mock
        llm:
          api_key: sk-x****
          model: gpt-4o-mini
          provider: openai
    ConfigSchemaResponse:
      properties: {}
      additionalProperties: true
      type: object
      title: ConfigSchemaResponse
      description: The full JSON Schema for the :class:`AppSettings` model (free-form).
      examples:
      - properties:
          env:
            default: development
            type: string
        title: AppSettings
        type: object
    ConfigValidateRequest:
      properties: {}
      additionalProperties: true
      type: object
      title: ConfigValidateRequest
      description: 'A partial or full configuration override to validate.


        Any subset of the :class:`AppSettings` fields may be supplied; omitted

        fields fall back to the current defaults during validation.'
      examples:
      - displays:
          backend: gc9a01
          height: 240
          width: 240
        env: development
      - servos:
          pan:
            max: 180
            min: 0
    ConfigValidateResponse:
      properties:
        valid:
          type: boolean
          title: Valid
        errors:
          items:
            $ref: '#/components/schemas/ConfigValidationErrorItem'
          type: array
          title: Errors
          default: []
      additionalProperties: true
      type: object
      required:
      - valid
      title: ConfigValidateResponse
      description: Result of a config validation request.
      examples:
      - valid: true
      - errors:
        - field: displays.width
          input: -1
          message: Input should be greater than 0
          type: greater_than
        valid: false
    ConfigValidationErrorItem:
      properties:
        field:
          type: string
          title: Field
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
        input:
          title: Input
      additionalProperties: true
      type: object
      required:
      - field
      - message
      - type
      title: ConfigValidationErrorItem
      description: A single validation error.
      examples:
      - field: displays.width
        input: -1
        message: Input should be greater than 0
        type: greater_than
    ConversationDetail:
      properties:
        id:
          type: string
          title: Id
        system_prompt:
          type: string
          title: System Prompt
        messages:
          items:
            $ref: '#/components/schemas/MessageItem'
          type: array
          title: Messages
      type: object
      required:
      - id
      - system_prompt
      title: ConversationDetail
      description: A conversation and its messages.
      examples:
      - id: abc123
        messages:
        - content: Hello! Who are you?
          role: user
        - content: I'm DeskBot, your desktop companion!
          role: assistant
        system_prompt: You are a helpful desktop robot.
    ConversationStatusResponse:
      properties:
        enabled:
          type: boolean
          title: Enabled
        state:
          anyOf:
          - type: string
          - type: 'null'
          title: State
        wake_checker:
          anyOf:
          - type: string
          - type: 'null'
          title: Wake Checker
        stt:
          anyOf:
          - type: string
          - type: 'null'
          title: Stt
        tts:
          anyOf:
          - type: string
          - type: 'null'
          title: Tts
        llm:
          anyOf:
          - type: string
          - type: 'null'
          title: Llm
      additionalProperties: true
      type: object
      required:
      - enabled
      title: ConversationStatusResponse
      description: Conversation pipeline status.
      examples:
      - enabled: true
        llm: OpenAILLM
        state: idle
        stt: WhisperSTT
        tts: OpenAITTS
        wake_checker: OpenWakeWordChecker
      - enabled: false
    ConversationSummary:
      properties:
        id:
          type: string
          title: Id
        created_at:
          type: string
          title: Created At
        system_prompt:
          type: string
          title: System Prompt
        message_count:
          type: integer
          title: Message Count
      type: object
      required:
      - id
      - created_at
      - system_prompt
      - message_count
      title: ConversationSummary
      description: Metadata for one saved conversation.
      examples:
      - created_at: '2026-08-12T10:00:00Z'
        id: abc123
        message_count: 8
        system_prompt: You are a helpful desktop robot.
    DisplayConfigResponse:
      properties:
        backend:
          type: string
          title: Backend
        width:
          type: integer
          title: Width
        height:
          type: integer
          title: Height
        rotation:
          type: integer
          title: Rotation
        spi_hz:
          type: integer
          title: Spi Hz
        invert:
          type: boolean
          title: Invert
      additionalProperties: true
      type: object
      required:
      - backend
      - width
      - height
      - rotation
      - spi_hz
      - invert
      title: DisplayConfigResponse
      description: Display configuration.
      examples:
      - backend: gc9a01
        height: 240
        invert: false
        rotation: 0
        spi_hz: 40000000
        width: 240
    EmotionRequest:
      properties:
        emotion:
          type: string
          title: Emotion
          description: Emotion name (neutral, happy, curious, etc.).
        intensity:
          type: number
          maximum: 1.0
          minimum: 0.0
          title: Intensity
          default: 1.0
      additionalProperties: true
      type: object
      required:
      - emotion
      title: EmotionRequest
      description: Request body for the emotion command.
      examples:
      - emotion: happy
        intensity: 0.8
    ForceTrainResponse:
      properties:
        triggered:
          type: boolean
          title: Triggered
        training_cycles_completed:
          type: integer
          title: Training Cycles Completed
        is_training:
          type: boolean
          title: Is Training
      additionalProperties: true
      type: object
      required:
      - triggered
      - training_cycles_completed
      - is_training
      title: ForceTrainResponse
      description: Result of a forced training cycle.
      examples:
      - is_training: false
        training_cycles_completed: 9
        triggered: true
    FrameStatsResponse:
      properties:
        enabled:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Enabled
        target_fps:
          anyOf:
          - type: integer
          - type: 'null'
          title: Target Fps
        actual_fps:
          anyOf:
          - type: number
          - type: 'null'
          title: Actual Fps
        avg_frame_time_ms:
          anyOf:
          - type: number
          - type: 'null'
          title: Avg Frame Time Ms
        p50_frame_time_ms:
          anyOf:
          - type: number
          - type: 'null'
          title: P50 Frame Time Ms
        p95_frame_time_ms:
          anyOf:
          - type: number
          - type: 'null'
          title: P95 Frame Time Ms
        p99_frame_time_ms:
          anyOf:
          - type: number
          - type: 'null'
          title: P99 Frame Time Ms
        dropped_frames:
          anyOf:
          - type: integer
          - type: 'null'
          title: Dropped Frames
        total_frames:
          anyOf:
          - type: integer
          - type: 'null'
          title: Total Frames
      additionalProperties: true
      type: object
      title: FrameStatsResponse
      description: Frame budget statistics.
      examples:
      - actual_fps: 29.4
        avg_frame_time_ms: 34.0
        dropped_frames: 3
        p50_frame_time_ms: 33.0
        p95_frame_time_ms: 38.0
        p99_frame_time_ms: 42.0
        target_fps: 30
        total_frames: 1200
      - enabled: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    HealthResponse:
      properties:
        status:
          type: string
          title: Status
          description: '"ok" or "degraded".'
      additionalProperties: true
      type: object
      required:
      - status
      title: HealthResponse
      description: Overall health, possibly with per-component degradation info.
      examples:
      - status: ok
      - components:
          camera:
            reason: device not found
            status: degraded
          microphone:
            status: ok
        status: degraded
    LLMTestRequest:
      properties:
        prompt:
          type: string
          title: Prompt
          default: Hello! Who are you?
      additionalProperties: true
      type: object
      title: LLMTestRequest
      description: Send a test prompt to the LLM and return the response.
      examples:
      - prompt: Hello! Who are you?
    LLMTestResponse:
      properties:
        status:
          type: string
          title: Status
        prompt:
          anyOf:
          - type: string
          - type: 'null'
          title: Prompt
        response:
          anyOf:
          - type: string
          - type: 'null'
          title: Response
        engine:
          anyOf:
          - type: string
          - type: 'null'
          title: Engine
        error:
          anyOf:
          - type: string
          - type: 'null'
          title: Error
      additionalProperties: true
      type: object
      required:
      - status
      title: LLMTestResponse
      description: Result of an LLM test prompt.
      examples:
      - engine: OpenAILLM
        prompt: Hello! Who are you?
        response: I'm DeskBot, your desktop companion!
        status: ok
      - error: No LLM configured
        prompt: Hello!
        status: error
    LearnedPreferenceItem:
      properties:
        key:
          type: string
          title: Key
        category:
          type: string
          title: Category
        value:
          type: string
          title: Value
        confidence:
          type: number
          title: Confidence
        observation_count:
          type: integer
          title: Observation Count
        avg_reward:
          type: number
          title: Avg Reward
        source:
          type: string
          title: Source
        last_observed:
          type: string
          title: Last Observed
      additionalProperties: true
      type: object
      required:
      - key
      - category
      - value
      - confidence
      - observation_count
      - avg_reward
      - source
      - last_observed
      title: LearnedPreferenceItem
      description: A single learned preference with confidence.
      examples:
      - avg_reward: 0.82
        category: preferred_action
        confidence: 0.75
        key: preferred_action:celebrate
        last_observed: '2026-08-12T10:25:00Z'
        observation_count: 12
        source: behavioral
        value: celebrate
    LearningCheckpointSchema:
      properties:
        checkpoint_dir:
          type: string
          title: Checkpoint Dir
        keep_last_n:
          type: integer
          title: Keep Last N
        promote_threshold:
          type: number
          title: Promote Threshold
      additionalProperties: true
      type: object
      required:
      - checkpoint_dir
      - keep_last_n
      - promote_threshold
      title: LearningCheckpointSchema
      description: Checkpoint management configuration.
      examples:
      - checkpoint_dir: ~/.deskbot/checkpoints
        keep_last_n: 5
        promote_threshold: 1.0
    LearningConfigResponse:
      properties:
        schedule:
          $ref: '#/components/schemas/LearningScheduleSchema'
        resource_limits:
          $ref: '#/components/schemas/LearningResourceLimitsSchema'
        checkpoint_config:
          $ref: '#/components/schemas/LearningCheckpointSchema'
      additionalProperties: true
      type: object
      required:
      - schedule
      - resource_limits
      - checkpoint_config
      title: LearningConfigResponse
      description: Learning service configuration.
      examples:
      - checkpoint_config:
          checkpoint_dir: ~/.deskbot/checkpoints
          keep_last_n: 5
          promote_threshold: 1.0
        resource_limits:
          batch_size: 32
          eval_sample_size: 128
          max_cpu_fraction: 0.3
          max_model_params: 500000
          training_epochs_per_cycle: 5
        schedule:
          min_experiences_for_training: 64
          min_new_experiences: 32
          train_interval_s: 30.0
    LearningPreferencesResponse:
      properties:
        preferences:
          items:
            $ref: '#/components/schemas/LearnedPreferenceItem'
          type: array
          title: Preferences
        total_patterns:
          type: integer
          title: Total Patterns
          default: 0
      additionalProperties: true
      type: object
      required:
      - preferences
      title: LearningPreferencesResponse
      description: All learned preferences and the total tracked pattern count.
      examples:
      - preferences:
        - avg_reward: 0.82
          category: preferred_action
          confidence: 0.75
          key: preferred_action:celebrate
          last_observed: '2026-08-12T10:25:00Z'
          observation_count: 12
          source: behavioral
          value: celebrate
        total_patterns: 17
    LearningResourceLimitsSchema:
      properties:
        batch_size:
          type: integer
          title: Batch Size
        training_epochs_per_cycle:
          type: integer
          title: Training Epochs Per Cycle
        max_cpu_fraction:
          type: number
          title: Max Cpu Fraction
        max_model_params:
          type: integer
          title: Max Model Params
        eval_sample_size:
          type: integer
          title: Eval Sample Size
      additionalProperties: true
      type: object
      required:
      - batch_size
      - training_epochs_per_cycle
      - max_cpu_fraction
      - max_model_params
      - eval_sample_size
      title: LearningResourceLimitsSchema
      description: Resource limits for background training.
      examples:
      - batch_size: 32
        eval_sample_size: 128
        max_cpu_fraction: 0.3
        max_model_params: 500000
        training_epochs_per_cycle: 5
    LearningScheduleSchema:
      properties:
        min_new_experiences:
          type: integer
          title: Min New Experiences
        train_interval_s:
          type: number
          title: Train Interval S
        min_experiences_for_training:
          type: integer
          title: Min Experiences For Training
      additionalProperties: true
      type: object
      required:
      - min_new_experiences
      - train_interval_s
      - min_experiences_for_training
      title: LearningScheduleSchema
      description: Training schedule configuration.
      examples:
      - min_experiences_for_training: 64
        min_new_experiences: 32
        train_interval_s: 30.0
    LearningStatusResponse:
      properties:
        enabled:
          type: boolean
          title: Enabled
        total_experiences:
          type: integer
          title: Total Experiences
        new_experiences_since_train:
          type: integer
          title: New Experiences Since Train
        training_cycles_completed:
          type: integer
          title: Training Cycles Completed
        current_model_loss:
          anyOf:
          - type: number
          - type: 'null'
          title: Current Model Loss
        candidate_model_loss:
          anyOf:
          - type: number
          - type: 'null'
          title: Candidate Model Loss
        last_training_time:
          anyOf:
          - type: string
          - type: 'null'
          title: Last Training Time
        last_training_duration_s:
          type: number
          title: Last Training Duration S
          default: 0.0
        is_training:
          type: boolean
          title: Is Training
          default: false
        promotions:
          type: integer
          title: Promotions
          default: 0
        rollbacks:
          type: integer
          title: Rollbacks
          default: 0
        model_version:
          type: integer
          title: Model Version
          default: 0
        use_multimodal:
          type: boolean
          title: Use Multimodal
          default: false
        multimodal_state_size:
          type: integer
          title: Multimodal State Size
          default: 0
      additionalProperties: true
      type: object
      required:
      - enabled
      - total_experiences
      - new_experiences_since_train
      - training_cycles_completed
      title: LearningStatusResponse
      description: Snapshot of the background learning service.
      examples:
      - candidate_model_loss: 0.0118
        current_model_loss: 0.0123
        enabled: true
        is_training: false
        last_training_duration_s: 1.842
        last_training_time: '2026-08-12T10:29:55Z'
        model_version: 5
        new_experiences_since_train: 12
        promotions: 5
        rollbacks: 3
        total_experiences: 1280
        training_cycles_completed: 8
        use_multimodal: false
        multimodal_state_size: 0
    LogEntry:
      properties:
        timestamp:
          type: string
          title: Timestamp
        created_epoch:
          type: number
          title: Created Epoch
          default: 0.0
        level:
          type: string
          title: Level
        logger:
          type: string
          title: Logger
        event:
          type: string
          title: Event
        data:
          additionalProperties: true
          type: object
          title: Data
          default: {}
      additionalProperties: true
      type: object
      required:
      - timestamp
      - level
      - logger
      - event
      title: LogEntry
      description: A single log entry.
      examples:
      - data:
          text: hi
        event: speak
        level: INFO
        logger: api.commands
        timestamp: '2026-08-12T10:30:00Z'
        created_epoch: 1723461000.0
    LogsResponse:
      properties:
        count:
          type: integer
          title: Count
        entries:
          items:
            $ref: '#/components/schemas/LogEntry'
          type: array
          title: Entries
          default: []
      additionalProperties: true
      type: object
      required:
      - count
      title: LogsResponse
      description: Recent log entries.
      examples:
      - count: 2
        entries:
        - data:
            text: hi
          event: speak
          level: INFO
          logger: api.commands
          timestamp: '2026-08-12T10:30:00Z'
          created_epoch: 1723461000.0
    LogsFiltersResponse:
      properties:
        levels:
          items:
            type: string
          type: array
          title: Levels
          default: []
        loggers:
          items:
            type: string
          type: array
          title: Loggers
          default: []
        events:
          items:
            type: string
          type: array
          title: Events
          default: []
        noisy_events:
          items:
            type: string
          type: array
          title: Noisy Events
          default: []
          description: Server-configured event types hidden by default in the
            dashboard feed (LoggingConfig.noisy_events).
      additionalProperties: true
      type: object
      title: LogsFiltersResponse
      description: Distinct log levels, logger names, and event names in the
        buffer, plus the server-configured noisy-events hide list.
      examples:
      - levels:
        - DEBUG
        - INFO
        - WARNING
        - ERROR
        loggers:
        - api.commands
        - robot.behavior
        events:
        - speak
        - state_changed
        noisy_events:
        - DisplayUpdated
        - LookRequested
        - BlinkRequested
        - ServoMoved
        - IdleTimeout
        - LookAroundAction
        - FaceDetected
    MessageItem:
      properties:
        role:
          type: string
          title: Role
        content:
          type: string
          title: Content
      type: object
      required:
      - role
      - content
      title: MessageItem
      description: A single conversation message.
      examples:
      - content: Hello! Who are you?
        role: user
      - content: I'm DeskBot, your desktop companion!
        role: assistant
    MicLevelResponse:
      properties:
        level:
          anyOf:
          - type: number
          - type: 'null'
          title: Level
      additionalProperties: true
      type: object
      title: MicLevelResponse
      description: Current microphone RMS level.
      examples:
      - level: 0.18
    MicTestRequest:
      properties:
        duration_s:
          type: number
          maximum: 10.0
          minimum: 0.5
          title: Duration S
          default: 3.0
        play_back:
          type: boolean
          title: Play Back
          default: true
      additionalProperties: true
      type: object
      title: MicTestRequest
      description: Parameters for a microphone record-and-playback test.
      examples:
      - duration_s: 3.0
        play_back: true
    MicrophoneInfoResponse:
      properties:
        type:
          type: string
          title: Type
        sample_rate:
          anyOf:
          - type: integer
          - type: 'null'
          title: Sample Rate
        is_mock:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Is Mock
      additionalProperties: true
      type: object
      required:
      - type
      title: MicrophoneInfoResponse
      description: Microphone type and sample rate.
      examples:
      - is_mock: false
        sample_rate: 16000
        type: UsbMicrophone
    OkResponse:
      properties:
        status:
          type: string
          title: Status
          description: Outcome of the request.
          default: ok
        detail:
          anyOf:
          - type: string
          - type: 'null'
          title: Detail
          description: Optional human-readable detail.
      additionalProperties: true
      type: object
      title: OkResponse
      description: 'Generic ``{status: "ok"}`` acknowledgement.'
      examples:
      - status: ok
    PerceptionResponse:
      properties:
        enabled:
          type: boolean
          title: Enabled
        running:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Running
        scan_interval_s:
          anyOf:
          - type: number
          - type: 'null'
          title: Scan Interval S
        max_faces:
          anyOf:
          - type: integer
          - type: 'null'
          title: Max Faces
      additionalProperties: true
      type: object
      required:
      - enabled
      title: PerceptionResponse
      description: Perception (face detection) status.
      examples:
      - enabled: true
        max_faces: 3
        running: true
        scan_interval_s: 0.5
      - enabled: false
    PerformanceSummaryResponse:
      properties:
        frames:
          additionalProperties: true
          type: object
          title: Frames
          default: {}
        servos:
          additionalProperties: true
          type: object
          title: Servos
          default: {}
        bus:
          additionalProperties: true
          type: object
          title: Bus
          default: {}
      additionalProperties: true
      type: object
      title: PerformanceSummaryResponse
      description: Combined profiler summary.
      examples:
      - bus:
          avg_latency_ms: 0.4
          events_per_s: 120.0
        frames:
          actual_fps: 29.4
          avg_frame_time_ms: 34.0
          dropped_frames: 3
          p50_frame_time_ms: 33.0
          p95_frame_time_ms: 38.0
          p99_frame_time_ms: 42.0
          target_fps: 30
          total_frames: 1200
        servos:
          pan:
            avg_ms: 2.1
            count: 100
            max_ms: 5.0
    PreferenceDeleteResponse:
      properties:
        status:
          type: string
          title: Status
        key:
          type: string
          title: Key
      additionalProperties: true
      type: object
      required:
      - status
      - key
      title: PreferenceDeleteResponse
      description: Acknowledgement of a preference deletion.
      examples:
      - key: tts:voice
        status: deleted
    PreferenceItem:
      properties:
        key:
          type: string
          title: Key
        value:
          title: Value
        confidence:
          type: number
          title: Confidence
        source:
          type: string
          title: Source
        updated_at:
          type: string
          title: Updated At
      additionalProperties: true
      type: object
      required:
      - key
      - value
      - confidence
      - source
      - updated_at
      title: PreferenceItem
      description: A single user preference.
      examples:
      - confidence: 0.9
        key: tts:voice
        source: explicit
        updated_at: '2026-08-12T10:30:00Z'
        value: alloy
    PreferenceListResponse:
      properties:
        preferences:
          items:
            $ref: '#/components/schemas/PreferenceItem'
          type: array
          title: Preferences
      additionalProperties: true
      type: object
      required:
      - preferences
      title: PreferenceListResponse
      description: All stored preferences.
      examples:
      - preferences:
        - confidence: 0.9
          key: tts:voice
          source: explicit
          updated_at: '2026-08-12T10:30:00Z'
          value: alloy
    ReleaseAllResponse:
      properties:
        released:
          type: boolean
          title: Released
      additionalProperties: true
      type: object
      required:
      - released
      title: ReleaseAllResponse
      description: Acknowledgement of release-all command.
      examples:
      - released: true
    ServoInfo:
      properties:
        name:
          type: string
          title: Name
        angle:
          type: number
          title: Angle
      additionalProperties: true
      type: object
      required:
      - name
      - angle
      title: ServoInfo
      description: A single servo's name and current angle.
      examples:
      - angle: 90.0
        name: pan
    ServoListResponse:
      properties:
        servos:
          items:
            $ref: '#/components/schemas/ServoInfo'
          type: array
          title: Servos
      additionalProperties: true
      type: object
      required:
      - servos
      title: ServoListResponse
      description: All servos and their angles.
      examples:
      - servos:
        - angle: 90.0
          name: pan
        - angle: 90.0
          name: tilt
    ServoMoveResponse:
      properties:
        name:
          type: string
          title: Name
        angle:
          type: number
          title: Angle
        duration_s:
          type: number
          title: Duration S
      additionalProperties: true
      type: object
      required:
      - name
      - angle
      - duration_s
      title: ServoMoveResponse
      description: Acknowledgement of a servo move command.
      examples:
      - angle: 45.0
        duration_s: 0.4
        name: pan
    ServoProfilerStatsResponse:
      properties:
        enabled:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Enabled
      additionalProperties: true
      type: object
      title: ServoProfilerStatsResponse
      description: Per-servo latency statistics (free-form, keyed by servo name).
      examples:
      - pan:
          avg_ms: 2.1
          count: 100
          max_ms: 5.0
        tilt:
          avg_ms: 1.8
          count: 100
          max_ms: 4.2
      - enabled: false
    ServoReleaseResponse:
      properties:
        name:
          type: string
          title: Name
        released:
          type: boolean
          title: Released
      additionalProperties: true
      type: object
      required:
      - name
      - released
      title: ServoReleaseResponse
      description: Acknowledgement of a servo release command.
      examples:
      - name: pan
        released: true
    SettingsInfoResponse:
      properties:
        ready:
          type: boolean
          title: Ready
          default: false
      additionalProperties: true
      type: object
      title: SettingsInfoResponse
      description: Hardware & subsystem overview (free-form nested).
      examples:
      - audio:
          sample_rate: 48000
          type: UsbSpeaker
        camera:
          captured: 1024
          height: 480
          is_mock: false
          type: UsbCamera
          width: 640
        display:
          backend: gc9a01
          fps: 30
          height: 240
          rotation: 0
          width: 240
        microphone:
          sample_rate: 16000
          type: UsbMicrophone
        ready: true
        servos:
          count: 4
          servos:
          - angle: 90.0
            name: pan
      - ready: false
    SoundEffectResponse:
      properties:
        status:
          type: string
          title: Status
        name:
          anyOf:
          - type: string
          - type: 'null'
          title: Name
        error:
          anyOf:
          - type: string
          - type: 'null'
          title: Error
      additionalProperties: true
      type: object
      required:
      - status
      title: SoundEffectResponse
      description: Acknowledgement of a sound effect play.
      examples:
      - name: talk
        status: ok
      - error: not found
        name: unknown
        status: error
    SoundEffectsListResponse:
      properties:
        available:
          type: boolean
          title: Available
        effects:
          items:
            type: string
          type: array
          title: Effects
          default: []
      additionalProperties: true
      type: object
      required:
      - available
      title: SoundEffectsListResponse
      description: List of available sound effects.
      examples:
      - available: true
        effects:
        - talk
        - thinking
        - cute
      - available: false
        effects: []
    SpeakRequest:
      properties:
        text:
          type: string
          maxLength: 1000
          minLength: 1
          title: Text
          description: Text to speak.
      additionalProperties: true
      type: object
      required:
      - text
      title: SpeakRequest
      description: Request body for the speak command.
      examples:
      - text: Hello! How are you today?
    StateRequest:
      properties:
        state:
          type: string
          title: State
          description: Target state (idle, curious, listening, thinking, speaking, sleeping).
      additionalProperties: true
      type: object
      required:
      - state
      title: StateRequest
      description: Request body for the state transition command.
      examples:
      - state: curious
    StateResponse:
      properties:
        state:
          type: string
          title: State
          description: Robot state (idle, curious, listening, thinking, speaking, sleeping) or 'unknown'.
        detail:
          anyOf:
          - type: string
          - type: 'null'
          title: Detail
      additionalProperties: true
      type: object
      required:
      - state
      title: StateResponse
      description: Current robot state.
      examples:
      - state: idle
      - detail: DeskBot app not attached
        state: unknown
    SystemInfoResponse:
      properties:
        hostname:
          type: string
          title: Hostname
        platform:
          type: string
          title: Platform
        machine:
          type: string
          title: Machine
        processor:
          type: string
          title: Processor
        python_version:
          type: string
          title: Python Version
        cpu_count:
          type: integer
          title: Cpu Count
        uptime_s:
          type: number
          title: Uptime S
        uptime_human:
          type: string
          title: Uptime Human
        pid:
          type: integer
          title: Pid
        app_version:
          type: string
          title: App Version
        env:
          type: string
          title: Env
        health:
          additionalProperties: true
          type: object
          title: Health
          default: {}
      additionalProperties: true
      type: object
      required:
      - hostname
      - platform
      - machine
      - processor
      - python_version
      - cpu_count
      - uptime_s
      - uptime_human
      - pid
      - app_version
      - env
      title: SystemInfoResponse
      description: System information for the dashboard.
      examples:
      - app_version: 0.1.0
        cpu_count: 4
        env: production
        health:
          status: ok
        hostname: deskbot
        machine: aarch64
        pid: 12345
        platform: Linux-6.1.0-aarch64
        processor: aarch64
        python_version: 3.12.4
        uptime_human: 1h 0m
        uptime_s: 3600.5
    TTSTestRequest:
      properties:
        text:
          type: string
          title: Text
          default: Hello! This is a test of the text to speech system.
        direct:
          type: boolean
          title: Direct
          description: When True, speak directly via TTS (no LLM). When False, go through the LLM pipeline.
          default: true
      additionalProperties: true
      type: object
      title: TTSTestRequest
      description: Speak a test phrase through the TTS engine.
      examples:
      - direct: true
        text: Hello! This is a test of the text to speech system.
    TTSTestResponse:
      properties:
        status:
          type: string
          title: Status
        text:
          anyOf:
          - type: string
          - type: 'null'
          title: Text
        engine:
          anyOf:
          - type: string
          - type: 'null'
          title: Engine
        via:
          anyOf:
          - type: string
          - type: 'null'
          title: Via
      additionalProperties: true
      type: object
      required:
      - status
      title: TTSTestResponse
      description: Acknowledgement of a TTS test.
      examples:
      - engine: OpenAITTS
        status: ok
        text: Hello!
      - status: ok
        text: Hello!
        via: llm_pipeline
    TestPatternResponse:
      properties:
        pattern:
          type: string
          title: Pattern
        width:
          type: integer
          title: Width
        height:
          type: integer
          title: Height
      additionalProperties: true
      type: object
      required:
      - pattern
      - width
      - height
      title: TestPatternResponse
      description: Acknowledgement of a display test pattern.
      examples:
      - height: 240
        pattern: gradient
        width: 240
    ToneRequest:
      properties:
        frequency_hz:
          type: number
          maximum: 20000.0
          minimum: 20.0
          title: Frequency Hz
          default: 440.0
        duration_s:
          type: number
          maximum: 10.0
          minimum: 0.1
          title: Duration S
          default: 1.0
        volume:
          type: number
          maximum: 1.0
          minimum: 0.0
          title: Volume
          default: 0.5
      additionalProperties: true
      type: object
      title: ToneRequest
      description: Parameters for an audio test tone.
      examples:
      - duration_s: 1.0
        frequency_hz: 440.0
        volume: 0.5
    ToneResponse:
      properties:
        status:
          type: string
          title: Status
        frequency_hz:
          anyOf:
          - type: number
          - type: 'null'
          title: Frequency Hz
        duration_s:
          anyOf:
          - type: number
          - type: 'null'
          title: Duration S
        sample_rate:
          anyOf:
          - type: integer
          - type: 'null'
          title: Sample Rate
      additionalProperties: true
      type: object
      required:
      - status
      title: ToneResponse
      description: Acknowledgement of a test tone.
      examples:
      - duration_s: 1.0
        frequency_hz: 440.0
        sample_rate: 48000
        status: ok
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    VersionResponse:
      properties:
        version:
          type: string
          title: Version
        name:
          type: string
          title: Name
      additionalProperties: true
      type: object
      required:
      - version
      - name
      title: VersionResponse
      description: API name and version.
      examples:
      - name: DeskBot API
        version: 0.1.0
