| 1 | import type { GenerateChunkEvent } from '@shared/generation' |
| 2 | import type { RuntimeAudience, RuntimeDomain, RuntimeOwner } from '../types' |
| 3 | |
| 4 | export type ImageProgressEvent = { |
| 5 | runId: string |
| 6 | progress: number |
| 7 | label: string |
| 8 | status: 'running' | 'completed' | 'failed' | 'cancelled' |
| 9 | sessionId?: string |
| 10 | pageId?: string |
| 11 | } |
| 12 | |
| 13 | export type RuntimeEventMap = { |
| 14 | 'job.queued': { queuePosition?: number } |
| 15 | 'job.started': Record<string, never> |
| 16 | 'job.completed': { summary?: string } |
| 17 | 'job.failed': { errorCode: string; errorMessage: string } |
| 18 | 'job.cancelled': { reason: 'user' | 'timeout' | 'shutdown' } |
| 19 | 'generation.chunk': GenerateChunkEvent |
| 20 | 'image.progress': ImageProgressEvent |
| 21 | } |
| 22 | |
| 23 | export type RuntimeEventType = keyof RuntimeEventMap |
| 24 | |
| 25 | export type RuntimeEventEnvelope<K extends RuntimeEventType = RuntimeEventType> = { |
| 26 | type: K |
| 27 | payload: RuntimeEventMap[K] |
| 28 | jobId: string |
| 29 | domain: RuntimeDomain |
| 30 | owner: RuntimeOwner |
| 31 | audience: RuntimeAudience |
| 32 | occurredAt: number |
| 33 | } |
| 34 | |
| 35 | export type RuntimeEventFilter = { |
| 36 | domain?: RuntimeDomain |
| 37 | owner?: Partial<RuntimeOwner> |
| 38 | subscriberId?: string |
| 39 | } |
| 40 |