Documentation
¶
Overview ¶
Package domain defines the core business entities for Sercha.
This package is part of the hexagonal architecture's innermost layer. It has NO external dependencies and defines the fundamental types:
- Document: An indexed document with metadata
- Chunk: A searchable unit within a document
- Source: A configured data source
- RawDocument: Opaque bytes from a connector
Architectural Position ¶
Domain is at the centre of the hexagon. It may only import the Go standard library. All other packages depend on domain, never the reverse.
Import Rules ¶
- Can Import: Standard library only
- Cannot Import: Any internal/ package, any external dependency
Index ¶
- Constants
- Variables
- func DefaultEmbeddingModels() map[AIProvider]string
- func DefaultLLMModels() map[AIProvider]string
- func EmbeddingDimensions() map[string]int
- type AIProvider
- type AppSettings
- type AuthCapability
- type AuthMethod
- type AuthProvider
- type ChangeType
- type Chunk
- type ConfigKey
- type ConnectorType
- type Credentials
- type Document
- type EmbeddingSettings
- type Exclusion
- type LLMSettings
- type OAuthCredentials
- type OAuthProviderConfig
- type OAuthToken
- type PATCredentials
- type PipelineConfig
- type ProviderType
- type RawDocument
- type RawDocumentChange
- type ScheduledTask
- type SchedulerConfig
- type SearchMode
- type SearchOptions
- type SearchResult
- type SearchSettings
- type Source
- type SyncState
- type TaskConfig
- type TaskResult
- type VectorIndexSettings
- type VectorPrecision
- type WebURLResolver
Constants ¶
const ( TaskIDOAuthRefresh = "oauth-refresh" TaskIDDocumentSync = "document-sync" )
Task IDs for built-in tasks.
Variables ¶
var ( // ErrNotFound indicates a requested entity does not exist. ErrNotFound = errors.New("not found") // ErrAlreadyExists indicates an entity already exists. ErrAlreadyExists = errors.New("already exists") // ErrInvalidInput indicates malformed or invalid input. ErrInvalidInput = errors.New("invalid input") // ErrNotImplemented indicates functionality is not yet available. ErrNotImplemented = errors.New("not implemented") // ErrUnsupportedType indicates an unknown connector or normaliser type. ErrUnsupportedType = errors.New("unsupported type") // ErrSyncInProgress indicates a sync is already running. ErrSyncInProgress = errors.New("sync in progress") // Features requiring LLM (query rewriting, summarisation) are disabled. ErrLLMUnavailable = errors.New("LLM service unavailable") // Vector/semantic search is disabled without embeddings. ErrEmbeddingUnavailable = errors.New("embedding service unavailable") // Full-text/keyword search is disabled. ErrSearchUnavailable = errors.New("search engine unavailable") // Semantic similarity search is disabled. ErrVectorIndexUnavailable = errors.New("vector index unavailable") // ErrAuthRequired indicates the connector requires authentication but none is configured. ErrAuthRequired = errors.New("authentication required") // ErrAuthExpired indicates the authentication has expired and refresh failed. ErrAuthExpired = errors.New("authentication expired") // ErrAuthInvalid indicates the authentication credentials are invalid. ErrAuthInvalid = errors.New("authentication invalid") // ErrTokenRefreshFailed indicates token refresh operation failed. ErrTokenRefreshFailed = errors.New("token refresh failed") // ErrConnectorValidation indicates connector validation failed. // The source is misconfigured or credentials are invalid. ErrConnectorValidation = errors.New("connector validation failed") // ErrConnectorClosed indicates the connector has been closed. ErrConnectorClosed = errors.New("connector closed") // ErrRateLimited indicates the API rate limit was exceeded. ErrRateLimited = errors.New("rate limited") // ErrAuthProviderInUse indicates an auth provider cannot be deleted because sources depend on it. ErrAuthProviderInUse = errors.New("auth provider is in use by one or more sources") )
Domain errors represent business logic failures. These are distinct from infrastructure errors.
Functions ¶
func DefaultEmbeddingModels ¶
func DefaultEmbeddingModels() map[AIProvider]string
DefaultEmbeddingModels returns default models for each embedding provider.
func DefaultLLMModels ¶
func DefaultLLMModels() map[AIProvider]string
DefaultLLMModels returns default models for each LLM provider.
func EmbeddingDimensions ¶
EmbeddingDimensions returns the vector dimensions for known models.
Types ¶
type AIProvider ¶
type AIProvider string
AIProvider identifies an AI service provider for embeddings or LLM.
const ( // AIProviderOllama is local Ollama instance. AIProviderOllama AIProvider = "ollama" // AIProviderOpenAI is OpenAI cloud API. AIProviderOpenAI AIProvider = "openai" // AIProviderAnthropic is Anthropic cloud API. AIProviderAnthropic AIProvider = "anthropic" )
Available AI providers.
func AllEmbeddingProviders ¶
func AllEmbeddingProviders() []AIProvider
AllEmbeddingProviders returns providers that support embeddings.
func AllLLMProviders ¶
func AllLLMProviders() []AIProvider
AllLLMProviders returns providers that support LLM operations.
func (AIProvider) Description ¶
func (p AIProvider) Description() string
Description returns a human-readable description of the provider.
func (AIProvider) IsLocal ¶
func (p AIProvider) IsLocal() bool
IsLocal returns true if this provider runs locally.
func (AIProvider) IsValid ¶
func (p AIProvider) IsValid() bool
IsValid returns true if the AI provider is recognised.
func (AIProvider) RequiresAPIKey ¶
func (p AIProvider) RequiresAPIKey() bool
RequiresAPIKey returns true if this provider needs an API key.
func (AIProvider) String ¶
func (p AIProvider) String() string
String returns the string representation.
type AppSettings ¶
type AppSettings struct {
// Search holds search behaviour settings.
Search SearchSettings
// Embedding holds embedding provider settings.
Embedding EmbeddingSettings
// LLM holds LLM provider settings.
LLM LLMSettings
// VectorIndex holds vector index settings.
VectorIndex VectorIndexSettings
}
AppSettings holds all application settings.
func DefaultAppSettings ¶
func DefaultAppSettings() AppSettings
DefaultAppSettings returns settings with sensible defaults. AI features (Embedding, LLM) are left unconfigured by default. Users must explicitly configure them via settings wizard.
type AuthCapability ¶
type AuthCapability uint8
AuthCapability represents supported authentication capabilities for a provider. This is a bitfield allowing providers to support multiple auth methods.
const ( // AuthCapNone indicates no authentication is needed. AuthCapNone AuthCapability = 0 // AuthCapPAT indicates Personal Access Token authentication is supported. AuthCapPAT AuthCapability = 1 << 0 // AuthCapOAuth indicates OAuth 2.0 authentication is supported. AuthCapOAuth AuthCapability = 1 << 1 )
func (AuthCapability) RequiresAuth ¶
func (c AuthCapability) RequiresAuth() bool
RequiresAuth returns true if any authentication is required.
func (AuthCapability) String ¶
func (c AuthCapability) String() string
String returns a human-readable representation.
func (AuthCapability) SupportedMethods ¶
func (c AuthCapability) SupportedMethods() []AuthMethod
SupportedMethods returns a slice of supported AuthMethods. Returns an empty slice if no authentication is required.
func (AuthCapability) SupportsMultipleMethods ¶
func (c AuthCapability) SupportsMultipleMethods() bool
SupportsMultipleMethods returns true if more than one auth method is supported.
func (AuthCapability) SupportsOAuth ¶
func (c AuthCapability) SupportsOAuth() bool
SupportsOAuth returns true if OAuth authentication is supported.
func (AuthCapability) SupportsPAT ¶
func (c AuthCapability) SupportsPAT() bool
SupportsPAT returns true if PAT authentication is supported.
type AuthMethod ¶
type AuthMethod string
AuthMethod defines how a connector authenticates.
const ( // AuthMethodNone requires no authentication (e.g., filesystem). AuthMethodNone AuthMethod = "none" // AuthMethodPAT uses a Personal Access Token. AuthMethodPAT AuthMethod = "pat" // AuthMethodOAuth uses OAuth 2.0 with PKCE. AuthMethodOAuth AuthMethod = "oauth" )
type AuthProvider ¶
type AuthProvider struct {
// ID is the unique identifier (UUID).
ID string `json:"id"`
// Name is the user-friendly name (e.g., "My Google App", "Work GitHub").
Name string `json:"name"`
// ProviderType identifies the provider (google, github, slack, etc.).
ProviderType ProviderType `json:"provider_type"`
// AuthMethod indicates how sources using this provider authenticate (oauth, pat, none).
AuthMethod AuthMethod `json:"auth_method"`
// OAuth holds OAuth application credentials (for AuthMethodOAuth).
// Nil for PAT or no-auth providers.
OAuth *OAuthProviderConfig `json:"oauth,omitempty"`
// CreatedAt is when the provider was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the provider was last updated.
UpdatedAt time.Time `json:"updated_at"`
}
AuthProvider represents a reusable authentication provider configuration. For OAuth: stores client credentials (can be shared across multiple sources/accounts). For PAT: stores provider info (each source has its own PAT in Credentials).
Example: One Google OAuth app can be used by multiple Gmail, Drive, and Calendar sources.
func (*AuthProvider) IsOAuth ¶
func (p *AuthProvider) IsOAuth() bool
IsOAuth returns true if this provider uses OAuth authentication.
func (*AuthProvider) IsPAT ¶
func (p *AuthProvider) IsPAT() bool
IsPAT returns true if this provider uses PAT authentication.
func (*AuthProvider) RequiresCredentials ¶
func (p *AuthProvider) RequiresCredentials() bool
RequiresCredentials returns true if sources using this provider need credentials.
type ChangeType ¶
type ChangeType int
ChangeType represents the type of document change.
const ( // ChangeCreated indicates a new document. ChangeCreated ChangeType = iota // ChangeUpdated indicates a modified document. ChangeUpdated // ChangeDeleted indicates a removed document. ChangeDeleted )
type Chunk ¶
type Chunk struct {
// ID is the unique identifier for the chunk.
ID string
// DocumentID links to the parent Document.
DocumentID string
// Content is the text content of this chunk.
Content string
// Position is the ordinal position within the document.
Position int
// Embedding is the vector representation for semantic search.
Embedding []float32
// Metadata contains chunk-specific key-value pairs.
Metadata map[string]any
}
Chunk represents a searchable unit within a document. Documents are split into chunks for granular search results.
type ConfigKey ¶
type ConfigKey struct {
// Key is the configuration key name.
Key string
// Label is the human-readable label for UI display.
Label string
// Description explains what this field is for.
Description string
// Default is the default value for this field (shown in placeholder).
Default string
// Required indicates whether this field must be provided.
Required bool
// Secret indicates whether this field should be masked in UI (e.g., tokens).
Secret bool
}
ConfigKey describes a configuration field for a connector.
type ConnectorType ¶
type ConnectorType struct {
// ID is the unique identifier (e.g., "filesystem", "github", "google-drive").
ID string
// Name is the human-readable display name.
Name string
// Description provides a brief explanation of the connector.
Description string
// ProviderType identifies which auth provider this connector uses.
ProviderType ProviderType
// AuthCapability specifies what authentication methods this connector supports.
// Use this to determine if user should be given a choice of auth methods.
AuthCapability AuthCapability
// AuthMethod specifies how the connector authenticates (derived from provider).
// Deprecated: Use AuthCapability instead. Kept for backward compatibility.
AuthMethod AuthMethod
// ConfigKeys lists the configuration fields required by this connector.
ConfigKeys []ConfigKey
// WebURLResolver converts document URIs to web-openable URLs.
// If nil, falls back to legacy URI conversion.
WebURLResolver WebURLResolver
}
ConnectorType describes a supported connector.
func (*ConnectorType) RequiresAuth ¶
func (c *ConnectorType) RequiresAuth() bool
RequiresAuth returns true if this connector requires authentication.
type Credentials ¶
type Credentials struct {
// ID is the unique identifier (UUID).
ID string `json:"id"`
// SourceID links to the Source this credentials belongs to (1:1 relationship).
SourceID string `json:"source_id"`
// AccountIdentifier is the user's email or username from the provider.
// Fetched from the provider's userinfo endpoint after authentication.
// Examples: "user@gmail.com", "octocat", "user@company.slack.com"
AccountIdentifier string `json:"account_identifier,omitempty"`
// OAuth holds OAuth tokens (for OAuth authentication).
// Nil for PAT authentication.
OAuth *OAuthCredentials `json:"oauth,omitempty"`
// PAT holds the Personal Access Token (for PAT authentication).
// Nil for OAuth authentication.
PAT *PATCredentials `json:"pat,omitempty"`
// CreatedAt is when the credentials were created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the credentials were last updated.
UpdatedAt time.Time `json:"updated_at"`
}
Credentials stores user-specific authentication tokens for a Source. Each Source has exactly one Credentials (or none for no-auth sources like filesystem).
This separates user tokens from OAuth app credentials (stored in AuthProvider), enabling one OAuth app to serve multiple user accounts.
func (*Credentials) GetAccessToken ¶
func (c *Credentials) GetAccessToken() string
GetAccessToken returns the access token (either OAuth or PAT).
func (*Credentials) HasRefreshToken ¶
func (c *Credentials) HasRefreshToken() bool
HasRefreshToken returns true if a refresh token is available.
func (*Credentials) IsAuthenticated ¶
func (c *Credentials) IsAuthenticated() bool
IsAuthenticated returns true if the credentials contain valid tokens.
func (*Credentials) NeedsRefresh ¶
func (c *Credentials) NeedsRefresh() bool
NeedsRefresh returns true if OAuth tokens need refreshing.
type Document ¶
type Document struct {
// ID is the unique identifier for the document.
ID string
// SourceID links to the Source that produced this document.
SourceID string
// URI is the original location (file path, URL, etc).
URI string
// Title is the human-readable title.
Title string
// Content is the full text content after normalisation.
// This is the complete document text before chunking.
Content string
// ParentID links to a parent document for hierarchical sources.
ParentID *string
// Metadata contains arbitrary key-value pairs.
Metadata map[string]any
// CreatedAt is when the document was first indexed.
CreatedAt time.Time
// UpdatedAt is when the document was last updated.
UpdatedAt time.Time
}
Document represents an indexed document with metadata. It is the canonical representation after normalisation.
type EmbeddingSettings ¶
type EmbeddingSettings struct {
// Provider is the embedding service provider.
Provider AIProvider
// Model is the embedding model name.
Model string
// BaseURL is the API endpoint (for Ollama).
BaseURL string
// APIKey is the API key (for OpenAI).
APIKey string
}
EmbeddingSettings holds embedding provider configuration.
func (EmbeddingSettings) IsConfigured ¶
func (e EmbeddingSettings) IsConfigured() bool
IsConfigured returns true if the embedding provider is set up.
type Exclusion ¶
type Exclusion struct {
// ID is the unique identifier for the exclusion.
ID string
// SourceID links to the Source this exclusion applies to.
SourceID string
// DocumentID is the ID of the excluded document.
DocumentID string
// URI is the original location for matching on re-sync.
URI string
// Reason is an optional explanation for the exclusion.
Reason string
// ExcludedAt is when the document was excluded.
ExcludedAt time.Time
}
Exclusion represents a document that has been excluded from syncing. When a document is excluded, it will not be re-indexed during future syncs.
type LLMSettings ¶
type LLMSettings struct {
// Provider is the LLM service provider.
Provider AIProvider
// Model is the LLM model name.
Model string
// BaseURL is the API endpoint (for Ollama).
BaseURL string
// APIKey is the API key (for OpenAI/Anthropic).
APIKey string
}
LLMSettings holds LLM provider configuration.
func (LLMSettings) IsConfigured ¶
func (l LLMSettings) IsConfigured() bool
IsConfigured returns true if the LLM provider is set up.
type OAuthCredentials ¶
type OAuthCredentials struct {
// AccessToken is the bearer token for API access.
AccessToken string `json:"access_token"`
// RefreshToken is used to obtain new access tokens.
RefreshToken string `json:"refresh_token,omitempty"`
// TokenType is typically "Bearer".
TokenType string `json:"token_type"`
// Expiry is when the access token expires.
Expiry time.Time `json:"expiry,omitempty"`
}
OAuthCredentials stores OAuth tokens for a specific user account.
func (*OAuthCredentials) IsExpired ¶
func (c *OAuthCredentials) IsExpired() bool
IsExpired returns true if the OAuth access token has expired.
type OAuthProviderConfig ¶
type OAuthProviderConfig struct {
// ClientID is the OAuth client ID from the developer console.
ClientID string `json:"client_id"`
// ClientSecret is the OAuth client secret from the developer console.
ClientSecret string `json:"client_secret"`
// Scopes are the OAuth scopes to request.
Scopes []string `json:"scopes"`
// AuthURL is the authorization endpoint (optional override for custom OAuth servers).
AuthURL string `json:"auth_url,omitempty"`
// TokenURL is the token exchange endpoint (optional override for custom OAuth servers).
TokenURL string `json:"token_url,omitempty"`
// RedirectURI is the callback URI (default: http://localhost:PORT/callback).
RedirectURI string `json:"redirect_uri,omitempty"`
}
OAuthProviderConfig stores OAuth application credentials. These are the client credentials from the OAuth provider's developer console.
type OAuthToken ¶
type OAuthToken struct {
// AccessToken is the bearer token for API access.
AccessToken string `json:"access_token"`
// RefreshToken is used to obtain new access tokens.
RefreshToken string `json:"refresh_token,omitempty"`
// TokenType is typically "Bearer".
TokenType string `json:"token_type"`
// Expiry is when the access token expires.
Expiry time.Time `json:"expiry,omitempty"`
}
OAuthToken represents stored OAuth credentials.
func (*OAuthToken) IsExpired ¶
func (t *OAuthToken) IsExpired() bool
IsExpired returns true if the token has expired.
type PATCredentials ¶
type PATCredentials struct {
// Token is the actual personal access token.
Token string `json:"token"`
}
PATCredentials stores a Personal Access Token.
type PipelineConfig ¶
type PipelineConfig struct {
// Processors is the ordered list of processor names to run.
Processors []string
// ProcessorConfigs holds per-processor configuration as generic maps.
// Key is processor name, value is processor-specific config.
ProcessorConfigs map[string]map[string]any
}
PipelineConfig holds post-processor pipeline configuration. Uses generic map-based config for extensibility - new processors can be added without modifying this struct.
func DefaultPipelineConfig ¶
func DefaultPipelineConfig() PipelineConfig
DefaultPipelineConfig returns the default pipeline configuration. Works out-of-the-box with chunker using sensible defaults.
func (*PipelineConfig) GetProcessorConfig ¶
func (c *PipelineConfig) GetProcessorConfig(name string) map[string]any
GetProcessorConfig returns config for a specific processor, or nil if not set.
type ProviderType ¶
type ProviderType string
ProviderType identifies the provider (google, github, slack, etc.).
const ( // ProviderLocal is for local filesystem sources. ProviderLocal ProviderType = "local" // ProviderGoogle is for Google services (Drive, Gmail, Calendar). ProviderGoogle ProviderType = "google" // ProviderGitHub is for GitHub repositories and issues. ProviderGitHub ProviderType = "github" // ProviderSlack is for Slack workspaces. ProviderSlack ProviderType = "slack" // ProviderNotion is for Notion workspaces. ProviderNotion ProviderType = "notion" // ProviderMicrosoft is for Microsoft 365 services (Outlook, OneDrive, Calendar). ProviderMicrosoft ProviderType = "microsoft" // ProviderDropbox is for Dropbox file storage. ProviderDropbox ProviderType = "dropbox" )
type RawDocument ¶
type RawDocument struct {
// SourceID links to the Source that produced this document.
SourceID string
// URI is the original location (file path, URL, etc).
URI string
// MIMEType is the content type (e.g., "application/pdf").
MIMEType string
// Content is the raw bytes.
Content []byte
// ParentURI links to a parent for hierarchical sources.
ParentURI *string
// Metadata contains connector-specific key-value pairs.
Metadata map[string]any
}
RawDocument represents opaque bytes fetched by a connector. It is the connector's output before normalisation.
type RawDocumentChange ¶
type RawDocumentChange struct {
// Type is the kind of change.
Type ChangeType
// Document is the affected document.
Document RawDocument
}
RawDocumentChange represents a change event from a connector. Used for incremental sync and watch operations.
type ScheduledTask ¶
type ScheduledTask struct {
// ID is the unique identifier for the task.
ID string
// Name is a human-readable name for the task.
Name string
// Interval defines how often the task should run.
Interval time.Duration
// LastRun is when the task last ran.
LastRun time.Time
// NextRun is when the task should run next.
NextRun time.Time
// LastError contains the last error message, if any.
LastError string
// LastSuccess is when the task last completed successfully.
LastSuccess time.Time
// Enabled indicates whether the task is active.
Enabled bool
}
ScheduledTask represents a recurring background task.
type SchedulerConfig ¶
type SchedulerConfig struct {
// Enabled is the master switch for the scheduler.
Enabled bool
// TaskConfigs holds per-task configuration.
TaskConfigs map[string]TaskConfig
}
SchedulerConfig holds scheduler configuration.
func DefaultSchedulerConfig ¶
func DefaultSchedulerConfig() SchedulerConfig
DefaultSchedulerConfig returns sensible defaults for the scheduler.
func (*SchedulerConfig) GetTaskConfig ¶
func (c *SchedulerConfig) GetTaskConfig(taskID string) TaskConfig
GetTaskConfig returns the configuration for a specific task. Returns a zero TaskConfig if the task is not configured.
type SearchMode ¶
type SearchMode string
SearchMode defines how search operations combine different retrieval methods.
const ( // SearchModeTextOnly uses only keyword/full-text search. SearchModeTextOnly SearchMode = "text_only" // SearchModeHybrid combines text and semantic (vector) search. SearchModeHybrid SearchMode = "hybrid" // SearchModeLLMAssisted uses text search with LLM query expansion. SearchModeLLMAssisted SearchMode = "llm_assisted" // SearchModeFull combines text, semantic, and LLM query expansion. SearchModeFull SearchMode = "full" )
Available search modes.
func AllSearchModes ¶
func AllSearchModes() []SearchMode
AllSearchModes returns all available search modes.
func (SearchMode) Description ¶
func (m SearchMode) Description() string
Description returns a human-readable description of the mode.
func (SearchMode) IsValid ¶
func (m SearchMode) IsValid() bool
IsValid returns true if the search mode is recognised.
func (SearchMode) RequiresEmbedding ¶
func (m SearchMode) RequiresEmbedding() bool
RequiresEmbedding returns true if this mode needs an embedding provider.
func (SearchMode) RequiresLLM ¶
func (m SearchMode) RequiresLLM() bool
RequiresLLM returns true if this mode needs an LLM provider.
func (SearchMode) String ¶
func (m SearchMode) String() string
String returns the string representation.
type SearchOptions ¶
type SearchOptions struct {
// Limit is the maximum number of results.
Limit int
// Offset is the number of results to skip.
Offset int
// SourceIDs filters to specific sources.
SourceIDs []string
// Semantic enables vector similarity search.
Semantic bool
// Hybrid enables combined keyword + semantic search.
Hybrid bool
}
SearchOptions configures a search query.
type SearchResult ¶
type SearchResult struct {
// Document is the matched document.
Document Document
// Chunk is the specific chunk that matched.
Chunk Chunk
// Score is the relevance score.
Score float64
// Highlights contains snippets with matched terms.
Highlights []string
// SourceName is the display name of the source (includes account identifier).
// Example: "Gmail - user@gmail.com" or "GitHub - octocat"
SourceName string
}
SearchResult represents a single search hit.
type SearchSettings ¶
type SearchSettings struct {
// Mode is the search retrieval mode.
Mode SearchMode
}
SearchSettings holds search behaviour configuration.
type Source ¶
type Source struct {
// ID is the unique identifier for the source.
ID string
// Type identifies the connector type (e.g., "filesystem", "gmail").
Type string
// Name is the human-readable name for this source.
Name string
// Config contains connector-specific configuration.
Config map[string]string
// AuthorizationID references the Authorization used by this source.
// Deprecated: Use AuthProviderID and CredentialsID instead.
// Kept for backward compatibility during migration.
AuthorizationID string
// AuthProviderID references the AuthProvider (OAuth app or PAT provider config).
// Empty string for no-auth connectors (filesystem).
AuthProviderID string
// CredentialsID references this source's Credentials (tokens + account info).
// Empty string for no-auth connectors.
CredentialsID string
// CreatedAt is when the source was created.
CreatedAt time.Time
// UpdatedAt is when the source was last updated.
UpdatedAt time.Time
}
Source represents a configured data source. Each source produces documents via a connector and belongs to a specific user account.
func (*Source) DisplayName ¶
DisplayName returns the source name with account identifier if provided. Used for display in CLI/TUI where the account context helps identify the source. If the account identifier is already present in the name, it is not appended again.
type SyncState ¶
type SyncState struct {
// SourceID links to the Source being synced.
SourceID string
// Cursor is an opaque token for incremental sync.
Cursor string
// LastSync is when the last successful sync completed.
LastSync time.Time
}
SyncState tracks the synchronisation progress for a source.
type TaskConfig ¶
type TaskConfig struct {
// Enabled indicates whether this task should run.
Enabled bool
// Interval defines how often the task should run.
Interval time.Duration
}
TaskConfig holds configuration for a single task.
type TaskResult ¶
type TaskResult struct {
// TaskID identifies which task was run.
TaskID string
// StartedAt is when the task started.
StartedAt time.Time
// EndedAt is when the task completed.
EndedAt time.Time
// Success indicates whether the task completed without error.
Success bool
// Error contains the error message if Success is false.
Error string
// ItemsProcessed is a count of items handled (e.g., documents synced).
ItemsProcessed int
}
TaskResult represents the outcome of a task execution.
type VectorIndexSettings ¶
type VectorIndexSettings struct {
// Enabled indicates whether vector indexing is active.
Enabled bool
// Dimensions is the embedding vector size.
Dimensions int
// Precision is the storage precision for vectors.
// Default is float16 (best balance of size vs quality).
Precision VectorPrecision
}
VectorIndexSettings holds vector index configuration.
type VectorPrecision ¶
type VectorPrecision string
VectorPrecision defines the storage precision for vector embeddings.
const ( // VectorPrecisionFloat32 stores vectors at full 32-bit precision (no compression). VectorPrecisionFloat32 VectorPrecision = "float32" // VectorPrecisionFloat16 stores vectors at 16-bit half precision (50% storage savings). VectorPrecisionFloat16 VectorPrecision = "float16" // VectorPrecisionInt8 stores vectors at 8-bit integer precision (75% storage savings). VectorPrecisionInt8 VectorPrecision = "int8" )
Available vector precision options.
func AllVectorPrecisions ¶
func AllVectorPrecisions() []VectorPrecision
AllVectorPrecisions returns all available vector precision options.
func (VectorPrecision) Description ¶
func (p VectorPrecision) Description() string
Description returns a human-readable description of the precision.
func (VectorPrecision) IsValid ¶
func (p VectorPrecision) IsValid() bool
IsValid returns true if the precision is recognised.
func (VectorPrecision) String ¶
func (p VectorPrecision) String() string
String returns the string representation.
type WebURLResolver ¶
WebURLResolver converts a document URI to a web-openable URL. Returns empty string if the URI cannot be resolved. Parameters:
- uri: The document URI (e.g., "gmail://messages/abc123")
- metadata: Document metadata (may contain pre-stored web links)