### Quick Start: OWA Release Manager CLI Commands Source: https://github.com/open-world-agents/ocap/blob/main/scripts/README.md Provides quick start examples for using the OWA Release Manager CLI. These commands cover updating package versions, publishing to PyPI, and updating lock files. Ensure you have the necessary environment variables (like PYPI_TOKEN) set for publishing. ```bash # Update all packages to version 1.0.0 with tagging vuv run scripts/release/main.py version 1.0.0 # Publish to PyPI export PYPI_TOKEN=your_token_here vuv run scripts/release/main.py publish # Update lock files vuv run scripts/release/main.py lock --upgrade ``` -------------------------------- ### Configure and Start Keyboard Listener Source: https://context7.com/open-world-agents/ocap/llms.txt Demonstrates how to configure a keyboard listener with a callback function and start its operation. It also shows how to perform a clean shutdown by stopping and joining the listener. ```python # Configure and start listener keyboard_listener = LISTENERS["desktop/keyboard"]().configure( callback=keyboard_callback ) keyboard_listener.start() # Process events in background thread... # Clean shutdown keyboard_listener.stop() keyboard_listener.join(timeout=5) ``` -------------------------------- ### Python Resource Setup with RecordingContext Source: https://context7.com/open-world-agents/ocap/llms.txt Shows the basic setup for recording resources using the `setup_resources` function and `RecordingContext` in the OCAP Python API. This pattern is used for managing the lifecycle of recording components. ```python from owa.ocap.recorder import setup_resources, RecordingContext from pathlib import Path context = RecordingContext(Path("output.mcap")) ``` -------------------------------- ### OCAP Installation and Testing (Bash) Source: https://context7.com/open-world-agents/ocap/llms.txt Provides bash commands for installing OCAP using conda and pip, verifying the installation by checking the version, and testing recording functionality with a specified duration. ```bash # Install with conda and pip conda install open-world-agents::gstreamer-bundle pip install ocap # Verify installation ocap --version # Test recording ocap test-recording --stop-after 10 ``` -------------------------------- ### Basic ocap Recording Commands Source: https://github.com/open-world-agents/ocap/blob/main/README.md Demonstrates basic usage of the ocap command-line tool for starting recordings and accessing help. Recordings can be stopped with Ctrl+C. ```shell # Start recording (stop with Ctrl+C) $ ocap my-recording # Show all options $ ocap --help ``` -------------------------------- ### CLI Basic Recording with OCAP Source: https://context7.com/open-world-agents/ocap/llms.txt Starts a basic desktop recording session using the OCAP command-line interface. The recording will continue until interrupted (Ctrl+C) and will output event logs and synchronized video/audio files. ```bash # Start basic recording (stop with Ctrl+C) ocap my-recording # Output files created: # - my-recording.mcap (event log: keyboard, mouse, window events) # - my-recording.mkv (video/audio with embedded timestamps) ``` -------------------------------- ### Setup Resources and Recorder with Automatic Cleanup (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Sets up essential recording resources like recorder, keyboard, and mouse listeners, ensuring automatic cleanup upon exit or exception. It uses a context manager for resource management and supports various recording options. ```python from owa.ocap.recorder import setup_resources # Assuming 'context' is an initialized RecordingContext object # context = RecordingContext(Path("recording.mcap")) with setup_resources( context=context, record_audio=True, record_video=True, record_timestamp=True, show_cursor=True, fps=60.0, window_name=None, monitor_idx=None, width=None, height=None, additional_properties={} ) as resources: # Resources now active: # - recorder (GStreamer omnimodal) # - keyboard_listener # - mouse_listener # - raw_mouse_listener # - window_listener # - keyboard_state_listener # - mouse_state_listener # All listeners configured with callbacks that enqueue events # Process events here... # Automatic cleanup on exit or exception # All resources stopped in reverse order with 5-second timeout ``` -------------------------------- ### Get Local and Latest Version Information with Python Source: https://context7.com/open-world-agents/ocap/llms.txt Retrieves the local installed version of the 'ocap' package and the latest available version from GitHub releases. It utilizes utility functions from the 'owa.ocap.utils' module. The output displays both versions for comparison. ```python from owa.ocap.utils import get_local_version, get_latest_release local_ver = get_local_version("ocap") print(f"Installed version: {local_ver}") # "0.6.1.post1" latest_ver = get_latest_release( "https://api.github.com/repos/open-world-agents/ocap/releases/latest" ) print(f"Latest version: {latest_ver}") # "0.6.2" ``` -------------------------------- ### Install ocap Package Source: https://github.com/open-world-agents/ocap/blob/main/README.md Installs the ocap package and its GStreamer dependencies using conda and pip. Ensure GStreamer dependencies are installed first, especially for video recording. ```shell # Install GStreamer dependencies first (for video recording) $ conda install open-world-agents::gstreamer-bundle # Install ocap $ pip install ocap ``` -------------------------------- ### CLI Advanced Recording: Delayed Start and Auto-Stop Source: https://context7.com/open-world-agents/ocap/llms.txt Configures advanced recording options in OCAP CLI, including a delayed start and an automatic stop timer. Also includes options to disable health monitoring and pass custom GStreamer pipeline arguments. ```bash # Advanced: delayed start and auto-stop ocap recording --start-after 5 --stop-after 60 # Waits 5 seconds before starting, automatically stops after 60 seconds # Disable health monitoring ocap recording --health-check-interval 0 # Pass custom GStreamer pipeline properties ocap recording --additional-args "gop-size=30,bitrate=8000" ``` -------------------------------- ### Full Recording Workflow with File Preparation and Error Handling (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt A comprehensive example showing the integration of `ensure_output_files_ready` within a full recording workflow, including error handling for user cancellations (e.g., declining to overwrite files). It confirms the final output file paths for MCAP and MKV. ```python from pathlib import Path import typer # Assuming 'ensure_output_files_ready' is imported and available try: file_location = Path("output/my-recording") output_file = ensure_output_files_ready(file_location) # output_file is now Path('output/my-recording.mcap') # Directory 'output/' has been created # Any existing files have been removed (with user confirmation) print(f"Ready to record to: {output_file}") print(f"Video will be saved to: {output_file.with_suffix('.mkv')}") except typer.Abort: # User declined to overwrite existing files print("Recording cancelled by user") ``` -------------------------------- ### Conda Environment Setup (environment.yml) Source: https://context7.com/open-world-agents/ocap/llms.txt Defines a Conda environment named 'owa' specifying the Python version and required packages, including the gstreamer-bundle from the open-world-agents channel. ```yaml # environment.yml - Conda environment setup name: owa channels: - open-world-agents - conda-forge dependencies: - python=3.11 - open-world-agents::gstreamer-bundle ``` -------------------------------- ### Python RecordingContext Multiple Event Sources Source: https://context7.com/open-world-agents/ocap/llms.txt Illustrates how to handle multiple event sources (keyboard, mouse, screen) feeding into a single `RecordingContext` event queue in OCAP Python API. It includes an example of adjusting media references for screen events. ```python # Multiple event sources feeding into single queue def keyboard_callback(event): context.enqueue_event(event, topic="keyboard") def mouse_callback(event): context.enqueue_event(event, topic="mouse") def screen_callback(event): # Adjust media reference to be relative path relative_path = Path(event.media_ref.uri).relative_to( context.mcap_location.parent ).as_posix() event.media_ref = MediaRef(uri=relative_path, pts_ns=event.media_ref.pts_ns) context.enqueue_event(event, topic="screen") # All events flow through the same queue for synchronized processing ``` -------------------------------- ### Configure GStreamer Omnimodal Recorder Source: https://context7.com/open-world-agents/ocap/llms.txt Configures a GStreamer-based omnimodal recorder for video and audio capture with hardware acceleration. It specifies output file, recording options, and GStreamer pipeline properties, then starts and stops the recorder. ```python from owa.core import LISTENERS from pathlib import Path # Instantiate GStreamer omnimodal recorder recorder = LISTENERS["gst/omnimodal.appsink_recorder"]() # Configure with all options recorder.configure( filesink_location=Path("output.mkv"), # Video output file record_audio=True, # Enable audio capture record_video=True, # Enable video capture record_timestamp=True, # Embed PTS timestamps show_cursor=True, # Render mouse cursor fps=60.0, # Frame rate window_name="Minecraft", # Specific window (optional) monitor_idx=None, # Specific monitor (optional) width=1920, # Video width (optional) height=1080, # Video height (optional) additional_properties={ "gop-size": "30", "bitrate": "8000" }, callback=screen_callback # Screen event callback ) # Start recording recorder.start() # Stop and cleanup recorder.stop() recorder.join(timeout=5) ``` -------------------------------- ### Python API Automated Recording with Timing Control Source: https://context7.com/open-world-agents/ocap/llms.txt Sets up automated recording using the OCAP Python API with precise timing controls for delayed start and automatic stop. This function also allows disabling audio recording and setting resource health check intervals. ```python # Automated recording with timing control record( file_location=Path("automated-capture.mcap"), start_after=10.0, # Wait 10 seconds before starting stop_after=120.0, # Automatically stop after 2 minutes health_check_interval=5.0, # Check resource health every 5 seconds record_audio=False, # Video only fps=60.0 ) # No user interaction needed - fully automated ``` -------------------------------- ### Discover and Use Plugins with Python Source: https://context7.com/open-world-agents/ocap/llms.txt Shows how to discover available listeners and callables from the OWA plugin system using 'owa.core'. It demonstrates listing available listeners and callables, instantiating specific listeners, calling functions via the CALLABLES registry, and checking for the successful loading of required plugins. ```python from owa.core import LISTENERS, CALLABLES, get_plugin_discovery # Get all available listeners print(LISTENERS.keys()) # Output: ['desktop/keyboard', 'desktop/mouse', 'desktop/window', # 'desktop/keyboard_state', 'desktop/mouse_state', 'desktop/raw_mouse', # 'gst/omnimodal.appsink_recorder', ...] # Instantiate specific listener keyboard_listener = LISTENERS["desktop/keyboard"]() mouse_listener = LISTENERS["desktop/mouse"]() recorder = LISTENERS["gst/omnimodal.appsink_recorder"]() # Get all available callables print(CALLABLES.keys()) # Output: ['desktop/mouse.get_pointer_ballistics_config', # 'desktop/keyboard.get_keyboard_repeat_timing', ...] # Call specific function config = CALLABLES["desktop/mouse.get_pointer_ballistics_config"]() ``` ```python # Check if required plugins are loaded plugin_discovery = get_plugin_discovery() success, failed = plugin_discovery.get_plugin_info(["desktop", "gst"]) if len(success) != 2: print(f"Failed to load plugins: {failed}") # Handle missing dependencies else: print("All required plugins loaded successfully") ``` -------------------------------- ### Full Recording Workflow with Resource Management (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Demonstrates a complete recording process using Ocap, including setting up resources, writing environment metadata, and running the main recording loop with optional auto-stop and health check intervals. It utilizes OWAMcapWriter for MCAP file handling. ```python from owa.ocap.recorder import ( RecordingContext, setup_resources, _run_recording_loop, _record_environment_metadata ) from mcap_owa.highlevel import OWAMcapWriter from pathlib import Path context = RecordingContext(Path("recording.mcap")) with setup_resources( context=context, record_audio=True, record_video=True, record_timestamp=True, show_cursor=True, fps=60.0, window_name=None, monitor_idx=None, width=None, height=None, additional_properties={} ) as resources: with OWAMcapWriter(context.mcap_location) as writer: # Record system metadata (mouse ballistics, keyboard timing) _record_environment_metadata(writer) # Main recording loop with health checks _run_recording_loop( context=context, writer=writer, resources=resources, stop_after=60.0, # Auto-stop after 60 seconds health_check_interval=5.0 ) # Output files automatically saved: # - recording.mcap (events) # - recording.mkv (video/audio) ``` -------------------------------- ### Advanced ocap Recording Options Source: https://github.com/open-world-agents/ocap/blob/main/README.md Illustrates advanced command-line options for ocap, allowing users to specify the output filename, record a specific window by name, select a monitor by index, set the framerate, or disable audio recording. ```shell # Advanced options $ ocap FILENAME --window-name "App" # Record specific window $ ocap FILENAME --monitor-idx 1 # Record specific monitor $ ocap FILENAME --fps 60 # Set framerate $ ocap FILENAME --no-record-audio # Disable audio ``` -------------------------------- ### Release Workflow Automation with OWA Release Manager Source: https://github.com/open-world-agents/ocap/blob/main/scripts/README.md Demonstrates automating the release workflow using the OWA Release Manager script. This includes version updates with tagging and pushing, followed by publishing packages. Assumes a pre-existing Git branch strategy. ```bash $ vuv run scripts/release/main.py version $VERSION --tag --push $ vuv run scripts/release/main.py publish ``` -------------------------------- ### Python API Basic Recording Source: https://context7.com/open-world-agents/ocap/llms.txt Initiates a basic recording session programmatically using the OCAP Python API. Allows configuration of output file location, audio/video recording, cursor visibility, and frame rate. ```python from pathlib import Path from owa.ocap import record # Basic recording record( file_location=Path("my-recording.mcap"), record_audio=True, record_video=True, show_cursor=True, fps=60.0 ) # Stop with Ctrl+C or use stop_after parameter ``` -------------------------------- ### Python API Advanced Recording with Window Capture Source: https://context7.com/open-world-agents/ocap/llms.txt Provides advanced configuration for programmatic recording using OCAP Python API, including capturing a specific window, setting resolution, and passing custom GStreamer arguments. Enables fine-grained control over recording parameters. ```python # Advanced configuration with window capture record( file_location=Path("output/game-recording.mcap"), window_name="Minecraft", # Capture specific window fps=30.0, width=1920, height=1080, record_timestamp=True, show_cursor=True, additional_args="gop-size=30,bitrate=10000" # GStreamer options ) ``` -------------------------------- ### Prepare Output Files for Recording (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Ensures that the output directory and files for recording are ready. This function creates necessary directories and handles potential conflicts with existing files by prompting the user for confirmation before overwriting. ```python from pathlib import Path from owa.ocap.recorder import ensure_output_files_ready # Prepare output files (creates directories, handles overwrites) output_file = ensure_output_files_ready(Path("recordings/session1")) # Returns: Path('recordings/session1.mcap') # Creates: recordings/ directory if it doesn't exist # Checks: for existing .mcap and .mkv files # Prompts: user for confirmation if files exist ``` -------------------------------- ### Configure Various Desktop Event Listeners Source: https://context7.com/open-world-agents/ocap/llms.txt Shows the configuration of multiple desktop event listeners including mouse, window change, mouse state, keyboard state, and raw mouse input. Each listener is configured with a lambda function to enqueue events to specific topics. ```python # Mouse listener with simple lambda callback mouse_listener = LISTENERS["desktop/mouse"]().configure( callback=lambda event: context.enqueue_event(event, topic="mouse") ) # Window change listener window_listener = LISTENERS["desktop/window"]().configure( callback=lambda event: context.enqueue_event(event, topic="window") ) # Mouse state (button presses) mouse_state_listener = LISTENERS["desktop/mouse_state"]().configure( callback=lambda event: context.enqueue_event(event, topic="mouse/state") ) # Keyboard state (Ctrl, Shift, Alt) keyboard_state_listener = LISTENERS["desktop/keyboard_state"]().configure( callback=lambda event: context.enqueue_event(event, topic="keyboard/state") ) # Raw mouse input (high-precision data) raw_mouse_listener = LISTENERS["desktop/raw_mouse"]().configure( callback=lambda event: context.enqueue_event(event, topic="mouse/raw") ) ``` -------------------------------- ### Python RecordingContext Event Queue Management Source: https://context7.com/open-world-agents/ocap/llms.txt Demonstrates the use of `RecordingContext` in OCAP Python API for managing captured events. It shows how to create a context, access the thread-safe event queue, and enqueue events with associated topics and timestamps. ```python from pathlib import Path from queue import Queue from owa.ocap.recorder import RecordingContext # Create recording context context = RecordingContext(mcap_location=Path("output.mcap")) # Context automatically creates thread-safe event queue print(f"Event queue: {context.event_queue}") # Queue object print(f"Output: {context.mcap_location}") # Path('output.mcap') # Enqueue events from listeners (called by callbacks) # Events are stored with nanosecond-precision timestamps context.enqueue_event( event=keyboard_event, # Event object from listener topic="keyboard" # Event category ) # Internally: queue.put((topic, event, time.time_ns())) ``` -------------------------------- ### OCAP Project Dependencies (pyproject.toml) Source: https://context7.com/open-world-agents/ocap/llms.txt Defines the project metadata and dependencies for the OCAP package using the pyproject.toml file. It specifies project name, version, description, Python requirements, and a list of required packages including owa components and utilities. ```toml # pyproject.toml [project] name = "ocap" version = "0.6.1.post1" description = "High-performance, omnimodal desktop recorder for Windows" requires-python = ">=3.11" dependencies = [ "loguru>=0.7.3", "mcap-owa-support==0.6.1", "owa-core==0.6.1", "owa-env-desktop==0.6.1", "owa-env-gst==0.6.1", "owa-msgs==0.6.1", "tqdm>=4.67.1", "typer>=0.19.2", ] [project.scripts] ocap = "owa.ocap.recorder:main" ``` -------------------------------- ### CLI Recording Specific Window or Monitor Source: https://context7.com/open-world-agents/ocap/llms.txt Configures OCAP CLI to record from a specific window by name or a particular monitor using its index. Allows for targeted capture scenarios. ```bash # Record specific window by name (substring matching) ocap recording --window-name "Visual Studio Code" # Record specific monitor ocap recording --monitor-idx 1 ``` -------------------------------- ### CLI Recording with Custom Frame Rate and Options Source: https://context7.com/open-world-agents/ocap/llms.txt Customizes OCAP recording via CLI by setting a specific frame rate, disabling audio, or excluding the cursor from the video output. Useful for optimizing recording parameters. ```bash # Custom frame rate (default is 60 fps) ocap recording --fps 30 # Disable audio recording ocap recording --no-record-audio # Disable cursor in video ocap recording --no-show-cursor ``` -------------------------------- ### CLI Recording with Custom Video Dimensions Source: https://context7.com/open-world-agents/ocap/llms.txt Sets custom video dimensions (width and height) for the OCAP recording session via the command line. This is useful for controlling the resolution of the captured video. ```bash # Custom video dimensions ocap recording --width 1280 --height 720 ``` -------------------------------- ### Write Events to MCAP File using OWAMcapWriter in Python Source: https://context7.com/open-world-agents/ocap/llms.txt Demonstrates how to store events with metadata in the OWAMcap format using 'OWAMcapWriter' from 'mcap_owa.highlevel'. It includes writing environment metadata like pointer ballistics and keyboard timing, and then writing timestamped events (keyboard and mouse) to the MCAP file. The writer automatically finalizes the file upon exiting the context. ```python from mcap_owa.highlevel import OWAMcapWriter from pathlib import Path from owa.core import CALLABLES import time # Write events to MCAP file with OWAMcapWriter(Path("recording.mcap")) as writer: # Write environment metadata (system configuration) pointer_config = CALLABLES["desktop/mouse.get_pointer_ballistics_config"]() keyboard_timing = CALLABLES["desktop/keyboard.get_keyboard_repeat_timing"]( return_seconds=False ) writer.write_metadata( "pointer_ballistics_config", {str(k): str(v) for k, v in pointer_config.model_dump(by_alias=True).items()} ) writer.write_metadata( "keyboard_repeat_timing", {str(k): str(v) for k, v in keyboard_timing.items()} ) # Write events with nanosecond timestamps writer.write_message( event=keyboard_event, # Assuming keyboard_event is defined elsewhere topic="keyboard", timestamp=time.time_ns() ) writer.write_message( event=mouse_event, # Assuming mouse_event is defined elsewhere topic="mouse", timestamp=time.time_ns() ) # File automatically finalized on context exit ``` -------------------------------- ### Parse GStreamer Pipeline Arguments with Python Source: https://context7.com/open-world-agents/ocap/llms.txt Parses GStreamer pipeline arguments from a comma-separated string of key=value pairs into a dictionary. The 'parse_additional_properties' function from 'owa.ocap.utils' handles this conversion, supporting single properties and None input. The resulting dictionary can be used to configure GStreamer recorders. ```python from owa.ocap.utils import parse_additional_properties # Parse comma-separated key=value pairs args = parse_additional_properties("gop-size=30,bitrate=8000,preset=fast") print(args) # Output: {'gop-size': '30', 'bitrate': '8000', 'preset': 'fast'} # Use with GStreamer recorder configuration recorder.configure( filesink_location=Path("output.mkv"), additional_properties=args, # ...other options ) ``` ```python # Handle None input args = parse_additional_properties(None) print(args) # Output: {} # Single property args = parse_additional_properties("quality=high") print(args) # Output: {'quality': 'high'} ``` -------------------------------- ### Configure Keyboard Event Listener with Callback in Python Source: https://context7.com/open-world-agents/ocap/llms.txt Configures a keyboard event listener with a custom callback function. This callback detects presses of F1-F12 keys and prints a message indicating which F-key was pressed. It also demonstrates enqueuing the event for MCAP writing, assuming a 'context' object with an 'enqueue_event' method is available. ```python from owa.core import LISTENERS # Keyboard listener with F-key detection def keyboard_callback(event): # Detect F1-F12 keys (virtual key codes 0x70-0x7B) if 0x70 <= event.vk <= 0x7B and event.event_type == "press": f_key_number = event.vk - 0x70 + 1 print(f"F{f_key_number} key pressed") # Enqueue event for MCAP writing context.enqueue_event(event, topic="keyboard") # Assuming 'context' is available # To use this callback, you would typically instantiate the listener and assign the callback: # keyboard_listener = LISTENERS["desktop/keyboard"]() # keyboard_listener.set_callback(keyboard_callback) ``` -------------------------------- ### Mermaid Diagram for ocap Technical Architecture Source: https://github.com/open-world-agents/ocap/blob/main/README.md A Mermaid diagram illustrating the technical architecture of ocap, showing the flow of input sources (desktop environment, GStreamer) through core processing (event queue, video/audio pipeline) to output files (MCAP writer, MKV pipeline). ```mermaid flowchart TD %% Input Sources A[owa.env.desktop] --> B[Keyboard Events] A --> C[Mouse Events] A --> D[Window Events] E[owa.env.gst] --> F[Screen Capture] E --> G[Audio Capture] %% Core Processing B --> H[Event Queue] C --> H D --> H F --> H F --> I[Video/Audio Pipeline] G --> I %% Outputs H --> J[MCAP Writer] I --> K[MKV Pipeline] %% Files J --> L[📄 events.mcap] K --> M[🎥 video.mkv] style A fill:#e1f5fe style E fill:#e1f5fe style H fill:#fff3e0 style L fill:#e8f5e8 style M fill:#e8f5e8 ``` -------------------------------- ### Check for Software Updates on GitHub (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Checks for the latest release of the 'ocap' package on GitHub to notify the user if an update is available. The `silent` parameter controls whether a notification is displayed even if the package is up-to-date. ```python from owa.ocap.utils import check_for_update # Check for updates (prints notification if available) is_up_to_date = check_for_update( package_name="ocap", silent=False, # Show update notification url="https://api.github.com/repos/open-world-agents/ocap/releases/latest" ) if not is_up_to_date: print("Please update to the latest version") else: print("You're running the latest version") # Returns: True if up-to-date, False if update available ``` -------------------------------- ### Check for Silent Updates using Python Source: https://context7.com/open-world-agents/ocap/llms.txt Checks if the 'ocap' package is up-to-date silently. If an update is available, it prints a notification to the console. This function is useful for background update checks without user interaction. ```python is_up_to_date = check_for_update(package_name="ocap", silent=True) if not is_up_to_date: # Handle update notification in custom way print("Update available at https://github.com/open-world-agents/ocap/releases") ``` -------------------------------- ### Health Monitoring of Recording Resources (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Checks the health status of recording resources such as the recorder, keyboard listener, and mouse listener. It returns a list of names of unhealthy resources, allowing for prompt action in case of failures. ```python from owa.ocap.recorder import check_resources_health # Assuming 'recorder', 'keyboard_listener', 'mouse_listener' are initialized resources # Resources list contains tuples of (resource, name) resources = [ (recorder, "recorder"), (keyboard_listener, "keyboard listener"), (mouse_listener, "mouse listener"), ] # Check if all resources are alive unhealthy = check_resources_health(resources) if unhealthy: print(f"Unhealthy resources: {', '.join(unhealthy)}") # Take action: stop recording, alert user, etc. else: print("All resources healthy") # Returns: [] if all healthy, or list of unhealthy resource names ``` -------------------------------- ### Implement Countdown Delay with Python Source: https://context7.com/open-world-agents/ocap/llms.txt Implements a countdown delay before an action begins, such as recording. The 'countdown_delay' function from 'owa.ocap.utils' displays a visual countdown for delays longer than 3 seconds and performs a silent wait for shorter durations. Zero or negative delays result in immediate execution. ```python from owa.ocap.utils import countdown_delay # Wait 5 seconds with countdown display countdown_delay(5.0) # Output: # ⏱️ Recording will start in 5.0 seconds... # Starting in 5... # Starting in 4... # Starting in 3... # Starting in 2... # Starting in 1... # 🎬 Recording started! # Then proceed with recording... ``` ```python # Short delay (< 3 seconds) - no countdown countdown_delay(1.5) # Output: # ⏱️ Recording will start in 1.5 seconds... # (waits 1.5 seconds silently) # 🎬 Recording started! # Zero or negative delay - no wait countdown_delay(0) # (returns immediately, no output) ``` -------------------------------- ### Resource Health Check Integration in Recording Loop (Python) Source: https://context7.com/open-world-agents/ocap/llms.txt Integrates periodic health monitoring into the main recording loop. It checks resource health at a specified interval and terminates the recording if any resource is found to be unhealthy, ensuring robust operation. ```python import time # Assuming 'resources' and 'logger' are defined # resources = [...] # List of resources to monitor # logger = ... # Logger instance recording_start = time.time() last_health_check = time.time() health_check_interval = 5.0 # Check every 5 seconds while True: # Periodic health monitoring if (time.time() - last_health_check) >= health_check_interval: unhealthy = check_resources_health(resources) if unhealthy: logger.error(f"Unhealthy resources: {', '.join(unhealthy)}") break # Terminate recording last_health_check = time.time() # Process events... # Automatic termination on resource failure ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.