dto

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: 2 Imported by: 0

Documentation

Overview

Package dto holds the wire types for the HTTP API. They are kept separate from internal/models so the public contract can evolve without forcing domain refactors (and vice versa).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrainResponse

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

func ToBrainResponse

func ToBrainResponse(b *models.Brain) BrainResponse

func ToBrainResponses

func ToBrainResponses(brains []models.Brain) []BrainResponse

type ComposeRequest

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

ComposeRequest is the body of POST /api/v1/compose. Mirrors models.ComposeRequest minus workspace_id — the workspace comes from auth, never from the body. Project/session in the body act as a fallback when the corresponding header is absent.

func (*ComposeRequest) ToDomain

func (r *ComposeRequest) ToDomain(ws models.WorkspaceID, projectSlug models.Slug, sessionID string) models.ComposeRequest

ToDomain produces a models.ComposeRequest with workspace/project/session filled from the resolved values the handler computed.

type ListBrainsResponse

type ListBrainsResponse struct {
	Brains []BrainResponse `json:"brains"`
}

type ListPersonasResponse

type ListPersonasResponse struct {
	Personas []PersonaResponse `json:"personas"`
}

type ListRulesResponse

type ListRulesResponse struct {
	Rules []RuleResponse `json:"rules"`
}

type ListSoulsResponse

type ListSoulsResponse struct {
	Souls []SoulResponse `json:"souls"`
}

ListSoulsResponse envelopes a list response. Resource-keyed rather than a generic "items" so the payload is self-describing.

type ListVersionsResponse

type ListVersionsResponse struct {
	Versions []models.VersionSummary `json:"versions"`
}

ListVersionsResponse envelopes a version list.

type PersonaResponse

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

func ToPersonaResponse

func ToPersonaResponse(p *models.Persona) PersonaResponse

func ToPersonaResponses

func ToPersonaResponses(personas []models.Persona) []PersonaResponse

type RuleResponse

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

func ToRuleResponse

func ToRuleResponse(r *models.Rule) RuleResponse

func ToRuleResponses

func ToRuleResponses(rules []models.Rule) []RuleResponse

type SetStateRequest

type SetStateRequest struct {
	SoulSlug      *string  `json:"soul_slug,omitempty"`
	PersonaSlug   *string  `json:"persona_slug,omitempty"`
	RulesToAdd    []string `json:"rules_to_add,omitempty"`
	RulesToRemove []string `json:"rules_to_remove,omitempty"`
}

SetStateRequest is the body of PUT /api/v1/state. The target scope is derived from headers (session > project > workspace), not from the body. Server-owned fields (workspace_id, scope_type, reference_id, timestamps) never appear here.

Slug pointer semantics match LayerOverride: nil = absent, &"" = clear, &"foo" = set.

func (*SetStateRequest) ToLayerOverride

func (r *SetStateRequest) ToLayerOverride() *models.LayerOverride

ToLayerOverride builds a partial LayerOverride suitable for StateApp.SetState. Scope fields are filled by the handler.

type SoulResponse

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

SoulResponse is the wire shape of a Soul. Mirrors the domain shape today; kept separate so it can diverge without breaking the domain.

func ToSoulResponse

func ToSoulResponse(s *models.Soul) SoulResponse

func ToSoulResponses

func ToSoulResponses(souls []models.Soul) []SoulResponse

type StateResponse

type StateResponse struct {
	Effective *models.EffectiveState `json:"effective"`
	Layers    []models.LayerOverride `json:"layers"`
}

StateResponse is returned by GET/PUT /api/v1/state. The layers slice includes every applicable scope in precedence order (workspace first).

type StatusResponse

type StatusResponse struct {
	WorkspaceID models.WorkspaceID     `json:"workspace_id"`
	Effective   *models.EffectiveState `json:"effective"`
	Layers      []models.LayerOverride `json:"layers"`
}

StatusResponse is a workspace-level summary: effective state and the full layer chain. Unlike GET /state (which is scope-aware), this is always workspace scope — a dashboard overview.

type UpsertBrainRequest

type UpsertBrainRequest struct {
	SoulSlug    models.Slug        `json:"soul_slug"`
	PersonaSlug models.Slug        `json:"persona_slug"`
	RuleSlugs   []models.Slug      `json:"rule_slugs"`
	ModelPrefs  *models.ModelPrefs `json:"model_prefs,omitempty"`
}

UpsertBrainRequest is the body of PUT /api/v1/brains/{slug}.

type UpsertPersonaRequest

type UpsertPersonaRequest struct {
	Content      string        `json:"content"`
	BundledRules []models.Slug `json:"bundled_rules"`
}

UpsertPersonaRequest is the body of PUT /api/v1/personas/{slug}.

type UpsertRuleRequest

type UpsertRuleRequest struct {
	Entries []models.RuleEntry `json:"entries"`
}

UpsertRuleRequest is the body of PUT /api/v1/rules/{slug}.

type UpsertSoulRequest

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

UpsertSoulRequest is the body of PUT /api/v1/souls/{slug}. The slug is taken from the path, the workspace from auth — neither appears in the body.

Jump to

Keyboard shortcuts

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