Documentation
¶
Overview ¶
Package chatguard is what a machine's runtime does about the chat's typing while the machine's local policy keeps the terminal switched off for the hub.
The machine agent's route filter refuses the routes of a terminal, but the chat page's own routes (a message, a queued message, "send now", an answer) type into the tmux pane of a conversation, and a pane is a terminal when the agent in it has gone: the text would be read by a shell and run. Claude Code's bash mode (a message that starts with "!") runs the rest of the line as a command without asking either. The filter cannot see a pane, so the agent tells the runtime when the terminal is off (POST <agent API>/policy, see cmd/runtime/hub_routes.go), and the runtime refuses at the source: text goes only into a pane where an agent runs, and never as a bash-mode line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTerminalOff = errors.New("the terminal is switched off on this machine: text goes only into a running agent, and not as a shell command")
ErrTerminalOff is what a refused write says.
Functions ¶
func AgentInForeground ¶
AgentInForeground says that a program other than a bare shell runs in the foreground of the pane; false when tmux did not say (an empty command), as the answer of a loaded machine proves nothing.
func BashMode ¶
BashMode says that an agent reads the text as a shell command: Claude Code (and Codex) enter their bash mode on a "!" at the start of the input. Whitespace and invisible format characters before it are skipped, since a paste or an editor may trim them, and it costs nothing to refuse a line that merely looks like one.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard says whether the terminal is switched off. The zero value, and a nil *Guard, is on: a runtime without a hub asks nobody. A runtime a hub carries starts with it off (New(true)) until the machine agent has said what the policy is, so that the minutes after a restart are not an open door.