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
ContextIDFromContext retrieves the context ID from the context. Returns empty string if not set.
Types ¶
type AgentEnqueuer ¶ added in v1.21.0
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 ¶
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
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.
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.
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.