Documentation
¶
Overview ¶
Package kagent calls the kagent controller's SessionService and the A2A service it serves, through agentgateway, as the caller: every call carries the caller's IdP token as `authorization: Bearer` and nothing else that identifies anyone. agentgateway verifies the token on the controller route and derives the identity header the controller reads from it, replacing any value a client sent; a client that set one would be dead weight through the gateway and impersonation without it.
A2A calls are addressed the way the gateway routes them: the Agent as the request's tenant (<namespace>/<name>) and the session as the message's context id (the controller keeps a session's A2A context equal to its id). The x-kagent-agent-instance-id header is the gateway's to the runtime and is never sent from here.
Index ¶
- Constants
- Variables
- func ParseTarget(target string) (hostPort string, useTLS bool, err error)
- type Client
- func (c *Client) Close() error
- func (c *Client) CreateSession(ctx context.Context, token string, in SessionCreate) (*apiv1alpha1.Session, error)
- func (c *Client) GetSession(ctx context.Context, token, sessionID string) (*apiv1alpha1.Session, error)
- func (c *Client) ListSessionTasks(ctx context.Context, token string, agent Ref, contextID string) ([]*a2apb.Task, error)
- func (c *Client) ListSessions(ctx context.Context, token string, agent Ref, allCreators bool) ([]*apiv1alpha1.Session, error)
- func (c *Client) SendMessage(ctx context.Context, token string, agent Ref, ...) (*a2apb.StreamResponse, error)
- type Ref
- type SessionCreate
Constants ¶
const ( SchemePlaintext = "grpc" SchemeTLS = "grpcs" )
Target schemes: plaintext h2c (the in-cluster agentgateway Service) and TLS (a public hostname).
Variables ¶
var ErrNoToken = errors.New("no caller token")
ErrNoToken is returned for a call without a caller token: there is no other identity to make it with.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client speaks to one kagent controller. It is safe for concurrent use.
func Dial ¶
Dial builds a Client for target. The connection is established lazily on the first call.
func NewClient ¶
func NewClient(conn grpc.ClientConnInterface) *Client
NewClient builds a Client on an existing connection (tests use bufconn).
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, token string, in SessionCreate) (*apiv1alpha1.Session, error)
CreateSession is SessionService/CreateSession.
func (*Client) GetSession ¶
func (c *Client) GetSession(ctx context.Context, token, sessionID string) (*apiv1alpha1.Session, error)
GetSession is SessionService/GetSession.
func (*Client) ListSessionTasks ¶
func (c *Client) ListSessionTasks(ctx context.Context, token string, agent Ref, contextID string) ([]*a2apb.Task, error)
ListSessionTasks is A2AService/ListTasks addressed to the session's Agent and filtered by its context, walked to the end: the conversation, oldest task first, with every task's history and artifacts.
func (*Client) ListSessions ¶
func (c *Client) ListSessions(ctx context.Context, token string, agent Ref, allCreators bool) ([]*apiv1alpha1.Session, error)
ListSessions is SessionService/ListSessions for one Agent, walked to the end. allCreators asks for every person's sessions, which the controller grants only to a caller authorized for it.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, token string, agent Ref, contextID, messageID, text string) (*a2apb.StreamResponse, error)
SendMessage opens A2AService/SendStreamingMessage with one user text message to the session (the Agent as tenant, the session as the message's context) and answers the first event, the gateway's acknowledgement that the runtime took the turn, then closes the stream: disconnecting an observer does not cancel the turn, and the session's tasks show it finish.
type SessionCreate ¶ added in v1.12.0
type SessionCreate struct {
Agent Ref
// RequestID makes a retry idempotent: the controller keys it on
// (creator, request_id).
RequestID string
// Name is the display name; empty leaves the session unnamed.
Name string
// VolumeSource is the workspace volume the session works in and how its
// actor mounts it; nil for a session without one, which leaves the
// request as it always was.
VolumeSource *apiv1alpha1.SessionVolumeSource
// AdmissionToken is the proof the controller's admission verifies for
// VolumeSource. The controller stores and shows it nowhere.
AdmissionToken string
}
SessionCreate is what CreateSession asks for: the Agent, the idempotency key and the display name, and for a session in a workspace the volume source and the admission token that admits it.
Directories
¶
| Path | Synopsis |
|---|---|
|
gen
|
|
|
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.
|
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. |