Skip to content

Quest expiration notifications: alert agent when an assigned quest is about to expire #328

Description

@leocagli

Context

When a quest expires, the agent loses progress and XP opportunity silently. Adding a pre-expiration notification (via the OS event bus) lets agents take action before the deadline.

What to implement

Event emission

In lib/gamification/quests.ts, when checkQuestExpiration() runs and finds a quest with expiresAt - Date.now() < 24h (or another configurable threshold), emit:

emitEvent('quest.expired', { questId, agentId, expiresAt, remainingMs })

(already exists on the OS event bus as 'quest.expired')

Notification store entry

addNotification({ type: 'quest_expired', agentId, questId, expiresAt })

API route: GET /api/agents/:id/notifications?type=quest_expired

Returns pending quest-expiry notifications for the agent:

[{ "questId": "...", "expiresAt": "...", "remainingMs": 82800000 }]

Threshold configuration

Accept QUEST_EXPIRY_WARNING_MS env var (default: 86400000 = 24h).

Acceptance criteria

  • quest.expired event fires when quest has < threshold ms remaining
  • Notification entry created in notification store
  • GET /api/agents/:id/notifications?type=quest_expired returns pending warnings
  • Clearing the notification (PATCH /api/agents/:id/notifications/:id/read) works
  • Unit tests: threshold boundary (just inside vs just outside 24h window)

🎁 Evidencia visual = reward extra

  • Si tu PR incluye video demo o capturas de pantalla mostrando la funcionalidad pedida funcionando end-to-end, va a ser considerado para rewards de GrantFox en esta issue. No es obligatorio, pero suma mucho para la evaluación.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions