rex

package
v0.0.0-...-14e3c9d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

README

Agent Framework

This directory contains the Go implementation of the Agent Framework (formerly SWE-ReX).

Components

  • runtime/ - Runtime implementation for agent execution
  • deployment/ - Deployment configuration and management
  • server/ - Server implementation for agent communication

Integration

The Agent Framework integrates with the Agent Runtime to provide a complete agent system.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashAction

type BashAction struct {
	Command              string   `json:"command"`
	Session              string   `json:"session,omitempty"`
	Timeout              *float64 `json:"timeout,omitempty"`
	IsInteractiveCommand bool     `json:"is_interactive_command,omitempty"`
	IsInteractiveQuit    bool     `json:"is_interactive_quit,omitempty"`
	Check                string   `json:"check,omitempty"`
	ErrorMsg             string   `json:"error_msg,omitempty"`
	Expect               []string `json:"expect,omitempty"`
	ActionType           string   `json:"action_type"`
}

type BashInterruptAction

type BashInterruptAction struct {
	Session    string   `json:"session,omitempty"`
	Timeout    float64  `json:"timeout,omitempty"`
	NRetry     int      `json:"n_retry,omitempty"`
	Expect     []string `json:"expect,omitempty"`
	ActionType string   `json:"action_type"`
}

type BashObservation

type BashObservation struct {
	Output        string `json:"output,omitempty"`
	ExitCode      *int   `json:"exit_code,omitempty"`
	FailureReason string `json:"failure_reason,omitempty"`
	ExpectString  string `json:"expect_string,omitempty"`
	SessionType   string `json:"session_type"`
}

type BashSession

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

type CloseBashSessionRequest

type CloseBashSessionRequest struct {
	Session     string `json:"session,omitempty"`
	SessionType string `json:"session_type"`
}

type CloseBashSessionResponse

type CloseBashSessionResponse struct {
	SessionType string `json:"session_type"`
}

type CloseResponse

type CloseResponse struct{}

type Command

type Command struct {
	Command  interface{}       `json:"command"`
	Timeout  *float64          `json:"timeout,omitempty"`
	Shell    bool              `json:"shell,omitempty"`
	Check    bool              `json:"check,omitempty"`
	ErrorMsg string            `json:"error_msg,omitempty"`
	Env      map[string]string `json:"env,omitempty"`
	Cwd      string            `json:"cwd,omitempty"`
}

type CommandResponse

type CommandResponse struct {
	Stdout   string `json:"stdout,omitempty"`
	Stderr   string `json:"stderr,omitempty"`
	ExitCode *int   `json:"exit_code,omitempty"`
}

type CreateBashSessionRequest

type CreateBashSessionRequest struct {
	StartupSource  []string `json:"startup_source,omitempty"`
	Session        string   `json:"session,omitempty"`
	SessionType    string   `json:"session_type"`
	StartupTimeout float64  `json:"startup_timeout,omitempty"`
}

type CreateBashSessionResponse

type CreateBashSessionResponse struct {
	Output      string `json:"output,omitempty"`
	SessionType string `json:"session_type"`
}

type DefaultLogger

type DefaultLogger struct{}

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(format string, args ...interface{})

func (*DefaultLogger) Error

func (l *DefaultLogger) Error(format string, args ...interface{})

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(format string, args ...interface{})

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(format string, args ...interface{})

type Deployment

type Deployment interface {
	Start(ctx context.Context) error

	Stop(ctx context.Context) error

	GetRuntime() Runtime
}

func GetDeployment

func GetDeployment(config *DeploymentConfig, logger Logger) (Deployment, error)

type DeploymentConfig

type DeploymentConfig struct {
	Type                DeploymentType `json:"type"`
	DockerConfig        *DockerConfig  `json:"docker_config,omitempty"`
	RemoteConfig        *RemoteConfig  `json:"remote_config,omitempty"`
	PythonStandaloneDir string         `json:"python_standalone_dir,omitempty"`
}

type DeploymentType

