domain

package
v1.15.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PIITypeEmail       = "email"
	PIITypeName        = "name"
	PIITypePhone       = "phone"
	PIITypeAddress     = "address"
	PIITypeCreditCard  = "credit_card"
	PIITypeSSN         = "ssn"
	PIITypePassword    = "password"
	PIITypeIPAddress   = "ip_address"
	PIITypeDateOfBirth = "date_of_birth"
	PIITypeGeneral     = "general"
)

PIIType constants for categorising PII fields.

Variables

View Source
var DatadogRegions = []DatadogRegion{
	{DatadogSiteUS1, "US1 (datadoghq.com)", "United States"},
	{DatadogSiteUS3, "US3 (us3.datadoghq.com)", "United States"},
	{DatadogSiteUS5, "US5 (us5.datadoghq.com)", "United States"},
	{DatadogSiteEU1, "EU1 (datadoghq.eu)", "Europe"},
	{DatadogSiteAP1, "AP1 (ap1.datadoghq.com)", "Asia Pacific"},
	{DatadogSiteUS1Fed, "US1-FED (ddog-gov.com)", "US Government"},
}

DatadogRegions is the list of available Datadog regions.

Functions

func EncodeBlocks

func EncodeBlocks(blocks []Block) (string, error)

EncodeBlocks serializes blocks to JSON string for storage.

func EncodeText

func EncodeText(content string) (string, error)

EncodeText is a convenience function to encode a single text block.

func EncodeToolResults

func EncodeToolResults(results []ToolResult) (string, error)

EncodeToolResults encodes tool results as blocks for storage.

Types

type Account

type Account struct {
	ID   AccountID `json:"id"`
	Name string    `json:"name"`
}

Account represents a billing/Datadog account within an organization.

func (Account) FilterValue

func (a Account) FilterValue() string

FilterValue returns the string used for filtering/searching.

type AccountID

type AccountID string

AccountID is a unique identifier for an account.

func NewAccountID

func NewAccountID() AccountID

NewAccountID generates a new unique AccountID.

func (AccountID) String

func (id AccountID) String() string

type AccountSummary added in v1.14.0

type AccountSummary struct {
	ReadyForUse bool

	// Health.
	Health    ServiceHealth
	Error     string
	ErrorAt   string
	Warning   string
	WarningAt string

	// Service counts.
	ServiceCount     int64
	ActiveServices   int64
	OkServices       int64
	ErrorServices    int64
	StaleServices    int64
	DisabledServices int64
	InactiveServices int64

	// Event counts.
	EventCount       int64
	AnalyzedCount    int64
	QuarantinedCount int64

	// Policy counts.
	PendingPolicyCount   int64
	ApprovedPolicyCount  int64
	DismissedPolicyCount int64

	// Service-level throughput (ground truth).
	TotalServiceVolumePerHour *float64
	TotalServiceCostPerHour   *float64

	// Log event throughput (discovered events).
	TotalCostPerHour       *float64 // nil when pricing unavailable
	TotalCostPerHourBytes  *float64
	TotalCostPerHourVolume *float64
	TotalVolumePerHour     float64
	TotalBytesPerHour      float64

	// Estimated savings from pending policies.
	EstimatedCostPerHour       *float64 // nil when pricing unavailable
	EstimatedCostPerHourBytes  *float64
	EstimatedCostPerHourVolume *float64
	EstimatedVolumePerHour     float64
	EstimatedBytesPerHour      float64

	// Observed impact from approved policies (before/after).
	ObservedCostBefore   *float64 // nil when pricing unavailable
	ObservedCostAfter    *float64
	ObservedVolumeBefore float64
	ObservedVolumeAfter  float64
	ObservedBytesBefore  float64
	ObservedBytesAfter   float64
}

AccountSummary mirrors datadog_account_statuses_cache aggregated across all Datadog accounts. All columns included; callers pick what they need.

type Block

type Block struct {
	Index      int         `json:"index"`
	Type       BlockType   `json:"type"`
	Text       *TextBlock  `json:"text,omitempty"`
	Thinking   *Thinking   `json:"thinking,omitempty"`
	ToolUse    *ToolUse    `json:"tool_use,omitempty"`
	ToolResult *ToolResult `json:"tool_result,omitempty"`
}

