Documentation
¶
Overview ¶
Package sessions finds the conversations agents saved for a directory, so conch can list and resume them. Each agent keeps its own store; this package only reads them:
- Claude Code: ~/.claude/projects/<encoded dir>/<session id>.jsonl
- Codex: ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl (session_meta first)
- Gemini CLI: ~/.gemini/tmp/<project>/chats/session-*.json
- OpenCode: ~/.local/share/opencode/opencode.db (sqlite), or the older storage/session/*/*.json files
- Copilot CLI: ~/.copilot/session-state/<session id>/events.jsonl
- Cline: ~/.cline/data/sessions/<id>/<id>.json and <id>.messages.json
- Qwen Code: ~/.qwen/projects/<encoded dir>/chats/<session id>.jsonl
- Goose: ~/.local/share/goose/sessions/sessions.db (sqlite)
Index ¶
- Constants
- Variables
- func AgentName(agent string) string
- func CheckReadBack(sent, got Conversation) error
- func CodexRollout(e Env, id string) string
- func ConductorDB(home string) string
- func Delete(ctx context.Context, e Env, s Session, trashDir string) error
- func Handoff(c Conversation) string
- func Key(s Session) string
- func Match(ctx context.Context, e Env, list []Session, query string) map[string]string
- func Measure(c Conversation, budget int) (Conversation, Crossing)
- func Reads(agent string) bool
- func RemoveSwitchRecord(dir, stamp string) error
- type Account
- type ChatTurn
- type ChatUpdate
- type ClaudeWriter
- func (ClaudeWriter) Agent() string
- func (w ClaudeWriter) Append(ctx context.Context, im Imported, dir, sid, path, after string) (int, error)
- func (w ClaudeWriter) Check(ctx context.Context, im Imported, dir string) error
- func (w ClaudeWriter) Filed(path, cwd string) bool
- func (w ClaudeWriter) Folder(cwd string) string
- func (w ClaudeWriter) Move(path, cwd string) (string, error)
- func (w ClaudeWriter) Original(id string) (path, cwd string)
- func (ClaudeWriter) ReadBack(ctx context.Context, wr Written) (Conversation, error)
- func (w ClaudeWriter) Write(ctx context.Context, im Imported, dir string) (string, string, error)
- func (w ClaudeWriter) WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
- type CodexImporter
- type CodexWriter
- type Conversation
- type ConversationWriter
- type Crossing
- type Env
- type GeminiWriter
- type ImportOutcome
- type ImportRecord
- type ImportState
- type ImportStatus
- type Imported
- type ImportedMessage
- type Item
- type Kind
- type Plan
- type PlanStep
- type QwenWriter
- type RecordedFile
- type Session
- type SessionAppender
- type SessionWriter
- type SwitchRecord
- type Turn
- type Written
Constants ¶
const ( ViaImporter = "codex import" // Codex's own import of a Claude Code session ViaWriter = "conch" // a session conch wrote )
Ways a conversation was written (Switched.Via).
const SwitchBudget = 400 << 10
SwitchBudget is how much of a conversation crosses, in bytes of text: a little over 100k tokens, which leaves room in Claude Code's context (200k) and Codex's (272k) for the work that follows.
Variables ¶
var ErrNoImporter = errors.New("this Codex cannot import a Claude Code session itself")
ErrNoImporter says the Codex here cannot import a Claude Code session itself: too old, not installed, or the session is not where Codex looks.
Functions ¶
func CheckReadBack ¶ added in v0.2.3
func CheckReadBack(sent, got Conversation) error
CheckReadBack says whether what was read back of a written session is what was meant to be written: every message, every command.
func CodexRollout ¶ added in v0.2.1
CodexRollout is the file Codex keeps thread id in, in this environment's Codex home (CODEX_HOME, else ~/.codex), or "" when it has none: rollout-TIME-ID.jsonl under its sessions folder. Only that home, since `codex resume` started by conch reads only it.
func ConductorDB ¶ added in v0.2.1
ConductorDB is where Conductor keeps its database on a Mac.
func Delete ¶
Delete removes a saved session: files move to trashDir (so a mistake can be undone), OpenCode's database entries are deleted through its CLI.
func Handoff ¶
func Handoff(c Conversation) string
Handoff renders a conversation as a Markdown document another agent can read to continue the work: where it stands (the open plan, the files changed, the last error), then every turn — the messages word for word, the commands run with their output cut, and the files read and edited and other tools as notes. A long message is cut; when the whole conversation is too long, the first request and the latest turns are kept whole and the turns between them shortened, the oldest of them left out if even that is too much.
func Match ¶
Match finds the sessions whose title, branch, agent, ID or conversation contains every word of query (case-insensitive). For conversation matches the result has a snippet around the first word; metadata matches have an empty snippet. The map is keyed by Key(session).
func Measure ¶ added in v0.2.3
func Measure(c Conversation, budget int) (Conversation, Crossing)
Measure says what switching c to another agent would carry, fitted to budget.
func Reads ¶ added in v0.2.3
Reads reports whether conch reads agent's saved sessions: every supported agent, and those it only runs whose files have been read off the real agent (Kilo Code, Pi, Grok, Cursor, Antigravity). An agent it does not read is said to have none rather than shown an empty list.
func RemoveSwitchRecord ¶ added in v0.2.3
RemoveSwitchRecord removes the record of stamp in dir: the same file LoadSwitchRecord reads, never a path the stamp spells out.
Types ¶
type Account ¶ added in v0.2.1
type Account struct {
Agent, Name, Dir string
}
Account is one of an agent's other accounts: its configuration folder.
type ChatTurn ¶ added in v0.2.0
type ChatTurn struct {
Seq int // its place in the whole conversation, from 0; stable as turns are added
Role string // "user", "assistant", "tool" or "note"
Text string // for a tool, its name
Detail string // for a tool, what it was used on, on one line: a file, a command
Input string // for a tool, what it was given, as a chat shows it
InputKind string // "diff" (lines marked - and +), "code", or "" for text
Output string // for a tool, what came back
Error bool // the tool failed
Done bool // the tool's result has come
Time time.Time
// contains filtered or unexported fields
}
ChatTurn is one entry of a conversation as a chat draws it: something the user typed, something the agent said, a tool it used — with what it was given and what came back — or a note (an interruption).
type ChatUpdate ¶ added in v0.2.0
ChatUpdate is what a chat is sent: the turns that are new or changed since the version it has, or — Reset — the newest turns to start again from, when it has none, or another log's (a new conversation, a file rewritten, a server restarted).
type ClaudeWriter ¶ added in v0.2.1
type ClaudeWriter struct {
Env Env
}
ClaudeWriter writes Claude Code sessions: one JSONL file in the project folder Claude keeps for dir, under $CLAUDE_CONFIG_DIR/projects or ~/.claude/projects, which `claude --resume ID` opens with its history.
Conductor kept each of the agent's stream messages (the Claude Agent SDK's) whole, so a line is that message with what Claude Code adds around it: a uuid chained to the line before by parentUuid, the session, the time, the folder and branch. A subagent's messages (the SDK's parent_tool_use_id) are sidechains with a chain of their own, as Claude Code keeps them out of the conversation it resumes.
func (ClaudeWriter) Agent ¶ added in v0.2.1
func (ClaudeWriter) Agent() string
Agent is the agent whose sessions it writes.
func (ClaudeWriter) Append ¶ added in v0.2.1
func (w ClaudeWriter) Append(ctx context.Context, im Imported, dir, sid, path, after string) (int, error)
Append adds the messages after the one with id after to the session at path, which an earlier Write made from the same conversation. The lines already written are rebuilt from the messages up to after, so the new ones chain on from them; the file is put back as it was if the write fails part way.
func (ClaudeWriter) Check ¶ added in v0.2.1
Check says whether Write would write im, writing nothing.
func (ClaudeWriter) Filed ¶ added in v0.2.1
func (w ClaudeWriter) Filed(path, cwd string) bool
Filed says whether the session at path is in the project folder Claude Code reads for cwd: the only one `claude --resume` run there looks in.
func (ClaudeWriter) Folder ¶ added in v0.2.1
func (w ClaudeWriter) Folder(cwd string) string
Folder is cwd's project folder, made or not.
func (ClaudeWriter) Move ¶ added in v0.2.1
func (w ClaudeWriter) Move(path, cwd string) (string, error)
Move puts the session at path into cwd's project folder, unchanged — one carried on keeps everything — so that `claude --resume` run in cwd finds it: a session written for a worktree since removed is otherwise found nowhere. A file already there by that name is never written over.
func (ClaudeWriter) Original ¶ added in v0.2.1
func (w ClaudeWriter) Original(id string) (path, cwd string)
Original is Claude Code's own session id, as Claude Code wrote it while another app ran it (Conductor runs Claude Code with the usual config folder): its file under any project folder, and the folder it ran in, read from its lines. Nothing for an id it has no file of, one that is not a plain name, or a file that names no folder.
func (ClaudeWriter) ReadBack ¶ added in v0.2.3
func (ClaudeWriter) ReadBack(ctx context.Context, wr Written) (Conversation, error)
ReadBack reads a session WriteConversation wrote, as conch reads any.
func (ClaudeWriter) Write ¶ added in v0.2.1
Write writes im as a new session and returns its id and file. Nothing is left behind when it fails: the file is made whole beside its place and only then moved there.
func (ClaudeWriter) WriteConversation ¶ added in v0.2.3
func (w ClaudeWriter) WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
WriteConversation writes c — another agent's conversation — as a new Claude Code session to resume in dir, and says what it wrote.
type CodexImporter ¶ added in v0.2.3
type CodexImporter struct {
Env Env
// Wait bounds the import; two minutes when zero, as /codex:transfer
// waits.
Wait time.Duration
}
CodexImporter drives Codex's own import of a Claude Code session — what its /import and OpenAI's /codex:transfer do — through `codex app-server`: externalAgentConfig/import with the session's file, then the thread id from the ledger Codex keeps of its imports ($CODEX_HOME/external_agent_session_imports.json). Codex then owns its format: it flattens Claude's tools into notes of its own and cuts their results. Codex 0.126 and later have the method; an older one answers "method not found", which is ErrNoImporter. Codex imports only from $HOME/.claude/projects (it does not read CLAUDE_CONFIG_DIR), so a session in another account's folder is ErrNoImporter too.
func (CodexImporter) Agent ¶ added in v0.2.3
func (CodexImporter) Agent() string
Agent is the agent it writes sessions for.
type CodexWriter ¶ added in v0.2.3
type CodexWriter struct {
Env Env
}
CodexWriter writes Codex sessions: a rollout under $CODEX_HOME/sessions (or ~/.codex/sessions), which `codex resume ID` opens with its history.
It is for a Codex that cannot import a Claude Code session itself, and for every other agent's conversation: Codex 0.126 and later import Claude Code's own (CodexImporter), and so own the format of what they write. The rollout is the shape every Codex reads, older ones too (Codex's own test rollout is three lines of it): a session_meta, then each message twice — a response_item, which is what the model is given back, and the user_message or agent_message event a resume shows — and commands as exec_command calls (the shell tool of Codex since unified exec became its default) with their output. Codex finds a rollout by its file name when its state database has no row for it.
func (CodexWriter) Agent ¶ added in v0.2.3
func (CodexWriter) Agent() string
Agent is the agent whose sessions it writes.
func (CodexWriter) ReadBack ¶ added in v0.2.3
func (CodexWriter) ReadBack(ctx context.Context, wr Written) (Conversation, error)
ReadBack reads a session WriteConversation wrote, as conch reads any.
func (CodexWriter) WriteConversation ¶ added in v0.2.3
func (w CodexWriter) WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
WriteConversation writes c as a new Codex session to resume in dir. Nothing is left behind when it fails.
type Conversation ¶ added in v0.2.3
type Conversation struct {
Session Session
Items []Item // oldest first
Plan *Plan // the latest plan or to-do list, if the agent kept one
// MessagesOnly says the agent's tool calls could not be read: Items
// holds only what was said.
MessagesOnly bool
}
Conversation is a saved session as no agent in particular: what was said, the commands run with their output, the files read and edited, the other tools used, and the latest plan. Another agent can be handed it whatever wrote it. Thinking and reasoning are never kept: they are signed or encrypted, and nobody else could use them.
It is built on demand from the agent's own files and kept nowhere.
func ConversationOf ¶ added in v0.2.3
func ConversationOf(s Session, turns []Turn) Conversation
ConversationOf is a conversation of messages alone, for an agent whose tool calls conch does not read.
func FitConversation ¶ added in v0.2.3
func FitConversation(c Conversation, budget int) (Conversation, int)
FitConversation keeps c within budget bytes: the first request and the latest turns whole, and the turns between shortened to their messages — the newest of them first — with a note saying how many steps were left out. A conversation within budget comes back as it was.
func ReadConversation ¶ added in v0.2.3
ReadConversation reads a saved session as a Conversation. Claude Code's, Codex's, Gemini CLI's, Qwen Code's and Copilot CLI's are read whole; every other agent's are its messages alone, from Transcript, and say so in MessagesOnly.
func (Conversation) HasMessages ¶ added in v0.2.3
func (c Conversation) HasMessages() bool
HasMessages says something was said, by either side.
func (Conversation) Turns ¶ added in v0.2.3
func (c Conversation) Turns() []Turn
Turns is what was said, as Transcript has it: an answer written in several blocks between tool calls is one turn.
type ConversationWriter ¶ added in v0.2.3
type ConversationWriter interface {
Agent() string
WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
ReadBack(ctx context.Context, w Written) (Conversation, error)
}
ConversationWriter writes another agent's conversation as a session of its own agent's, and reads one back as conch reads any.
func WriterFor ¶ added in v0.2.3
func WriterFor(agent string, env Env) ConversationWriter
WriterFor is the writer of agent's sessions in env, or nil when conch writes none: that agent is handed the Markdown document instead.
type Crossing ¶ added in v0.2.3
type Crossing struct {
Messages int `json:"messages"` // said word for word
Commands int `json:"commands"` // as the target's shell tool
Notes int `json:"notes"` // reads, edits, other tools, images
// Shortened counts the steps in the middle of a conversation too long
// for the target's context that crossed as a short message or not at
// all; Fits says none had to.
Shortened int `json:"shortened,omitempty"`
Fits bool `json:"fits"`
Bytes int `json:"bytes"`
Plan bool `json:"plan,omitempty"` // the latest plan crosses
// Left is what does not cross, as a person reads it.
Left []string `json:"left,omitempty"`
}
Crossing is what a switch carries and what it leaves behind, for a person to read before and after.
type Env ¶
type Env struct {
Home string
Getenv func(string) string
// Accounts are the agents' other accounts (internal/accounts), whose
// folders hold conversations of their own.
Accounts []Account
}
Env is where agents keep their data.
type GeminiWriter ¶ added in v0.2.3
type GeminiWriter struct {
Env Env
}
GeminiWriter writes Gemini CLI sessions: a chat file in the folder Gemini CLI keeps for the project, which `gemini --resume ID` opens with its history. It was checked against Gemini CLI 0.66.0's chatRecordingService.ts, sessionUtils.ts and projectRegistry.ts; a chat file names no version.
The file is the JSONL Gemini CLI 0.66 writes, named as it names one (session-<minute>-<first 8 of the id>.jsonl): a header with the session id and the hash of the project's folder, which Gemini checks, then a line per message — the person's as text parts, Gemini's as text with its tool calls recorded on it, each with its result, which is how Gemini's own resume turns them back into function calls and responses.
The project's folder is ~/.gemini/tmp/<short id> (or under $GEMINI_CLI_HOME), the short id from projects.json. A project Gemini CLI has not opened yet has none, and conch does not write Gemini's registry: it claims a short id the way Gemini does — a .project_root file naming the folder, which Gemini looks for when its registry has no entry — and Gemini adds it to the registry itself when it starts.
func (GeminiWriter) Agent ¶ added in v0.2.3
func (GeminiWriter) Agent() string
Agent is the agent whose sessions it writes.
func (GeminiWriter) ReadBack ¶ added in v0.2.3
func (GeminiWriter) ReadBack(ctx context.Context, wr Written) (Conversation, error)
ReadBack reads a session WriteConversation wrote, as conch reads any.
func (GeminiWriter) WriteConversation ¶ added in v0.2.3
func (w GeminiWriter) WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
WriteConversation writes c as a new Gemini CLI session to resume in dir. Nothing is left behind when it fails.
type ImportOutcome ¶ added in v0.2.1
type ImportOutcome struct {
Status ImportStatus
AgentSessionID string
Path string
Added int // messages added, for ImportAdded
Why string // for ImportCarriedOn and ImportSkipped
Err error // for ImportFailed
}
ImportOutcome is what ImportResumable did with one conversation.
func ImportPlan ¶ added in v0.2.1
func ImportPlan(im Imported, st ImportState) ImportOutcome
ImportPlan says what ImportResumable would do with im, writing nothing: ImportWritten for a conversation not imported before (which may yet fail), ImportAdded with the messages it would add, or why it would leave it alone. Cheap: no session is read, only stat'ed.
func ImportResumable ¶ added in v0.2.1
func ImportResumable(ctx context.Context, im Imported, w SessionWriter, st ImportState, now time.Time) ImportOutcome
ImportResumable makes im a session of its agent through w, or brings the one an earlier import wrote up to date, and records it in st:
- a conversation not imported before is written;
- one with new messages gets them only if the session file is as conch left it; one the person carried on with is left alone and said to be;
- nothing is ever deleted, nor written again once removed.
A conversation that cannot be written comes back ImportFailed, and st is left as it was for it.
type ImportRecord ¶ added in v0.2.1
type ImportRecord struct {
Agent string `json:"agent"`
AgentSessionID string `json:"agentSessionID"`
Path string `json:"path"`
// LastMessageID is the last of the conversation's rows the session
// holds; Size is the session file's size once conch wrote it, which
// it is still only if the agent has not written to it since.
LastMessageID string `json:"lastMessageID"`
ImportedAt time.Time `json:"importedAt"`
Size int64 `json:"size"`
// Dir is the folder it was written to resume in: the one the person
// chose (-dir) for a conversation whose own folders are gone, which
// nothing in the other app's database says. Older states have none.
Dir string `json:"dir,omitempty"`
}
ImportRecord is what an import wrote for one conversation, so that importing again adds only what is new, and never writes over what the person did with the session since.
type ImportState ¶ added in v0.2.1
type ImportState map[string]ImportRecord
ImportState maps the other app's conversation id to what was written for it: $CONCH_HOME/imports/conductor/state.json for Conductor.
func LoadImportState ¶ added in v0.2.1
func LoadImportState(path string) (ImportState, error)
LoadImportState reads the state at path; none there is an empty one. A file that cannot be read is an error, not an empty state: saved over, it would have every conversation imported a second time.
func (ImportState) Save ¶ added in v0.2.1
func (st ImportState) Save(path string) error
Save writes the state to path whole, through a file beside it.
type ImportStatus ¶ added in v0.2.1
type ImportStatus string
ImportStatus is what became of one conversation.
const ( ImportWritten ImportStatus = "written" // a new session ImportAdded ImportStatus = "added" // new messages added to the session written before ImportUnchanged ImportStatus = "unchanged" // imported before, nothing new ImportCarriedOn ImportStatus = "carried-on" // the session changed since: left alone ImportSkipped ImportStatus = "skipped" // nothing said in it ImportFailed ImportStatus = "failed" // not resumable; Err says why // ImportFound: the agent kept the conversation itself (Codex's own // rollout, written as Conductor ran it), so it resumes with nothing // written. ImportFound ImportStatus = "found" )
type Imported ¶ added in v0.2.1
type Imported struct {
Session Session
Repo string // the repository's name
Root string // the repository's folder
// Workspace is the folder the conversation ran in, which may be gone:
// Session.Dir is the nearest of it and Root that is still there.
Workspace string
// AgentSession is the agent's own id for the conversation, as
// Conductor kept it (its claude_session_id column, for every agent):
// a Codex thread id, whose rollout Codex itself wrote.
AgentSession string
Turns []Turn
// Messages are the conversation's rows as they were stored, in order:
// what a writer needs to make a session the agent resumes, which the
// handoff (Turns) leaves out — tool calls, their results, ids.
Messages []ImportedMessage
// Unread counts the agent's messages that were neither text nor a
// tool call conch knows to leave out.
Unread int
}
Imported is one conversation read from another app's store.
func ReadConductor ¶ added in v0.2.1
ReadConductor reads every conversation in a Conductor database, oldest first. The database is copied before it is read, with its write-ahead log, so a Conductor that is still open is neither locked nor written to.
type ImportedMessage ¶ added in v0.2.1
type ImportedMessage struct {
ID string
Role string // "user" or "assistant", as the row said
// Content is the row as stored: a user's prompt as typed, or one
// message of the agent's stream as JSON.
Content string
Time time.Time
}
ImportedMessage is one row of a conversation as the other app kept it.
type Item ¶ added in v0.2.3
type Item struct {
Kind Kind
// Role is who it came from: "user" or "assistant". Every tool call is
// the assistant's; an attached image is the user's.
Role string
// Text is the message, the command line, the file's path, the tool's
// name, or the note.
Text string
// Input is what an other tool was given, on one line and short.
Input string
// Output is what a command printed, its start and end kept.
Output string
// Size is how many bytes the call returned.
Size int
// Exit is a command's exit code, when Failed and it is known.
Exit int
// Failed says the call (or, for a note, the agent) reported an error.
Failed bool
// Done says the call's result has come.
Done bool
// Added and Removed count an edit's lines; Created and Deleted say it
// made or removed the whole file.
Added, Removed int
Created, Deleted bool
Time time.Time
}
Item is one step of a Conversation.
type Kind ¶ added in v0.2.3
type Kind string
Kind is what an Item is.
const ( KindMessage Kind = "message" // something the user typed or the agent said KindCommand Kind = "command" // a shell command KindRead Kind = "read" // a file read KindEdit Kind = "edit" // a file edited, written or deleted KindTool Kind = "tool" // any other tool KindNote Kind = "note" // an image attached, an interruption, an error from the agent itself )
type Plan ¶ added in v0.2.3
type Plan struct {
Text string // an explanation, or the whole plan when it has no steps
Steps []PlanStep
Time time.Time
}
Plan is an agent's plan: steps with a status, or a plan as text.
type QwenWriter ¶ added in v0.2.3
type QwenWriter struct {
Env Env
}
QwenWriter writes Qwen Code sessions: <id>.jsonl in the folder Qwen keeps for the project, <QWEN_HOME or ~/.qwen>/projects/<the folder's path, every character but a letter or digit made "-">/chats, which `qwen --resume ID` opens with its history.
A line is a record as Qwen's recorder makes one — uuid, parentUuid naming the line before (Qwen resumes the chain that ends at the last record, so a broken one loses what is above the break), sessionId, timestamp, type, cwd (Qwen checks that its hash is the project's), and a message of Gemini's shape: the person's text, the model's text with its function calls, and a tool_result for each call with the function's response. It is a plain transcript, which Qwen calls a legacy one: no managed journal is written beside it.
func (QwenWriter) Agent ¶ added in v0.2.3
func (QwenWriter) Agent() string
Agent is the agent whose sessions it writes.
func (QwenWriter) ReadBack ¶ added in v0.2.3
func (QwenWriter) ReadBack(ctx context.Context, wr Written) (Conversation, error)
ReadBack reads a session WriteConversation wrote, as conch reads any.
func (QwenWriter) WriteConversation ¶ added in v0.2.3
func (w QwenWriter) WriteConversation(ctx context.Context, c Conversation, dir string) (Written, error)
WriteConversation writes c as a new Qwen Code session to resume in dir. Nothing is left behind when it fails.
type RecordedFile ¶ added in v0.2.3
RecordedFile is a file a switch wrote and its hash then.
type Session ¶
type Session struct {
Agent string
ID string
Dir string // where it ran
Branch string // when the agent recorded it
Title string
Started time.Time
Updated time.Time
// Path is the agent's session file, or its database (OpenCode).
Path string
// Cost is what the agent said the conversation cost, and Output the
// tokens it generated; both 0 when the store doesn't say. Read from
// the tail of the store, so listing stays cheap.
Cost float64
Output int
// Account is the agent's account whose folder holds it, "" for the
// agent's own.
Account string
// contains filtered or unexported fields
}
Session is one saved agent conversation.
func List ¶
List returns the sessions that ran in any of dirs (or below them), newest first, at most limit. It asks every store itself and waits for the answer: callers of this one — search, sharing, usage — want what is there now, not what a store said a moment ago.
func ListStatus ¶ added in v0.1.3
ListStatus is List, and whether every store answered. complete is false when an agent that keeps its sessions behind another program (see slow.go) was too slow: that agent's sessions are missing from the list, which is worth asking for again in a moment.
type SessionAppender ¶ added in v0.2.1
type SessionAppender interface {
Append(ctx context.Context, im Imported, dir, agentSessionID, path, after string) (added int, err error)
}
SessionAppender adds what was said since an earlier import to the session that import wrote. after is the id of the last message that import wrote; added counts the messages it adds now.
type SessionWriter ¶ added in v0.2.1
type SessionWriter interface {
Agent() string
Write(ctx context.Context, im Imported, dir string) (agentSessionID, path string, err error)
}
SessionWriter makes a conversation imported from another app into a session of its agent's own, which that agent resumes as if it had written it. dir is the folder it resumes in: the workspace it ran in if that is still there, else the repository.
type SwitchRecord ¶ added in v0.2.3
type SwitchRecord struct {
Stamp string `json:"stamp"`
Pane string `json:"pane,omitempty"`
From string `json:"from"`
FromID string `json:"from_id"`
To string `json:"to"`
ToID string `json:"to_id"`
Time time.Time `json:"time"`
Files []RecordedFile `json:"files"`
}
SwitchRecord is what one switch wrote, so it can be undone: each file with what it held when written, and nothing else.
func LoadSwitchRecord ¶ added in v0.2.3
func LoadSwitchRecord(dir, stamp string) (SwitchRecord, error)
LoadSwitchRecord reads the record of stamp in dir.
func Record ¶ added in v0.2.3
func Record(stamp, pane string, c Conversation, wr Written) SwitchRecord
Record is what wr wrote, hashed as it is now.
func (SwitchRecord) Save ¶ added in v0.2.3
func (r SwitchRecord) Save(dir string) error
Save writes the record into dir, as STAMP.json.
func (SwitchRecord) Undo ¶ added in v0.2.3
func (r SwitchRecord) Undo() (removed, kept []string, err error)
Undo removes the files the switch wrote that are still as it wrote them. One the agent has written to since holds its own work and stays, named in kept.
type Turn ¶
Turn is one message of a saved conversation: what the user typed or what the agent answered. Tool calls, their output and reasoning are left out.
type Written ¶ added in v0.2.3
type Written struct {
Agent string `json:"agent"`
ID string `json:"id"`
Path string `json:"path"`
Files []string `json:"files"`
}
Written is a session a switch wrote: the agent's id for it, its file, and every file written for it.
func SwitchWrite ¶ added in v0.2.3
func SwitchWrite(ctx context.Context, c, fit Conversation, to string, env Env, dir string) (Written, string, error)
SwitchWrite writes the conversation c — fitted to the target's context as fit — as a session of agent to's own, for it to resume in dir. A Claude Code session going to Codex is imported by Codex itself where it can (CodexImporter), checked by reading it back; otherwise, and when that fails, conch writes it (TryWrite). via says which; an error says why nothing could be, and nothing is left behind.
func TryWrite ¶ added in v0.2.3
func TryWrite(ctx context.Context, c Conversation, w ConversationWriter, scratch func(string) ConversationWriter, dir string) (Written, error)
TryWrite writes c with w into a scratch home first and reads it back; only when that reads back whole is it written for real. A conversation that cannot be written, or reads back wrong, writes nothing, and the error says why: the caller hands the Markdown document over instead.
Source Files
¶
- antigravity.go
- antigravitychat.go
- chat.go
- claudewrite.go
- cline.go
- codexwrite.go
- conductor.go
- convclaude.go
- convcodex.go
- convcopilot.go
- conversation.go
- convgemini.go
- convqwen.go
- copilot.go
- cursor.go
- geminiwrite.go
- goose.go
- grok.go
- handoff.go
- importstate.go
- pi.go
- qwen.go
- qwenwrite.go
- sessions.go
- slow.go
- stores.go
- switch.go
- transcript.go