Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v2.0.0-...-c9ed136 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package models defines the data structures for the REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZeroValue

func IsZeroValue(val any) bool

IsZeroValue checks if the val is the zero-ed value.

func ToSessionEvent

func ToSessionEvent(event Event) *session.Event

ToSessionEvent maps Event data struct to session.Event

Types

type CreateSessionRequest

type CreateSessionRequest struct {
	State  map[string]any `json:"state"`
	Events []Event        `json:"events"`
}

type Event

type Event struct {
	ID                  string                                      `json:"id"`
	InvocationID        string                                      `json:"invocationId"`
	Branch              string                                      `json:"branch,omitempty"`
	Author              string                                      `json:"author"`
	Partial             bool                                        `json:"partial,omitempty"`
	LongRunningToolIDs  []string                                    `json:"longRunningToolIds,omitempty"`
	Content             *genai.Content                              `json:"content"`
	GroundingMetadata   *genai.GroundingMetadata                    `json:"groundingMetadata"`
	UsageMetadata       *genai.GenerateContentResponseUsageMetadata `json:"usageMetadata"`
	TurnComplete        bool                                        `json:"turnComplete,omitempty"`
	Interrupted         bool                                        `json:"interrupted,omitempty"`
	ErrorCode           string                                      `json:"errorCode,omitempty"`
	ErrorMessage        string                                      `json:"errorMessage,omitempty"`
	AvgLogprobs         float64                                     `json:"avgLogprobs,omitempty"`
	FinishReason        genai.FinishReason                          `json:"finishReason,omitempty"`
	ModelVersion        string                                      `json:"modelVersion,omitempty"`
	InputTranscription  *genai.Transcription                        `json:"inputTranscription,omitempty"`
	OutputTranscription *genai.Transcription                        `json:"outputTranscription,omitempty"`
	Actions             EventActions                                `json:"actions"`
	Output              any                                         `json:"output,omitempty"`
	NodeInfo            *session.NodeInfo                           `json:"nodeInfo,omitempty"`
	IsolationScope      string                                      `json:"isolationScope,omitempty"`
	Routes              []string                                    `json:"routes,omitempty"`
	RequestedInput      *session.RequestInput                       `json:"requestedInput,omitempty"`
}

Event represents a single event in a session.

func FromSessionEvent

func FromSessionEvent(event session.Event) Event

FromSessionEvent maps session.Event to Event data struct

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

type EventActions

type EventActions struct {
	StateDelta                 map[string]any                               `json:"stateDelta"`
	ArtifactDelta              map[string]int64                             `json:"artifactDelta"`
	Escalate                   bool                                         `json:"escalate,omitempty"`
	SkipSummarization          bool                                         `json:"skipSummarization,omitempty"`
	TransferToAgent            string                                       `json:"transferToAgent,omitempty"`
	RequestedToolConfirmations map[string]toolconfirmation.ToolConfirmation `json:"requestedToolConfirmations,omitempty"`
}

EventActions represent a data model for session.EventActions

type EventarcTriggerRequest

type EventarcTriggerRequest struct {
	// Unique identifier for the event
	ID string `json:"id"`
	// Identifies the source of the event
	Source string `json:"source"`
	// The type of event data
	Type string `json:"type"`
	// The CloudEvents specification version used for this event
	SpecVersion string `json:"specversion"`
	// Event generation time, in RFC 3339 format (optional)
	Time string `json:"time,omitempty"`
	// In structured mode, “data“ is always present.
	// In binary mode, the entire body is the data (often a Pub/Sub wrapper).
	// But sometimes it can be just a JSON object.
	// E.g. https://googleapis.github.io/google-cloudevents/examples/binary/firestore/DocumentEventData-simple.json
	Data json.RawMessage `json:"data,omitempty"`
}

EventarcTriggerRequest represents the request for the Eventarc trigger. Eventarc / CloudEvents request format.

