Summary
Add the public trigger types, factories, and registration plumbing to the Go SDK, including the WithTriggers reasoner option and app.OnEvent() / app.OnSchedule() sugar helpers.
Part of the epic #508. The CP-side scaffolding (types.TriggerBinding, ReasonerDefinition.Triggers, ReasonerDefinition.AcceptsWebhook) and the auto-set accepts_webhook=true rule already landed in #506.
Scope
New Files
| File |
Purpose |
sdk/go/triggers/triggers.go |
Context, Binding, EventOpts, ScheduleOpts, Event(...), Schedule(...) factories. Field-for-field equivalent of agentfield/triggers.py |
Modified Files
| File |
Change |
sdk/go/agent/agent.go |
WithTriggers(...Binding) reasoner option — appends to Reasoner.Triggers. WithAcceptsWebhook(string) option — sets Reasoner.AcceptsWebhook explicitly when needed |
sdk/go/agent/agent.go (sugar) |
app.OnEvent(opts EventOpts, name string, handler HandlerFunc) and app.OnSchedule(expression string, name string, handler HandlerFunc) — pure forwards to RegisterReasoner with a pre-built trigger binding |
Interface
package triggers
type Context struct {
TriggerID, Source, EventType, EventID, IdempotencyKey, VCID string
ReceivedAt time.Time
}
type Transform func(rawEvent map[string]any) any
type EventOpts struct {
Source string
Types []string
SecretEnv string
Config json.RawMessage
Transform Transform
}
type ScheduleOpts struct {
Expression string
Timezone string
Config json.RawMessage
}
type Binding struct { /* wraps types.TriggerBinding plus the (non-serialisable) Transform */ }
func Event(opts EventOpts) Binding
func Schedule(opts ScheduleOpts) Binding
agent.WithTriggers(triggers.Event(triggers.EventOpts{
Source: "stripe",
Types: []string{"payment_intent.succeeded"},
SecretEnv: "STRIPE_WEBHOOK_SECRET",
}))
Acceptance
References
Summary
Add the public trigger types, factories, and registration plumbing to the Go SDK, including the
WithTriggersreasoner option andapp.OnEvent()/app.OnSchedule()sugar helpers.Part of the epic #508. The CP-side scaffolding (
types.TriggerBinding,ReasonerDefinition.Triggers,ReasonerDefinition.AcceptsWebhook) and the auto-setaccepts_webhook=truerule already landed in #506.Scope
New Files
sdk/go/triggers/triggers.goContext,Binding,EventOpts,ScheduleOpts,Event(...),Schedule(...)factories. Field-for-field equivalent ofagentfield/triggers.pyModified Files
sdk/go/agent/agent.goWithTriggers(...Binding)reasoner option — appends toReasoner.Triggers.WithAcceptsWebhook(string)option — setsReasoner.AcceptsWebhookexplicitly when neededsdk/go/agent/agent.go(sugar)app.OnEvent(opts EventOpts, name string, handler HandlerFunc)andapp.OnSchedule(expression string, name string, handler HandlerFunc)— pure forwards toRegisterReasonerwith a pre-built trigger bindingInterface
Acceptance
go build -tags "embedded sqlite_fts5" ./...cleango vet ./...cleanRegisterReasonerwithWithTriggers(...)populatesReasoner.Triggersand round-trips throughregisterNodepayload (already plumbed in Feat universal plugin based triggers #506)app.OnEvent/app.OnScheduleproduce the same registration shape as the long-form pathcode_originderived fromruntime.Callerso the UI's Drift Card has a pathReferences
sdk/python/agentfield/triggers.pysdk/go/types/types.go(TriggerBinding,ReasonerDefinition.Triggers,ReasonerDefinition.AcceptsWebhook),sdk/go/agent/agent_register.go(auto-setaccepts_webhook),sdk/go/agent/agent_lifecycle.go(registration payload)