ឯកសារយោង API

cmux ផ្ដល់ទាំងឧបករណ៍ CLI និង Unix socket សម្រាប់ការគ្រប់គ្រងដោយកម្មវិធី។ ពាក្យបញ្ជាទាំងអស់មានតាមរយៈចំណុចប្រទាក់ទាំងពីរ។

Socket

Buildផ្លូវ
Release/tmp/cmux.sock
Debug/tmp/cmux-debug.sock
Tagged debug build/tmp/cmux-debug-<tag>.sock

បដិសេធជាមួយអថេរបរិស្ថាន CMUX_SOCKET_PATH។ ផ្ញើសំណើ JSON មួយដែលបញ្ចប់ដោយបន្ទាត់ថ្មីក្នុងការហៅម្ដង:

{"id":"req-1","method":"workspace.list","params":{}}
// Response:
{"id":"req-1","ok":true,"result":{"workspaces":[...]}}
សំណើ socket JSON ត្រូវប្រើ method និង params។ JSON payloads ចាស់ v1 ដូចជា {"command":"..."} មិនត្រូវបានគាំទ្រទេ។

មុខងារចូលប្រើ

មុខងារការពិពណ៌នារបៀបបើក
OffSocket បានបិទUI ការកំណត់ ឬ CMUX_SOCKET_MODE=off
cmux processes onlyមានតែដំណើរការដែលចាប់ផ្ដើមក្នុងទែមីណល cmux ប៉ុណ្ណោះអាចភ្ជាប់បាន។មុខងារលំនាំដើមក្នុង UI ការកំណត់
allowAllអនុញ្ញាតដំណើរការមូលដ្ឋានណាមួយភ្ជាប់ (គ្មានការពិនិត្យដើមកំណើត)។បដិសេធអថេរបរិស្ថានប៉ុណ្ណោះ: CMUX_SOCKET_MODE=allowAll
នៅលើម៉ាស៊ីនចែករំលែក, ប្រើមុខងារបិទ ឬដំណើរការ cmux ប៉ុណ្ណោះ។

ជម្រើស CLI

ទង់ការពិពណ៌នា
--socket PATHផ្លូវ socket ផ្ទាល់ខ្លួន
--jsonលទ្ធផលក្នុងទម្រង់ JSON
--window IDកំណត់គោលដៅបង្អួចជាក់លាក់
--workspace IDកំណត់គោលដៅ workspace ជាក់លាក់
--surface IDកំណត់គោលដៅ surface ជាក់លាក់
--id-format refs|uuids|bothគ្រប់គ្រងទម្រង់ identifier ក្នុងលទ្ធផល JSON

ពាក្យបញ្ជា workspace

list-workspaces

រាយ workspace ដែលបើកទាំងអស់។

CLI
cmux list-workspaces
cmux list-workspaces --json
Socket
{"id":"ws-list","method":"workspace.list","params":{}}

new-workspace

បង្កើត workspace ថ្មី។

CLI
cmux new-workspace
Socket
{"id":"ws-new","method":"workspace.create","params":{}}

select-workspace

ប្ដូរទៅ workspace ជាក់លាក់។

CLI
cmux select-workspace --workspace <id>
Socket
{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}

current-workspace

ទទួល workspace ដែលកំពុងដំណើរការបច្ចុប្បន្ន។

CLI
cmux current-workspace
cmux current-workspace --json
Socket
{"id":"ws-current","method":"workspace.current","params":{}}

close-workspace

បិទ workspace។

CLI
cmux close-workspace --workspace <id>
Socket
{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}

ពាក្យបញ្ជាបំបែក

new-split

បង្កើតបន្ទះបំបែកថ្មី។ ទិសដៅ: ឆ្វេង, ស្ដាំ, លើ, ក្រោម។

CLI
cmux new-split right
cmux new-split down
Socket
{"id":"split-new","method":"surface.split","params":{"direction":"right"}}

list-surfaces

រាយ surface ទាំងអស់ក្នុង workspace បច្ចុប្បន្ន។

CLI
cmux list-surfaces
cmux list-surfaces --json
Socket
{"id":"surface-list","method":"surface.list","params":{}}

focus-surface

ផ្ដោតលើ surface ជាក់លាក់។

CLI
cmux focus-surface --surface <id>
Socket
{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}

