agentexec

package
v0.0.0-...-94730e1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: GPL-3.0 Imports: 43 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentexec owns transport-independent, audited asset operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJournalFull   = errors.New("audit journal is full; new operations are disabled")
	ErrEvidenceLimit = errors.New("operation evidence limit reached")
)

Functions

func NormalizeIssuer

func NormalizeIssuer(value string) (string, error)

Types

type Action

type Action struct {
	ID                   string         `json:"id"`
	ActionID             string         `json:"action_id"`
	SessionID            string         `json:"session_id"`
	Kind                 string         `json:"kind"`
	Status               string         `json:"status"`
	Request              map[string]any `json:"request,omitempty"`
	RequestHash          string         `json:"request_hash,omitempty"`
	Result               map[string]any `json:"result,omitempty"`
	ApprovalURL          string         `json:"approval_url,omitempty"`
	CancelRequested      bool           `json:"cancel_requested,omitempty"`
	AuditStatus          string         `json:"audit_status,omitempty"`
	Events               []Event        `json:"events,omitempty"`
	NextOffset           *int64         `json:"next_offset"`
	EvidencePending      bool           `json:"evidence_pending"`
	LastSequence         uint64         `json:"last_sequence,omitempty"`
	HandoffURL           string         `json:"handoff_url,omitempty"`
	ResultExpiresAt      *time.Time     `json:"result_expires_at,omitempty"`
	NextStep             string         `json:"next_step,omitempty"`
	Terminal             bool           `json:"is_terminal"`
	OutputComplete       bool           `json:"output_complete"`
	PollAfterMS          int            `json:"poll_after_ms,omitempty"`
	NextCursor           string         `json:"next_cursor,omitempty"`
	Output               []OutputStream `json:"output,omitempty"`
	OutputLossy          bool           `json:"output_lossy,omitempty"`
	OutputRequiresCursor bool           `json:"output_requires_cursor,omitempty"`
	Transfer             *Transfer      `json:"transfer,omitempty"`
}

type Core

type Core interface {
	Call(context.Context, string, any, any) error
}

Core is also the test seam for authorization and the durable dispatch claim.

type CoreClient

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

func NewCoreClient

func NewCoreClient(base string, key model.AccessKey) (*CoreClient, error)

func (*CoreClient) Call

func (c *CoreClient) Call(ctx context.Context, path string, body, result any) error

type CoreError

type CoreError struct {
	Status       int
	Operation    string
	Code         string
	RetryAfterMS int
}

func (*CoreError) Error

func (e *CoreError) Error() string

type Event

type Event struct {
	EventID      string         `json:"event_id"`
	ActionID     string         `json:"action_id"`
	Sequence     uint64         `json:"sequence"`
	State        string         `json:"state"`
	Payload      map[string]any `json:"payload"`
	OccurredAt   time.Time      `json:"occurred_at"`
	SessionToken string         `json:"session_token,omitempty"`
	Key          uint64         `json:"-"`
}

type HTTP

type HTTP struct {
	Resource     string
	Issuer       string
	Handler      http.Handler
	Metadata     http.Handler
	Path         string
	MetadataPath string
}

func NewHTTP

func NewHTTP(r *Runtime, resourceURL, issuerURL string) (*HTTP, error)

type Journal

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

Journal atomically persists each state change and its outbound audit event. Values are encrypted because retry records include scoped Core capabilities. bbolt's default synchronous commits are intentionally never disabled.

func OpenJournal

func OpenJournal(directory string, maxBytes int64) (*Journal, error)

func (*Journal) Ack

func (j *Journal) Ack(event Event) error

func (*Journal) Action

func (j *Journal) Action(id string) (rec record, err error)

func (*Journal) ActionEvents

func (j *Journal) ActionEvents(id string, after uint64, limit int) ([]Event, error)

ActionEvents exposes only bounded, undelivered output. Core authorizes the corresponding action before the runtime merges this page with delivered data.

func (*Journal) Append

func (j *Journal) Append(id, state string, payload map[string]any) error

func (*Journal) Close

func (j *Journal) Close() error

func (*Journal) DeleteSession

func (j *Journal) DeleteSession(id string) error

func (*Journal) Intent

func (j *Journal) Intent(id string) error

func (*Journal) NextSession

func (j *Journal) NextSession() (*Session, error)

NextSession advances only one record so a slow close cannot skip the rest of a prefetched page. A nil result ends this pass and resets the cursor.

func (*Journal) Pending

func (j *Journal) Pending(limit int) (events []Event, err error)

Pending rotates between actions while preserving each action's event order. The index avoids scanning a failed action's entire backlog to reach another.

func (*Journal) Prune

func (j *Journal) Prune(now time.Time) ([]string, error)

Prune scans at most 128 records per call, only deleting after every audit event was acknowledged and its 24-hour retention elapsed. Returned artifact paths may be deleted by the runtime after the transaction commits.

func (*Journal) PutAction

func (j *Journal) PutAction(action Action, sessionToken string) error

func (*Journal) Recover

func (j *Journal) Recover() error

func (*Journal) SaveSession

func (j *Journal) SaveSession(session Session) error

func (*Journal) SyncCore

func (j *Journal) SyncCore(action Action) (bool, error)

