Available triggers
Only
repository, organization, and project are required. Requesters fill in the config when they schedule the trigger.
Add triggers to a skill
githubTriggers() and sentryTriggers() take the skill’s connection and return the triggers, and the skill picks the ones it offers. The task handler reads the event’s data:
agent.receiveOAuth(), so humans can connect their accounts.
The GitHub triggers work with either a githubConnection() or a githubAppConnection(). The Sentry trigger takes a sentryConnection() from @agentjam/sdk/sentry (agentjam.sentry in Python). After the connection, both helpers take these options:
In Python, the options are snake_case, such as
poll_interval_minutes.
How each trigger works
A new schedule only fires for events that happen after it first activates. Every event has a stable id, so an event that’s seen twice, such as by both a poll and a webhook, starts only one run.pull_request_openedfires for each newly opened pull request, oldest first. IfincludeDraftsis set, a draft pull request starts a run when it opens. Otherwise, it starts a run once it’s marked ready for review. Pull requests from forks only start runs ifincludeForksis set.pull_request_mergedfires for each pull request merged intobranch, in merge order. Ifbranchisn’t set, it watches the repository’s default branch.issue_assignedfires each time an issue is assigned toassigneeor labeled withlabel. Both are matched case-insensitively. Pull requests are left out. A schedule must setassignee,label, or both. Assigning an issue again starts another run.error_reportedfires once for each new unresolved issue in the Sentry project. An issue that regresses after being resolved doesn’t start another run. ThesentryConnection()needs theevent:read,project:read, andorg:readscopes.regionisusorde, and defaults tous.
Run sooner with GitHub webhooks
Pull request triggers can start runs as soon as GitHub delivers a webhook, rather than at the next poll. Point the GitHub App’s or repository’s webhook at your server, subscribe it to the “Pull request” event, and pass each delivery toreceiveEvents() with githubWebhooks():
githubWebhooks() verifies each delivery’s signature and responds to an invalid one with a 401. Webhook events use the same ids and data as polls, so a pull request seen both ways starts only one run. GitHub doesn’t retry a failed delivery, so the poll catches anything a webhook missed. The issue_assigned trigger only polls.
Watermark stores
For each schedule, a trigger records how far it has gotten in a watermark store. That way, a process that takes over a schedule, or a process that restarts, carries on where the last one left off. The default in-memory store is fine for tests, but it forgets its progress on restart, so schedules start over from the moment of the restart. In production, back the store with your database. A store gets and sets a small JSON object per key. In this example,github and sentry are the skills’ connections: