event

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package event defines the persisted session event representation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventID          int64        `json:"event_id" db:"event_id"`
	SessionID        string       `json:"session_id" db:"session_id"`
	TurnID           string       `json:"turn_id" db:"turn_id"`
	Author           string       `json:"author" db:"author"`
	Role             string       `json:"role" db:"role"`
	Content          string       `json:"content" db:"text"`
	Parts            Parts        `json:"parts" db:"parts"`
	ReasoningContent string       `json:"reasoning_content" db:"reasoning_text"`
	ToolCalls        ToolCalls    `json:"tool_calls" db:"tool_calls"`
	ToolResponse     ToolResponse `json:"tool_response" db:"tool_result"`
	ToolCallID       string       `json:"tool_call_id" db:"tool_call_id"`
	FinishReason     string       `json:"finish_reason" db:"finish_reason"`
	PromptTokens     int64        `json:"prompt_tokens" db:"prompt_tokens"`
	CompletionTokens int64        `json:"completion_tokens" db:"completion_tokens"`
	TotalTokens      int64        `json:"total_tokens" db:"total_tokens"`
	UsageDetails     UsageDetails `json:"usage_details" db:"usage_details"`
	CreatedAt        int64        `json:"created_at" db:"created_at"`
	UpdatedAt        int64        `json:"updated_at" db:"updated_at"`
	// ArchivedAt is set when the event has been archived. A non-zero value means
	// the event is no longer part of the active history.
	ArchivedAt int64 `json:"archived_at" db:"archived_at"`
	DeletedAt  int64 `json:"deleted_at" db:"deleted_at"`
}

Event represents a persisted conversation event.

func FromModel

func FromModel(e model.Event) *Event

FromModel creates an Event from a model.Event, ready for persistence. EventID and timestamp fields must be set by the caller before saving.

func (*Event) ToModel

func (e *Event) ToModel() model.Event

ToModel converts a persisted Event to a model.Event.

type Parts

type Parts []model.ContentPart

Parts is a slice of ContentPart that serializes to/from JSON for database storage.

func (*Parts) Scan

func (p *Parts) Scan(src any) error

Scan implements sql.Scanner so Parts can be read from the database from a JSON string.

func (Parts) Value

func (p Parts) Value() (driver.Value, error)

Value implements driver.Valuer so Parts can be written to the database as a JSON string.

type ToolCall

type ToolCall struct {
	// ID is the unique identifier of this tool call, matching model.ToolCall.ID.
	ID        string          `json:"id" db:"id"`
	Name      string          `json:"name" db:"name"`
	Arguments json.RawMessage `json:"arguments" db:"arguments"`
	// ThoughtSignature is provider-supplied opaque state that must survive
	// history persistence for subsequent Gemini tool-call turns.
	ThoughtSignature []byte `json:"thought_signature,omitempty" db:"thought_signature"`
}

ToolCall represents a persisted tool call within an assistant event.

func (*ToolCall) UnmarshalJSON added in v0.0.7

func (tc *ToolCall) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the current raw JSON argument value and the older JSON-string representation used by pre-structured tool calls.

type ToolCalls

type ToolCalls []ToolCall

ToolCalls is a slice of ToolCall that serializes to/from JSON for database storage.

func (*ToolCalls) Scan

func (tl *ToolCalls) Scan(src any) error

Scan implements sql.Scanner so ToolCalls can be read from the database from a JSON string.

func (ToolCalls) Value

func (tl ToolCalls) Value() (driver.Value, error)

Value implements driver.Valuer so ToolCalls can be written to the database as a JSON string.

type ToolResponse added in v0.0.12

type ToolResponse struct {
	ToolCallID string             `json:"tool_call_id"`
	Name       string             `json:"name,omitempty"`
	Result     *tool.Result       `json:"result,omitempty"`
	Error      *tool.HandledError `json:"error,omitempty"`
}

ToolResponse is a persisted tool response within a tool event.

func (*ToolResponse) Scan added in v0.0.12

func (tr *ToolResponse) Scan(src any) error

Scan implements sql.Scanner so ToolResponse can be read from a JSON string. It accepts the legacy flat shape containing is_error for history compatibility.

func (ToolResponse) Value added in v0.0.12

func (tr ToolResponse) Value() (driver.Value, error)

Value implements driver.Valuer so ToolResponse can be written as JSON.

type UsageDetails added in v0.0.9

type UsageDetails model.TokenUsageDetails

UsageDetails serializes model.TokenUsageDetails to/from JSON for database storage.

func (*UsageDetails) Scan added in v0.0.9

func (d *UsageDetails) Scan(src any) error

Scan implements sql.Scanner so UsageDetails can be read from a JSON string.

func (UsageDetails) Value added in v0.0.9

func (d UsageDetails) Value() (driver.Value, error)

Value implements driver.Valuer so UsageDetails can be written as JSON.

Jump to

Keyboard shortcuts

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