Help us shape the future of Go! Take the 2026 Go Developer Survey

loop

package
v0.4.43 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentCommand added in v0.4.9

func AgentCommand(agents []agentkit.Agent, store agentkit.SessionStore, defaultAgent agentkit.AgentID, ws workspace.Service) agentkit.Command

Command exposes the agent catalog and session or global agent switching.

func AgentHelpCommand added in v0.4.9

func AgentHelpCommand(agents []agentkit.Agent) agentkit.Command

HelpCommand exposes the agent catalog help slash command for built agent instances.

func ModelCommand added in v0.4.9

func ModelCommand(agents []agentkit.Agent, store agentkit.SessionStore, defaultAgent agentkit.AgentID, ws workspace.Service, catalog capllm.ModelCatalog) agentkit.Command

ModelCommand shows or sets the session or global LLM model override for coding agents.

The catalog is optional: when nil the command still works, just without the available-model list and unknown-model warnings. Commands for other domains (failover chain, subagent models) are provided by their own plugins.

func New

func New(cfg Config, deps Deps) (agentkit.Loop, error)

New registers loop/default: Route inbound messages to an agent and serialize turns per session.

Types

type Config

type Config struct {
	// DefaultAgent is agent id used when the event names none; defaults to the single configured agent.
	DefaultAgent agentkit.AgentID `json:"defaultAgent"`
	// FollowUpMode is how follow-up messages are drained after a turn ends.
	FollowUpMode agentkit.FollowUpMode `json:"followUpMode"`
}

func (*Config) SetDefaults added in v0.3.48

func (c *Config) SetDefaults()

SetDefaults implements pluginkit.Defaulter.

func (*Config) Validate added in v0.3.48

func (c *Config) Validate() error

Validate implements pluginkit.Validator.

type Control

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

Control holds steer / follow-up queues and step-cancel state for one session. Loop owns one Control per SessionID; Agent reads step-level hooks via ctx.Value(agentkit.KeySessionControl).

All mutable state is owned by a single goroutine; callers synchronize via ch.

func NewControl

func NewControl() *Control

func (*Control) Await

func (*Control) BeginStep

func (c *Control) BeginStep(parent context.Context) (context.Context, func())

func (*Control) Cancel

func (c *Control) Cancel(_ context.Context, reason string) error

func (*Control) CancelRoot added in v0.4.39

func (c *Control) CancelRoot(rootTurnID, reason string) bool

CancelRoot cancels only registrations owned by the given user interaction. It does not set the session-wide pending reason or stop another root/job.

func (*Control) ClearTurnCancel

func (c *Control) ClearTurnCancel()

func (*Control) DeliverPermissionReply

func (c *Control) DeliverPermissionReply(_ agentkit.SessionID, reply permission.Reply) bool

func (*Control) DrainFollowUps

func (c *Control) DrainFollowUps(_ context.Context, mode agentkit.FollowUpMode) ([]agentkit.ModelMessage, error)

func (*Control) FollowUp

func (c *Control) FollowUp(_ context.Context, msg agentkit.ModelMessage) error

func (*Control) HasSteering added in v0.1.10

func (c *Control) HasSteering() bool

func (*Control) PermissionAllowAll added in v0.4.23

func (c *Control) PermissionAllowAll() bool

PermissionAllowAll reports whether the user has chosen 全部允许 for this session.

func (*Control) PermissionCapability

func (c *Control) PermissionCapability() permission.Capability

func (*Control) PopCancelReason

func (c *Control) PopCancelReason() string

func (*Control) PopSteering

func (c *Control) PopSteering() []agentkit.SteerEntry

func (*Control) RegisterExecution added in v0.4.39

func (c *Control) RegisterExecution(parent context.Context, identity capexecution.Identity) (context.Context, func())

RegisterExecution associates this cancel registration with an immutable invocation owner. Legacy BeginStep delegates here without changing its API.

