models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID        APIKeyID   `json:"id"`
	UserID    UserID     `json:"user_id"`
	Name      string     `json:"name"`
	KeyPrefix string     `json:"key_prefix"`
	KeyHash   string     `json:"key_hash"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	RevokedAt *time.Time `json:"revoked_at,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

type APIKeyID

type APIKeyID string

type APIKeySummary

type APIKeySummary struct {
	ID        APIKeyID   `json:"id"`
	Name      string     `json:"name"`
	KeyPrefix string     `json:"key_prefix"`
	UserID    UserID     `json:"user_id"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	RevokedAt *time.Time `json:"revoked_at,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

type Brain

type Brain struct {
	ID          EntityID    `json:"id"`
	WorkspaceID WorkspaceID `json:"workspace_id"`
	Slug        Slug        `json:"slug"`
	SoulSlug    Slug        `json:"soul_slug"`
	PersonaSlug Slug        `json:"persona_slug"`
	RuleSlugs   []Slug      `json:"rule_slugs"`
	ModelPrefs  *ModelPrefs `json:"model_prefs,omitempty"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

type ComposeRequest

type ComposeRequest struct {
	WorkspaceID WorkspaceID   `json:"workspace_id"`
	Source      ComposeSource `json:"source"`
	ModelPrefs  *ModelPrefs   `json:"model_prefs,omitempty"`
	ProjectSlug Slug          `json:"project_slug,omitempty"`
	SessionID   string        `json:"session_id,omitempty"`
	Task        string        `json:"task,omitempty"`
}

type ComposeResponse

type ComposeResponse struct {
	Prompt        string        `json:"prompt"`
	Soul          Slug          `json:"soul"`
	Persona       Slug          `json:"persona"`
	Brain         Slug          `json:"brain"`
	Rules         []Slug        `json:"rules"`
	ModelPrefs    *ModelPrefs   `json:"model_prefs,omitempty"`
	TokenEstimate TokenEstimate `json:"token_estimate"`
	Warnings      []string      `json:"warnings"`
}

type ComposeSource

type ComposeSource struct {
	Kind        ComposeSourceKind `json:"kind"`
	BrainSlug   Slug              `json:"brain_slug,omitempty"`
	PersonaSlug Slug              `json:"persona_slug,omitempty"`
}

ComposeSource is a discriminated union — brain, persona, and state resolution are mutually exclusive. The Kind field selects the variant.

type ComposeSourceKind

type ComposeSourceKind string
const (
	ComposeFromBrain   ComposeSourceKind = "brain"
	ComposeFromPersona ComposeSourceKind = "persona"
	ComposeFromState   ComposeSourceKind = "state"
)

type ContentType

type ContentType string
const (
	ContentTypeSoul    ContentType = "soul"
	ContentTypePersona ContentType = "persona"
	ContentTypeRule    ContentType = "rule"
)

type ContentVersion

type ContentVersion struct {
	ID          EntityID        `json:"id"`
	ContentType ContentType     `json:"content_type"`
	WorkspaceID WorkspaceID     `json:"workspace_id"`
	Slug        Slug            `json:"slug"`
	Version     int             `json:"version"`
	Content     string          `json:"content,omitempty"`
	Metadata    json.RawMessage `json:"metadata,omitempty"`
	CreatedAt   time.Time       `json:"created_at"`
}

ContentVersion is a historical snapshot of a content entity. Stores hold old versions only — the current version lives in the live entity table. For rules, Content is empty and Metadata holds the entries as JSON.

type CreateAPIKeyResult

type CreateAPIKeyResult struct {
	ID        APIKeyID   `json:"id"`
	Name      string     `json:"name"`
	Key       string     `json:"key"`
	KeyPrefix string     `json:"key_prefix"`
	UserID    UserID     `json:"user_id"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

CreateAPIKeyResult is returned by CreateAPIKey — Key is the plaintext token shown to the user once and never persisted in recoverable form.

type EffectiveState

type EffectiveState struct {
	Soul    string   `json:"soul"`
	Persona string   `json:"persona"`
	Rules   []string `json:"rules"`
}

EffectiveState is the resolved state after merging all applicable layers.

type EntityID

type EntityID string

type LayerOverride

type LayerOverride struct {
	WorkspaceID   WorkspaceID `json:"workspace_id"`
	ScopeType     ScopeType   `json:"scope_type"`
	ReferenceID   string      `json:"reference_id"`
	SoulSlug      *string     `json:"soul_slug,omitempty"`
	PersonaSlug   *string     `json:"persona_slug,omitempty"`
	RulesToAdd    []string    `json:"rules_to_add"`
	RulesToRemove []string    `json:"rules_to_remove"`
	CreatedAt     time.Time   `json:"created_at"`
	UpdatedAt     time.Time   `json:"updated_at"`
}

LayerOverride is a single row in the precedence chain, keyed by (WorkspaceID, ScopeType, ReferenceID). Three-way semantics for single-valued fields via *string:

  • nil = absent (no opinion, NULL in SQL)
  • &"" = inherit (clear override, empty string in SQL)
  • &"cto" = set (value in SQL)

type ModelPrefs

type ModelPrefs struct {
	Model          string         `json:"model,omitempty"`
	Temperature    *float64       `json:"temperature,omitempty"`
	MaxTokens      *int           `json:"max_tokens,omitempty"`
	PlatformExtras map[string]any `json:"platform_extras,omitempty"`
}

ModelPrefs controls how a brain should be instantiated. All fields are optional — omitted fields inherit runtime defaults. Only platform-agnostic fields are first-class. Provider-specific params live in PlatformExtras.

ModelPrefs is attached to Brain as the default, but ComposeRequest can supply a per-call override and ComposeResponse echoes the resolved value.

func (*ModelPrefs) IsZero

func (m *ModelPrefs) IsZero() bool

IsZero returns true when no preferences are set.

type Persona

type Persona struct {
	ID           EntityID    `json:"id"`
	WorkspaceID  WorkspaceID `json:"workspace_id"`
	Slug         Slug        `json:"slug"`
	Content      string      `json:"content"`
	BundledRules []Slug      `json:"bundled_rules"`
	CreatedAt    time.Time   `json:"created_at"`
	UpdatedAt    time.Time   `json:"updated_at"`
}

type Project

type Project struct {
	ID             EntityID    `json:"id"`
	WorkspaceID    WorkspaceID `json:"workspace_id"`
	Slug           Slug        `json:"slug"`
	FilesystemPath string      `json:"filesystem_path,omitempty"`
	CreatedAt      time.Time   `json:"created_at"`
}

type Rule

type Rule struct {
	ID          EntityID    `json:"id"`
	WorkspaceID WorkspaceID `json:"workspace_id"`
	Slug        Slug        `json:"slug"`
	Entries     []RuleEntry `json:"entries"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

type RuleEntry

type RuleEntry struct {
	SortKey int    `json:"sort_key"`
	Content string `json:"content"`
}

type ScopeType

type ScopeType string
const (
	ScopeWorkspace ScopeType = "workspace"
	ScopeProject   ScopeType = "project"
	ScopeSession   ScopeType = "session"
)

type Slug

type Slug string

func MustSlug

func MustSlug(raw string) Slug

MustSlug panics on invalid input. Use only in tests and hardcoded constants.

func ParseSlug

func ParseSlug(raw string) (Slug, error)

ParseSlug validates and returns a Slug. Returns an error if the input does not match the slug pattern (lowercase letter start, then lowercase letters, digits, and hyphens).

type Soul

type Soul struct {
	ID          EntityID    `json:"id"`
	WorkspaceID WorkspaceID `json:"workspace_id"`
	Slug        Slug        `json:"slug"`
	Content     string      `json:"content"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

type TokenEstimate

type TokenEstimate struct {
	Soul    int `json:"soul"`
	Persona int `json:"persona"`
	Rules   int `json:"rules"`
	Task    int `json:"task"`
	Total   int `json:"total"`
}

type UserID

type UserID string

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError is returned when input fails validation.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type VersionSummary

type VersionSummary struct {
	Version   int       `json:"version"`
	CreatedAt time.Time `json:"created_at"`
}

type Workspace

type Workspace struct {
	ID        WorkspaceID `json:"id"`
	Name      string      `json:"name"`
	CreatedAt time.Time   `json:"created_at"`
	UpdatedAt time.Time   `json:"updated_at"`
}

type WorkspaceID

type WorkspaceID string

Jump to

Keyboard shortcuts

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