otherapps

package
v0.219.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 17 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.

Documentation

Overview

Package otherapps answers "what did Caprock already bring over from the other agent tools on this computer": for each tool (Orca, Claude Code, the Claude and Codex apps, Codex, OpenCode, Cursor, T3 Code, Conductor, cmux), whether it is installed, how many of its sessions Caprock already holds, how many from the last seven days, and the most recent ones, with whether each is still running in the other app (.ai/28-other-apps.md).

The rules it keeps:

  • Read-only. It opens other tools' files for reading only (SQLite with immutable=1, so not even a -shm file is made) and writes nothing anywhere; Caprock's own database is only queried.
  • A session is attributed to an app only where that app's own data, or the marker the agent wrote into its own transcript, says so. Nothing is inferred from a folder name.
  • Never a secret. Each tool's file is decoded into the few fields named here (session ids, worktree paths, an originator, project names and folders); everything else in it — settings, environment values, cookies — is skipped by the decoder and never held, logged or returned.
  • What could not be read is counted and named on its source, never dropped, and never a failure of the whole scan.
  • Each app's reading can be switched off in Settings (Off).

Index

Constants

View Source
const (
	Orca       = "orca"
	ClaudeCode = "claude-code"
	ClaudeApp  = "claude-app"
	Codex      = "codex"
	CodexApp   = "codex-app"
	OpenCode   = "opencode"
	Cursor     = "cursor"
	Gemini     = "gemini"
	T3Code     = "t3code"
	Conductor  = "conductor"
	Cmux       = "cmux"
)

Source ids, stable: they are the keys of the Settings switch (other_apps_off) and of the card's rows.

View Source
const (

	// RecentWindow is "the last seven days" of the card.
	RecentWindow = 7 * day
	// MarkerWindow bounds the transcripts whose heads are read for an app's
	// marker: a session older than this is counted under its agent only.
	MarkerWindow = 30 * day

	// RecentMax is how many sessions the card lists.
	RecentMax = 8
)
View Source
const HistoryMax = 50

HistoryMax is how many gone threads the report lists, newest first.

View Source
const OpenMax = 24

OpenMax bounds the set "Open what was open in Orca" brings back.

View Source
const ProjectsMax = 200

ProjectsMax bounds the offer.

Variables

Order is the order sources are reported in: the apps people move from first, then the agents underneath them.

Functions

func ChecksProcess

func ChecksProcess(agent string) bool

ChecksProcess is whether an agent's sessions are judged by this check (the agents whose processes Caprock cannot otherwise see).

func Name

func Name(id string) string

Name is a source's display name.

func Switchable

func Switchable(id string) bool

Switchable reports whether a source has its own reading the Settings switch turns off. The agents' own sessions are Caprock's ordinary history; the switch is for what this scan reads in another tool's folder.

Types

type Env

type Env struct {
	Home string
	// GOOS picks the per-OS folders ("darwin", "windows", "linux").
	GOOS string
	// AppData, LocalAppData and ConfigHome are %APPDATA%, %LOCALAPPDATA%
	// and $XDG_CONFIG_HOME; empty falls back to the usual place under Home.
	AppData, LocalAppData, ConfigHome string
	// Applications is where macOS apps are installed (/Applications).
	Applications string
	Now          time.Time
	Off          map[string]bool
	Rows         []Row
	// Origins remembers what a transcript's head said, across scans: the
	// marker is written once, at the top, and never changes.
	Origins *OriginCache
	// Procs is the agents' live processes (live.go); nil when the table is
	// not available, and then a Codex, OpenCode, Cursor or Hermes session not
	// ended counts as running while its agent wrote in the last ten minutes.
	Procs *Procs
	// Root is the folder a project at dir would have (its repository's root,
	// as Add a project lists it); nil keeps dir. Known reports a folder
	// Caprock has a project for, listed or removed; nil knows none. Both
	// serve the projects offer (projects.go).
	Root  func(dir string) string
	Known func(root string) bool
}

Env is everything a scan reads from outside: the folders, the clock, the switches and Caprock's own rows. Tests build one over a fake HOME.

