Documentation
¶
Overview ¶
Package wire holds the HTTP wire format that the action handler (package genkit) serves and the remote agent client (package ai/exp) speaks, so the two sides share one definition and cannot drift apart.
A request is a POST whose body is a Request. A non-streaming response is a ResultResponse on success and an Error on failure, with the HTTP status mapped from the error's status. A streaming response is server-sent events, one "data: " line per event: a MessageResponse per chunk, then one ResultResponse or ErrorResponse.
Index ¶
Constants ¶
const RemoteAgentMetadataKey = "remoteAgent"
RemoteAgentMetadataKey is the action descriptor metadata key that marks an agent action as a proxy for an agent in another process (see AgentHandle.Register in ai/exp). Serving layouts skip such actions, so a server does not expose another service's agent with its own credentials.
const SSEDataPrefix = "data: "
SSEDataPrefix starts every server-sent event line the handler writes.
Variables ¶
This section is empty.
Functions ¶
func ClientMessage ¶
ClientMessage returns the message a client may see for err, and whether it is err's own text. The text leaves the process only when err was built with status.PublicErrorf, or in the dev environment, where hiding a failure only hides it from the developer causing it. Otherwise it is a generic message derived from the status, so schema dumps, provider text, and internal identifiers stay server-side.
func ServesAction ¶
ServesAction reports whether ctx is the context of a transport serving the action with the given key.
func WithServedAction ¶
WithServedAction marks ctx as the context of a request that a transport serves for the action with the given key. The action reads it with ServesAction to shape what it returns for a client, such as redacting internal error text. The mark names one action, so actions that the served action calls in turn do not read it as their own.
Types ¶
type Error ¶
Error is a failure on the wire: the body of a non-streaming error response, and the payload of a streaming one. It carries no details, so internal failure text stays off the wire.
type ErrorResponse ¶
type ErrorResponse struct {
Error *Error `json:"error"`
}
ErrorResponse carries the error that ended a stream.
type MessageResponse ¶
type MessageResponse struct {
Message json.RawMessage `json:"message"`
}
MessageResponse carries one streamed chunk.
type Request ¶
type Request struct {
// Data is the action's input.
Data json.RawMessage `json:"data"`
// Init is the session init of a bidi action, and is rejected for any
// other action.
Init json.RawMessage `json:"init,omitempty"`
}
Request is the body of a POST to an action.
type ResultResponse ¶
type ResultResponse struct {
Result json.RawMessage `json:"result"`
}
ResultResponse carries an action's final result.