forge

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 23 Imported by: ? 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 forge is the LaForge backend: it runs shells and agent CLIs in pseudo-terminals, keeps them alive while browsers come and go, and serves the Forge web client that lays them out as tabs and split panes.

Server is an http.Handler so a host program (the la binary, or Outcome) can serve it on a listener of its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginShell

func LoginShell() string

LoginShell is the user's shell: $SHELL, else /bin/sh; on Windows, PowerShell 7 (pwsh), else Windows PowerShell, else COMSPEC (cmd.exe).

func NewToken

func NewToken() string

NewToken is a fresh random secret.

func Notices

func Notices() string

Notices is THIRD_PARTY_NOTICES.md as built into the web client.

Types

type Options

type Options struct {
	// Home is the forge's folder (layout.json, profiles.json).
	Home string
	// Token is the secret a browser presents once (?token=) to get its cookie,
	// and a client presents as a bearer token. Empty generates one.
	Token string
	// Cwd is the folder new panes start in when the client names none.
	Cwd string
	// Version is reported by /api/health.
	Version string
	// Scrollback is each session's replay buffer in bytes (0: 256 KiB).
	Scrollback int
	// Web replaces the embedded client (tests, development).
	Web fs.FS
}

Options configure a Server.

type Pane

type Pane struct {
	terminal.SessionView
	Profile string `json:"profile"`
	Title   string `json:"title"`
	Cwd     string `json:"cwd"`
	// After names the agent profile a pane ran before it became a shell, and
	// AgentExit that agent's exit code.
	After     string `json:"after,omitempty"`
	AgentExit *int   `json:"agentExit,omitempty"`
}

Pane is a running or finished terminal session, as the client sees it.

type Profile

type Profile struct {
	Name        string   `json:"name"`
	Label       string   `json:"label"`
	Description string   `json:"description"`
	Command     string   `json:"command"`
	Args        []string `json:"args,omitempty"`
	Env         []string `json:"env,omitempty"`
	Agent       bool     `json:"agent"`
	// Available and Reason are filled in when profiles are listed.
	Available bool   `json:"available"`
	Reason    string `json:"reason,omitempty"`
}

Profile is one kind of pane the forge can start: a shell or an agent CLI.

func BuiltinProfiles

func BuiltinProfiles() []Profile

BuiltinProfiles are the panes every forge offers. The shell is the user's own login shell; each agent is its platform's own CLI, run unchanged with its own login.

type Server

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

Server is the forge's HTTP surface.

func NewServer

func NewServer(opts Options) (*Server, error)

NewServer builds a forge server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Sessions

func (s *Server) Sessions() []Pane

Sessions lists the forge's sessions (for status reports).

func (*Server) SetCwd

func (s *Server) SetCwd(dir string)

SetCwd changes the folder new panes start in.

func (*Server) Shutdown

func (s *Server) Shutdown(grace time.Duration)

Shutdown stops every session, waiting up to grace for them to exit.

func (*Server) Token

func (s *Server) Token() string

Token is the server's secret.

type StartRequest

type StartRequest struct {
	Profile string `json:"profile"`
	Cwd     string `json:"cwd"`
	Title   string `json:"title"`
	Cols    uint16 `json:"cols"`
	Rows    uint16 `json:"rows"`
}

StartRequest is the body of POST /api/sessions.

Jump to

Keyboard shortcuts

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