types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayStrategy

type ArrayStrategy string

ArrayStrategy defines how arrays are handled in deep_merge.

const (
	ArrayStrategyConcat       ArrayStrategy = "concat"
	ArrayStrategyConcatUnique ArrayStrategy = "concat_unique"
	ArrayStrategyReplace      ArrayStrategy = "replace"
)

type Chunk

type Chunk struct {
	ID           string            `json:"id"`
	DocumentID   string            `json:"document_id"`
	Namespace    string            `json:"namespace"`
	CollectionID string            `json:"collection_id"`
	Content      string            `json:"content"`
	Embedding    []float32         `json:"embedding,omitempty"`
	Index        int               `json:"index"` // Position within the document
	TokenCount   int               `json:"token_count,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

Chunk represents a chunk of a document with its embedding.

type ChunkConfig

type ChunkConfig struct {
	Strategy  string `json:"strategy"`            // "fixed", "sentence", "paragraph", "semantic"
	MaxTokens int    `json:"max_tokens"`          // Max tokens per chunk (default: 512)
	Overlap   int    `json:"overlap"`             // Overlap tokens between chunks (default: 50)
	Separator string `json:"separator,omitempty"` // Custom split delimiter
}

ChunkConfig configures how documents are chunked.

func DefaultChunkConfig

func DefaultChunkConfig() ChunkConfig

DefaultChunkConfig returns a ChunkConfig with default values.

type ChunkResult

type ChunkResult struct {
	Chunk         *Chunk            `json:"chunk"`
	Score         float64           `json:"score"`
	Rank          int               `json:"rank,omitempty"` // Position in result set (for RRF)
	DocumentTitle string            `json:"document_title"`
	Source        string            `json:"source"`
	DocMetadata   map[string]string `json:"doc_metadata,omitempty"`
	ContextBefore string            `json:"context_before,omitempty"`
	ContextAfter  string            `json:"context_after,omitempty"`
}

ChunkResult represents a search result for a chunk.

type Collection

type Collection struct {
	ID          string      `json:"id"`
	Namespace   string      `json:"namespace"`
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	ChunkConfig ChunkConfig `json:"chunk_config"`
	CreatedAt   time.Time   `json:"created_at"`
}

Collection represents a collection of documents.

type CollectionStats

type CollectionStats struct {
	DocumentCount int64     `json:"document_count"`
	ChunkCount    int64     `json:"chunk_count"`
	TotalTokens   int64     `json:"total_tokens"`
	LastIngest    time.Time `json:"last_ingest"`
}

CollectionStats holds statistics for a collection.

type ContextEntry

type ContextEntry struct {
	Namespace    string     `json:"namespace"`
	RunID        *string    `json:"run_id,omitempty"` // Nil for cross-run state
	Key          string     `json:"key"`
	Value        any        `json:"value"`
	Version      int64      `json:"version"` // Optimistic concurrency
	UpdatedAt    time.Time  `json:"updated_at"`
	UpdatedBy    string     `json:"updated_by,omitempty"`     // Agent/task that last wrote
	TTLExpiresAt *time.Time `json:"ttl_expires_at,omitempty"` // Auto-expire time
}

ContextEntry represents a key-value entry in the workflow context.

type ContextGetResponse

type ContextGetResponse struct {
	Key       string    `json:"key"`
	Value     any       `json:"value"`
	Version   int64     `json:"version"`
	UpdatedAt time.Time `json:"updated_at"`
	Exists    bool      `json:"exists"`
}

ContextGetResponse represents the response from context.get.

type ContextHistoryEntry

type ContextHistoryEntry struct {
	Version   int64     `json:"version"`
	Value     any       `json:"value"`
	Operation string    `json:"operation"` // "set", "merge", "delete"
	UpdatedAt time.Time `json:"updated_at"`
	UpdatedBy string    `json:"updated_by,omitempty"`
}

ContextHistoryEntry represents a single entry in context history.

type ContextHistoryResponse

type ContextHistoryResponse struct {
	Key        string                 `json:"key"`
	History    []*ContextHistoryEntry `json:"history"`
	NextCursor string                 `json:"next_cursor,omitempty"`
}

ContextHistoryResponse represents the response from context.history.

type ContextListResponse

type ContextListResponse struct {
	Keys       []string `json:"keys"`
	Count      int      `json:"count"`
	NextCursor string   `json:"next_cursor,omitempty"`
}

ContextListResponse represents the response from context.list.

type ContextMergeResponse

type ContextMergeResponse struct {
	Key         string `json:"key"`
	Version     int64  `json:"version"`
	MergedValue any    `json:"merged_value"`
}

ContextMergeResponse represents the response from context.merge.

type ContextSetResponse

type ContextSetResponse struct {
	Key             string `json:"key"`
	Version         int64  `json:"version"`
	PreviousVersion int64  `json:"previous_version"`
}

ContextSetResponse represents the response from context.set.

type ConversationHistoryResponse

type ConversationHistoryResponse struct {
	Messages   []*Message `json:"messages"`
	Summary    string     `json:"summary,omitempty"`
	TotalCount int        `json:"total_count"`
	NextCursor string     `json:"next_cursor,omitempty"`
}

ConversationHistoryResponse represents the response from conversation.history.

type ConversationSearchResponse

type ConversationSearchResponse struct {
	Results []*MessageResult `json:"results"`
}

ConversationSearchResponse represents the response from conversation.search.

type Document

type Document struct {
	ID           string            `json:"id"`
	Namespace    string            `json:"namespace"`
	CollectionID string            `json:"collection_id"`
	Title        string            `json:"title,omitempty"`
	Content      string            `json:"content"`
	ContentType  string            `json:"content_type"` // "text", "markdown", "html"
	Source       string            `json:"source,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	SourceUser   string            `json:"source_user,omitempty"` // For future GDPR/PII compliance
	TenantID     string            `json:"tenant_id,omitempty"`   // For future multi-tenancy
	CreatedAt    time.Time         `json:"created_at"`
	UpdatedAt    time.Time         `json:"updated_at"`
}

