task
functionDeclare a background task. A task pairs a trigger with a body. The trigger is data: the host schedules it, persists its progress, and survives restarts — a `schedule` task missed while the app was closed catches up on launch, and an event task's `once` ledger never re-fires or skips an entity. The body runs in the extension host with a full TaskContext. ```ts task({ id: 'title-sessions', on: 'ai.session.statusChanged', when: e => e.previous === 'inProgress', once: true, async run({ ctx, firing }) { … }, }); task({ id: 'morning-digest', schedule: 'daily 09:00', async run({ ctx }) { … }, }); ```