models

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TurnStateRunning     TurnState = "running"
	TurnStateCompleted   TurnState = "completed"
	TurnStateFailed      TurnState = "failed"
	TurnStateCancelled   TurnState = "cancelled"
	TurnStateInterrupted TurnState = "interrupted"

	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleTool      MessageRole = "tool"

	AgentRunStateRunning     AgentRunState = "running"
	AgentRunStateCompleted   AgentRunState = "completed"
	AgentRunStateFailed      AgentRunState = "failed"
	AgentRunStateCancelled   AgentRunState = "cancelled"
	AgentRunStateInterrupted AgentRunState = "interrupted"

	AgentRunDefinitionStored AgentRunDefinition = "stored"
	AgentRunDefinitionAdHoc  AgentRunDefinition = "ad-hoc"

	NoticeDeliveryQueue NoticeDelivery = "queue"
	NoticeDeliveryWake  NoticeDelivery = "wake"

	NoticeStatePending   NoticeState = "pending"
	NoticeStateDelivered NoticeState = "delivered"

	JobStateRunning     JobState = "running"
	JobStateExited      JobState = "exited"
	JobStateSignalled   JobState = "signalled"
	JobStateFailed      JobState = "failed"
	JobStateInterrupted JobState = "interrupted"

	JobOutputStreamStdout JobOutputStream = "stdout"
	JobOutputStreamStderr JobOutputStream = "stderr"

	JobSignalStop JobSignal = "stop"
	JobSignalKill JobSignal = "kill"

	ModelRunStageTurn       ModelRunStage = "turn"
	ModelRunStageChild      ModelRunStage = "child"
	ModelRunStageCompaction ModelRunStage = "compaction"

	ModelRunStateRunning     ModelRunState = "running"
	ModelRunStateCompleted   ModelRunState = "completed"
	ModelRunStateFailed      ModelRunState = "failed"
	ModelRunStateCancelled   ModelRunState = "cancelled"
	ModelRunStateInterrupted ModelRunState = "interrupted"

	ModelCallStateRunning     ModelCallState = "running"
	ModelCallStateCompleted   ModelCallState = "completed"
	ModelCallStateFailed      ModelCallState = "failed"
	ModelCallStateCancelled   ModelCallState = "cancelled"
	ModelCallStateInterrupted ModelCallState = "interrupted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentRun added in v0.4.0

type AgentRun struct {
	ID                    uuid.UUID
	SessionID             uuid.UUID
	ParentTurnID          uuid.UUID
	WorkerGenerationID    string
	ParentAgentRunID      *uuid.UUID
	ParentToolCallID      string
	RequestID             uuid.UUID
	Name                  string
	Definition            AgentRunDefinition
	Depth                 int64
	Workspace             string
	ModelReference        string
	ModelID               string
	Task                  string
	Instructions          string
	AllowedToolsJSON      string
	SystemPrompt          string
	EventCount            int64
	CancelRequested       bool
	State                 AgentRunState
	ResponseText          string
	ResponseThinking      string
	ResponseMessagesJSON  string
	FinishReason          string
	PromptTokenCount      int64
	CompletionTokenCount  int64
	FailureClassification string
	FailureDetail         string
	StartedAt             time.Time
	EndedAt               *time.Time
}

AgentRun is one durable child-agent execution launched from a session turn.

func (AgentRun) TableName added in v0.4.0

func (AgentRun) TableName() string

TableName pins the schema-owned agent_runs table name.

type AgentRunCompaction added in v0.11.0

type AgentRunCompaction struct {
	ID                     uuid.UUID
	SessionID              uuid.UUID
	AgentRunID             uuid.UUID
	FromMessageID          uuid.UUID
	ToMessageID            uuid.UUID
	FromSequence           int64
	ToSequence             int64
	DirectFromSequence     int64
	DirectToSequence       int64
	Summary                string
	SourceMessageCount     int64
	InputTokenCount        int64
	SummaryTokenCount      int64
	ModelID                string
	PromptHash             string
	CreatedAt              time.Time
	SupersedesCompactionID *uuid.UUID
}

AgentRunCompaction is one immutable summary covering a completed prefix of one child agent's transcript.

DirectFromSequence and DirectToSequence record only the messages this row covered itself. FromSequence and ToSequence span the whole superseded lineage, so a later compaction extends the chain without rewriting the direct membership an earlier row already recorded.

func (AgentRunCompaction) TableName added in v0.11.0

