transport

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PermissionOutcomeSelected and PermissionOutcomeCancelled are the only two
	// ACP RequestPermissionOutcome discriminators.
	PermissionOutcomeSelected  = "selected"
	PermissionOutcomeCancelled = "cancelled"
)

Variables

This section is empty.

Functions

func AllowOptionID

func AllowOptionID(params json.RawMessage) string

AllowOptionID returns the id of the permission option that grants access, or "" when none of the offered options is an allow/approve option. It never falls back to an arbitrary option, so callers fail closed when no allow option exists. The ACP v1 PermissionOption id field is "optionId"; the legacy "id" spelling is accepted as a fallback.

Types

type Handlers

type Handlers struct {
	Permission func(ctx context.Context, params json.RawMessage) PermissionResponse
}

type Message

type Message struct {
	Method string
	Params json.RawMessage
}

type PermissionMode

type PermissionMode string
const (
	PermissionModeDeny        PermissionMode = "deny"
	PermissionModeAutoApprove PermissionMode = "auto_approve"
)

type PermissionResponse

type PermissionResponse struct {
	Outcome          string
	SelectedOptionID string
}

PermissionResponse is the host's decision for a session/request_permission. Outcome is the ACP outcome discriminator ("selected" or "cancelled"); SelectedOptionID is required when Outcome == "selected".

type ProcessConfig

type ProcessConfig struct {
	Command        string
	Args           []string
	Dir            string
	Env            []string
	PermissionMode PermissionMode
}

type StdioTransport

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

func (*StdioTransport) Alive

func (t *StdioTransport) Alive() bool

func (*StdioTransport) Close

func (t *StdioTransport) Close() error

func (*StdioTransport) Notify

func (t *StdioTransport) Notify(method string, params any) error

func (*StdioTransport) Request

func (t *StdioTransport) Request(ctx context.Context, method string, params any) (json.RawMessage, error)

func (*StdioTransport) Updates

func (t *StdioTransport) Updates(buffer int) (<-chan Message, func())

type Transport

type Transport interface {
	Request(ctx context.Context, method string, params any) (json.RawMessage, error)
	Notify(method string, params any) error
	Updates(buffer int) (<-chan Message, func())
	// Alive reports whether the underlying connection is still usable. A pooled
	// transport whose process has exited must not be reused.
	Alive() bool
	Close() error
}

func Open

func Open(ctx context.Context, cfg ProcessConfig, handlers Handlers) (Transport, error)

Jump to

Keyboard shortcuts

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