lifecyclepayload

package
v0.0.0-...-820128f Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package lifecyclepayload builds extension-facing lifecycle event payloads.

Index

Constants

View Source
const (
	APIKey                = "api"
	AssistantEntryIDKey   = "assistant_entry_id"
	AttemptKey            = "attempt"
	BreakdownKey          = "breakdown"
	ContextTokensKey      = "context_tokens"
	ContextWindowKey      = "context_window"
	CreatedAtKey          = "created_at"
	CWDKey                = "cwd"
	EntryIDKey            = "entry_id"
	ErrorKey              = "error"
	InputTokensKey        = "input_tokens"
	MaxTokensKey          = "max_tokens"
	ModelKey              = "model"
	OutputTokensKey       = "output_tokens"
	ParentEntryIDKey      = "parent_entry_id"
	ParentSessionKey      = "parent_session"
	PhaseKey              = "phase"
	PromptKey             = "prompt"
	ProviderKey           = "provider"
	ProviderPayloadKey    = "payload"
	ProviderHeadersKey    = "headers"
	RoleKey               = "role"
	SessionIDKey          = "session_id"
	SummaryKey            = "summary"
	TextKey               = "text"
	TerminationKey        = "termination"
	TokensBeforeKey       = "tokens_before"
	ToolErrorKey          = "error"
	ToolNameKey           = "name"
	UpdatedAtKey          = "updated_at"
	UsageKey              = "usage"
	UserEntryIDKey        = "user_entry_id"
	TimeFormatRFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
)

Lifecycle payload keys define the stable extension-facing lifecycle payload schema.

View Source
const (
	ProviderStatusKey        = "status"
	ProviderCodeKey          = "provider_code"
	ProviderParamKey         = "provider_param"
	ProviderTypeKey          = "provider_type"
	ProviderBodyPreviewKey   = "body_preview"
	ProviderBodyTruncatedKey = "body_truncated"
	ProviderRequestShapeKey  = "request_shape"
)

Provider error payload keys define safe provider diagnostics exposed to extensions.

Variables

This section is empty.

Functions

func CompactionFileOperations

func CompactionFileOperations(operations []compaction.FileOperation) []any

CompactionFileOperations builds compaction file-operation lifecycle payloads.

func CompactionPreparation

func CompactionPreparation(sessionID, cwd string, plan *compaction.Plan) map[string]any

CompactionPreparation builds before-compaction lifecycle payloads.

func CompactionSavedPayload

func CompactionSavedPayload(saved CompactionSaved) map[string]any

CompactionSavedPayload builds after-compaction lifecycle payloads.

func ContextBuild

func ContextBuild(sessionID, cwd string, base *contextwindow.Base, result *contextwindow.BuildResult) map[string]any

ContextBuild builds context-build lifecycle payloads.

func Entry

func Entry(entry *database.EntryEntity) map[string]any

Entry builds message-append lifecycle payloads.

func ModelFacingRoleCounts

func ModelFacingRoleCounts(messages []database.MessageEntity) map[string]int

ModelFacingRoleCounts counts model-facing roles for lifecycle diagnostics.

func Prompt

func Prompt(request *PromptRequest) map[string]any

Prompt builds input and prompt-prepare payloads.

func ProviderErrorDetails

func ProviderErrorDetails(err error) map[string]any

ProviderErrorDetails returns safe structured provider-error diagnostics from err.

func ProviderErrorPayload

func ProviderErrorPayload(providerErr *ProviderError) map[string]any

ProviderErrorPayload builds provider-error lifecycle payloads.

func ProviderRequestPayload

func ProviderRequestPayload(request *ProviderRequest) map[string]any

ProviderRequestPayload builds before-provider-request lifecycle payloads.

func ProviderResponsePayload

func ProviderResponsePayload(response *ProviderResponse) map[string]any

ProviderResponsePayload builds after-provider-response lifecycle payloads.

func Session

func Session(session *database.SessionEntity) map[string]any

Session builds session lifecycle payloads.

func StringSlice

func StringSlice(values []string) []any

StringSlice converts a string slice to an extension-friendly any slice.

func TokenContributors

func TokenContributors(contributors []model.TokenContributor) []any

TokenContributors builds token-contributor lifecycle payloads.

func TokenUsage

func TokenUsage(usage *model.TokenUsage) map[string]any

TokenUsage builds a lifecycle payload for token usage.

func ToolCallPayload

func ToolCallPayload(call *ToolCall) map[string]any

ToolCallPayload builds tool-call lifecycle payloads.

func ToolResultPayload

func ToolResultPayload(event *ToolResult) map[string]any

ToolResultPayload builds tool-result lifecycle payloads.

func TurnEndPayload

func TurnEndPayload(turn *TurnEnd) map[string]any

TurnEndPayload builds turn-end and turn-error lifecycle payloads.

func TurnStart

func TurnStart(sessionID, cwd, prompt, userEntryID string, parentEntryID *string) map[string]any

TurnStart builds turn-start lifecycle payloads.

Types

type CompactionSaved

type CompactionSaved struct {
	Entry     *database.EntryEntity
	Plan      *compaction.Plan
	SessionID string
	CWD       string
	Source    string
}

CompactionSaved describes an after-compaction lifecycle payload.

type PromptRequest

type PromptRequest struct {
	ParentEntryID *string
	CWD           string
	Name          string
	SessionID     string
	Text          string
	Attachments   []map[string]any
	ResumeLatest  bool
}

PromptRequest is the lifecycle payload view of an assistant prompt request.

type ProviderError

type ProviderError struct {
	Err       error
	API       string
	ModelID   string
	Provider  string
	SessionID string
	Attempt   int
}

ProviderError describes provider-error lifecycle payload metadata.

type ProviderRequest

type ProviderRequest struct {
	Payload       map[string]any
	Headers       map[string]string
	API           string
	ModelID       string
	Provider      string
	SessionID     string
	ThinkingLevel string
	Attempt       int
	MaxTokens     int
}

ProviderRequest describes before-provider-request lifecycle payload metadata.

type ProviderResponse

type ProviderResponse struct {
	FinishReason   llm.FinishReason
	Termination    llm.TerminationMetadata
	API            string
	ModelID        string
	Provider       string
	SessionID      string
	Text           string
	Usage          model.TokenUsage
	Attempt        int
	ThinkingCount  int
	ToolEventCount int
}

ProviderResponse describes after-provider-response lifecycle payload metadata.

type ToolCall

type ToolCall struct {
	ArgumentsJSON string
	ID            string
	ParentCallID  string
	Name          string
	Arguments     tool.Arguments
	Sequence      int
}

ToolCall describes a tool-call lifecycle payload.

type ToolResult

type ToolResult struct {
	CallID        string
	ParentCallID  string
	Name          string
	ArgumentsJSON string
	DetailsJSON   string
	Result        string
	Error         string
	Sequence      int
	IsError       bool
}

ToolResult describes a tool-result lifecycle payload.

type TurnEnd

type TurnEnd struct {
	Err              error
	AssistantEntryID string
	SessionID        string
	UserEntryID      string
	Usage            model.TokenUsage
	Cached           bool
}

TurnEnd describes the payload for a finished prompt turn.

Jump to

Keyboard shortcuts

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