agent

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 11 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 agent is the contract between the hopsesh core and its agent modules. A module knows one coding agent (Claude Code, Codex, ...): where it keeps sessions, how they are listed, moved, resumed and converted. The core knows none of that; it owns all I/O, transport, safety, conversion and the user interfaces, and hands each module a Host.

A module is a Spec (data the core acts on before running module code) plus the Module interface, plus any optional capability interfaces it implements. Modules hold no state and never import os, os/exec, net, path/filepath or the core: everything goes through the Host, so every write is confined, journaled and undoable.

Index

Constants

View Source
const NotePrefix = "[hopsesh] "

NotePrefix begins every message hopsesh itself adds to a conversation (a move's first prompt, a continuation's briefing). Session lists do not show such a message as the user's last prompt.

Variables

View Source
var (
	ErrNotInstalled    = errors.New("the agent is not installed there")
	ErrNotFound        = errors.New("session not found")
	ErrLive            = errors.New("the session is open")
	ErrUnsupported     = errors.New("not supported")
	ErrAccountMismatch = errors.New("signed in to a different account")
	ErrDiverged        = errors.New("both copies changed")
	ErrDenied          = errors.New("denied by the host")
)

Errors a module returns, wrapped with detail. The user interfaces map each to a state; modules never invent other top-level kinds.

Functions

func Expand

func Expand(p, home string, roots map[string]string, pa Path) string

Expand replaces a leading "~" with home and "{name}" with resolved roots.

func Has

func Has(m Module, c Capability) bool

Has reports whether a module has a capability.

func IsExperimental

func IsExperimental(m Module, c Capability) bool

IsExperimental reports whether a module marks a capability experimental.

func MarkPrefixes

func MarkPrefixes() []string

MarkPrefixes are the beginnings of every mark title (for dropping marks from a copy that moves on).

func MarkTitle

func MarkTitle(m Mark, title string) string

MarkTitle is the title of a copy left behind; MarkContinued uses m.AgentName ("Codex").

func OwnText

func OwnText(text string) string

OwnText is the person's own part of a user message: "" for a message hopsesh added, and the text before hopsesh's note when one was added to the person's last message (a continuation's briefing joins it so that roles keep alternating).

func StagedKey

func StagedKey(f PlacedFile) string

StagedKey names a placed file in Module.Verify's staged map.

func VersionOf

func VersionOf(line string) string

VersionOf extracts a dotted version ("2.1.284") from a --version line.

Types

type Account

type Account struct {
	Key   string `json:"key"`             // compared for equality only
	Label string `json:"label,omitempty"` // for people: "Max plan", "Team org"
	// RemoteControl is whether this login can use the agent's own remote control.
	RemoteControl bool   `json:"remoteControl"`
	Why           string `json:"why,omitempty"` // why not
}

Account is an opaque, hashed account identity (never a credential).

type AccountProber

type AccountProber interface {
	Account(ctx context.Context, h Host, in Install) (Account, error)
}

AccountProber identifies the login the agent uses on a machine, without reading credentials.

type AppendOptions

type AppendOptions struct {
	NewLine   bool // start on a new line if the file does not end with one
	KeepMtime bool // restore the modification time (marks must not look like activity)
	// Standalone: nothing written after these bytes builds on them (a title record, a
	// line in an index every session shares), so undo takes them out from between later
	// lines. Otherwise (a session's new turns) later lines continue from them, and undo
	// counts them as the file being used since.
	Standalone bool
}

AppendOptions control FS.Append.

type Binary

type Binary struct {
	Name string // "claude"
	// Candidates are extra places to look besides PATH, by GOOS ("*" for all); "~" is the
	// home folder.
	Candidates  map[string][]string
	VersionArgs []string // ["--version"]
}

Binary is a program the module may run.

type BinaryFact

type BinaryFact struct {
	Path    string `json:"path"`
	Version string `json:"version,omitempty"` // first line of VersionArgs output
}

BinaryFact is a binary found on a machine.

type Bundle

type Bundle struct {
	Files []BundleFile `json:"files"`
}

Bundle is every file of one session.

func (Bundle) Main

