hooks

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPersistentRepo

func NewPersistentRepo(
	localHooks map[string]taskengine.HookRepo,
	dbInstance libdb.DBManager,
	httpClient *http.Client,
) taskengine.HookRepo

func NewSimpleProvider

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

Types

type HookCallRecord

type HookCallRecord struct {
	Args  taskengine.HookCall
	Input any
}

HookCallRecord now only stores the arguments passed to the hook.

type HookResponse

type HookResponse struct {
	Output any
}

HookResponse is simplified to only contain the direct output.

type LangServeDirectProtocol added in v0.0.73

type LangServeDirectProtocol struct{}

func (*LangServeDirectProtocol) BuildRequest added in v0.0.73

func (p *LangServeDirectProtocol) BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

func (*LangServeDirectProtocol) ParseResponse added in v0.0.73

func (p *LangServeDirectProtocol) ParseResponse(body []byte) (any, error)

type LangServeOpenAIProtocol added in v0.0.73

type LangServeOpenAIProtocol struct{}

func (*LangServeOpenAIProtocol) BuildRequest added in v0.0.73

func (p *LangServeOpenAIProtocol) BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

func (*LangServeOpenAIProtocol) ParseResponse added in v0.0.73

func (p *LangServeOpenAIProtocol) ParseResponse(body []byte) (any, error)

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 HookRepo interface.

func NewMockHookRegistry

func NewMockHookRegistry() *MockHookRepo

NewMockHookRegistry returns a new instance of MockHookRepo.

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,
	args *taskengine.HookCall,
) (any, error)

Exec simulates execution of a hook call using the new simplified signature.

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 using the new simplified HookResponse.

type OllamaProtocol added in v0.0.73

type OllamaProtocol struct{}

func (*OllamaProtocol) BuildRequest added in v0.0.73

func (p *OllamaProtocol) BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

func (*OllamaProtocol) ParseResponse added in v0.0.73

func (p *OllamaProtocol) ParseResponse(body []byte) (any, error)

type OpenAIObjectProtocol added in v0.0.73

type OpenAIObjectProtocol struct{}

func (*OpenAIObjectProtocol) BuildRequest added in v0.0.73

func (p *OpenAIObjectProtocol) BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

func (*OpenAIObjectProtocol) ParseResponse added in v0.0.73

func (p *OpenAIObjectProtocol) ParseResponse(body []byte) (any, error)

type OpenAIProtocol added in v0.0.73

type OpenAIProtocol struct{}

func (*OpenAIProtocol) BuildRequest added in v0.0.73

func (p *OpenAIProtocol) BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

func (*OpenAIProtocol) ParseResponse added in v0.0.73

func (p *OpenAIProtocol) ParseResponse(body []byte) (any, error)

type PersistentRepo

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

func (*PersistentRepo) Exec

func (p *PersistentRepo) Exec(
	ctx context.Context,
	startingTime time.Time,
	input any,
	args *taskengine.HookCall,
) (any, error)

Exec remains the same.

func (*PersistentRepo) Supports

func (p *PersistentRepo) Supports(ctx context.Context) ([]string, error)

Supports remains the same.

type ProtocolHandler added in v0.0.73

type ProtocolHandler interface {
	// BuildRequest creates the HTTP request body for the given protocol.
	BuildRequest(toolName string, argsMap map[string]any) ([]byte, error)

	// ParseResponse extracts the meaningful output from the HTTP response body.
	ParseResponse(body []byte) (any, error)
}

ProtocolHandler defines the contract for building requests and parsing responses for a specific remote hook protocol.

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,
	args *taskengine.HookCall,
) (any, error)

Exec now implements the new, simplified HookRepo interface.

func (*SimpleRepo) Supports

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

Jump to

Keyboard shortcuts

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