handlers

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateExecution

func CreateExecution(r *runner.Runner) gin.HandlerFunc

CreateExecution handles POST /v1/executions. It parses the request body, invokes the runner synchronously, and returns the full RunResult JSON. The "skill" field is required; "version" defaults to "latest" if omitted.

func DeleteSkill

func DeleteSkill(reg *registry.Registry, s *store.Store) gin.HandlerFunc

DeleteSkill handles DELETE /v1/skills/:name/:version. It removes the skill from both the registry and the metadata store, then returns 204 No Content.

func GetExecution

func GetExecution(s *store.Store) gin.HandlerFunc

GetExecution handles GET /v1/executions/:id. It retrieves an execution record from the store and enforces tenant isolation: the caller's tenant must match the execution's tenant.

func GetExecutionLogs

func GetExecutionLogs(s *store.Store) gin.HandlerFunc

GetExecutionLogs handles GET /v1/executions/:id/logs. It returns just the logs field as plain text.

func GetSkill

func GetSkill(reg *registry.Registry, s *store.Store) gin.HandlerFunc

GetSkill handles GET /v1/skills/:name/:version. It downloads the skill zip from the registry, parses SKILL.md, and returns the full metadata including the SKILL.md body content (instructions). When version is "latest", it resolves to the most recently uploaded version via the database before downloading from the registry.

func GetSkillFiles added in v0.6.0

func GetSkillFiles(reg *registry.Registry, s *store.Store) gin.HandlerFunc

GetSkillFiles handles GET /v1/skills/:name/:version/files. It downloads the skill zip from the registry, extracts all files, and returns them as a JSON array. An optional "path" query parameter returns only the matching file.

func Health

func Health(s *store.Store) gin.HandlerFunc

Health returns a liveness handler that always responds 200 OK if the process is running. Load balancers and orchestrators use this to determine whether to route traffic to the instance.

func ListSkills

func ListSkills(s *store.Store, reg *registry.Registry) gin.HandlerFunc

ListSkills handles GET /v1/skills. It returns all skill metadata for the authenticated tenant, including descriptions so agents can decide which skill to use.

func Ready

func Ready(s *store.Store) gin.HandlerFunc

Ready returns a readiness handler that checks all downstream dependencies (Postgres, etc.) and reports whether the instance can serve requests. Orchestrators use this to decide when to add the instance to the load balancer pool.

func UploadSkill

func UploadSkill(reg *registry.Registry, s *store.Store, cfg *config.Config) gin.HandlerFunc

UploadSkill handles POST /v1/skills.

It accepts skill zip data via two content types:

  • application/zip: raw zip body
  • multipart/form-data: zip in a "file" form field

The zip is validated (must contain SKILL.md with valid frontmatter), then uploaded to the registry. Skill metadata is also persisted in PostgreSQL so that list operations can return descriptions without downloading every zip archive. Returns 201 with skill metadata on success.

Types

type FilesHandler added in v0.2.0

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

FilesHandler groups the handler methods for the /v1/files endpoints.

func NewFilesHandler added in v0.2.0

func NewFilesHandler(st *store.Store, col *artifacts.Collector) *FilesHandler

NewFilesHandler creates a new FilesHandler with the given store and artifact collector dependencies.

func (*FilesHandler) Delete added in v0.2.0

func (h *FilesHandler) Delete(c *gin.Context)

Delete handles DELETE /v1/files/:id. It removes the file record from the database and the object from S3.

func (*FilesHandler) Download added in v0.2.0

func (h *FilesHandler) Download(c *gin.Context)

Download handles GET /v1/files/:id/download. It streams the file content from S3/MinIO directly to the client.

func (*FilesHandler) Get added in v0.2.0

func (h *FilesHandler) Get(c *gin.Context)

Get handles GET /v1/files/:id. It retrieves a single file record and enforces tenant isolation.

func (*FilesHandler) List added in v0.2.0

func (h *FilesHandler) List(c *gin.Context)

List handles GET /v1/files. It returns files matching the query parameters for the authenticated tenant, with pagination via limit and offset.

func (*FilesHandler) Update added in v0.2.0

func (h *FilesHandler) Update(c *gin.Context)

Update handles PUT /v1/files/:id. It accepts a multipart form upload with a "file" field, uploads the new content to S3, and creates a new version record linked to the original via parent_id.

func (*FilesHandler) Upload added in v0.5.0

func (h *FilesHandler) Upload(c *gin.Context)

Upload handles POST /v1/files. Accepts multipart form with "file" field, uploads to S3, creates DB record.

func (*FilesHandler) Versions added in v0.2.0

func (h *FilesHandler) Versions(c *gin.Context)

Versions handles GET /v1/files/:id/versions. It returns all versions of the file, ordered by version descending.

type SandboxDirEntry added in v0.8.0