Document represents a document in the knowledge store.

type Entity

type Entity struct {
	ID           string            `json:"id"`
	Namespace    string            `json:"namespace"`
	Name         string            `json:"name"`       // Canonical name
	Type         EntityType        `json:"type"`       // "person", "organization", "product", "location", "concept"
	Aliases      []string          `json:"aliases"`    // Alternative names, abbreviations
	Summary      string            `json:"summary"`    // LLM-generated summary of everything known
	Attributes   map[string]string `json:"attributes"` // Structured facts (e.g., "role": "CEO", "founded": "2021")
	Metadata     map[string]string `json:"metadata,omitempty"`
	MentionCount int64             `json:"mention_count"`
	FirstSeenAt  time.Time         `json:"first_seen_at"`
	LastSeenAt   time.Time         `json:"last_seen_at"`
}

Entity represents a named entity (person, organization, product, etc.).

type EntityListItem

type EntityListItem struct {
	Name         string     `json:"name"`
	Type         EntityType `json:"type"`
	MentionCount int64      `json:"mention_count"`
	LastSeenAt   time.Time  `json:"last_seen_at"`
}

EntityListItem is a lightweight entity representation for list responses.

type EntityListResponse

type EntityListResponse struct {
	Entities   []*EntityListItem `json:"entities"`
	TotalCount int               `json:"total_count"`
	NextCursor string            `json:"next_cursor,omitempty"`
}

EntityListResponse represents the response from entity.list.

type EntityMention

type EntityMention struct {
	ID         string    `json:"id"`
	EntityID   string    `json:"entity_id"`
	Namespace  string    `json:"namespace"`
	SourceType string    `json:"source_type"` // "conversation", "knowledge", "manual"
	SourceID   string    `json:"source_id"`   // Message ID, chunk ID, or manual entry ID
	Context    string    `json:"context"`     // Surrounding text where the entity was mentioned
	Snippet    string    `json:"snippet"`     // The exact mention text
	CreatedAt  time.Time `json:"created_at"`
}

