Documentation
¶
Overview ¶
Package managedbots owns the Telegram Bot API "Managed Bots" create-flow's session correlation: airlock UI button → manager-bot deep link → user creates a bot in Telegram → the manager bridge's poll loop receives ManagedBotCreated → bridge row inserted. This package handles the session row (one per Create click) the ingest path correlates the callback against by nonce.
The manager is a capability on a Telegram bridge (bridges.is_manager); its poll loop (airlock/trigger) surfaces ManagedBotCreated, which the bridges service ingests. This package only mints the session + deep link, resolving the manager bridge's username (with a live can_manage_bots check) via the injected callback.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateSessionRequest ¶
type CreateSessionRequest struct {
AgentID uuid.UUID
IsSystem bool
SuggestedName string // user-facing display name; empty falls back to "Airlock bot"
// SystemConversationID is the sysagent conversation that requested the bot
// (create_tg_bot tool). uuid.Nil for the web-UI path. When set, the
// managed_bot_created ingest routes a "bot ready" follow-up back into it.
SystemConversationID uuid.UUID
}
CreateSessionRequest is the validated payload from the API handler. Exactly one of AgentID / IsSystem must be set: a managed bot is either bound to a target agent or registered as a tenant-wide system bridge. SuggestedName is the bot's display name (passed through to Telegram via the ?name= query param on the deeplink); the suggested_username is generated server-side as the session nonce so we control the correlation key.
type Deps ¶
type Deps struct {
DB *db.DB
ManagerBridgeUsername func(ctx context.Context) (string, error)
SessionTTL time.Duration // default 15 minutes if zero
Logger *zap.Logger
}
Deps bundles construction-time dependencies. ManagerBridgeUsername is a callback (not a string) so it resolves the manager bridge's username with a LIVE can_manage_bots re-check at deep-link time — returning a descriptive error when no manager is configured or the capability was revoked. Wired to bridges.Service.ManagerBridgeUsername; a callback keeps this package free of trigger/bridges imports.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wires the persistence + authz for managed-bot sessions. The deep-link template needs the manager bot's public username, which the service reads from a callback the caller passes (rather than depending on the manager bot poller directly — keeps this package free of trigger imports).
func (*Service) CreateSession ¶
func (s *Service) CreateSession(ctx context.Context, p authz.Principal, req CreateSessionRequest) (SessionCreated, error)
CreateSession inserts a fresh managed_bot_sessions row and returns the nonce + Telegram deep link. Authz: TenantBridgeCreate plus TenantBridgeSystem if IsSystem; agent-bound sessions also require agent-admin on the target.