Hierarchical Context Signalling (OSC 3008)

Signal nested execution contexts (containers, VMs, SSH, sudo, subshells) to the terminal.

  1. 0x1B
    ESC
  2. 0x5D
    ]
  3. 0x33 0x30 0x30 0x38
    3008
  4. 0x3B
    ;
  5. ____
    a
  6. 0x3D
    =
  7. ____
    i
  8. 0x3B
    ;
  9. ____
    ...
  10. 0x1B
    ESC
  11. 0x5C
    \

OSC 3008 is the UAPI hierarchical context signalling protocol. It lets programs announce when execution enters or leaves a nested context, such as a container, a virtual machine, an SSH session, a sudo elevation, or a subshell. Each context has a unique identifier and an open set of metadata fields. Contexts nest naturally: an SSH session inside a container inside a shell session forms a stack inside the terminal.

The first field selects the action and carries the context ID. Trailing fields are semicolon-separated key=value pairs of metadata.

Actions

Action formMeaning
start=<id>Begin a new context (or update / re-enter an existing one).
end=<id>Terminate the context with the given ID.

Context ID

The <id> is a stable identifier for the context. The specification requires it to be 1-64 characters, all in the printable ASCII range 0x20-0x7e. Wintty's parser enforces both bounds; sequences with an empty, oversized, or non-printable ID are dropped.

Metadata fields

Both start= and end= sequences may carry additional key=value metadata after the context ID. Unknown keys are ignored per the spec. Wintty's parser exposes the following keys to the terminal layer:

Start fields

KeyTypeMeaning
typeenumContext kind. See Context types.
userstringUsername for this context.
hostnamestringHostname for this context.
machineidstringPersistent machine identifier (/etc/machine-id).
bootidstringBoot-instance identifier.
pidunsigned intProcess ID of the context root.
pidfdidunsigned intPidfd identifier for the context root.
commstringShort process command name.
cwdstringWorking directory.
cmdlinestringFull command line.
vmstringVM name (when type=vm).
containerstringContainer name (when type=container).
targetuserstringTarget user (e.g. for elevate or SSH).
targethoststringTarget host (e.g. for SSH).
sessionidstringLogical session identifier.

End fields

KeyTypeMeaning
exitenumsuccess, failure, crash, or interrupt.
statusunsigned intExit status integer (typically 0-255 for processes).
signalstringTerminating signal name (e.g. SIGKILL).

Context types

The type= field is normalized to one of:

boot, container, vm, elevate, chpriv, subcontext, remote, shell, command, app, service, session.

Any other value is treated as unset.

Examples

Announce entry into a systemd-nspawn container named foobar launched by user lennart on host zeta:

printf '\033]3008;start=bed86fab93af4328bbed0a1224af6d40;type=container;user=lennart;hostname=zeta;comm=systemd-nspawn;container=foobar\033\\'

Announce that the container exited successfully:

printf '\033]3008;end=bed86fab93af4328bbed0a1224af6d40;exit=success;status=0\033\\'

Behavior in Wintty

Note

OSC 3008 is parsed but not yet acted on in Wintty. The parser validates the action, the context ID, and every metadata field listed above (the test suite covers all spec examples), but the terminal does not currently maintain a context stack or expose context state to the UI. Programs may safely emit OSC 3008; the sequence will be silently consumed by current desktop builds and become meaningful in a future release without any wire-format change.

See also