CFX Run

Let GitHub Copilot Chat run code inside a live FiveM or RedM client, so you can ask it questions about the running game instead of guessing.

What it does

CFX Run registers tools with Copilot Chat that execute JavaScript in a sandboxed context inside the game client. Copilot can then read real state out of a running session rather than reasoning about code in the abstract.

Tools are referenced in the chat message that uses them, for example:

@RunJSFiveMCode Get the player position

Two halves

The extension

Installs into VS Code, registers the Copilot tools, and talks to the client over the CEF bridge.

The resource

Runs on your FiveM server and exposes the execution endpoint the extension calls. MIT licensed.

Both are required — the extension has nothing to talk to without the resource running on the server.

Before you use it

This is a development tool, not a production one. The resource allows execution of any native function. That is exactly what makes it useful while debugging, and exactly why it should not be left running on a live server. Restrict access, or remove it, outside development.

Debugging a client on another machine

Remote use means exposing the client's CEF DevTools port, which is bound to localhost by default. On Windows, allow the port through the firewall and proxy it to the loopback address:

netsh advfirewall firewall add rule name="CEF DevTools Port" ^
  dir=in action=allow protocol=TCP localport=13172

netsh interface portproxy add v4tov4 listenport=13172 ^
  listenaddress=0.0.0.0 connectport=13172 connectaddress=127.0.0.1

Add the port proxy after the game client is running. If a proxy from a previous session is still bound, delete it before starting the game:

netsh interface portproxy delete v4tov4 listenport=13172 listenaddress=0.0.0.0

Opening a DevTools port to your network is a real exposure. Do it on a network you trust, and undo it when you are finished.

Current limitations

Server-side execution and user input support are both planned.

Getting help

Pull requests and issues are welcome on the resource repository. For questions, the Discord is the fastest route.