EntityMention represents a mention of an entity in source content.

type EntityMergeResponse

type EntityMergeResponse struct {
	KeptEntity          string `json:"kept_entity"`
	MergedMentions      int    `json:"merged_mentions"`
	MergedRelationships int    `json:"merged_relationships"`
}

EntityMergeResponse represents the response from entity.merge.

type EntityQueryResponse

type EntityQueryResponse struct {
	Entity        *Entity               `json:"entity,omitempty"`
	Relationships []*EntityRelationship `json:"relationships,omitempty"`
	Mentions      []*EntityMention      `json:"mentions,omitempty"`
	Found         bool                  `json:"found"`
}

EntityQueryResponse represents the response from entity.query.

type EntityRelationship

type EntityRelationship struct {
	ID             string    `json:"id"`
	Namespace      string    `json:"namespace"`
	SourceEntityID string    `json:"source_entity_id"`
	TargetEntityID string    `json:"target_entity_id"`
	RelationType   string    `json:"relation_type"` // "works_at", "competes_with", "part_of", "related_to"
	Description    string    `json:"description"`   // Free-text description of the relationship
	Confidence     float64   `json:"confidence"`    // 0.0-1.0 extraction confidence
	MentionCount   int64     `json:"mention_count"`
	FirstSeenAt    time.Time `json:"first_seen_at"`
	LastSeenAt     time.Time `json:"last_seen_at"`
}

EntityRelationship represents a relationship between two entities.

type EntityRelationshipWithName

type EntityRelationshipWithName struct {
	RelatedEntity     string  `json:"related_entity"`
	RelatedEntityType string  `json:"related_entity_type"`
	RelationType      string  `json:"relation_type"`
	Description       string  `json:"description"`
	Direction         string  `json:"direction"` // "outgoing" or "incoming"
	Confidence        float64 `json:"confidence"`
	MentionCount      int64   `json:"mention_count"`
}

EntityRelationshipWithName includes the related entity name for display.

type EntityRelationshipsResponse

type EntityRelationshipsResponse struct {
	EntityName    string                        `json:"entity_name"`
	Relationships []*EntityRelationshipWithName `json:"relationships"`
}

EntityRelationshipsResponse represents the response from entity.relationships.

type EntityResult

type EntityResult struct {
	Entity *Entity `json:"entity"`
	Score  float64 `json:"score"`
	Rank   int     `json:"rank,omitempty"` // Position in result set (for RRF)
}

EntityResult represents a search result for an entity.

type EntitySearchResponse

type EntitySearchResponse struct {
	Results    []*EntityResult `json:"results"`
	TotalFound int             `json:"total_found"`
}

EntitySearchResponse represents the response from entity.search.

type EntitySortBy

type EntitySortBy string

EntitySortBy specifies the sort order for entity list queries.

const (
	EntitySortByName         EntitySortBy = "name"
	EntitySortByMentionCount EntitySortBy = "mention_count"
	EntitySortByLastSeen     EntitySortBy = "last_seen"
)

type EntityType

type EntityType string

EntityType represents the type of an entity.

const (
	EntityTypePerson       EntityType = "person"
	EntityTypeOrganization EntityType = "organization"
	EntityTypeProduct      EntityType = "product"
	EntityTypeLocation     EntityType = "location"
	EntityTypeConcept      EntityType = "concept"
)

type EntityUpdateResponse

type EntityUpdateResponse struct {
	EntityName    string   `json:"entity_name"`
	UpdatedFields []string `json:"updated_fields"`
}

EntityUpdateResponse represents the response from entity.update.

type ErrVersionConflict

type ErrVersionConflict struct {
	Key             string
	ExpectedVersion int64
	ActualVersion   int64
}

ErrVersionConflict is returned when optimistic concurrency check fails.

func (*ErrVersionConflict) Error

func (e *ErrVersionConflict) Error() string

type ExtractedEntity

