Documentation
¶
Overview ¶
Package goal implements the persistent goal system. Mirrors Codex's ThreadGoal / ThreadGoalStatus from protocol.rs and the goal-management tools (create_goal, get_goal, update_goal).
Index ¶
- Constants
- func BudgetLimitPrompt(g *Goal) string
- func ContinuationPrompt(g *Goal) string
- func IsFinal(s Status) bool
- func ObjectiveUpdatedPrompt(g *Goal) string
- func ValidateObjective(objective string) error
- type Goal
- type Status
- type Store
- func (s *Store) Clear(sessionID string)
- func (s *Store) Get(sessionID string) (*Goal, bool)
- func (s *Store) RecordTokenUsage(sessionID string, tokens int64)
- func (s *Store) Set(sessionID, objective string, tokenBudget *int64) *Goal
- func (s *Store) Update(sessionID string, newStatus *Status, newObjective *string) (*Goal, bool)
Constants ¶
const MaxObjectiveChars = 4_000
MaxObjectiveChars mirrors Codex's MAX_THREAD_GOAL_OBJECTIVE_CHARS.
Variables ¶
This section is empty.
Functions ¶
func BudgetLimitPrompt ¶
BudgetLimitPrompt returns the prompt injected when a goal's token budget is exhausted. Mirrors Codex's budget_limit_prompt() + budget_limit.md template.
func ContinuationPrompt ¶
ContinuationPrompt returns the hidden prompt injected after each turn of an active goal. Mirrors Codex's continuation_prompt() + continuation.md template.
func ObjectiveUpdatedPrompt ¶
ObjectiveUpdatedPrompt returns the prompt injected when a goal's objective is edited mid-session. Mirrors Codex's objective_updated_prompt() + objective_updated.md.
func ValidateObjective ¶
ValidateObjective returns an error when the objective violates the Codex constraints.
Types ¶
type Goal ¶
type Goal struct {
SessionID string `json:"session_id"`
Objective string `json:"objective"`
Status Status `json:"status"`
TokenBudget *int64 `json:"token_budget,omitempty"`
TokensUsed int64 `json:"tokens_used"`
TimeUsedSeconds int64 `json:"time_used_seconds"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
// contains filtered or unexported fields
}
Goal mirrors Codex's ThreadGoal struct (protocol.rs:3651). Keyed by SessionID in the Store.
func (*Goal) IsOverBudget ¶
IsOverBudget returns true when the token budget is exhausted.
func (*Goal) RemainingTokens ¶
RemainingTokens returns how many tokens are left in the budget, or -1 if unbounded.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the in-memory goal registry keyed by SessionID. Thread-safe. Mirrors Codex's server-side goal state per thread.
func GetDefaultStore ¶
func GetDefaultStore() *Store
GetDefaultStore returns the process-level singleton GoalStore.
func (*Store) RecordTokenUsage ¶
RecordTokenUsage adds tokens to the running counter and auto-transitions to budgetLimited when the budget is exceeded. Called by the runner after each turn.