workspace

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SubdirUploads   = "uploads"
	SubdirImages    = "uploads/images"
	SubdirDocuments = "uploads/documents"
	SubdirOther     = "uploads/other"
	SubdirPlans     = "plans"
	SubdirArtifacts = "artifacts"
)

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath(sessionID string) (string, error)

DefaultPath returns the default workspace path for a session without creating it.

func EnsureDir

func EnsureDir(path string) error

EnsureDir creates the workspace directory if it doesn't exist.

func Resolve

func Resolve(path, workspaceRoot string) (string, error)

Resolve resolves path against workspaceRoot. Relative paths are joined; absolute paths are validated. Returns an error if the resolved path escapes the workspace.

func Validate

func Validate(absPath, workspaceRoot string) error

Validate checks that absPath is within workspaceRoot. Returns an error if the path would escape the workspace via directory traversal or a symlink whose target lies outside the workspace.

Types

type Context

type Context struct {
	Root string `json:"root"`
}

Context represents the filesystem boundary for one agent session.

func New

func New(root string) (*Context, error)

New resolves, cleans, and creates a workspace root.

func (*Context) ArtifactsPath

func (c *Context) ArtifactsPath() string

ArtifactsPath returns the absolute path to the artifacts directory.

func (*Context) EnsureSubdirs

func (c *Context) EnsureSubdirs() error

EnsureSubdirs creates the standard subdirectory layout inside the workspace. Safe to call multiple times; existing directories are left untouched.

func (*Context) PlansPath

func (c *Context) PlansPath() string

PlansPath returns the absolute path to the plans directory.

func (*Context) Resolve

func (c *Context) Resolve(rel string) (string, error)

Resolve resolves rel against the workspace root. Relative paths are anchored to the workspace root and validated to stay inside it. Absolute paths are resolved as-is — the caller (sandbox FilesystemPolicy) handles dangerous-prefix blocking; workspace containment is not enforced for absolute paths so that the user can explicitly approve writes to /tmp or other out-of-workspace dirs.

func (*Context) UploadsPath

func (c *Context) UploadsPath(category string) string

UploadsPath returns the absolute path to the uploads sub-category directory. category should be one of "images", "documents", or "other".

func (*Context) Validate

func (c *Context) Validate(abs string) error

Validate verifies that abs is within the workspace root.

Jump to

Keyboard shortcuts

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