refactor(js): centralize runtime session handling (#7449)