type DeploymentType string
const (
	DeploymentTypeLocal DeploymentType = "local"

	DeploymentTypeDocker DeploymentType = "docker"

	DeploymentTypeRemote DeploymentType = "remote"
)

type DockerConfig

type DockerConfig struct {
	Image       string            `json:"image"`
	Volumes     map[string]string `json:"volumes,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`
	Network     string            `json:"network,omitempty"`
}

type IsAliveResponse

type IsAliveResponse struct {
	IsAlive bool   `json:"is_alive"`
	Message string `json:"message,omitempty"`
}

type LocalDeployment

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

func NewLocalDeployment

func NewLocalDeployment(logger Logger) *LocalDeployment

func (*LocalDeployment) GetRuntime

func (d *LocalDeployment) GetRuntime() Runtime

func (*LocalDeployment) Start

func (d *LocalDeployment) Start(ctx context.Context) error

func (*LocalDeployment) Stop

func (d *LocalDeployment) Stop(ctx context.Context) error

type LocalRuntime

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

func NewLocalRuntime

func NewLocalRuntime(logger Logger) *LocalRuntime

func (*LocalRuntime) Close

func (r *LocalRuntime) Close(ctx context.Context) (*CloseResponse, error)

func (*LocalRuntime) CloseSession

func (*LocalRuntime) CreateSession

func (*LocalRuntime) Execute

func (r *LocalRuntime) Execute(ctx context.Context, command *Command) (*CommandResponse, error)

func (*LocalRuntime) IsAlive

func (r *LocalRuntime) IsAlive(ctx context.Context, timeout *time.Duration) (*IsAliveResponse, error)

func (*LocalRuntime) ReadFile

func (r *LocalRuntime) ReadFile(ctx context.Context, request *ReadFileRequest) (*ReadFileResponse, error)

func (*LocalRuntime) RunInSession

func (r *LocalRuntime) RunInSession(ctx context.Context, action interface{}) (*BashObservation, error)

func (*LocalRuntime) Upload

func (r *LocalRuntime) Upload(ctx context.Context, request *UploadRequest) (*UploadResponse, error)

func (*LocalRuntime) WriteFile

func (r *LocalRuntime) WriteFile(ctx context.Context, request *WriteFileRequest) (*WriteFileResponse, error)

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
}

type ReadFileRequest

type ReadFileRequest struct {
	Path     string `json:"path"`
	Encoding string `json:"encoding,omitempty"`
	Errors   string `json:"errors,omitempty"`
}

type ReadFileResponse

type ReadFileResponse struct {
	Content string `json:"content,omitempty"`
}

type RemoteConfig

type RemoteConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Username string `json:"username"`
	Password string `json:"password,omitempty"`
	KeyFile  string `json:"key_file,omitempty"`
}

type Runtime

type Runtime struct {
	Agent interfaces.Agent

	Trajectories map[string]*Trajectory

	Context map[string]interface{}
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(agent interfaces.Agent, config RuntimeConfig) (*Runtime, error)

func (*Runtime) CreateTrajectory

func (r *Runtime) CreateTrajectory(id string, config TrajectoryConfig) (*Trajectory, error)

func (*Runtime) DeleteTrajectory

func (r *Runtime) DeleteTrajectory(id string) error

func (*Runtime) ExecuteTool

func (r *Runtime) ExecuteTool(ctx context.Context, name string, params map[string]interface{}) (interface{}, error)

func (*Runtime) GetContext

func (r *Runtime) GetContext() map[string]interface{}

func (*Runtime) GetTool

func (r *Runtime) GetTool(name string) (tools.Tool, error)

func (*Runtime) GetTrajectory

func (r *Runtime) GetTrajectory(id string) (*Trajectory, error)

func (*Runtime) ListTools

func (r *Runtime) ListTools() []tools.Tool

func (*Runtime) ListTrajectories

func (r *Runtime) ListTrajectories() []*Trajectory

func (*Runtime) LoadState

func (r *Runtime) LoadState(data []byte) error

func (*Runtime) LoadTrajectories

func (r *Runtime) LoadTrajectories(path string) error

func (*Runtime) RegisterTool

func (r *Runtime) RegisterTool(tool tools.Tool) error

func (*Runtime) SaveState

func (r *Runtime) SaveState() ([]byte, error)

func (*Runtime) SetContext

func (r *Runtime) SetContext(ctx map[string]interface{})

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context) error

