mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
eedebabbea
Introduce pkg/events with filtered channels, subscription policies, backpressure, and stats. Wire AgentLoop to dual-publish legacy agent events into runtime events while preserving old event APIs. Validation: go test ./pkg/events/... ./pkg/agent; go test -race ./pkg/events/...; make lint
21 lines
608 B
Go
21 lines
608 B
Go
package agent
|
|
|
|
import runtimeevents "github.com/sipeed/picoclaw/pkg/events"
|
|
|
|
// AgentLoopOption configures an AgentLoop at construction time.
|
|
type AgentLoopOption func(*AgentLoop)
|
|
|
|
// WithRuntimeEvents injects the runtime event bus used for new observation APIs.
|
|
//
|
|
// The injected bus is treated as externally owned and will not be closed by
|
|
// AgentLoop.Close. Passing nil leaves the default owned runtime bus enabled.
|
|
func WithRuntimeEvents(bus runtimeevents.Bus) AgentLoopOption {
|
|
return func(al *AgentLoop) {
|
|
if bus == nil {
|
|
return
|
|
}
|
|
al.runtimeEvents = bus
|
|
al.ownsRuntimeEvents = false
|
|
}
|
|
}
|