Agent Service
Agent Service (GA)
The Agent Service (GA service) is the core component deployed on the user's server. It handles app management, command execution and process communication.
Overview
Service characteristics
- Deployment: local to the user's server
- Protocols: HTTP API + JSON-RPC 2.0
- Security: local file socket communication
- Performance: low-latency, efficient inter-process communication
HTTP API
Response Format
Every API follows the same response format:
| Field | Type | Description |
|---|---|---|
code | number | Status code; 200000 on success, any other value on failure |
data | any | Response payload |
meta | object | Metadata |
msg | string | Response message (English) |
API Reference
1. Execute a Command
Endpoint: /api/command/exec_shell
SDK support
This method is wrapped by the frontend SDK and can be called directly.
Request:
{
"cmd_string": "cat .bashrc",
"timeout": "1",
"cwd": "/root",
"username": "root"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd_string | string | Yes | Command to run; either a raw command or a base64-encoded command |
timeout | string | Yes | Timeout in seconds |
cwd | string | No | Working directory; defaults to /.__gmssh/bin |
username | string | Yes | User to run the command as |
Response:
{
"code": 200000,
"data": "# .bashrc content here...",
"meta": {
"close": 0,
"endpoint": "/api/command/exec_shell"
},
"msg": "Successful operation"
}2. Get a Process Port
Endpoint: /api/command/get_process_port
Request:
{
"process_name": "test"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
process_name | string | Yes | Process name |
Response:
{
"code": 200000,
"data": {
"port": 17766,
"pid": 17764
},
"meta": {
"close": 0,
"endpoint": "/api/command/get_process_port"
},
"msg": "Successful operation"
}3. Execute Script Content
Endpoint: /api/command/exec_script
Request:
{
"script": "ZWNobyBoZWxsbw==",
"timeout": "5"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
script | string | Yes | Base64-encoded script content |
timeout | string | Yes | Timeout in seconds |
Response:
{
"code": 200000,
"data": "hello",
"meta": {
"close": 0,
"endpoint": "/api/command/exec_script"
},
"msg": "Successful operation"
}Difference between the two
- Execute a command: behaves like running a command in a terminal
- Execute a script: runs the content of a script file directly
4. Check App Status
Endpoint: /api/center/check_status
SDK support
This method is wrapped by the frontend SDK and can be called directly.
Request:
{
"app_name": "official/omc",
"version": "1.0.0",
"communication_type": "http"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
app_name | string | Yes | App name in the form {organization}/{app} |
version | string | Yes | App version |
communication_type | string | Yes | Transport: http or socket |
5. External App Access
Endpoint: /api/call/{organization}/{app}/{endpoint}
Request:
{
"version": "1.0.0",
"transport": "http",
"params": {
"lang": "zh-CN"
}
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
version | string | Yes | External app version |
transport | string | Yes | Transport: http or socket |
params | object | No | Parameters passed to the external app |
Response:
{
"code": 200000,
"data": {
"code": 200,
"data": "hello world!",
"msg": "操作成功"
},
"meta": {
"close": 0,
"endpoint": "/api/call/*"
},
"msg": "Successful operation"
}6. List Files and Directories
Endpoint: api/files/get_dir
Request:
{
"path": "/",
"search": "",
"all": "",
"reverse": "False",
"sort": "name",
"showRow": 9999,
"window_id": ""
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Directory path, for example / for the root |
search | string | No | Search keyword used to filter file names |
all | string | No | Whether to show all files |
reverse | string | No | Sort descending: "True" or "False" |
sort | string | No | Sort order: "name", "size" or "time" |
showRow | number | No | Row limit; defaults to 9999 (desktop only) |
window_id | string | No | Window identifier |
Response:
{
"code": 200000,
"data": {
"LIST": [
{
"name": "/.__gmssh",
"filename": ".__gmssh",
"cwd": "/",
"fullname": "/.__gmssh",
"filesize": 4096,
"size": 4096,
"mtime": 1751468646,
"accept": "755",
"user": "root",
"link": "",
"download_id": "0",
"is_composer_json": "0",
"favorite": "0",
"share": "0",
"ps": "",
"top": "0",
"recycle_raw": -1,
"gmk": {
"name": "",
"title": "",
"icon": "",
"type": 0,
"type_des": "",
"key": "",
"v": "",
"sort": 0,
"only_one": 0,
"run_status": 0,
"installed": 0,
"target_exists": 0,
"version": "",
"min_width": "",
"min_height": "",
"index": null
},
"type": 1
},
],
"PATH": "/",
"desktop": "/.__gmssh/desktop",
"recycle": {
"rec_has_file": false
},
"size": 0
},
"meta": {
"close": 0,
"endpoint": "/api/files/get_dir"
},
"msg": "Successful operation"
}7. Create a File
Endpoint: /api/files/create_file
Request:
{
"path": "/demo.txt"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Absolute file path |
Response:
{
"code": 200000,
"data": {
"name": "/demo.txt",
"filename": "demo.txt",
"cwd": "/",
"fullname": "/demo.txt",
"filesize": 0,
"size": 0,
"mtime": 1753061249,
"accept": "644",
"user": "root",
"link": "",
"download_id": "0",
"is_composer_json": "0",
"favorite": "0",
"share": "0",
"ps": "",
"top": "0",
"recycle_raw": -1,
"gmk": {
"name": "",
"title": "",
"icon": "",
"type": 0,
"type_des": "",
"key": "",
"v": "",
"sort": 0,
"only_one": 0,
"run_status": 0,
"installed": 0,
"target_exists": 0,
"version": "",
"min_width": "",
"min_height": "",
"index": null
},
"type": 2
},
"meta": {
"close": 0,
"endpoint": "/api/files/create_file"
},
"msg": "Successful operation"
}8. Delete a File
Endpoint: /api/files/delete_file
Request:
{
"path": "/demo.txt"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Absolute file path |
Response:
{
"code": 200000,
"data": {
"refresh_store": false
},
"meta": {
"close": 0,
"endpoint": "/api/files/delete_file"
},
"msg": "Successful operation"
}9. Create a Directory
Endpoint: /api/files/create_dir
Request:
{
"path": "/demo"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Absolute directory path |
Response:
{
"code": 200000,
"data": {
"name": "/demo",
"filename": "demo",
"cwd": "/",
"fullname": "/demo",
"filesize": 4096,
"size": 4096,
"mtime": 1753061569,
"accept": "755",
"user": "root",
"link": "",
"download_id": "0",
"is_composer_json": "0",
"favorite": "0",
"share": "0",
"ps": "",
"top": "0",
"recycle_raw": -1,
"gmk": {
"name": "",
"title": "",
"icon": "",
"type": 0,
"type_des": "",
"key": "",
"v": "",
"sort": 0,
"only_one": 0,
"run_status": 0,
"installed": 0,
"target_exists": 0,
"version": "",
"min_width": "",
"min_height": "",
"index": null
},
"type": 1
},
"meta": {
"close": 0,
"endpoint": "/api/files/create_dir"
},
"msg": "Successful operation"
}10. Delete a Directory
Endpoint: /api/files/delete_dir
Request:
{
"path": "/demo"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Absolute directory path |
Response:
{
"code": 200000,
"data": {
"refresh_store": false
},
"meta": {
"close": 0,
"endpoint": "/api/files/delete_dir"
},
"msg": "Successful operation"
}11. Read File Content
Endpoint: /api/files/read_file_body
Request:
{
"path": "/demo.txt",
"auto_create": "0"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Absolute file path |
auto_create | string | Yes | Create the file when missing: 0 no, 1 yes |
Response:
{
"code": 200000,
"data": {
"path": "",
"encoding": "utf-8",
"data": "",
"only_read": false,
"size": 0,
"st_mtime": "1753061659"
},
"meta": {
"close": 0,
"endpoint": "/api/files/read_file_body"
},
"msg": "Successful operation"
}12. Rename a File or Directory
Endpoint: /api/files/mv_file
Request:
{
"sfile": "/demo.txt",
"dfile": "/example.txt",
"rename": true
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sfile | string | Yes | Absolute path of the source |
dfile | string | Yes | Absolute path of the destination |
rename | bool | Yes | With false, move forcibly (delete the destination if it exists) |
Response:
{
"code": 200000,
"data": {
"name": "/example",
"filename": "example",
"cwd": "/",
"fullname": "/example",
"filesize": 0,
"size": 0,
"mtime": 1753061659,
"accept": "644",
"user": "root",
"link": "",
"download_id": "0",
"is_composer_json": "0",
"favorite": "0",
"share": "0",
"ps": "",
"top": "0",
"recycle_raw": -1,
"gmk": {
"name": "",
"title": "",
"icon": "",
"type": 0,
"type_des": "",
"key": "",
"v": "",
"sort": 0,
"only_one": 0,
"run_status": 0,
"installed": 0,
"target_exists": 0,
"version": "",
"min_width": "",
"min_height": "",
"index": null
},
"type": 2
},
"meta": {
"close": 0,
"endpoint": "/api/files/mv_file"
},
"msg": "Successful operation"
}13. Copy a File or Directory
Endpoint: /api/files/copy_file
Request:
{
"sfile": "/demo",
"dfile": "/example"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sfile | string | Yes | Absolute path of the source |
dfile | string | Yes | Absolute path of the destination |
Response:
{
"code": 200000,
"data": true,
"meta": {
"close": 0,
"endpoint": "/api/files/copy_file"
},
"msg": "Successful operation"
}JSON-RPC Interface
The GA service also exposes a JSON-RPC 2.0 interface over a Unix Domain Socket for high-performance local inter-process communication.
Connection
Unix socket path:
/.__gmssh/tmp/rpc.sockProtocol
- Version: JSON-RPC 2.0
- Transport: Unix Domain Socket
- Format: JSON
- Encoding: UTF-8
Request Format
{
"jsonrpc": "2.0",
"method": "method_name",
"params": {
"param1": "value1",
"param2": "value2"
},
"id": 1
}Fields:
| Field | Type | Required | Description |
|---|---|---|---|
jsonrpc | string | Yes | Protocol version, always "2.0" |
method | string | Yes | Method name to call |
params | object/array | No | Method parameters |
id | number/string | Yes | Request identifier used to match the response |
JSON-RPC Methods
1. Log Report (Important)
Method: log_report
Request:
{
"plugin_name": "user",
"plugin_name_des": "用户模块",
"fn_name": "add_user",
"fn_name_des": "添加用户",
"data": data,
"o_name": "新增用户:xxx",
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
plugin_name | string | Yes | Plugin name |
plugin_name_des | string | Yes | Plugin description |
fn_name | string | Yes | Function name |
fn_name_des | string | Yes | Function description |
data | string | Yes | Request data |
o_name | string | Yes | Operation details |
Response:
{
"jsonrpc": "2.0",
"result": {
"code": 200,
"meta": {"endpoint": null, "close": 1},
"data": null,
"msg": "Successful operation"
},
"id": 1
}Environment Variables
IsClean
Scope: available only inside an app's uninstall.sh script
Values:
true: the user chose to remove app datafalse: the user chose to keep app data
Example:
#!/bin/bash
if [ "$IsClean" = "true" ]; then
echo "Removing app data..."
rm -rf ./data/
rm -rf ./config/
else
echo "Keeping app data"
fiBest practices
- Always check the
IsCleanenvironment variable in the uninstall script. - Clean data according to the user's choice.
- Log enough information to make troubleshooting easy.
