Documentation
¶
Overview ¶
Package bridge connects in-process pubsub events to the ZMQ Bus, enabling real-time event broadcasting to all connected Pando instances and observers.
Index ¶
- func RegisterHandlers(bus BusRegistrar, instanceID string, svc session.Service, ...)
- func RegisterHandlersWithAgent(bus BusRegistrar, instanceID string, svc session.Service, ...)
- func RegisterHandlersWithDelegation(bus BusRegistrar, instanceID string, svc session.Service, ...)
- type Bridge
- type BusRegistrar
- type DelegationRunner
- type MessageRunner
- type SessionInterrupter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(bus BusRegistrar, instanceID string, svc session.Service, msgSvc message.Service, startedAt time.Time)
RegisterHandlers registers all JSON-RPC handlers on the Bus. instanceID is the local instance identifier (bus.instanceID is unexported). svc is the local session service; startedAt is when this instance started. runner and interrupter are optional: pass nil if message.send / session.interrupt should not be handled by this instance.
func RegisterHandlersWithAgent ¶
func RegisterHandlersWithAgent(bus BusRegistrar, instanceID string, svc session.Service, msgSvc message.Service, startedAt time.Time, runner MessageRunner, interrupter SessionInterrupter)
RegisterHandlersWithAgent registers all JSON-RPC handlers including the agent-backed message.send and session.interrupt methods. Delegation is disabled; the ping handler advertises AcceptsDelegations=false.
func RegisterHandlersWithDelegation ¶ added in v0.604.0
func RegisterHandlersWithDelegation(bus BusRegistrar, instanceID string, svc session.Service, msgSvc message.Service, startedAt time.Time, runner MessageRunner, interrupter SessionInterrupter, delRunner DelegationRunner, acceptDelegations bool)
RegisterHandlersWithDelegation registers all JSON-RPC handlers, with optional hot-peer delegation support. When acceptDelegations is true AND delRunner is non-nil the ping handler advertises AcceptsDelegations=true / DelegationProtocol=1 and the delegation.run / delegation.cancel handlers are active.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge connects the in-process pubsub events to the ZMQ Bus. Only the primary instance should create a Bridge.
type BusRegistrar ¶
type BusRegistrar interface {
RegisterMethod(method string, handler ipc.HandlerFunc)
Publish(topic string, payload any) error
}
BusRegistrar is the minimal interface needed by RegisterHandlers to register RPC methods. *ipc.Bus satisfies this interface; a test double can also implement it.
type DelegationRunner ¶ added in v0.604.0
type DelegationRunner interface {
RunDelegation(ctx context.Context, params protocol.DelegationRunParams) (protocol.DelegationRunResult, error)
// CancelDelegation best-effort cancels an in-flight delegated run by the
// caller-supplied correlation id. No-op if unknown.
CancelDelegation(correlationID string)
}
DelegationRunner runs a delegated prompt in a fresh ephemeral session on the local agent and returns the captured assistant output synchronously. Local interface to avoid an import cycle with the agent package.
func NewAgentDelegationRunner ¶ added in v0.604.0
func NewAgentDelegationRunner(sessions session.Service, agentSvc agent.Service) DelegationRunner
NewAgentDelegationRunner returns a DelegationRunner backed by the local agent and session services. Both deps must be non-nil; NewAgentDelegationRunner panics if either is nil.
type MessageRunner ¶
type MessageRunner interface {
RunMessage(ctx context.Context, sessionID string, content string) error
}
MessageRunner is the minimal interface used by the bridge to send a user message to a session via the local agent. A local interface is used to avoid import cycles between the bridge and the agent packages. RunMessage starts processing the given user message asynchronously and returns after the agent goroutine is launched. Any streaming events are handled internally.
type SessionInterrupter ¶
type SessionInterrupter interface {
Cancel(sessionID string)
}
SessionInterrupter is the minimal interface used by the bridge to cancel the running LLM call for a session. A local interface is used to avoid import cycles.