func (*Control) RestoreSteering added in v0.4.26

func (c *Control) RestoreSteering(entries []agentkit.SteerEntry)

RestoreSteering returns unconsumed input ahead of messages that arrived while an agent was attempting delivery to an external runtime.

func (*Control) Steer

func (c *Control) Steer(_ context.Context, msg agentkit.ModelMessage) error

func (*Control) SteerEntry added in v0.4.38

func (c *Control) SteerEntry(_ context.Context, entry agentkit.SteerEntry) error

SteerEntry queues one steering message together with its outcome reporter. The reporter is consumed when the queue position is resolved: locally by the agent injecting at a step boundary, or by Loop running it as the next turn.

func (*Control) Stop added in v0.3.28

func (c *Control) Stop()

Stop cancels pending work and retires the owner. Concurrent calls and late turn cleanup are safe: the request channel stays open, and stop rejects sends.

func (*Control) SupersedePending

func (c *Control) SupersedePending(_ agentkit.SessionID, reason string) bool

type Default

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

func (*Default) Agents added in v0.1.6

func (l *Default) Agents() []agentkit.Agent

Agents returns configured agent instances in arbitrary order.

func (*Default) Cancel added in v0.2.1

func (l *Default) Cancel(ctx context.Context, reason string) error

func (*Default) CancelAllInFlight added in v0.3.15

func (l *Default) CancelAllInFlight(reason string)

func (*Default) Commands added in v0.1.5

func (l *Default) Commands() []agentkit.Command

Commands implements agentkit.CommandProvider: the loop owns the agent catalog, so it contributes /agent and, when any agent exposes local model configuration, /model. commands/registry collects them through the generic WireContributions channel; turn dispatch is unaffected when the optional command deps are absent.

func (*Default) DefaultAgentID added in v0.2.1

func (l *Default) DefaultAgentID() agentkit.AgentID

DefaultAgentID returns the loop fallback agent when no session bind is set.

func (*Default) Dispatch

func (l *Default) Dispatch(ctx context.Context, req agentkit.LoopRequest) error

func (*Default) FollowUp

func (l *Default) FollowUp(ctx context.Context, msg agentkit.ModelMessage) error

func (*Default) IsSessionBusy added in v0.1.10

func (l *Default) IsSessionBusy(sessionID agentkit.SessionID) bool

IsSessionBusy reports whether a turn is currently executing for the session.

func (*Default) Steer

func (l *Default) Steer(ctx context.Context, msg agentkit.ModelMessage) error

func (*Default) SteerEntry added in v0.4.38

func (l *Default) SteerEntry(ctx context.Context, entry agentkit.SteerEntry) error

SteerEntry queues one steering message with its outcome reporter. Transports that want per-message steering feedback call this instead of Steer; the runner picks it up through agentkit.SteerReporter.

func (*Default) Stop added in v0.3.28

func (l *Default) Stop(_ context.Context) error

Stop retires all session owners, including when in-flight turns are abandoned. Later cleanup calls are safe and cannot create a live owner after shutdown.

func (*Default) SupersedePendingForInbound

func (l *Default) SupersedePendingForInbound(event agentkit.MessageEvent)

func (*Default) TryDeliverPermission

func (l *Default) TryDeliverPermission(event agentkit.MessageEvent) bool

type Deps

type Deps struct {
	Agents    []agentkit.Agent      `json:"agents"`
	Telemetry captelemetry.Exporter `json:"telemetry,omitempty"`
	// SessionStore, Workspace and ModelCatalog are optional and only serve the
	// catalog slash commands and preparation of standalone turn contexts.
	SessionStore agentkit.SessionStore `json:"sessionStore,omitempty"`
	Workspace    workspace.Service     `json:"workspace,omitempty"`
	ModelCatalog capllm.ModelCatalog   `json:"modelCatalog,omitempty"`
}

Jump to

Keyboard shortcuts

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