Documentation
¶
Index ¶
- Variables
- func Listen(ctx context.Context, addr string) (net.Listener, error)
- func NewSourceLoader(ctx context.Context, inner config.Source, refreshInterval time.Duration) *sourceLoader
- type EventSource
- type Server
- type SessionManager
- func (sm *SessionManager) AttachRuntime(sessionID string, rt runtime.Runtime, sess *session.Session)
- func (sm *SessionManager) CreateSession(ctx context.Context, sessionTemplate *session.Session) (*session.Session, error)
- func (sm *SessionManager) DeleteSession(ctx context.Context, sessionID string) error
- func (sm *SessionManager) FollowUpSession(_ context.Context, sessionID string, messages []api.Message) error
- func (sm *SessionManager) GetAgentToolCount(ctx context.Context, agentFilename, agentName string) (int, error)
- func (sm *SessionManager) GetEventSource(sessionID string) (EventSource, bool)
- func (sm *SessionManager) GetSession(ctx context.Context, id string) (*session.Session, error)
- func (sm *SessionManager) GetSessions(ctx context.Context) ([]*session.Session, error)
- func (sm *SessionManager) RegisterEventSource(sessionID string, src EventSource)
- func (sm *SessionManager) ResumeElicitation(ctx context.Context, sessionID, action string, content map[string]any) error
- func (sm *SessionManager) ResumeSession(ctx context.Context, sessionID, confirmation, reason, toolName string) error
- func (sm *SessionManager) RunSession(ctx context.Context, sessionID, agentFilename, currentAgent string, ...) (<-chan runtime.Event, error)
- func (sm *SessionManager) SteerSession(_ context.Context, sessionID string, messages []api.Message) error
- func (sm *SessionManager) StreamEvents(ctx context.Context, sessionID string, send func(any)) bool
- func (sm *SessionManager) ToggleToolApproval(ctx context.Context, sessionID string) error
- func (sm *SessionManager) UpdateSessionPermissions(ctx context.Context, sessionID string, perms *session.PermissionsConfig) error
- func (sm *SessionManager) UpdateSessionTitle(ctx context.Context, sessionID, title string) error
Constants ¶
This section is empty.
Variables ¶
var ErrSessionBusy = errors.New("session is already processing a request")
ErrSessionBusy is returned when a session is already processing a request.
Functions ¶
Types ¶
type EventSource ¶ added in v1.58.0
EventSource pushes session events to send for the lifetime of ctx. The callback is invoked from request goroutines (e.g. an SSE handler), so it must be safe to call concurrently across requests.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewWithManager ¶ added in v1.58.0
func NewWithManager(sm *SessionManager) *Server
NewWithManager builds a Server around an already-constructed SessionManager. Useful when the runtime is owned by another component (e.g. the TUI) and only needs to be exposed over HTTP.
type SessionManager ¶
SessionManager manages sessions for HTTP and Connect-RPC servers.
func NewSessionManager ¶
func NewSessionManager(ctx context.Context, sources config.Sources, sessionStore session.Store, refreshInterval time.Duration, runConfig *config.RuntimeConfig) *SessionManager
NewSessionManager creates a new session manager.
func (*SessionManager) AttachRuntime ¶ added in v1.58.0
func (sm *SessionManager) AttachRuntime(sessionID string, rt runtime.Runtime, sess *session.Session)
AttachRuntime registers a pre-built runtime + session under sessionID so that subsequent calls (RunSession, Steer, Resume...) reuse it instead of building one from agentFilename. This is what lets a single in-process runtime be shared between the TUI and an HTTP control plane.
The internal cancellation signal is fired by SessionManager.DeleteSession; SSE streams and other lifetime-bound consumers use it (via SessionManager.StreamEvents) to terminate when the session is detached.
func (*SessionManager) CreateSession ¶
func (sm *SessionManager) CreateSession(ctx context.Context, sessionTemplate *session.Session) (*session.Session, error)
CreateSession creates a new session from a template.
func (*SessionManager) DeleteSession ¶
func (sm *SessionManager) DeleteSession(ctx context.Context, sessionID string) error
DeleteSession deletes a session by ID.
func (*SessionManager) FollowUpSession ¶ added in v1.44.0
func (sm *SessionManager) FollowUpSession(_ context.Context, sessionID string, messages []api.Message) error
FollowUpSession enqueues user messages for end-of-turn processing in a running session. Each message is popped one at a time after the current turn finishes, giving each follow-up a full undivided agent turn.
func (*SessionManager) GetAgentToolCount ¶
func (sm *SessionManager) GetAgentToolCount(ctx context.Context, agentFilename, agentName string) (int, error)
GetAgentToolCount loads the agent's team and returns the number of tools available to the given agent. When agentName is empty, it resolves to the team's default agent.
func (*SessionManager) GetEventSource ¶ added in v1.58.0
func (sm *SessionManager) GetEventSource(sessionID string) (EventSource, bool)
GetEventSource returns the registered event source for sessionID.
func (*SessionManager) GetSession ¶
GetSession retrieves a session by ID.
func (*SessionManager) GetSessions ¶
GetSessions retrieves all sessions.
func (*SessionManager) RegisterEventSource ¶ added in v1.58.0
func (sm *SessionManager) RegisterEventSource(sessionID string, src EventSource)
RegisterEventSource attaches an event source for sessionID. It is used by callers that own a runtime out-of-band (e.g. the TUI) so that HTTP clients can subscribe to events via GET /api/sessions/:id/events.
func (*SessionManager) ResumeElicitation ¶
func (sm *SessionManager) ResumeElicitation(ctx context.Context, sessionID, action string, content map[string]any) error
ResumeElicitation resumes an elicitation request.
func (*SessionManager) ResumeSession ¶
func (sm *SessionManager) ResumeSession(ctx context.Context, sessionID, confirmation, reason, toolName string) error
ResumeSession resumes a paused session with an optional rejection reason or tool name.
func (*SessionManager) RunSession ¶
func (sm *SessionManager) RunSession(ctx context.Context, sessionID, agentFilename, currentAgent string, messages []api.Message) (<-chan runtime.Event, error)
RunSession runs a session with the given messages.
func (*SessionManager) SteerSession ¶ added in v1.44.0
func (sm *SessionManager) SteerSession(_ context.Context, sessionID string, messages []api.Message) error
SteerSession enqueues user messages for mid-turn injection into a running session. The messages are picked up by the agent loop after the current tool calls finish but before the next LLM call. Returns an error if the session is not actively running or if the steer buffer is full.
func (*SessionManager) StreamEvents ¶ added in v1.58.0
StreamEvents drives the EventSource registered for sessionID, sending each event through send. It blocks until the source returns, the caller's ctx is cancelled, or the session is detached via SessionManager.DeleteSession. Returns false when no source is registered.
func (*SessionManager) ToggleToolApproval ¶
func (sm *SessionManager) ToggleToolApproval(ctx context.Context, sessionID string) error
ToggleToolApproval toggles the tool approval mode for a session.
func (*SessionManager) UpdateSessionPermissions ¶
func (sm *SessionManager) UpdateSessionPermissions(ctx context.Context, sessionID string, perms *session.PermissionsConfig) error
UpdateSessionPermissions updates the permissions for a session.
func (*SessionManager) UpdateSessionTitle ¶
func (sm *SessionManager) UpdateSessionTitle(ctx context.Context, sessionID, title string) error
UpdateSessionTitle updates the title for a session. If the session is actively running, it also updates the in-memory session object to prevent subsequent runtime saves from overwriting the title.