func (*Runtime) Stop

func (r *Runtime) Stop() error

func (*Runtime) UpdateContext

func (r *Runtime) UpdateContext(updates map[string]interface{})

func (*Runtime) WaitForTrajectory

func (r *Runtime) WaitForTrajectory(id string, timeout time.Duration) error

type RuntimeConfig

type RuntimeConfig struct {
	Name string `json:"name"`

	Description string `json:"description"`

	TrajectoryPath string `json:"trajectory_path"`
}

type Trajectory

type Trajectory struct {
	Runtime *Runtime

	ID string

	Config TrajectoryConfig

	State TrajectoryState

	CurrentStep string

	Context map[string]interface{}

	Results map[string]interface{}

	Error error

	RetryCount int
	// contains filtered or unexported fields
}

func NewTrajectory

func NewTrajectory(runtime *Runtime, id string, config TrajectoryConfig) *Trajectory

func (*Trajectory) GetContext

func (t *Trajectory) GetContext() map[string]interface{}

func (*Trajectory) GetCurrentStep

func (t *Trajectory) GetCurrentStep() string

func (*Trajectory) GetError

func (t *Trajectory) GetError() error

func (*Trajectory) GetResults

func (t *Trajectory) GetResults() map[string]interface{}

func (*Trajectory) GetState

func (t *Trajectory) GetState() TrajectoryState

func (*Trajectory) LoadState

func (t *Trajectory) LoadState(data []byte) error

func (*Trajectory) Pause

func (t *Trajectory) Pause() error

func (*Trajectory) Resume

func (t *Trajectory) Resume(ctx context.Context) error

func (*Trajectory) SaveState

func (t *Trajectory) SaveState() ([]byte, error)

func (*Trajectory) SetContext

func (t *Trajectory) SetContext(ctx map[string]interface{})

func (*Trajectory) Start

func (t *Trajectory) Start(ctx context.Context) error

func (*Trajectory) Stop

func (t *Trajectory) Stop() error

func (*Trajectory) UpdateContext

func (t *Trajectory) UpdateContext(updates map[string]interface{})

func (*Trajectory) Wait

func (t *Trajectory) Wait(timeout time.Duration) error

type TrajectoryConfig

type TrajectoryConfig struct {
	Name string `json:"name"`

	Description string `json:"description"`

	Steps []TrajectoryStep `json:"steps"`

	MaxRetries int `json:"max_retries"`

	RetryDelay time.Duration `json:"retry_delay"`
}

type TrajectoryState

type TrajectoryState string
const (
	StateIdle      TrajectoryState = "idle"
	StateRunning   TrajectoryState = "running"
	StatePaused    TrajectoryState = "paused"
	StateCompleted TrajectoryState = "completed"
	StateFailed    TrajectoryState = "failed"
)

type TrajectoryStep

type TrajectoryStep struct {
	ID string `json:"id"`

	Name string `json:"name"`

	Description string `json:"description"`

	Tool string `json:"tool"`

	Params map[string]interface{} `json:"params"`

	NextSteps []string `json:"next_steps"`

	Condition string `json:"condition"`
}

type UploadRequest

type UploadRequest struct {
	SourcePath string `json:"source_path"`
	TargetPath string `json:"target_path"`
}

type UploadResponse

type UploadResponse struct{}

type WriteFileRequest

type WriteFileRequest struct {
	Content string `json:"content"`
	Path    string `json:"path"`
}

type WriteFileResponse

type WriteFileResponse struct{}

Jump to

Keyboard shortcuts

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