Documentation
¶
Overview ¶
Package kagenttest is a fake kagent controller for tests: SessionService and lf.a2a.v1.A2AService on an in-memory gRPC connection, addressed the way the A2A gateway routes (the Agent as tenant, the session as the message's context), recording every call's metadata.
Index ¶
- Constants
- type Call
- type Controller
- func (c *Controller) AddSession(namespace, name string, tasks ...*a2apb.Task) *apiv1alpha1.Session
- func (c *Controller) Calls() []Call
- func (c *Controller) CreateSession(ctx context.Context, req *apiv1alpha1.CreateSessionRequest) (*apiv1alpha1.CreateSessionResponse, error)
- func (c *Controller) GetSession(ctx context.Context, req *apiv1alpha1.GetSessionRequest) (*apiv1alpha1.GetSessionResponse, error)
- func (c *Controller) ListSessions(ctx context.Context, req *apiv1alpha1.ListSessionsRequest) (*apiv1alpha1.ListSessionsResponse, error)
- func (c *Controller) ListTasks(ctx context.Context, req *a2apb.ListTasksRequest) (*a2apb.ListTasksResponse, error)
- func (c *Controller) SendStreamingMessage(req *a2apb.SendMessageRequest, ...) error
- func (c *Controller) Tasks(contextID string) []*a2apb.Task
- func (c *Controller) TurnEnded() <-chan struct{}
Constants ¶
const Creator = "admin@lab.local"
Creator is the creator the fake records on every session it creates.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
apiv1alpha1.UnimplementedSessionServiceServer
a2apb.UnimplementedA2AServiceServer
// NotReady holds the tenants (<namespace>/<name>) whose CreateSession
// answers FailedPrecondition, as an Agent without a ready revision does.
NotReady map[string]bool
// Fail makes a method (its bare name, e.g. "ListSessions") answer the error.
Fail map[string]error
// contains filtered or unexported fields
}
Controller is the fake's state. Seed it before the calls; read it after.
func New ¶
func New(t *testing.T) (*Controller, *grpc.ClientConn)
New starts the fake and answers a client connection to it. Both stop with the test.
func (*Controller) AddSession ¶
func (c *Controller) AddSession(namespace, name string, tasks ...*a2apb.Task) *apiv1alpha1.Session
AddSession seeds a READY session of agent and its tasks; it answers the session.
func (*Controller) Calls ¶
func (c *Controller) Calls() []Call
Calls answers the calls served so far, in order.
func (*Controller) CreateSession ¶
func (c *Controller) CreateSession(ctx context.Context, req *apiv1alpha1.CreateSessionRequest) (*apiv1alpha1.CreateSessionResponse, error)
CreateSession implements SessionService: idempotent on request_id, refused for a NotReady Agent.
func (*Controller) GetSession ¶
func (c *Controller) GetSession(ctx context.Context, req *apiv1alpha1.GetSessionRequest) (*apiv1alpha1.GetSessionResponse, error)
GetSession implements SessionService.
func (*Controller) ListSessions ¶
func (c *Controller) ListSessions(ctx context.Context, req *apiv1alpha1.ListSessionsRequest) (*apiv1alpha1.ListSessionsResponse, error)
ListSessions implements SessionService.
func (*Controller) ListTasks ¶
func (c *Controller) ListTasks(ctx context.Context, req *a2apb.ListTasksRequest) (*a2apb.ListTasksResponse, error)
ListTasks implements A2AService: the tasks of the context, through the session's Agent.
func (*Controller) SendStreamingMessage ¶
func (c *Controller) SendStreamingMessage(req *a2apb.SendMessageRequest, stream grpc.ServerStreamingServer[a2apb.StreamResponse]) error
SendStreamingMessage implements A2AService: the turn is accepted (a task in SUBMITTED), held open until the client hangs up, then finished with the agent's reply, as a turn outlives its observer.
func (*Controller) Tasks ¶
func (c *Controller) Tasks(contextID string) []*a2apb.Task
Tasks answers the tasks of a session's context.
func (*Controller) TurnEnded ¶
func (c *Controller) TurnEnded() <-chan struct{}
TurnEnded is signalled when a SendStreamingMessage stream ends: the client hung up, and the fake finishes the turn regardless, as the gateway does.