Documentation
¶
Overview ¶
Package dispatch wires inbound WebSocket frames to the agent layer. It owns one Turn per active RunID and a per-Turn output goroutine that forwards the agent's events to the transport.
Concurrency: Handle is safe for one goroutine (typically the read loop). Each session runs its own goroutine. Internal state is mutex-protected.
Index ¶
- Variables
- type Config
- type Router
- func (r *Router) ActiveRuns() int
- func (r *Router) Handle(ctx context.Context, env proto.Envelope) error
- func (r *Router) Quiesce(ctx context.Context, request proto.EnvironmentSuspendPayload) error
- func (r *Router) Resume(request proto.EnvironmentSuspendPayload, sender Sender) error
- func (r *Router) Shutdown(ctx context.Context) error
- type Sender
Constants ¶
This section is empty.
Variables ¶
var ErrRouterBusy = errors.New("dispatch: router has unsettled work")
var ErrRouterClosed = errors.New("dispatch: router closed")
var ErrRouterQuiesced = errors.New("dispatch: router quiesced")
ErrRouterQuiesced also wraps failed quiesce attempts that have fenced admission.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Registry *agent.Registry
Sender Sender
Log *slog.Logger
IdleTimeout time.Duration
PreparationTimeout time.Duration
LocalWorkspace *localworkspace.Binding
}
Config is the constructor input. Registry and Sender are required; Log is optional (defaults to slog.Default()).
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router maps inbound Envelopes to agent sessions.
func (*Router) ActiveRuns ¶
ActiveRuns returns the in-flight run count. Wired into the heartbeat payload supplier.
func (*Router) Handle ¶
Handle dispatches one inbound Envelope. Errors are returned for programmer-visible problems (bad shape, registry miss); transient session-level failures are logged and swallowed.
Adopts env.Trace into ctx so every downstream log under it inherits the same trace_id, making a single grep cover both sides.
func (*Router) Quiesce ¶
Quiesce serializes against admission, then drains every admitted output and receipt while retaining settled idle Executors for suspension. Busy rejection leaves admission open; a drain timeout keeps it closed until the caller shuts the connection down.
Source Files
¶
- cancellation.go
- capabilities.go
- environment.go
- executor.go
- functions.go
- mcp_http.go
- preparation.go
- preparation_cancel.go
- preparation_cleanup.go
- preparation_start.go
- prepared_handoff.go
- router.go
- runtime_preparation.go
- shutdown.go
- steering.go
- steering_lifetime.go
- suspend.go
- work.go
- workspace_export.go
- workspace_read.go
- workspace_write.go