hooks

package
v0.0.0-...-71c47e0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChatHook

func NewChatHook(dbInstance libdb.DBManager, chatManager *chat.Manager) taskengine.HookRepo

NewChatHook creates a new Chat hook repository instance.

func NewEchoHook

func NewEchoHook() taskengine.HookRepo

NewEchoHook creates a new instance of EchoHook.

func NewMux

NewMux creates a new Mux hook router with registered sub-hooks.

func NewSearch

func NewSearch(
	embedder embedservice.Service,
	vectorsStore vectors.Store,
	dbInstance libdb.DBManager,
) taskengine.HookRepo

func NewSimpleProvider

func NewSimpleProvider(hooks map[string]taskengine.HookRepo) taskengine.HookRepo

func NewWebCaller

func NewWebCaller(options ...WebhookOption) taskengine.HookRepo

NewWebCaller creates a new webhook caller

Types

type BridgeService

type BridgeService struct {
	Hooks   map[string]taskengine.HookRepo
	Client  *runtimesdk.Client
	BaseURL string // Gateway's internal URL (e.g., http://gateway:8080)
}

func NewBridgeService

func NewBridgeService(hooks map[string]taskengine.HookRepo, client *runtimesdk.Client, baseURL string) *BridgeService

func (*BridgeService) HandleHook

func (b *BridgeService) HandleHook(w http.ResponseWriter, r *http.Request)

func (*BridgeService) Start

func (b *BridgeService) Start(ctx context.Context) error

Start registers hooks and creates HTTP handler

type Chat

type Chat struct {
	// contains filtered or unexported fields
}

Chat implements taskengine.HookRepo and manages chat-related hooks. It enables integration of chat-based logic like appending user input, invoking LLMs, and persisting chat messages.

func (*Chat) AppendOpenAIChatToChathistory

func (h *Chat) AppendOpenAIChatToChathistory(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

func (*Chat) ConvertToOpenAIResponse

func (h *Chat) ConvertToOpenAIResponse(
	ctx context.Context,
	startTime time.Time,
	input any,
	dataType taskengine.DataType,
	transition string,
	hookCall *taskengine.HookCall,
) (any, taskengine.DataType, string, error)

func (*Chat) Exec

func (h *Chat) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

Exec resolves and runs the hook function based on the provided hook call.

func (*Chat) Supports

func (h *Chat) Supports(ctx context.Context) ([]string, error)

Supports returns the list of hook types supported by this hook repository.

type EchoHook

type EchoHook struct{}

EchoHook is a simple hook that echoes back the input arguments.

func (*EchoHook) Exec

func (e *EchoHook) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

Exec handles execution by echoing the input arguments.

func (*EchoHook) Get

Get returns the function corresponding to the hook name.

func (*EchoHook) Supports

func (e *EchoHook) Supports(ctx context.Context) ([]string, error)

Supports returns the hook types supported by this hook.

type HookCallRecord

type HookCallRecord struct {
	Args       taskengine.HookCall
	Input      any
	InputType  taskengine.DataType
	Transition string
}

type HookResponse

type HookResponse struct {
	Status     int
	Output     any
	OutputType taskengine.DataType
	Transition string
}

type MockHookRepo

type MockHookRepo struct {
	Calls           []HookCallRecord
	ResponseMap     map[string]HookResponse
	DefaultResponse HookResponse
	ErrorSequence   []error
	// contains filtered or unexported fields
}

MockHookRepo is a mock implementation of the HookProvider interface.

func NewMockHookRegistry

func NewMockHookRegistry() *MockHookRepo

NewMockHookRegistry returns a new instance of MockHookProvider.

func (*MockHookRepo) CallCount

func (m *MockHookRepo) CallCount() int

CallCount returns number of times Exec was called

func (*MockHookRepo) Exec

func (m *MockHookRepo) Exec(
	ctx context.Context,
	startingTime time.Time,
	input any,
	inputType taskengine.DataType,
	transition string,
	args *taskengine.HookCall,
) (int, any, taskengine.DataType, string, error)

Exec simulates execution of a hook call.

func (*MockHookRepo) LastCall

func (m *MockHookRepo) LastCall() *HookCallRecord

LastCall returns the most recent hook call

func (*MockHookRepo) Reset

func (m *MockHookRepo) Reset()

Reset clears all recorded calls and resets counters

func (*MockHookRepo) Supports

func (m *MockHookRepo) Supports(ctx context.Context) ([]string, error)

func (*MockHookRepo) WithErrorSequence

func (m *MockHookRepo) WithErrorSequence(errors ...error) *MockHookRepo

WithErrorSequence sets a sequence of errors to return

func (*MockHookRepo) WithResponse

func (m *MockHookRepo) WithResponse(hookType string, response HookResponse) *MockHookRepo

WithResponse configures a response for a specific hook type

type Mux

type Mux struct {
	// contains filtered or unexported fields
}

Mux implements a hook router that dispatches to sub-hooks based on command prefixes. It supports command parsing in the format: /<command> [arguments]

func (*Mux) Exec

func (m *Mux) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

Exec processes input by either routing to a sub-hook or returning unaltered input.

func (*Mux) Get

Get returns the Exec function for the mux hook.

func (*Mux) Supports

func (m *Mux) Supports(ctx context.Context) ([]string, error)

Supports returns the single hook type "command_router" that this router handles.

type Print

type Print struct {
	// contains filtered or unexported fields
}

Print implements a simple hook that returns predefined messages

func NewPrint

func NewPrint(tracker activitytracker.ActivityTracker) *Print

NewPrint creates a new Print instance

func (*Print) Exec

func (h *Print) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

func (*Print) Supports

func (h *Print) Supports(ctx context.Context) ([]string, error)
type Search struct {
	// contains filtered or unexported fields
}

func (*Search) Exec

func (h *Search) Exec(
	ctx context.Context,
	startTime time.Time,
	input any,
	dataType taskengine.DataType,
	transition string,
	hook *taskengine.HookCall,
) (any, taskengine.DataType, string, error)

Exec executes the "search" hook by performing a vector search based on the input string.

func (*Search) Supports

func (h *Search) Supports(ctx context.Context) ([]string, error)

Supports returns the list of hook names this provider supports.

type SearchResolve

type SearchResolve struct {
	// contains filtered or unexported fields
}

func NewSearchResolveHook

func NewSearchResolveHook(dbInstance libdb.DBManager) *SearchResolve

func (*SearchResolve) Exec

func (s *SearchResolve) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, args *taskengine.HookCall) (any, taskengine.DataType, string, error)