func (b Bundle) Main() (BundleFile, bool)

Main returns the bundle's main file.

type BundleFile

type BundleFile struct {
	Root     string      `json:"root"`
	Rel      string      `json:"rel"` // slash-separated
	Size     int64       `json:"size"`
	Role     FileRole    `json:"role"`
	Rewrite  RewriteKind `json:"rewrite"`
	Growable bool        `json:"growable,omitempty"` // may still be appended to while copied
}

BundleFile is one file of a session, relative to a root of its install.

type Capability

type Capability string

Capability names something a module can do beyond the required interface.

const (
	CapLive          Capability = "live"           // LiveDetector
	CapStop          Capability = "stop"           // Stopper
	CapMark          Capability = "mark"           // Marker: the agent's own "moved" mark
	CapAccount       Capability = "account"        // AccountProber
	CapSanitize      Capability = "sanitize"       // Sanitizer: same-agent move to another account
	CapPostInstall   Capability = "post-install"   // PostInstaller
	CapRead          Capability = "read"           // Reader: a conversion source
	CapWrite         Capability = "write"          // Writer: a conversion target
	CapNativeReplay  Capability = "native-replay"  // Writer renders tool calls natively (Profile.NativeReplay)
	CapIntegrate     Capability = "integrate"      // Integrator: skill and approval rules
	CapFork          Capability = "fork"           // Resume honours ResumeOptions.Fork (Spec.Features)
	CapRemoteControl Capability = "remote-control" // Resume honours ResumeOptions.RemoteControl (Spec.Features)
	CapApp           Capability = "app"            // Resume honours ResumeOptions.App (Spec.Features)
	CapNotify        Capability = "notify"         // Notifier: the resumed session tells the old one
	CapImport        Capability = "import"         // Importer: the agent converts another agent's sessions itself
)

func Capabilities

func Capabilities(m Module) []Capability

Capabilities lists what a module can do, from the interfaces it implements and the features its Spec declares.

type Command

type Command struct {
	Argv []string `json:"argv"`
	Dir  string   `json:"dir"`
}

Command is a program to run, never a shell string; the core quotes it for the user's shell.

type ElemMatch

type ElemMatch struct {
	Array  string   `json:"array"` // "message.content"
	Field  string   `json:"field"`
	Values []string `json:"values"`
}

ElemMatch matches elements of the array at Array (dot path) by a string field.

type Exec

type Exec interface {
	Run(ctx context.Context, argv []string, o RunOptions) (Result, error)
}

Exec runs the module's Spec binaries on the machine.

type FS

type FS interface {
	Stat(p string) (fs.FileInfo, error)
	ReadDir(p string) ([]fs.FileInfo, error)
	Open(p string) (File, error)
	// RealPath resolves symbolic links (agents key sessions by the real working directory).
	RealPath(p string) (string, error)
	// ReadFile reads a whole file, failing if it is larger than limit bytes.
	ReadFile(p string, limit int64) ([]byte, error)
	// WriteFile replaces a file atomically, creating parent folders. Journaled.
	WriteFile(p string, b []byte, perm fs.FileMode) error
	// Append adds bytes at the end of a file, creating it (and parent folders) when it does
	// not exist. Journaled: undo takes out these bytes, and refuses while anything follows
	// them unless they are Standalone.
	Append(p string, b []byte, o AppendOptions) error
	// Rename moves a file within the module's roots. Journaled.
	Rename(from, to string) error
}

FS is a machine's filesystem, with that machine's absolute paths.

type Facts

type Facts struct {
	Machine string `json:"machine"` // the name hopsesh knows it by
	Local   bool   `json:"local"`   // this machine
	OS      string `json:"os"`      // darwin | linux | windows
	Arch    string `json:"arch"`
	Home    string `json:"home"`
	// Env holds the variables the module's Spec declares (Roots[].Env, LoginEnv), as set on
	// that machine ("" when unset).
	Env map[string]string `json:"env"`
	// Binaries are the module's Spec binaries as found there.
	Binaries map[string]BinaryFact `json:"binaries"`
}

Facts is what the core learned about a machine in one probe.

type FieldMatch

