ask

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPendingApproval = "pending_approval"
	StatusApproved        = "approved"
	StatusRunning         = "running"
	StatusAnswered        = "answered"
	StatusDenied          = "denied"
	StatusFailed          = "failed"
	StatusTimedOut        = "timed_out"
)

Variables

View Source
var PolicyLoader func() (Policy, error)

PolicyLoader returns the owner's responder policy. The responder runs an arbitrary local command, so the policy must come only from the owner's DevX config file, never through viper: viper gives a project .devx/config.yaml and DEVX_* environment variables precedence, which would let a repository enable the responder, drop approval, or choose the executable. cmd installs the owner-config loader at startup. Unset, or on a load error, the responder is disabled (fail closed).

Functions

func RenderPrompt

func RenderPrompt(req *Request, target *session.Session, policy Policy) string

Types

type Approval

type Approval struct {
	FromSession string    `json:"from_session"`
	ToSession   string    `json:"to_session"`
	FromPath    string    `json:"from_path"`
	ToPath      string    `json:"to_path"`
	CreatedAt   time.Time `json:"created_at"`
}

type ApprovalStore

type ApprovalStore struct {
	Approvals []Approval `json:"approvals"`
}

type ExecuteOptions

type ExecuteOptions struct {
	Policy Policy
	Store  *Store
}

type ExecutionMetadata

type ExecutionMetadata struct {
	Command    string     `json:"command,omitempty"`
	PromptPath string     `json:"prompt_path,omitempty"`
	StartedAt  *time.Time `json:"started_at,omitempty"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
	ExitCode   int        `json:"exit_code,omitempty"`
	LogPath    string     `json:"log_path,omitempty"`
}

type Policy

type Policy struct {
	// LoadErr is set when the owner policy could not be loaded; such a
	// policy is disabled.
	LoadErr  error
	Enabled  bool
	Mode     string
	Command  string
	Args     []string
	Timeout  time.Duration
	ReadOnly bool
}

func EffectivePolicy

func EffectivePolicy() Policy

EffectivePolicy is the owner's responder policy, or a disabled policy carrying the load error when it cannot be read.

type Request

type Request struct {
	ID          string             `json:"id"`
	FromSession string             `json:"from_session"`
	ToSession   string             `json:"to_session"`
	FromPath    string             `json:"from_path,omitempty"`
	ToPath      string             `json:"to_path,omitempty"`
	Question    string             `json:"question"`
	Status      string             `json:"status"`
	CreatedAt   time.Time          `json:"created_at"`
	UpdatedAt   time.Time          `json:"updated_at"`
	Response    *Response          `json:"response,omitempty"`
	Execution   *ExecutionMetadata `json:"execution,omitempty"`
	Error       string             `json:"error,omitempty"`
}

func Execute

func Execute(ctx context.Context, req *Request, target *session.Session, opts ExecuteOptions) (*Request, error)

type Response

type Response struct {
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
	Responder string    `json:"responder"`
}

type Store

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

func NewStore

func NewStore() *Store

func NewStoreAt

func NewStoreAt(dir string) *Store

func (*Store) AllowFuture

func (s *Store) AllowFuture(fromSession, toSession, fromPath, toPath string) error

func (*Store) Approvals

func (s *Store) Approvals() (*ApprovalStore, error)

func (*Store) ApproveAlwaysAndExecute

func (s *Store) ApproveAlwaysAndExecute(ctx context.Context, id string, policy Policy) (*Request, error)

func (*Store) ApproveAndExecute

func (s *Store) ApproveAndExecute(ctx context.Context, id string, policy Policy) (*Request, error)

func (*Store) Create

func (s *Store) Create(fromSession, toSession, fromPath, toPath, question string) (*Request, error)

func (*Store) Deny

func (s *Store) Deny(id string) (*Request, error)

func (*Store) Dir

func (s *Store) Dir() string

func (*Store) Get

func (s *Store) Get(id string) (*Request, error)

func (*Store) IsAllowed

func (s *Store) IsAllowed(fromSession, toSession, fromPath, toPath string) (bool, error)

func (*Store) List

func (s *Store) List() ([]*Request, error)

func (*Store) Pending

func (s *Store) Pending() ([]*Request, error)

func (*Store) Save

func (s *Store) Save(req *Request) error

Jump to

Keyboard shortcuts

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