worklet

package
v0.0.0-...-f0049f5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(deps *deps.Deps) *http.ServeMux

New returns a *http.ServeMux with worklet routes following the main.go pattern

Types

type ClaudeClient

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

func NewClaudeClient

func NewClaudeClient() *ClaudeClient

func (*ClaudeClient) ApplyPrompt

func (c *ClaudeClient) ApplyPrompt(ctx context.Context, repoPath, prompt string) error

func (*ClaudeClient) CleanupOldSessions

func (c *ClaudeClient) CleanupOldSessions(maxAge time.Duration) error

func (*ClaudeClient) CloseSession

func (c *ClaudeClient) CloseSession(sessionID string) error

func (*ClaudeClient) CreatePR

func (c *ClaudeClient) CreatePR(ctx context.Context, repoPath, branchName, title, description string) error

func (*ClaudeClient) GetSessionStatus

func (c *ClaudeClient) GetSessionStatus(sessionID string) (string, error)

func (*ClaudeClient) ListSessions

func (c *ClaudeClient) ListSessions() ([]string, error)

func (*ClaudeClient) ProcessPrompt

func (c *ClaudeClient) ProcessPrompt(ctx context.Context, repoPath, prompt string) (string, error)

type CreateWorkletRequest

type CreateWorkletRequest struct {
	Name        string            `json:"name" binding:"required"`
	Description string            `json:"description"`
	GitRepo     string            `json:"git_repo" binding:"required"`
	Branch      string            `json:"branch"`
	BasePrompt  string            `json:"base_prompt"`
	Environment map[string]string `json:"environment"`
}

type DockerClient

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

func NewDockerClient

func NewDockerClient() *DockerClient

func (*DockerClient) BuildAndRun

func (d *DockerClient) BuildAndRun(ctx context.Context, repoPath string, worklet *Worklet) (string, int, error)

func (*DockerClient) RemoveContainer

func (d *DockerClient) RemoveContainer(containerID string) error

func (*DockerClient) RestartContainer

func (d *DockerClient) RestartContainer(containerID string) error

func (*DockerClient) StopContainer

func (d *DockerClient) StopContainer(containerID string) error

type GitClient

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

func NewGitClient

func NewGitClient() *GitClient

func (*GitClient) CleanupOldRepos

func (g *GitClient) CleanupOldRepos(maxAge time.Duration) error

func (*GitClient) CloneRepository

func (g *GitClient) CloneRepository(repoURL, branch string) (string, error)

func (*GitClient) CommitChanges

func (g *GitClient) CommitChanges(repoPath, message, userEmail, userName string) error

func (*GitClient) CreateBranch

func (g *GitClient) CreateBranch(repoPath, branchName string) error

func (*GitClient) GetCurrentBranch

func (g *GitClient) GetCurrentBranch(repoPath string) (string, error)

func (*GitClient) GetRepoPath

func (g *GitClient) GetRepoPath(repoURL, branch string) string

func (*GitClient) HasUncommittedChanges

func (g *GitClient) HasUncommittedChanges(repoPath string) (bool, error)

type Manager

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

func NewManager

func NewManager(deps *deps.Deps) *Manager

func (*Manager) CreateWorklet

func (m *Manager) CreateWorklet(ctx context.Context, req CreateWorkletRequest, userID string) (*Worklet, error)

func (*Manager) DeleteWorklet

func (m *Manager) DeleteWorklet(workletID string) error

func (*Manager) GetWorklet

func (m *Manager) GetWorklet(workletID string) (*Worklet, error)

func (*Manager) ListWorklets

func (m *Manager) ListWorklets(userID string) ([]*Worklet, error)

func (*Manager) ProcessPrompt

func (m *Manager) ProcessPrompt(ctx context.Context, workletID string, prompt string, userID string) (*WorkletPrompt, error)

func (*Manager) RestartWorklet

func (m *Manager) RestartWorklet(ctx context.Context, workletID string) error

func (*Manager) StopWorklet

func (m *Manager) StopWorklet(workletID string) error

type PromptRequest

type PromptRequest struct {
	Prompt string `json:"prompt" binding:"required"`
}

type Status

type Status string
const (
	StatusCreating  Status = "creating"
	StatusRunning   Status = "running"
	StatusStopped   Status = "stopped"
	StatusError     Status = "error"
	StatusBuilding  Status = "building"
	StatusDeploying Status = "deploying"
)

type WebServer

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

func NewWebServer

func NewWebServer() *WebServer

func (*WebServer) CleanupInactiveProxies

func (ws *WebServer) CleanupInactiveProxies(activeWorkletIDs []string)

func (*WebServer) CreateProxy

