ឯកសារយោង 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":[...]}}{"command":"..."} មិនត្រូវបានគាំទ្រទេ។មុខងារចូលប្រើ
| មុខងារ | ការពិពណ៌នា | របៀបបើក |
|---|---|---|
| Off | Socket បានបិទ | UI ការកំណត់ ឬ CMUX_SOCKET_MODE=off |
| cmux processes only | មានតែដំណើរការដែលចាប់ផ្ដើមក្នុងទែមីណល cmux ប៉ុណ្ណោះអាចភ្ជាប់បាន។ | មុខងារលំនាំដើមក្នុង UI ការកំណត់ |
| allowAll | អនុញ្ញាតដំណើរការមូលដ្ឋានណាមួយភ្ជាប់ (គ្មានការពិនិត្យដើមកំណើត)។ | បដិសេធអថេរបរិស្ថានប៉ុណ្ណោះ: CMUX_SOCKET_MODE=allowAll |
ជម្រើស 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 ដែលបើកទាំងអស់។
cmux list-workspaces
cmux list-workspaces --json{"id":"ws-list","method":"workspace.list","params":{}}new-workspace
បង្កើត workspace ថ្មី។
cmux new-workspace{"id":"ws-new","method":"workspace.create","params":{}}select-workspace
ប្ដូរទៅ workspace ជាក់លាក់។
cmux select-workspace --workspace <id>{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}current-workspace
ទទួល workspace ដែលកំពុងដំណើរការបច្ចុប្បន្ន។
cmux current-workspace
cmux current-workspace --json{"id":"ws-current","method":"workspace.current","params":{}}close-workspace
បិទ workspace។
cmux close-workspace --workspace <id>{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}ពាក្យបញ្ជាបំបែក
new-split
បង្កើតបន្ទះបំបែកថ្មី។ ទិសដៅ: ឆ្វេង, ស្ដាំ, លើ, ក្រោម។
cmux new-split right
cmux new-split down{"id":"split-new","method":"surface.split","params":{"direction":"right"}}list-surfaces
រាយ surface ទាំងអស់ក្នុង workspace បច្ចុប្បន្ន។
cmux list-surfaces
cmux list-surfaces --json{"id":"surface-list","method":"surface.list","params":{}}focus-surface
ផ្ដោតលើ surface ជាក់លាក់។
cmux focus-surface --surface <id>{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}ពាក្យបញ្ជាបញ្ចូល
send
ផ្ញើអត្ថបទបញ្ចូលទៅទែមីណលដែលកំពុងផ្ដោត។
cmux send "echo hello"
cmux send "ls -la\n"{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}send-key
ផ្ញើការចុចគ្រាប់ចុច។ គ្រាប់ចុច: enter, tab, escape, backspace, delete, up, down, left, right។
cmux send-key enter{"id":"send-key","method":"surface.send_key","params":{"key":"enter"}}send-surface
ផ្ញើអត្ថបទទៅ surface ជាក់លាក់។
cmux send-surface --surface <id> "command"{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}send-key-surface
ផ្ញើការចុចគ្រាប់ចុចទៅ surface ជាក់លាក់។
cmux send-key-surface --surface <id> enter{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}ពាក្យបញ្ជាជូនដំណឹង
notify
ផ្ញើជូនដំណឹង។
cmux notify --title "Title" --body "Body"
cmux notify --title "T" --subtitle "S" --body "B"{"id":"notify","method":"notification.create","params":{"title":"Title","subtitle":"S","body":"Body"}}list-notifications
រាយជូនដំណឹងទាំងអស់។
cmux list-notifications
cmux list-notifications --json{"id":"notif-list","method":"notification.list","params":{}}clear-notifications
សម្អាតជូនដំណឹងទាំងអស់។
cmux clear-notifications{"id":"notif-clear","method":"notification.clear","params":{}}ពាក្យបញ្ជាទិន្នន័យមេតារបារចំហៀង
កំណត់ស្ថានភាព pill, របារវឌ្ឍនភាព, និងធាតុកំណត់ត្រាក្នុងរបារចំហៀងសម្រាប់ workspace ណាមួយ។ មានប្រយោជន៍សម្រាប់ស្គ្រីប build, ការរួមបញ្ចូល CI, និង AI coding agent ដែលចង់បង្ហាញស្ថានភាពក្នុងមួយភ្លែត។
set-status
កំណត់ស្ថានភាព pill របារចំហៀង។ ប្រើកូនសោតែមួយគត់ដើម្បីឧបករណ៍ផ្សេងៗអាចគ្រប់គ្រងធាតុផ្ទាល់ខ្លួន។
cmux set-status build "compiling" --icon hammer --color "#ff9500"
cmux set-status deploy "v1.2.3" --workspace workspace:2set_status build compiling --icon=hammer --color=#ff9500 --tab=<workspace-uuid>clear-status
លុបធាតុស្ថានភាពរបារចំហៀងតាមកូនសោ។
cmux clear-status buildclear_status build --tab=<workspace-uuid>list-status
រាយធាតុស្ថានភាពរបារចំហៀងទាំងអស់សម្រាប់ workspace។
cmux list-statuslist_status --tab=<workspace-uuid>set-progress
កំណត់របារវឌ្ឍនភាពក្នុងរបារចំហៀង (0.0 ដល់ 1.0)។
cmux set-progress 0.5 --label "Building..."
cmux set-progress 1.0 --label "Done"set_progress 0.5 --label=Building... --tab=<workspace-uuid>clear-progress
សម្អាតរបារវឌ្ឍនភាពរបារចំហៀង។
cmux clear-progressclear_progress --tab=<workspace-uuid>log
បន្ថែមធាតុកំណត់ត្រាទៅរបារចំហៀង។ កម្រិត: info, progress, success, warning, error។
cmux log "Build started"
cmux log --level error --source build "Compilation failed"
cmux log --level success -- "All 42 tests passed"log --level=error --source=build --tab=<workspace-uuid> -- Compilation failedclear-log
សម្អាតធាតុកំណត់ត្រារបារចំហៀងទាំងអស់។
cmux clear-logclear_log --tab=<workspace-uuid>list-log
រាយធាតុកំណត់ត្រារបារចំហៀង។
cmux list-log
cmux list-log --limit 5list_log --limit=5 --tab=<workspace-uuid>sidebar-state
បង្ហាញទិន្នន័យមេតារបារចំហៀងទាំងអស់ (cwd, git branch, ports, ស្ថានភាព, វឌ្ឍនភាព, កំណត់ត្រា)។
cmux sidebar-state
cmux sidebar-state --workspace workspace:2sidebar_state --tab=<workspace-uuid>ពាក្យបញ្ជាឧបករណ៍
ping
ពិនិត្យថា cmux កំពុងដំណើរការនិងឆ្លើយតប។
cmux ping{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}capabilities
រាយវិធី socket ដែលមាននិងមុខងារចូលប្រើបច្ចុប្បន្ន។
cmux capabilities
cmux capabilities --json{"id":"caps","method":"system.capabilities","params":{}}identify
បង្ហាញបរិបទបង្អួច/workspace/បន្ទះ/surface ដែលកំពុងផ្ដោត។
cmux identify
cmux identify --json{"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
# 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
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
#!/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 ជាមួយជូនដំណឹង
#!/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