bootstrap

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WireGoalTools added in v0.2.2

func WireGoalTools(sess *agent.Session, mgr *goal.Manager)

WireGoalTools connects goal tool callbacks and the usage-limit handler to the goal manager. Called at boot and again by the UI after a plugin reload rebuilds the toolset.

Types

type MCPReport added in v0.2.2

type MCPReport struct {
	Tools  int
	Errors []string
}

MCPReport summarizes a ConnectMCP run for frontend display.

type Options

type Options struct {
	Cwd string

	Continue   bool
	Resume     bool
	NonTTYMode bool

	ApprovalMode  string
	ToolFactories []ToolFactory
	ModelFactory  agent.ModelFactory

	// WorkspaceFS is the file backend that read/write/edit operate on, shared
	// by the main agent and every sub-agent. Nil means the local filesystem.
	// Frontends that serve files differently (e.g. the ACP frontend reading
	// editor buffers) inject their own backend here.
	WorkspaceFS agentcoretools.WorkspaceFS
}

Options controls how runtime bootstraps.

type Runtime

type Runtime struct {
	Cwd       string
	GitBranch string

	ApprovalEngine *approval.Engine
	TaskRuntime    *task.Runtime
	TeamRegistry   *team.Registry
	TeammateEvents *cbteam.EventHub

	Settings      config.Resolved
	ModelName     string // display form: "provider/model" or session-restored name
	Session       *agent.Session
	SessionStore  *storage.Store
	PluginCatalog *plugin.Catalog
	SkillCatalog  *skill.Catalog
	MCPManager    *mcpclient.Manager
	MCPServers    map[string]mcpclient.ServerConfig // for async connection in TUI
	HookRunner    *hooks.Runner                     // nil if no hooks configured
	Dreamer       *dream.Dreamer                    // background memory consolidation; nil in print mode

	// Frontend-neutral session lifecycle, assembled by wireLifecycle.
	// Restored from the session snapshot before any frontend runs.
	PlanStore   *storage.PlanStore
	PlanManager *plan.Manager
	GoalManager *goal.Manager
	CronStore   *cron.Store // nil when the cron tools are absent
	// contains filtered or unexported fields
}

Runtime is the bootstrapped app runtime state.

func Boot

func Boot(opts Options) (*Runtime, error)

Boot creates a ready-to-run runtime.

func (*Runtime) CleanWorktreeOrphans added in v0.3.0

func (r *Runtime) CleanWorktreeOrphans()

CleanWorktreeOrphans removes leftover codebot worktrees with no uncommitted changes — sandboxes a previous run created but never cleaned (e.g. after a crash). Dirty ones are always kept; unreviewed work is never destroyed.

func (*Runtime) Close

func (r *Runtime) Close()

Close releases runtime resources.

func (*Runtime) ConnectMCP added in v0.2.2

func (r *Runtime) ConnectMCP(ctx context.Context) *MCPReport

ConnectMCP connects all configured MCP servers and warms the tool list. Blocking — async frontends run it in a goroutine. Returns nil when no servers are configured.

It deliberately never touches the session: session prompt state is not goroutine-safe, so MCP tools and instructions enter the session through exactly one writer — the before-prompt refresh hook, which MarkDirty arms and which runs on the prompt path ahead of the turn.

func (*Runtime) EnterWorktree added in v0.3.0

func (r *Runtime) EnterWorktree(name string) (string, error)

EnterWorktree creates a sandbox worktree and relocates the session into it. It is rejected when not in a git repo, when already in a sandbox, or while teammates are live (they run against the main cwd and would be split off).

func (*Runtime) ExitWorktree added in v0.3.0

func (r *Runtime) ExitWorktree(discard bool) (WorktreeExit, error)

ExitWorktree returns the session to the main workspace. With uncommitted changes it keeps the sandbox for review unless discard is set; a clean (or discarded) sandbox is removed along with its branch and snapshot artifacts. Removal is data-safe: git refuses to drop a dirty checkout or a branch with unmerged commits, so committed work survives even on the clean path.

func (*Runtime) StartCron added in v0.2.2

func (r *Runtime) StartCron(onFire func(prompt string)) func()

StartCron starts the session cron scheduler. Fired prompts are delivered through onFire — the frontend decides how they enter the conversation (the TUI injects them as user prompts). Returns a stop function, or nil when no cron store is available. Print mode never starts cron: a one-shot run has no loop to schedule against.

func (*Runtime) WorktreeActive added in v0.3.0

func (r *Runtime) WorktreeActive() bool

WorktreeActive reports whether the session is currently inside a sandbox.

func (*Runtime) WorktreeDiff added in v0.3.0

func (r *Runtime) WorktreeDiff() (string, error)

WorktreeDiff returns the active sandbox's uncommitted diff for review.

func (*Runtime) WorktreeDir added in v0.3.0

func (r *Runtime) WorktreeDir() string

WorktreeDir returns the active sandbox path, or "" when on the main worktree.

type ToolFactory

type ToolFactory func(cwd string) agentcore.Tool

ToolFactory creates one tool instance for the given workspace.

type WorktreeExit added in v0.3.0

type WorktreeExit struct {
	Slug       string
	Dir        string
	Branch     string
	HadChanges bool
	Kept       bool // true when changes were preserved instead of removed
	// BranchKept is true when the checkout was removed but its branch was
	// retained because it held commits not reachable elsewhere — the work
	// survives on the branch even though the working tree was clean.
	BranchKept bool
}

WorktreeExit reports what ExitWorktree did so the UI can tell the user whether changes were kept for review or the sandbox was cleaned up.

Jump to

Keyboard shortcuts

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