type HistoryItem

type HistoryItem struct {
	Role string `json:"role"` // "user" or "agent"
	Text string `json:"text"`
	At   int64  `json:"at"` // unix ms
}

HistoryItem is one message of a gone Codex thread.

func CodexHistory

func CodexHistory(env Env, id string) (items []HistoryItem, ok bool, err error)

CodexHistory reads the messages of one Codex thread from Codex's history store, read-only: what the user typed and what the agent answered, never tool output. ok is false when Codex holds no such thread.

type HistoryThread

type HistoryThread struct {
	ID         string `json:"id"`
	Title      string `json:"title"`
	Cwd        string `json:"cwd,omitempty"`
	Source     string `json:"source"`
	SourceName string `json:"source_name"`
	UpdatedAt  int64  `json:"updated_at"` // unix ms
}

HistoryThread is a Codex thread whose transcript is gone: readable, never continued.

type Live

type Live struct {
	State LiveState
	// ByID is whether the session's id is on the process's command line (as
	// opposed to its folder only).
	ByID bool
	// Host names a process that serves many sessions ("codex app-server").
	Host string
}

Live is the check's answer, with what decided it.

type LiveState

type LiveState int

LiveState is what the process table says about one session.

const (
	// NotRunning: the table was read and no process of the agent is on it.
	NotRunning LiveState = iota
	// Running: a process of the agent carries its id or runs in its folder.
	Running
	// CannotTell: a process of the agent could hold it, and nothing says
	// whether it does.
	CannotTell
	// NoTable: the process table is not available here.
	NoTable
)

type NameCarry

type NameCarry struct {
	SessionID, Source, Name string
}

NameCarry is one session's name in another app.

type OriginCache

type OriginCache struct {
	// contains filtered or unexported fields
}

OriginCache remembers each transcript's marker for the daemon's life.

func NewOriginCache

func NewOriginCache() *OriginCache

NewOriginCache makes an empty cache.

type Process

type Process struct {
	PID   int32
	Agent string // "codex", "opencode", "cursor", "hermes"
	Argv  []string
	// Cwd is its working folder; "" when it could not be read.
	Cwd string
	// Unread is whether its command line could not be read.
	Unread bool
}

Process is one live process as the check needs it.

type Procs

type Procs struct {
	// contains filtered or unexported fields
}

Procs is the agents' processes at one moment. A nil *Procs is a table that could not be read.

func NewProcs

func NewProcs(list []Process) *Procs

NewProcs builds a table from known processes (tests, and ReadProcs).

func ReadProcs

func ReadProcs(ctx context.Context) (*Procs, error)

ReadProcs reads the agents' processes from the machine's table: only this user's, and only command lines and folders, never their environment.

func (*Procs) Check

func (p *Procs) Check(agent, cwd string, ids ...string) Live

Check is what the table says about the session ids (Caprock's and the agent's own) of agent, run in cwd.

type ProcsCache

type ProcsCache struct {
	// contains filtered or unexported fields
}

ProcsCache reads the table at most once a few seconds: one answer serves every row of a card, and every resume check made while it is fresh.

func NewProcsCache

func NewProcsCache(ttl time.Duration) *ProcsCache

NewProcsCache caches ReadProcs for ttl.

func (*ProcsCache) Get

func (c *ProcsCache) Get(ctx context.Context) *Procs

Get is the table, nil when it cannot be read.

type ProjectOffer added in v0.218.0

type ProjectOffer struct {
	Source     string `json:"source"`
	SourceName string `json:"source_name"`
	Name       string `json:"name"`
	// Path is the folder POST /v1/projects {"path"} adds; with Repos (two or
	// more), the repositories of one project, the first its home
	// (POST /v1/projects {"repos", "name"}).
	Path   string   `json:"path"`
	Repos  []string `json:"repos,omitempty"`
	Pinned bool     `json:"pinned,omitempty"`
}

ProjectOffer is one project another app lists that Caprock does not have.

type Report

