Documentation
¶
Index ¶
- Constants
- func ClearGoal(ctx context.Context, sessionID string)
- func ClearSessionDBCache()
- func CountActiveDelegations(sessionID string) (count int)
- func EnglishGoalRender(key, def string, values map[string]any) string
- func GatherBackgroundProcesses(ctx context.Context, taskID, ownerTaskID string) (running []map[string]any)
- func GoalKickPrompt(goal string, lastUserMessage any) string
- func GoalMetaKey(sessionID string) string
- func IsGoalControl(arg string) bool
- func LastUserMessageContent(history any) any
- func LastUserMessageFromDB(ctx context.Context, sessionID string) (content any)
- func MigrateGoalToSession(ctx context.Context, oldSessionID, newSessionID, reason string) bool
- func RunGate(ctx context.Context, gate GoalGate, cwd string) (passed bool, exitCode int64, outputTail string, interrupted error)
- func SaveGoal(ctx context.Context, sessionID string, st *GoalState)
- func SessionDB(ctx context.Context) *state.DB
- func WarnDroppedWrite(manager, kind, sessionID string)
- type GoalCommandOptions
- type GoalCommandResult
- type GoalContract
- type GoalDecision
- type GoalGate
- type GoalLoopOptions
- type GoalLoopResult
- type GoalManager
- func (m *GoalManager) AddGate(command string, timeoutSeconds, maxRetries int64) (GoalGate, error)
- func (m *GoalManager) AddSubgoal(text string) (string, error)
- func (m *GoalManager) Clear()
- func (m *GoalManager) ClearGates() (int, error)
- func (m *GoalManager) ClearSubgoals() (int, error)
- func (m *GoalManager) Context() context.Context
- func (m *GoalManager) EvaluateAfterTurn(lastResponse string, backgroundProcesses []map[string]any, ...) (GoalDecision, error)
- func (m *GoalManager) HasContract() bool
- func (m *GoalManager) HasGoal() bool
- func (m *GoalManager) IsActive() bool
- func (m *GoalManager) IsWaiting() bool
- func (m *GoalManager) MarkDone(reason string)
- func (m *GoalManager) NextContinuationPrompt() *string
- func (m *GoalManager) Pause(reason string) *GoalState
- func (m *GoalManager) Refresh()
- func (m *GoalManager) RemoveGate(index1Based int64) (string, error)
- func (m *GoalManager) RemoveSubgoal(index1Based int64) (string, error)
- func (m *GoalManager) RenderContract() string
- func (m *GoalManager) RenderGates() string
- func (m *GoalManager) RenderSubgoals() string
- func (m *GoalManager) Resume(resetBudget bool) *GoalState
- func (m *GoalManager) Session() string
- func (m *GoalManager) Set(goal string, maxTurns int64, contract *GoalContract) (*GoalState, error)
- func (m *GoalManager) SetContract(contract GoalContract) *GoalState
- func (m *GoalManager) State() *GoalState
- func (m *GoalManager) StatusLine() string
- func (m *GoalManager) StopWaiting() bool
- func (m *GoalManager) WaitForSeconds(seconds int64, reason string, onDelegations int64) (*GoalState, error)
- func (m *GoalManager) WaitOn(pid int64, reason string) (*GoalState, error)
- func (m *GoalManager) WaitOnSession(sessionID, reason string) (*GoalState, error)
- type GoalRender
- type GoalState
- type JudgeOptions
- type JudgeResult
- type Manager
Constants ¶
const ( DefaultJudgeTimeout = 30.0 DefaultJudgeMaxTokens = 4096 DefaultMaxConsecutiveParseFailures = 3 DefaultMaxConsecutiveTransportFailures = 5 )
const ( DefaultGoalMaxTurns = 20 DefaultGateTimeoutSeconds = 300 DefaultGateMaxRetries = 3 )
const (
GoalAlreadySeenKick = "[Goal set] Continue with the goal you were just given; there is no need to re-read it."
)
const UserPausedReason = "user-paused"
Pause reason of a goal the user paused without naming one
Variables ¶
This section is empty.
Functions ¶
func ClearSessionDBCache ¶
func ClearSessionDBCache()
Empties the per home session database cache the way tests reset the module level dict
func CountActiveDelegations ¶
Live async delegation batches the session spawned, zero for no session or a registry failure
func EnglishGoalRender ¶
English rendering that fills the default template and ignores the key
func GatherBackgroundProcesses ¶
func GatherBackgroundProcesses(ctx context.Context, taskID, ownerTaskID string) (running []map[string]any)
Running process registry sessions for the judge, only those the owner task spawned when one is named
func GoalKickPrompt ¶
Goal text, or the already seen pointer when the last user message is essentially that text
func GoalMetaKey ¶
func IsGoalControl ¶
True when the command controls an existing goal rather than replacing it
func LastUserMessageContent ¶
Content of the newest user message of a chat history, empty text when there is none
func LastUserMessageFromDB ¶
Newest user message of a session from the session store, empty text on any failure
func MigrateGoalToSession ¶
Copies a live goal onto the continuation session and archives the parent row, true when migrated
func RunGate ¶
func RunGate(ctx context.Context, gate GoalGate, cwd string) (passed bool, exitCode int64, outputTail string, interrupted error)
Shell run of one gate giving pass, exit code and output tail, a timeout as minus one
func SessionDB ¶
Cached registry database of the home in effect, never opened inline on a running loop, nil on failure
func WarnDroppedWrite ¶
func WarnDroppedWrite(manager, kind, sessionID string)
Warns that a state write was dropped because the session database is unavailable
Types ¶
type GoalCommandOptions ¶
type GoalCommandOptions struct {
AuthorizeGate func() string
LastUserMessage any
Render GoalRender
Progress func(string)
}
Optional inputs of one goal command, a nil render meaning English
type GoalCommandResult ¶
type GoalCommandResult struct {
Output string
Prompt *string
Kickoff bool
ClearPending string
Error bool
}
Outcome of one goal command, the prompt nil when no turn should follow
func DispatchGoalCommand ¶
func DispatchGoalCommand(m Manager, arg string, o GoalCommandOptions) (GoalCommandResult, error)
Applies one goal command to the manager, the goal errors rendered as an invalid goal result
type GoalContract ¶
type GoalContract struct {
Outcome string
Verification string
Constraints string
Boundaries string
StopWhen string
}
Optional structured completion contract whose empty fields are omitted everywhere
func DraftContract ¶
func DraftContract(ctx context.Context, objective string, timeout *float64) *GoalContract
Completion contract drafted from a plain objective through the goal_judge task, nil when unavailable or unparseable
func GoalContractFromDict ¶
func GoalContractFromDict(data any) GoalContract
Contract of a stored dict with each field stringified and stripped, empty for a non dict
func ParseContract ¶
func ParseContract(text string) (string, GoalContract)
Headline and contract of goal text whose field lines such as verify or done when fill the contract
func (GoalContract) IsEmpty ¶
func (c GoalContract) IsEmpty() bool
True when every field is blank after stripping
func (GoalContract) RenderBlock ¶
func (c GoalContract) RenderBlock() string
Labelled lines of the non empty fields, empty for an empty contract
func (GoalContract) ToDict ¶
func (c GoalContract) ToDict() *pyjson.Object
Ordered dict of every field keyed by its name
type GoalDecision ¶
type GoalDecision struct {
Status any
ShouldContinue bool
ContinuationPrompt *string
Verdict string
Reason string
Message string
}
What the goal loop does after a turn, the status nil when the session has no goal
func (GoalDecision) ToDict ¶
func (d GoalDecision) ToDict() *pyjson.Object
Decision fields as an ordered JSON object
type GoalGate ¶
type GoalGate struct {
Command string
TimeoutSeconds int64
MaxRetries int64
Attempts int64
LastExitCode *int64
LastOutputTail string
}
Deterministic shell command that must pass before a goal can be done
func GoalGateFromDict ¶
Gate of a stored dict with Python int and str coercion, a blank gate for a non dict
func NewGoalGate ¶
Gate for command with the default timeout and retry budget
type GoalLoopOptions ¶
type GoalLoopOptions struct {
TaskID string
GoalText string
RunTurn func(prompt string) (any, error)
TaskStatus func() (*string, error)
Block func(reason string) error
MaxTurns int
FirstResponse string
Log func(string)
}
Inputs of the kanban worker goal loop, a turn budget below one meaning twenty
type GoalLoopResult ¶
How the kanban worker goal loop ended
func RunKanbanGoalLoop ¶
func RunKanbanGoalLoop(ctx context.Context, o GoalLoopOptions) (GoalLoopResult, error)
Drives a kanban worker until it ends its task, the judge blocks it, or the budget runs out
type GoalManager ¶
type GoalManager struct {
SessionID string
DefaultMaxTurns int64
// contains filtered or unexported fields
}
Per session goal state and the continuation decisions the CLI and the gateway act on
func NewGoalManager ¶
func NewGoalManager(ctx context.Context, sessionID string, defaultMaxTurns int64) *GoalManager
Manager of a session's goal loaded from the session store, a zero default meaning twenty turns
func (*GoalManager) AddGate ¶
func (m *GoalManager) AddGate(command string, timeoutSeconds, maxRetries int64) (GoalGate, error)
Appends a quality gate command, zero timeout or retries taking the defaults
func (*GoalManager) AddSubgoal ¶
func (m *GoalManager) AddSubgoal(text string) (string, error)
Appends a user criterion and returns it, a RuntimeError without a goal and a ValueError for empty text
func (*GoalManager) Clear ¶
func (m *GoalManager) Clear()
Marks the goal cleared in the store and drops it from the manager
func (*GoalManager) ClearGates ¶
func (m *GoalManager) ClearGates() (int, error)
Removes every gate and returns how many there were
func (*GoalManager) ClearSubgoals ¶
func (m *GoalManager) ClearSubgoals() (int, error)
Removes every subgoal and returns how many there were
func (*GoalManager) Context ¶
func (m *GoalManager) Context() context.Context
Context the manager reads the store and calls the judge under
func (*GoalManager) EvaluateAfterTurn ¶
func (m *GoalManager) EvaluateAfterTurn(lastResponse string, backgroundProcesses []map[string]any, activeDelegations int) (GoalDecision, error)
Runs the gates and the judge after a turn, updates the state and returns what the loop does next
func (*GoalManager) HasContract ¶
func (m *GoalManager) HasContract() bool
True when the goal carries a completion contract
func (*GoalManager) HasGoal ¶
func (m *GoalManager) HasGoal() bool
True when the goal is active or paused
func (*GoalManager) IsWaiting ¶
func (m *GoalManager) IsWaiting() bool
True while a barrier is set and unmet, a met or overlong barrier cleared on the way
func (*GoalManager) MarkDone ¶
func (m *GoalManager) MarkDone(reason string)
Marks the goal done with the reason as its last verdict
func (*GoalManager) NextContinuationPrompt ¶
func (m *GoalManager) NextContinuationPrompt() *string
User role message that continues an active goal, the contract first and subgoals folded in, nil when not active
func (*GoalManager) Pause ¶
func (m *GoalManager) Pause(reason string) *GoalState
Pauses the goal and lifts any wait barrier, nil when the session has no goal
func (*GoalManager) Refresh ¶
func (m *GoalManager) Refresh()
Reads the state again from the session store
func (*GoalManager) RemoveGate ¶
func (m *GoalManager) RemoveGate(index1Based int64) (string, error)
Removes a gate by its one based index and returns its command
func (*GoalManager) RemoveSubgoal ¶
func (m *GoalManager) RemoveSubgoal(index1Based int64) (string, error)
Removes a subgoal by its one based index and returns its text
func (*GoalManager) RenderContract ¶
func (m *GoalManager) RenderContract() string
Completion contract block for the goal show and draft commands, a hint when there is none
func (*GoalManager) RenderGates ¶
func (m *GoalManager) RenderGates() string
Numbered gates with their last result for the gate command
func (*GoalManager) RenderSubgoals ¶
func (m *GoalManager) RenderSubgoals() string
Numbered subgoals for the subgoal command, a hint when there are none
func (*GoalManager) Resume ¶
func (m *GoalManager) Resume(resetBudget bool) *GoalState
Reactivates the goal with no wait barrier, resetting the turn budget when asked
func (*GoalManager) Session ¶
func (m *GoalManager) Session() string
Session id the manager is bound to
func (*GoalManager) Set ¶
func (m *GoalManager) Set(goal string, maxTurns int64, contract *GoalContract) (*GoalState, error)
Starts a fresh active goal, a zero turn budget taking the manager default, a ValueError for empty text
func (*GoalManager) SetContract ¶
func (m *GoalManager) SetContract(contract GoalContract) *GoalState
Attaches or replaces the completion contract, nil when the session has no goal
func (*GoalManager) State ¶
func (m *GoalManager) State() *GoalState
Current goal state, nil when the session has none
func (*GoalManager) StatusLine ¶
func (m *GoalManager) StatusLine() string
One line describing the goal, its budget and any wait barrier
func (*GoalManager) StopWaiting ¶
func (m *GoalManager) StopWaiting() bool
Clears any wait barrier, true when one was set
func (*GoalManager) WaitForSeconds ¶
func (m *GoalManager) WaitForSeconds(seconds int64, reason string, onDelegations int64) (*GoalState, error)
Parks the loop for seconds, lifting early once fewer than onDelegations batches are live
func (*GoalManager) WaitOn ¶
func (m *GoalManager) WaitOn(pid int64, reason string) (*GoalState, error)
Parks the loop until a background pid exits, a ValueError for a dead or invalid pid
func (*GoalManager) WaitOnSession ¶
func (m *GoalManager) WaitOnSession(sessionID, reason string) (*GoalState, error)
Parks the loop on a process registry session's own trigger, its exit or a watch pattern match
type GoalRender ¶
Renders a user facing goal message from its translation key, English default and values
type GoalState ¶
type GoalState struct {
Goal any
Status any
TurnsUsed int64
MaxTurns int64
CreatedAt float64
LastTurnAt float64
LastVerdict any
LastReason any
PausedReason any
ConsecutiveParseFailures int64
ConsecutiveTransportFailures int64
Subgoals []string
WaitingOnPID *int64
WaitingOnSession *string
WaitingUntil float64
WaitingOnDelegations int64
WaitingReason any
WaitingSince float64
Contract GoalContract
Gates []GoalGate
}
Serializable goal state stored per session, uncoerced fields keeping their stored JSON value
func GoalStateFromJSON ¶
Goal state of a stored row with the Python coercions, legacy rows filling defaults
func (*GoalState) HasContract ¶
True when a non empty contract is attached
func (*GoalState) RenderSubgoalsBlock ¶
Numbered subgoal lines, empty when there are no subgoals
type JudgeOptions ¶
type JudgeOptions struct {
Timeout *float64
Subgoals []string
BackgroundProcesses []map[string]any
Contract *GoalContract
ActiveDelegations int
}
Optional inputs of one judge call
type JudgeResult ¶
type JudgeResult struct {
Verdict string
Reason string
ParseFailed bool
Wait map[string]any
TransportFailed bool
}
Outcome of one judge call, the verdict being done, blocked, continue, wait or skipped
func JudgeGoal ¶
func JudgeGoal(ctx context.Context, goal, lastResponse string, o JudgeOptions) JudgeResult
Asks the auxiliary model whether the goal is satisfied, failing open to continue on any transport error
type Manager ¶
type Manager interface {
Session() string
Context() context.Context
Refresh()
State() *GoalState
IsActive() bool
HasGoal() bool
HasContract() bool
StatusLine() string
RenderSubgoals() string
RenderGates() string
RenderContract() string
NextContinuationPrompt() *string
Set(goal string, maxTurns int64, contract *GoalContract) (*GoalState, error)
Pause(reason string) *GoalState
Resume(resetBudget bool) *GoalState
Clear()
MarkDone(reason string)
AddSubgoal(text string) (string, error)
RemoveSubgoal(index1Based int64) (string, error)
ClearSubgoals() (int, error)
AddGate(command string, timeoutSeconds, maxRetries int64) (GoalGate, error)
RemoveGate(index1Based int64) (string, error)
ClearGates() (int, error)
WaitOn(pid int64, reason string) (*GoalState, error)
WaitOnSession(sessionID, reason string) (*GoalState, error)
WaitForSeconds(seconds int64, reason string, onDelegations int64) (*GoalState, error)
StopWaiting() bool
IsWaiting() bool
EvaluateAfterTurn(lastResponse string, backgroundProcesses []map[string]any, activeDelegations int) (GoalDecision, error)
}
Calls of a goal manager the goal command and the CLI make, answered in process or by the gateway