layoutapi

package
v0.16.25 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 37 Imported by: 0 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 layoutapi answers the core slice's routes over layouts, workspaces, the CLIs' tab commands and the right pane's bridges, the way the previous runtime's API answered them: its route table and precedence, its sign-in check, its body parsing (1 MB, "Invalid JSON", 413), its JSON with ETag and 304, and each handler's statuses and texts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agents

type Agents interface {
	// Availability is nil when the agent of panelType (if any) can run.
	Availability(panelType string) *Unavailable
	// ValidateLaunch checks a requested model and effort against what the CLI offers; the text is the 400 error.
	ValidateLaunch(provider string, model, effort any) (*agents.Launch, string)
	LaunchLine(provider, workspaceID string, launch *agents.Launch) (string, error)
	ResumeLine(provider, sessionID, workspaceID string, launch *agents.Launch) (string, error)
	Start(StartRequest) StartResult
	// AutoResume starts again the agents that ran before a reset.
	AutoResume()
}

Agents is what the routes need of the agent CLIs: availability, launch lines and starting a conversation.

type Deps

type Deps struct {
	Store   *state.Store
	Tmux    Tmux
	Status  Status
	Agents  Agents
	Sync    Sync
	Intents *paneintents.Store
	Panel   *panel.Bridge
	Vault   *vault.Bridge
	Targets panel.Targets
	// Deliver reads a file the agent hands over (the rules of the files the pane opens); nil: the machine delivers nothing.
	Deliver func(path, title string) (delivery.Info, *delivery.Refusal)
	// Session: the request carries a page session; CLIToken: it carries the runtime's cli-token (the first token
	// header present decides).
	Session  func(*http.Request) bool
	CLIToken func(*http.Request) bool
	// PlatformAPI is the prefix of the platform's own routes (state-changed, pane-shell, pane intents, bridges).
	PlatformAPI string
	Home        string
	// ShellReady is how long a new tab's shell gets before a resume line is typed (500 ms).
	ShellReady time.Duration
	// PanelWait is how long a pane command waits for a page (1.5 s).
	PanelWait time.Duration
}

Deps is everything the routes use. Status and Agents may be nil until they exist: tabs are then not registered, every agent counts as available and a conversation start is refused.

type Launch

type Launch struct {
	Starter   *launch.Starter
	Inbox     *launch.Inbox
	Headlines *launch.Headlines
	// MachineAgent: the request is the machine agent's own (loopback, its session).
	MachineAgent func(*http.Request) bool
	// SessionCreated is a tmux session's start, epoch seconds (0 when unknown).
	SessionCreated func(session string) int64
	// CodexArgs are the arguments the Codex launcher gets for codex itself.
	CodexArgs func(workspaceID, resumeID string, launch *agents.Launch) ([]string, error)
	// CodexForkArgs are the arguments that start codex on a fork of a session; nil when the runtime cannot fork.
	CodexForkArgs func(workspaceID, sessionID string, launch *agents.Launch) ([]string, error)
	// EvalRuns holds eval runs (<runId>/request.json, state.json, stop); EvalRunner is the runner script, run by Node
	// detached ("" or missing: this release has none).
	EvalRuns, EvalRunner, Node string
	// SideChat* find a tab's Claude session and run the fork.
	SideChatRuntime string
	Sources         func() []status.AgentSource
	ProjectDir      func(cwd string) string
	Log             func(level, msg string, kv ...any)
}

Launch is what the launch slice's routes use besides Deps: the starter and document inbox, the Codex launch lines, eval runs and side chats.

type Route

type Route struct {
	Match   func(*http.Request) bool
	Handler http.Handler
}

Route is one gate route: Match the paths, Handler the answer.

func LaunchRoutes

func LaunchRoutes(d *Deps, l *Launch) (main, shadow Route)

LaunchRoutes are the launch slice's routes: starting conversations, documents, evals, side chats and Codex lines.

func Routes

func Routes(d *Deps) (main, shadow Route)

Routes are the answering route and the route of the GETs that may run in the shadow.

type StartRequest

type StartRequest struct {
	Provider, WorkspaceID string
	Prompt                any // string or nil
	Launch                *agents.Launch
	TabName               any // string or nil
}

StartRequest starts an agent conversation the platform's way (launch line, hooks, prompt).

type StartResult

type StartResult struct {
	ConversationID string
	Status         int
	Body           []byte
}

StartResult is the started conversation, or the status and JSON body of the refusal.

type Status

type Status interface {
	RegisterTab(tabID string, e TabEntry)
	RemoveTab(tabID string)
	MarkAgentLaunch(tabID string, resetAgentSession bool)
	// HooksMissing: the tab's agent was started without the platform's hooks.
	HooksMissing(tabID string) bool
	// AgentTab is the agent tab (Claude Code or Codex) whose tmux session this is, "" for none.
	AgentTab(tmuxSession string) string
	// Rescan rebuilds the tab statuses after a tmux reset.
	Rescan()
}

Status is the status keeper.

type Sync

type Sync interface {
	Broadcast(event *jsvalue.Object)
	ClientCount() int
}

Sync is the sync socket: an event to every page, and how many sockets are open (the agent's relay included).

type TabEntry

type TabEntry struct {
	CliState, WorkspaceID, TabName, TmuxSession string
	PanelType                                   any
	AgentProviderID                             string // "" for a tab without an agent
	AgentSessionID                              any
}

TabEntry is what the status keeper learns of a new tab.

type Tmux

type Tmux interface {
	HasSession(name string) bool
	Capture(name string) (string, bool)
	SendKeys(name, line string) error
	SendBracketedPaste(name, text string) error
	SendKeySequence(name string, keys ...string) error
	PaneCurrentCommand(name string) string
	CheckTerminalProcess(name string) (safe bool, process string)
	ListSessions() []string
	KillServer()
	ApplyConfig(socket string)
	CreateSession(name string, cols, rows int, cwd string) error
	KillSession(name string)
	PaneShellName(tabID string, legacy bool) (string, bool)
	SessionCwd(name string) string
	// CwdAndLastCommand is the session's folder and the newest command its shell runs (nil for none).
	CwdAndLastCommand(name string) (string, *string)
	ResolveExistingDir(preferred string) string
}

Tmux is what the routes ask of tmux beyond the stores. FromTmux adapts the runtime's own.

func FromTmux

func FromTmux(t *tmux.Tmux) Tmux

FromTmux is the runtime's tmux layer as the routes use it.

type Unavailable

type Unavailable = agents.Unavailable

Unavailable is why an agent CLI cannot start: the 409 answer.

Jump to

Keyboard shortcuts

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