Skip to content

Latest commit

 

History

History
262 lines (235 loc) · 4.82 KB

File metadata and controls

262 lines (235 loc) · 4.82 KB

API Endpoints List

1. Computer Endpoint (/computer)

Supported Operations:

  • cursor_position
  • key
  • type
  • mouse_move
  • left_click
  • left_click_drag
  • right_click
  • middle_click
  • double_click
  • screenshot

1.1 Get Cursor Position

curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"cursor_position"}'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Cursor position is: X=100, Y=200"
}

1.2 Keyboard Key Press

curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"key", "text":"Return"}'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Key action executed successfully"
}

1.3 Type Text

curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"type", "text":"Hello World"}'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Type action executed successfully"
}

1.4 Move Mouse

curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"mouse_move", "coordinate":[100, 200]}'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Mouse move executed successfully"
}

1.5 Mouse Click Operations

# Left Click
curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"left_click"}'

# Right Click
curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"right_click"}'

# Middle Click
curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"middle_click"}'

# Double Click
curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"double_click"}'

# Left Click Drag
curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"left_click_drag"}'

1.6 Screenshot

curl -X POST http://localhost:8090/computer \
  -H "Content-Type: application/json" \
  -d '{"action":"screenshot"}'

Response:

{
  "type": "base64",
  "media_type": "image/png",
  "data": "base64_encoded_image_data..."
}

2. Edit Endpoint (/edit)

Supported Operations:

  • view
  • create
  • str_replace
  • insert
  • undo_edit

2.1 View File Content

# View entire file
curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "view",
    "path": "/path/to/file"
  }'

# View specific line range
curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "view",
    "path": "/path/to/file",
    "view_range": [1, 10]
  }'

2.2 Create File

curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "create",
    "path": "/path/to/file",
    "file_text": "File content here"
  }'

2.3 String Replace

curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "str_replace",
    "path": "/path/to/file",
    "old_str": "old text",
    "new_str": "new text"
  }'

2.4 Insert Text

curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "insert",
    "path": "/path/to/file",
    "file_text": "text to insert",
    "insert_line": 5
  }'

2.5 Undo Edit

curl -X POST http://localhost:8090/edit \
  -H "Content-Type: application/json" \
  -d '{
    "command": "undo_edit",
    "path": "/path/to/file"
  }'

3. Bash Endpoint (/bash)

3.1 Execute Command

curl -X POST http://localhost:8090/bash \
  -H "Content-Type: application/json" \
  -d '{
    "command": "ls -la"
  }'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "command_output_here"
}

3.2 Restart Bash Session

curl -X POST http://localhost:8090/bash \
  -H "Content-Type: application/json" \
  -d '{
    "restart": true
  }'

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Bash session has been restarted"
}

4. Health Check (/health)

curl -X GET http://localhost:8090/health

Response:

{
  "type": "success",
  "media_type": "text/plain",
  "data": "Service is running"
}

Notes:

  1. All responses follow a unified format:
{
  "type": "success|error|base64",
  "media_type": "text/plain|image/png",
  "data": "Response data"
}
  1. Error responses will include specific error information:
{
  "type": "error",
  "media_type": "text/plain",
  "data": "Error description"
}
  1. Port number 8090 is used in examples, please adjust according to your actual configuration.