Iteration loop

What a productive session looks like once everything is wired.

Single-file fix

  1. Symptom. "Players see double mileage in the speedometer."
  2. Agent calls read_file({ resource: "speed_hud", path: "client/main.lua" }).
  3. Agent calls write_file({ resource: "speed_hud", path: "client/main.lua", content: "<patched>" }).
  4. Agent calls restart_resource({ name: "speed_hud" }).
  5. Agent calls tail_console({ lines: 20 }) to verify no errors on start.

You confirm in-game; done.

UI iteration

  1. Agent edits web/src/App.vue.
  2. Agent calls run_shell({ resource: "my_res", command: "npm", args: ["run", "build"], cwd: "web", timeoutMs: 60000 }).
  3. Agent calls restart_resource({ name: "my_res" }).
  4. You reopen the UI (F6 / /myres).
  5. Agent calls screenshot_nui({ resource: "my_res" }).
  6. Agent reads the PNG, describes what it sees, proposes the next tweak.

Average loop time on a dev box: ~5–10 seconds per change.

Multi-resource change

  1. Agent picks a name and runs scaffold_fivem_resource_workflow (mandatory grill).
  2. After your confirmation, agent: create_resource, refresh_resources, run_shell for any UI scaffolding, then a batch of write_file calls.
  3. ensure_resource returns stateAfter === "started" and the post-start console lines.
  4. If start failed, agent calls tail_console to find the syntax error and offers a single-file fix before re-writing.

Live player workflow

  1. You: /agent_test_optin.
  2. Agent: register_test_subject({ serverId: 1 }).
  3. Agent: get_player_state({ serverId: 1 }) to see coords, ped, health.
  4. Agent: esx_call_player({ serverId: 1, method: "getInventory" }) to see items.
  5. Agent: client_call_native({ serverId: 1, native: "SetEntityCoords", args: ["$ped", 200, -800, 30, false, false, false, true] }) to test a teleport.
  6. Agent: client_call_native({ serverId: 1, native: "GetEntityCoords", args: ["$ped", true] }) to verify the move.

What goes wrong + how the agent recovers

ProblemTool that catches itRecovery path
Resource won't startensure_resource returns RESOURCE_FAILED_TO_START + log linestail_console, propose fix, ask before re-writing
Token leaked / suspicious activityaudit log JSONLrotate token (rm dist/.agent_token && restart agent_api)
Player griefed by a client_call_nativehard agent_api_client_blocked_nativesadd native to blocklist, restart
Rate limit hittool returns RATE_LIMITED with retryAfterMsback off, then continue
Multi-step write raceper-resource lock serialisesnext call waits, no race