harness

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManagedMarker      = "aht managed integration"
	HookTimeoutSeconds = 5

	HookTypeCommand             = "command"
	HookEventSessionStart       = "SessionStart"
	HookEventSessionEnd         = "SessionEnd"
	HookEventUserPromptSubmit   = "UserPromptSubmit"
	HookEventPostToolUse        = "PostToolUse"
	HookEventPostToolUseFailure = "PostToolUseFailure"
	HookEventPreToolUse         = "PreToolUse"
	HookEventStop               = "Stop"
	ResumeFlag                  = "--resume"

	HookActivityRunning     HookTransition = "activity:running"
	HookActivityWaiting     HookTransition = "activity:waiting"
	HookActivityIdle        HookTransition = "activity:idle"
	HookActivityFailed      HookTransition = "activity:failed"
	HookActivityInterrupted HookTransition = "activity:interrupted"
	HookPresenceGone        HookTransition = "presence:gone"
)

Variables

This section is empty.

Functions

func AddAttributeString

func AddAttributeString(attributes map[string]string, key string, value string)

func FirstArrayString

func FirstArrayString(payload map[string]any, keys ...string) string

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

func HookTimeoutSecondsFor

func HookTimeoutSecondsFor(harness registry.Harness, event string) int

HookTimeoutSecondsFor returns the native command-hook timeout for an event.

func NestedString

func NestedString(payload map[string]any, path ...string) string

func PayloadBool

func PayloadBool(payload map[string]any, keys ...string) bool

func PayloadBoolString

func PayloadBoolString(payload map[string]any, keys ...string) string

func PayloadObject

func PayloadObject(rawPayload json.RawMessage) (map[string]any, bool)

func PayloadString

func PayloadString(payload map[string]any, key string) string

func PayloadStringAny

func PayloadStringAny(payload map[string]any, keys ...string) string

func RawStdinDefaultsReportHookCommand

func RawStdinDefaultsReportHookCommand[T Transition](
	binary string,
	harness registry.Harness,
	transition T,
	event string,
	source string,
) string

func RenderScriptTemplate

func RenderScriptTemplate(template string, integrationID string, binary string, source string, version int) string

func ReportHookCommand

func ReportHookCommand[T Transition](binary string, harness registry.Harness, transition T, event string, source string) string

func RunCommand

func RunCommand(ctx context.Context, timeout time.Duration, outputLimit int, executable string, args ...string) ([]byte, error)

RunCommand executes a command with bounded output and a caller-specified timeout. It never returns a partial successful response when the output budget is exceeded.

func ShellQuote

func ShellQuote(value string) string

Types

type Adapter

type Adapter interface {
	Definition() Definition
}

type BaseAdapter

type BaseAdapter struct {
	// contains filtered or unexported fields
}

func NewBaseAdapter

func NewBaseAdapter(definition Definition) BaseAdapter

func (BaseAdapter) Definition

func (adapter BaseAdapter) Definition() Definition

type Capabilities

type Capabilities struct {
	SessionStart      bool
	SessionEnd        bool
	RunningIdle       bool
	WaitingPermission bool
	ProcessIdentity   bool
	NativeCatalog     bool
	TTYTmuxContext    bool
}

type CommandHookInstallSpec

type CommandHookInstallSpec struct {
	Event   string
	Matcher string
	Command string
}

type CursorCommandHookInstallSpec

type CursorCommandHookInstallSpec struct {
	Event   string
	Command string
}

type CursorJSONHookInstallPlan

type CursorJSONHookInstallPlan struct {
	Path        string
	Source      string
	Label       string
	ConfigLabel string
	Hooks       []CursorCommandHookInstallSpec
}

type CursorJSONHooksAction

type CursorJSONHooksAction struct {
	Plan CursorJSONHookInstallPlan
}

type Definition

type Definition struct {
	ID                 registry.Harness
	Aliases            []string
	ProcessNames       []string
	Env                EnvKeys
	Capabilities       Capabilities
	IntegrationVersion int
}

type EnvField

type EnvField string
const (
	IntegrationVersion = 7

	EnvSessionID   EnvField = "session_id"
	EnvSessionPath EnvField = "session_path"
	EnvProjectRoot EnvField = "project_root"
	EnvPID         EnvField = "pid"
	EnvEvent       EnvField = "event"
)

type EnvKeys

type EnvKeys struct {
	SessionID   []string
	SessionPath []string
	ProjectRoot []string
	PID         []string
	Event       []string
}

type HookAdapter

type HookAdapter interface {
	HandleHook(invocation HookInvocation) HookResult
}

type HookInvocation

