model

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: BSD-3-Clause Imports: 3 Imported by: 1 module, 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.

Documentation

Overview

Package model is the wire and screen model of agentscope: one Snapshot is everything the UI shows, and it carries METADATA only -- ids, working directories resolved to repositories, tool names, agent descriptions, lease notes, tell texts and timestamps. Nothing here ever holds a prompt or a response; the collector never reads those fields (see package collect).

Index

Constants

View Source
const (
	AnomalyUnresolvedKey   = "unresolved key"
	AnomalyOrphanLease     = "lease owner has no transcript"
	AnomalyUnknownSender   = "tell from unknown session"
	AnomalyUnknownTarget   = "tell to unknown session"
	AnomalyBadLine         = "unparsable line"
	AnomalyOversizedLine   = "oversized line skipped"
	AnomalyUnreadable      = "unreadable file"
	AnomalyTranscriptStall = "transcript shrank"
)

Anomaly kinds.

View Source
const Version = 1

Version is the snapshot schema version; the browser refuses a newer one.

Variables

This section is empty.

Functions

func ShortID

func ShortID(id string) string

ShortID is the first 8 characters of an id.

func Truncate

func Truncate(s string, n int) string

Truncate cuts s to at most n runes, with an ellipsis, on a rune boundary.

Types

type Agent

type Agent struct {
	ID           string    `json:"id"`
	Type         string    `json:"type,omitempty"`
	Description  string    `json:"description,omitempty"`
	ToolUseID    string    `json:"toolUseId,omitempty"`
	Depth        int       `json:"depth"`
	LastActivity time.Time `json:"lastActivity"`
	Active       bool      `json:"active"`
}

Agent is one sub-agent of a session.

type Anomaly

type Anomaly struct {
	Kind    string `json:"kind"`
	Subject string `json:"subject"`
	Detail  string `json:"detail,omitempty"`
}

Anomaly is something odd the collector met and chose to show.

type Counts

type Counts struct {
	Sessions, Active, Agents, ActiveAgents, Repos, Held, Leases, Tells, Anomalies int
}

Counts is the header line of the UI.

type Lease

type Lease struct {
	Resource string    `json:"resource"` // as written in the lease
	Repo     string    `json:"repo"`     // normalised key (org/repo when resolved)
	Kind     RepoKind  `json:"kind"`
	Path     string    `json:"path,omitempty"` // the clone, when there is one
	Owner    string    `json:"owner"`
	PID      int       `json:"pid"`
	Note     string    `json:"note,omitempty"`
	Acquired time.Time `json:"acquired"`
	Expires  time.Time `json:"expires"`
	Expired  bool      `json:"expired"`
}

Lease is one advisory lease, expired ones included.

type RepoKind

type RepoKind string

RepoKind says how a lease resource was understood.

const (
	// KindRepo is an org/repo that matches a clone on this machine.
	KindRepo RepoKind = "repo"
	// KindRepoForm is an org/repo spelling with no clone here.
	KindRepoForm RepoKind = "repo-form"
	// KindOrg is an organisation that has clones here.
	KindOrg RepoKind = "org"
	// KindUnresolved is a key that is no repository: a note used as the key,
	// a bare name, a flag. It is shown, flagged, never hidden.
	KindUnresolved RepoKind = "unresolved"
)

type Session

type Session struct {
	ID            string    `json:"id"`
	Short         string    `json:"short"` // first 8 characters of ID
	Title         string    `json:"title,omitempty"`
	Slug          string    `json:"slug,omitempty"`
	Cwd           string    `json:"cwd,omitempty"`
	CwdRepo       string    `json:"cwdRepo,omitempty"` // Cwd resolved to org/repo, when it is one
	Branch        string    `json:"branch,omitempty"`
	PR            string    `json:"pr,omitempty"`
	Project       string    `json:"project,omitempty"`
	LastActivity  time.Time `json:"lastActivity"`
	Active        bool      `json:"active"`
	HasTranscript bool      `json:"hasTranscript"`
	Sent          int       `json:"sent"`    // SendMessage calls seen in the observed window
	MemAdds       int       `json:"memAdds"` // entries in the agentsync session record
	Agents        []Agent   `json:"agents,omitempty"`
}

Session is one Claude Code session, with its sub-agents.

type Snapshot

type Snapshot struct {
	Version   int       `json:"version"`
	At        time.Time `json:"at"`
	ActiveFor string    `json:"activeFor"` // the activity window, e.g. "10m0s"
	Horizon   string    `json:"horizon"`   // sessions older than this are not listed
	Sessions  []Session `json:"sessions"`
	Leases    []Lease   `json:"leases"`
	Tells     []Tell    `json:"tells"`
	Anomalies []Anomaly `json:"anomalies"`
	Stats     Stats     `json:"stats"`
}

Snapshot is the whole picture at one instant.

func (Snapshot) Counts

func (s Snapshot) Counts() Counts

Counts summarises the snapshot.

func (Snapshot) LeasesOf

func (s Snapshot) LeasesOf(id string) []Lease

LeasesOf returns the leases a session holds or held, live first and then by most recent acquisition.

func (Snapshot) SessionByShort

func (s Snapshot) SessionByShort(short string) (Session, bool)

SessionByShort finds a session by its short id.

func (Snapshot) Task

func (s Snapshot) Task(se Session) string

Task is the best one-line statement of what a session is doing: the note of its live lease, else its title, else its slug.

type Stats

type Stats struct {
	TranscriptsSeen  int   `json:"transcriptsSeen"`
	TranscriptsRead  int   `json:"transcriptsRead"`
	BytesRead        int64 `json:"bytesRead"`
	LeasesRead       int   `json:"leasesRead"`
	LeasesTorn       int   `json:"leasesTorn"`
	TellsRead        int   `json:"tellsRead"`
	TellsDropped     int   `json:"tellsDropped"`
	SubAgentsRead    int   `json:"subAgentsRead"`
	SessionRecords   int   `json:"sessionRecords"`
	ElapsedMicros    int64 `json:"elapsedMicros"`
	LinesSkipped     int   `json:"linesSkipped"`
	LinesUnparsable  int   `json:"linesUnparsable"`
	ReadErrors       int   `json:"readErrors"`
	ExpiredNotListed int   `json:"expiredNotListed"`
}

Stats counts what the collector looked at, so a zero is distinguishable from "could not read".

type TargetKind

type TargetKind string

TargetKind says what a tell was addressed to.

const (
	TargetSession  TargetKind = "session"
	TargetResource TargetKind = "resource"
)

type Tell

type Tell struct {
	Target     string     `json:"target"` // the session short id or the repo key
	TargetKind TargetKind `json:"targetKind"`
	From       string     `json:"from"` // sender session id
	Text       string     `json:"text"` // truncated
	At         time.Time  `json:"at"`
}

Tell is one `agentsync tell` message.

Jump to

Keyboard shortcuts

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