turncomplete

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PersistObservedResultCost

func PersistObservedResultCost(log *slog.Logger, tracker SessionCostTracker, claudeHome string, result *message.ResultMessage)

PersistObservedResultCost persists the current tracker snapshot after a terminal result.

func RestoreCostTracker

func RestoreCostTracker(log *slog.Logger, tracker SessionCostTracker, sessionID, claudeHome string)

RestoreCostTracker restores persisted session-cost state for resumed sessions.

Types

type Callback

type Callback func(context.Context, *Info) error

Callback handles a completed turn summary.

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector accumulates per-turn side-channel messages until a terminal result arrives.

func (*Collector) Complete

func (c *Collector) Complete(
	ctx context.Context,
	callback Callback,
	result *message.ResultMessage,
	turnCost CostSummary,
	aggregate *CostSummary,
) error

Complete invokes the callback with the current turn summary and resets the collector.

func (*Collector) Observe

func (c *Collector) Observe(msg message.Message)

Observe records message-side metadata relevant to turn completion.

func (*Collector) Reset

func (c *Collector) Reset()

Reset clears the current turn state.

type CostSummary

type CostSummary struct {
	TotalCostUSD                float64
	Results                     int
	TotalDurationMs             int
	TotalDurationAPIMs          int
	TotalTurns                  int
	TotalInputTokens            int
	TotalOutputTokens           int
	TotalCacheReadInputTokens   int
	TotalCacheCreateInputTokens int
	TotalWebSearchRequests      int
}

CostSummary contains lightweight turn and aggregate cost data.

func AggregateCostSummary

func AggregateCostSummary(tracker SessionCostTracker) *CostSummary

AggregateCostSummary returns the current aggregate summary from the tracker.

func BuildTurnCostSummary

func BuildTurnCostSummary(result *message.ResultMessage) CostSummary

BuildTurnCostSummary derives one turn-cost summary from a terminal result.

type Info

type Info struct {
	Result                *message.ResultMessage
	TurnCost              CostSummary
	AggregateCost         *CostSummary
	SawPromptSuggestion   bool
	PromptSuggestions     []string
	SawPostTurnSummary    bool
	PostTurnSummaryCount  int
	SawTaskNotification   bool
	TaskNotificationCount int
}

Info summarizes one completed turn.

type SessionCostTracker

type SessionCostTracker interface {
	LoadSessionCost(sessionID, claudeHome string) error
	SaveSessionCost(sessionID, claudeHome string) error
	CostSummary() CostSummary
}

SessionCostTracker is the narrow tracker interface used by shared runtime helpers.

Jump to

Keyboard shortcuts

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