Documentation
¶
Overview ¶
Package sessionlink ties sessions that handle the same matter together, so each knows the others exist, what they are doing right now, and can read their latest turns — instead of a person forwarding between them.
A link comes from one of four places:
- an explicit pair in session.Meta.Links, written to both sides (Link): by an agent through wick_session_link, or by wick itself;
- a Team pairing, session.Meta.LinkedFromSession (read as a link, never rewritten here: Team routing owns that field);
- a thread an agent opened and announced with LinkThread: the session born in that thread later is linked to the one that opened it the first time either side is looked at;
- nothing else. Tickets link through Link when a session joins one.
Everything here reads and writes session files directly; callers that cache sessions refresh them afterwards.
Index ¶
- Constants
- Variables
- func IsLinked(layout config.Layout, id, peer string) bool
- func Link(layout config.Layout, a, b, why string) error
- func LinkThread(layout config.Layout, origin, channel, chatID, threadID, why string) error
- func Note(layout config.Layout, id string, now time.Time) string
- func Prompt(layout config.Layout, id string) string
- func Unlink(layout config.Layout, a, b string) error
- type Peer
- type Turn
Constants ¶
const ( StateRunning = "running" StateIdle = "idle" // StatePending: a thread was opened and announced, nobody replied in // it yet, so no session exists there. StatePending = "pending" )
Peer states.
Variables ¶
var ErrSelf = errors.New("a session cannot be linked to itself")
ErrSelf refuses linking a session to itself.
Functions ¶
func Link ¶
Link ties a and b together, on both sides. Linking an existing pair again only refreshes its reason.
func LinkThread ¶
LinkThread announces that origin opened a thread (channel "slack", chatID a channel id, threadID the new message's ts). The session a reply there starts is linked to origin the first time either is looked at.
func Note ¶
Note is the one-line [linked] block a turn of id opens with: only the linked sessions working right now, since those are the ones whose work this turn could repeat or collide with. "" when none is.
Types ¶
type Peer ¶
type Peer struct {
Session string `json:"session,omitempty"`
Title string `json:"title"`
AgentID string `json:"agent_id,omitempty"`
Why string `json:"why"`
State string `json:"state"`
LastActive time.Time `json:"last_active,omitempty"`
// Thread is "<channel>:<chat>/<thread>" for a pending thread.
Thread string `json:"thread,omitempty"`
}
Peer is one linked session as an agent or the UI sees it.