CLI 指南

使用 termdock CLI 識別工作區、操作終端、管理版面、通知使用者與傳送 agent 事件。以下指令與旗標對齊 app 1.22.0 的內建說明。

連線與身分

CLI 透過本機 control socket 與 Terminal API 連到執行中的 Termdock。--token 可指定 Bearer token,預設從本機設定解析。hostinfo 離線偵測宿主終端與 Terminal/AST API 埠;identify 回傳目前工作區、窗格與 session 身分。

完整指令與旗標

Termdock CLI

Usage: termdock [options] <command>

Options:
  --help, -h           Show this help text
  --version, -v        Show the Termdock CLI version
  --url <url>          Terminal API base URL
  --token <token>      Terminal API bearer token (resolved from local config by default)

Commands:
  identify --json      Print focused workspace/pane/session identity
  hostinfo --json      Detect host terminal + Terminal/AST API ports (offline)
  notify <message> [--session <id>] [--title <text>] [--json]
                       Push a message to the configured Discord/Telegram remote
                       (session defaults to $TERMDOCK_SESSION_ID; --title names the
                       Discord thread created on the first push of a session)
  workspace list --json
  session create --workspace <id> [--name <name>] [--background] --json
  session list [--workspace <id>] --json
  session rename <id> <name> --json
  session output <id> [--mode raw|text|content|screen] [--lines <n>] [--since <cursor>] --json
  session output <id> [--mode raw|text|content] [--lines <n>] [--since <cursor>] --follow [--json]
  agent callback <session> --source <source> --event-kind <kind> --message <text>
                       [--dedupe-key <key>] [--metadata <json-object>] --json
                       Deliver an external event to an existing AgentSession only
  session input <id> <text> [--enter] --json
  session submit <id> <text> [--settle-ms <n>] [--queue-until-ready] [--ready-timeout <ms>] --json
  session key <id> <key> --json
  session interrupt <id> --json
  session status <id> --json
  session log <id> --json
  session ports <id> --json
  session keepalive list <id> --json
  session keepalive set <id> --message <text> (--interval <30m> | --idle <15m> | --daily <09:00>)
                       [--rule-id <id>] [--disabled] --json (live promptRef: use HTTP API)
  session keepalive rm <id> <rule-id> --json
  session attach <id>
  session destroy <id> --json
  layout get [--full] --json
  layout set <type> [--sessions <id,id>] --json
  layout assign <pane-id> <session-id|none> --json
  layout activate <pane-id> --json
  layout activate-panel <panel-id> --json
  layout restore --file <path> --json   (snapshot from "layout get --full --json")
  hook ingest --json [--wait] [--wait-timeout <ms>] [--request-timeout <ms>]
  hooks status [--agent claude|codex|gemini] [--json]
  hooks setup [--agent claude|codex|gemini] [--dry-run] [--json]
  hooks uninstall [--agent claude|codex|gemini] [--dry-run] [--json]

終端輸入與輸出

session input 搭配 --enter 送出指令。session submit 用於已進入互動提示的終端,可等待輸入穩定或就緒。--since 使用前次輸出的 nextCursor;--follow 僅支援 raw、text、content,無法串流 screen。session list 可用 --workspace 篩選。

termdock workspace list --json
termdock session create --workspace <id> --background --json
termdock session input <id> "npm test" --enter --json
termdock session output <id> --mode text --lines 100 --json

版面快照與 keep-alive

還原版面前,用 layout get --full --json 儲存完整快照,再交給 layout restore --file。精簡快照不能供 CLI 還原。keepalive set 使用 --interval、--idle 或 --daily 其中一種;若要在觸發時讀取 Prompt Library 的 promptRef,請用 HTTP API。

Terminal API

通知與外部事件

notify 將訊息推送至已設定的 Discord/Telegram。session 預設取自 $TERMDOCK_SESSION_ID;--title 僅命名該 session 首次推送建立的 Discord 討論串。agent callback 只傳送事件到既有 AgentSession,不會建立 agent 或改用原始終端輸入;metadata 必須是 JSON object,dedupe-key 不會自動去除重複事件。

遠端控制

Agent hooks

hooks status、setup、uninstall 支援 claude、codex、gemini;--dry-run 預覽安裝或移除動作。hook ingest 接收 provider 事件,--wait 等待回覆,--wait-timeout 與 --request-timeout 控制等待時間。