Documentation
¶
Index ¶
- func ContextWithOutboundEmit(ctx context.Context, emit agentkit.OutboundEmit) context.Context
- func MarshalOutboundData(v any) json.RawMessage
- func New(cfg Config, deps Deps) (agentkit.Loop, error)
- func OutboundEmitFromContext(ctx context.Context) agentkit.OutboundEmit
- type AsyncEmitter
- type Config
- type Control
- func (c *Control) Await(ctx context.Context, req permission.Request) (permission.Result, error)
- func (c *Control) BeginStep(parent context.Context) (context.Context, func())
- func (c *Control) Cancel(_ context.Context, reason string) error
- func (c *Control) ClearTurnCancel()
- func (c *Control) DeliverPermissionReply(_ agentkit.SessionID, reply permission.Reply) bool
- func (c *Control) DrainFollowUps(_ context.Context, mode agentkit.FollowUpMode) ([]agentkit.ModelMessage, error)
- func (c *Control) FollowUp(_ context.Context, msg agentkit.ModelMessage) error
- func (c *Control) HasSteering() bool
- func (c *Control) PermissionCapability() permission.Capability
- func (c *Control) PopCancelReason() string
- func (c *Control) PopSteering() []agentkit.ModelMessage
- func (c *Control) Steer(_ context.Context, msg agentkit.ModelMessage) error
- func (c *Control) Stop()
- func (c *Control) SupersedePending(_ agentkit.SessionID, reason string) bool
- type Default
- func (l *Default) Agents() []agentkit.Agent
- func (l *Default) Cancel(ctx context.Context, reason string) error
- func (l *Default) CancelAllInFlight(reason string)
- func (l *Default) DefaultAgentID() agentkit.AgentID
- func (l *Default) Dispatch(ctx context.Context, req agentkit.LoopRequest) error
- func (l *Default) FollowUp(ctx context.Context, msg agentkit.ModelMessage) error
- func (l *Default) IsSessionBusy(sessionID agentkit.SessionID) bool
- func (l *Default) Steer(ctx context.Context, msg agentkit.ModelMessage) error
- func (l *Default) Stop(_ context.Context) error
- func (l *Default) SupersedePendingForInbound(event agentkit.MessageEvent)
- func (l *Default) TryDeliverPermission(event agentkit.MessageEvent) bool
- type Deps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithOutboundEmit ¶ added in v0.3.1
ContextWithOutboundEmit attaches the per-turn outbound hook to ctx.
func MarshalOutboundData ¶ added in v0.3.1
func MarshalOutboundData(v any) json.RawMessage
MarshalOutboundData JSON-encodes an outbound event payload.
func New ¶
New registers loop/default: Route inbound messages to an agent and serialize turns per session.
func OutboundEmitFromContext ¶ added in v0.3.1
func OutboundEmitFromContext(ctx context.Context) agentkit.OutboundEmit
OutboundEmitFromContext returns the per-turn outbound hook, if any.
Types ¶
type AsyncEmitter ¶ added in v0.3.28
type AsyncEmitter struct {
// contains filtered or unexported fields
}
AsyncEmitter wraps an OutboundEmit so calls return immediately while events are delivered in arrival order by a single goroutine. This keeps async subagent outbound (e.g. ACP SessionUpdate) from blocking the child agent runtime on platform I/O, while preserving event order for progress cards. Close must be called when the emitter is no longer needed to retire the goroutine; events still queued are best-effort drained.
func NewAsyncEmitter ¶ added in v0.3.28
func NewAsyncEmitter(inner agentkit.OutboundEmit) *AsyncEmitter
NewAsyncEmitter returns an emitter that serializes events through a single goroutine. Returns nil when inner is nil so callers can assign directly.
func (*AsyncEmitter) Close ¶ added in v0.3.28
func (e *AsyncEmitter) Close()
Close drains the queue and retires the goroutine. Safe to call once.
func (*AsyncEmitter) CloseWithTimeout ¶ added in v0.3.28
func (e *AsyncEmitter) CloseWithTimeout(d time.Duration) bool
CloseWithTimeout drains the queue like Close but gives up waiting after d. It returns true if the loop retired within d, false if it is still draining (the loop goroutine keeps running best-effort and retires once the queue is empty). Use this on paths where blocking forever on platform I/O would stall a more important step (e.g. async subagent follow-up delivery): the progress card is best-effort UI and must not block the follow-up turn.
func (*AsyncEmitter) Emit ¶ added in v0.3.28
func (e *AsyncEmitter) Emit(_ context.Context, event agentkit.OutboundEvent) error
Emit is the OutboundEmit entry point. It never blocks on platform I/O; when the queue is full the event is dropped with a warning rather than stalling the caller or growing without bound.
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"`
}
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 (c *Control) Await(ctx context.Context, req permission.Request) (permission.Result, error)
func (*Control) ClearTurnCancel ¶
func (c *Control) ClearTurnCancel()
func (*Control) DeliverPermissionReply ¶
func (*Control) DrainFollowUps ¶
func (c *Control) DrainFollowUps(_ context.Context, mode agentkit.FollowUpMode) ([]agentkit.ModelMessage, error)
func (*Control) HasSteering ¶ added in v0.1.10
func (*Control) PermissionCapability ¶
func (c *Control) PermissionCapability() permission.Capability
func (*Control) PopCancelReason ¶
func (*Control) PopSteering ¶
func (c *Control) PopSteering() []agentkit.ModelMessage
type Default ¶
type Default struct {
// contains filtered or unexported fields
}
func (*Default) Agents ¶ added in v0.1.6
Agents returns configured agent instances in arbitrary order.
func (*Default) CancelAllInFlight ¶ added in v0.3.15
func (*Default) DefaultAgentID ¶ added in v0.2.1
DefaultAgentID returns the loop fallback agent when no session bind is set.
func (*Default) IsSessionBusy ¶ added in v0.1.10
IsSessionBusy reports whether a turn is currently executing for the session.
func (*Default) Stop ¶ added in v0.3.28
Stop retires every per-session Control owner goroutine. Call after the runner scheduler has drained (sched.wait + sched.stop); no further Dispatch may run after this returns.
func (*Default) SupersedePendingForInbound ¶
func (l *Default) SupersedePendingForInbound(event agentkit.MessageEvent)
func (*Default) TryDeliverPermission ¶
func (l *Default) TryDeliverPermission(event agentkit.MessageEvent) bool