session

package
v1.4.87 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupSessions

func CleanupSessions() (int, error)

CleanupSessions deletes all inactive session JSONL logs. If no session is active, it deletes all logs.

func EndSession

func EndSession() (string, error)

EndSession ends the currently active session.

func FindGographRoot added in v1.4.72

func FindGographRoot() string

FindGographRoot walks up from the current working directory until it finds a directory that already contains a ".gograph" subdirectory (i.e. the project root where `gograph build` was run). Falls back to "." when none is found so that existing behaviour and tests that chdir to a fresh temp dir are unaffected.

This is a thin wrapper around rootfind.FindRoot() kept for backward compatibility.

func FindMostRecentSessionID

func FindMostRecentSessionID() (string, error)

FindMostRecentSessionID finds the session log file with the newest modification time.

func GetActiveSessionID

func GetActiveSessionID() (string, error)

GetActiveSessionID retrieves the currently active session ID if it exists.

func LogCommand

func LogCommand(command string, args []string, intention string, elapsed time.Duration, status string) error

LogCommand Telemetry records command execution details inside the active session log if present.

func RunAudit

func RunAudit(sessionID string, jsonMode bool) int

RunAudit parses and scores a session for agent compliance and success rates.

func StartSession

func StartSession(customWord string) (string, error)

StartSession initializes a new session and writes the active session pointer.

Types

type ActiveSessionPointer

type ActiveSessionPointer struct {
	ActiveSessionID string `json:"active_session_id"`
}

ActiveSessionPointer tracks the currently active session ID.

type AuditReport

type AuditReport struct {
	SessionID       string   `json:"session_id"`
	Status          string   `json:"status"`
	CreatedAt       string   `json:"created_at"`
	EndedAt         string   `json:"ended_at"`
	DurationSeconds float64  `json:"duration_seconds"`
	TotalCommands   int      `json:"total_commands"`
	SuccessCount    int      `json:"success_count"`
	FailureCount    int      `json:"failure_count"`
	SuccessRate     float64  `json:"success_rate"`
	PlanRun         bool     `json:"plan_run"`
	ReviewRun       bool     `json:"review_run"`
	ComposedCount   int      `json:"composed_count"`
	RawQueryCount   int      `json:"raw_query_count"`
	Composability   float64  `json:"composability"`
	ComplianceScore float64  `json:"compliance_score"`
	Grade           string   `json:"grade"`
	Recommendations []string `json:"recommendations"`
}

AuditReport holds the calculated compliance and success metrics of a session.

type CommandLogEntry

type CommandLogEntry struct {
	Type        string   `json:"type"`
	Timestamp   string   `json:"timestamp"`
	Command     string   `json:"command"`
	Args        []string `json:"args"`
	Intention   string   `json:"intention"`
	ExecutionMs int64    `json:"execution_ms"`
	Status      string   `json:"status"`
}

CommandLogEntry logs telemetry metadata for an executed command.

type GenericLogLine

type GenericLogLine struct {
	Type        string   `json:"type"`
	SessionID   string   `json:"session_id"`
	CreatedAt   string   `json:"created_at"`
	EndedAt     string   `json:"ended_at"`
	Timestamp   string   `json:"timestamp"`
	Command     string   `json:"command"`
	Args        []string `json:"args"`
	Intention   string   `json:"intention"`
	ExecutionMs int64    `json:"execution_ms"`
	Status      string   `json:"status"`
}

GenericLogLine represents any log line parsed from a JSONL session file.

type SessionEndEntry

type SessionEndEntry struct {
	Type    string `json:"type"`
	EndedAt string `json:"ended_at"`
	Status  string `json:"status"`
}

SessionEndEntry logs the termination of a session.

type SessionStartEntry

type SessionStartEntry struct {
	Type      string `json:"type"`
	SessionID string `json:"session_id"`
	CreatedAt string `json:"created_at"`
}

SessionStartEntry logs the start of a session.

Jump to

Keyboard shortcuts

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