func (AgentRunCompaction) TableName() string

TableName pins the schema-owned agent_run_compactions table name.

type AgentRunDefinition added in v0.4.0

type AgentRunDefinition string

AgentRunDefinition records whether a child is stored or inline.

type AgentRunEvent added in v0.4.0

type AgentRunEvent struct {
	ID          uuid.UUID
	SessionID   uuid.UUID
	AgentRunID  uuid.UUID
	Sequence    int64
	EventType   string
	PayloadJSON string
	CreatedAt   time.Time
}

AgentRunEvent is one ordered, replayable child-agent event.

func (AgentRunEvent) TableName added in v0.4.0

func (AgentRunEvent) TableName() string

TableName pins the schema-owned agent_run_events table name.

type AgentRunMessage added in v0.11.0

type AgentRunMessage struct {
	ID            uuid.UUID
	SessionID     uuid.UUID
	AgentRunID    uuid.UUID
	Sequence      int64
	Role          MessageRole
	Content       string
	ModelID       string
	Thinking      string
	ToolCallsJSON string
	ToolCallID    string
	CompactionID  *uuid.UUID
	IsError       bool
	Incomplete    bool
	CreatedAt     time.Time
}

AgentRunMessage is one durable prompt-visible record in a child agent's own transcript.

A child agent runs a separate model context, so its conversation is stored apart from the session transcript. A parent-session compaction can then never absorb child messages, and a child compaction can never rewrite the parent's.

func (AgentRunMessage) TableName added in v0.11.0

func (AgentRunMessage) TableName() string

TableName pins the schema-owned agent_run_messages table name.

type AgentRunState added in v0.4.0

type AgentRunState string

AgentRunState is the durable lifecycle state of one child-agent run.

type Compaction

type Compaction struct {
	ID                     uuid.UUID
	SessionID              uuid.UUID
	FromMessageID          uuid.UUID
	ToMessageID            uuid.UUID
	FromSequence           int64
	ToSequence             int64
	Summary                string
	SourceMessageCount     int64
	InputTokenCount        int64
	SummaryTokenCount      int64
	ModelID                string
	PromptHash             string
	CreatedAt              time.Time
	SupersedesCompactionID *uuid.UUID
}

Compaction is one immutable summary covering a completed message prefix.

func (Compaction) TableName

func (Compaction) TableName() string

TableName pins the schema-owned compactions table name.

type ContextSnapshot

type ContextSnapshot struct {
	Hash            string `gorm:"primaryKey"`
	ManifestJSON    string
	ResolvedContent string
	CreatedAt       time.Time
}

ContextSnapshot stores one immutable resolved harness context.

func (ContextSnapshot) TableName

func (ContextSnapshot) TableName() string

TableName pins the schema-owned context_snapshots table name.

type Event

type Event struct {
	ID                 uuid.UUID
	SessionID          uuid.UUID
	TurnID             uuid.UUID
	WorkerGenerationID string
	Sequence           int64
	RequestID          uuid.UUID
	EventType          string
	PayloadJSON        string
	ParentToolCallID   string
	CreatedAt          time.Time
}

Event is one ordered internal or protocol event in a session transcript.

func (Event) TableName

func (Event) TableName() string

TableName pins the schema-owned events table name.

type Job added in v0.4.0

type Job struct {
	ID                 uuid.UUID
	SessionID          uuid.UUID
	TurnID             uuid.UUID
	WorkerGenerationID string
	ToolCallID         string
	PID                int64 `gorm:"column:pid"`
	Purpose            string
	Command            string
	Directory          string
	State              JobState
	ExitCode           int64
	FailureDetail      string
	StartedAt          time.Time
	EndedAt            *time.Time
}

Job is one durable supervised process launched from a session turn.

func (Job) TableName added in v0.4.0

func (Job) TableName() string

TableName pins the schema-owned jobs table name.

type JobOutputLine added in v0.4.0

type JobOutputLine struct {
	ID        uuid.UUID
	SessionID uuid.UUID
	JobID     uuid.UUID
	Sequence  int64
	Stream    JobOutputStream
	Content   string
	CreatedAt time.Time
}

JobOutputLine is one ordered immutable stdout or stderr line.

func (JobOutputLine) TableName added in v0.4.0

func (JobOutputLine) TableName() string

TableName pins the schema-owned job_output_lines table name.

type JobOutputStream added in v0.4.0

type JobOutputStream string

JobOutputStream identifies one process output stream.

