Documentation
¶
Index ¶
- func RefreshDynamicModels(ctx context.Context)
- func StartModelRefreshLoop(ctx context.Context)
- type App
- func (app *App) ACPDBCompactor() mesnadaACP.DBCompactor
- func (app *App) Clients() map[string]*lsp.Client
- func (app *App) ClientsForFile(path string) map[string]*lsp.Client
- func (app *App) CompactDatabase(ctx context.Context, incremental, enableAutoVacuum bool) (protocol.DBCompactResult, error)
- func (app *App) EnsureForFile(ctx context.Context, path string)
- func (app *App) EnsureForFileTrigger(ctx context.Context, path string, trigger config.LSPTrigger)
- func (app *App) EnsureLSPForFile(ctx context.Context, path string)
- func (app *App) EnsureLSPForFileTrigger(ctx context.Context, path string, trigger config.LSPTrigger)
- func (app *App) EnsurePrimary(ctx context.Context)
- func (app *App) LSPActivationSettings() config.LSPActivationSettings
- func (app *App) LSPCatalog() []tools.LSPCatalogEntry
- func (app *App) LSPServerStatusByName(name string) (LSPServerStatus, bool)
- func (app *App) LSPServerStatuses() []LSPServerStatus
- func (app *App) PromoteToPrimary(ctx context.Context, lockFile *os.File) error
- func (a *App) RunNonInteractive(ctx context.Context, prompt string, outputFormat string, quiet bool, ...) error
- func (a *App) RunNonInteractiveGoal(ctx context.Context, objective string, outputFormat string, quiet bool, ...) (NonInteractiveGoalResult, error)
- func (app *App) SetIPCSecondaryContext(client *ipc.Client, roConn *sql.DB, workdir, instanceID string, ...)
- func (app *App) SetupIPC(bus *ipc.Bus)
- func (app *App) Shutdown()
- func (app *App) UnavailableReason(path string) string
- func (app *App) WaitForFile(ctx context.Context, path string) map[string]*lsp.Client
- type AppOptions
- type LSPAvailability
- type LSPResolution
- type LSPServerStatus
- type NonInteractiveGoalResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RefreshDynamicModels ¶ added in v0.416.3
RefreshDynamicModels fetches and caches models from all configured provider accounts. It is safe to call concurrently and is exported so other startup modes (e.g. LLM Proxy) can trigger the same refresh without a full App instance.
func StartModelRefreshLoop ¶ added in v0.416.3
StartModelRefreshLoop refreshes dynamic models immediately and then every 24 h until ctx is cancelled. Use this in startup modes that do not create a full App instance (e.g. LLM Proxy).
Types ¶
type App ¶
type App struct {
Sessions session.Service
Messages message.Service
History history.Service
Permissions permission.Service
UserInput userinput.Service
DBQuerier db.Querier
CoderAgent agent.Service
Projects project.Service
ProjectManager *project.Manager
AgentVCS agentvcs.Service
LSPClients map[string]*lsp.Client
SkillManager *skills.SkillManager
MesnadaOrchestrator *mesnadaOrch.Orchestrator
CronService *cronjob.Service
MesnadaServer *mesnadaServer.Server
Remembrances *rag.RemembrancesService
ContextEnricher *rag.ContextEnricher
LuaManager *luaengine.FilterManager
MCPGateway *mcpgateway.Gateway
Evaluator *evaluator.EvaluatorService
// IPCBus is set on the primary instance after calling SetupIPC.
// Secondary instances leave this nil.
IPCBus *ipc.Bus
// IPCIsPrimary is true when this instance holds the IPC lock.
IPCIsPrimary bool
// contains filtered or unexported fields
}
func (*App) ACPDBCompactor ¶ added in v0.605.1
func (app *App) ACPDBCompactor() mesnadaACP.DBCompactor
ACPDBCompactor returns an ACP DBCompactor backed by this app's CompactDatabase.
func (*App) ClientsForFile ¶ added in v0.503.5
ClientsForFile returns a snapshot of the running LSP clients that handle the given file. The returned map is a copy, safe to iterate without holding the app lock while clients are added or removed concurrently.
func (*App) CompactDatabase ¶ added in v0.605.1
func (app *App) CompactDatabase(ctx context.Context, incremental, enableAutoVacuum bool) (protocol.DBCompactResult, error)
CompactDatabase reclaims unused space in the SQLite database (VACUUM). Because only the primary owns DB writes, this is a single funnel used by every UI (/db-compact in TUI/WebUI/ACP) and the IPC db.compact handler:
- On the primary (or when IPC is not active) it runs db.Compact directly on the read-write connection.
- On a secondary it forwards the request to the primary over IPC and returns the primary's result, so two writers never contend for the database.
incremental runs only PRAGMA incremental_vacuum; enableAutoVacuum switches the database to auto_vacuum=INCREMENTAL before the full VACUUM.
func (*App) EnsureForFile ¶ added in v0.503.5
EnsureForFile implements the lazy-activation half of the LSP provider used by the tools. It is a thin wrapper around EnsureLSPForFile.
func (*App) EnsureForFileTrigger ¶ added in v0.629.4
EnsureForFileTrigger implements the trigger-aware half of the LSP provider, letting each tool declare why it wants a language server.
func (*App) EnsureLSPForFile ¶ added in v0.503.5
EnsureLSPForFile lazily activates the language server(s) for a file Pando is about to modify. It is shorthand for EnsureLSPForFileTrigger with the edit trigger.
func (*App) EnsureLSPForFileTrigger ¶ added in v0.629.4
func (app *App) EnsureLSPForFileTrigger(ctx context.Context, path string, trigger config.LSPTrigger)
EnsureLSPForFileTrigger lazily activates the language server(s) that handle the given file's extension, provided the configuration allows the trigger to start a server (see Config.LSPActivateOn).
It is safe to call frequently (e.g. on every edit): servers already running, currently spawning, or known-broken are skipped, and a server whose binary is not on PATH is recorded so it is not retried. When several preset servers handle the same extension only the first installed one is started, while servers the user configured explicitly are always honored.
func (*App) EnsurePrimary ¶ added in v0.326.0
EnsurePrimary performs an active liveness probe of the primary and, if the primary is unreachable and auto-failover is enabled, triggers the failover sequence. Must be called before processing each user prompt on a secondary instance. Safe to call on the primary instance (no-op).
func (*App) LSPActivationSettings ¶ added in v0.629.4
func (app *App) LSPActivationSettings() config.LSPActivationSettings
LSPActivationSettings returns the global on-demand knobs, so a surface can render them next to the per-server statuses.
func (*App) LSPCatalog ¶ added in v0.629.4
func (app *App) LSPCatalog() []tools.LSPCatalogEntry
LSPCatalog implements tools.SetupLSPCatalog: it is the same report as LSPServerStatuses, in the shape the pando_setup tool consumes.
func (*App) LSPServerStatusByName ¶ added in v0.629.4
func (app *App) LSPServerStatusByName(name string) (LSPServerStatus, bool)
LSPServerStatusByName returns the status of a single server.
func (*App) LSPServerStatuses ¶ added in v0.629.4
func (app *App) LSPServerStatuses() []LSPServerStatus
LSPServerStatuses describes every server in the registry: the presets plus anything the user configured. It is the single source of truth behind the TUI settings page, the REST config API and the pando_setup tool, so all three agree on what "installed" means.
Resolution is read-only: it never installs anything and never starts a server; a server that is only installable is reported as such.
func (*App) PromoteToPrimary ¶ added in v0.326.0
PromoteToPrimary is the failover.PromoteFunc implementation. It is called by the Watcher when this secondary wins the lock race. lockFile is the open flock file that must be kept open for the duration of this instance's primary role.
The method:
- Closes the old read-only SQLite connection.
- Opens a new read-write connection (with migrations).
- Creates a new IPC Bus and calls ipcBusSetupFunc to wire all handlers.
- Updates the app's Querier, IPCBus, and IPCIsPrimary fields.
- Publishes instance.promoted on the new Bus so other secondaries reconnect.
func (*App) RunNonInteractive ¶
func (a *App) RunNonInteractive(ctx context.Context, prompt string, outputFormat string, quiet bool, yoloMode bool) error
RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
func (*App) RunNonInteractiveGoal ¶ added in v0.324.0
func (*App) SetIPCSecondaryContext ¶ added in v0.326.0
func (app *App) SetIPCSecondaryContext( client *ipc.Client, roConn *sql.DB, workdir, instanceID string, pubPort, rpcPort int, watcher *failover.Watcher, busSetupFunc func(ctx context.Context, bus *ipc.Bus, rwConn *sql.DB) error, )
SetIPCSecondaryContext stores the secondary IPC state and registers the active-probe function on the watcher so it can perform per-prompt and per-minute liveness checks.
busSetupFunc is called during promotion with the new Bus and RW connection. It must wire the writecoordinator, changepub publisher, and bridge handlers.
func (*App) SetupIPC ¶ added in v0.294.1
Shutdown performs a clean shutdown of the application SetupIPC configures the primary IPC bus for this instance. Call this after New() on the primary instance to enable ZMQ event broadcasting and to register the db.write handler so secondary instances can proxy writes. bus must already be started (bus.Start called) before calling SetupIPC.
func (*App) UnavailableReason ¶ added in v0.629.4
UnavailableReason explains why no ready language server could be obtained for a file, in terms the user can act on: a missing binary with its install command, an install still running, or activation being switched off. It returns an empty string when a ready server exists.
func (*App) WaitForFile ¶ added in v0.603.0
WaitForFile waits for a lazily spawned LSP client to become *ready* for the requested file, so a tool call never queries a server that is still starting up. It returns early when startup settles (ready or unavailable).
The wait is bounded by LSPStartupTimeout, extended once to LSPInstallTimeout when the matching server is still being downloaded — a first-run install is an order of magnitude slower than a cold start.
type AppOptions ¶ added in v0.100.0
type AppOptions struct {
// SkipLSP disables LSP client initialisation. Set this to true in headless
// modes (e.g. ACP stdio) where the editor manages its own language servers.
SkipLSP bool
// SkipMesnadaServer avoids starting the embedded Mesnada HTTP server while
// still allowing the orchestrator and related tools to be initialized.
SkipMesnadaServer bool
// StartupMode identifies the mode in which Pando is starting so background
// remembrances behaviors can be aligned consistently across entrypoints.
StartupMode string
// DBQuerier overrides the db.Querier used for sessions, messages, and projects.
// When non-nil this querier is used instead of db.New(conn).
// Primary instances leave this nil; secondary instances pass a dbproxy.DBProxy.
DBQuerier db.Querier
}
AppOptions configures optional behaviour for New().
type LSPAvailability ¶ added in v0.629.4
type LSPAvailability int
LSPAvailability describes whether a language server can be started.
const ( // LSPAvailable means the binary was resolved and the server can start now. LSPAvailable LSPAvailability = iota // LSPInstallable means Pando can provision the binary itself before // starting the server. LSPInstallable // LSPManual means the binary is missing and only the user can install it. LSPManual )
type LSPResolution ¶ added in v0.629.4
type LSPResolution struct {
// Command and Args are the process to spawn. They are only meaningful when
// Availability is LSPAvailable.
Command string
Args []string
// Availability says whether the server can start, could start after an
// install, or needs the user to act.
Availability LSPAvailability
// Reason explains, in a sentence a user can act on, why the server is not
// available. Empty when Availability is LSPAvailable.
Reason string
}
LSPResolution is the outcome of resolving a server's executable.
type LSPServerStatus ¶ added in v0.629.4
type LSPServerStatus struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// Command is the configured command, as it should be written back to the
// configuration; ResolvedCommand is the executable Pando would actually
// spawn (an absolute path, possibly inside Pando's own staging directory).
Command string `json:"command"`
ResolvedCommand string `json:"resolvedCommand,omitempty"`
Args []string `json:"args,omitempty"`
Languages []string `json:"languages,omitempty"`
Filenames []string `json:"filenames,omitempty"`
// Configured reports that the user declared this server under [LSP.<name>]
// instead of only inheriting the built-in preset.
Configured bool `json:"configured"`
// OptIn reports a preset that stays inactive until it is declared.
OptIn bool `json:"optIn"`
Disabled bool `json:"disabled"`
Autostart bool `json:"autostart"`
// Availability is "installed", "installable" or "manual".
Availability string `json:"availability"`
// AvailabilityLabel is the short human-readable form, e.g.
// "installable (bun)".
AvailabilityLabel string `json:"availabilityLabel"`
// Reason explains a non-installed server; Hint is the command the user can
// run themselves and URL its documentation.
Reason string `json:"reason,omitempty"`
Hint string `json:"hint,omitempty"`
URL string `json:"url,omitempty"`
// RunState is "stopped", "starting", "ready" or "error".
RunState string `json:"runState"`
Installing bool `json:"installing"`
}
LSPServerStatus is what a settings page, the API or the setup tool needs to describe one language server: how it is configured, whether its binary can be obtained, and what it is doing right now.
type NonInteractiveGoalResult ¶ added in v0.324.0
type NonInteractiveGoalResult struct {
SessionID string `json:"session_id"`
Objective string `json:"objective"`
Status string `json:"status"`
Iteration int64 `json:"iteration"`
MaxIterations int64 `json:"max_iterations"`
MaxDurationSeconds int64 `json:"max_duration_seconds"`
Response string `json:"response"`
Progress string `json:"progress,omitempty"`
NextStep string `json:"next_step,omitempty"`
BlockedReason string `json:"blocked_reason,omitempty"`
}
NonInteractiveGoalResult is the serialized outcome of a CLI goal-mode run.