Documentation
¶
Overview ¶
Package app provides multi-app (multi-tenant) management for Hector.
Each app represents an isolated workspace with its own:
- Configuration (agents, tools, LLMs)
- Data (sessions, tasks, memory)
- Authentication (JWT tokens)
Apps are stored in the database and managed via the Admin API.
Index ¶
- Constants
- Variables
- func IDFromContext(ctx context.Context) string
- func WithApp(ctx context.Context, app *App) context.Context
- func WithAppID(ctx context.Context, appID string) context.Context
- type App
- type SQLStore
- func (s *SQLStore) Create(ctx context.Context, app *App) (*App, error)
- func (s *SQLStore) Delete(ctx context.Context, id string) error
- func (s *SQLStore) Exists(ctx context.Context, id string) (bool, error)
- func (s *SQLStore) Get(ctx context.Context, id string) (*App, error)
- func (s *SQLStore) List(ctx context.Context) ([]*App, error)
- func (s *SQLStore) Update(ctx context.Context, app *App) error
- type Store
Constants ¶
View Source
const (
// AppContextKey is the context key for storing the current app.
AppContextKey contextKey = "hector_app"
)
Variables ¶
View Source
var ErrAppNotFound = fmt.Errorf("app not found")
ErrAppNotFound is returned when an app is not found.
Functions ¶
func IDFromContext ¶
IDFromContext extracts the app ID from the context. Returns "default" if no app is set.
Types ¶
type App ¶
type App struct {
// ID is the unique identifier for the app (also used as app_name/tenant_id)
ID string `json:"id"`
// Name is the human-readable display name
Name string `json:"name"`
// ConfigJSON stores the full hector configuration as JSON/YAML
ConfigJSON string `json:"config_json,omitempty"`
// CreatedAt is when the app was created
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the app was last modified
UpdatedAt time.Time `json:"updated_at"`
}
App represents a tenant/workspace in the multi-app system.
func FromContext ¶
FromContext extracts the current app from the context. Returns nil if no app is set.
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore implements Store using a SQL database.
func NewSQLStore ¶
NewSQLStore creates a new SQL-based app store.
type Store ¶
type Store interface {
// Create creates a new app and returns it with generated ID if not provided.
Create(ctx context.Context, app *App) (*App, error)
// Get retrieves an app by ID.
Get(ctx context.Context, id string) (*App, error)
// List returns all apps.
List(ctx context.Context) ([]*App, error)
// Update updates an existing app's configuration.
Update(ctx context.Context, app *App) error
// Delete removes an app by ID.
Delete(ctx context.Context, id string) error
// Exists checks if an app with the given ID exists.
Exists(ctx context.Context, id string) (bool, error)
}
Store provides CRUD operations for apps.
Click to show internal directories.
Click to hide internal directories.