Exec implements taskengine.HookRepo.

func (*SearchResolve) Supports

func (s *SearchResolve) Supports(ctx context.Context) ([]string, error)

Supports implements taskengine.HookRepo.

type SimpleRepo

type SimpleRepo struct {
	// contains filtered or unexported fields
}

func (*SimpleRepo) Exec

func (m *SimpleRepo) Exec(ctx context.Context, startingTime time.Time, input any, dataType taskengine.DataType, transition string, args *taskengine.HookCall) (any, taskengine.DataType, string, error)

func (*SimpleRepo) Supports

func (m *SimpleRepo) Supports(ctx context.Context) ([]string, error)

type Transition

type Transition struct {
	// contains filtered or unexported fields
}

Transition simply returns a transition value without modifying input

func NewTransition

func NewTransition(transition string, tracker activitytracker.ActivityTracker) *Transition

func (*Transition) Exec

func (h *Transition) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hookCall *taskengine.HookCall) (any, taskengine.DataType, string, error)

func (*Transition) Supports

func (h *Transition) Supports(ctx context.Context) ([]string, error)

type WebCaller

type WebCaller struct {
	// contains filtered or unexported fields
}

WebCaller makes HTTP requests to external services

func (*WebCaller) Exec

func (h *WebCaller) Exec(ctx context.Context, startTime time.Time, input any, dataType taskengine.DataType, transition string, hook *taskengine.HookCall) (any, taskengine.DataType, string, error)

Exec implements the HookRepo interface

func (*WebCaller) Supports

func (h *WebCaller) Supports(ctx context.Context) ([]string, error)

type WebhookOption

type WebhookOption func(*WebCaller)

WebhookOption configures the WebhookCaller

func WithDefaultHeader

func WithDefaultHeader(key, value string) WebhookOption

WithDefaultHeader sets a default header

func WithHTTPClient

func WithHTTPClient(client *http.Client) WebhookOption

WithHTTPClient sets a custom HTTP client

Jump to

Keyboard shortcuts

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