SyncCore accepts an authoritative Core state without emitting it back to Core as a new event. Local evidence must be delivered before reconciliation. A false result means no local record, an ineligible state, or pending evidence.

func (*Journal) Unfinished

func (j *Journal) Unfinished(limit int) (records []record, more bool, err error)

Unfinished scans at most 128 records per call. More indicates that this pass has unscanned records, including when a page contains only completed actions.

type Options

type Options struct {
	Directory       string
	MaxSessions     int
	MaxPending      int
	MaxRunning      int
	QueueTimeout    time.Duration
	MaxRequests     int
	ControlRequests int
	MaxOutputBytes  int64
	MaxFileBytes    int64
	MaxStagedFiles  int
	JournalBytes    int64
	IdleTimeout     time.Duration
}

type OutputStream

type OutputStream struct {
	Stream string `json:"stream"`
	Text   string `json:"text"`
}

type Principal

type Principal struct {
	UserID           string    `json:"user_id"`
	AllOrganizations bool      `json:"all_organizations,omitempty"`
	ClientID         string    `json:"client_id"`
	ContextToken     string    `json:"context_token"`
	ExpiresAt        time.Time `json:"expires_at"`
	Resource         string    `json:"resource"`
	Scopes           []string  `json:"scopes"`
	RemoteAddr       string    `json:"-"`
}

Principal is issued by Core after validating a resource-bound OAuth token. ContextToken must never be returned to an MCP client or included in logs.

type Runtime

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

func New

func New(core Core, jms *service.JMService, options Options) (*Runtime, error)

func (*Runtime) Cancel

func (r *Runtime) Cancel(ctx context.Context, p Principal, id string) (Action, error)

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) Connect

func (r *Runtime) Connect(ctx context.Context, p Principal, asset, account, protocol, key, remoteAddr string) (map[string]any, error)

func (*Runtime) Disconnect

func (r *Runtime) Disconnect(ctx context.Context, p Principal, id string) (map[string]any, error)

func (*Runtime) Download

func (r *Runtime) Download(ctx context.Context, p Principal, id string) (*os.File, int64, string, error)

func (*Runtime) FindAction

func (r *Runtime) FindAction(ctx context.Context, p Principal, key, sessionID string) (string, error)

func (*Runtime) Get

func (r *Runtime) Get(ctx context.Context, p Principal, id string, offset, limit int64) (Action, error)

func (*Runtime) GetPage

func (r *Runtime) GetPage(ctx context.Context, p Principal, id string, offset, limit int64, value string) (Action, error)

func (*Runtime) Introspect

func (r *Runtime) Introspect(ctx context.Context, token, resource string) (p Principal, err error)

func (*Runtime) ListResources

func (r *Runtime) ListResources(ctx context.Context, p Principal, sessions bool, sessionID, status string, offset, limit int) (map[string]any, error)

func (*Runtime) RecoverSession

func (r *Runtime) RecoverSession(ctx context.Context, p Principal, id, key string) (map[string]any, error)

func (*Runtime) Search

func (r *Runtime) Search(ctx context.Context, p Principal, query, assetID string, offset, limit, accountOffset int) (map[string]any, error)

func (*Runtime) String

func (r *Runtime) String() string

func (*Runtime) Submit

func (r *Runtime) Submit(ctx context.Context, p Principal, sessionID, kind, key string, request map[string]any) (Action, error)

func (*Runtime) Upload

func (r *Runtime) Upload(ctx context.Context, p Principal, id string, body io.Reader, length int64, digest string) (Action, error)

type Session

type Session struct {
	ID                  string         `json:"id"`
	Status              string         `json:"status"`
	AuthorizationStatus string         `json:"authorization_status,omitempty"`
	ActionID            string         `json:"action_id"`
	SessionToken        string         `json:"session_token,omitempty"`
	TerminalSessionID   string         `json:"terminal_session_id,omitempty"`
	Protocol            string         `json:"protocol,omitempty"`
	ApprovalURL         string         `json:"approval_url,omitempty"`
	ExpiresAt           time.Time      `json:"expires_at,omitempty"`
	RequiresTerminal    bool           `json:"requires_terminal,omitempty"`
	Capabilities        map[string]any `json:"capabilities,omitempty"`
}

type ToolError

type ToolError struct {
	Code         string `json:"code"`
	Message      string `json:"message"`
	HTTPStatus   int    `json:"http_status,omitempty"`
	Retryable    bool   `json:"retryable"`
	RetryMode    string `json:"retry_mode"`
	NextStep     string `json:"next_step"`
	RetryAfterMS int    `json:"retry_after_ms,omitempty"`
}

type Transfer

type Transfer struct {
	URL                    string            `json:"url"`
	Method                 string            `json:"method"`
	Headers                map[string]string `json:"headers"`
	RequiresBearer         bool              `json:"requires_bearer"`
	RequiresClientTransfer bool              `json:"requires_client_transfer"`
	Ready                  bool              `json:"ready"`
	Size                   any               `json:"size,omitempty"`
	SHA256                 string            `json:"sha256,omitempty"`
	ContentLengthRequired  bool              `json:"content_length_required,omitempty"`
	ExpiresAt              *time.Time        `json:"expires_at,omitempty"`
}

Jump to

Keyboard shortcuts

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