type JobSignal added in v0.4.0

type JobSignal string

JobSignal identifies a requested process signal.

type JobSignalRequest added in v0.4.0

type JobSignalRequest struct {
	ID             uuid.UUID
	SessionID      uuid.UUID
	JobID          uuid.UUID
	Signal         JobSignal
	Accepted       bool
	StateAtRequest JobState
	RequestedAt    time.Time
}

JobSignalRequest records every accepted or no-op request to signal a job.

func (JobSignalRequest) TableName added in v0.4.0

func (JobSignalRequest) TableName() string

TableName pins the schema-owned job_signal_requests table name.

type JobState added in v0.4.0

type JobState string

JobState is the durable lifecycle state of one supervised process.

type Message

type Message struct {
	ID            uuid.UUID
	SessionID     uuid.UUID
	TurnID        uuid.UUID
	Sequence      int64
	Workspace     string
	Role          MessageRole
	Content       string
	ModelID       string
	Thinking      string
	ToolCallsJSON string
	ToolCallID    string
	CompactionID  *uuid.UUID
	IsError       bool
	Incomplete    bool
	CreatedAt     time.Time
}

Message is one durable user, assistant, or tool transcript record.

func (Message) TableName

func (Message) TableName() string

TableName pins the schema-owned messages table name.

type MessageRole

type MessageRole string

MessageRole identifies a transcript message source.

type ModelCall added in v0.4.0

type ModelCall struct {
	ID                      uuid.UUID
	SessionID               uuid.UUID
	ModelRunID              uuid.UUID
	Round                   int64
	RequestMessagesJSON     string
	RequestToolsJSON        string
	State                   ModelCallState
	ResponseMessageJSON     string
	ResponseUsageJSON       string
	RetryAttemptsJSON       string
	RetryAttemptCount       int64
	PromptTokens            int64
	CompletionTokens        int64
	TotalTokens             int64
	ReasoningTokens         int64
	CacheReadTokens         int64
	CacheWriteTokens        int64
	CacheWriteLongTTLTokens int64
	WastedPromptTokens      int64
	WastedCompletionTokens  int64
	WastedTotalTokens       int64
	TotalAttempts           int64
	ResponseModelID         string
	FinishReason            string
	ResponseCostAmount      string
	RetryCostAmount         string
	BilledCostAmount        string
	CostKnown               bool
	FailureClassification   string
	FailureDetail           string
	StartedAt               time.Time
	CompletedAt             *time.Time
}

ModelCall records one outbound provider round within a logical ModelRun.

func (ModelCall) TableName added in v0.4.0

func (ModelCall) TableName() string

TableName pins the schema-owned model_calls table name.

type ModelCallState added in v0.4.0

type ModelCallState string

ModelCallState is the durable lifecycle state of one provider round.

type ModelRun added in v0.4.0

type ModelRun struct {
	ID                     uuid.UUID
	SessionID              uuid.UUID
	TurnID                 uuid.UUID
	AgentRunID             *uuid.UUID
	Stage                  ModelRunStage
	ModelReference         string
	ConnectionName         string
	RequestedModelID       string
	ResponseModelID        string
	RequestSettingsJSON    string
	State                  ModelRunState
	ResponseText           string
	ResponseThinking       string
	ResponseMessagesJSON   string
	ResponseInjectionsJSON string
	ResponseUsageJSON      string
	ResponseCostAmount     string
	RetryCostAmount        string
	BilledCostAmount       string
	CostKnown              bool
	FinishReason           string
	FailureClassification  string
	FailureDetail          string
	StartedAt              time.Time
	CompletedAt            *time.Time
}

ModelRun records one logical Elelem Run invocation. It keeps the complete non-secret input and output audit record while ModelCall splits its provider rounds into separately replayable rows.

func (ModelRun) TableName added in v0.4.0

func (ModelRun) TableName() string

TableName pins the schema-owned model_runs table name.

type ModelRunStage added in v0.4.0

type ModelRunStage string

ModelRunStage identifies the Peen operation that issued model work.

type ModelRunState added in v0.4.0

type ModelRunState string

ModelRunState is the durable lifecycle state of one logical model run.

type NoticeDelivery added in v0.4.0

type NoticeDelivery string

NoticeDelivery identifies whether an outside notice can wake a session.

type NoticeState added in v0.4.0

type NoticeState string

NoticeState records whether a notice has reached the model context.

type PromptSnapshot

