manager

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGateways

func ParseGateways(list string, terminalOnly bool, defaults []string) []string

ParseGateways turns the `--gateways a,b` flag (and the `--terminal_only` shorthand) into the ordered, de-duplicated gateway set stored on a session. Entries are lowercased and must match [a-z0-9_-]; invalid entries are dropped. An explicit list always wins; an empty list with terminalOnly yields ["terminal"]; an empty list otherwise falls back to defaults — the primary gateway kinds the composition root injects (it names the concrete platform, the core never does). A nil/empty defaults yields the same, i.e. nothing.

Types

type CoordView

type CoordView struct {
	Role     string
	Lead     string
	Reported int
	Expected int
	Complete bool
}

CoordView mirrors host.CoordinationView so the manager stays decoupled from the host package (no import cycle). The host wires an adapter implementing coordinationReader.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds the dependencies the session/service/agent commands act on. Commands (commands.go) turns its methods into declared contracts.Cmd values the CLI dispatches.

func NewHandler

func NewHandler(d channelAdmin, sup supervisor, wt worktrees, fg forges, up updater, agents agentStore, st *state.State, defaultCmd, partDir string, defaultGateways []string) *Handler

NewHandler builds a Handler. defaultCmd is the bridge command used when a session is created without an explicit cmd. partDir is the directory under which per-session participant journals live (participants/<name>.log). agents owns the durable agent homes used to provision sessions.

func (*Handler) Agents

func (h *Handler) Agents() agentStore

Agents returns the durable agent store (used by tests/wiring).

func (*Handler) BudgetGate

func (h *Handler) BudgetGate() *SessionBudgetGate

BudgetGate returns a gate bound to this handler's session store + transcript dir. The returned *SessionBudgetGate satisfies host's (private) budgetGate interface structurally via Check.

func (*Handler) Commands

func (h *Handler) Commands() []contracts.Cmd

Commands returns the manager's command set as neutral contracts.Cmd values for the CLI registry to dispatch. Each Run closes over the Handler's dependencies, so the registry holding these stays agnostic of the gateway, git, or the backend.

func (*Handler) PartDir

func (h *Handler) PartDir() string

PartDir returns the participants journal directory (used by tests/wiring).

func (*Handler) SetCoordinationReader

func (h *Handler) SetCoordinationReader(r coordinationReader)

SetCoordinationReader wires the join-state source used to enrich session list. nil-safe: until set, session list omits the coordination field.

func (*Handler) SetDefaultModel added in v0.3.6

func (h *Handler) SetDefaultModel(id string)

SetDefaultModel wires the operator's configured default. It is a fallback, never an override: an explicit --model always wins.

func (*Handler) SetGatewayOnly added in v0.3.5

func (h *Handler) SetGatewayOnly(fn func() bool)

SetGatewayOnly wires the active route policy. Under gateway-only every turn must run on the product's account, so the two ways of escaping the catalog have to be closed at the command:

  • an explicit `cmd` is a free-form argv the catalog never sees. It can name any binary and any `--model`, so it bills our account for something the operator never selected, and it bypasses the policy outright.
  • no `model` at all skips the catalog lookup entirely, so the spawn gets no gateway environment and runs on the machine's own vendor login — silently, while the session reads as gateway-routed.

Both are legitimate on the internal build, where the machine's own login IS the intended account. This is why the check is policy-gated rather than unconditional.

func (*Handler) SetModelValidator added in v0.3.4

func (h *Handler) SetModelValidator(fn func(vendor, modelID string) error)

SetModelValidator wires the catalog check applied to `--vendor`/`--model` on session create/switch, so a typo, a policy-excluded id, or a vendor that does not own the model fails at the command instead of much later, as an opaque spawn failure — or worse, as a turn silently run on the machine's own login.

func (*Handler) SetSeeder

func (h *Handler) SetSeeder(fn func(name, task string) bool)

SetSeeder wires the live-session seed injector (host.Seed). The daemon calls this; the operator CLI leaves it nil (switch --handoff none still works).

func (*Handler) SetTerminalAdmin

func (h *Handler) SetTerminalAdmin(td channelAdmin)

SetTerminalAdmin wires the terminal (TUI) channel admin used to route terminal-only sessions to a local terminal channel instead of the operator's home gateway. nil-safe: until set, terminal-only sessions fall back to the home gateway's admin.

type SessionBudgetGate

type SessionBudgetGate struct {
	// contains filtered or unexported fields
}

SessionBudgetGate enforces per-session and cohort budget caps. It re-derives usage from the transcript fold (single source of truth) and persists the paused reason when a cap trips at a turn boundary; it also answers how much token headroom a turn has, so the host can cut a runaway one mid-flight. Injected into the host turn loop via the host's budgetGate interface.

func (*SessionBudgetGate) Check added in v0.6.0

func (g *SessionBudgetGate) Check(session string) (reason string, headroom uint64, capped bool)

Check answers both budget questions from one transcript fold: the reason the session must pause ("" = it may run), and — for the turn about to start — how many tokens it may spend before a token cap trips, with capped false when no token cap applies. On a trip it persists PausedReason so the session comes back paused across reloads. Reason vocabulary: cost|tokens|cohort_cost|cohort_tokens.

The headroom is what the host watches the live counter against, so a single runaway turn is cut mid-flight instead of only being caught at a boundary it has already blown past. Cost has no equivalent: a backend reports cost only in its terminal result event, so there is no mid-turn number to compare a cost cap against.

Jump to

Keyboard shortcuts

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