InitRunner

Triggers

Triggers allow agents to run automatically in response to events — cron schedules, file changes, or incoming webhooks. They are configured in spec.triggers and activated with the initrunner daemon command.

Trigger Types

TypeDescription
cronFire on a cron schedule
file_watchFire when files change in watched directories
webhookFire on incoming HTTP requests (localhost only)

Quick Example

spec:
  triggers:
    - type: cron
      schedule: "0 9 * * 1"
      prompt: "Generate weekly status report."
    - type: file_watch
      paths: ["./watched"]
      extensions: [".md", ".txt"]
      prompt_template: "File changed: {path}. Summarize the changes."
    - type: webhook
      path: /webhook
      port: 8080
      secret: ${WEBHOOK_SECRET}
initrunner daemon role.yaml

Cron Trigger

Fires the agent on a cron schedule.

triggers:
  - type: cron
    schedule: "0 9 * * 1"
    prompt: "Generate weekly status report."
    timezone: UTC
FieldTypeDefaultDescription
schedulestr(required)Cron expression (5-field: min hour day month weekday)
promptstr(required)Prompt sent to the agent when the trigger fires
timezonestr"UTC"Timezone for schedule evaluation

Schedule Examples

ExpressionMeaning
"0 9 * * 1"Every Monday at 9:00 AM
"*/5 * * * *"Every 5 minutes
"0 0 1 * *"First day of every month at midnight
"30 14 * * 1-5"Weekdays at 2:30 PM

File Watch Trigger

Fires when files change in watched directories using watchfiles.

triggers:
  - type: file_watch
    paths: ["./watched", "./data"]
    extensions: [".md", ".txt"]
    prompt_template: "File changed: {path}. Summarize."
    debounce_seconds: 1.0
    process_existing: false
FieldTypeDefaultDescription
pathslist[str](required)Directories to watch
extensionslist[str][]File extensions to filter (empty = all)
prompt_templatestr"File changed: {path}"Template with {path} placeholder
debounce_secondsfloat1.0Debounce interval
process_existingboolfalseFire once for each matching file already present on startup

Webhook Trigger

Fires when an HTTP request is received on a local endpoint. Useful for GitHub webhooks, CI/CD systems, or HTTP callbacks.

triggers:
  - type: webhook
    path: /webhook
    port: 8080
    method: POST
    secret: ${WEBHOOK_SECRET}
FieldTypeDefaultDescription
pathstr"/webhook"URL path to listen on
portint8080Port to listen on
methodstr"POST"HTTP method to accept
secretstr | nullnullHMAC secret for X-Hub-Signature-256 verification

HMAC Verification

When secret is set, requests must include a valid X-Hub-Signature-256 header (GitHub-compatible HMAC-SHA256). Invalid or missing signatures return 403 Forbidden.

Example: GitHub Webhook

triggers:
  - type: webhook
    path: /github
    port: 9000
    secret: ${GITHUB_WEBHOOK_SECRET}
curl -X POST http://127.0.0.1:9000/github \
  -H "Content-Type: application/json" \
  -H "X-Hub-Signature-256: sha256=..." \
  -d '{"action": "opened", "pull_request": {"title": "Fix bug"}}'

Daemon Mode

The initrunner daemon command starts all configured triggers and waits for events:

initrunner daemon role.yaml
initrunner daemon role.yaml --audit-db ./custom-audit.db
initrunner daemon role.yaml --no-audit
OptionTypeDefaultDescription
role_filePath(required)Path to the role YAML file
--audit-dbPath~/.initrunner/audit.dbAudit database path
--no-auditboolfalseDisable audit logging

Signal Handling

The daemon handles SIGINT (Ctrl+C) and SIGTERM for clean shutdown:

  1. Sets a stop event
  2. Stops all triggers
  3. Joins trigger threads (5-second timeout)
  4. Exits cleanly

On this page