Documentation
¶
Overview ¶
The CI-aware PR loop's API surface (internal/ciloop, docs/ci-loop.md): arming a watch when the commit button opens a PR, the manual "watch this PR" endpoint for a PR the agent opened itself, and the card view.
Decision log routes (internal/decisionlog, docs/decision-log.md). Both are read-only: the rows are written as decisions happen, never on request.
mcp_clients.go backs the Settings "Connect your AI tools" card: one place that tells a new user which MCP clients can be wired to this Lectern with a single click, runs that click for the ones that genuinely support it, and remembers which clients have actually spoken to `lectern mcp` at least once.
Claude Code and Codex ship their own `mcp add`/`mcp get` subcommands, so for those two lectern can run the client's own registration command on the machine Lectern itself runs on (as the Lectern service user) — a true one click. Every other client (Claude Desktop, Cursor, VS Code, claude.ai, ChatGPT) gets the most automatic path it genuinely supports: a prefilled config snippet, a real deep link, or — where the client needs a public HTTPS endpoint Lectern does not expose — an honest explanation instead of a fake button.
pairing.go backs Settings → Devices ("Pair a phone") and the public /pair exchange it feeds: minting a short-lived, single-use code as an already-signed-in owner, and trading that code for a long-lived device credential from an unauthenticated browser. See internal/pairing for the design rationale and docs/remote-access.md for the operator-facing story (running Lectern behind a public tunnel with pairing on).
mintPairingCode and the device-list/revoke/settings handlers below all require CanDecide, exactly like decideApproval — minting a credential that can decide approvals is at least as sensitive as deciding one. exchangePairingCode is the one deliberate exception: see its own doc comment and the exemption in withAuth.
relay.go backs Settings → Devices → Encrypted relay (docs/relay.md): the relay connection's status, pairing a phone over the relay, revoking relay devices, and the signed app-shell manifest a paired phone's service worker checks before it accepts a new shell. Everything but the manifest is owner-only, like ordinary pairing: minting a credential that can decide approvals is at least as sensitive as deciding one.
Replay evals (docs/replay-evals.md): building eval cases out of a project's own merged-PR history, so "which agent/model is best for MY repository" is ground-truthed against what actually landed. This file is the target-facing orchestration — everything that needs a real gh/git call — around the pure logic in internal/replay.
Package api is lectern's HTTP surface: the REST control plane, the agent-facing hook endpoints, the SSE streams and the embedded PWA.
Session checks: the project's verify_cmd (or auto-detected .verify.yaml) run against a session's worktree, triggered on an agent Stop and shown on the card. See internal/checks and docs/agent-events.md section 4.
Session effects: the completion claims in an agent's final message, checked against the machine (internal/effects, docs/effect-checks.md). Both routes are read-only: the probes run when the agent stops, not when someone asks.
Review and merge: live diffs, commit/push/PR and inline review comments, shared between tasks (finished attempts) and sessions (long-running interactive worktrees). See docs/agent-events.md section 4.
Named session_review.go (not review.go) because review.go already exists — the terminal workspace's "changes" file browser, an unrelated feature.
The Tasks hub (docs/trackers.md): pull requests and issues from the project's GitHub/GitLab repository and issues from Linear and Jira, read and acted on without leaving Lectern. internal/trackers holds the adapters; this file is the HTTP surface for connections, the forge a project resolves to, and the aggregated list. trackers_pr.go has the pull request page and its actions; trackers_work.go starts agents from items.
Trust rules, the same as the rest of the API: reads need an authenticated caller; anything that changes a tracker (merge, reviewers, labels, comments, state, transitions) or configures a credential needs a signed-in human (Auth.CanDecide), exactly like approvals and arming the CI loop. Credentials are never returned — only which fields are set.
Triggers let a project pick up work on its own — a labelled GitHub issue, an @mention, a Slack message/slash command, or a labelled Linear issue — instead of a human always pressing dispatch. See internal/triggers for the polling/socket engines and docs/triggers.md for setup and the security model. This file is the HTTP surface plus the one adapter (CreateTriggerTask) that turns a matched event into a real task through the same path a human's "New task" + dispatch always used.
Index ¶
- Constants
- Variables
- type RepoRefWithSource
- type Server
- func (s *Server) CreateTriggerTask(project *store.Project, spec triggers.NewTaskSpec) (*store.Task, error)
- func (s *Server) Creds() *creds.Provisioner
- func (s *Server) DrainStreams()
- func (s *Server) Handler() http.Handler
- func (s *Server) RunAutonomyTick(ctx context.Context)
- func (s *Server) RunDueRoutines(ctx context.Context)
- func (s *Server) RunEvalsTick(ctx context.Context)
- func (s *Server) ScheduleAutonomyTick(ctx context.Context)
- func (s *Server) Shutdown(ctx context.Context)
Constants ¶
const ( AgentTaskCap = 10 NoteCap = 20 )
AgentTaskCap and NoteCap bound what one attempt can file, so a looping agent cannot flood the board or the memory store.
const FoldersMarker = "# lectern-folders"
FoldersMarker starts the folder-listing script, so the mock executor can recognise it (internal/executor/mock.go).
const ShellManifestLabel = "lectern-shell-manifest-v1\x00"
ShellManifestLabel domain-separates the shell signature from every other use of an Ed25519 key. frontend/src/relay/shell.ts uses the same string.
const UnauthenticatedPluginsRefused = "" /* 233-byte string literal not displayed */
UnauthenticatedPluginsRefused is the error for a plugin change in LECTERN_AUTH=none, word for word what the UI and CLI show.
Variables ¶
var ClaudeModels = []string{"fable", "opus", "sonnet", "haiku"}
ClaudeModels are the shorthands Claude Code accepts. Every other agent names its models differently and the set moves, so there is nothing honest to hardcode for them — what you have actually used is the better suggestion.
Functions ¶
This section is empty.
Types ¶
type RepoRefWithSource ¶ added in v2.6.0
RepoRefWithSource is a detected repository and where it came from.
type Server ¶
type Server struct {
// PhoneURL is the tailnet HTTPS origin (real certificate) once that
// listener is up — the address to hand a phone. Empty otherwise.
PhoneURL string
// EnableWiFi, DisableWiFi and WiFiURL are set only by the private local
// runtime: they let it also listen on this computer's Wi-Fi address for
// paired phones (cmd/lectern/localruntime/phone.go, POST/DELETE
// /api/phone/wifi). A server keeps its configured listener.
EnableWiFi func() (string, error)
DisableWiFi func()
WiFiURL func() string
// TailnetStatus and LANAddresses answer "Connect your phone"
// (phone.go); nil uses tailscaled and this computer's interfaces.
TailnetStatus func(context.Context) (*auth.StatusResponse, error)
LANAddresses func() []string
DB *store.DB
Bus *bus.Bus
Broker *broker.Broker
Notifier *sinks.Notifier
// Decisions records Review actions and hook-derived decisions
// (internal/decisionlog). nil records nothing; every call is nil-safe.
Decisions *decisionlog.Recorder
Reg *executor.Registry
Sched *scheduler.Scheduler
Sessions *sessions.Manager
Events *agentevents.Ingester
Checks *checks.Runner
// CILoop watches the pull requests Lectern opens (internal/ciloop,
// docs/ci-loop.md). Nil is safe: nothing is armed.
CILoop *ciloop.Watcher
// Triggers polls GitHub/Linear and holds Slack's Socket Mode connections
// open (internal/triggers). Nil is safe everywhere it is read — a build
// or test harness that never sets it simply has no trigger sources.
Triggers *triggers.Manager
// Awareness is cross-agent awareness's tracker (internal/awareness,
// docs/agent-events.md "Cross-agent awareness"): peer lookups, briefing
// text, edit warnings. Nil is safe everywhere it is read (every awareness
// call site checks it first) so a build that predates this field, or a
// test harness that never sets it, degrades to "no awareness" rather
// than a panic.
Awareness *awareness.Tracker
// Claims is the Claim board's tracker (internal/claims, docs/claims.md):
// create/release/extend, overlap queries, and the briefing/warning text.
// Nil is safe everywhere it is read, same convention as Awareness.
Claims *claims.Tracker
Memory memory.Provider
Terminals *terminal.Manager
// TerminalBackend, when set and not nil for a target, overrides which
// session backend its web terminals attach through (mock mode's real
// local shells).
TerminalBackend func(*store.Target) backend.Backend
Push *push.Sender
Cfg *config.Config
Auth *auth.Resolver
// Clipboard routes agent clipboard reads to the device driving a session.
Clipboard *clipboard.Broker
// ClipboardBin is the lectern binary that runs the headless clipboard on this machine.
ClipboardBin string
Log *slog.Logger
// Pairing is device pairing's store (internal/pairing, pairing.go in
// this package) — nil is safe everywhere it is read (pairingEnabled
// treats a nil Pairing as "off"), so a build or test harness that never
// wires one simply never offers /pair.
Pairing *pairing.Store
// Limits is the usage-limit tracker (internal/limits, docs/rate-limits.md):
// the one-tap choices on a card or push go through it. Nil disables the
// endpoints.
Limits *limits.Tracker
// Plugins holds installed plugins and their consent (internal/plugins,
// docs/plugins.md). Nil is safe: only the bundled contributions apply.
Plugins *plugins.Manager
// Relay is the end-to-end encrypted relay connection (internal/relay/
// host, relay.go in this package); nil unless LECTERN_RELAY_URL is set.
// RelayStore holds the relay keys and devices and is set either way.
Relay *relayhost.Host
RelayStore *relayhost.Store
// Activity records recent real terminal input per session, for the
// alert-suppression rule in docs/agent-events.md section 3. Nil is safe
// (terminalActivity then just has nowhere to record — no suppression,
// not a crash); app.New always sets it.
Activity *alerts.Activity
// SummaryGen, when set, replaces the real headless cheap-model call PR
// description generation makes (see review.go runSummary). Tests set this
// to a stub so a review test never spends a real model token or needs a
// real agent binary.
SummaryGen func(ctx context.Context, ex executor.Executor, agent, model, prompt string) (string, error)
// TLS is the tailnet listener's TLS config when it runs, so a dev server
// view can answer https too and be framed by a page served over TLS.
TLS *tls.Config
// MCPClientRunner, when set, replaces the real exec.CommandContext call
// mcp_clients.go makes to run a client's own `mcp add`/`mcp get`
// subcommand. Tests always set this — the suite must never run a real
// claude/codex binary and mutate the operator's own agent config. nil
// means "really exec it" (see mcpRunner).
MCPClientRunner mcpClientRunnerFunc
// LecternPath, when set, overrides the resolved lectern binary path
// mcp_clients.go reports and uses to build install commands. Tests set
// this to a fixed value instead of the test binary's own os.Executable().
LecternPath string
// contains filtered or unexported fields
}
Server wires every dependency the handlers need.
func (*Server) CreateTriggerTask ¶ added in v2.4.0
func (s *Server) CreateTriggerTask(project *store.Project, spec triggers.NewTaskSpec) (*store.Task, error)
CreateTriggerTask is internal/triggers.Manager.CreateTask's implementation: the one path a matched event reaches the board through, identical to a human's "New task" + dispatch except for two things that are the whole safety story in requirement 4 — the permission mode is always the project's own default (never anything a trigger source's config could elevate), and the task is queued and dispatched immediately, since a trigger with nobody watching the board is the point.
func (*Server) Creds ¶
func (s *Server) Creds() *creds.Provisioner
Creds exposes the provisioner the scheduler owns, so the deep probe and a dispatch can never drift apart.
func (*Server) DrainStreams ¶
func (s *Server) DrainStreams()
DrainStreams ends open-ended live updates before HTTP graceful shutdown waits for requests. Ordinary requests retain their own lifetime and drain normally.
func (*Server) RunAutonomyTick ¶ added in v2.4.0
func (*Server) RunDueRoutines ¶
RunDueRoutines fires every scheduled routine whose time has come. The scheduler calls this on its tick.
A routine that cannot be scheduled any more (its schedule was edited to something unreadable) is disabled rather than retried forever, and says so in the log — a job silently firing every two seconds is a much worse failure than one that stops.
func (*Server) RunEvalsTick ¶ added in v2.4.0
RunEvalsTick is the scheduler.Scheduler.Evals callback (see app.go): once per scheduler tick, it materialises newly-queued runs into their result cells, dispatches the next queued cells up to the run's concurrency limit, and grades cells whose dispatched task has finished. It reuses the ordinary task/attempt machinery end to end — an eval cell IS a task, so nothing here touches tmux, drivers or worktrees directly.
func (*Server) ScheduleAutonomyTick ¶ added in v2.4.0
Source Files
¶
- a2a.go
- accounts.go
- agent_commands.go
- agent_registry.go
- approvals.go
- attachments.go
- autonomy.go
- autonomy_admission.go
- autonomy_artifact.go
- autonomy_backlog.go
- autonomy_bridge.go
- autonomy_browser_capabilities.go
- autonomy_capabilities.go
- autonomy_checkpoint_repair.go
- autonomy_continuous.go
- autonomy_dependencies.go
- autonomy_dependency_recovery.go
- autonomy_diagnosis_environment.go
- autonomy_documentation.go
- autonomy_escalation.go
- autonomy_expert_bridge.go
- autonomy_expert_probe_http.go
- autonomy_expert_recovery.go
- autonomy_files_linux.go
- autonomy_go_probe_runtime.go
- autonomy_go_runtime.go
- autonomy_go_runtime_recovery.go
- autonomy_gpu_capabilities.go
- autonomy_gpu_http.go
- autonomy_gpu_owner_unix.go
- autonomy_gpu_research.go
- autonomy_historical_diagnosis.go
- autonomy_integrations.go
- autonomy_node_broker.go
- autonomy_node_capability.go
- autonomy_node_launch_failure.go
- autonomy_node_requirements.go
- autonomy_node_test_runtime.go
- autonomy_ordinary_audit_catalog.go
- autonomy_ordinary_audit_evidence.go
- autonomy_plan_evidence.go
- autonomy_private_catalog.go
- autonomy_private_expert.go
- autonomy_private_integration.go
- autonomy_private_lifecycle.go
- autonomy_private_test_bridge.go
- autonomy_private_test_http.go
- autonomy_private_test_receipt.go
- autonomy_private_test_reconcile.go
- autonomy_private_tooling.go
- autonomy_progress_lifecycle.go
- autonomy_python_broker.go
- autonomy_python_runtime.go
- autonomy_report_repair.go
- autonomy_requirement_diagnosis.go
- autonomy_requirement_diagnosis_node.go
- autonomy_requirements.go
- autonomy_retry.go
- autonomy_search.go
- autonomy_server_maintenance.go
- autonomy_server_maintenance_bridge.go
- autonomy_server_maintenance_capability.go
- autonomy_server_maintenance_conflict.go
- autonomy_server_maintenance_controller.go
- autonomy_server_maintenance_execution.go
- autonomy_server_maintenance_http.go
- autonomy_server_maintenance_lifecycle.go
- autonomy_server_maintenance_prompt.go
- autonomy_server_maintenance_review.go
- autonomy_server_maintenance_scheduler.go
- autonomy_server_maintenance_successor.go
- autonomy_server_observation.go
- autonomy_server_observation_http.go
- autonomy_source.go
- autonomy_source_activity.go
- autonomy_source_activity_index_linux.go
- autonomy_worker_recovery.go
- autonomy_workspace.go
- awareness.go
- bestofn.go
- browser.go
- browser_profiles.go
- budgets.go
- ci_loop.go
- claims.go
- claims_hooks.go
- clipboard.go
- computer.go
- conflicts_api.go
- conversation.go
- decisions.go
- delegation.go
- design.go
- evals.go
- evals_engine.go
- external_files.go
- folders.go
- gzip.go
- hookcheck.go
- hooks_agentevents.go
- hooks_otel.go
- import.go
- interactive_worktree.go
- launch_profiles.go
- limits.go
- live.go
- mcp_clients.go
- media.go
- memory_deliveries.go
- misc.go
- mobile.go
- native_conversations.go
- native_search.go
- native_search_fork.go
- onboarding.go
- outcomes.go
- pairing.go
- phone.go
- plugins.go
- project_link.go
- project_mcp.go
- project_memory.go
- project_skills.go
- project_workflows.go
- projects.go
- promotion_preview.go
- relay.go
- remote_ssh.go
- replay.go
- restore.go
- review.go
- review_attribution.go
- review_comments.go
- review_git.go
- revive.go
- routines.go
- sandboxes.go
- scratch.go
- server.go
- session_archive.go
- session_checks.go
- session_effects.go
- session_memory.go
- session_review.go
- sessions.go
- share_target.go
- shells.go
- takeovers.go
- targets.go
- task_build.go
- tasks.go
- terminal_errors.go
- terminal_split.go
- terminal_workspace.go
- termproxy.go
- trackers.go
- trackers_extra.go
- trackers_pr.go
- trackers_work.go
- triggers.go
- ui_prefs.go
- usage.go
- usage_providers.go
- view.go
- workspace_files.go
- workspace_operations.go