Add schema for agent personas, parts, traits, and character arcs
Some checks failed
CI / build-and-test (push) Failing after -31m18s
Some checks failed
CI / build-and-test (push) Failing after -31m18s
- Created tables for agent_personas, agent_parts, agent_traits, and character_arcs. - Established relationships between personas, parts, skills, guardrails, and traits. - Added arc stages and their corresponding parts, along with a persona_arc table to track current stages. - Implemented cascading delete rules for referential integrity.
This commit is contained in:
178
internal/types/agent_persona.go
Normal file
178
internal/types/agent_persona.go
Normal file
@@ -0,0 +1,178 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// Core entities
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
type Persona struct {
|
||||
ID int64 `json:"id"`
|
||||
GUID uuid.UUID `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Summary string `json:"summary"`
|
||||
Detail string `json:"detail,omitempty"`
|
||||
CompiledSummary string `json:"compiled_summary,omitempty"`
|
||||
CompiledDetail string `json:"compiled_detail,omitempty"`
|
||||
CompiledAt *time.Time `json:"compiled_at,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Part struct {
|
||||
ID int64 `json:"id"`
|
||||
GUID uuid.UUID `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
PartType string `json:"part_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Summary string `json:"summary"`
|
||||
Content string `json:"content,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Trait struct {
|
||||
ID int64 `json:"id"`
|
||||
GUID uuid.UUID `json:"guid"`
|
||||
Name string `json:"name"`
|
||||
TraitType string `json:"trait_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Instruction string `json:"instruction,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CharacterArc struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
Stages []ArcStage `json:"stages,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type ArcStage struct {
|
||||
ID int64 `json:"id"`
|
||||
ArcID int64 `json:"arc_id"`
|
||||
Name string `json:"name"`
|
||||
StageOrder int `json:"stage_order"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Condition string `json:"condition,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// Assembled persona (get_agent_persona result)
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
// PersonaFull is returned by get_agent_persona. Parts, skills, guardrails, and
|
||||
// traits are assembled according to priority order:
|
||||
//
|
||||
// 1. runtime overrides (highest)
|
||||
// 2. active arc-stage parts
|
||||
// 3. persona-linked parts (base)
|
||||
type PersonaFull struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Body string `json:"body"` // summary or detail, depending on mode
|
||||
CompiledSummary string `json:"compiled_summary,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
Parts []AssembledPart `json:"parts"`
|
||||
Skills []PersonaSkillEntry `json:"skills"`
|
||||
Guardrails []PersonaGuardrailEntry `json:"guardrails"`
|
||||
Traits []PersonaTraitEntry `json:"traits"`
|
||||
Arc *PersonaArcState `json:"arc,omitempty"`
|
||||
Detail bool `json:"detail"` // whether full detail was requested
|
||||
}
|
||||
|
||||
type AssembledPart struct {
|
||||
Name string `json:"name"`
|
||||
PartType string `json:"part_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Body string `json:"body"` // summary or content, depending on detail mode
|
||||
Tags []string `json:"tags"`
|
||||
Source string `json:"source"` // "persona" | "arc_stage" | "override"
|
||||
}
|
||||
|
||||
type PersonaSkillEntry struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Content string `json:"content,omitempty"` // only when detail=true
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type PersonaGuardrailEntry struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Content string `json:"content,omitempty"` // only when detail=true
|
||||
Severity string `json:"severity,omitempty"` // only when detail=true
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type PersonaTraitEntry struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
TraitType string `json:"trait_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Instruction string `json:"instruction,omitempty"` // only when detail=true
|
||||
Tags []string `json:"tags"`
|
||||
}
|
||||
|
||||
type PersonaArcState struct {
|
||||
ArcName string `json:"arc_name"`
|
||||
StageName string `json:"stage_name"`
|
||||
StageOrder int `json:"stage_order"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Condition string `json:"condition,omitempty"`
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// Manifest (get_persona_manifest result)
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
type PersonaManifest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Parts []ManifestPart `json:"parts"`
|
||||
Traits []ManifestTrait `json:"traits"`
|
||||
Skills []ManifestSkill `json:"skills"`
|
||||
Guardrails []ManifestGuardrail `json:"guardrails"`
|
||||
Arc *PersonaArcState `json:"arc,omitempty"`
|
||||
OnDemandTools []string `json:"on_demand_tools"`
|
||||
}
|
||||
|
||||
type ManifestPart struct {
|
||||
Name string `json:"name"`
|
||||
PartType string `json:"part_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type ManifestTrait struct {
|
||||
Name string `json:"name"`
|
||||
TraitType string `json:"trait_type"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type ManifestSkill struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type ManifestGuardrail struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Severity string `json:"severity"`
|
||||
}
|
||||
Reference in New Issue
Block a user