history

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package history reads the web chat's sessions from a workspace's session store: the list of sessions and each one's transcript, as the launcher's /api/sessions and the gateway's /web/sessions serve them.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("session not found")

ErrNotFound reports that no web chat session has the asked id, or that it has nothing to show.

Functions

func FileBase

func FileBase(key string) string

FileBase returns the name a session's files have in the sessions directory, before their extension.

func ServeDetail

func ServeDetail(w http.ResponseWriter, reader Reader, id string)

ServeDetail answers a request for the transcript of the session id: 404 when it has none.

func ServeList

func ServeList(w http.ResponseWriter, r *http.Request, reader Reader)

ServeList answers a request for one page of sessions: offset (0 by default) and limit (20 by default) come from the query.

func SessionsDir

func SessionsDir(workspace string) string

SessionsDir returns the sessions directory of workspace: its "sessions" folder, or that of the default workspace when workspace is empty.

Types

type Attachment

type Attachment struct {
	Type        string `json:"type,omitempty"`
	URL         string `json:"url,omitempty"`
	Filename    string `json:"filename,omitempty"`
	ContentType string `json:"content_type,omitempty"`
}

type Detail

type Detail struct {
	ID       string    `json:"id"`
	Messages []Message `json:"messages"`
	Summary  string    `json:"summary"`
	Created  string    `json:"created"`
	Updated  string    `json:"updated"`
}

Detail is a session's transcript.

type Message

type Message struct {
	Role               string                  `json:"role"`
	Content            string                  `json:"content"`
	Kind               string                  `json:"kind,omitempty"`
	ModelName          string                  `json:"model_name,omitempty"`
	RequestedSelection string                  `json:"requested_selection,omitempty"`
	ServedTarget       string                  `json:"served_target,omitempty"`
	ServedIdentity     string                  `json:"served_identity,omitempty"`
	CreatedAt          *time.Time              `json:"created_at,omitempty"`
	Media              []string                `json:"media,omitempty"`
	Attachments        []Attachment            `json:"attachments,omitempty"`
	ToolCalls          []utils.VisibleToolCall `json:"tool_calls,omitempty"`
}

type Reader

type Reader struct {
	// Dir is the workspace's sessions directory (see SessionsDir).
	Dir string
	// MaxArgsLength cuts the tool call arguments a transcript shows; 0 uses
	// the default.
	MaxArgsLength int
}

Reader reads the web chat's sessions in a sessions directory.

func (Reader) Delete

func (r Reader) Delete(id string) error

Delete removes the files of the session id. It returns ErrNotFound when there were none.

func (Reader) Get

func (r Reader) Get(id string) (Detail, error)

Get returns the transcript of the session id, including the model's thoughts, or ErrNotFound.

func (Reader) List

func (r Reader) List(offset, limit int) []Summary

List returns one page of sessions, most recently updated first. A session with nothing to show gives its place on the page to the next one.

type Summary

type Summary struct {
	ID           string `json:"id"`
	Title        string `json:"title"`
	Preview      string `json:"preview"`
	MessageCount int    `json:"message_count"`
	Created      string `json:"created"`
	Updated      string `json:"updated"`
}

Summary is a lightweight summary returned by GET /api/sessions.

Jump to

Keyboard shortcuts

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