Documentation
¶
Index ¶
- func ForwardACPAgentEvents(ctx context.Context, realCh <-chan agent.AgentEvent) <-chan mesnadaACP.AgentEvent
- func RefreshDynamicModels(ctx context.Context)
- func RegisterACPResumeHandler(reg *agent.ResumeRegistry, acpAgent *mesnadaACP.PandoACPAgent) (unregister func())
- 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) RefreshAgentTools()
- 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, workdir, instanceID string, pubPort, rpcPort int, ...)
- 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
- func (app *App) WorkspaceWatchPathCount() int
- type AppOptions
- type LSPAvailability
- type LSPResolution
- type LSPServerStatus
- type NonInteractiveGoalResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForwardACPAgentEvents ¶ added in v1.0.5
func ForwardACPAgentEvents(ctx context.Context, realCh <-chan agent.AgentEvent) <-chan mesnadaACP.AgentEvent
ForwardACPAgentEvents translates agent events into ACP agent events. It is shared by every ACP adapter (the in-app one and the `pando acp` stdio one in cmd/root.go) so fields such as MessageID cannot be forgotten in one copy: Xcode groups streamed chunks by messageId, and a dropped id merges turns.
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 RegisterACPResumeHandler ¶ added in v1.2.7
func RegisterACPResumeHandler(reg *agent.ResumeRegistry, acpAgent *mesnadaACP.PandoACPAgent) (unregister func())
RegisterACPResumeHandler makes an ACP agent the owner of the runs the delegation supervisor resumes for the idle sessions it serves, so the client gets them live. It is the single registration used by both ACP adapters (the in-app server and `pando acp` over stdio): the translation to ACP events is ForwardACPAgentEvents, the same one a prompt uses. The handler registers at owner priority and only takes sessions this agent has a live client for, so every other session still reaches the WebUI fallback or the plain drain. The returned function unregisters it.
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
// Extensions owns the compiled-in extensions (pkg/extension). It is always
// non-nil; a build with no extensions simply holds an empty manager.
Extensions *extension.Manager
// MemorySink is the fan-out from remembrance writes to the extensions that
// observe them. Nil unless [Extensions.Memory] opens the gate and a loaded
// extension implements extension.MemorySink.
MemorySink *extensions.MemoryPublisher
// Identity reports who the host is running for, when a loaded extension
// implements extension.IdentityProvider. It is always non-nil and is asked
// per use, never cached, so a sign-in or a sign-out during a run takes
// effect without a restart. With no provider it always reports false and
// every consumer behaves exactly as an unextended Pando.
Identity func(ctx context.Context) (extensions.Identity, bool)
// UIPolicy reports what the settings surfaces should hide and what they
// should render read-only, when a loaded extension implements
// extension.UIPolicyProvider. It is always non-nil and is asked at render
// time, so a policy that appears or disappears during a run takes effect on
// the next rebuild. With no provider it returns the zero policy and every
// surface behaves exactly as an unextended Pando.
UIPolicy func(ctx context.Context) extensions.UIPolicy
// ResumeHandlers lets a surface that streams runs (the WebUI API, ACP) own
// the runs the delegation supervisor resumes for an idle session, instead of
// the agent draining them. Always non-nil; with nothing registered (TUI, CLI)
// resumed runs are drained by the agent exactly as before.
ResumeHandlers *agent.ResumeRegistry
// IPCBus is set on the leader instance after calling SetupIPC.
// Followers leave this nil.
IPCBus *ipc.Bus
// IPCIsPrimary is true when this instance holds the IPC lock (the leader).
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 is the funnel for /db-compact in the TUI, WebUI and ACP. VACUUM rewrites the whole file, which needs every process — this one included — to have closed the database, so a running instance cannot compact it; it explains how to do it instead.
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 leader and, if it is unreachable and auto-failover is enabled, triggers the failover sequence so this instance takes over the singleton jobs. Safe to call on the leader (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, called by the Watcher when this follower wins the IPC lock after the leader died. lockFile is the open flock file that must stay open while this instance leads.
It creates and starts the IPC bus (bridge handlers via ipcBusSetupFunc), marks this instance as leader, starts the singleton jobs it skipped as a follower, and publishes instance.promoted. The database connection is left alone: followers already write it directly.
func (*App) RefreshAgentTools ¶ added in v0.643.1
func (a *App) RefreshAgentTools()
RefreshAgentTools rebuilds the coder agent's tool set from the current configuration and installs it on the running agent. It is called after the MCP server configuration changes so newly configured tools become usable without restarting Pando. It is a no-op when the agent does not support a runtime swap or the builder is not wired yet.
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, workdir, instanceID string, pubPort, rpcPort int, watcher *failover.Watcher, busSetupFunc func(ctx context.Context, bus *ipc.Bus) error, )
SetIPCSecondaryContext records that this instance started as an IPC follower (another process holds the IPC lock) and stores what failover promotion needs to take over the leader role.
busSetupFunc is called during promotion with the new Bus; it registers the bridge handlers. The database needs nothing: it is already open read-write.
func (*App) SetupIPC ¶ added in v0.294.1
SetupIPC configures the IPC bus of the leader instance (the one holding the IPC lock) for event broadcasting. It is unrelated to database writes: every instance writes pando.db directly through the multi-writer engine. 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.
func (*App) WorkspaceWatchPathCount ¶ added in v1.2.14
WorkspaceWatchPathCount reports how many directories the shared workspace watcher has registered with the OS (0 when it has not started).
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
// SkipStartupIndexing disables the startup KB import, the KB watcher and
// the code-index startup scan/watcher. Set it for one-shot runs (`-p`,
// `--goal`, mesnada pando-cli subagents): those processes are short-lived,
// often started several at a time, and re-running a full embedding sync in
// each one saturates the embedding backend (e.g. Ollama at 100% CPU).
SkipStartupIndexing bool
// ChildParentInstanceID is set when this process was spawned as a project
// child by another Pando instance. Child instances must not spawn nested
// project children, but they still import peer projects for IPC delegation.
ChildParentInstanceID string
// DBQuerier overrides the db.Querier used for sessions, messages, and projects.
// When non-nil this querier is used instead of db.New(conn).
DBQuerier db.Querier
// IPCFollower is true when another process holds the IPC lock for this
// workdir: the singleton jobs (code index + watcher, evaluator sweeps) are
// left to the leader until failover promotes this instance.
IPCFollower bool
// InstanceID identifies the current Pando process for project child ownership.
InstanceID string
// WebChildTLSCertFile/WebChildTLSKeyFile configure the certificate the
// project manager passes to spawned background WebUI children.
WebChildTLSCertFile string
WebChildTLSKeyFile string
WebChildTLSDataDir string
}
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.