ពាក្យបញ្ជាបញ្ចូល

send

ផ្ញើអត្ថបទបញ្ចូលទៅទែមីណលដែលកំពុងផ្ដោត។

CLI
cmux send "echo hello"
cmux send "ls -la\n"
Socket
{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}

send-key

ផ្ញើការចុចគ្រាប់ចុច។ គ្រាប់ចុច: enter, tab, escape, backspace, delete, up, down, left, right។

CLI
cmux send-key enter
Socket
{"id":"send-key","method":"surface.send_key","params":{"key":"enter"}}

send-surface

ផ្ញើអត្ថបទទៅ surface ជាក់លាក់។

CLI
cmux send-surface --surface <id> "command"
Socket
{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}

send-key-surface

ផ្ញើការចុចគ្រាប់ចុចទៅ surface ជាក់លាក់។

CLI
cmux send-key-surface --surface <id> enter
Socket
{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}

ពាក្យបញ្ជាជូនដំណឹង

notify

ផ្ញើជូនដំណឹង។

CLI
cmux notify --title "Title" --body "Body"
cmux notify --title "T" --subtitle "S" --body "B"
Socket
{"id":"notify","method":"notification.create","params":{"title":"Title","subtitle":"S","body":"Body"}}

list-notifications

រាយជូនដំណឹងទាំងអស់។

CLI
cmux list-notifications
cmux list-notifications --json
Socket
{"id":"notif-list","method":"notification.list","params":{}}

clear-notifications

សម្អាតជូនដំណឹងទាំងអស់។

CLI
cmux clear-notifications
Socket
{"id":"notif-clear","method":"notification.clear","params":{}}

ពាក្យបញ្ជាទិន្នន័យមេតារបារចំហៀង

កំណត់ស្ថានភាព pill, របារវឌ្ឍនភាព, និងធាតុកំណត់ត្រាក្នុងរបារចំហៀងសម្រាប់ workspace ណាមួយ។ មានប្រយោជន៍សម្រាប់ស្គ្រីប build, ការរួមបញ្ចូល CI, និង AI coding agent ដែលចង់បង្ហាញស្ថានភាពក្នុងមួយភ្លែត។

set-status

កំណត់ស្ថានភាព pill របារចំហៀង។ ប្រើកូនសោតែមួយគត់ដើម្បីឧបករណ៍ផ្សេងៗអាចគ្រប់គ្រងធាតុផ្ទាល់ខ្លួន។

CLI
cmux set-status build "compiling" --icon hammer --color "#ff9500"
cmux set-status deploy "v1.2.3" --workspace workspace:2
Socket
set_status build compiling --icon=hammer --color=#ff9500 --tab=<workspace-uuid>

clear-status

លុបធាតុស្ថានភាពរបារចំហៀងតាមកូនសោ។

CLI
cmux clear-status build
Socket
clear_status build --tab=<workspace-uuid>

list-status

រាយធាតុស្ថានភាពរបារចំហៀងទាំងអស់សម្រាប់ workspace។

CLI
cmux list-status
Socket
list_status --tab=<workspace-uuid>

set-progress

កំណត់របារវឌ្ឍនភាពក្នុងរបារចំហៀង (0.0 ដល់ 1.0)។

CLI
cmux set-progress 0.5 --label "Building..."
cmux set-progress 1.0 --label "Done"
Socket
set_progress 0.5 --label=Building... --tab=<workspace-uuid>

clear-progress

សម្អាតរបារវឌ្ឍនភាពរបារចំហៀង។

CLI
cmux clear-progress
Socket
clear_progress --tab=<workspace-uuid>

log

បន្ថែមធាតុកំណត់ត្រាទៅរបារចំហៀង។ កម្រិត: info, progress, success, warning, error។

CLI
cmux log "Build started"
cmux log --level error --source build "Compilation failed"
cmux log --level success -- "All 42 tests passed"
Socket
log --level=error --source=build --tab=<workspace-uuid> -- Compilation failed

clear-log

សម្អាតធាតុកំណត់ត្រារបារចំហៀងទាំងអស់។

CLI
cmux clear-log
Socket
clear_log --tab=<workspace-uuid>

list-log

រាយធាតុកំណត់ត្រារបារចំហៀង។

