function generateTraceId() {
    return crypto.randomUUID();
}
export function createEventEnvelope(type, payload, context) {
    return Object.freeze({
        type,
        ts: Date.now(),
        traceId: context.traceId ?? generateTraceId(),
        sessionId: context.sessionId,
        turnId: context.turnId,
        agentId: context.agentId,
        taskId: context.taskId,
        source: context.source,
        payload,
    });
}
