Documentation
¶
Overview ¶
Package fork launches a DSH session as a child of another session in a different checkout. The child inherits the source transcript up to a chosen cut, so an Agent can keep its context while working in a new worktree without disturbing the conversation that is still running.
The package owns the fork policy — checkout separation, resume of a partially delivered child, verification that the Host honoured the checkout, draft seeding and the optional browser launch. It never writes the session store: every fact about a session comes from the caller-supplied reader.
Index ¶
Constants ¶
const DefaultTimeout = 2 * time.Minute
DefaultTimeout bounds one attempt: a long transcript can take a while to seed, and the Host composes the child Agent before it answers.
Variables ¶
var ( // ErrSourceMissing means the fork source is not a known session. ErrSourceMissing = errors.New("source session not found") // ErrSameCheckout means the child would share the source checkout and could // interfere with the Agent that is still running there. ErrSameCheckout = errors.New("fork needs a checkout different from the source session") // ErrChildElsewhere means a resumed child belongs to a different checkout. ErrChildElsewhere = errors.New("session does not belong to the selected checkout") // ErrCwdNotHonored means the Host forked into the source checkout, which only // a Host without fork-checkout support does. ErrCwdNotHonored = errors.New("fork stayed in the source checkout; update the harness that serves dsh web") )
Refusals a caller should surface verbatim; errors.Is matches all of them.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Client talks to the Host. Required; a nil HTTPClient gets one bounded by
// Timeout, because the default is too short for seeding a long transcript.
Client web.Client
// ReadSession reports a session's current checkout. Required; pass the
// caller's live-aware reader so a running Agent is seen.
ReadSession func(id string) (SessionInfo, error)
// SourceID is the session whose transcript the child inherits. Required.
SourceID string
// Cwd is the child checkout, which must differ from the source's. Required.
Cwd string
// AtSeq is the inclusive transcript cut; 0 keeps the latest completed turn.
AtSeq int64
// Resume is a child ID from an earlier partial attempt; when it still
// belongs to Cwd the fork is skipped and only the remaining steps run.
Resume string
// Draft is stored in the child composer for review and never submitted.
Draft string
// Browser selects the window opened when Open is set; web.BrowserNone skips it.
Browser string
// Open launches the child's browser window after the draft is seeded.
Open bool
// Timeout bounds the attempt; 0 uses DefaultTimeout.
Timeout time.Duration
}
Options is one fork attempt.
type Result ¶
Result reports what the attempt did. SessionID is set as soon as a child exists, even when a later step fails, so a caller can checkpoint it and retry with Resume.
type SessionInfo ¶
SessionInfo is the durable or live fact a fork needs about one session. Cwd is the session's working directory as recorded by the Host; an empty Cwd means the reader cannot tell and skips the checkout checks.