botnode

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package botnode provides Harness's native Node module for generic Bot & Group workspaces, external IM channels, and product extension hooks.

Index

Constants

View Source
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

func FormatIMPlainText(text string) string

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

func Module(opts ...Option) moduleapi.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.

func QueueContactTurn

func QueueContactTurn(ctx context.Context, host moduleapi.Host, req moduleapi.ModuleTurn) (protocol.TurnID, error)

QueueContactTurn queues a turn 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

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

type IMReplyFormatter func(ctx context.Context, host moduleapi.Host, replyText string) string

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

func WithAssociationNamespace(ns string) Option

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL