chatrole

package
v0.16.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Dir = "chat-role"

Dir is where, under the runtime's data folder, the chats with a role are marked.

View Source
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

func Answer(raw []byte, r Role) []byte

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

func GuardCommand(cmd, dir string) string

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.

func Mark

func Mark(dir, session string, r Role) error

Mark sets a session's role; None takes the mark away.

func Verdict

func Verdict(r Role, tool, command string) string

Verdict is why a call is refused, "" when it may go.

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"
)

func Of

func Of(dir, session string) Role

Of is a session's role; None for no mark or one that cannot be read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL