localruntime

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSocketPath

func DefaultSocketPath() string

func EnsureSocketDir

func EnsureSocketDir(socketPath string) error

func EventFromEvaluateRequest

func EventFromEvaluateRequest(sessionID, fallbackAgent string, req *EvaluateRequest) (hook.Event, error)

func ReadMessage

func ReadMessage(conn net.Conn, v any) error

func ResultFromEvaluateResult

func ResultFromEvaluateResult(result EvaluateResult) hook.Result

func WriteMessage

func WriteMessage(conn net.Conn, v any) error

Types

type Client

type Client struct {
	SocketPath string
	Timeout    time.Duration
}

func NewClient

func NewClient(socketPath string) Client

func (Client) Process

func (c Client) Process(ctx context.Context, event hook.Event) (hook.Result, error)

type EvaluateRequest

type EvaluateRequest struct {
	Type           string          `json:"type"`
	SessionID      string          `json:"session_id,omitempty"`
	Agent          string          `json:"agent"`
	HookEvent      string          `json:"hook_event"`
	ToolName       string          `json:"tool_name"`
	ToolInput      json.RawMessage `json:"tool_input,omitempty"`
	ToolResponse   json.RawMessage `json:"tool_response,omitempty"`
	ToolUseID      string          `json:"tool_use_id"`
	CWD            string          `json:"cwd"`
	PermissionMode string          `json:"permission_mode,omitempty"`
	DurationMs     *int64          `json:"duration_ms,omitempty"`
	Error          string          `json:"error,omitempty"`
	IsInterrupt    *bool           `json:"is_interrupt,omitempty"`
}

func EvaluateRequestFromEvent

func EvaluateRequestFromEvent(event hook.Event) (EvaluateRequest, error)

type EvaluateResult

type EvaluateResult struct {
	Type         string         `json:"type"`
	Decision     string         `json:"decision,omitempty"`
	Allowed      bool           `json:"allowed"`
	Reason       string         `json:"reason"`
	ReasonCode   string         `json:"reason_code,omitempty"`
	RequestID    string         `json:"request_id,omitempty"`
	Mode         string         `json:"mode,omitempty"`
	Epoch        string         `json:"epoch,omitempty"`
	UpdatedInput map[string]any `json:"updated_input,omitempty"`
}

func EvaluateResultFromResult

func EvaluateResultFromResult(result hook.Result) EvaluateResult

type Options

type Options struct {
	SocketPath  string
	Core        *runtimecore.Core
	SessionID   string
	AgentName   string
	AsyncIngest bool
	OnFailure   func(hook.Event, error) hook.Result
	Diagnostic  diagnostic.Logger
}

type Service

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

func NewService

func NewService(opts Options) (*Service, error)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

func (*Service) SocketPath

func (s *Service) SocketPath() string

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) Stop

func (s *Service) Stop()

Jump to

Keyboard shortcuts

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