agent

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package agent defines the interface for AI agent adapters. Each supported agent (Claude Code, Cursor, Codex) implements this interface to translate between the agent's native hook format and Kontext's protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns all registered agent names.

func Register

func Register(a Agent)

Register adds an agent adapter to the registry.

Types

type Agent

type Agent interface {
	// Name returns the agent identifier (e.g., "claude", "cursor", "codex").
	Name() string

	// DecodeHookInput parses the agent's native hook stdin JSON into a HookEvent.
	DecodeHookInput(input []byte) (*HookEvent, error)

	// EncodeAllow encodes an allow decision in the agent's native output format.
	EncodeAllow(event *HookEvent, reason string) ([]byte, error)

	// EncodeDeny encodes a deny decision in the agent's native output format.
	// The returned bytes are written to stdout, and the process exits with code 2.
	EncodeDeny(event *HookEvent, reason string) ([]byte, error)
}

Agent is the interface that each supported AI agent must implement. It handles the translation between the agent's native hook I/O format and Kontext's internal representation.

func Get

func Get(name string) (Agent, bool)

Get returns the agent adapter for the given name.

type HookEvent

type HookEvent struct {
	SessionID     string
	HookEventName string // "PreToolUse", "PostToolUse", "UserPromptSubmit"
	ToolName      string
	ToolInput     map[string]any
	ToolResponse  map[string]any // PostToolUse only
	ToolUseID     string
	CWD           string
}

HookEvent is the normalized representation of a hook event across all agents.

Directories

Path Synopsis
Package claude implements the agent adapter for Claude Code.
Package claude implements the agent adapter for Claude Code.

Jump to

Keyboard shortcuts

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