open-codex-computer-use

repository·main·Indexed 23 days ago

https://github.com/ifuryst/open-codex-computer-use

An open-source Computer Use service implemented as a Model Context Protocol (MCP) server. It enables AI agents to interact with macOS, Linux, and Windows environments via accessibility and screen recording. The project includes tools for state collection, coordinate clicking with AX hit-test and HID fallback, and a CLI for invoking tools. It also features reverse engineering research into Codex Computer Use, including cursor motion simulations and traffic analysis tools.

Tokens
66.4K
Snippets
115
Records
362
Agent score
80%

What's inside open-codex-computer-use

  1. Overview of Codex Computer Use Reverse Engineering

    main

    This directory serves as a repository for the ongoing reverse engineering analysis of the official closed-source Codex Computer Use.app and SkyComputerUseClient. The goal is to provide traceable inputs for the open-source open-computer-use implementation by documenting confirmed technical details rather than relying on chat histories.

    Key areas of research include:

    • Architecture & Runtime: Bundle structures, entry points, transport layers, host dependencies, and runtime behaviors.
    • IPC & Lifecycle: Internal client-service IPC types, sender authorization, the skyshot model, and turn-ended lifecycle integration.
    • Tooling & Interaction: Request/response samples for computer-use tools, background click-free tooling methodologies, and permission onboarding (Accessibility/Screen Recording).
    • Software Cursor Implementation: Analysis of the yellow virtual mouse overlay, cursor motion parameter models (including CursorMotionPath.sample(progress), SpringAnimation -> VelocityVerletSimulation timing chains, and geometric scoring), and slider parameter mapping.
    • State Rendering: Analysis of state renderer strings, AX fields, tree transforms, and window recovery clues used to converge state outputs for Lark/Electron apps.
  2. Supply Chain Security Controls and Tooling

    main

    The project implements several supply chain security controls to ensure dependency integrity and artifact provenance. The following tools and actions are used:

    • Dependency Review: Uses actions/dependency-review-action to block Pull Requests that introduce high-risk dependency changes.
    • Vulnerability Scanning: Uses google/osv-scanner-action to scan dependency declarations and lockfiles against known vulnerabilities using OSV.
    • SBOM Generation: Uses anchore/sbom-action to generate Software Bill of Materials (SBOM) in SPDX format for release artifacts.
    • Build Provenance: Uses actions/attest-build-provenance to generate signed provenance attestations for release artifacts.
    • Security Posture Analysis: Uses ossf/scorecard-action to analyze repository-level security signals (e.g., workflow permissions, branch protection).
    • Action Pinning: Uses scripts/check-action-pinning.sh to ensure all GitHub Actions are pinned to immutable commit SHAs rather than floating version tags. If a floating tag is detected, the CI will fail.
  3. Understand the Open Computer Use architecture and components

    main

    The project is a local computer-use implementation designed to provide automation capabilities across different operating systems. The core is a Swift-based macOS automation MCP server, with experimental Windows and Linux runtimes implemented in Go that expose the same set of 9 Computer Use tools.

    Core Components by Platform

    • macOS: Managed via apps/OpenComputerUse, which serves as the main entry point for CLI commands and the macOS app mode. It handles permissions and provides a GUI onboarding window if permissions are missing.
    • Windows (Experimental): Managed via apps/OpenComputerUseWindows. It uses a Go CLI/MCP entry point with a PowerShell UI Automation bridge, producing an open-computer-use.exe binary.
    • Linux (Experimental): Managed via apps/OpenComputerUseLinux. It uses a Go CLI/MCP entry point with a Python AT-SPI bridge, producing an open-computer-use binary.

    Key Packages and Directories

    • packages/OpenComputerUseKit: The core library containing the MCP stdio transport, tool registry, app discovery, accessibility/window snapshots, input simulation (keyboard/mouse), and software cursor overlay.
    • skills/: Contains installable skills for agent runtimes. The open-computer-use skill is a lightweight entry point, with detailed usage and troubleshooting located in adjacent references/ files.
    • apps/OpenComputerUseFixture: A local GUI fixture app used for low-risk, predictable testing of clicks, inputs, scrolling, and dragging.
  4. Use `scripts/computer-use-cli` for debugging and probing

    main

    The scripts/computer-use-cli directory contains an independent Go CLI designed for two primary purposes:

    1. Probing the official Codex desktop version's closed-source computer-use: This is used to detect available tools within the official bundled service.
    2. Connecting directly to standard stdio MCP servers: This is used for scriptable tool calls, such as those provided by the open-computer-use server in this repository.

    Note: This CLI is a debugging and reverse-engineering auxiliary tool, not the primary product of the repository. It is useful for verifying tool lists or testing scriptable tool calls when standard MCP clients fail due to host signature or parent process constraints (e.g., Launch Constraint Violation or CODESIGNING errors).

    cd scripts/computer-use-cli
  5. Operating Rules and Best Practices for Open Computer Use

    main

    When using Open Computer Use, adhere to these safety and operational guidelines:

    Safety & Privacy

    • Session Context: Treat the target desktop as a real user session. Do not inspect password managers or sensitive private content unless explicitly requested.
    • Confirmation: Always ask for permission before performing high-stakes actions like sending, deleting, purchasing, approving, or uploading content.

    Operational Reliability

    • Index Validity: Never guess element_index values. Always run get_app_state immediately before an action to get the most recent mapping.
    • Action Selection: Prefer semantic actions and set_value for editable controls. Use coordinate-based click, scroll, and drag only as a fallback when the element tree does not provide a safe target.
    • Platform Specifics:
      • macOS: Do not enable OPEN_COMPUTER_USE_ALLOW_GLOBAL_POINTER_FALLBACKS=1 unless the user explicitly requests click_method: "global" or diagnostic behavior.
      • Windows/Linux: Ensure the command is running inside a logged-in desktop session to enable GUI automation.
  6. Understand the codex-dump output structure

    main

    The scripts/codex_dump.py script organizes captured data into three main layers within the <session-name>/ directory. Understanding these layers is key to debugging Codex behavior:

    • websocket/*.jsonl: Contains WebSocket frames. Use this to see when the model decides to call a tool and what the parameters are (e.g., response.create, response.output_item.done with item.type=="function_call").
    • local-sessions/*.json: Structured summaries exported from ~/.codex/sessions/rollout-*.jsonl. Use this to see which function_call was actually dispatched to a local MCP and what the function_call_output was.
    • http/*.json: Standard HTTP request/response pairs. Use this for auxiliary traffic like plugin/config initialization (e.g., wham/apps).

    Troubleshooting Priority

    When investigating issues, follow this order:

    1. Check upstream LLM calls in websocket/.
    2. Check local tool/MCP dispatch in local-sessions/.
    3. Only if the above are insufficient, check low-level Codex local logs.
  7. Understand the ComputerUse IPC Architecture

    main

    The official implementation uses a three-layer protocol stack rather than a single MCP server. Developers building compatible tools should understand these layers to replicate behavior correctly:

    1. Codex Appserver IPC: Private JSON-RPC or thread event integration between the SkyComputerUseService and the Codex host.
    2. ComputerUse IPC: A local, trusted request protocol between the SkyComputerUseClient and the SkyComputerUseService.
    3. MCP (Model Context Protocol): The standard tool interface exposed by the client to the Codex agent runtime.

    This architecture explains why features like sender authorization, service idle timeouts, and parent constraints exist even when the external MCP interface appears simple.

  8. Identify the frontmost application using list_apps

    main
    The list_apps tool provides information about currently running applications. To align with official computer-use standards, the ListedAppDescriptor now includes an isFrontmost status. When calling list_apps, the application currently in focus (the frontmost app) will be explicitly marked with the frontmost tag. In the output list, the frontmost application is prioritized and placed at the top of the list, appearing before the running tag.
  9. How Codex integrates with Computer Use via MCP

    main

    Codex integrates with the Computer Use service by launching a built-in client in stdio mode to act as an MCP (Model Context Protocol) server. This allows the agent to communicate with the computer via standard input/output streams.

    In a typical configuration (e.g., within a JSON configuration file), the integration is defined as follows:

    • Server Name: computer-use
    • Origin: stdio
    • Transport: stdio
    {
      "mcpServers": {
        "computer-use": {
          "command": "./Codex Computer Use.app/Contents/SharedSupport/SkyComputerUseClient.app/Contents/MacOS/SkyComputerUseClient",
          "args": ["mcp"],
          "cwd": "."
        }
      }
    }
  10. Architectural Design for Software Cursor Motion Model

    main

    To implement a high-fidelity software cursor motion model (mimicking human-like movement), the architecture should be decoupled into four distinct layers rather than being bundled into a single overlay component. This separation allows for independent testing, parameter tuning, and eventual open-sourcing without coupling to the MCP runtime.

    1. Motion Parameters

    Pure value types that do not depend on AppKit. Essential parameters include:

    • startHandle
    • endHandle
    • arcHeight
    • arcFlow
    • spring

    2. Motion Path Builder

    Responsible for geometry only (not time). It takes a start point, end point, and parameters to produce:

    • CursorMotionPath
    • segments
    • control1
    • control2
    • measurement
    • Tangents (切线)

    3. Motion Simulator

    Handles time progression on top of the path geometry. It manages:

    • Bezier progress animation
    • Spring simulation
    • velocity
    • force
    • next-interaction timing gate
    • completion timing

    4. Cursor Renderer / Demo Host

    The outermost layer that integrates with AppKit / SwiftUI. It handles:

    • Overlay windows
    • Debug slider UI
    • Target point annotation
    • click / mail / debug toggles
  11. Non-intrusive Input Strategies in OpenCodexComputerUseKit

    main

    To minimize user disruption (mouse hijacking and focus stealing), the project implements a hierarchy of input methods that prioritize non-intrusive channels over global HID (Human Interface Device) events.

    Input Hierarchy

    1. Accessibility (AX) First: For clicks, the system attempts an AX hit-test path first. It uses AXRaise, kAXMainAttribute, and kAXFocusedAttribute to interact with elements. Only if these fail does it fall back to NSRunningApplication.activate and global HID.
    2. Targeted Keyboard Input: Instead of forcing application activation for every keystroke, type_text and press_key are implemented to deliver keyboard events directly to a specific Process ID (PID).
    3. State Reading: get_app_state is designed to read application state without forcing the application to become the active/focused window.

    Model-Side Preferences

    To support this runtime behavior, ToolDefinitions and plugin manifests include 'Tool Intrusion Hints'. This encourages the model to prioritize low-side-effect tools in this order:

    • get_app_state
    • press_key
    • type_text
    • set_value
    • perform_secondary_action

    This approach aims to achieve a "keyboard-first, AX-first, global mouse last" behavior pattern.

  12. Understand the Codex Host IPC and Parent Constraints

    main

    The SkyComputerUseClient mcp is not a standalone process; it is designed to run under a specific host.

    • Parent Process: Long-lived instances of SkyComputerUseClient mcp are typically children of the Codex host process (associated with OpenAI Team ID 2DC432GLL2).
    • IPC Mechanism: The SkyComputerUseService connects to a Unix socket held by Codex.app, specifically located at codex-ipc/ipc-501.sock.
    • Implication: The official computer-use implementation relies on a private Codex host IPC layer rather than being a pure, independent MCP server.