Block is one element in a message's content array. Exactly one of the typed fields is populated, determined by Type.

func NewTextBlock

func NewTextBlock(content string) Block

NewTextBlock creates a text block.

func ParseBlocks

func ParseBlocks(data string) ([]Block, error)

ParseBlocks parses a JSON string into content blocks.

type BlockType

type BlockType string

BlockType identifies the kind of content block.

const (
	// Persistable block types - stored in the database.
	BlockTypeText       BlockType = "text"
	BlockTypeThinking   BlockType = "thinking"
	BlockTypeToolUse    BlockType = "tool_use"
	BlockTypeToolResult BlockType = "tool_result"
)

type ContextEntity

type ContextEntity struct {
	EntityType string `json:"entity_type"` // "service", "log_event", "policy", etc.
	EntityID   string `json:"entity_id"`
}

ContextEntity is an entity attached to a conversation for the AI to reference. The client sends entity IDs; the server loads full entity data for the system prompt.

type ContextSource

type ContextSource string

ContextSource indicates who added an entity to context.

const (
	ContextSourceUser      ContextSource = "user"
	ContextSourceAssistant ContextSource = "assistant"
)

type Conversation

type Conversation struct {
	ID          ConversationID `json:"id"`
	WorkspaceID WorkspaceID    `json:"workspace_id"`
	Title       string         `json:"title"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
}

Conversation represents a chat conversation.

type ConversationID

type ConversationID string

ConversationID is a typed identifier for conversations.

func NewConversationID

func NewConversationID() ConversationID

NewConversationID generates a new unique ConversationID.

func (ConversationID) String

func (id ConversationID) String() string

String returns the string representation of the ConversationID.

type DatadogAccountID

type DatadogAccountID string

DatadogAccountID is a unique identifier for a Datadog account integration.

func (DatadogAccountID) String

func (id DatadogAccountID) String() string

type DatadogRegion

type DatadogRegion struct {
	Site DatadogSite
	Name string
	Desc string
}

DatadogRegion contains display information for a Datadog site.

type DatadogSite

type DatadogSite string

DatadogSite represents a Datadog datacenter region.

const (
	DatadogSiteUS1    DatadogSite = "US1"
	DatadogSiteUS3    DatadogSite = "US3"
	DatadogSiteUS5    DatadogSite = "US5"
	DatadogSiteEU1    DatadogSite = "EU1"
	DatadogSiteAP1    DatadogSite = "AP1"
	DatadogSiteUS1Fed DatadogSite = "US1_FED"
)

func (DatadogSite) String

func (s DatadogSite) String() string

type LogEventStatus

type LogEventStatus string

LogEventStatus is the pipeline status for a log event.

const (
	LogEventStatusBroken      LogEventStatus = "BROKEN"
	LogEventStatusQuarantined LogEventStatus = "QUARANTINED"
	LogEventStatusResolved    LogEventStatus = "RESOLVED"
	LogEventStatusClean       LogEventStatus = "CLEAN"
	LogEventStatusPending     LogEventStatus = "PENDING"
	LogEventStatusAnalyzing   LogEventStatus = "ANALYZING"
	LogEventStatusDiscovering LogEventStatus = "DISCOVERING"
)

func (LogEventStatus) String

func (s LogEventStatus) String() string

type Message

type Message struct {
	ID             MessageID      `json:"id"`
	ConversationID ConversationID `json:"conversation_id"`
	Role           Role           `json:"role"`
	Content        []Block        `json:"content"`
	Model          string         `json:"model,omitempty"`
	StopReason     string         `json:"stop_reason,omitempty"`
	CreatedAt      time.Time      `json:"created_at"`
}

Message represents a chat message.

type MessageID

type MessageID string

MessageID is a typed identifier for messages.

func NewMessageID

func NewMessageID() MessageID

NewMessageID generates a new unique MessageID.

func (MessageID) String

func (id MessageID) String() string

String returns the string representation of the MessageID.

type Organization

type Organization struct {
	ID                   OrganizationID       `json:"id"`
	Name                 string               `json:"name"`
	WorkosOrganizationID WorkosOrganizationID `json:"workos_organization_id,omitempty"`
}

Organization represents a customer organization.

func (Organization) FilterValue

func (o Organization) FilterValue() string

FilterValue returns the string used for filtering/searching.

type OrganizationID

type OrganizationID string

OrganizationID is a unique identifier for an organization.

func NewOrganizationID

func NewOrganizationID() OrganizationID

NewOrganizationID generates a new unique OrganizationID.

func (OrganizationID) String

func (id OrganizationID) String() string

type PIIAnalysisEnvelope added in v1.15.0

type PIIAnalysisEnvelope struct {
	PIILeakage *PIILeakageAnalysis `json:"pii_leakage,omitempty"`
}

PIIAnalysisEnvelope wraps the category-keyed analysis JSON from the database.

type PIIField added in v1.15.0

type PIIField struct {
	Path    []string `json:"path"`
	PIIType string   `json:"pii_type"`
}

PIIField identifies an attribute path that contains PII and its type.

func (PIIField) Severity added in v1.15.0

func (f PIIField) Severity() PIISeverity

Severity returns the derived sensitivity level for this field's PII type.

type PIILeakageAnalysis added in v1.15.0

type PIILeakageAnalysis struct {
	Rationale string     `json:"rationale"`
	Benefits  []string   `json:"benefits"`
	Fields    []PIIField `json:"fields"`
}

PIILeakageAnalysis is the category-specific analysis for PII leakage policies. Stored as JSON in the log_event_policies.analysis column under the "pii_leakage" key.

type PIIPolicy added in v1.15.0

type PIIPolicy struct {
	LogEventName  string
	ServiceName   string
	Fields        []PIIField  // Parsed from analysis JSON
	VolumePerHour float64     // Log event volume from log_event_statuses_cache
	MaxSeverity   PIISeverity // Highest severity across fields, computed in SQL
}

PIIPolicy is a single pending PII leakage finding with context from joined tables.

type PIISeverity added in v1.15.0

type PIISeverity int

PIISeverity indicates how sensitive a PII type is.

const (
	PIISeverityMedium   PIISeverity = iota // general
	PIISeverityHigh                        // email, name, phone, address, ip_address, date_of_birth
	PIISeverityCritical                    // credit_card, ssn, password
)

type PolicyCategoryStatus

type PolicyCategoryStatus struct {
	Category               string
	PendingCount           int64
	ApprovedCount          int64
	DismissedCount         int64
	EstimatedVolumePerHour float64
	EstimatedBytesPerHour  float64
	EstimatedCostPerHour   float64
	Benefit                string

	// Observed impact from approved policies (before/after).
	ObservedVolumeBefore float64
	ObservedVolumeAfter  float64
	ObservedBytesBefore  float64
	ObservedBytesAfter   float64
	ObservedCostBefore   float64
	ObservedCostAfter    float64
}

PolicyCategoryStatus is the per-category policy breakdown.

func (PolicyCategoryStatus) DisplayName added in v1.15.0

func (c PolicyCategoryStatus) DisplayName() string

DisplayName returns a human-readable name for the category. Converts slugs like "bot_traffic" to "Bot Traffic".

type PolicyLogStatus

type PolicyLogStatus string

PolicyLogStatus is the lifecycle status for a policy.

const (
	PolicyLogStatusPending   PolicyLogStatus = "PENDING"
	PolicyLogStatusApproved  PolicyLogStatus = "APPROVED"
	PolicyLogStatusDismissed PolicyLogStatus = "DISMISSED"
)

func (PolicyLogStatus) String

func (s PolicyLogStatus) String() string

type Role

type Role string

Role identifies who sent a message.

const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
)

type ServiceHealth added in v1.15.0

type ServiceHealth string

ServiceHealth is the health status for a service or account.

const (
	ServiceHealthDisabled ServiceHealth = "DISABLED"
	ServiceHealthInactive ServiceHealth = "INACTIVE"
	ServiceHealthError    ServiceHealth = "ERROR"
	ServiceHealthStale    ServiceHealth = "STALE"
	ServiceHealthOK       ServiceHealth = "OK"
)

func (ServiceHealth) String added in v1.15.0

func (s ServiceHealth) String() string

type ServiceID added in v1.15.0

type ServiceID string

ServiceID is a unique identifier for a service.

func (ServiceID) String added in v1.15.0

func (id ServiceID) String() string

type ServiceStatus

type ServiceStatus struct {
	Name   string
	Health ServiceHealth

	// Error / warning state.
	Error     string
	ErrorAt   string
	Warning   string
	WarningAt string

	// Event counts.
	LogEventCount            int64
	LogEventAnalyzedCount    int64
	LogEventQuarantinedCount int64

	// Policy counts.
	PolicyPendingCount   int64
	PolicyApprovedCount  int64
	PolicyDismissedCount int64

	// Service-level throughput (ground truth from service_log_volumes).
	ServiceVolumePerHour        float64
	ServiceCostPerHourVolumeUSD float64

	// Log event throughput (discovered events subset).
	LogEventVolumePerHour        float64
	LogEventBytesPerHour         float64
	LogEventCostPerHourUSD       float64
	LogEventCostPerHourBytesUSD  float64
	LogEventCostPerHourVolumeUSD float64

	// Estimated savings from pending policies.
	EstimatedVolumeReductionPerHour     float64
	EstimatedBytesReductionPerHour      float64
	EstimatedCostReductionPerHourUSD    float64
	EstimatedCostReductionPerHourBytes  float64
	EstimatedCostReductionPerHourVolume float64

	// Observed impact from approved policies (before/after).
	ObservedVolumePerHourBefore        float64
	ObservedVolumePerHourAfter         float64
	ObservedBytesPerHourBefore         float64
	ObservedBytesPerHourAfter          float64
	ObservedCostPerHourBeforeUSD       float64
	ObservedCostPerHourBeforeBytesUSD  float64
	ObservedCostPerHourBeforeVolumeUSD float64
	ObservedCostPerHourAfterUSD        float64
	ObservedCostPerHourAfterBytesUSD   float64
	ObservedCostPerHourAfterVolumeUSD  float64
}

ServiceStatus mirrors service_statuses_cache. All columns included; callers pick what they need.

type TextBlock

type TextBlock struct {
	Content string `json:"content"`
}

TextBlock is prose content.

type Thinking

type Thinking struct {
	Content string `json:"content"`
}

Thinking is the AI's internal reasoning.

type ToolInputDelta

type ToolInputDelta struct {
	ToolUseID string `json:"tool_use_id"`
	Delta     string `json:"delta"`
}

ToolInputDelta is a streaming fragment of tool input JSON.

type ToolResult

type ToolResult struct {
	ToolUseID string         `json:"tool_use_id"`
	IsError   bool           `json:"is_error,omitempty"`
	Error     string         `json:"error,omitempty"`
	Content   map[string]any `json:"content,omitempty"`
}

ToolResult is the outcome of a tool call (wire/storage format).

type ToolUse

type ToolUse struct {
	ID            string          `json:"id"`
	Name          string          `json:"name"`
	Input         json.RawMessage `json:"input"`
	InputComplete bool            `json:"-"` // True when input is fully received (after content_block_stop)
}

ToolUse represents the AI calling a tool.

type WastePolicy added in v1.15.0

type WastePolicy struct {
	LogEventName          string
	ServiceName           string
	VolumePerHour         float64
	EstimatedCostPerHour  float64
	EstimatedBytesPerHour float64
}

WastePolicy is a single pending waste policy with context from joined tables.

type WorkosOrganizationID

type WorkosOrganizationID string

WorkosOrganizationID is the external ID from WorkOS.

func (WorkosOrganizationID) String

func (id WorkosOrganizationID) String() string

type Workspace

type Workspace struct {
	ID   WorkspaceID `json:"id"`
	Name string      `json:"name"`
}

Workspace represents a workspace within an account.

func (Workspace) FilterValue

func (w Workspace) FilterValue() string

FilterValue returns the string used for filtering/searching.

type WorkspaceID

type WorkspaceID string

WorkspaceID is a unique identifier for a workspace.

func NewWorkspaceID

func NewWorkspaceID() WorkspaceID

NewWorkspaceID generates a new unique WorkspaceID.

func (WorkspaceID) String

func (id WorkspaceID) String() string

Directories

Path Synopsis
Package domaintest provides factories for creating domain objects in tests.
Package domaintest provides factories for creating domain objects in tests.
Package tools defines tool input/output types.
Package tools defines tool input/output types.

Jump to

Keyboard shortcuts

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