type ExtractedEntity struct {
	Name          string                  `json:"name"`
	Type          EntityType              `json:"type"`
	Aliases       []string                `json:"aliases,omitempty"`
	Attributes    map[string]string       `json:"attributes,omitempty"`
	Relationships []ExtractedRelationship `json:"relationships,omitempty"`
}

ExtractedEntity represents an entity extracted by the LLM.

type ExtractedRelationship

type ExtractedRelationship struct {
	TargetName   string  `json:"target_name"`
	RelationType string  `json:"relation_type"`
	Description  string  `json:"description,omitempty"`
	Confidence   float64 `json:"confidence,omitempty"`
}

ExtractedRelationship represents a relationship extracted by the LLM.

type ExtractionQueueItem

type ExtractionQueueItem struct {
	ID          int64      `json:"id"`
	Namespace   string     `json:"namespace"`
	SourceType  string     `json:"source_type"` // "conversation", "knowledge"
	SourceID    string     `json:"source_id"`
	Content     string     `json:"content"`
	Status      string     `json:"status"` // "pending", "processing", "completed", "failed", "dead_letter"
	Attempts    int        `json:"attempts"`
	CreatedAt   time.Time  `json:"created_at"`
	ProcessedAt *time.Time `json:"processed_at,omitempty"`
}

ExtractionQueueItem represents an item in the entity extraction queue.

type KnowledgeIngestResponse

type KnowledgeIngestResponse struct {
	DocumentID    string `json:"document_id"`
	ChunksCreated int    `json:"chunks_created"`
	CollectionID  string `json:"collection_id"`
}

KnowledgeIngestResponse represents the response from knowledge.ingest.

type KnowledgeSearchResponse

type KnowledgeSearchResponse struct {
	Results    []*ChunkResult `json:"results"`
	TotalFound int            `json:"total_found"`
}

KnowledgeSearchResponse represents the response from knowledge.search.

type MergeStrategy

type MergeStrategy string

MergeStrategy defines how values are merged in context.merge.

const (
	MergeStrategyDeepMerge MergeStrategy = "deep_merge"
	MergeStrategyAppend    MergeStrategy = "append"
	MergeStrategyReplace   MergeStrategy = "replace"
	MergeStrategyMax       MergeStrategy = "max"
	MergeStrategyMin       MergeStrategy = "min"
	MergeStrategySum       MergeStrategy = "sum"
)

type Message

type Message struct {
	ID         string            `json:"id"`
	Namespace  string            `json:"namespace"`
	ThreadID   string            `json:"thread_id"`
	Role       string            `json:"role"` // "user", "assistant", "system", "tool"
	Content    string            `json:"content"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	SourceUser string            `json:"source_user,omitempty"` // For future GDPR/PII compliance
	TenantID   string            `json:"tenant_id,omitempty"`   // For future multi-tenancy
	Summarized bool              `json:"summarized,omitempty"`  // Whether this message has been summarized
	CreatedAt  time.Time         `json:"created_at"`
}

Message represents a single message in a conversation thread.

type MessageResult

type MessageResult struct {
	Message  *Message `json:"message"`
	Score    float64  `json:"score"`
	Rank     int      `json:"rank,omitempty"` // Position in result set (for RRF)
	ThreadID string   `json:"thread_id"`
}

MessageResult represents a search result for a message.

type RelationshipDirection

type RelationshipDirection string

RelationshipDirection specifies the direction for relationship queries.

const (
	RelationshipDirectionOutgoing RelationshipDirection = "outgoing"
	RelationshipDirectionIncoming RelationshipDirection = "incoming"
	RelationshipDirectionBoth     RelationshipDirection = "both"
)

type Thread

type Thread struct {
	ID        string            `json:"id"`
	Namespace string            `json:"namespace"`
	Title     string            `json:"title,omitempty"`
	Summary   string            `json:"summary,omitempty"` // LLM-generated summary of the thread
	Metadata  map[string]string `json:"metadata,omitempty"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

Thread represents a conversation thread containing messages.

Jump to

Keyboard shortcuts

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