type FieldMatch struct {
	Field    string   `json:"field"` // a dot path into the record ("payload.type")
	Values   []string `json:"values,omitempty"`
	Prefixes []string `json:"prefixes,omitempty"`
}

FieldMatch matches a record by a top-level string field: equal to one of Values, or starting with one of Prefixes.

type File

type File interface {
	io.Reader
	io.ReaderAt
	io.Closer
	Stat() (fs.FileInfo, error)
}

File is an open file with random access.

type FileRole

type FileRole string

FileRole says what a bundle file is.

const (
	RoleMain FileRole = "main" // the session transcript the agent resumes
	RoleSide FileRole = "side" // anything else the session needs (subagents, tool output, history)
)

type FormatError

type FormatError struct {
	Path string
	Line int // 1-based, 0 when unknown
	Err  error
}

FormatError is native data a module could not read.

func (*FormatError) Error

func (e *FormatError) Error() string

func (*FormatError) Unwrap

func (e *FormatError) Unwrap() error

type Host

type Host interface {
	Facts() Facts
	FS() FS
	Exec() Exec
	Path() Path
	Locks() Locks
	Procs() Procs
	Log() *slog.Logger
}

Host is a module's only way to reach a machine: this one, or another over SSH. The core confines it to the module's Spec: writes only under its roots (and journaled for undo), no reads of its Secrets, and only its Binaries run.

func Confine

func Confine(h Host, s Spec, in Install) Host

