app

package
v0.411.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Sessions    session.Service
	Messages    message.Service
	History     history.Service
	Permissions permission.Service
	DBQuerier   db.Querier

	CoderAgent agent.Service

	Projects            project.Service
	ProjectManager      *project.Manager
	Snapshots           snapshot.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 New

func New(ctx context.Context, conn *sql.DB, opts ...AppOptions) (*App, error)

func (*App) EnsurePrimary added in v0.326.0

func (app *App) EnsurePrimary(ctx context.Context)

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) PromoteToPrimary added in v0.326.0

func (app *App) PromoteToPrimary(ctx context.Context, lockFile *os.File) error

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:

  1. Closes the old read-only SQLite connection.
  2. Opens a new read-write connection (with migrations).
  3. Creates a new IPC Bus and calls ipcBusSetupFunc to wire all handlers.
  4. Updates the app's Querier, IPCBus, and IPCIsPrimary fields.
  5. 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 (a *App) RunNonInteractiveGoal(ctx context.Context, objective string, outputFormat string, quiet bool, yoloMode bool) (NonInteractiveGoalResult, error)

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

func (app *App) SetupIPC(bus *ipc.Bus)

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) Shutdown

func (app *App) Shutdown()

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 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.

Jump to

Keyboard shortcuts

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