CLI
cmux list-log
cmux list-log --limit 5
Socket
list_log --limit=5 --tab=<workspace-uuid>

sidebar-state

បង្ហាញទិន្នន័យមេតារបារចំហៀងទាំងអស់ (cwd, git branch, ports, ស្ថានភាព, វឌ្ឍនភាព, កំណត់ត្រា)។

CLI
cmux sidebar-state
cmux sidebar-state --workspace workspace:2
Socket
sidebar_state --tab=<workspace-uuid>

ពាក្យបញ្ជាឧបករណ៍

ping

ពិនិត្យថា cmux កំពុងដំណើរការនិងឆ្លើយតប។

CLI
cmux ping
Socket
{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}

capabilities

រាយវិធី socket ដែលមាននិងមុខងារចូលប្រើបច្ចុប្បន្ន។

CLI
cmux capabilities
cmux capabilities --json
Socket
{"id":"caps","method":"system.capabilities","params":{}}

identify

បង្ហាញបរិបទបង្អួច/workspace/បន្ទះ/surface ដែលកំពុងផ្ដោត។

CLI
cmux identify
cmux identify --json
Socket
{"id":"identify","method":"system.identify","params":{}}

អថេរបរិស្ថាន

អថេរការពិពណ៌នា
CMUX_SOCKET_PATHបដិសេធផ្លូវ socket ដែលប្រើដោយ CLI និងការរួមបញ្ចូល
CMUX_SOCKET_ENABLEបង្ខំបើក/បិទ socket (1/0, true/false, on/off)
CMUX_SOCKET_MODEបដិសេធមុខងារចូលប្រើ (cmuxOnly, allowAll, off)។ ទទួលផងដែរ cmux-only/cmux_only និង allow-all/allow_all
CMUX_WORKSPACE_IDកំណត់ស្វ័យប្រវត្តិ: ID workspace បច្ចុប្បន្ន
CMUX_SURFACE_IDកំណត់ស្វ័យប្រវត្តិ: ID surface បច្ចុប្បន្ន
TERM_PROGRAMកំណត់ទៅ ghostty
TERMកំណត់ទៅ xterm-ghostty
តម្លៃ CMUX_SOCKET_MODE ចាស់ full និង notifications នៅតែទទួលបានសម្រាប់ភាពឆបគ្នា។

កំណត់ cmux

bash
# Prefer explicit socket path if set
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"
[ -S "$SOCK" ] && echo "Socket available"

# Check for the CLI
command -v cmux &>/dev/null && echo "cmux available"

# In cmux-managed terminals these are auto-set
[ -n "${CMUX_WORKSPACE_ID:-}" ] && [ -n "${CMUX_SURFACE_ID:-}" ] && echo "Inside cmux surface"

# Distinguish from regular Ghostty
[ "$TERM_PROGRAM" = "ghostty" ] && [ -n "${CMUX_WORKSPACE_ID:-}" ] && echo "In cmux"

ឧទាហរណ៍

Python client

python
import json
import os
import socket

SOCKET_PATH = os.environ.get("CMUX_SOCKET_PATH", "/tmp/cmux.sock")

def rpc(method, params=None, req_id=1):
    payload = {"id": req_id, "method": method, "params": params or {}}
    with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
        sock.connect(SOCKET_PATH)
        sock.sendall(json.dumps(payload).encode("utf-8") + b"\n")
        return json.loads(sock.recv(65536).decode("utf-8"))

# List workspaces
print(rpc("workspace.list", req_id="ws"))

# Send notification
print(rpc(
    "notification.create",
    {"title": "Hello", "body": "From Python!"},
    req_id="notify"
))

Shell script

bash
#!/bin/bash
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"

cmux_cmd() {
    printf "%s\n" "$1" | nc -U "$SOCK"
}

cmux_cmd '{"id":"ws","method":"workspace.list","params":{}}'
cmux_cmd '{"id":"notify","method":"notification.create","params":{"title":"Done","body":"Task complete"}}'

Build script ជាមួយជូនដំណឹង

bash
#!/bin/bash
npm run build
if [ $? -eq 0 ]; then
    cmux notify --title "✓ Build Success" --body "Ready to deploy"
else
    cmux notify --title "✗ Build Failed" --body "Check the logs"
fi