{
 "name": "wait_for",
 "description": "Observe a typed condition immediately, then wait within timeout_ms. Returns the final typed value on timeout; unavailable metrics never satisfy a threshold.",
 "inputSchema": {
  "$defs": {
   "Condition": {
    "description": "Explicit condition language, rejecting unknown fields.",
    "oneOf": [
     {
      "additionalProperties": false,
      "description": "Wait for an output to reach a state.",
      "properties": {
       "output": {
        "$ref": "#/$defs/OutputName",
        "description": "Output selector."
       },
       "state": {
        "$ref": "#/$defs/OutputState",
        "description": "Desired state."
       },
       "type": {
        "const": "output_state",
        "type": "string"
       }
      },
      "required": [
       "type",
       "output",
       "state"
      ],
      "type": "object"
     },
     {
      "additionalProperties": false,
      "description": "Wait until a source exists and is active.",
      "properties": {
       "name": {
        "description": "Source name.",
        "type": "string"
       },
       "type": {
        "const": "source_active",
        "type": "string"
       }
      },
      "required": [
       "type",
       "name"
      ],
      "type": "object"
     },
     {
      "additionalProperties": false,
      "description": "Wait for a named media source's state.",
      "properties": {
       "name": {
        "description": "Source name.",
        "type": "string"
       },
       "state": {
        "$ref": "#/$defs/MediaState",
        "description": "Desired media state."
       },
       "type": {
        "const": "media_state",
        "type": "string"
       }
      },
      "required": [
       "type",
       "name",
       "state"
      ],
      "type": "object"
     },
     {
      "additionalProperties": false,
      "description": "Wait until a measured metric is at most the threshold.",
      "properties": {
       "metric": {
        "$ref": "#/$defs/Metric",
        "description": "Metric selector."
       },
       "type": {
        "const": "stat_at_most",
        "type": "string"
       },
       "value": {
        "description": "Maximum acceptable value, in the metric's units.",
        "format": "double",
        "type": "number"
       }
      },
      "required": [
       "type",
       "metric",
       "value"
      ],
      "type": "object"
     }
    ]
   },
   "MediaState": {
    "description": "libobs media state.",
    "oneOf": [
     {
      "const": "none",
      "description": "Not a controllable media source.",
      "type": "string"
     },
     {
      "const": "playing",
      "description": "Playing.",
      "type": "string"
     },
     {
      "const": "opening",
      "description": "Opening.",
      "type": "string"
     },
     {
      "const": "buffering",
      "description": "Buffering.",
      "type": "string"
     },
     {
      "const": "paused",
      "description": "Paused.",
      "type": "string"
     },
     {
      "const": "stopped",
      "description": "Stopped.",
      "type": "string"
     },
     {
      "const": "ended",
      "description": "Playback reached the end.",
      "type": "string"
     },
     {
      "const": "error",
      "description": "Playback failed.",
      "type": "string"
     }
    ]
   },
   "Metric": {
    "description": "A supported numeric metric, never an expression.",
    "oneOf": [
     {
      "const": "render_frame_time_ns",
      "description": "Average render duration.",
      "type": "string"
     },
     {
      "const": "render_frames_dropped",
      "description": "Render drops since baseline.",
      "type": "string"
     },
     {
      "const": "vcam_latency_max_ns",
      "description": "Camera maximum measured stage latency.",
      "type": "string"
     },
     {
      "const": "vmic_latency_max_ns",
      "description": "Microphone maximum measured stage latency.",
      "type": "string"
     },
     {
      "const": "vmic_xruns",
      "description": "Microphone xruns, if measured.",
      "type": "string"
     },
     {
      "const": "av_offset_abs_ms",
      "description": "Absolute independently measured sync offset.",
      "type": "string"
     }
    ]
   },
   "OutputName": {
    "description": "An output controlled by OBS.",
    "oneOf": [
     {
      "const": "record",
      "description": "Recording.",
      "type": "string"
     },
     {
      "const": "stream",
      "description": "Streaming.",
      "type": "string"
     },
     {
      "const": "vcam",
      "description": "Virtual Camera.",
      "type": "string"
     },
     {
      "const": "vmic",
      "description": "Paired virtual microphone.",
      "type": "string"
     }
    ]
   },
   "OutputState": {
    "description": "Desired output state.",
    "oneOf": [
     {
      "const": "active",
      "description": "Running.",
      "type": "string"
     },
     {
      "const": "inactive",
      "description": "Stopped.",
      "type": "string"
     }
    ]
   }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "One wait request.",
  "properties": {
   "condition": {
    "$ref": "#/$defs/Condition",
    "description": "Condition to observe before waiting."
   },
   "timeout_ms": {
    "default": 5000,
    "description": "Deadline in milliseconds; zero still observes once.",
    "format": "uint64",
    "minimum": 0,
    "type": "integer"
   }
  },
  "required": [
   "condition"
  ],
  "title": "WaitInput",
  "type": "object"
 },
 "outputSchema": {
  "$defs": {
   "LastValue": {
    "description": "Typed final observation, including unavailable measurements.",
    "oneOf": [
     {
      "description": "Output observation.",
      "properties": {
       "active": {
        "description": "Null if the output state cannot be queried.",
        "type": [
         "boolean",
         "null"
        ]
       },
       "kind": {
        "const": "output",
        "type": "string"
       }
      },
      "required": [
       "kind"
      ],
      "type": "object"
     },
     {
      "description": "Source observation.",
      "properties": {
       "active": {
        "description": "Whether it is active.",
        "type": "boolean"
       },
       "kind": {
        "const": "source",
        "type": "string"
       },
       "present": {
        "description": "Whether the source exists.",
        "type": "boolean"
       }
      },
      "required": [
       "kind",
       "present",
       "active"
      ],
      "type": "object"
     },
     {
      "description": "Media observation.",
      "properties": {
       "kind": {
        "const": "media",
        "type": "string"
       },
       "state": {
        "anyOf": [
         {
          "$ref": "#/$defs/MediaState"
         },
         {
          "type": "null"
         }
        ],
        "description": "Null if the named source is absent."
       }
      },
      "required": [
       "kind"
      ],
      "type": "object"
     },
     {
      "description": "Numeric observation.",
      "properties": {
       "kind": {
        "const": "stat",
        "type": "string"
       },
       "metric": {
        "$ref": "#/$defs/Metric",
        "description": "Metric selector."
       },
       "value": {
        "description": "Null if unavailable; never satisfies a threshold.",
        "format": "double",
        "type": [
         "number",
         "null"
        ]
       }
      },
      "required": [
       "kind",
       "metric"
      ],
      "type": "object"
     }
    ]
   },
   "MediaState": {
    "description": "libobs media state.",
    "oneOf": [
     {
      "const": "none",
      "description": "Not a controllable media source.",
      "type": "string"
     },
     {
      "const": "playing",
      "description": "Playing.",
      "type": "string"
     },
     {
      "const": "opening",
      "description": "Opening.",
      "type": "string"
     },
     {
      "const": "buffering",
      "description": "Buffering.",
      "type": "string"
     },
     {
      "const": "paused",
      "description": "Paused.",
      "type": "string"
     },
     {
      "const": "stopped",
      "description": "Stopped.",
      "type": "string"
     },
     {
      "const": "ended",
      "description": "Playback reached the end.",
      "type": "string"
     },
     {
      "const": "error",
      "description": "Playback failed.",
      "type": "string"
     }
    ]
   },
   "Metric": {
    "description": "A supported numeric metric, never an expression.",
    "oneOf": [
     {
      "const": "render_frame_time_ns",
      "description": "Average render duration.",
      "type": "string"
     },
     {
      "const": "render_frames_dropped",
      "description": "Render drops since baseline.",
      "type": "string"
     },
     {
      "const": "vcam_latency_max_ns",
      "description": "Camera maximum measured stage latency.",
      "type": "string"
     },
     {
      "const": "vmic_latency_max_ns",
      "description": "Microphone maximum measured stage latency.",
      "type": "string"
     },
     {
      "const": "vmic_xruns",
      "description": "Microphone xruns, if measured.",
      "type": "string"
     },
     {
      "const": "av_offset_abs_ms",
      "description": "Absolute independently measured sync offset.",
      "type": "string"
     }
    ]
   }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Final wait result.",
  "properties": {
   "elapsed_ms": {
    "description": "Monotonic elapsed time.",
    "format": "uint64",
    "minimum": 0,
    "type": "integer"
   },
   "last_value": {
    "$ref": "#/$defs/LastValue",
    "description": "Last observed value, including on timeout."
   },
   "satisfied": {
    "description": "Condition met before the deadline.",
    "type": "boolean"
   }
  },
  "required": [
   "satisfied",
   "elapsed_ms",
   "last_value"
  ],
  "title": "WaitOutput",
  "type": "object"
 },
 "annotations": {
  "destructiveHint": false,
  "idempotentHint": true,
  "openWorldHint": false,
  "readOnlyHint": true
 }
}