trigger

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package trigger provides scheduled and event-driven agent invocation.

The scheduler component uses cron expressions to trigger agents on a schedule without external HTTP requests.

Package trigger provides scheduled and event-driven agent invocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInvoker

type AgentInvoker func(ctx context.Context, agentName, input string) (taskID string, err error)

AgentInvoker is a function that invokes an agent with optional input. Returns the A2A task ID for tracking, or empty string if task tracking is unavailable.

type Option added in v1.15.1

type Option func(*WebhookHandler)

Option configures WebhookHandler.

func WithResultProvider added in v1.15.1

func WithResultProvider(rp func(ctx context.Context, taskID string) (string, error)) Option

WithResultProvider sets the result provider for fetching task results.

type Scheduler

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

Scheduler manages scheduled agent invocations.

func NewScheduler

func NewScheduler(invoker AgentInvoker) *Scheduler

NewScheduler creates a new scheduler.

func (*Scheduler) RegisterAgent

func (s *Scheduler) RegisterAgent(agentName string, ag agent.Agent, cfg *config.TriggerConfig) error

RegisterAgent registers an agent's trigger with the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start begins the scheduler.

func (*Scheduler) Stop

func (s *Scheduler) Stop() context.Context

Stop gracefully stops the scheduler.

type WebhookHandler added in v1.15.0

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

WebhookHandler handles incoming webhook requests and invokes agents.

func NewWebhookHandler added in v1.15.0

func NewWebhookHandler(agentName string, cfg *config.TriggerConfig, invoker AgentInvoker, opts ...Option) (*WebhookHandler, error)

NewWebhookHandler creates a new webhook handler for an agent.

func (*WebhookHandler) ServeHTTP added in v1.15.0

func (h *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles incoming webhook requests.

type WebhookPayloadContext added in v1.15.0

type WebhookPayloadContext struct {
	Body    map[string]any    `json:"body"`
	Headers map[string]string `json:"headers"`
	Query   map[string]string `json:"query"`
	Fields  map[string]any    `json:"fields"` // Extracted fields
}

WebhookPayloadContext provides data for template execution.

type WebhookResult added in v1.15.0

type WebhookResult struct {
	TaskID    string `json:"task_id,omitempty"`
	Status    string `json:"status"`
	Result    string `json:"result,omitempty"`
	Error     string `json:"error,omitempty"`
	AgentName string `json:"agent_name"`
}

WebhookResult represents the result of a webhook invocation.

Jump to

Keyboard shortcuts

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