Confine wraps a Host so a module can write only under its install's roots, never opens its Spec's Secrets (paths, or patterns with * ? [), and runs only its Spec's Binaries. The core gives every module a confined Host; the conformance kit does the same.

type ID

type ID string

ID names an agent module: lower case letters and digits, 2 to 16 characters.

type Icon

type Icon struct {
	// SVG is a mark drawn for hopsesh: a complete <svg> document with no scripts or
	// external references. It must not reproduce a vendor's logo or trademark.
	SVG string
	// Apps are where the agent's desktop app may be installed, by GOOS ("~" is the home
	// folder): a macOS .app bundle or a Windows .exe. Its icon is read from this machine
	// and never shipped.
	Apps map[string][]string
}

Icon pictures an agent. The installed desktop app's own icon comes first (unless the user turns that off), then the module's mark, then the agent's initials.

type Importer

type Importer interface {
	CanImport(from ID) bool
	// Import converts the session file at path (on h's machine) into a new session of this
	// agent and returns its id.
	Import(ctx context.Context, h Host, in Install, from ID, path, cwd, title string) (SessionID, error)
}

Importer is the agent's own importer of another agent's sessions: it converts a native session file itself, an alternative to the core's conversion through Writer.

type Install

type Install struct {
	Agent   ID                `json:"agent"`
	Version string            `json:"version,omitempty"` // "" when the binary was not found
	Binary  string            `json:"binary,omitempty"`  // absolute path
	Roots   map[string]string `json:"roots"`             // name → absolute path on that machine
	Present bool              `json:"present"`           // the main root exists
}

Install is an agent as found on one machine.

func DefaultInstall

func DefaultInstall(s Spec, h Host) Install

DefaultInstall resolves a Spec's roots and first binary from a machine's facts.

func (Install) Root

func (in Install) Root(name string) string

Root returns the path of a named root.

type Integration

type Integration struct {
	SkillDir string    // folder that holds skills ("~/.claude/skills"); the skill goes in SkillDir/hopsesh
	Rules    *RuleFile // nil when the agent has no rules the core can manage
}

Integration is an agent's integration points.

type Integrator

type Integrator interface {
	Integration(h Host, in Install) Integration
}

Integrator says where the shared hopsesh skill goes for this agent, and how the agent is told which hopsesh commands may run without asking.

type Listing

type Listing struct {
	Sessions []Summary
	Errors   []SessionError
}

Listing is the result of Module.List.

type LiveDetector

type LiveDetector interface {
	Live(ctx context.Context, h Host, in Install, ids []SessionID) (map[SessionID]LiveInfo, error)
}

LiveDetector reports which sessions are open right now.

type LiveInfo

type LiveInfo struct {
	State  Liveness `json:"state"`
	PID    int      `json:"pid,omitempty"`
	Status string   `json:"status,omitempty"` // agent words: "busy", "waiting for input"
}

LiveInfo describes a live session.

type Liveness

type Liveness string

Liveness says whether a session is open right now.

const (
	Live    Liveness = "live"
	Ended   Liveness = "ended"
	Unknown Liveness = "unknown"
)

type LockState

type LockState string

LockState is what a lock probe found.

const (
	LockHeld    LockState = "held"
	LockFree    LockState = "free"
	LockUnknown LockState = "unknown"
)

type Locks

type Locks interface {
	Probe(ctx context.Context, paths []string) (map[string]LockState, error)
	// Holders returns the processes holding each lock file (none when it is free). A machine
	// that cannot tell returns ErrUnsupported.
	Holders(ctx context.Context, paths []string) (map[string][]int, error)
}

Locks probes advisory file locks without taking them.

type Mapping

type Mapping struct {
	From  string `json:"from"`
	To    string `json:"to"`
	ToSep string `json:"toSep,omitempty"` // also convert separators after a match ("/" or `\`)
}

Mapping replaces an absolute path prefix (as it appears on the source) with another.

type Mark

type Mark struct {
	Kind     MarkKind `json:"kind"`
	Location string   `json:"location,omitempty"` // where it went: a machine name (later also a cloud)
	Agent    ID       `json:"agent,omitempty"`    // the agent it continues in (MarkContinued)
	// AgentName is that agent's display name, as a mark title carries it (the core
	// resolves Agent from it).
	AgentName string `json:"agentName,omitempty"`
}

Mark describes a copy left behind.

func ParseMarkTitle

func ParseMarkTitle(t string) (Mark, string, bool)

ParseMarkTitle reads a mark title back: the mark (AgentName set for MarkContinued), the original title, and ok=false when t is an ordinary title.

type MarkKind

type MarkKind string

MarkKind says why a copy was left behind.

const (
	MarkMoved     MarkKind = "moved"     // the session moved to another location
	MarkContinued MarkKind = "continued" // the session continues in another agent
)

type Marker

type Marker interface {
	Mark(ctx context.Context, h Host, in Install, s Summary, m Mark) error
}

Marker records, in the agent's own data, that a copy was left behind ("↪ moved to …"), so the agent's own session list shows it. The core's lineage manifest records it in any case.

type Module

type Module interface {
	Spec() Spec

	// Detect turns the probe facts of a machine into an Install. Most modules return
	// DefaultInstall(spec, facts) with checks of their own.
	Detect(ctx context.Context, h Host) (Install, error)

	// List returns the sessions on the machine. One unreadable session goes in
	// Listing.Errors; only a failure to list at all returns an error.
	List(ctx context.Context, h Host, in Install) (Listing, error)

	// Bundle names the files that make up one session.
	Bundle(ctx context.Context, h Host, in Install, s Summary) (Bundle, error)

	// PlanMove places a bundle on the target (pure): where each file goes, how it is
	// rewritten, and records to append. src and dst are the same agent's installs.
	PlanMove(src, dst Install, s Summary, b Bundle, p Placement) (MovePlan, error)

	// Verify checks staged files (already rewritten, on the target machine) before they are
	// installed, for example that the session's working directory is the target's.
	Verify(ctx context.Context, h Host, mp MovePlan, staged map[string]string, p Placement) error

	// Resume is how the user continues a session on this machine.
	Resume(in Install, key SessionKey, p Placement, o ResumeOptions) Command
}

Module is what every agent module implements.

type MovePlan

type MovePlan struct {
	Files  []PlacedFile  `json:"files"`
	Policy RewritePolicy `json:"policy"`
}

MovePlan is how a module places a bundle on the target.

type Notifier

type Notifier interface {
	NotifyInstruction(oldName, oldLocation, newName string, fork bool) string
}

Notifier lets a resumed session tell the copy left behind that the work moved on. The text is added to the new session's first message; the agent itself delivers it.

type Path

type Path interface {
	Join(elem ...string) string
	Base(p string) string
	Dir(p string) string
	Clean(p string) string
	IsAbs(p string) bool
	// Rel returns target relative to base, or ok=false when it is not inside it.
	Rel(base, target string) (string, bool)
	Sep() string
}

Path manipulates paths in the machine's own form (a Windows machine seen from a Mac uses backslashes and drive letters).

func PathFor

func PathFor(goos string) Path

PathFor returns the path rules of an operating system.

type PlacedFile

type PlacedFile struct {
	From   BundleFile `json:"from"`
	ToRoot string     `json:"toRoot"`
	ToRel  string     `json:"toRel"`
	// Append are complete records (without newline) added after the rewrite.
	Append [][]byte `json:"-"`
}

PlacedFile is a bundle file with its destination.

type Placement

type Placement struct {
	Key      SessionKey `json:"key"` // the session's key on the target (renamed for keep-both)
	SourceID SessionID  `json:"sourceId"`
	CWD      string     `json:"cwd"`   // the working directory on the target
	Title    string     `json:"title"` // title to give the copy ("" keeps it)
	// Name is the session's own name, for agents that keep names outside the session's
	// files (they record it again after installing; "" when it has none).
	Name     string    `json:"name,omitempty"`
	Mappings []Mapping `json:"mappings"`
	Location string    `json:"location"` // where the session lands: this machine's name
	// OtherAccount: the target is signed in to another account than the source, so
	// account-bound content must be removed (the module's Sanitizer policy applies).
	OtherAccount bool `json:"otherAccount,omitempty"`
}

Placement is what the core decided about where a session lands on the target.

type PosixPath

type PosixPath struct{}

PosixPath is the path form of macOS and Linux.

func (PosixPath) Base

func (PosixPath) Base(p string) string

func (PosixPath) Clean

func (PosixPath) Clean(p string) string

func (PosixPath) Dir

func (PosixPath) Dir(p string) string

func (PosixPath) IsAbs

func (PosixPath) IsAbs(p string) bool

func (PosixPath) Join

func (PosixPath) Join(elem ...string) string

func (PosixPath) Rel

func (PosixPath) Rel(base, target string) (string, bool)

func (PosixPath) Sep

func (PosixPath) Sep() string

type PostInstaller

type PostInstaller interface {
	AfterInstall(ctx context.Context, h Host, in Install, key SessionKey, p Placement) error
}

PostInstaller runs after a session was installed (for example to make the agent index it).

type Procs

type Procs interface {
	Alive(ctx context.Context, pids []int) (map[int]bool, error)
	// Names returns the program name of each running process ("codex"); exited ones are
	// left out.
	Names(ctx context.Context, pids []int) (map[int]string, error)
	// Terminate asks a process to exit (SIGTERM; unsupported on Windows).
	Terminate(ctx context.Context, pid int) error
}

Procs checks and stops processes on the machine.

type Reader

type Reader interface {
	Read(ctx context.Context, h Host, in Install, s Summary, from ir.Cursor) (ir.Segment, error)
}

Reader lifts a session into the conversation IR, from a cursor (incremental reads for round trips).

type Result

type Result struct {
	Stdout []byte
	Stderr []byte
	Code   int
}

Result is a finished command. A non-zero exit is not an error.

type ResumeOptions

type ResumeOptions struct {
	Fork          bool
	RemoteControl bool
	App           bool   // open in the agent's desktop app instead of the terminal
	Name          string // a name for Remote Control / the session list
	Prompt        string // a first message, "" for none
}

ResumeOptions shape the resume command.

type RewriteKind

type RewriteKind string

RewriteKind says how the core rewrites paths in a file.

const (
	RewriteJSONL RewriteKind = "jsonl" // JSON lines: string values only, with the module's policy
	RewriteText  RewriteKind = "text"  // plain text
	RewriteNone  RewriteKind = "none"  // copied byte for byte
)

type RewritePolicy

type RewritePolicy struct {
	// Protect: string values under these object keys are never changed (signatures,
	// encrypted content, opaque blobs).
	Protect []string `json:"protect,omitempty"`
	// DropRecords removes whole records whose top-level field has one of the values.
	DropRecords []FieldMatch `json:"dropRecords,omitempty"`
	// DropElems removes array elements (only when Placement.OtherAccount, via Sanitizer).
	DropElems []ElemMatch `json:"dropElems,omitempty"`
	// Rename gives a keep-both copy a new session id ({"old","new"}; empty for none): the id
	// changes inside every rewritable string, and in the RenameKeys fields even when they
	// are protected.
	Rename     [2]string `json:"rename,omitempty"`
	RenameKeys []string  `json:"renameKeys,omitempty"`
}

RewritePolicy is data the core's JSON rewriter applies to RewriteJSONL files.

type Root

type Root struct {
	Name string   // "home"
	Env  []string // overriding variables, first set wins: ["CLAUDE_CONFIG_DIR"]
	// Default is the folder when no variable is set, by GOOS ("*" for all); "~" is the home
	// folder, "{name}" another root.
	Default map[string]string
}

Root is one data folder of the agent.

type RuleFile

type RuleFile struct {
	Path string
	// Owned: hopsesh writes the whole file (Render). Otherwise it is the agent's shared
	// settings file, edited with Merge and checked with Has.
	Owned  bool
	Render func(r Rules) []byte
	Merge  func(existing []byte, r Rules) ([]byte, error)
	Has    func(existing []byte, r Rules) bool
	Remove func(existing []byte, r Rules) ([]byte, error)
}

RuleFile is where an agent keeps approval rules.

type Rules

type Rules struct {
	Bin   string     // the command as the agent runs it ("hopsesh")
	Allow [][]string // run without asking: {"ls"}, {"show"}
	Ask   [][]string // ask first: {"pull"}, {"undo"}
}

Rules are hopsesh command prefixes (after the binary) by approval.

type RunOptions

type RunOptions struct {
	Dir   string
	Env   []string // extra KEY=value pairs
	Stdin []byte
	// HoldStdin keeps standard input open this long after Stdin is written (or until the
	// program exits, or its output contains StdinUntil), for programs that stop at the end
	// of their input before answering it.
	HoldStdin  time.Duration
	StdinUntil []byte
	Timeout    time.Duration
}

RunOptions control Exec.Run.

type Sanitizer

type Sanitizer interface {
	Sanitize() RewritePolicy
}

Sanitizer is the extra policy for a same-agent move to a machine signed in to another account (content bound to the source account is removed).

type SessionError

type SessionError struct {
	Path string
	Err  error
}

SessionError is one session that could not be read.

func (SessionError) Error

func (e SessionError) Error() string

type SessionID

type SessionID string

SessionID is an agent's own id for a session, opaque to the core.

type SessionKey

type SessionKey struct {
	Agent   ID        `json:"agent"`
	Session SessionID `json:"session"`
}

SessionKey identifies a session across agents: the only key the core, the lineage manifests and the user interfaces use.

func ParseKey

func ParseKey(s string) (SessionKey, error)

ParseKey parses "agent/session".

func (SessionKey) String

func (k SessionKey) String() string

type Spec

type Spec struct {
	ID        ID
	Name      string // "Claude Code"
	Vendor    string // "Anthropic"
	Stability Stability
	// Tested lists the agent versions this module was verified against, oldest first,
	// as version prefixes ("2.1"). Other versions work but are reported as untested.
	Tested []string
	// Binaries the module may run through Host.Exec (the first is the agent itself).
	Binaries []Binary
	// Roots are the agent's data folders. The first is the main one; writes are allowed
	// only under a root.
	Roots []Root
	// LoginEnv are environment variables a GUI app must adopt from the user's login shell
	// (an app started from Finder does not inherit them).
	LoginEnv []string
	// Secrets are root-relative paths ("{home}/auth.json") the Host never opens.
	Secrets []string
	// Worktrees are worktree folders the agent creates inside a repository
	// (".claude/worktrees"); git status ignores them.
	Worktrees []string
	// Instructions are the project instruction files the agent reads, in its order of
	// preference ("CLAUDE.md", "AGENTS.md"). A session continued in another agent is told
	// about files only the other agent read.
	Instructions []string
	// GlobalInstructions are the user's instructions for every project, root-relative
	// ("{home}/CLAUDE.md"). A continued session reports them, and carries them when asked.
	GlobalInstructions []string
	// Tools names the agent's own tools for people and for a continued session's briefing
	// ("shell, apply_patch, update_plan").
	Tools string
	// Features are capabilities without a method of their own: the module honours the
	// matching ResumeOptions (CapFork, CapRemoteControl) or start prompt (CapNotify).
	Features []Capability
	// Experimental marks capabilities that are not yet trustworthy; the user interfaces
	// say so and keep them opt-in.
	Experimental []Capability
	// Icon is how the user interfaces picture the agent (optional; its initials otherwise).
	Icon Icon
}

Spec is what a module declares as data. The core resolves roots, probes binaries, confines writes and refuses secret reads from it, before any module code runs.

func (Spec) TestedWith

func (s Spec) TestedWith(version string) bool

TestedWith reports whether a version matches one of the Spec's tested version prefixes.

type Stability

type Stability string

Stability says how far a module (or one of its capabilities) can be trusted.

const (
	Experimental Stability = "experimental"
	Stable       Stability = "stable"
)

type Stopper

type Stopper interface {
	Stop(ctx context.Context, h Host, in Install, s Summary, grace time.Duration) error
}

Stopper asks an open session to end, waiting up to grace.

type Summary

type Summary struct {
	Key         SessionKey `json:"key"`
	Title       string     `json:"title"`
	TitleSource string     `json:"titleSource,omitempty"` // custom | generated | prompt
	// CWD is the session's project folder, as the agent resumes it.
	CWD          string    `json:"cwd"`
	LastPrompt   string    `json:"lastPrompt,omitempty"`
	LastActivity time.Time `json:"lastActive"`
	Size         int64     `json:"size"`
	GitBranch    string    `json:"gitBranch,omitempty"`
	AgentVersion string    `json:"agentVersion,omitempty"` // the agent version that last wrote it
	// WorktreeRoot is set when CWD is a worktree the agent itself manages inside a
	// repository (for example <repo>/.claude/worktrees/<name>).
	WorktreeRoot string `json:"worktreeRoot,omitempty"`
	Subagents    int    `json:"subagents,omitempty"`
	// Mark is set when the agent's own data says this copy was left behind by a move.
	Mark *Mark `json:"mark,omitempty"`
	// Path is the session's main file on its machine (the lineage manifest sits beside it).
	Path string `json:"path"`
	// Account is the module's opaque account fingerprint for the session, when the agent
	// records one (bound reasoning cannot cross accounts).
	Account string `json:"account,omitempty"`
}

Summary describes one session, the same way for every agent.

type VersionError

type VersionError struct {
	Agent    ID
	Have     string
	Tested   []string
	Blocking bool
}

VersionError is an agent version the module cannot handle (Blocking) or has not been tested with.

func (*VersionError) Error

func (e *VersionError) Error() string

type WindowsPath

type WindowsPath struct{}

WindowsPath is the path form of Windows: drive letters, backslashes, and names compared without regard to case.

func (WindowsPath) Base

func (w WindowsPath) Base(p string) string

func (WindowsPath) Clean

func (w WindowsPath) Clean(p string) string

func (WindowsPath) Dir

func (w WindowsPath) Dir(p string) string

func (WindowsPath) IsAbs

func (WindowsPath) IsAbs(p string) bool

func (WindowsPath) Join

func (w WindowsPath) Join(elem ...string) string

func (WindowsPath) Rel

func (w WindowsPath) Rel(base, target string) (string, bool)

func (WindowsPath) Sep

func (WindowsPath) Sep() string

type Writer

type Writer interface {
	Profile(in Install) ir.Profile
	Write(ctx context.Context, h Host, in Install, req ir.WriteRequest) (ir.WriteResult, error)
}

Writer writes IR into the agent's native format: a new session, or an append to one it can extend.

Directories

Path Synopsis
Package agenttest is the conformance kit for agent modules: an in-memory Host and a suite every module must pass.
Package agenttest is the conformance kit for agent modules: an in-memory Host and a suite every module must pass.

Jump to

Keyboard shortcuts

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