Documentation
¶
Index ¶
- func WireGoalTools(sess *agent.Session, mgr *goal.Manager)
- type MCPReport
- type Options
- type Runtime
- func (r *Runtime) CleanWorktreeOrphans()
- func (r *Runtime) Close()
- func (r *Runtime) ConnectMCP(ctx context.Context) *MCPReport
- func (r *Runtime) EnterWorktree(name string) (string, error)
- func (r *Runtime) ExitWorktree(discard bool) (WorktreeExit, error)
- func (r *Runtime) StartCron(onFire func(prompt string)) func()
- func (r *Runtime) WorktreeActive() bool
- func (r *Runtime) WorktreeDiff() (string, error)
- func (r *Runtime) WorktreeDir() string
- type ToolFactory
- type WorktreeExit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 (*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) ConnectMCP ¶ added in v0.2.2
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
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
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
WorktreeActive reports whether the session is currently inside a sandbox.
func (*Runtime) WorktreeDiff ¶ added in v0.3.0
WorktreeDiff returns the active sandbox's uncommitted diff for review.
func (*Runtime) WorktreeDir ¶ added in v0.3.0
WorktreeDir returns the active sandbox path, or "" when on the main worktree.
type ToolFactory ¶
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.