func (ws *WebServer) CreateProxy(workletID string, targetURL string) error

func (*WebServer) CreateWorkletHandler

func (ws *WebServer) CreateWorkletHandler(workletID string, targetPort int) http.HandlerFunc

func (*WebServer) CreateWorkletPreviewHandler

func (ws *WebServer) CreateWorkletPreviewHandler(workletID string, repoPath string) http.HandlerFunc

func (*WebServer) GetProxy

func (ws *WebServer) GetProxy(workletID string) (*httputil.ReverseProxy, bool)

func (*WebServer) GetWorkletStats

func (ws *WebServer) GetWorkletStats(workletID string) map[string]interface{}

func (*WebServer) HealthCheck

func (ws *WebServer) HealthCheck(workletID string, targetURL string) error

func (*WebServer) ListActiveProxies

func (ws *WebServer) ListActiveProxies() []string

func (*WebServer) RemoveProxy

func (ws *WebServer) RemoveProxy(workletID string)

func (*WebServer) ServeWorklet

func (ws *WebServer) ServeWorklet(w http.ResponseWriter, r *http.Request, workletID string)

type Worklet

type Worklet struct {
	models.Model
	Name        string                               `json:"name" gorm:"not null"`
	Description string                               `json:"description"`
	Status      Status                               `json:"status" gorm:"not null"`
	GitRepo     string                               `json:"git_repo" gorm:"not null"`
	Branch      string                               `json:"branch" gorm:"not null"`
	BasePrompt  string                               `json:"base_prompt" gorm:"type:text"`
	WebURL      string                               `json:"web_url"`
	Port        int                                  `json:"port"`
	Environment *models.JSONField[map[string]string] `json:"environment"`
	UserID      string                               `json:"user_id" gorm:"index;not null"`
	ContainerID string                               `json:"container_id" gorm:"index"`
	SessionID   string                               `json:"session_id" gorm:"index"`
	LastPrompt  string                               `json:"last_prompt" gorm:"type:text"`
	LastError   string                               `json:"last_error" gorm:"type:text"`
	BuildLogs   string                               `json:"build_logs" gorm:"type:text"`
	User        *models.User                         `gorm:"foreignKey:UserID"`
	Container   *models.Container                    `gorm:"foreignKey:ContainerID"`
}

func NewWorklet

func NewWorklet(req CreateWorkletRequest, userID string) *Worklet

func (*Worklet) ToResponse

func (w *Worklet) ToResponse() WorkletResponse

type WorkletHandler

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

func NewWorkletHandler

func NewWorkletHandler(deps *deps.Deps) *WorkletHandler

func (*WorkletHandler) CreatePR

func (h *WorkletHandler) CreatePR(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) CreateWorklet

func (h *WorkletHandler) CreateWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) DeleteWorklet

func (h *WorkletHandler) DeleteWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) GetLogs

func (h *WorkletHandler) GetLogs(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) GetStatus

func (h *WorkletHandler) GetStatus(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) GetWorklet

func (h *WorkletHandler) GetWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) ListWorklets

func (h *WorkletHandler) ListWorklets(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) ProcessPrompt

func (h *WorkletHandler) ProcessPrompt(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) ProxyToWorklet

func (h *WorkletHandler) ProxyToWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) RegisterRoutes

func (h *WorkletHandler) RegisterRoutes(router *mux.Router)

func (*WorkletHandler) RestartWorklet

func (h *WorkletHandler) RestartWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) StartWorklet

func (h *WorkletHandler) StartWorklet(w http.ResponseWriter, r *http.Request)

func (*WorkletHandler) StopWorklet

func (h *WorkletHandler) StopWorklet(w http.ResponseWriter, r *http.Request)

type WorkletPrompt

type WorkletPrompt struct {
	models.Model
	WorkletID string       `json:"worklet_id" gorm:"index;not null"`
	Prompt    string       `json:"prompt" gorm:"type:text;not null"`
	Response  string       `json:"response" gorm:"type:text"`
	Status    string       `json:"status" gorm:"not null"`
	UserID    string       `json:"user_id" gorm:"index;not null"`
	Worklet   *Worklet     `gorm:"foreignKey:WorkletID"`
	User      *models.User `gorm:"foreignKey:UserID"`
}

type WorkletResponse

type WorkletResponse struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Status      Status            `json:"status"`
	GitRepo     string            `json:"git_repo"`
	Branch      string            `json:"branch"`
	WebURL      string            `json:"web_url"`
	Port        int               `json:"port"`
	Environment map[string]string `json:"environment"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
	LastPrompt  string            `json:"last_prompt"`
	LastError   string            `json:"last_error"`
}

Jump to

Keyboard shortcuts

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