Documentation
¶
Overview ¶
Package chatrole holds what a chat may do besides the person's permission mode, set by the orchestration of delegated chats (internal/delegation): a delegated chat that must show its plan first may not change anything until the plan is approved, and a chat the person made a coordinator hands work out instead of doing it.
The runtime marks a chat with one small file named by the tmux session its agent runs in; the agent's PreToolUse hook (`harnessly hook voice-guard`, the one every chat already has) reads it and refuses what the role does not allow, with words that tell the agent what to do instead. No file, or one the hook cannot read, lets every call go.
Index ¶
Constants ¶
const Dir = "chat-role"
Dir is where, under the runtime's data folder, the chats with a role are marked.
const FailedText = "The role check of this chat (plan or coordinator) could not run, so the call is refused to be safe. " +
"Try again; if it keeps failing, tell the person that the harnessly hook of this chat is broken."
FailedText is why a call of a chat with a role is refused when the hook itself could not run.
Variables ¶
This section is empty.
Functions ¶
func Answer ¶
Answer is the hook's answer for a chat of role r to the call raw: nil lets it go, else a refusal the agent reads.
func GuardCommand ¶
GuardCommand wraps a hook's command line so that it fails closed for a chat with a role: when the command fails (crashed, missing, killed) and the chat's session is marked under dir, the call is refused with FailedText; a chat without a role is let through as before. It is one shell group, so a caller may add redirections after it.
Types ¶
type HookInput ¶
type HookInput struct {
ToolName string `json:"tool_name"`
ToolInput struct {
Command any `json:"command"`
} `json:"tool_input"`
}
HookInput is the part of a PreToolUse hook's input read here (Claude Code's and Codex's alike).
type Role ¶
type Role string
Role is what a chat is held to.
const ( // None: the chat does what its permission mode allows. None Role = "" // Plan: the chat reads and plans; it changes no file and runs no command that writes, until its plan is approved. Plan Role = "plan" // Coordinate: the chat hands work out (delegate_task, the team's task list), reads and checks; it edits no file and // runs no build or test suite itself. Coordinate Role = "coordinate" )