type HookInvocation struct {
	Event      string
	RawPayload json.RawMessage
	Payload    map[string]any
	ParentArgs []string
}

type HookPayloadValidator

type HookPayloadValidator func(json.RawMessage) bool

func PayloadValidator

func PayloadValidator[T any]() HookPayloadValidator

type HookResult

type HookResult struct {
	Report   registry.Observation
	ReportOK bool
	Response map[string]any
}

type HookTransition

type HookTransition string

HookTransition is the closed, dimension-aware state used by generated hook specifications that need to store a transition before rendering it.

func (HookTransition) State added in v1.3.0

func (transition HookTransition) State() string

State returns the activity or presence state represented by the transition.

type ImportManifestInstallPlan

type ImportManifestInstallPlan struct {
	Path       string
	Name       string
	Source     string
	Components []string
}

type InstallAction

type InstallAction interface {
	// contains filtered or unexported methods
}

type InstallAdvisor

type InstallAdvisor interface {
	InstallNextStep(changed bool, dryRun bool) string
	StatusNextStep(current bool, stale bool) string
}

type InstallPlan

type InstallPlan struct {
	Actions []InstallAction
}

type Installable

type Installable interface {
	InstallPlan(binary string) InstallPlan
}

type JSONCommandHookInstallPlan

type JSONCommandHookInstallPlan struct {
	Path              string
	Source            string
	Label             string
	ConfigLabel       string
	StatusMessage     string
	OmitStatusMessage bool
	HooksAtRoot       bool
	Hooks             []CommandHookInstallSpec
}

type JSONCommandHooksAction

type JSONCommandHooksAction struct {
	Plan JSONCommandHookInstallPlan
}

type ManagedTextBlockAction

type ManagedTextBlockAction struct {
	Plan ManagedTextBlockInstallPlan
}

type ManagedTextBlockInstallPlan

type ManagedTextBlockInstallPlan struct {
	Path        string
	Label       string
	ConfigLabel string
	StartMarker string
	EndMarker   string
	Block       string
}

type PayloadAdapter

type PayloadAdapter interface {
	PayloadCompatible(rawPayload json.RawMessage) bool
	PayloadDefaults(payload map[string]any) (PayloadDefaults, error)
}

type PayloadDefaults

type PayloadDefaults struct {
	SessionID   string
	SessionPath string
	CWD         string
	ProjectRoot string
	Event       string
	Attributes  map[string]string
}

type PluginDirectoryAction

type PluginDirectoryAction struct {
	Plan PluginDirectoryInstallPlan
}

type PluginDirectoryInstallPlan

type PluginDirectoryInstallPlan struct {
	Dir            string
	Label          string
	Files          []RenderedFileInstallSpec
	SnippetOrder   []string
	MarkerFile     string
	ObsoleteFiles  []string
	ImportManifest *ImportManifestInstallPlan
	Registration   PluginRegistration
}

type PluginRegistration

type PluginRegistration interface {
	ID() string
	Label() string
	Inspect(ctx context.Context, pluginDir string) (PluginRegistrationState, error)
	EnsureMutable(pluginDir string) error
	Install(ctx context.Context, pluginDir string) error
	CleanupFailedInstall(ctx context.Context, previousState PluginRegistrationState, pluginDir string) error
	Remove(ctx context.Context, pluginDir string) error
}

type PluginRegistrationState

type PluginRegistrationState uint8
const (
	PluginRegistrationMissing PluginRegistrationState = iota
	PluginRegistrationCurrent
	PluginRegistrationStale
	PluginRegistrationForeign
)

type RenderedFileAction

type RenderedFileAction struct {
	Plan RenderedFileInstallPlan
}

type RenderedFileInstallPlan

type RenderedFileInstallPlan struct {
	Path        string
	Label       string
	ConfigLabel string
	Content     string
	JSONContent any
}

type RenderedFileInstallSpec

type RenderedFileInstallSpec struct {
	Name        string
	Content     string
	JSONContent any
}

type RenderedFilesAction

type RenderedFilesAction struct {
	Plan RenderedFilesInstallPlan
}

type RenderedFilesInstallPlan

type RenderedFilesInstallPlan struct {
	Dir          string
	Label        string
	ConfigLabel  string
	Files        []RenderedFileInstallSpec
	SnippetOrder []string
}

type Resumable

type Resumable interface {
	ResumeCommand(sessionID string, sessionPath string) []string
}

type ScreenManifestProvider

type ScreenManifestProvider interface {
	ScreenManifest() string
}

type ShimAction

type ShimAction struct{}

type Transition

type Transition interface {
	registry.Activity | registry.Presence | HookTransition
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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