# On Timer Event

Starts a workflow when a timer starts, reaches zero, or ends.

- Tag: `timer_event_trigger`
- Trigger node: no input socket
- Output: `output` `TimerEvent` JSON

## Config

Two independent filters. An empty array means all, and an event must pass both to start the
workflow.

- `kinds`: array of `timer`, `pomodoro`. Which kind of timer the session is.
- `event_kinds`: array of `started`, `paused`, `resumed`, `zero_reached`, `finished`, `cancelled`.

So `{"kinds": ["timer"], "event_kinds": ["zero_reached"]}` runs only when one of the workspace's own
timers reaches zero, and a trigger stating neither runs for every event of every kind.

Reaching zero reads differently per kind, and this is what the filters have to account for: a plain
timer emits `zero_reached` and keeps running into the negative, so its `finished` arrives later,
when something stops it. A pomodoro ends at zero and emits `finished` there; with auto-advance, the
session that replaces it emits its own `started`.

## Output

`TimerEvent` JSON contains:

- `type` — the event kind, one of the six above
- `session` — the whole session: `id`, `kind`, `state`, `label`, `length_seconds`, `started_at`,
  `ended_at`, `resumed_at`, `elapsed_seconds`, `zero_reached_at`, `overtime_seconds`, `note`, and
  `details` carrying what only that kind has (`{"kind": "timer", "timer": "<timer id>"}` or
  `{"kind": "pomodoro", "mode": "focus"}`)
- `elapsed_seconds`
- `remaining_seconds` — signed, and negative once a plain timer is past zero
- `occurred_at`

## Delivery behavior

- Each matching timer event starts one run, in the order the events happened, including events
  that happen while earlier runs are still going.

## Failure behavior

- A run Verdalia cannot queue is retried.
