trigger

package
v1.40.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 20 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

func ContextIDFromContext added in v1.21.0

func ContextIDFromContext(ctx context.Context) string

ContextIDFromContext retrieves the context ID from the context. Returns empty string if not set.

func WithContextID added in v1.21.0

func WithContextID(ctx context.Context, contextID string) context.Context

WithContextID returns a new context with the given context ID stored. This ID will be used as the A2A Message.ContextID for session continuity.

Types

type AgentEnqueuer added in v1.21.0

type AgentEnqueuer func(ctx context.Context, appName, agentName, input, contextID string) error

AgentEnqueuer is a function that enqueues an agent invocation for durable execution. The task is processed by the worker pool with retry support.

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. Deprecated: Use AgentEnqueuer for durable, queue-based execution.

type Option added in v1.15.1

type Option func(*WebhookHandler)

Option configures WebhookHandler.

func WithAppName added in v1.21.0

func WithAppName(appName string) Option

WithAppName sets the app name for the handler.

func WithEnqueuer added in v1.21.0

func WithEnqueuer(enqueuer AgentEnqueuer) Option

WithEnqueuer sets the enqueuer for durable async/callback execution. When set, async and callback modes will use the queue instead of direct invocation.

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(appName string, enqueuer AgentEnqueuer, metrics *observability.Metrics) *Scheduler

NewScheduler creates a new scheduler with queue-based execution.

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