Eventarc delivers events as CloudEvents over HTTP in two modes:

  1. **Structured content mode** (JSON body): All CloudEvents attributes and the event data are in the JSON body. Used by direct HTTP callers.
  2. **Binary content mode** (Eventarc default): CloudEvents attributes are sent as “ce-*“ HTTP headers, and the body contains only the event data — typically a Pub/Sub message wrapper for Pub/Sub-sourced events: “{"message": {"data": "<base64>", ...}, "subscription": "..."}“.

See: https://cloud.google.com/eventarc/docs/cloudevents

type LiveRequest

type LiveRequest struct {
	Content       *genai.Content       `json:"content,omitempty"`
	Blob          *blob                `json:"blob,omitempty"`
	ActivityStart *genai.ActivityStart `json:"activityStart,omitempty"`
	ActivityEnd   *genai.ActivityEnd   `json:"activityEnd,omitempty"`
	Close         bool                 `json:"close,omitempty"`
}

LiveRequest represents the client request format for real-time interactions over WebSocket.

type PubSubMessage

type PubSubMessage struct {
	// The message payload. This will always be a base64-encoded string.
	Data []byte `json:"data"`
	// ID of this message, assigned by the Pub/Sub server.
	MessageID string `json:"messageId"`
	// The time at which the message was published, populated by the server.
	PublishTime string `json:"publishTime"`
	// Optional attributes for this message. An object containing a list of 'key': 'value' string pairs.
	Attributes map[string]string `json:"attributes,omitempty"`
	// If message ordering is enabled, this identifies related messages for which publish order should be respected.
	OrderingKey string `json:"orderingKey,omitempty"`
}

PubSubMessage represents the message for the PubSub trigger.

type PubSubTriggerRequest

type PubSubTriggerRequest struct {
	// The Pub/Sub message.
	Message PubSubMessage `json:"message"`
	// The subscription this message was published to.
	Subscription string `json:"subscription"`
}

PubSubTriggerRequest represents the request for the PubSub trigger. See: https://cloud.google.com/pubsub/docs/push#receive_push

type RunAgentRequest

type RunAgentRequest struct {
	AppName string `json:"appName"`

	UserId string `json:"userId"`

	SessionId string `json:"sessionId"`

	NewMessage genai.Content `json:"newMessage"`

	Streaming bool `json:"streaming,omitempty"`

	StateDelta *map[string]any `json:"stateDelta,omitempty"`

	// FunctionCallEventID identifies the event whose function call this
	// request answers (e.g. a human-in-the-loop reply from the web UI).
	// Accepted for adk-python parity but currently ignored; declared so
	// strict decoding (DisallowUnknownFields) does not reject the request.
	FunctionCallEventID *string `json:"functionCallEventId,omitempty"`
}

func (RunAgentRequest) AssertRunAgentRequestRequired

func (req RunAgentRequest) AssertRunAgentRequestRequired() error

AssertRunAgentRequestRequired checks if the required fields are not zero-ed

type Session

type Session struct {
	ID        string         `json:"id"`
	AppName   string         `json:"appName"`
	UserID    string         `json:"userId"`
	UpdatedAt int64          `json:"lastUpdateTime"`
	Events    []Event        `json:"events"`
	State     map[string]any `json:"state"`
}

Session represents an agent's session.

func FromSession

func FromSession(session session.Session) (Session, error)

func (Session) Validate

func (s Session) Validate() error

type SessionID

type SessionID struct {
	ID      string `mapstructure:"session_id,optional"`
	AppName string `mapstructure:"app_name,required"`
	UserID  string `mapstructure:"user_id,required"`
}

func SessionIDFromHTTPParameters

func SessionIDFromHTTPParameters(vars map[string]string) (SessionID, error)

type TriggerResponse

type TriggerResponse struct {
	// Processing status: 'success' or error message.
	Status string `json:"status"`
}

TriggerResponse represents the standard response for Pub/Sub and Eventarc triggers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL