session

command
v0.260514.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MPL-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Session Management Example

This example demonstrates how to use the session management features of agentboot to list and view Claude Code sessions.

Building

go build -o session ./agentboot/examples/session/main.go

Usage

# List recent sessions for a project (default: 10)
./session /path/to/project

# List recent sessions with a custom limit
./session /path/to/project 20

# Example with actual project path
./session /root/tingly-polish

# Output as JSON (pipe to jq for pretty printing)
./session /root/tingly-polish | jq .

Output Format

The output is JSON formatted for easy parsing:

[
  {
    "session_id": "947100b0-fcfe-4abc-af28-ace64aa23364",
    "project_path": "/root/tingly-polish",
    "status": "complete",
    "start_time": "2026-03-03T11:31:53Z",
    "end_time": "2026-03-03T11:37:23Z",
    "duration_ms": 330000,
    "first_message": "Implement session management feature",
    "last_result": "Successfully implemented all phases",
    "num_turns": 5,
    "input_tokens": 15234,
    "output_tokens": 3421,
    "cache_read_tokens": 8192,
    "total_cost_usd": 0.1234
  },
  {
    "session_id": "fbb2165f-742e-44df-9a48-631e815d0304",
    "project_path": "/root/tingly-polish",
    "status": "active",
    "start_time": "2026-03-03T10:15:22Z",
    "first_message": "Fix bug in JSON parser",
    "num_turns": 2,
    "total_cost_usd": 0.0567
  }
]

Features

  • JSON Output: Structured JSON output for easy parsing and integration
  • Path Resolution: Automatically resolves project paths to Claude's encoded format
  • Session Metadata: Includes session ID, status, timestamps, cost, and usage metrics
  • First Message Preview: Shows the first user message for context

Examples

# Get recent sessions
./session /root/tingly-polish

# Get last 20 sessions
./session /root/tingly-polish 20

# Pipe to jq for formatted output
./session /root/tingly-polish | jq '.[] | {id: .session_id, status: .status, cost: .total_cost_usd}'

# Filter by status
./session /root/tingly-polish | jq '.[] | select(.status == "complete")'

# Calculate total cost
./session /root/tingly-polish | jq '[.[] | .total_cost_usd] | add'

Programmatic Usage

package main

import (
	"context"
	"fmt"
	"github.com/tingly-dev/tingly-box/agentboot/claude/claude"
)

func main() {
	// Create a session store
	store, _ := claude.NewStore("") // Uses default ~/.claude/projects

	// List recent sessions
	ctx := context.Background()
	sessions, _ := store.GetRecentSessions(ctx, "/root/project", 10)

	for _, sess := range sessions {
		fmt.Printf("%s: %s\n", sess.SessionID, sess.FirstMessage)
	}

	// Get session summary
	summary, _ := store.GetSessionSummary(ctx, sess.SessionID, 3, 2)
	fmt.Printf("First events: %d\n", len(summary.Head))
	fmt.Printf("Last events: %d\n", len(summary.Tail))
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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