Documentation
¶
Index ¶
- Constants
- func UISession(next http.Handler, sessionStore *Manager, apiHandler http.Handler) http.Handler
- type ConfigWrapper
- type Env
- type Manager
- func (m *Manager) Acquire(ctx context.Context, server mcp.MessageHandler, id string) (ret *mcp.ServerSession, found bool, retErr error)
- func (m *Manager) ExtractID(req *http.Request) string
- func (m *Manager) LoadAndDelete(ctx context.Context, server mcp.MessageHandler, id string) (*mcp.ServerSession, bool, error)
- func (m *Manager) Release(session *mcp.ServerSession)
- func (m *Manager) Store(ctx context.Context, id string, session *mcp.ServerSession) error
- type ScheduledTask
- type Session
- type State
- type Store
- func (s *Store) AddWorkflowRun(ctx context.Context, sessionID, workflowURI string) error
- func (s *Store) Create(ctx context.Context, session *Session) error
- func (s *Store) CreateScheduledTask(ctx context.Context, task *ScheduledTask) error
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) DeleteScheduledTask(ctx context.Context, taskURI string) error
- func (s *Store) DeleteTokenConfig(ctx context.Context, url string) error
- func (s *Store) FindByAccount(ctx context.Context, sessionType, accountID string) ([]Session, error)
- func (s *Store) FindByPrefix(ctx context.Context, sessionIDPrefix string) ([]Session, error)
- func (s *Store) Get(ctx context.Context, id string) (*Session, error)
- func (s *Store) GetByIDByAccountID(ctx context.Context, id, accountID string) (*Session, error)
- func (s *Store) GetScheduledTask(ctx context.Context, taskURI string) (*ScheduledTask, error)
- func (s *Store) GetTokenConfig(ctx context.Context, url string) (*oauth2.Config, *oauth2.Token, error)
- func (s *Store) List(ctx context.Context) ([]Session, error)
- func (s *Store) ListScheduledTasks(ctx context.Context) ([]ScheduledTask, error)
- func (s *Store) ListWorkflowURIs(ctx context.Context, sessionIDs ...string) (map[string][]string, error)
- func (s *Store) NextScheduledTaskURI(ctx context.Context, name string) (string, error)
- func (s *Store) RecordScheduledTaskRun(ctx context.Context, taskURI string, lastRunAt time.Time, nextRunAt *time.Time) error
- func (s *Store) SetTokenConfig(ctx context.Context, url string, oauth2Config *oauth2.Config, ...) error
- func (s *Store) Update(ctx context.Context, session *Session) error
- func (s *Store) UpdateScheduledTask(ctx context.Context, task *ScheduledTask) error
- type Token
- type WorkflowRun
Constants ¶
const (
ManagerSessionKey = "sessionManager"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfigWrapper ¶
func (*ConfigWrapper) Scan ¶
func (c *ConfigWrapper) Scan(value any) error
type Manager ¶
type Manager struct {
DB *Store
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) Acquire ¶
func (m *Manager) Acquire(ctx context.Context, server mcp.MessageHandler, id string) (ret *mcp.ServerSession, found bool, retErr error)
func (*Manager) LoadAndDelete ¶
func (m *Manager) LoadAndDelete(ctx context.Context, server mcp.MessageHandler, id string) (*mcp.ServerSession, bool, error)
func (*Manager) Release ¶
func (m *Manager) Release(session *mcp.ServerSession)
type ScheduledTask ¶
type ScheduledTask struct {
gorm.Model
TaskURI string `json:"taskURI" gorm:"uniqueIndex;not null"`
Name string `json:"name"`
Prompt string `json:"prompt" gorm:"type:text"`
Schedule string `json:"schedule"`
Timezone string `json:"timezone"`
Enabled bool `json:"enabled" gorm:"not null"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
LastRunAt *time.Time `json:"lastRunAt,omitempty"`
NextRunAt *time.Time `json:"nextRunAt,omitempty" gorm:"index"`
}
ScheduledTask is the persisted definition for a scheduled chat run.
type Session ¶
type Session struct {
gorm.Model
Type string `json:"type,omitempty"`
SessionID string `json:"sessionId" gorm:"uniqueIndex;not null"`
Description string `json:"description,omitempty"`
AccountID string `json:"accountId,omitempty"`
TaskURI string `json:"taskURI,omitempty" gorm:"index"`
State State `json:"state" gorm:"type:json"`
Config ConfigWrapper `json:"config,omitempty" gorm:"type:json"`
Cwd string `json:"cwd,omitempty"`
}
type State ¶
type State mcp.SessionState
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewStoreFromDSN ¶
func (*Store) AddWorkflowRun ¶
AddWorkflowRun records a workflow run for a session and ignores duplicates.
func (*Store) CreateScheduledTask ¶
func (s *Store) CreateScheduledTask(ctx context.Context, task *ScheduledTask) error
CreateScheduledTask inserts a new scheduled task record.
func (*Store) DeleteScheduledTask ¶
DeleteScheduledTask deletes a scheduled task by its task URI.
func (*Store) DeleteTokenConfig ¶
func (*Store) FindByAccount ¶
func (*Store) FindByPrefix ¶
func (*Store) GetByIDByAccountID ¶
func (*Store) GetScheduledTask ¶
GetScheduledTask returns a scheduled task by its task URI.
func (*Store) GetTokenConfig ¶
func (*Store) ListScheduledTasks ¶
func (s *Store) ListScheduledTasks(ctx context.Context) ([]ScheduledTask, error)
ListScheduledTasks returns all scheduled tasks ordered newest-first.
func (*Store) ListWorkflowURIs ¶
func (s *Store) ListWorkflowURIs(ctx context.Context, sessionIDs ...string) (map[string][]string, error)
ListWorkflowURIs returns the URIs of the workflows that have been run in each of the given sessions.
func (*Store) NextScheduledTaskURI ¶
NextScheduledTaskURI builds the next stable task URI for the given name.
func (*Store) RecordScheduledTaskRun ¶
func (s *Store) RecordScheduledTaskRun(ctx context.Context, taskURI string, lastRunAt time.Time, nextRunAt *time.Time) error
RecordScheduledTaskRun records when a scheduled task last ran and when it will next run.
func (*Store) SetTokenConfig ¶
func (*Store) UpdateScheduledTask ¶
func (s *Store) UpdateScheduledTask(ctx context.Context, task *ScheduledTask) error
UpdateScheduledTask persists definition changes to an existing scheduled task. Only writes configuration columns — never touches LastRunAt.
type WorkflowRun ¶
type WorkflowRun struct {
SessionID string `json:"sessionId" gorm:"primaryKey;not null"`
WorkflowURI string `json:"workflowURI" gorm:"primaryKey;not null"`
}
WorkflowRun records that a workflow was executed within a session.