type PromptSnapshot struct {
	Hash            string `gorm:"primaryKey"`
	EffectivePrompt string
	CreatedAt       time.Time
}

PromptSnapshot stores one immutable effective prompt.

func (PromptSnapshot) TableName

func (PromptSnapshot) TableName() string

TableName pins the schema-owned prompt_snapshots table name.

type Session

type Session struct {
	ID                    uuid.UUID
	CreatedAt             time.Time
	UpdatedAt             time.Time
	LastMessageAt         *time.Time
	MessageCount          int64
	CompletedTurnCount    int64
	LastCompletedSequence int64
	ActiveContextHash     string
	RootAgent             string
	ModelID               string
	Workspace             string

	// ExecutionProfile is the operator-defined profile this session's tools
	// run under. It is empty for a session recorded before profiles existed,
	// which the supervisor reads as the deployment default.
	ExecutionProfile string
}

Session is the durable metadata for one Peen conversation.

func (Session) TableName

func (Session) TableName() string

TableName pins the schema-owned sessions table name.

type SessionNotice added in v0.4.0

type SessionNotice struct {
	ID          uuid.UUID
	SessionID   uuid.UUID
	Sequence    int64
	Type        string
	Source      string
	Summary     string
	DataJSON    string
	Delivery    NoticeDelivery
	State       NoticeState
	CreatedAt   time.Time
	DeliveredAt *time.Time
}

SessionNotice is a durable report waiting for or already delivered to a session.

func (SessionNotice) TableName added in v0.4.0

func (SessionNotice) TableName() string

TableName pins the schema-owned session_notices table name.

type SessionProfileDecision added in v0.8.0

type SessionProfileDecision struct {
	ID          uuid.UUID
	SessionID   uuid.UUID
	FromProfile string
	ToProfile   string
	Reason      string
	DecidedAt   time.Time
}

SessionProfileDecision records one deliberate change of a session's execution profile, with the reason the operator gave.

A profile change replaces the session's execution environment, so it is kept as history rather than overwritten: a later reader can tell which profile ran which turns and why it moved.

func (SessionProfileDecision) TableName added in v0.8.0

func (SessionProfileDecision) TableName() string

TableName pins the schema-owned session_profile_decisions table name.

type Turn

type Turn struct {
	ID                    uuid.UUID
	SessionID             uuid.UUID
	RequestID             uuid.UUID
	Workspace             string
	State                 TurnState
	CancelRequested       bool
	StartedAt             time.Time
	CompletedAt           *time.Time
	FailureClassification string
	ContextSnapshotHash   *string
	PromptSnapshotHash    *string

	// WorkerGenerationID names the worker process that ran this turn. It is
	// empty for a turn recorded before worker generations existed.
	WorkerGenerationID string
}

Turn is one request execution within a session.

func (Turn) TableName

func (Turn) TableName() string

TableName pins the schema-owned turns table name.

type TurnState

type TurnState string

TurnState is the durable lifecycle state of one session turn.

type WorkerGeneration added in v0.8.0

type WorkerGeneration struct {
	ID              uuid.UUID
	SessionID       uuid.UUID
	Kind            string
	Profile         string
	ProfileRevision int64
	State           string
	Workspace       string

	// CredentialHash verifies the worker's one-time launch credential. The raw
	// credential is never stored, so a controller that reads its own database
	// cannot recover one, and a restarted controller can still accept the
	// worker it recorded.
	CredentialHash string

	// SocketPath is the private session-bound socket this generation talks to
	// its controller over.
	SocketPath string

	// ProcessID identifies a native worker. It is zero for a Docker worker.
	ProcessID int

	// ContainerID and ImageDigest identify a Docker worker.
	ContainerID string
	ImageDigest string

	// FailureDetail explains a failed generation. It never holds a credential.
	FailureDetail string

	// ExitCode is the process or container exit status once the worker ended.
	ExitCode int

	CreatedAt time.Time
	StartedAt *time.Time
	EndedAt   *time.Time
}

WorkerGeneration is one live worker process for one session and one profile.

It is recorded before the worker launches, so a controller that dies mid-launch still leaves a row an operator can reconcile. Replacing a dead worker starts a new generation rather than reusing the old one, so every turn can name the exact process that ran it.

func (WorkerGeneration) TableName added in v0.8.0

func (WorkerGeneration) TableName() string

TableName pins the schema-owned worker_generations table name.

Jump to

Keyboard shortcuts

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