source

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SummaryBytes = 8 << 10

Variables

This section is empty.

Functions

func ApprovedScript

func ApprovedScript(
	ctx context.Context,
	approvals ApprovalReader,
	profileID, definitionDir, name string,
) (data []byte, hash string, approved bool, err error)

ApprovedScript reads an executable script and reports whether the operator approved its current bytes, keyed the same way approvals are stored: profile, resolved definition dir, name.

func InspectScript

func InspectScript(dir, name string) ([]byte, string, error)

func ReadScript

func ReadScript(dir, name string) ([]byte, string, error)

func SanitizeText

func SanitizeText(text string, limit int) string

func ValidScript

func ValidScript(name string) bool

func ValidateResult

func ValidateResult(r Result, l Limits) error

Types

type ApprovalReader

type ApprovalReader interface {
	ApprovedHash(context.Context, string, string, string) (string, error)
}

type CatalogScope

type CatalogScope struct{ ProfileID, WorkspaceID string }

type Error

type Error struct {
	Code   ErrorCode `json:"code"`
	Detail string    `json:"detail"`
}

func Failure

func Failure(code, detail string) *Error

func (*Error) DiagnosticCode

func (e *Error) DiagnosticCode() string

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string

type ExtensionPoller

type ExtensionPoller interface {
	PollSource(context.Context, CatalogScope, string, Request) (Result, error)
	SourceKinds(context.Context, CatalogScope) ([]KindDescriptor, error)
}

type Item

type Item struct {
	Key        string         `json:"key"`
	Title      string         `json:"title"`
	Summary    string         `json:"summary,omitempty"`
	URL        string         `json:"url,omitempty"`
	Attributes jsontext.Value `json:"attributes,omitempty"`
}

type KindDescriptor

type KindDescriptor struct {
	Kind         string         `json:"kind"`
	Extension    string         `json:"extension"`
	Title        string         `json:"title"`
	Description  string         `json:"description,omitempty"`
	ParamsSchema jsontext.Value `json:"params_schema,omitempty"`
}

type Limits

type Limits struct {
	MaxOutputBytes  int `json:"-"`
	MaxItems        int `json:"max_items"`
	MaxSummaryBytes int `json:"max_summary_bytes"`
	MaxStateBytes   int `json:"max_state_bytes"`
}

type Ref

type Ref struct {
	ID     string         `json:"id"`
	Kind   string         `json:"kind,omitempty"`
	Script string         `json:"script,omitempty"`
	With   jsontext.Value `json:"with,omitempty"`
}

func (Ref) Digest

func (r Ref) Digest() (string, error)

func (Ref) Validate

func (r Ref) Validate() error

type Request

type Request struct {
	Version   int            `json:"version"`
	SourceID  string         `json:"source_id"`
	Kind      string         `json:"kind,omitempty"`
	Params    jsontext.Value `json:"params"`
	State     jsontext.Value `json:"state"`
	Limits    Limits         `json:"limits"`
	Workspace WorkspaceRef   `json:"workspace"`
	Now       time.Time      `json:"now"`
	DryRun    bool           `json:"dry_run"`
}

type Result

type Result struct {
	Items []Item         `json:"items"`
	State jsontext.Value `json:"state,omitempty"`
	More  bool           `json:"more,omitzero"`
}

type Runner

type Runner interface {
	Poll(context.Context, Ref, Request) (Result, error)
}

type ScriptRunner

type ScriptRunner struct {
	DefinitionDir, ProfileID, Agent string
	ScriptsEnabled                  bool
	Timeout                         time.Duration
	MaxOutputBytes                  int
	EnvAllow                        []string
	Approvals                       ApprovalReader
}

func (*ScriptRunner) Poll

func (s *ScriptRunner) Poll(ctx context.Context, ref Ref, req Request) (Result, error)

type WorkspaceRef

type WorkspaceRef struct {
	ID      string `json:"id"`
	RootDir string `json:"root_dir"`
}

Jump to

Keyboard shortcuts

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