Rex terminal integration
The orka CLI emits standard terminal escape sequences that Rex (and any other terminal implementing these protocols) uses to show live task progress, highlight pending approvals, and restore sessions after a terminal or server restart. Orka also ships a ready-to-use Lua module at contrib/rex/orka.lua for Rex's command palette.
Program Status Protocol (OSC 7501)
When orka writes to an interactive TTY (and ORKA_NO_OSC is unset), long-running CLI commands emit OSC 7501 status records with app=orka:
| Command | Reported states |
|---|---|
orka task wait <task> | working while polling, blocked (kind=permission) when waiting on approvals, done on Succeeded, error on Failed/Cancelled/timeout, idle on Ctrl-C. |
orka task follow <task> / orka session follow <session> | working while streaming, blocked (kind=permission) on ApprovalRequested, back to working once decided, done/error on completion, idle on Ctrl-C. |
orka task approvals <task> --watch | working while polling, done with the tool/summary when a pending approval arrives (table output mode only), error on terminal task/timeout. |
orka run | idle at the REPL prompt, working during a turn, done/error on one-shot completion, plus child records (id=task/<name>) for delegated sub-tasks. |
orka auth login | blocked (kind=auth) while waiting for OIDC device-code sign-in, then done/error. |
Because done and error records persist after a command exits, unfocused Rex tabs and the session picker keep an unread indicator until you return.
To disable all OSC 7501 and OSC 7577 output, set ORKA_NO_OSC=1. TTY detection is checked per output writer (stderr for status/resume sequences), so piping stdout alone does not disable OSC output when stderr is still attached to a terminal; structured output modes (-o json, -o yaml) suppress OSC sequences.
Program Resume Protocol (OSC 7577)
When Rex starts a terminal, it sets OSC7577_TOKEN in the initial process environment. When that token is present and no raw --token or --txn-token flag was passed on the command line, orka reports its resume command and clears it on clean exit:
orka run(REPL) — resumes with--session <id>and updates the record if you run/clear.orka task follow <task>/orka session follow <session>— updates--after <seq>as events arrive so a restart resumes at the exact cursor.orka task wait <task>— resumes waiting on the same task.
orka task exec intentionally does not emit OSC 7577 because operator exec sessions are ephemeral and taint the Task's workspace.
Installing the Rex Lua module
Copy contrib/rex/orka.lua into your Rex config directory (for example ~/.config/rex/orka.lua) and load it from ~/.config/rex/init.lua:
local orka = require("orka")
orka.setup({
-- Optional overrides:
-- bin = "/usr/local/bin/orka",
-- server = "https://orka.example.com",
-- namespace = "default",
-- resume = true, -- registers resume.trust.orka_* rules
})
rex.bind("alt+cmd+o", "orka_follow_task")
rex.bind("alt+cmd+a", "orka_decide_approval")
Run rex config reload. The module registers five command-palette actions under the Orka category:
- Orka: Follow Task... (
orka_follow_task) — pick a task and open a labeled window runningorka task follow. - Orka: Decide Pending Approval... (
orka_decide_approval) — pick a running task, choose a pending approval, and approve or decline it inline. - Orka: Dispatch Agent Task... (
orka_dispatch_task) — pick an Agent, enter a prompt, create the Task, and open a window following it. - Orka: Shell into Task Workspace... (
orka_exec_task) — openorka task exec <task> -it -- shfor a running Task (requires operator workspace access). - Orka: Open Chat Session (
orka_chat) — open an interactiveorka runwindow.
It also registers resume.trust.orka_* rules so Rex can automatically restore orka run, orka task follow, orka session follow, and orka task wait panes across restarts.