Documentation
¶
Overview ¶
Package state maps relay conversation keys to ACP sessions and stable cwd dirs.
Index ¶
- type Agent
- type Config
- type CwdFor
- type Manager
- func (m *Manager) Agent() Agent
- func (m *Manager) Cancel(ctx context.Context, key string)
- func (m *Manager) Close() error
- func (m *Manager) GCOnce()
- func (m *Manager) GetOrCreate(ctx context.Context, key string, sink client.SessionUpdateSink) (*Session, error)
- func (m *Manager) Len() int
- func (m *Manager) Run(ctx context.Context)
- func (m *Manager) StateDir() string
- func (m *Manager) TakePendingSystemPrompt(s *Session) string
- func (m *Manager) Touch(s *Session)
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
Caps() client.Caps
NewSession(ctx context.Context, cwd string, sink client.SessionUpdateSink, systemPromptBlocks []acp.ContentBlock) (acp.SessionId, error)
ListSessions(ctx context.Context, cwd string) ([]client.SessionInfo, error)
ResumeSession(ctx context.Context, cwd string, sid acp.SessionId, sink client.SessionUpdateSink) error
Cancel(ctx context.Context, sid acp.SessionId) error
DropSession(sid acp.SessionId)
RebindSink(sid acp.SessionId, sink client.SessionUpdateSink)
}
Agent is the subset of *client.AgentProc needed by Manager.
type Config ¶
type Config struct {
Agent Agent
StateDir string
IdleTimeout time.Duration // 0 => 30 minutes
// CwdFor optionally overrides cwd layout. If nil, keys must be single safe
// path components and are stored under <StateDir>/convs/<key>.
CwdFor CwdFor
// SystemPrompt is durable per-session instruction text. If Provider is set,
// it is called for each new/resumed session and overrides SystemPrompt.
SystemPrompt string
SystemPromptProvider func() string
}
Config configures a Manager.
type CwdFor ¶
CwdFor returns and creates the stable cwd for key. A custom CwdFor is responsible for its own path validation and mkdirs. The default stores each key as one safe path component under <StateDir>/convs/<key>.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the key -> session map, stable cwd allocation, best-effort resume, and idle GC. GC drops in-memory sessions but never deletes cwd dirs.
func (*Manager) GCOnce ¶
func (m *Manager) GCOnce()
GCOnce drops stale in-memory sessions and leaves their cwd dirs intact.
func (*Manager) GetOrCreate ¶
func (m *Manager) GetOrCreate(ctx context.Context, key string, sink client.SessionUpdateSink) (*Session, error)
GetOrCreate returns an existing session for key or creates/resumes one.
func (*Manager) TakePendingSystemPrompt ¶
TakePendingSystemPrompt returns inline fallback text for the next user prompt and clears the pending flag. Call with s.Mu held.
type Session ¶
type Session struct {
Key string
SessionID acp.SessionId
Cwd string
// Mu serializes prompt submission for this session. ACP allows one
// outstanding prompt per session at a time.
Mu sync.Mutex
// contains filtered or unexported fields
}
Session holds manager-side state for one ACP session.