interactive

package
v0.93.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package interactive serves the shared interactive agent HTTP surface: readiness, metrics and prompt intake, over a per-session cache of long-lived conversations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PendingPermission added in v0.93.0

type PendingPermission struct {
	// ID identifies the request. It is generated per request and is the only handle
	// a verdict may name.
	ID string `json:"id"`
	// ToolName is the name of the tool the CLI wants to invoke.
	ToolName string `json:"tool_name"`
	// Description is the CLI's human-readable description of the invocation.
	Description string `json:"description"`
	// InputPreview is a preview of the tool input. It is never logged.
	InputPreview string `json:"input_preview"`
}

PendingPermission is one permission request currently waiting for a verdict, as served on GET /permission.

type PermissionRegistry added in v0.93.0

type PermissionRegistry interface {
	// DecidePermission registers request as pending and blocks until a verdict is
	// posted for it or ctx is cancelled.
	DecidePermission(
		ctx context.Context,
		request claude.PermissionRequest,
	) (claude.PermissionDecision, error)

	// List returns the requests currently pending. The result is never nil, so the
	// endpoint always renders a JSON array.
	List() []PendingPermission

	// Resolve delivers decision to the pending request named by id and reports
	// whether such a request was pending. It never blocks.
	Resolve(id string, decision claude.PermissionDecision) bool
}

PermissionRegistry holds the permission requests one service is currently waiting on. It is the PermissionDecider the sessions built for that service consult, so a request raised by a turn appears on that service's endpoint and nowhere else.

func NewPermissionRegistry added in v0.93.0

func NewPermissionRegistry() PermissionRegistry

NewPermissionRegistry creates an empty registry. Construct one per service and pass the same instance to the session factory and to NewServiceWithPermissions, so a request raised by a session is served by that service's endpoint.

type Service

type Service interface {
	// Handler returns the HTTP handler serving GET /readiness, GET /metrics and
	// POST /prompt, plus GET and POST /permission when the service was built with a
	// permission registry.
	Handler() http.Handler

	// Run serves the handler on the configured listen address until ctx is cancelled.
	Run(ctx context.Context) error
}

Service serves the interactive agent HTTP surface.

func NewService

func NewService(
	sessions agentlib.SessionFactory,
	listen string,
	providerBaseURL string,
	registry *prometheus.Registry,
) Service

NewService creates the interactive session service.

sessions supplies one conversation per session id; listen is the address the service binds; providerBaseURL is the endpoint the readiness probe dials (empty means the check is skipped and reported as such); registry is the Prometheus registry the metrics route gathers from — a parameter rather than a library singleton, so each binary keeps its own metrics identity. The permission endpoint is not served by this constructor; use NewServiceWithPermissions to serve it.

func NewServiceWithPermissions added in v0.93.0

func NewServiceWithPermissions(
	sessions agentlib.SessionFactory,
	listen string,
	providerBaseURL string,
	registry *prometheus.Registry,
	permissions PermissionRegistry,
) Service

NewServiceWithPermissions creates the interactive session service with the permission endpoint enabled.

permissions is the registry the endpoint serves and the decider the sessions built by the caller's factory consult; the caller constructs it first and passes the one instance to both, which is what makes the endpoint and the sessions resolve through the same registry. A nil permissions is invalid here — use NewService for that.

Jump to

Keyboard shortcuts

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