type SandboxDirEntry struct {
	Path  string `json:"path"`
	IsDir bool   `json:"is_dir"`
	Size  int64  `json:"size"`
}

SandboxDirEntry represents a single directory entry in a listing response.

type SandboxExecRequest added in v0.8.0

type SandboxExecRequest struct {
	Command   string `json:"command"`
	WorkDir   string `json:"workdir,omitempty"`    // default: /sandbox/session
	TimeoutMs int    `json:"timeout_ms,omitempty"` // default: 30000
}

SandboxExecRequest is the body for POST /v1/sandbox/execute.

type SandboxExecResponse added in v0.8.0

type SandboxExecResponse struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

SandboxExecResponse is the response for POST /v1/sandbox/execute.

type SandboxHandler added in v0.8.0

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

SandboxHandler groups sandbox shell HTTP handlers and their dependencies.

func NewSandboxHandler added in v0.8.0

func NewSandboxHandler(sm *sandbox.SessionManager) *SandboxHandler

NewSandboxHandler creates a handler with the session manager dependency.

func (*SandboxHandler) Destroy added in v0.8.0

func (h *SandboxHandler) Destroy(c *gin.Context)

Destroy handles DELETE /v1/sandbox/:session.

func (*SandboxHandler) Execute added in v0.8.0

func (h *SandboxHandler) Execute(c *gin.Context)

Execute handles POST /v1/sandbox/execute.

func (*SandboxHandler) LimitBody added in v0.8.1

func (h *SandboxHandler) LimitBody() gin.HandlerFunc

LimitBody returns middleware that limits the request body size for sandbox endpoints.

func (*SandboxHandler) ListDir added in v0.8.0

func (h *SandboxHandler) ListDir(c *gin.Context)

ListDir handles POST /v1/sandbox/list-dir.

func (*SandboxHandler) ReadFile added in v0.8.0

func (h *SandboxHandler) ReadFile(c *gin.Context)

ReadFile handles POST /v1/sandbox/read-file.

func (*SandboxHandler) Sync added in v0.8.0

func (h *SandboxHandler) Sync(c *gin.Context)

Sync handles POST /v1/sandbox/sync.

func (*SandboxHandler) WriteFile added in v0.8.0

func (h *SandboxHandler) WriteFile(c *gin.Context)

WriteFile handles POST /v1/sandbox/write-file.

type SandboxListRequest added in v0.8.0

type SandboxListRequest struct {
	Path     string `json:"path"`
	MaxDepth int    `json:"max_depth,omitempty"` // default: 2
}

SandboxListRequest is the body for POST /v1/sandbox/list-dir.

type SandboxListResponse added in v0.8.0

type SandboxListResponse struct {
	Entries []SandboxDirEntry `json:"entries"`
}

SandboxListResponse is the response for POST /v1/sandbox/list-dir.

type SandboxReadRequest added in v0.8.0

type SandboxReadRequest struct {
	Path string `json:"path"`
}

SandboxReadRequest is the body for POST /v1/sandbox/read-file.

type SandboxReadResponse added in v0.8.0

type SandboxReadResponse struct {
	Content string `json:"content"`
	Size    int64  `json:"size"`
}

SandboxReadResponse is the response for POST /v1/sandbox/read-file.

type SandboxWriteRequest added in v0.8.0

type SandboxWriteRequest struct {
	Path    string `json:"path"`
	Content string `json:"content"`
	Append  bool   `json:"append,omitempty"`
}

SandboxWriteRequest is the body for POST /v1/sandbox/write-file.

type SessionsHandler added in v0.8.0

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

SessionsHandler groups session-related HTTP handlers and their dependencies.

func NewSessionsHandler added in v0.8.0

func NewSessionsHandler(s *store.Store, col *artifacts.Collector) *SessionsHandler

NewSessionsHandler creates a handler with all required dependencies.

func (*SessionsHandler) Delete added in v0.8.0

func (h *SessionsHandler) Delete(c *gin.Context)

Delete handles DELETE /v1/sessions/:external_id.

func (*SessionsHandler) DeleteFile added in v0.8.0

func (h *SessionsHandler) DeleteFile(c *gin.Context)

DeleteFile handles DELETE /v1/sessions/:external_id/files/:filename.

func (*SessionsHandler) DownloadFile added in v0.8.0

func (h *SessionsHandler) DownloadFile(c *gin.Context)

DownloadFile handles GET /v1/sessions/:external_id/files/:filename.

func (*SessionsHandler) ListFiles added in v0.8.0

func (h *SessionsHandler) ListFiles(c *gin.Context)

ListFiles handles GET /v1/sessions/:external_id/files.

type SkillFileEntry added in v0.6.0

type SkillFileEntry struct {
	Path      string `json:"path"`
	Content   string `json:"content"`
	SizeBytes int    `json:"size_bytes"`
}

SkillFileEntry represents a single file extracted from a skill archive.

Jump to

Keyboard shortcuts

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