Documentation
¶
Overview ¶
Package botnode provides Harness's native Node module for generic Bot & Group workspaces, external IM channels, and product extension hooks.
Index ¶
- Constants
- func ContactExecutionPermission(host moduleapi.Host, target string) protocol.Permission
- func EnsureContactSession(ctx context.Context, host moduleapi.Host, target string) (protocol.SessionID, error)
- func ExternalChannelOrigin(pkg string) moduleapi.TurnOrigin
- func FormatIMPlainText(text string) string
- func IsExternalChannelTurn(inv *store.AgentInvocation) bool
- func Module(opts ...Option) moduleapi.Module
- func PostExternalMessage(ctx context.Context, host moduleapi.Host, post moduleapi.TaskDeliveryPost) (bool, error)
- func QueueContactTurn(ctx context.Context, host moduleapi.Host, req moduleapi.ModuleTurn) (protocol.TurnID, error)
- type BotService
- func (s *BotService) AllowProfileScope() bool
- func (s *BotService) Call(ctx context.Context, _ protocol.NodeID, _ protocol.RequestID, ...) (json.RawMessage, error)
- func (s *BotService) ChannelAdapter(provider string) (moduleapi.ChannelAdapter, bool)
- func (s *BotService) Close() error
- func (s *BotService) RegisterChannelAdapter(adapter moduleapi.ChannelAdapter)
- func (s *BotService) RegisteredCommands() map[string]moduleapi.CommandPolicy
- type ContactInfo
- type IMChannelStatus
- type IMCommandHandler
- type IMReplyFormatter
- type MentionCandidate
- type MentionProvider
- type Option
- func WithAssociationNamespace(ns string) Option
- func WithChannelAdapter(adapters ...moduleapi.ChannelAdapter) Option
- func WithIMCommandHandler(fn IMCommandHandler) Option
- func WithIMReplyFormatter(fn IMReplyFormatter) Option
- func WithMentionProvider(fn MentionProvider) Option
- func WithPermissionProvider(fn PermissionProvider) Option
- func WithPromptContributor(fn PromptContributor) Option
- func WithTaskOwnerResolver(...) Option
- func WithToolContributor(tc ToolContributor) Option
- func WithTurnCompletionObserver(fn TurnCompletionObserver) Option
- func WithTurnOriginMatcher(fn TurnOriginMatcher) Option
- type PermissionProvider
- type PromptContributor
- type StateSnapshot
- type ToolContributor
- type TurnCompletionObserver
- type TurnOriginMatcher
Constants ¶
const ModuleID = bot.ModuleID
ModuleID is the stable native Node module ID for Harness modules/bot.
Variables ¶
This section is empty.
Functions ¶
func ContactExecutionPermission ¶
func ContactExecutionPermission(host moduleapi.Host, target string) protocol.Permission
ContactExecutionPermission returns the configured execution permission (ask/smart/full) for a Bot or Group contact on host.
func EnsureContactSession ¶
func EnsureContactSession(ctx context.Context, host moduleapi.Host, target string) (protocol.SessionID, error)
EnsureContactSession returns the active Bot or Group desk session for target ("role:<uuid>" or "team:<uuid>"), creating one via the registered "bot" module host if none exists yet.
func ExternalChannelOrigin ¶
func ExternalChannelOrigin(pkg string) moduleapi.TurnOrigin
ExternalChannelOrigin returns the TurnOrigin label for an inbound IM channel turn.
func FormatIMPlainText ¶
FormatIMPlainText converts Desktop-oriented Markdown replies (internal sailry*:// links, HTTP links, headings, bold, and ```card JSON blocks) into clean plain text suitable for external IM channels.
func IsExternalChannelTurn ¶
func IsExternalChannelTurn(inv *store.AgentInvocation) bool
IsExternalChannelTurn reports whether inv was initiated by an external IM channel managed by Harness modules/bot.
func Module ¶
Module returns the Harness native Node module for Bot & Group workspaces, external IM channels, and product extension hooks.
func PostExternalMessage ¶
func PostExternalMessage(ctx context.Context, host moduleapi.Host, post moduleapi.TaskDeliveryPost) (bool, error)
PostExternalMessage posts an external-sender delivery into a Bot/Group contact session using the registered "bot" module host.
Types ¶
type BotService ¶
type BotService struct {
// contains filtered or unexported fields
}
BotService owns the profile-local Bot settings store, external IM channel runtime, and ChannelAdapter registry for one Node profile.
func (*BotService) AllowProfileScope ¶
func (s *BotService) AllowProfileScope() bool
func (*BotService) Call ¶
func (s *BotService) Call(ctx context.Context, _ protocol.NodeID, _ protocol.RequestID, call protocol.NativeModuleCall) (json.RawMessage, error)
Call dispatches profile-scoped native module actions for Desktop/Mobile clients.
func (*BotService) ChannelAdapter ¶
func (s *BotService) ChannelAdapter(provider string) (moduleapi.ChannelAdapter, bool)
ChannelAdapter returns a registered ChannelAdapter by provider name.
func (*BotService) Close ¶
func (s *BotService) Close() error
Close stops background IM channel workers and releases resources.
func (*BotService) RegisterChannelAdapter ¶
func (s *BotService) RegisterChannelAdapter(adapter moduleapi.ChannelAdapter)
RegisterChannelAdapter registers an external ChannelAdapter by its Provider().
func (*BotService) RegisteredCommands ¶
func (s *BotService) RegisteredCommands() map[string]moduleapi.CommandPolicy
RegisteredCommands marks state-mutating bot actions as configuration writes.
type ContactInfo ¶
type ContactInfo struct {
// Key is the canonical contact key ("role:<uuid>" or "team:<uuid>").
Key string
// Kind is "bot" for a 1-on-1 Bot desk or "group" for a multi-Bot Group desk.
Kind string
// ID is the bare role or team UUID string.
ID string
// Speaker is the active speaker role key ("role:<uuid>") when speaking in a group.
Speaker string
// IsGroupLead is true for 1-on-1 Bot chats and for the coordinator/lead of a group.
IsGroupLead bool
// GroupObserver is true when multiple group members are replying and this
// speaker is an observer rather than the action owner.
GroupObserver bool
}
ContactInfo describes the active Bot or Group contact in a native discussion.
type IMChannelStatus ¶
type IMChannelStatus = bot.IMChannelStatus
IMChannelStatus reports the live connection state of one IM channel worker.
type IMCommandHandler ¶
type IMCommandHandler func(ctx context.Context, host moduleapi.Host, channel bot.ChannelConfig, session protocol.SessionID, text string) (handled bool, replyText string, err error)
IMCommandHandler optionally intercepts an authenticated owner IM command (such as a numeric approval or task review shortcut) before it is queued as a normal conversation turn. Returning handled=true sends replyText directly.
type IMReplyFormatter ¶
IMReplyFormatter optionally enriches or transforms a Bot reply before it is converted to plain text and sent to an external IM channel.
type MentionCandidate ¶
type MentionCandidate struct {
Kind string `json:"kind"`
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
}
MentionCandidate describes one @ or # mention target contributed by a product module.
type MentionProvider ¶
type MentionProvider func(ctx context.Context, host moduleapi.Host, contact ContactInfo) ([]MentionCandidate, error)
MentionProvider returns additional mention candidates for a Bot/Group contact.
type Option ¶
type Option func(*config)
Option configures the Harness Bot Node module.
func WithAssociationNamespace ¶
WithAssociationNamespace overrides the native discussion namespace owned by modules/bot (default: "sailry-bot"). Products migrating from an earlier namespace (such as "sailry-code") may set it to preserve existing profiles.
func WithChannelAdapter ¶
func WithChannelAdapter(adapters ...moduleapi.ChannelAdapter) Option
WithChannelAdapter registers one or more external ChannelAdapters on the BotService.
func WithIMCommandHandler ¶
func WithIMCommandHandler(fn IMCommandHandler) Option
WithIMCommandHandler appends an optional handler for authenticated owner IM commands before normal Bot conversation admission.
func WithIMReplyFormatter ¶
func WithIMReplyFormatter(fn IMReplyFormatter) Option
WithIMReplyFormatter appends an optional formatter applied to IM turn replies before plain-text sanitization and outbound IM delivery.
func WithMentionProvider ¶
func WithMentionProvider(fn MentionProvider) Option
WithMentionProvider appends a mention candidate provider for Bot/Group contacts.
func WithPermissionProvider ¶
func WithPermissionProvider(fn PermissionProvider) Option
WithPermissionProvider appends a permission override/lookup hook.
func WithPromptContributor ¶
func WithPromptContributor(fn PromptContributor) Option
WithPromptContributor appends a product prompt contributor for Bot/Group turns.
func WithTaskOwnerResolver ¶
func WithTaskOwnerResolver( contactFn func(protocol.ProjectTaskOwnerSelection, protocol.ProjectTaskOwnerSelection) (protocol.ProjectTaskOwnerSelection, error), groupFn func(store.GroupTaskAssignment) (protocol.ProjectTaskOwnerSelection, error), ) Option
WithTaskOwnerResolver sets optional project-task owner resolution hooks on the Bot/Group DirectoryDiscussions registered by modules/bot.
func WithToolContributor ¶
func WithToolContributor(tc ToolContributor) Option
WithToolContributor appends a product tool contributor for Bot/Group turns.
func WithTurnCompletionObserver ¶
func WithTurnCompletionObserver(fn TurnCompletionObserver) Option
WithTurnCompletionObserver appends an observer invoked when modules/bot receives OnTurnCompleted for a Bot/Group conversation turn.
func WithTurnOriginMatcher ¶
func WithTurnOriginMatcher(fn TurnOriginMatcher) Option
WithTurnOriginMatcher appends an optional turn-origin predicate admitted on Bot/Group contact conversations.
type PermissionProvider ¶
type PermissionProvider func(ctx context.Context, host moduleapi.Host, target string) (protocol.Permission, bool)
PermissionProvider overrides or supplies the execution permission for a contact target.
type PromptContributor ¶
type PromptContributor func(ctx context.Context, host moduleapi.Host, inv *store.AgentInvocation, contact ContactInfo) ([]string, error)
PromptContributor injects additional transient system prompt sections for a Bot or Group conversation turn (for example, Sailry Code's project-task dispatch rules and project charter summary).
type StateSnapshot ¶
type StateSnapshot = bot.StateSnapshot
StateSnapshot is returned by the "get_state" native module action.
type ToolContributor ¶
type ToolContributor interface {
Catalog() []moduleapi.ToolMeta
ToolsForContact(ctx context.Context, host moduleapi.Host, inv *store.AgentInvocation, contact ContactInfo) ([]engine.Tool, error)
}
ToolContributor registers additional native tools for Bot/Group turns.
type TurnCompletionObserver ¶
type TurnCompletionObserver func(ctx context.Context, host moduleapi.Host, ev moduleapi.TurnCompletionEvent)
TurnCompletionObserver receives completed-turn notifications observed by modules/bot (for example turns queued via QueueContactTurn).
type TurnOriginMatcher ¶
type TurnOriginMatcher func(inv *store.AgentInvocation) bool
TurnOriginMatcher reports whether an invocation's TurnOrigin is authorized to run inside a Bot/Group contact conversation.