type Report struct {
	// Sessions is how many sessions from other tools Caprock holds, each
	// counted once; Recent7d how many of them moved in the last seven days.
	Sessions int       `json:"sessions"`
	Recent7d int       `json:"recent_7d"`
	Sources  []Source  `json:"sources"`
	Recent   []Session `json:"recent"`
	// Open is what was open in Orca's tabs, workspace by workspace, in
	// Orca's order: the set "Open what was open in Orca" brings back.
	Open []Session `json:"open"`
	// History is Codex's threads whose transcript files are gone: readable
	// from Codex's own history store, never continued.
	History []HistoryThread `json:"history"`
	// Projects is what Orca and the Codex app list as projects that Caprock
	// has no project for: offered, never added without the person's click.
	Projects []ProjectOffer `json:"projects"`
	// Home is the home folder the scan looked in, so a client can show a
	// project's folder as ~/….
	Home string `json:"home,omitempty"`
	At   int64  `json:"at"`
	// Names is each session another app names, for the daemon to carry
	// into Caprock (store.CarryOtherAppNames); not part of the answer.
	Names []NameCarry `json:"-"`
}

Report is the answer of GET /v1/other-apps.

func Scan

func Scan(env Env) Report

Scan builds the report. It never fails: what it could not read is in the sources' Problems and NotRead.

type Row

type Row struct {
	SessionID      string
	NativeID       string
	Agent          string
	Cwd            string
	RepoPath       string
	Project        string
	Title          string
	Name           string
	Status         string
	TranscriptPath string
	LastEventAt    int64 // unix ms
}

Row is one session Caprock holds that it did not start itself.

type Session

type Session struct {
	SessionID    string `json:"session_id"`
	Title        string `json:"title"`
	Repo         string `json:"repo,omitempty"`
	Cwd          string `json:"cwd,omitempty"`
	Agent        string `json:"agent"`
	Source       string `json:"source"`
	SourceName   string `json:"source_name"`
	LastActivity int64  `json:"last_activity"`
	// Running says the session looks alive in another app: its agent wrote
	// to it moments ago and it has not ended, or the app lists it as live.
	// RunningIn names that app.
	Running   bool   `json:"running"`
	RunningIn string `json:"running_in,omitempty"`
	// Name is what the app that started it calls it (an Orca tab's name, a
	// Codex thread's, a T3 Code chat's); Pinned and Archived are its marks
	// there; Group and GroupID the Orca workspace it sits in; Open that an
	// Orca tab shows it.
	Name     string `json:"name,omitempty"`
	Pinned   bool   `json:"pinned,omitempty"`
	Archived bool   `json:"archived,omitempty"`
	Group    string `json:"group,omitempty"`
	GroupID  string `json:"group_id,omitempty"`
	Open     bool   `json:"open,omitempty"`
}

Session is one of the recent sessions the card offers to continue.

type Source

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Kind is "agent" (its sessions are its own files, which Caprock reads)
	// or "app" (it runs agents; its sessions are counted by attribution).
	Kind      string `json:"kind"`
	Installed bool   `json:"installed"`
	// Switchable says Settings has a switch for this source; Off that it is
	// turned off, in which case nothing in its folder was read.
	Switchable bool `json:"switchable"`
	Off        bool `json:"off"`
	Sessions   int  `json:"sessions"`
	Recent7d   int  `json:"recent_7d"`
	// CountedSince (unix ms) is set when only sessions from then on were
	// looked at for this source (the apps attributed by transcript marker);
	// 0 means all of them.
	CountedSince int64 `json:"counted_since,omitempty"`
	// NotRead is how many sessions the tool itself lists that Caprock does
	// not hold, and NotReadWhy why, in a few words.
	NotRead    int    `json:"not_read,omitempty"`
	NotReadWhy string `json:"not_read_why,omitempty"`
	// Imported is false for a tool whose own chats are not brought over at
	// all yet; Note says so in a sentence.
	Imported bool   `json:"imported"`
	Note     string `json:"note,omitempty"`
	// Problems names each file that was there and could not be read.
	Problems []string `json:"problems,omitempty"`
}

Source is one tool.

Jump to

Keyboard shortcuts

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